diff options
author | Richard Antalik <richardantalik@gmail.com> | 2019-09-14 03:22:42 +0300 |
---|---|---|
committer | Richard Antalik <richardantalik@gmail.com> | 2019-09-14 03:24:42 +0300 |
commit | a960dc451930796ca310cc88f00fb701374b2f7f (patch) | |
tree | 3bd2b69426bc36605792718e5b44e2917ac49427 /source/blender/blenfont/intern/blf_internal.h | |
parent | ab3a9dc1ed28d44bd71f5e255da74ef4d6f1fdbf (diff) |
BLF: make library glyph cache handling thread-safe
Functions that utilize glyph cache should lock and unlock cache by
calling `blf_glyph_cache_acquire()` and `blf_glyph_cache_release()`.
Function `blf_glyph_cache_acquire()` will create glyph cache, if it doesn't exist.
Locking mutex is global and shared by all fonts.
Reviewed By: brecht
Differential Revision: https://developer.blender.org/D5701
Diffstat (limited to 'source/blender/blenfont/intern/blf_internal.h')
-rw-r--r-- | source/blender/blenfont/intern/blf_internal.h | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/source/blender/blenfont/intern/blf_internal.h b/source/blender/blenfont/intern/blf_internal.h index cfc1d245a11..efcf9e15100 100644 --- a/source/blender/blenfont/intern/blf_internal.h +++ b/source/blender/blenfont/intern/blf_internal.h @@ -93,6 +93,10 @@ void blf_font_width_and_height(struct FontBLF *font, float blf_font_width(struct FontBLF *font, const char *str, size_t len, struct ResultBLF *r_info); float blf_font_height(struct FontBLF *font, const char *str, size_t len, struct ResultBLF *r_info); float blf_font_fixed_width(struct FontBLF *font); +int blf_font_height_max(struct FontBLF *font); +int blf_font_width_max(struct FontBLF *font); +float blf_font_descender(struct FontBLF *font); +float blf_font_ascender(struct FontBLF *font); int blf_font_count_missing_chars(struct FontBLF *font, const char *str, @@ -102,21 +106,27 @@ int blf_font_count_missing_chars(struct FontBLF *font, void blf_font_free(struct FontBLF *font); struct KerningCacheBLF *blf_kerning_cache_find(struct FontBLF *font); -struct KerningCacheBLF *blf_kerning_cache_new(struct FontBLF *font); +struct KerningCacheBLF *blf_kerning_cache_new(struct FontBLF *font, struct GlyphCacheBLF *gc); void blf_kerning_cache_clear(struct FontBLF *font); struct GlyphCacheBLF *blf_glyph_cache_find(struct FontBLF *font, unsigned int size, unsigned int dpi); struct GlyphCacheBLF *blf_glyph_cache_new(struct FontBLF *font); +struct GlyphCacheBLF *blf_glyph_cache_acquire(struct FontBLF *font); +void blf_glyph_cache_release(struct FontBLF *font); void blf_glyph_cache_clear(struct FontBLF *font); void blf_glyph_cache_free(struct GlyphCacheBLF *gc); struct GlyphBLF *blf_glyph_search(struct GlyphCacheBLF *gc, unsigned int c); -struct GlyphBLF *blf_glyph_add(struct FontBLF *font, unsigned int index, unsigned int c); +struct GlyphBLF *blf_glyph_add(struct FontBLF *font, + struct GlyphCacheBLF *gc, + unsigned int index, + unsigned int c); void blf_glyph_free(struct GlyphBLF *g); -void blf_glyph_render(struct FontBLF *font, struct GlyphBLF *g, float x, float y); +void blf_glyph_render( + struct FontBLF *font, struct GlyphCacheBLF *gc, struct GlyphBLF *g, float x, float y); #ifdef WIN32 /* blf_font_win32_compat.c */ |