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>2021-11-06 08:26:09 +0300
committerCampbell Barton <ideasman42@gmail.com>2021-11-06 08:28:02 +0300
commit81baeec59ba530c53f8db253bb0289825aef2f82 (patch)
tree840790ac1bd1d69f8ddae68e4ac099d288521b71 /source/blender/blenfont/intern
parenta804a11db100883b15d100b1566f545a81a099cc (diff)
Cleanup: remove window_manager & editor includes from BLF
Remove the need to include the window manager & editor functions in low level font rendering code. - The default font size is now set when changed in the preferences. - Flushing cache is set as a callback.
Diffstat (limited to 'source/blender/blenfont/intern')
-rw-r--r--source/blender/blenfont/intern/blf_default.c16
-rw-r--r--source/blender/blenfont/intern/blf_font.c19
2 files changed, 23 insertions, 12 deletions
diff --git a/source/blender/blenfont/intern/blf_default.c b/source/blender/blenfont/intern/blf_default.c
index 2bac0bf8904..57eeaa6768d 100644
--- a/source/blender/blenfont/intern/blf_default.c
+++ b/source/blender/blenfont/intern/blf_default.c
@@ -29,8 +29,6 @@
#include "BLF_api.h"
-#include "UI_interface.h"
-
#include "blf_internal.h"
/* call BLF_default_set first! */
@@ -39,12 +37,19 @@
/* Default size and dpi, for BLF_draw_default. */
static int global_font_default = -1;
static int global_font_dpi = 72;
+/* Keep in sync with `UI_style_get()->widgetlabel.points` */
+static int global_font_size = 11;
void BLF_default_dpi(int dpi)
{
global_font_dpi = dpi;
}
+void BLF_default_size(int size)
+{
+ global_font_size = size;
+}
+
void BLF_default_set(int fontid)
{
if ((fontid == -1) || blf_font_id_is_valid(fontid)) {
@@ -62,8 +67,7 @@ int BLF_set_default(void)
{
ASSERT_DEFAULT_SET;
- const uiStyle *style = UI_style_get();
- BLF_size(global_font_default, style->widgetlabel.points, global_font_dpi);
+ BLF_size(global_font_default, global_font_size, global_font_dpi);
return global_font_default;
}
@@ -71,9 +75,7 @@ int BLF_set_default(void)
void BLF_draw_default(float x, float y, float z, const char *str, const size_t str_len)
{
ASSERT_DEFAULT_SET;
-
- const uiStyle *style = UI_style_get();
- BLF_size(global_font_default, style->widgetlabel.points, global_font_dpi);
+ BLF_size(global_font_default, global_font_size, global_font_dpi);
BLF_position(global_font_default, x, y, z);
BLF_draw(global_font_default, str, str_len);
}
diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c
index a2c778fcf16..d536a0b8486 100644
--- a/source/blender/blenfont/intern/blf_font.c
+++ b/source/blender/blenfont/intern/blf_font.c
@@ -50,8 +50,6 @@
#include "BLF_api.h"
-#include "UI_interface.h"
-
#include "GPU_batch.h"
#include "GPU_matrix.h"
@@ -72,6 +70,9 @@ static FT_Library ft_lib;
static SpinLock ft_lib_mutex;
static SpinLock blf_glyph_cache_mutex;
+/* May be set to #UI_widgetbase_draw_cache_flush. */
+static void (*blf_draw_cache_flush)(void) = NULL;
+
/* -------------------------------------------------------------------- */
/** \name FreeType Utilities (Internal)
* \{ */
@@ -255,10 +256,10 @@ void blf_batch_draw(void)
GPU_blend(GPU_BLEND_ALPHA);
-#ifndef BLF_STANDALONE
/* We need to flush widget base first to ensure correct ordering. */
- UI_widgetbase_draw_cache_flush();
-#endif
+ if (blf_draw_cache_flush != NULL) {
+ blf_draw_cache_flush();
+ }
GPUTexture *texture = blf_batch_cache_texture_load();
GPU_vertbuf_data_len_set(g_batch.verts, g_batch.glyph_len);
@@ -1167,6 +1168,14 @@ void blf_font_exit(void)
blf_batch_draw_exit();
}
+/**
+ * Optional cache flushing function, called before #blf_batch_draw.
+ */
+void BLF_cache_flush_set_fn(void (*cache_flush_fn)(void))
+{
+ blf_draw_cache_flush = cache_flush_fn;
+}
+
/** \} */
/* -------------------------------------------------------------------- */