forked from external/yambar
font: remove lock (all rendering happens in the main thread)
This commit is contained in:
parent
b3a5e0b5d7
commit
54797ffbd8
2 changed files with 1 additions and 11 deletions
11
font.c
11
font.c
|
@ -63,8 +63,6 @@ font_destroy_no_free(struct font *font)
|
||||||
mtx_unlock(&ft_lock);
|
mtx_unlock(&ft_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
mtx_destroy(&font->lock);
|
|
||||||
|
|
||||||
if (font->fc_pattern != NULL)
|
if (font->fc_pattern != NULL)
|
||||||
FcPatternDestroy(font->fc_pattern);
|
FcPatternDestroy(font->fc_pattern);
|
||||||
if (font->fc_fonts != NULL)
|
if (font->fc_fonts != NULL)
|
||||||
|
@ -235,7 +233,6 @@ from_font_set(FcPattern *pattern, FcFontSet *fonts, int start_idx,
|
||||||
int descent = ft_face->size->metrics.descender / 64;
|
int descent = ft_face->size->metrics.descender / 64;
|
||||||
int ascent = ft_face->size->metrics.ascender / 64;
|
int ascent = ft_face->size->metrics.ascender / 64;
|
||||||
|
|
||||||
mtx_init(&font->lock, mtx_plain);
|
|
||||||
font->face = ft_face;
|
font->face = ft_face;
|
||||||
font->load_flags = load_flags | FT_LOAD_COLOR;
|
font->load_flags = load_flags | FT_LOAD_COLOR;
|
||||||
font->render_flags = render_flags;
|
font->render_flags = render_flags;
|
||||||
|
@ -522,20 +519,16 @@ err:
|
||||||
const struct glyph *
|
const struct glyph *
|
||||||
font_glyph_for_wc(struct font *font, wchar_t wc)
|
font_glyph_for_wc(struct font *font, wchar_t wc)
|
||||||
{
|
{
|
||||||
mtx_lock(&font->lock);
|
|
||||||
|
|
||||||
assert(font->cache != NULL);
|
assert(font->cache != NULL);
|
||||||
size_t hash_idx = hash_index(wc);
|
size_t hash_idx = hash_index(wc);
|
||||||
hash_entry_t *hash_entry = font->cache[hash_idx];
|
hash_entry_t *hash_entry = font->cache[hash_idx];
|
||||||
|
|
||||||
if (hash_entry != NULL) {
|
if (hash_entry != NULL) {
|
||||||
tll_foreach(*hash_entry, it) {
|
tll_foreach(*hash_entry, it) {
|
||||||
if (it->item.wc == wc) {
|
if (it->item.wc == wc)
|
||||||
mtx_unlock(&font->lock);
|
|
||||||
return it->item.valid ? &it->item : NULL;
|
return it->item.valid ? &it->item : NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
struct glyph glyph;
|
struct glyph glyph;
|
||||||
bool got_glyph = glyph_for_wchar(font, wc, &glyph);
|
bool got_glyph = glyph_for_wchar(font, wc, &glyph);
|
||||||
|
@ -549,8 +542,6 @@ font_glyph_for_wc(struct font *font, wchar_t wc)
|
||||||
|
|
||||||
assert(hash_entry != NULL);
|
assert(hash_entry != NULL);
|
||||||
tll_push_back(*hash_entry, glyph);
|
tll_push_back(*hash_entry, glyph);
|
||||||
|
|
||||||
mtx_unlock(&font->lock);
|
|
||||||
return got_glyph ? &tll_back(*hash_entry) : NULL;
|
return got_glyph ? &tll_back(*hash_entry) : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
1
font.h
1
font.h
|
@ -59,7 +59,6 @@ struct font {
|
||||||
} strikeout;
|
} strikeout;
|
||||||
|
|
||||||
hash_entry_t **cache;
|
hash_entry_t **cache;
|
||||||
mtx_t lock;
|
|
||||||
|
|
||||||
bool is_fallback;
|
bool is_fallback;
|
||||||
int ref_counter;
|
int ref_counter;
|
||||||
|
|
Loading…
Add table
Reference in a new issue