diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-04-17 09:14:07 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-04-17 10:04:28 +0400 |
commit | 3e3efae7e9420817a6fe35545d97568a69e2ce7c (patch) | |
tree | b6702eea72f629be453795e317fbcc22c3692535 /source/blender/editors/space_nla | |
parent | 1b9db9911d9cbcb81d58277084b9c4c5daf84e8a (diff) |
Viewport Text Drawing: replace single allocs with a memarena
- pass label strlen since in many cases its already known.
- use single linked list for cached text drawing.
- add BLI_link_utils.h for single linked list macros.
own tests give approx 22% overall speedup.
Diffstat (limited to 'source/blender/editors/space_nla')
-rw-r--r-- | source/blender/editors/space_nla/nla_draw.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/source/blender/editors/space_nla/nla_draw.c b/source/blender/editors/space_nla/nla_draw.c index cf01ebd6976..46fd32541cb 100644 --- a/source/blender/editors/space_nla/nla_draw.c +++ b/source/blender/editors/space_nla/nla_draw.c @@ -428,16 +428,17 @@ static void nla_draw_strip_text(AnimData *adt, NlaTrack *nlt, NlaStrip *strip, i { short notSolo = ((adt && (adt->flag & ADT_NLA_SOLO_TRACK)) && (nlt->flag & NLATRACK_SOLO) == 0); char str[256]; + size_t str_len; char col[4]; float xofs; rctf rect; /* just print the name and the range */ if (strip->flag & NLASTRIP_FLAG_TEMP_META) { - BLI_snprintf(str, sizeof(str), "%d) Temp-Meta", index); + str_len = BLI_snprintf(str, sizeof(str), "%d) Temp-Meta", index); } else { - BLI_strncpy(str, strip->name, sizeof(str)); + str_len = BLI_strncpy_rlen(str, strip->name, sizeof(str)); } /* set text color - if colors (see above) are light, draw black text, otherwise draw white */ @@ -470,7 +471,7 @@ static void nla_draw_strip_text(AnimData *adt, NlaTrack *nlt, NlaStrip *strip, i rect.ymax = ymaxc; /* add this string to the cache of texts to draw */ - UI_view2d_text_cache_rectf(v2d, &rect, str, col); + UI_view2d_text_cache_rectf(v2d, &rect, str, str_len, col); } /* add frame extents to cache of text-strings to draw in pixelspace @@ -480,7 +481,8 @@ static void nla_draw_strip_frames_text(NlaTrack *UNUSED(nlt), NlaStrip *strip, V { const float ytol = 1.0f; /* small offset to vertical positioning of text, for legibility */ const char col[4] = {220, 220, 220, 255}; /* light gray */ - char numstr[32] = ""; + char numstr[32]; + size_t numstr_len; /* Always draw times above the strip, whereas sequencer drew below + above. @@ -490,12 +492,12 @@ static void nla_draw_strip_frames_text(NlaTrack *UNUSED(nlt), NlaStrip *strip, V * while also preserving some accuracy, since we do use floats */ /* start frame */ - BLI_snprintf(numstr, sizeof(numstr), "%.1f", strip->start); - UI_view2d_text_cache_add(v2d, strip->start - 1.0f, ymaxc + ytol, numstr, col); + numstr_len = BLI_snprintf(numstr, sizeof(numstr), "%.1f", strip->start); + UI_view2d_text_cache_add(v2d, strip->start - 1.0f, ymaxc + ytol, numstr, numstr_len, col); /* end frame */ - BLI_snprintf(numstr, sizeof(numstr), "%.1f", strip->end); - UI_view2d_text_cache_add(v2d, strip->end, ymaxc + ytol, numstr, col); + numstr_len = BLI_snprintf(numstr, sizeof(numstr), "%.1f", strip->end); + UI_view2d_text_cache_add(v2d, strip->end, ymaxc + ytol, numstr, numstr_len, col); } /* ---------------------- */ |