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>2019-03-05 18:34:30 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-03-05 18:42:53 +0300
commita4540116ba828c5b6f9b350fe28ae03eaf1d381e (patch)
tree8e18726c50c116343b51c00fc13031f2d5dfc9b3 /source/blender/draw/intern/draw_manager_text.c
parent301bcf771dec827138412ca6e7a25e2269eb5e9e (diff)
DRW: use memiter for on screen text allocation
Avoid allocation for each string, improves redraw speed for text heavy views. A contrived test showed FPS ~18.5% speedup but this doesn't represent typical usage.
Diffstat (limited to 'source/blender/draw/intern/draw_manager_text.c')
-rw-r--r--source/blender/draw/intern/draw_manager_text.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/source/blender/draw/intern/draw_manager_text.c b/source/blender/draw/intern/draw_manager_text.c
index 82bee3f8b8e..eff3688589c 100644
--- a/source/blender/draw/intern/draw_manager_text.c
+++ b/source/blender/draw/intern/draw_manager_text.c
@@ -22,10 +22,9 @@
#include "MEM_guardedalloc.h"
-#include "BLI_listbase.h"
+#include "BLI_memiter.h"
#include "BLI_math.h"
-
#include "GPU_matrix.h"
#include "ED_screen.h"
@@ -39,7 +38,6 @@
#include "draw_manager_text.h"
typedef struct ViewCachedString {
- struct ViewCachedString *next, *prev;
float vec[3];
union {
uchar ub[4];
@@ -55,18 +53,19 @@ typedef struct ViewCachedString {
} ViewCachedString;
typedef struct DRWTextStore {
- ListBase list;
+ BLI_memiter *cache_strings;
} DRWTextStore;
DRWTextStore *DRW_text_cache_create(void)
{
DRWTextStore *dt = MEM_callocN(sizeof(*dt), __func__);
+ dt->cache_strings = BLI_memiter_create(1 << 14); /* 16kb */
return dt;
}
void DRW_text_cache_destroy(struct DRWTextStore *dt)
{
- BLI_freelistN(&dt->list);
+ BLI_memiter_destroy(dt->cache_strings);
MEM_freeN(dt);
}
@@ -88,9 +87,7 @@ void DRW_text_cache_add(
alloc_len = str_len + 1;
}
- vos = MEM_mallocN(sizeof(ViewCachedString) + alloc_len, __func__);
-
- BLI_addtail(&dt->list, vos);
+ vos = BLI_memiter_alloc(dt->cache_strings, sizeof(ViewCachedString) + alloc_len);
copy_v3_v3(vos->vec, co);
copy_v4_v4_uchar(vos->col.ub, col);
@@ -115,7 +112,9 @@ void DRW_text_cache_draw(DRWTextStore *dt, ARegion *ar)
int tot = 0;
/* project first and test */
- for (vos = dt->list.first; vos; vos = vos->next) {
+ BLI_memiter_handle it;
+ BLI_memiter_iter_init(dt->cache_strings, &it);
+ while ((vos = BLI_memiter_iter_step(&it))) {
if (ED_view3d_project_short_ex(
ar,
(vos->flag & DRW_TEXT_CACHE_GLOBALSPACE) ? rv3d->persmat : rv3d->persmatob,
@@ -150,7 +149,8 @@ void DRW_text_cache_draw(DRWTextStore *dt, ARegion *ar)
BLF_size(font_id, style->widget.points * U.pixelsize, U.dpi);
- for (vos = dt->list.first; vos; vos = vos->next) {
+ BLI_memiter_iter_init(dt->cache_strings, &it);
+ while ((vos = BLI_memiter_iter_step(&it))) {
if (vos->sco[0] != IS_CLIPPED) {
if (col_pack_prev != vos->col.pack) {
BLF_color4ubv(font_id, vos->col.ub);