font: fix caching issues
This commit is contained in:
parent
55a4329f3e
commit
dd73e291cf
@ -51,7 +51,7 @@ PKG_CHECK_MODULES([XKBCOMMON], [xkbcommon])
|
||||
AC_SUBST(XKBCOMMON_CFLAGS)
|
||||
AC_SUBST(XKBCOMMON_LIBS)
|
||||
|
||||
PKG_CHECK_MODULES([TSM], [libtsm])
|
||||
PKG_CHECK_MODULES([TSM], [libtsm >= 4.0.0])
|
||||
AC_SUBST(TSM_CFLAGS)
|
||||
AC_SUBST(TSM_LIBS)
|
||||
|
||||
|
@ -396,7 +396,7 @@ void kmscon_font_unref(struct kmscon_font *font)
|
||||
*/
|
||||
SHL_EXPORT
|
||||
int kmscon_font_render(struct kmscon_font *font,
|
||||
uint32_t id, const uint32_t *ch, size_t len,
|
||||
uint64_t id, const uint32_t *ch, size_t len,
|
||||
const struct kmscon_glyph **out)
|
||||
{
|
||||
if (!font || !out || !ch || !len)
|
||||
|
@ -83,7 +83,7 @@ struct kmscon_font_ops {
|
||||
const struct kmscon_font_attr *attr);
|
||||
void (*destroy) (struct kmscon_font *font);
|
||||
int (*render) (struct kmscon_font *font,
|
||||
uint32_t id, const uint32_t *ch, size_t len,
|
||||
uint64_t id, const uint32_t *ch, size_t len,
|
||||
const struct kmscon_glyph **out);
|
||||
int (*render_empty) (struct kmscon_font *font,
|
||||
const struct kmscon_glyph **out);
|
||||
@ -101,7 +101,7 @@ void kmscon_font_ref(struct kmscon_font *font);
|
||||
void kmscon_font_unref(struct kmscon_font *font);
|
||||
|
||||
int kmscon_font_render(struct kmscon_font *font,
|
||||
uint32_t id, const uint32_t *ch, size_t len,
|
||||
uint64_t id, const uint32_t *ch, size_t len,
|
||||
const struct kmscon_glyph **out);
|
||||
int kmscon_font_render_empty(struct kmscon_font *font,
|
||||
const struct kmscon_glyph **out);
|
||||
|
@ -81,7 +81,7 @@ static void kmscon_font_8x16_destroy(struct kmscon_font *font)
|
||||
}
|
||||
|
||||
static int kmscon_font_8x16_render(struct kmscon_font *font,
|
||||
uint32_t id, const uint32_t *ch, size_t len,
|
||||
uint64_t id, const uint32_t *ch, size_t len,
|
||||
const struct kmscon_glyph **out)
|
||||
{
|
||||
if (len > 1 || *ch >= 256)
|
||||
|
@ -110,7 +110,7 @@ static void manager__unref()
|
||||
}
|
||||
|
||||
static int get_glyph(struct face *face, struct kmscon_glyph **out,
|
||||
uint32_t id, const uint32_t *ch, size_t len, const struct kmscon_font_attr *attr)
|
||||
uint64_t id, const uint32_t *ch, size_t len, const struct kmscon_font_attr *attr)
|
||||
{
|
||||
struct kmscon_glyph *glyph;
|
||||
PangoLayout *layout;
|
||||
@ -132,7 +132,7 @@ static int get_glyph(struct face *face, struct kmscon_glyph **out,
|
||||
|
||||
pthread_mutex_lock(&face->glyph_lock);
|
||||
res = shl_hashtable_find(face->glyphs, (void**)&glyph,
|
||||
(void*)(long)id);
|
||||
(void*)(uint64_t)id);
|
||||
pthread_mutex_unlock(&face->glyph_lock);
|
||||
if (res) {
|
||||
*out = glyph;
|
||||
@ -227,7 +227,7 @@ static int get_glyph(struct face *face, struct kmscon_glyph **out,
|
||||
pango_ft2_render_layout_line(&bitmap, line, -rec.x, face->baseline);
|
||||
|
||||
pthread_mutex_lock(&face->glyph_lock);
|
||||
ret = shl_hashtable_insert(face->glyphs, (void*)(long)id, glyph);
|
||||
ret = shl_hashtable_insert(face->glyphs, (void*)(uint64_t)id, glyph);
|
||||
pthread_mutex_unlock(&face->glyph_lock);
|
||||
if (ret) {
|
||||
log_error("cannot add glyph to hashtable");
|
||||
@ -423,7 +423,7 @@ static void kmscon_font_pango_destroy(struct kmscon_font *font)
|
||||
manager_put_face(face);
|
||||
}
|
||||
|
||||
static int kmscon_font_pango_render(struct kmscon_font *font, uint32_t id,
|
||||
static int kmscon_font_pango_render(struct kmscon_font *font, uint64_t id,
|
||||
const uint32_t *ch, size_t len,
|
||||
const struct kmscon_glyph **out)
|
||||
{
|
||||
|
@ -42,6 +42,7 @@
|
||||
#include <pthread.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <libtsm.h>
|
||||
#include "font.h"
|
||||
#include "shl_hashtable.h"
|
||||
#include "shl_log.h"
|
||||
@ -105,7 +106,7 @@ static void unfold(uint8_t *dst, uint8_t val)
|
||||
*dst = 0xff * !!val;
|
||||
}
|
||||
|
||||
static int find_glyph(uint32_t id, const struct kmscon_glyph **out)
|
||||
static int find_glyph(uint32_t ch, const struct kmscon_glyph **out)
|
||||
{
|
||||
struct kmscon_glyph *g;
|
||||
int ret;
|
||||
@ -124,21 +125,21 @@ static int find_glyph(uint32_t id, const struct kmscon_glyph **out)
|
||||
}
|
||||
} else {
|
||||
res = shl_hashtable_find(cache, (void**)out,
|
||||
(void*)(long)id);
|
||||
(void*)(uint64_t)ch);
|
||||
if (res) {
|
||||
ret = 0;
|
||||
goto out_unlock;
|
||||
}
|
||||
}
|
||||
|
||||
if (id > 0xffff) {
|
||||
if (ch > 0xffff) {
|
||||
ret = -ERANGE;
|
||||
goto out_unlock;
|
||||
}
|
||||
|
||||
start = _binary_src_font_unifont_data_bin_start;
|
||||
end = _binary_src_font_unifont_data_bin_end;
|
||||
d = &start[id];
|
||||
d = &start[ch];
|
||||
|
||||
if (d >= end) {
|
||||
ret = -ERANGE;
|
||||
@ -186,7 +187,7 @@ static int find_glyph(uint32_t id, const struct kmscon_glyph **out)
|
||||
unfold(&g->buf.data[i * 8 + 7], d->data[i] & 0x01);
|
||||
}
|
||||
|
||||
ret = shl_hashtable_insert(cache, (void*)(long)id, g);
|
||||
ret = shl_hashtable_insert(cache, (void*)(uint64_t)ch, g);
|
||||
if (ret) {
|
||||
log_error("cannot insert glyph into glyph-cache: %d", ret);
|
||||
goto err_data;
|
||||
@ -240,14 +241,14 @@ static void kmscon_font_unifont_destroy(struct kmscon_font *font)
|
||||
cache_unref();
|
||||
}
|
||||
|
||||
static int kmscon_font_unifont_render(struct kmscon_font *font, uint32_t id,
|
||||
static int kmscon_font_unifont_render(struct kmscon_font *font, uint64_t id,
|
||||
const uint32_t *ch, size_t len,
|
||||
const struct kmscon_glyph **out)
|
||||
{
|
||||
if (len > 1)
|
||||
return -ERANGE;
|
||||
|
||||
return find_glyph(id, out);
|
||||
return find_glyph(id & TSM_UCS4_MAX, out);
|
||||
}
|
||||
|
||||
static int kmscon_font_unifont_render_inval(struct kmscon_font *font,
|
||||
|
@ -381,7 +381,7 @@ int kmscon_text_prepare(struct kmscon_text *txt)
|
||||
* Returns: 0 on success or negative error code if this glyph couldn't be drawn.
|
||||
*/
|
||||
int kmscon_text_draw(struct kmscon_text *txt,
|
||||
uint32_t id, const uint32_t *ch, size_t len,
|
||||
uint64_t id, const uint32_t *ch, size_t len,
|
||||
unsigned int width,
|
||||
unsigned int posx, unsigned int posy,
|
||||
const struct tsm_screen_attr *attr)
|
||||
@ -438,7 +438,7 @@ void kmscon_text_abort(struct kmscon_text *txt)
|
||||
}
|
||||
|
||||
int kmscon_text_draw_cb(struct tsm_screen *con,
|
||||
uint32_t id, const uint32_t *ch, size_t len,
|
||||
uint64_t id, const uint32_t *ch, size_t len,
|
||||
unsigned int width,
|
||||
unsigned int posx, unsigned int posy,
|
||||
const struct tsm_screen_attr *attr,
|
||||
|
@ -68,7 +68,7 @@ struct kmscon_text_ops {
|
||||
void (*unset) (struct kmscon_text *txt);
|
||||
int (*prepare) (struct kmscon_text *txt);
|
||||
int (*draw) (struct kmscon_text *txt,
|
||||
uint32_t id, const uint32_t *ch, size_t len,
|
||||
uint64_t id, const uint32_t *ch, size_t len,
|
||||
unsigned int width,
|
||||
unsigned int posx, unsigned int posy,
|
||||
const struct tsm_screen_attr *attr);
|
||||
@ -93,7 +93,7 @@ unsigned int kmscon_text_get_rows(struct kmscon_text *txt);
|
||||
|
||||
int kmscon_text_prepare(struct kmscon_text *txt);
|
||||
int kmscon_text_draw(struct kmscon_text *txt,
|
||||
uint32_t id, const uint32_t *ch, size_t len,
|
||||
uint64_t id, const uint32_t *ch, size_t len,
|
||||
unsigned int width,
|
||||
unsigned int posx, unsigned int posy,
|
||||
const struct tsm_screen_attr *attr);
|
||||
@ -101,7 +101,7 @@ int kmscon_text_render(struct kmscon_text *txt);
|
||||
void kmscon_text_abort(struct kmscon_text *txt);
|
||||
|
||||
int kmscon_text_draw_cb(struct tsm_screen *con,
|
||||
uint32_t id, const uint32_t *ch, size_t len,
|
||||
uint64_t id, const uint32_t *ch, size_t len,
|
||||
unsigned int width,
|
||||
unsigned int posx, unsigned int posy,
|
||||
const struct tsm_screen_attr *attr,
|
||||
|
@ -62,7 +62,7 @@ static int bblit_set(struct kmscon_text *txt)
|
||||
}
|
||||
|
||||
static int bblit_draw(struct kmscon_text *txt,
|
||||
uint32_t id, const uint32_t *ch, size_t len,
|
||||
uint64_t id, const uint32_t *ch, size_t len,
|
||||
unsigned int width,
|
||||
unsigned int posx, unsigned int posy,
|
||||
const struct tsm_screen_attr *attr)
|
||||
|
@ -111,7 +111,7 @@ static void bbulk_unset(struct kmscon_text *txt)
|
||||
}
|
||||
|
||||
static int bbulk_draw(struct kmscon_text *txt,
|
||||
uint32_t id, const uint32_t *ch, size_t len,
|
||||
uint64_t id, const uint32_t *ch, size_t len,
|
||||
unsigned int width,
|
||||
unsigned int posx, unsigned int posy,
|
||||
const struct tsm_screen_attr *attr)
|
||||
|
@ -381,7 +381,7 @@ err_free:
|
||||
}
|
||||
|
||||
static int find_glyph(struct kmscon_text *txt, struct glyph **out,
|
||||
uint32_t id, const uint32_t *ch, size_t len, const struct tsm_screen_attr *attr)
|
||||
uint64_t id, const uint32_t *ch, size_t len, const struct tsm_screen_attr *attr)
|
||||
{
|
||||
struct gltex *gt = txt->data;
|
||||
struct atlas *atlas;
|
||||
@ -412,7 +412,7 @@ static int find_glyph(struct kmscon_text *txt, struct glyph **out,
|
||||
font->attr.italic = false;
|
||||
|
||||
res = shl_hashtable_find(gtable, (void**)&glyph,
|
||||
(void*)(unsigned long)id);
|
||||
(void*)(uint64_t)id);
|
||||
if (res) {
|
||||
*out = glyph;
|
||||
return 0;
|
||||
@ -515,7 +515,7 @@ static int find_glyph(struct kmscon_text *txt, struct glyph **out,
|
||||
glyph->atlas = atlas;
|
||||
glyph->texoff = atlas->fill;
|
||||
|
||||
ret = shl_hashtable_insert(gtable, (void*)(long)id, glyph);
|
||||
ret = shl_hashtable_insert(gtable, (void*)(uint64_t)id, glyph);
|
||||
if (ret)
|
||||
goto err_free;
|
||||
|
||||
@ -553,7 +553,7 @@ static int gltex_prepare(struct kmscon_text *txt)
|
||||
}
|
||||
|
||||
static int gltex_draw(struct kmscon_text *txt,
|
||||
uint32_t id, const uint32_t *ch, size_t len,
|
||||
uint64_t id, const uint32_t *ch, size_t len,
|
||||
unsigned int width,
|
||||
unsigned int posx, unsigned int posy,
|
||||
const struct tsm_screen_attr *attr)
|
||||
|
@ -262,7 +262,7 @@ static void tp_unset(struct kmscon_text *txt)
|
||||
}
|
||||
|
||||
static int find_glyph(struct kmscon_text *txt, struct tp_glyph **out,
|
||||
uint32_t id, const uint32_t *ch, size_t len, const struct tsm_screen_attr *attr)
|
||||
uint64_t id, const uint32_t *ch, size_t len, const struct tsm_screen_attr *attr)
|
||||
{
|
||||
struct tp_pixman *tp = txt->data;
|
||||
struct tp_glyph *glyph;
|
||||
@ -293,7 +293,7 @@ static int find_glyph(struct kmscon_text *txt, struct tp_glyph **out,
|
||||
font->attr.italic = false;
|
||||
|
||||
res = shl_hashtable_find(gtable, (void**)&glyph,
|
||||
(void*)(unsigned long)id);
|
||||
(void*)(uint64_t)id);
|
||||
if (res) {
|
||||
*out = glyph;
|
||||
return 0;
|
||||
@ -361,7 +361,7 @@ static int find_glyph(struct kmscon_text *txt, struct tp_glyph **out,
|
||||
goto err_free;
|
||||
}
|
||||
|
||||
ret = shl_hashtable_insert(gtable, (void*)(long)id, glyph);
|
||||
ret = shl_hashtable_insert(gtable, (void*)(uint64_t)id, glyph);
|
||||
if (ret)
|
||||
goto err_pixman;
|
||||
|
||||
@ -397,7 +397,7 @@ static int tp_prepare(struct kmscon_text *txt)
|
||||
}
|
||||
|
||||
static int tp_draw(struct kmscon_text *txt,
|
||||
uint32_t id, const uint32_t *ch, size_t len,
|
||||
uint64_t id, const uint32_t *ch, size_t len,
|
||||
unsigned int width,
|
||||
unsigned int posx, unsigned int posy,
|
||||
const struct tsm_screen_attr *attr)
|
||||
|
Loading…
x
Reference in New Issue
Block a user