From 2a967d444f11514891c5d229993d486df06c066e Mon Sep 17 00:00:00 2001 From: Harley Acheson Date: Fri, 4 Feb 2022 17:37:23 -0800 Subject: BLF: blf_glyph_cache_free Made Static blf_glyph_cache_free does not need to be public. See D13395 for more details. Differential Revision: https://developer.blender.org/D13395 Reviewed by Campbell Barton --- source/blender/blenfont/intern/blf_font.c | 9 +-------- source/blender/blenfont/intern/blf_glyph.c | 28 +++++++++++++-------------- source/blender/blenfont/intern/blf_internal.h | 1 - 3 files changed, 15 insertions(+), 23 deletions(-) (limited to 'source/blender/blenfont') diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index 14d3a208f69..c03cdc3d16d 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -1318,12 +1318,7 @@ FontBLF *blf_font_new_from_mem(const char *name, const unsigned char *mem, int m void blf_font_free(FontBLF *font) { - BLI_spin_lock(&blf_glyph_cache_mutex); - GlyphCacheBLF *gc; - - while ((gc = BLI_pophead(&font->cache))) { - blf_glyph_cache_free(gc); - } + blf_glyph_cache_clear(font); if (font->kerning_cache) { MEM_freeN(font->kerning_cache); @@ -1337,8 +1332,6 @@ void blf_font_free(FontBLF *font) MEM_freeN(font->name); } MEM_freeN(font); - - BLI_spin_unlock(&blf_glyph_cache_mutex); } /** \} */ diff --git a/source/blender/blenfont/intern/blf_glyph.c b/source/blender/blenfont/intern/blf_glyph.c index 4f25f99b65c..b87a784adff 100644 --- a/source/blender/blenfont/intern/blf_glyph.c +++ b/source/blender/blenfont/intern/blf_glyph.c @@ -122,20 +122,7 @@ void blf_glyph_cache_release(FontBLF *font) BLI_spin_unlock(font->glyph_cache_mutex); } -void blf_glyph_cache_clear(FontBLF *font) -{ - GlyphCacheBLF *gc; - - BLI_spin_lock(font->glyph_cache_mutex); - - while ((gc = BLI_pophead(&font->cache))) { - blf_glyph_cache_free(gc); - } - - BLI_spin_unlock(font->glyph_cache_mutex); -} - -void blf_glyph_cache_free(GlyphCacheBLF *gc) +static void blf_glyph_cache_free(GlyphCacheBLF *gc) { GlyphBLF *g; for (uint i = 0; i < ARRAY_SIZE(gc->bucket); i++) { @@ -152,6 +139,19 @@ void blf_glyph_cache_free(GlyphCacheBLF *gc) MEM_freeN(gc); } +void blf_glyph_cache_clear(FontBLF *font) +{ + GlyphCacheBLF *gc; + + BLI_spin_lock(font->glyph_cache_mutex); + + while ((gc = BLI_pophead(&font->cache))) { + blf_glyph_cache_free(gc); + } + + BLI_spin_unlock(font->glyph_cache_mutex); +} + /** * Try to find a glyph in cache. * diff --git a/source/blender/blenfont/intern/blf_internal.h b/source/blender/blenfont/intern/blf_internal.h index 4e36f522981..04b7a3ca13b 100644 --- a/source/blender/blenfont/intern/blf_internal.h +++ b/source/blender/blenfont/intern/blf_internal.h @@ -148,7 +148,6 @@ 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); /** * Create (or load from cache) a fully-rendered bitmap glyph. -- cgit v1.2.3