diff options
author | Jeroen Bakker <jbakker> | 2021-08-03 09:10:07 +0300 |
---|---|---|
committer | Jeroen Bakker <jeroen@blender.org> | 2021-08-03 09:10:21 +0300 |
commit | 6f50969406a751ac69d41e792d859d74410ebef6 (patch) | |
tree | 79caf3176af7b9947fd7919b8e7227858563448a /source/blender/editors/space_nla/nla_draw.c | |
parent | ebd55b4acdc47ba2a412fd769aa6ab657abe97ca (diff) |
Cleanup: Hide implementation details for ED_keyframe_keylist.
For T78995 we want to change the data structure of keylists to
improve performance. (Probably a Vector with bin-search capabilities).
This patch hides the internal structure of the keylists behind `AnimKeylist`
structure. This allows us to change the internals without 'breaking' where it is
being used.
The change adds functions to create, free, find and walk over the
keylist.
Reviewed By: sybren
Maniphest Tasks: T78995
Differential Revision: https://developer.blender.org/D11974
Diffstat (limited to 'source/blender/editors/space_nla/nla_draw.c')
-rw-r--r-- | source/blender/editors/space_nla/nla_draw.c | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/source/blender/editors/space_nla/nla_draw.c b/source/blender/editors/space_nla/nla_draw.c index c96047da0c8..2bf4c7d4344 100644 --- a/source/blender/editors/space_nla/nla_draw.c +++ b/source/blender/editors/space_nla/nla_draw.c @@ -35,6 +35,7 @@ #include "BLI_blenlib.h" #include "BLI_dlrbTree.h" +#include "BLI_range.h" #include "BLI_utildefines.h" #include "BKE_context.h" @@ -95,12 +96,16 @@ void nla_action_get_color(AnimData *adt, bAction *act, float color[4]) static void nla_action_draw_keyframes( View2D *v2d, AnimData *adt, bAction *act, float y, float ymin, float ymax) { + if (act == NULL) { + return; + } + /* get a list of the keyframes with NLA-scaling applied */ - DLRBT_Tree keys; - BLI_dlrbTree_init(&keys); - action_to_keylist(adt, act, &keys, 0); + struct AnimKeylist *keylist = ED_keylist_create(); + action_to_keylist(adt, act, keylist, 0); - if (ELEM(NULL, act, keys.first)) { + if (ED_keylist_is_empty(keylist)) { + ED_keylist_free(keylist); return; } @@ -122,15 +127,16 @@ static void nla_action_draw_keyframes( /* - draw a rect from the first to the last frame (no extra overlaps for now) * that is slightly stumpier than the track background (hardcoded 2-units here) */ - float f1 = ((ActKeyColumn *)keys.first)->cfra; - float f2 = ((ActKeyColumn *)keys.last)->cfra; - immRectf(pos_id, f1, ymin + 2, f2, ymax - 2); + Range2f frame_range; + ED_keylist_frame_range(keylist, &frame_range); + immRectf(pos_id, frame_range.min, ymin + 2, frame_range.max, ymax - 2); immUnbindProgram(); /* Count keys before drawing. */ /* NOTE: It's safe to cast #DLRBT_Tree, as it's designed to degrade down to a #ListBase. */ - uint key_len = BLI_listbase_count((ListBase *)&keys); + const ListBase *keys = ED_keylist_listbase(keylist); + uint key_len = BLI_listbase_count(keys); if (key_len > 0) { format = immVertexFormat(); @@ -151,7 +157,7 @@ static void nla_action_draw_keyframes( /* - disregard the selection status of keyframes so they draw a certain way * - size is 6.0f which is smaller than the editable keyframes, so that there is a distinction */ - LISTBASE_FOREACH (ActKeyColumn *, ak, &keys) { + LISTBASE_FOREACH (const ActKeyColumn *, ak, keys) { draw_keyframe_shape(ak->cfra, y, 6.0f, @@ -174,7 +180,7 @@ static void nla_action_draw_keyframes( } /* free icons */ - BLI_dlrbTree_free(&keys); + ED_keylist_free(keylist); } /* Strip Markers ------------------------ */ |