From a8dc3f4596ef5aed70ceeaa7e3029cb782a0f0ef Mon Sep 17 00:00:00 2001 From: Mike Erwin Date: Sat, 15 Oct 2016 19:40:41 -0400 Subject: [PATCH] BLF: make blurry text an optional (disabled) feature While trying to simplify text drawing, noticed no Blender code uses the blur feature. Hopefully scripts don't use it! --- source/blender/blenfont/BLF_api.h | 6 ++++++ source/blender/blenfont/intern/blf.c | 2 ++ source/blender/blenfont/intern/blf_font.c | 2 ++ source/blender/blenfont/intern/blf_glyph.c | 5 +++++ source/blender/blenfont/intern/blf_internal_types.h | 2 ++ source/blender/python/generic/blf_py_api.c | 4 ++++ 6 files changed, 21 insertions(+) diff --git a/source/blender/blenfont/BLF_api.h b/source/blender/blenfont/BLF_api.h index 1f38d64924c..3da0434687c 100644 --- a/source/blender/blenfont/BLF_api.h +++ b/source/blender/blenfont/BLF_api.h @@ -34,6 +34,9 @@ #include "BLI_compiler_attrs.h" +/* enable this only if needed (unused circa 2016) */ +#define BLF_BLUR_ENABLE 0 + struct rctf; struct ColorManagedDisplay; struct ResultBLF; @@ -144,7 +147,10 @@ void BLF_rotation(int fontid, float angle); void BLF_clipping(int fontid, float xmin, float ymin, float xmax, float ymax); void BLF_clipping_default(float xmin, float ymin, float xmax, float ymax); void BLF_wordwrap(int fontid, int wrap_width); + +#if BLF_BLUR_ENABLE void BLF_blur(int fontid, int size); +#endif void BLF_enable(int fontid, int option); void BLF_disable(int fontid, int option); diff --git a/source/blender/blenfont/intern/blf.c b/source/blender/blenfont/intern/blf.c index 7ddc540044a..f42057a8475 100644 --- a/source/blender/blenfont/intern/blf.c +++ b/source/blender/blenfont/intern/blf.c @@ -455,6 +455,7 @@ void BLF_size(int fontid, int size, int dpi) } } +#if BLF_BLUR_ENABLE void BLF_blur(int fontid, int size) { FontBLF *font = blf_get(fontid); @@ -463,6 +464,7 @@ void BLF_blur(int fontid, int size) font->blur = size; } } +#endif void BLF_draw_default(float x, float y, float z, const char *str, size_t len) { diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index 42717e65d9b..cac3b86b249 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -951,7 +951,9 @@ static void blf_font_fill(FontBLF *font) font->size = 0; BLI_listbase_clear(&font->cache); font->glyph_cache = NULL; +#if BLF_BLUR_ENABLE font->blur = 0; +#endif font->max_tex_size = -1; font->buf_info.fbuf = NULL; diff --git a/source/blender/blenfont/intern/blf_glyph.c b/source/blender/blenfont/intern/blf_glyph.c index 3d96260f61b..a74210cf961 100644 --- a/source/blender/blenfont/intern/blf_glyph.c +++ b/source/blender/blenfont/intern/blf_glyph.c @@ -490,6 +490,7 @@ void blf_glyph_render(FontBLF *font, GlyphBLF *g, float x, float y) } } +#if BLF_BLUR_ENABLE switch (font->blur) { case 3: blf_texture3_draw(font->orig_col, g->uv, rect.xmin, rect.ymin, rect.xmax, rect.ymax); @@ -501,4 +502,8 @@ void blf_glyph_render(FontBLF *font, GlyphBLF *g, float x, float y) immAttrib4fv(BLF_COLOR_ID, font->orig_col); blf_texture_draw(g->uv, rect.xmin, rect.ymin, rect.xmax, rect.ymax); } +#else + immAttrib4fv(BLF_COLOR_ID, font->orig_col); + blf_texture_draw(g->uv, rect.xmin, rect.ymin, rect.xmax, rect.ymax); +#endif } diff --git a/source/blender/blenfont/intern/blf_internal_types.h b/source/blender/blenfont/intern/blf_internal_types.h index 0fac576a8cc..26d7fd3adac 100644 --- a/source/blender/blenfont/intern/blf_internal_types.h +++ b/source/blender/blenfont/intern/blf_internal_types.h @@ -175,8 +175,10 @@ typedef struct FontBLF { /* angle in radians. */ float angle; +#if BLF_BLUR_ENABLE /* blur: 3 or 5 large kernel */ int blur; +#endif /* shadow level. */ int shadow; diff --git a/source/blender/python/generic/blf_py_api.c b/source/blender/python/generic/blf_py_api.c index 69f1e297b43..02bd1fdbe39 100644 --- a/source/blender/python/generic/blf_py_api.c +++ b/source/blender/python/generic/blf_py_api.c @@ -114,6 +114,7 @@ static PyObject *py_blf_aspect(PyObject *UNUSED(self), PyObject *args) } +#if BLF_BLUR_ENABLE PyDoc_STRVAR(py_blf_blur_doc, ".. function:: blur(fontid, radius)\n" "\n" @@ -135,6 +136,7 @@ static PyObject *py_blf_blur(PyObject *UNUSED(self), PyObject *args) Py_RETURN_NONE; } +#endif PyDoc_STRVAR(py_blf_draw_doc, @@ -418,7 +420,9 @@ static PyObject *py_blf_unload(PyObject *UNUSED(self), PyObject *args) /*----------------------------MODULE INIT-------------------------*/ static PyMethodDef BLF_methods[] = { {"aspect", (PyCFunction) py_blf_aspect, METH_VARARGS, py_blf_aspect_doc}, +#if BLF_BLUR_ENABLE {"blur", (PyCFunction) py_blf_blur, METH_VARARGS, py_blf_blur_doc}, +#endif {"clipping", (PyCFunction) py_blf_clipping, METH_VARARGS, py_blf_clipping_doc}, {"word_wrap", (PyCFunction) py_blf_word_wrap, METH_VARARGS, py_blf_word_wrap_doc}, {"disable", (PyCFunction) py_blf_disable, METH_VARARGS, py_blf_disable_doc},