Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2018-07-31 09:57:05 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-07-31 09:57:05 +0300
commit21f61cbe73a1bc24d2e74b82b039ea5f36c960a5 (patch)
treeb2949478a021e3d36b58edfe1b3523486495839e
parent18888b7b0c3556d3a2177fe7693fda02bf2a8cb5 (diff)
BLF: replace global aa pref w/ monochrome flag
Now disabling anti-aliasing doesn't impact sequencer, render stamp etc.
-rw-r--r--source/blender/blenfont/BLF_api.h4
-rw-r--r--source/blender/blenfont/intern/blf.c11
-rw-r--r--source/blender/blenfont/intern/blf_glyph.c11
-rw-r--r--source/blender/editors/interface/interface_style.c7
-rw-r--r--source/blender/makesrna/intern/rna_userdef.c8
-rw-r--r--source/blender/python/generic/blf_py_api.c1
-rw-r--r--source/blender/windowmanager/intern/wm_files.c2
7 files changed, 16 insertions, 28 deletions
diff --git a/source/blender/blenfont/BLF_api.h b/source/blender/blenfont/BLF_api.h
index eafcf74b611..9bb3dd39aa6 100644
--- a/source/blender/blenfont/BLF_api.h
+++ b/source/blender/blenfont/BLF_api.h
@@ -44,9 +44,6 @@ void BLF_exit(void);
void BLF_default_dpi(int dpi);
void BLF_default_set(int fontid);
-void BLF_antialias_set(bool enabled);
-bool BLF_antialias_get(void);
-
void BLF_cache_clear(void);
int BLF_load(const char *name) ATTR_NONNULL();
@@ -223,6 +220,7 @@ void BLF_state_print(int fontid);
#define BLF_ASPECT (1 << 5)
#define BLF_HINTING (1 << 6)
#define BLF_WORD_WRAP (1 << 7)
+#define BLF_MONOCHROME (1 << 8) /* no-AA */
#define BLF_DRAW_STR_DUMMY_MAX 1024
diff --git a/source/blender/blenfont/intern/blf.c b/source/blender/blenfont/intern/blf.c
index 2a8fc14f4ae..75aabf1f713 100644
--- a/source/blender/blenfont/intern/blf.c
+++ b/source/blender/blenfont/intern/blf.c
@@ -84,7 +84,6 @@ static FontBLF *global_font[BLF_MAX_FONT] = {NULL};
static int global_font_default = -1;
static int global_font_points = 11;
static int global_font_dpi = 72;
-static bool global_use_antialias = true;
/* XXX, should these be made into global_font_'s too? */
int blf_mono_font = -1;
@@ -176,16 +175,6 @@ void BLF_default_set(int fontid)
}
}
-void BLF_antialias_set(bool enabled)
-{
- global_use_antialias = enabled;
-}
-
-bool BLF_antialias_get(void)
-{
- return global_use_antialias;
-}
-
int BLF_load(const char *name)
{
FontBLF *font;
diff --git a/source/blender/blenfont/intern/blf_glyph.c b/source/blender/blenfont/intern/blf_glyph.c
index 9af347908e1..f1301d38ab6 100644
--- a/source/blender/blenfont/intern/blf_glyph.c
+++ b/source/blender/blenfont/intern/blf_glyph.c
@@ -221,7 +221,6 @@ GlyphBLF *blf_glyph_add(FontBLF *font, unsigned int index, unsigned int c)
GlyphBLF *g;
FT_Error err;
FT_Bitmap bitmap, tempbitmap;
- const bool is_sharp = !BLF_antialias_get();
int flags = FT_LOAD_TARGET_NORMAL | FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP;
FT_BBox bbox;
unsigned int key;
@@ -246,10 +245,12 @@ GlyphBLF *blf_glyph_add(FontBLF *font, unsigned int index, unsigned int c)
if (font->flags & BLF_HINTING)
flags &= ~FT_LOAD_NO_HINTING;
- if (is_sharp)
+ if (font->flags & BLF_MONOCHROME) {
err = FT_Load_Glyph(font->face, (FT_UInt)index, FT_LOAD_TARGET_MONO);
- else
+ }
+ else {
err = FT_Load_Glyph(font->face, (FT_UInt)index, flags);
+ }
if (err) {
BLI_spin_unlock(font->ft_lib_mutex);
@@ -259,7 +260,7 @@ GlyphBLF *blf_glyph_add(FontBLF *font, unsigned int index, unsigned int c)
/* get the glyph. */
slot = font->face->glyph;
- if (is_sharp) {
+ if (font->flags & BLF_MONOCHROME) {
err = FT_Render_Glyph(slot, FT_RENDER_MODE_MONO);
/* Convert result from 1 bit per pixel to 8 bit per pixel */
@@ -288,7 +289,7 @@ GlyphBLF *blf_glyph_add(FontBLF *font, unsigned int index, unsigned int c)
g->height = (int)bitmap.rows;
if (g->width && g->height) {
- if (is_sharp) {
+ if (font->flags & BLF_MONOCHROME) {
/* Font buffer uses only 0 or 1 values, Blender expects full 0..255 range */
int i;
for (i = 0; i < (g->width * g->height); i++) {
diff --git a/source/blender/editors/interface/interface_style.c b/source/blender/editors/interface/interface_style.c
index 9a09ae67601..0257fb0d428 100644
--- a/source/blender/editors/interface/interface_style.c
+++ b/source/blender/editors/interface/interface_style.c
@@ -531,6 +531,13 @@ void uiStyleInit(void)
flag_disable |= BLF_HINTING;
}
+ if (U.text_render & USER_TEXT_DISABLE_AA) {
+ flag_enable |= BLF_MONOCHROME;
+ }
+ else {
+ flag_disable |= BLF_MONOCHROME;
+ }
+
for (font = U.uifonts.first; font; font = font->next) {
if (font->blf_id != -1) {
BLF_enable(font->blf_id, flag_enable);
diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c
index 739303e20ea..315ac26c1d2 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -451,12 +451,6 @@ static void rna_userdef_text_update(Main *UNUSED(bmain), Scene *UNUSED(scene), P
WM_main_add_notifier(NC_WINDOW, NULL);
}
-static void rna_userdef_text_antialiasing_update(Main *bmain, Scene *scene, PointerRNA *ptr)
-{
- BLF_antialias_set((U.text_render & USER_TEXT_DISABLE_AA) == 0);
- rna_userdef_text_update(bmain, scene, ptr);
-}
-
static PointerRNA rna_Theme_space_generic_get(PointerRNA *ptr)
{
return rna_pointer_inherit_refine(ptr, &RNA_ThemeSpaceGeneric, ptr->data);
@@ -4211,7 +4205,7 @@ static void rna_def_userdef_system(BlenderRNA *brna)
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_antialiasing_update");
+ RNA_def_property_update(prop, 0, "rna_userdef_text_update");
prop = RNA_def_property(srna, "use_text_hinting", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "text_render", USER_TEXT_DISABLE_HINTING);
diff --git a/source/blender/python/generic/blf_py_api.c b/source/blender/python/generic/blf_py_api.c
index 629335888e4..7d124966334 100644
--- a/source/blender/python/generic/blf_py_api.c
+++ b/source/blender/python/generic/blf_py_api.c
@@ -461,6 +461,7 @@ PyObject *BPyInit_blf(void)
PyModule_AddIntConstant(submodule, "SHADOW", BLF_SHADOW);
PyModule_AddIntConstant(submodule, "KERNING_DEFAULT", BLF_KERNING_DEFAULT);
PyModule_AddIntConstant(submodule, "WORD_WRAP", BLF_WORD_WRAP);
+ PyModule_AddIntConstant(submodule, "MONOCHROME", BLF_MONOCHROME);
return submodule;
}
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index 19b48e3f79e..a802c695dd1 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -343,8 +343,6 @@ static void wm_init_userdef(Main *bmain, const bool read_userdef_from_memory)
/* update tempdir from user preferences */
BKE_tempdir_init(U.tempdir);
-
- BLF_antialias_set((U.text_render & USER_TEXT_DISABLE_AA) == 0);
}