Merge branch 'master' into blender2.8
[blender.git] / source / blender / editors / space_action / action_draw.c
index 0764f586de98380fe7b75323c14b3409155892c7..feea9cf5b13d882c25eb67a59fc2d51a44235aaf 100644 (file)
@@ -61,6 +61,7 @@
 #include "ED_keyframes_draw.h"
 
 #include "action_intern.h"
+#include "GPU_immediate.h"
 
 /* ************************************************************************* */
 /* Channel List */
@@ -205,6 +206,12 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
        
        /* first backdrop strips */
        y = (float)(-ACHANNEL_HEIGHT(ac));
+
+       VertexFormat* format = immVertexFormat();
+       unsigned pos = add_attrib(format, "pos", GL_FLOAT, 2, KEEP_FLOAT);
+
+       immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
+
        glEnable(GL_BLEND);
        
        for (ale = anim_data.first; ale; ale = ale->next) {
@@ -223,7 +230,7 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
                                /* determine if channel is selected */
                                if (acf->has_setting(ac, ale, ACHANNEL_SETTING_SELECT))
                                        sel = ANIM_channel_setting_get(ac, ale, ACHANNEL_SETTING_SELECT);
-                               
+
                                if (ELEM(ac->datatype, ANIMCONT_ACTION, ANIMCONT_DOPESHEET, ANIMCONT_SHAPEKEY)) {
                                        switch (ale->type) {
                                                case ANIMTYPE_SUMMARY:
@@ -235,16 +242,16 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
                                                case ANIMTYPE_SCENE:
                                                case ANIMTYPE_OBJECT:
                                                {
-                                                       if (sel) glColor4ub(col1b[0], col1b[1], col1b[2], 0x45); 
-                                                       else glColor4ub(col1b[0], col1b[1], col1b[2], 0x22); 
+                                                       if (sel) immUniformColor4ub(col1b[0], col1b[1], col1b[2], 0x45);
+                                                       else immUniformColor4ub(col1b[0], col1b[1], col1b[2], 0x22);
                                                        break;
                                                }
                                                case ANIMTYPE_FILLACTD:
                                                case ANIMTYPE_DSSKEY:
                                                case ANIMTYPE_DSWOR:
                                                {
-                                                       if (sel) glColor4ub(col2b[0], col2b[1], col2b[2], 0x45); 
-                                                       else glColor4ub(col2b[0], col2b[1], col2b[2], 0x22); 
+                                                       if (sel) immUniformColor4ub(col2b[0], col2b[1], col2b[2], 0x45);
+                                                       else immUniformColor4ub(col2b[0], col2b[1], col2b[2], 0x22);
                                                        break;
                                                }
                                                case ANIMTYPE_GROUP:
@@ -252,17 +259,17 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
                                                        bActionGroup *agrp = ale->data;
                                                        if (show_group_colors && agrp->customCol) {
                                                                if (sel) {
-                                                                       unsigned char *cp = (unsigned char *)agrp->cs.select;
-                                                                       glColor4ub(cp[0], cp[1], cp[2], 0x45);
+                                                                       unsigned char *cp = agrp->cs.select;
+                                                                       immUniformColor4ub(cp[0], cp[1], cp[2], 0x45);
                                                                }
                                                                else {
-                                                                       unsigned char *cp = (unsigned char *)agrp->cs.solid;
-                                                                       glColor4ub(cp[0], cp[1], cp[2], 0x1D);
+                                                                       unsigned char *cp = agrp->cs.solid;
+                                                                       immUniformColor4ub(cp[0], cp[1], cp[2], 0x1D);
                                                                }
                                                        }
                                                        else {
-                                                               if (sel) glColor4ub(col1a[0], col1a[1], col1a[2], 0x22);
-                                                               else glColor4ub(col2a[0], col2a[1], col2a[2], 0x22);
+                                                               if (sel) immUniformColor4ub(col1a[0], col1a[1], col1a[2], 0x22);
+                                                               else immUniformColor4ub(col2a[0], col2a[1], col2a[2], 0x22);
                                                        }
                                                        break;
                                                }
@@ -272,51 +279,51 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
                                                        if (show_group_colors && fcu->grp && fcu->grp->customCol) {
                                                                unsigned char *cp = (unsigned char *)fcu->grp->cs.active;
                                                                
-                                                               if (sel) glColor4ub(cp[0], cp[1], cp[2], 0x65);
-                                                               else glColor4ub(cp[0], cp[1], cp[2], 0x0B);
+                                                               if (sel) immUniformColor4ub(cp[0], cp[1], cp[2], 0x65);
+                                                               else immUniformColor4ub(cp[0], cp[1], cp[2], 0x0B);
                                                        }
                                                        else {
-                                                               if (sel) glColor4ub(col1[0], col1[1], col1[2], 0x22);
-                                                               else glColor4ub(col2[0], col2[1], col2[2], 0x22);
+                                                               if (sel) immUniformColor4ub(col1[0], col1[1], col1[2], 0x22);
+                                                               else immUniformColor4ub(col2[0], col2[1], col2[2], 0x22);
                                                        }
                                                        break;
                                                }
                                                default:
                                                {
-                                                       if (sel) glColor4ub(col1[0], col1[1], col1[2], 0x22);
-                                                       else glColor4ub(col2[0], col2[1], col2[2], 0x22);
+                                                       if (sel) immUniformColor4ub(col1[0], col1[1], col1[2], 0x22);
+                                                       else immUniformColor4ub(col2[0], col2[1], col2[2], 0x22);
                                                        break;
                                                }
                                        }
                                        
                                        /* draw region twice: firstly backdrop, then the current range */
-                                       glRectf(v2d->cur.xmin,  (float)y - ACHANNEL_HEIGHT_HALF(ac),  v2d->cur.xmax + EXTRA_SCROLL_PAD,  (float)y + ACHANNEL_HEIGHT_HALF(ac));
+                                       immRectf(pos, v2d->cur.xmin,  (float)y - ACHANNEL_HEIGHT_HALF(ac),  v2d->cur.xmax + EXTRA_SCROLL_PAD,  (float)y + ACHANNEL_HEIGHT_HALF(ac));
                                        
                                        if (ac->datatype == ANIMCONT_ACTION)
-                                               glRectf(act_start,  (float)y - ACHANNEL_HEIGHT_HALF(ac),  act_end,  (float)y + ACHANNEL_HEIGHT_HALF(ac));
+                                               immRectf(pos, act_start,  (float)y - ACHANNEL_HEIGHT_HALF(ac),  act_end,  (float)y + ACHANNEL_HEIGHT_HALF(ac));
                                }
                                else if (ac->datatype == ANIMCONT_GPENCIL) {
                                        /* frames less than one get less saturated background */
-                                       if (sel) glColor4ub(col1[0], col1[1], col1[2], 0x22);
-                                       else glColor4ub(col2[0], col2[1], col2[2], 0x22);
-                                       glRectf(0.0f, (float)y - ACHANNEL_HEIGHT_HALF(ac), v2d->cur.xmin, (float)y + ACHANNEL_HEIGHT_HALF(ac));
+                                       if (sel) immUniformColor4ub(col1[0], col1[1], col1[2], 0x22);
+                                       else immUniformColor4ub(col2[0], col2[1], col2[2], 0x22);
+                                       immRectf(pos, 0.0f, (float)y - ACHANNEL_HEIGHT_HALF(ac), v2d->cur.xmin, (float)y + ACHANNEL_HEIGHT_HALF(ac));
                                        
                                        /* frames one and higher get a saturated background */
-                                       if (sel) glColor4ub(col1[0], col1[1], col1[2], 0x44);
-                                       else glColor4ub(col2[0], col2[1], col2[2], 0x44);
-                                       glRectf(v2d->cur.xmin, (float)y - ACHANNEL_HEIGHT_HALF(ac), v2d->cur.xmax + EXTRA_SCROLL_PAD,  (float)y + ACHANNEL_HEIGHT_HALF(ac));
+                                       if (sel) immUniformColor4ub(col1[0], col1[1], col1[2], 0x44);
+                                       else immUniformColor4ub(col2[0], col2[1], col2[2], 0x44);
+                                       immRectf(pos, v2d->cur.xmin, (float)y - ACHANNEL_HEIGHT_HALF(ac), v2d->cur.xmax + EXTRA_SCROLL_PAD,  (float)y + ACHANNEL_HEIGHT_HALF(ac));
                                }
                                else if (ac->datatype == ANIMCONT_MASK) {
                                        /* TODO --- this is a copy of gpencil */
                                        /* frames less than one get less saturated background */
-                                       if (sel) glColor4ub(col1[0], col1[1], col1[2], 0x22);
-                                       else glColor4ub(col2[0], col2[1], col2[2], 0x22);
-                                       glRectf(0.0f, (float)y - ACHANNEL_HEIGHT_HALF(ac), v2d->cur.xmin, (float)y + ACHANNEL_HEIGHT_HALF(ac));
+                                       if (sel) immUniformColor4ub(col1[0], col1[1], col1[2], 0x22);
+                                       else immUniformColor4ub(col2[0], col2[1], col2[2], 0x22);
+                                       immRectf(pos, 0.0f, (float)y - ACHANNEL_HEIGHT_HALF(ac), v2d->cur.xmin, (float)y + ACHANNEL_HEIGHT_HALF(ac));
 
                                        /* frames one and higher get a saturated background */
-                                       if (sel) glColor4ub(col1[0], col1[1], col1[2], 0x44);
-                                       else glColor4ub(col2[0], col2[1], col2[2], 0x44);
-                                       glRectf(v2d->cur.xmin, (float)y - ACHANNEL_HEIGHT_HALF(ac), v2d->cur.xmax + EXTRA_SCROLL_PAD,  (float)y + ACHANNEL_HEIGHT_HALF(ac));
+                                       if (sel) immUniformColor4ub(col1[0], col1[1], col1[2], 0x44);
+                                       else immUniformColor4ub(col2[0], col2[1], col2[2], 0x44);
+                                       immRectf(pos, v2d->cur.xmin, (float)y - ACHANNEL_HEIGHT_HALF(ac), v2d->cur.xmax + EXTRA_SCROLL_PAD,  (float)y + ACHANNEL_HEIGHT_HALF(ac));
                                }
                        }
                }
@@ -383,11 +390,12 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
 
        /* black line marking 'current frame' for Time-Slide transform mode */
        if (saction->flag & SACTION_MOVING) {
-               glColor3f(0.0f, 0.0f, 0.0f);
-               
-               glBegin(GL_LINES);
-               glVertex2f(saction->timeslide, v2d->cur.ymin - EXTRA_SCROLL_PAD);
-               glVertex2f(saction->timeslide, v2d->cur.ymax);
-               glEnd();
+               immUniformColor3f(0.0f, 0.0f, 0.0f);
+
+               immBegin(GL_LINES, 2);
+               immVertex2f(pos, saction->timeslide, v2d->cur.ymin - EXTRA_SCROLL_PAD);
+               immVertex2f(pos, saction->timeslide, v2d->cur.ymax);
+               immEnd();
        }
+       immUnbindProgram();
 }