[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [33344] trunk/blender: added option to turn off Text anti-aliasing in the UI

Michael Fox mfoxdogg at gmail.com
Fri Nov 26 23:12:46 CET 2010


Revision: 33344
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=33344
Author:   mfoxdogg
Date:     2010-11-26 23:12:46 +0100 (Fri, 26 Nov 2010)

Log Message:
-----------
added option to turn off Text anti-aliasing in the UI
(userpref->system), with a great help from brecht (its been way too long
for me).

However as brecht pointed out that the non-AA text is slightly lareger
then AA'ed Text :S, i did not do anything about this as this commit was
just the option not the text drawing.

this commit also makes it possible to do all kinds of UI textrender options

Modified Paths:
--------------
    trunk/blender/release/scripts/ui/space_userpref.py
    trunk/blender/source/blender/blenfont/BLF_api.h
    trunk/blender/source/blender/blenfont/intern/blf.c
    trunk/blender/source/blender/blenfont/intern/blf_glyph.c
    trunk/blender/source/blender/blenfont/intern/blf_internal.h
    trunk/blender/source/blender/makesdna/DNA_userdef_types.h
    trunk/blender/source/blender/makesrna/SConscript
    trunk/blender/source/blender/makesrna/intern/CMakeLists.txt
    trunk/blender/source/blender/makesrna/intern/Makefile
    trunk/blender/source/blender/makesrna/intern/SConscript
    trunk/blender/source/blender/makesrna/intern/rna_userdef.c

Modified: trunk/blender/release/scripts/ui/space_userpref.py
===================================================================
--- trunk/blender/release/scripts/ui/space_userpref.py	2010-11-26 18:13:27 UTC (rev 33343)
+++ trunk/blender/release/scripts/ui/space_userpref.py	2010-11-26 22:12:46 UTC (rev 33344)
@@ -429,6 +429,8 @@
         #col.prop(system, "use_antialiasing")
         col.label(text="Window Draw Method:")
         col.prop(system, "window_draw_method", text="")
+        col.label(text="Text Draw Options:")
+        col.prop(system, "use_text_antialiasing")
         col.label(text="Textures:")
         col.prop(system, "gl_texture_limit", text="Limit Size")
         col.prop(system, "texture_time_out", text="Time Out")

Modified: trunk/blender/source/blender/blenfont/BLF_api.h
===================================================================
--- trunk/blender/source/blender/blenfont/BLF_api.h	2010-11-26 18:13:27 UTC (rev 33343)
+++ trunk/blender/source/blender/blenfont/BLF_api.h	2010-11-26 22:12:46 UTC (rev 33344)
@@ -34,6 +34,8 @@
 int BLF_init(int points, int dpi);
 void BLF_exit(void);
 
+void BLF_cache_clear(void);
+
 int BLF_load(const char *name);
 int BLF_load_mem(const char *name, unsigned char *mem, int mem_size);
 

Modified: trunk/blender/source/blender/blenfont/intern/blf.c
===================================================================
--- trunk/blender/source/blender/blenfont/intern/blf.c	2010-11-26 18:13:27 UTC (rev 33343)
+++ trunk/blender/source/blender/blenfont/intern/blf.c	2010-11-26 22:12:46 UTC (rev 33344)
@@ -103,6 +103,18 @@
 	blf_font_exit();
 }
 
+void BLF_cache_clear(void)
+{
+	FontBLF *font;
+	int i;
+
+	for (i= 0; i < global_font_num; i++) {
+		font= global_font[i];
+		if (font)
+			blf_glyph_cache_clear(font);
+	}
+}
+
 static int blf_search(const char *name)
 {
 	FontBLF *font;

Modified: trunk/blender/source/blender/blenfont/intern/blf_glyph.c
===================================================================
--- trunk/blender/source/blender/blenfont/intern/blf_glyph.c	2010-11-26 18:13:27 UTC (rev 33343)
+++ trunk/blender/source/blender/blenfont/intern/blf_glyph.c	2010-11-26 22:12:46 UTC (rev 33344)
@@ -41,6 +41,7 @@
 #include "MEM_guardedalloc.h"
 
 #include "DNA_vec_types.h"
+#include "DNA_userdef_types.h"
 
 #include "BLI_blenlib.h"
 
@@ -115,6 +116,23 @@
 	return(gc);
 }
 
+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 (gc->bucket[i].first) {
+				g= gc->bucket[i].first;
+				BLI_remlink(&(gc->bucket[i]), g);
+				blf_glyph_free(g);
+			}
+		}
+	}
+}
+
 void blf_glyph_cache_free(GlyphCacheBLF *gc)
 {
 	GlyphBLF *g;
@@ -193,12 +211,10 @@
 	GlyphBLF *g;
 	FT_Error err;
 	FT_Bitmap bitmap, tempbitmap;
-	int sharp;
+	int sharp = (U.text_render & USER_TEXT_DISABLE_AA);
 	FT_BBox bbox;
 	unsigned int key;
 
-	sharp = 0; /* TODO make the value be configurable somehow */
-
 	g= blf_glyph_search(font->glyph_cache, c);
 	if (g)
 		return(g);

Modified: trunk/blender/source/blender/blenfont/intern/blf_internal.h
===================================================================
--- trunk/blender/source/blender/blenfont/intern/blf_internal.h	2010-11-26 18:13:27 UTC (rev 33343)
+++ trunk/blender/source/blender/blenfont/intern/blf_internal.h	2010-11-26 22:12:46 UTC (rev 33344)
@@ -56,6 +56,7 @@
 
 GlyphCacheBLF *blf_glyph_cache_find(FontBLF *font, int size, int dpi);
 GlyphCacheBLF *blf_glyph_cache_new(FontBLF *font);
+void blf_glyph_cache_clear(FontBLF *font);
 void blf_glyph_cache_free(GlyphCacheBLF *gc);
 
 GlyphBLF *blf_glyph_search(GlyphCacheBLF *gc, unsigned int c);

Modified: trunk/blender/source/blender/makesdna/DNA_userdef_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_userdef_types.h	2010-11-26 18:13:27 UTC (rev 33343)
+++ trunk/blender/source/blender/makesdna/DNA_userdef_types.h	2010-11-26 22:12:46 UTC (rev 33344)
@@ -376,6 +376,9 @@
 	
 	short autokey_mode;		/* autokeying mode */
 	short autokey_flag;		/* flags for autokeying */
+	
+	short text_render, pad9;		/*options for text rendering*/
+	float pad10;
 
 	struct ColorBand coba_weight;	/* from texture.h */
 
@@ -531,6 +534,9 @@
 #define USER_DRAW_AUTOMATIC		3
 #define USER_DRAW_OVERLAP_FLIP	4
 
+/* text draw options*/
+#define USER_TEXT_DISABLE_AA	(1 << 0)
+
 /* tw_flag (transform widget) */
 
 /* gp_settings (Grease Pencil Settings) */

Modified: trunk/blender/source/blender/makesrna/SConscript
===================================================================
--- trunk/blender/source/blender/makesrna/SConscript	2010-11-26 18:13:27 UTC (rev 33343)
+++ trunk/blender/source/blender/makesrna/SConscript	2010-11-26 22:12:46 UTC (rev 33344)
@@ -7,7 +7,7 @@
 objs += o
 
 incs = '#/intern/guardedalloc #/intern/memutil #/intern/audaspace/intern ../blenkernel ../blenlib ../makesdna intern .'
-incs += ' ../windowmanager ../editors/include ../gpu ../imbuf ../ikplugin'
+incs += ' ../windowmanager ../editors/include ../gpu ../imbuf ../ikplugin ../blenfont'
 incs += ' ../render/extern/include'
 
 defs = []

Modified: trunk/blender/source/blender/makesrna/intern/CMakeLists.txt
===================================================================
--- trunk/blender/source/blender/makesrna/intern/CMakeLists.txt	2010-11-26 18:13:27 UTC (rev 33343)
+++ trunk/blender/source/blender/makesrna/intern/CMakeLists.txt	2010-11-26 22:12:46 UTC (rev 33344)
@@ -54,6 +54,7 @@
 	../../makesdna
 	../../blenkernel
 	../../blenlib
+	../../blenfont
 	../../ikplugin
 	../../windowmanager
 	../../editors/include

Modified: trunk/blender/source/blender/makesrna/intern/Makefile
===================================================================
--- trunk/blender/source/blender/makesrna/intern/Makefile	2010-11-26 18:13:27 UTC (rev 33343)
+++ trunk/blender/source/blender/makesrna/intern/Makefile	2010-11-26 22:12:46 UTC (rev 33344)
@@ -52,6 +52,7 @@
 CPPFLAGS += -I../../../../intern/audaspace/intern
 CPPFLAGS += -I../../blenlib
 CPPFLAGS += -I../../blenkernel
+CPPFLAGS += -I../../blenfont
 CPPFLAGS += -I../../imbuf
 CPPFLAGS += -I../../ikplugin
 CPPFLAGS += -I../../makesdna

Modified: trunk/blender/source/blender/makesrna/intern/SConscript
===================================================================
--- trunk/blender/source/blender/makesrna/intern/SConscript	2010-11-26 18:13:27 UTC (rev 33343)
+++ trunk/blender/source/blender/makesrna/intern/SConscript	2010-11-26 22:12:46 UTC (rev 33344)
@@ -31,7 +31,7 @@
 
 incs = '#/intern/guardedalloc ../../blenlib ../../blenkernel'
 incs += ' ../../imbuf ../../makesdna ../../makesrna ../../ikplugin'
-incs += ' ../../windowmanager ../../editors/include'
+incs += ' ../../windowmanager ../../editors/include ../../blenfont'
 incs += ' ../../render/extern/include'
 incs += ' #/intern/audaspace/intern '
 

Modified: trunk/blender/source/blender/makesrna/intern/rna_userdef.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_userdef.c	2010-11-26 18:13:27 UTC (rev 33343)
+++ trunk/blender/source/blender/makesrna/intern/rna_userdef.c	2010-11-26 22:12:46 UTC (rev 33344)
@@ -44,14 +44,18 @@
 
 #ifdef RNA_RUNTIME
 
-#include "BKE_main.h"
+#include "DNA_object_types.h"
+#include "DNA_screen_types.h"
+
 #include "BKE_DerivedMesh.h"
 #include "BKE_depsgraph.h"
-#include "DNA_object_types.h"
-#include "DNA_screen_types.h"
-#include "GPU_draw.h"
 #include "BKE_global.h"
+#include "BKE_main.h"
 
+#include "GPU_draw.h"
+
+#include "BLF_api.h"
+
 #include "MEM_guardedalloc.h"
 #include "MEM_CacheLimiterC-Api.h"
 
@@ -254,6 +258,12 @@
 	BLI_where_is_temp(btempdir, 1);
 }
 
+static void rna_userdef_text_update(Main *bmain, Scene *scene, PointerRNA *ptr)
+{
+	BLF_cache_clear();
+	WM_main_add_notifier(NC_WINDOW, NULL);
+}
+
 #else
 
 static void rna_def_userdef_theme_ui_font_style(BlenderRNA *brna)
@@ -2575,6 +2585,11 @@
 	RNA_def_property_range(prop, 50, 1000);
 	RNA_def_property_ui_text(prop, "Wait Timer (ms)", "Time in milliseconds between each frame recorded for screencast");
 
+	prop= RNA_def_property(srna, "use_text_antialiasing", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_negative_sdna(prop, NULL, "text_render", USER_TEXT_DISABLE_AA);
+	RNA_def_property_ui_text(prop, "Text Anti-aliasing", "Draw user interface text anti-aliased");
+	RNA_def_property_update(prop, 0, "rna_userdef_text_update");
+	
 #if 0
 	prop= RNA_def_property(srna, "verse_master", PROP_STRING, PROP_NONE);
 	RNA_def_property_string_sdna(prop, NULL, "versemaster");





More information about the Bf-blender-cvs mailing list