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!
This commit is contained in:
Mike Erwin 2016-10-15 19:40:41 -04:00
parent 878938f203
commit a8dc3f4596
6 changed files with 21 additions and 0 deletions

View File

@ -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);

View File

@ -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)
{

View File

@ -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;

View File

@ -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
}

View File

@ -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;

View File

@ -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},