Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/animation/keyframes_draw.c
| Context not available. | |||||
| #include "ED_anim_api.h" | #include "ED_anim_api.h" | ||||
| #include "ED_keyframes_draw.h" | #include "ED_keyframes_draw.h" | ||||
| #include "GPU_immediate.h" | |||||
| /* *************************** Keyframe Processing *************************** */ | /* *************************** Keyframe Processing *************************** */ | ||||
| /* ActKeyColumns (Keyframe Columns) ------------------------------------------ */ | /* ActKeyColumns (Keyframe Columns) ------------------------------------------ */ | ||||
| Context not available. | |||||
| static GLuint displist1 = 0; | static GLuint displist1 = 0; | ||||
| static GLuint displist2 = 0; | static GLuint displist2 = 0; | ||||
| VertexFormat* format = immVertexFormat(); | |||||
| unsigned pos = add_attrib(format, "pos", GL_FLOAT, 2, KEEP_FLOAT); | |||||
| /* initialize 2 display lists for diamond shape - one empty, one filled */ | /* initialize 2 display lists for diamond shape - one empty, one filled */ | ||||
| if (displist1 == 0) { | if (displist1 == 0) { | ||||
| displist1 = glGenLists(1); | displist1 = glGenLists(1); | ||||
| glNewList(displist1, GL_COMPILE); | glNewList(displist1, GL_COMPILE); | ||||
| glBegin(GL_LINE_LOOP); | immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); | ||||
| glVertex2fv(_unit_diamond_shape[0]); | |||||
| glVertex2fv(_unit_diamond_shape[1]); | immBegin(GL_LINE_LOOP, 4); | ||||
| glVertex2fv(_unit_diamond_shape[2]); | immVertex2fv(pos, _unit_diamond_shape[0]); | ||||
| glVertex2fv(_unit_diamond_shape[3]); | immVertex2fv(pos, _unit_diamond_shape[1]); | ||||
| glEnd(); | immVertex2fv(pos, _unit_diamond_shape[2]); | ||||
| immVertex2fv(pos, _unit_diamond_shape[3]); | |||||
| immEnd(); | |||||
| immUnbindProgram(); | |||||
| glEndList(); | glEndList(); | ||||
| } | } | ||||
| if (displist2 == 0) { | if (displist2 == 0) { | ||||
| displist2 = glGenLists(1); | displist2 = glGenLists(1); | ||||
| glNewList(displist2, GL_COMPILE); | glNewList(displist2, GL_COMPILE); | ||||
| glBegin(GL_QUADS); | immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); | ||||
| glVertex2fv(_unit_diamond_shape[0]); | |||||
| glVertex2fv(_unit_diamond_shape[1]); | immBegin(GL_QUADS, 4); | ||||
| glVertex2fv(_unit_diamond_shape[2]); | immVertex2fv(pos, _unit_diamond_shape[0]); | ||||
| glVertex2fv(_unit_diamond_shape[3]); | immVertex2fv(pos, _unit_diamond_shape[1]); | ||||
| glEnd(); | immVertex2fv(pos, _unit_diamond_shape[2]); | ||||
| immVertex2fv(pos, _unit_diamond_shape[3]); | |||||
| immEnd(); | |||||
| immUnbindProgram(); | |||||
| glEndList(); | glEndList(); | ||||
| } | } | ||||
merwin: All this display list code should go away. That's an obsolete OpenGL feature. | |||||
| Context not available. | |||||
| /* adjust view transform before starting */ | /* adjust view transform before starting */ | ||||
| glTranslatef(x, y, 0.0f); | glTranslatef(x, y, 0.0f); | ||||
| glScalef(1.0f / xscale * hsize, hsize, 1.0f); | glScalef(1.0f / xscale * hsize, hsize, 1.0f); | ||||
| /* anti-aliased lines for more consistent appearance */ | /* anti-aliased lines for more consistent appearance */ | ||||
| glEnable(GL_LINE_SMOOTH); | glEnable(GL_LINE_SMOOTH); | ||||
| immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); | |||||
| /* draw! */ | /* draw! */ | ||||
| if (ELEM(mode, KEYFRAME_SHAPE_INSIDE, KEYFRAME_SHAPE_BOTH)) { | if (ELEM(mode, KEYFRAME_SHAPE_INSIDE, KEYFRAME_SHAPE_BOTH)) { | ||||
| float inner_col[4]; | |||||
| /* get interior colors from theme (for selected and unselected only) */ | /* get interior colors from theme (for selected and unselected only) */ | ||||
| switch (key_type) { | switch (key_type) { | ||||
| case BEZT_KEYTYPE_BREAKDOWN: /* bluish frames (default theme) */ | case BEZT_KEYTYPE_BREAKDOWN: /* bluish frames (default theme) */ | ||||
| { | { | ||||
| if (sel) UI_GetThemeColor4fv(TH_KEYTYPE_BREAKDOWN_SELECT, inner_col); | if (sel) immUniformThemeColor(TH_KEYTYPE_BREAKDOWN_SELECT); | ||||
| else UI_GetThemeColor4fv(TH_KEYTYPE_BREAKDOWN, inner_col); | else immUniformThemeColor(TH_KEYTYPE_BREAKDOWN); | ||||
| break; | break; | ||||
| } | } | ||||
| case BEZT_KEYTYPE_EXTREME: /* reddish frames (default theme) */ | case BEZT_KEYTYPE_EXTREME: /* reddish frames (default theme) */ | ||||
| { | { | ||||
| if (sel) UI_GetThemeColor4fv(TH_KEYTYPE_EXTREME_SELECT, inner_col); | if (sel) immUniformThemeColor(TH_KEYTYPE_EXTREME_SELECT); | ||||
| else UI_GetThemeColor4fv(TH_KEYTYPE_EXTREME, inner_col); | else immUniformThemeColor(TH_KEYTYPE_EXTREME); | ||||
merwinUnsubmitted Not Done Inline ActionsCan shorten each of these lines: merwin: Can shorten each of these lines:
immUniformThemeColor(sel ? TH_KEYTYPE_EXTREME_SELECT… | |||||
| break; | break; | ||||
| } | } | ||||
| case BEZT_KEYTYPE_JITTER: /* greenish frames (default theme) */ | case BEZT_KEYTYPE_JITTER: /* greenish frames (default theme) */ | ||||
| { | { | ||||
| if (sel) UI_GetThemeColor4fv(TH_KEYTYPE_JITTER_SELECT, inner_col); | if (sel) immUniformThemeColor(TH_KEYTYPE_JITTER_SELECT); | ||||
| else UI_GetThemeColor4fv(TH_KEYTYPE_JITTER, inner_col); | else immUniformThemeColor(TH_KEYTYPE_JITTER); | ||||
| break; | break; | ||||
| } | } | ||||
| case BEZT_KEYTYPE_MOVEHOLD: /* similar to traditional keyframes, but different... */ | case BEZT_KEYTYPE_MOVEHOLD: /* similar to traditional keyframes, but different... */ | ||||
| { | { | ||||
| /* XXX: Should these get their own theme options instead? */ | /* XXX: Should these get their own theme options instead? */ | ||||
| if (sel) UI_GetThemeColorShade4fv(TH_STRIP_SELECT, 35, inner_col); | if (sel) immUniformThemeColorShade(TH_STRIP_SELECT, 35); | ||||
| else UI_GetThemeColorShade4fv(TH_STRIP, 50, inner_col); | else immUniformThemeColorShade(TH_STRIP, 50); | ||||
| inner_col[3] = 1.0f; /* full opacity, to avoid problems with visual glitches */ | |||||
| break; | break; | ||||
| } | } | ||||
| case BEZT_KEYTYPE_KEYFRAME: /* traditional yellowish frames (default theme) */ | case BEZT_KEYTYPE_KEYFRAME: /* traditional yellowish frames (default theme) */ | ||||
| default: | default: | ||||
| { | { | ||||
| if (sel) UI_GetThemeColor4fv(TH_KEYTYPE_KEYFRAME_SELECT, inner_col); | if (sel) immUniformThemeColor(TH_KEYTYPE_KEYFRAME_SELECT); | ||||
| else UI_GetThemeColor4fv(TH_KEYTYPE_KEYFRAME, inner_col); | else immUniformThemeColor(TH_KEYTYPE_KEYFRAME); | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| /* NOTE: we don't use the straight alpha from the theme, or else effects such as | immUnbindProgram(); | ||||
merwinUnsubmitted Not Done Inline Actionsdelete, keep same program bound merwin: delete, keep same program bound | |||||
| * graying out protected/muted channels doesn't work correctly! | |||||
| */ | |||||
| inner_col[3] *= alpha; | |||||
| glColor4fv(inner_col); | |||||
| /* draw the "filled in" interior poly now */ | /* draw the "filled in" interior poly now */ | ||||
| glCallList(displist2); | glNewList(displist2, GL_COMPILE); | ||||
| immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); | |||||
merwinUnsubmitted Not Done Inline Actionsdelete merwin: delete | |||||
| immBegin(GL_QUADS, 4); | |||||
| immVertex2fv(pos, _unit_diamond_shape[0]); | |||||
| immVertex2fv(pos, _unit_diamond_shape[1]); | |||||
| immVertex2fv(pos, _unit_diamond_shape[2]); | |||||
| immVertex2fv(pos, _unit_diamond_shape[3]); | |||||
| immEnd(); | |||||
| immUnbindProgram(); | |||||
| glEndList(); | |||||
merwinUnsubmitted Not Done Inline Actionsdelete merwin: delete | |||||
| } | } | ||||
| if (ELEM(mode, KEYFRAME_SHAPE_FRAME, KEYFRAME_SHAPE_BOTH)) { | if (ELEM(mode, KEYFRAME_SHAPE_FRAME, KEYFRAME_SHAPE_BOTH)) { | ||||
| float border_col[4]; | |||||
| immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); | |||||
merwinUnsubmitted Not Done Inline Actionsdelete merwin: delete | |||||
| /* exterior - black frame */ | /* exterior - black frame */ | ||||
| if (sel) UI_GetThemeColor4fv(TH_KEYBORDER_SELECT, border_col); | if (sel) immUniformThemeColor(TH_KEYBORDER_SELECT); | ||||
| else UI_GetThemeColor4fv(TH_KEYBORDER, border_col); | else immUniformThemeColor(TH_KEYBORDER); | ||||
| border_col[3] *= alpha; | |||||
| glColor4fv(border_col); | |||||
| glCallList(displist1); | glNewList(displist1, GL_COMPILE); | ||||
merwinUnsubmitted Not Done Inline Actionsdelete (old OpenGL feature) merwin: delete (old OpenGL feature) | |||||
| immBegin(GL_LINE_LOOP, 4); | |||||
| immVertex2fv(pos, _unit_diamond_shape[0]); | |||||
| immVertex2fv(pos, _unit_diamond_shape[1]); | |||||
| immVertex2fv(pos, _unit_diamond_shape[2]); | |||||
| immVertex2fv(pos, _unit_diamond_shape[3]); | |||||
| immEnd(); | |||||
| immUnbindProgram(); | |||||
merwinUnsubmitted Not Done Inline ActionsMove this to after this "if" block, near the end of the function. merwin: Move this to after this "if" block, near the end of the function. | |||||
| glEndList(); | |||||
merwinUnsubmitted Not Done Inline Actionsdelete merwin: delete | |||||
| } | } | ||||
| glDisable(GL_LINE_SMOOTH); | glDisable(GL_LINE_SMOOTH); | ||||
| Context not available. | |||||
| copy_v4_v4(unsel_mhcol, unsel_color); | copy_v4_v4(unsel_mhcol, unsel_color); | ||||
| unsel_mhcol[3] *= 0.8f; | unsel_mhcol[3] *= 0.8f; | ||||
| VertexFormat* format = immVertexFormat(); | |||||
| unsigned pos = add_attrib(format, "pos", GL_FLOAT, 2, KEEP_FLOAT); | |||||
merwinUnsubmitted Not Done Inline Actionsbind a shader for drawing merwin: bind a shader for drawing | |||||
| /* NOTE: the tradeoff for changing colors between each draw is dwarfed by the cost of checking validity */ | /* NOTE: the tradeoff for changing colors between each draw is dwarfed by the cost of checking validity */ | ||||
| for (ab = blocks->first; ab; ab = ab->next) { | for (ab = blocks->first; ab; ab = ab->next) { | ||||
| if (actkeyblock_is_valid(ab, keys)) { | if (actkeyblock_is_valid(ab, keys)) { | ||||
| Context not available. | |||||
| else | else | ||||
| glColor4fv(unsel_mhcol); | glColor4fv(unsel_mhcol); | ||||
merwinUnsubmitted Not Done Inline ActionsCan shorten these: immUniformColor4fv(ab->sel ? sel_mhcol : unsel_mhcol); merwin: Can shorten these: immUniformColor4fv(ab->sel ? sel_mhcol : unsel_mhcol); | |||||
| glRectf(ab->start, ypos - mhsize, ab->end, ypos + mhsize); | immRectf(pos, ab->start, ypos - mhsize, ab->end, ypos + mhsize); | ||||
| } | } | ||||
| else { | else { | ||||
| /* draw standard long-keyframe block */ | /* draw standard long-keyframe block */ | ||||
| Context not available. | |||||
| else | else | ||||
| glColor4fv(unsel_color); | glColor4fv(unsel_color); | ||||
| glRectf(ab->start, ypos - iconsize, ab->end, ypos + iconsize); | immRectf(pos, ab->start, ypos - iconsize, ab->end, ypos + iconsize); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| Context not available. | |||||
All this display list code should go away. That's an obsolete OpenGL feature.