Commit: 31a21135cf72c8623be7f5aee2bfdac983ceae2e
Author: Dalai Felinto
Date:   Tue Feb 14 13:00:22 2017 +0100
Branches: blender2.8
https://developer.blender.org/rB31a21135cf72c8623be7f5aee2bfdac983ceae2e

Immediate Mode: area.c and UI_draw_icon_tri, ui_draw_anti_tria

Note: This makes the jittering to not work :/

@merwin, would you know how to use gpuMatrixBegin2D for this case? I
think it must be the reason behind the lack of jittering. But I couldn't
get it to work (the 2D shader is asking for a 3D Matrix).

Part of T49043

===================================================================

M       source/blender/editors/include/UI_interface.h
M       source/blender/editors/interface/interface_intern.h
M       source/blender/editors/interface/interface_panel.c
M       source/blender/editors/interface/interface_widgets.c
M       source/blender/editors/screen/area.c
M       source/blender/editors/space_node/node_draw.c

===================================================================

diff --git a/source/blender/editors/include/UI_interface.h 
b/source/blender/editors/include/UI_interface.h
index 153c3d415e..8b783377f6 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -1062,7 +1062,7 @@ void UI_fontstyle_draw_simple_backdrop(
 int UI_fontstyle_string_width(const struct uiFontStyle *fs, const char *str);
 int UI_fontstyle_height_max(const struct uiFontStyle *fs);
 
-void UI_draw_icon_tri(float x, float y, char dir);
+void UI_draw_icon_tri(float x, float y, char dir, const float[4]);
 
 struct uiStyle *UI_style_get(void);            /* use for fonts etc */
 struct uiStyle *UI_style_get_dpi(void);        /* DPI scaled settings for 
drawing */
diff --git a/source/blender/editors/interface/interface_intern.h 
b/source/blender/editors/interface/interface_intern.h
index 7529f60c6f..73c527729e 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -681,7 +681,7 @@ struct wmIMEData *ui_but_ime_data_get(uiBut *but);
 #endif
 
 /* interface_widgets.c */
-void ui_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, float 
y3);
+void ui_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, float 
y3, const float color[4]);
 void ui_draw_anti_roundbox(int mode, float minx, float miny, float maxx, float 
maxy,
                            float rad, bool use_alpha, const float color[4]);
 void ui_draw_menu_back(struct uiStyle *style, uiBlock *block, rcti *rect);
diff --git a/source/blender/editors/interface/interface_panel.c 
b/source/blender/editors/interface/interface_panel.c
index 1bdc47e503..c6dc3ebd77 100644
--- a/source/blender/editors/interface/interface_panel.c
+++ b/source/blender/editors/interface/interface_panel.c
@@ -412,33 +412,36 @@ static void uiPanelPop(uiBlock *UNUSED(block))
 #endif
 
 /* triangle 'icon' for panel header */
-void UI_draw_icon_tri(float x, float y, char dir)
+void UI_draw_icon_tri(float x, float y, char dir, const float color[4])
 {
        float f3 = 0.15 * U.widget_unit;
        float f5 = 0.25 * U.widget_unit;
        float f7 = 0.35 * U.widget_unit;
        
        if (dir == 'h') {
-               ui_draw_anti_tria(x - f3, y - f5, x - f3, y + f5, x + f7, y);
+               ui_draw_anti_tria(x - f3, y - f5, x - f3, y + f5, x + f7, y, 
color);
        }
        else if (dir == 't') {
-               ui_draw_anti_tria(x - f5, y - f7, x + f5, y - f7, x, y + f3);
+               ui_draw_anti_tria(x - f5, y - f7, x + f5, y - f7, x, y + f3, 
color);
        }
        else { /* 'v' = vertical, down */
-               ui_draw_anti_tria(x - f5, y + f3, x + f5, y + f3, x, y - f7);
+               ui_draw_anti_tria(x - f5, y + f3, x + f5, y + f3, x, y - f7, 
color);
        }
 }
 
 /* triangle 'icon' inside rect */
 static void ui_draw_tria_rect(const rctf *rect, char dir)
 {
+       float color[4];
+       UI_GetThemeColor4fv(TH_TITLE, color);
+
        if (dir == 'h') {
                float half = 0.5f * BLI_rctf_size_y(rect);
-               ui_draw_anti_tria(rect->xmin, rect->ymin, rect->xmin, 
rect->ymax, rect->xmax, rect->ymin + half);
+               ui_draw_anti_tria(rect->xmin, rect->ymin, rect->xmin, 
rect->ymax, rect->xmax, rect->ymin + half, color);
        }
        else {
                float half = 0.5f * BLI_rctf_size_x(rect);
-               ui_draw_anti_tria(rect->xmin, rect->ymax, rect->xmax, 
rect->ymax, rect->xmin + half, rect->ymin);
+               ui_draw_anti_tria(rect->xmin, rect->ymax, rect->xmax, 
rect->ymax, rect->xmin + half, rect->ymin, color);
        }
 }
 
diff --git a/source/blender/editors/interface/interface_widgets.c 
b/source/blender/editors/interface/interface_widgets.c
index ff4762ccc6..bbb53324d3 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -187,28 +187,35 @@ static const unsigned int check_tria_face[4][3] = {
 
 /* ************************************************* */
 
-void ui_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, float 
y3)
+void ui_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, float 
y3,
+                       const float color[4])
 {
        float tri_arr[3][2] = {{x1, y1}, {x2, y2}, {x3, y3}};
-       float color[4];
-       int j;
-       
+       float draw_color[4];
+
+       copy_v4_v4(draw_color, color);
+       draw_color[3] *= 0.125f;
+
        glEnable(GL_BLEND);
-       glGetFloatv(GL_CURRENT_COLOR, color);
-       color[3] *= 0.125f;
-       glColor4fv(color);
 
-       glEnableClientState(GL_VERTEX_ARRAY);
-       glVertexPointer(2, GL_FLOAT, 0, tri_arr);
+       unsigned int pos = add_attrib(immVertexFormat(), "pos", GL_FLOAT, 2, 
KEEP_FLOAT);
+       immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
+
+       immUniformColor4fv(draw_color);
+       immBegin(GL_TRIANGLES, 3 * WIDGET_AA_JITTER);
 
        /* for each AA step */
-       for (j = 0; j < WIDGET_AA_JITTER; j++) {
+       for (int j = 0; j < WIDGET_AA_JITTER; j++) {
                glTranslate2fv(jit[j]);
-               glDrawArrays(GL_TRIANGLES, 0, 3);
+               immVertex2fv(pos, tri_arr[0]);
+               immVertex2fv(pos, tri_arr[1]);
+               immVertex2fv(pos, tri_arr[2]);
                glTranslatef(-jit[j][0], -jit[j][1], 0.0f);
        }
+       immEnd();
+
+       immUnbindProgram();
 
-       glDisableClientState(GL_VERTEX_ARRAY);
        glDisable(GL_BLEND);
 }
 
@@ -3910,15 +3917,21 @@ void ui_draw_menu_back(uiStyle *UNUSED(style), uiBlock 
*block, rcti *rect)
                wt->draw(&wt->wcol, rect, 0, 0);
        
        if (block) {
+               float draw_color[4];
+               unsigned char *color = (unsigned char *)wt->wcol.text;
+
+               draw_color[0] = ((float)color[0]) / 255.0f;
+               draw_color[1] = ((float)color[1]) / 255.0f;
+               draw_color[2] = ((float)color[2]) / 255.0f;
+               draw_color[3] = 1.0f;
+
                if (block->flag & UI_BLOCK_CLIPTOP) {
                        /* XXX no scaling for UI here yet */
-                       glColor3ubv((unsigned char *)wt->wcol.text);
-                       UI_draw_icon_tri(BLI_rcti_cent_x(rect), rect->ymax - 8, 
't');
+                       UI_draw_icon_tri(BLI_rcti_cent_x(rect), rect->ymax - 8, 
't', draw_color);
                }
                if (block->flag & UI_BLOCK_CLIPBOTTOM) {
                        /* XXX no scaling for UI here yet */
-                       glColor3ubv((unsigned char *)wt->wcol.text);
-                       UI_draw_icon_tri(BLI_rcti_cent_x(rect), rect->ymin + 
10, 'v');
+                       UI_draw_icon_tri(BLI_rcti_cent_x(rect), rect->ymin + 
10, 'v', draw_color);
                }
        }
 }
diff --git a/source/blender/editors/screen/area.c 
b/source/blender/editors/screen/area.c
index dbecbb974f..cc47667772 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -74,7 +74,7 @@
 
 #include "screen_intern.h"
 
-extern void ui_draw_anti_tria(float x1, float y1, float x2, float y2, float 
x3, float y3); /* xxx temp */
+extern void ui_draw_anti_tria(float x1, float y1, float x2, float y2, float 
x3, float y3, const float color[4]); /* xxx temp */
 
 /* general area and region code */
 
@@ -414,24 +414,24 @@ static void region_draw_azone_tria(AZone *az)
 {
        glEnable(GL_BLEND);
        //UI_GetThemeColor3fv(TH_HEADER, col);
-       glColor4f(0.0f, 0.0f, 0.0f, 0.35f);
+       float color[4] = {0.0f, 0.0f, 0.0f, 0.35f};
        
        /* add code to draw region hidden as 'too small' */
        switch (az->edge) {
                case AE_TOP_TO_BOTTOMRIGHT:
-                       ui_draw_anti_tria((float)az->x1, (float)az->y1, 
(float)az->x2, (float)az->y1, (float)(az->x1 + az->x2) / 2, (float)az->y2);
+                       ui_draw_anti_tria((float)az->x1, (float)az->y1, 
(float)az->x2, (float)az->y1, (float)(az->x1 + az->x2) / 2, (float)az->y2, 
color);
                        break;
                        
                case AE_BOTTOM_TO_TOPLEFT:
-                       ui_draw_anti_tria((float)az->x1, (float)az->y2, 
(float)az->x2, (float)az->y2, (float)(az->x1 + az->x2) / 2, (float)az->y1);
+                       ui_draw_anti_tria((float)az->x1, (float)az->y2, 
(float)az->x2, (float)az->y2, (float)(az->x1 + az->x2) / 2, (float)az->y1, 
color);
                        break;
 
                case AE_LEFT_TO_TOPRIGHT:
-                       ui_draw_anti_tria((float)az->x2, (float)az->y1, 
(float)az->x2, (float)az->y2, (float)az->x1, (float)(az->y1 + az->y2) / 2);
+                       ui_draw_anti_tria((float)az->x2, (float)az->y1, 
(float)az->x2, (float)az->y2, (float)az->x1, (float)(az->y1 + az->y2) / 2, 
color);
                        break;
                        
                case AE_RIGHT_TO_TOPLEFT:
-                       ui_draw_anti_tria((float)az->x1, (float)az->y1, 
(float)az->x1, (float)az->y2, (float)az->x2, (float)(az->y1 + az->y2) / 2);
+                       ui_draw_anti_tria((float)az->x1, (float)az->y1, 
(float)az->x1, (float)az->y2, (float)az->x2, (float)(az->y1 + az->y2) / 2, 
color);
                        break;
                        
        }
diff --git a/source/blender/editors/space_node/node_draw.c 
b/source/blender/editors/space_node/node_draw.c
index 80b19176c9..40917f8e34 100644
--- a/source/blender/editors/space_node/node_draw.c
+++ b/source/blender/editors/space_node/node_draw.c
@@ -934,10 +934,12 @@ static void node_draw_basis(const bContext *C, ARegion 
*ar, SpaceNode *snode, bN
        }
        
        /* title */
-       if (node->flag & SELECT) 
-               UI_ThemeColor(TH_SELECT);
-       else
-               UI_ThemeColorBlendShade(TH_TEXT, color_id, 0.4f, 10);
+       if (node->flag & SELECT) {
+               UI_GetThemeColor4fv(TH_SELECT, color);
+       }
+       else {
+               UI_GetThemeColorBlendShade4fv(TH_SELECT, color_id, 0.4f, 10, 
color);
+       }
        
        /* open/close entirely? */
        {
@@ -952,7 +954,7 @@ static void node_draw_basis(const bContext *C, ARegion *ar, 
SpaceNode *snode, bN
                UI_block_emboss_set(node->block, UI_EMBOSS);
                
                /* custom draw function for this button */
-               UI_draw_icon_tri(rct->xmin + 0.5f * U.widget_unit, rct->ymax - 
NODE_DY / 2.0f, 'v');
+               UI_draw_icon_tri(rct->xmin + 0.5f * U.widget_unit, rct->ymax - 
NODE_DY / 2.0f, 'v', color);
        }
        
 #if 0 /* this isn't doing anything for the label, so commenting out */
@@ -1077,10 +1079,12 @@ static void node_draw_hidden(const bContext *C, ARegion 
*ar, SpaceNode *snode, b
        }
 
        /* title */
-       if (node->flag & SELECT) 
-               UI_ThemeColor(TH_SELECT);
-       else
-               UI_ThemeColorBlendShade(TH_TEXT, color_id, 0.4f, 10);
+       if (node->flag & SELECT) {
+               UI_GetThemeColor4fv(TH_SELECT, color);
+       }
+       else {
+               UI_GetThemeColorBlendShade4fv(TH_SELECT, color_id, 0.4f, 10, 
color);
+       }
        
        /* open entirely icon */
        {
@@ -1095,7 +1099,7 @@ static void node_draw_hidden(const bContext *C, ARegion 
*ar, SpaceNode *snode, b
                UI_block_emboss_set(node->block, UI_EMBOSS);
                
                /* custom draw function for this button */
-               UI_draw_icon_tri(rct->xmin + 10.0f, centy, 'h');
+               UI_draw_icon_tri(rct->xmin + 10.0f, centy, 'h', color);
        }
        
        /* disable lines */

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to