Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_nla/nla_draw.c
| Show All 16 Lines | |||||
| #include "DNA_space_types.h" | #include "DNA_space_types.h" | ||||
| #include "DNA_windowmanager_types.h" | #include "DNA_windowmanager_types.h" | ||||
| #include "BLI_blenlib.h" | #include "BLI_blenlib.h" | ||||
| #include "BLI_dlrbTree.h" | #include "BLI_dlrbTree.h" | ||||
| #include "BLI_range.h" | #include "BLI_range.h" | ||||
| #include "BLI_utildefines.h" | #include "BLI_utildefines.h" | ||||
| #include "BKE_action.h" | |||||
| #include "BKE_context.h" | #include "BKE_context.h" | ||||
| #include "BKE_fcurve.h" | #include "BKE_fcurve.h" | ||||
| #include "BKE_nla.h" | #include "BKE_nla.h" | ||||
| #include "BKE_screen.h" | #include "BKE_screen.h" | ||||
| #include "ED_anim_api.h" | #include "ED_anim_api.h" | ||||
| #include "ED_keyframes_draw.h" | #include "ED_keyframes_draw.h" | ||||
| #include "ED_keyframes_keylist.h" | #include "ED_keyframes_keylist.h" | ||||
| ▲ Show 20 Lines • Show All 818 Lines • ▼ Show 20 Lines | if (IN_RANGE(ymin, v2d->cur.ymin, v2d->cur.ymax) || | ||||
| if (ale->data) { | if (ale->data) { | ||||
| ANIM_draw_action_framerange(adt, ale->data, v2d, ymin, ymax); | ANIM_draw_action_framerange(adt, ale->data, v2d, ymin, ymax); | ||||
| } | } | ||||
| uint pos = GPU_vertformat_attr_add( | uint pos = GPU_vertformat_attr_add( | ||||
| immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | ||||
| immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); | immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); | ||||
| /* just draw a semi-shaded rect spanning the width of the viewable area if there's data, | /* just draw a semi-shaded rect spanning the width of the viewable area, based on if | ||||
| * and a second darker rect within which we draw keyframe indicator dots if there's data | * there's data and the action's extrapolation mode. Draw a second darker rect within | ||||
| * which we draw keyframe indicator dots if there's data. | |||||
| */ | */ | ||||
| GPU_blend(GPU_BLEND_ALPHA); | GPU_blend(GPU_BLEND_ALPHA); | ||||
| /* get colors for drawing */ | /* get colors for drawing */ | ||||
| float color[4]; | float color[4]; | ||||
| nla_action_get_color(adt, ale->data, color); | nla_action_get_color(adt, ale->data, color); | ||||
| immUniformColor4fv(color); | immUniformColor4fv(color); | ||||
| /* draw slightly shifted up for greater separation from standard channels, | /* draw slightly shifted up for greater separation from standard channels, | ||||
| * but also slightly shorter for some more contrast when viewing the strips | * but also slightly shorter for some more contrast when viewing the strips | ||||
| */ | */ | ||||
| immRectf( | switch (adt->act_extendmode) { | ||||
| pos, v2d->cur.xmin, ymin + NLACHANNEL_SKIP, v2d->cur.xmax, ymax - NLACHANNEL_SKIP); | case NLASTRIP_EXTEND_HOLD: { | ||||
| immRectf(pos, | |||||
| v2d->cur.xmin, | |||||
| ymin + NLACHANNEL_SKIP, | |||||
| v2d->cur.xmax, | |||||
| ymax - NLACHANNEL_SKIP); | |||||
| break; | |||||
cmbasnett: This `ED_keylist_create` needs a corresponding `ED_keylist_free`, otherwise this will leak… | |||||
| } | |||||
Done Inline ActionsThis seems a bit excessive to be doing every draw call. That function can run quite deep, and copying a potentially huge array just to discard it all and grab one value from it seems inefficient. Is there a less costly way to get the key range from an action? cmbasnett: This seems a bit excessive to be doing every draw call. That function can run quite deep, and… | |||||
| case NLASTRIP_EXTEND_HOLD_FORWARD: { | |||||
| float r_start; | |||||
| float r_end; | |||||
| BKE_action_get_frame_range(ale->data, &r_start, &r_end); | |||||
| immRectf(pos, r_end, ymin + NLACHANNEL_SKIP, v2d->cur.xmax, ymax - NLACHANNEL_SKIP); | |||||
| break; | |||||
| } | |||||
Done Inline ActionsRemove the default case. That way the compiler can issue a warning when another item in the enum is added. sybren: Remove the `default` case. That way the compiler can issue a warning when another item in the… | |||||
| case NLASTRIP_EXTEND_NOTHING: | |||||
| break; | |||||
| } | |||||
| immUnbindProgram(); | immUnbindProgram(); | ||||
| /* draw keyframes in the action */ | /* draw keyframes in the action */ | ||||
| nla_action_draw_keyframes( | nla_action_draw_keyframes( | ||||
| v2d, adt, ale->data, ycenter, ymin + NLACHANNEL_SKIP, ymax - NLACHANNEL_SKIP); | v2d, adt, ale->data, ycenter, ymin + NLACHANNEL_SKIP, ymax - NLACHANNEL_SKIP); | ||||
| GPU_blend(GPU_BLEND_NONE); | GPU_blend(GPU_BLEND_NONE); | ||||
| ▲ Show 20 Lines • Show All 92 Lines • Show Last 20 Lines | |||||
This ED_keylist_create needs a corresponding ED_keylist_free, otherwise this will leak memory.