[Bf-blender-cvs] [a780e7f] master: BLF: Fix for changing the DPI storing many fonts (300+)

Campbell Barton noreply at git.blender.org
Thu Jan 16 17:13:35 CET 2014


Commit: a780e7f3f09ffec99600a518a17b219b5aaee2c6
Author: Campbell Barton
Date:   Fri Jan 17 03:04:46 2014 +1100
https://developer.blender.org/rBa780e7f3f09ffec99600a518a17b219b5aaee2c6

BLF: Fix for changing the DPI storing many fonts (300+)

Each dpi value stores its own set of font sizes, so while dragging the
dpi value would collect many sizes and never free.

Also change how BLF_cache_clear works,
it was freeing memory but not the OpenGL textures.

Now just free all the cache and GL textures and let drawing allocate them again as needed.

===================================================================

M	source/blender/blenfont/intern/blf_glyph.c
M	source/blender/makesrna/intern/rna_userdef.c

===================================================================

diff --git a/source/blender/blenfont/intern/blf_glyph.c b/source/blender/blenfont/intern/blf_glyph.c
index 637f534..248c645 100644
--- a/source/blender/blenfont/intern/blf_glyph.c
+++ b/source/blender/blenfont/intern/blf_glyph.c
@@ -121,17 +121,9 @@ GlyphCacheBLF *blf_glyph_cache_new(FontBLF *font)
 void blf_glyph_cache_clear(FontBLF *font)
 {
 	GlyphCacheBLF *gc;
-	GlyphBLF *g;
-	int i;
-
-	for (gc = font->cache.first; gc; gc = gc->next) {
-		for (i = 0; i < 257; i++) {
-			while ((g = BLI_pophead(&gc->bucket[i]))) {
-				blf_glyph_free(g);
-			}
-		}
 
-		memset(gc->glyph_ascii_table, 0, sizeof(gc->glyph_ascii_table));
+	while ((gc = BLI_pophead(&font->cache))) {
+		blf_glyph_cache_free(gc);
 	}
 }
 
diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c
index f4cb470..7b5c269 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -111,6 +111,9 @@ static void rna_userdef_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Pointe
 /* also used by buffer swap switching */
 static void rna_userdef_dpi_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *UNUSED(ptr))
 {
+	/* font's are stored at each DPI level, without this we can easy load 100's of fonts */
+	BLF_cache_clear();
+
 	BKE_userdef_state();
 	WM_main_add_notifier(NC_WINDOW, NULL);      /* full redraw */
 	WM_main_add_notifier(NC_SCREEN | NA_EDITED, NULL);    /* refresh region sizes */




More information about the Bf-blender-cvs mailing list