[Bf-blender-cvs] [e58359c26f] blender2.8: OpenGL immediate mode: interface_draw.c (cont)

Clément Foucault noreply at git.blender.org
Mon Feb 6 15:21:09 CET 2017


Commit: e58359c26f2b68b04b28cbcd69c53f19818aa5e1
Author: Clément Foucault
Date:   Mon Feb 6 15:19:45 2017 +0100
Branches: blender2.8
https://developer.blender.org/rBe58359c26f2b68b04b28cbcd69c53f19818aa5e1

OpenGL immediate mode: interface_draw.c (cont)

Replaced GL_POLYGON in various places.
Ported UI_draw_roundbox_unfilled

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

M	source/blender/editors/animation/anim_channels_defines.c
M	source/blender/editors/include/UI_interface.h
M	source/blender/editors/interface/interface_draw.c
M	source/blender/editors/interface/interface_panel.c
M	source/blender/editors/screen/area.c
M	source/blender/editors/space_node/node_draw.c

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

diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c
index 26674278a5..4163cbfe11 100644
--- a/source/blender/editors/animation/anim_channels_defines.c
+++ b/source/blender/editors/animation/anim_channels_defines.c
@@ -124,7 +124,7 @@ static void acf_generic_root_backdrop(bAnimContext *ac, bAnimListElem *ale, floa
 	
 	/* rounded corners on LHS only - top only when expanded, but bottom too when collapsed */
 	UI_draw_roundbox_corner_set((expanded) ? UI_CNR_TOP_LEFT : (UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT));
-	UI_draw_roundbox_gl_mode_3fvAlpha(GL_POLYGON, offset,  yminc, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymaxc, 8, color, 1.0f);
+	UI_draw_roundbox_gl_mode_3fvAlpha(GL_TRIANGLE_FAN, offset,  yminc, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymaxc, 8, color, 1.0f);
 }
 
 
@@ -442,7 +442,7 @@ static void acf_summary_backdrop(bAnimContext *ac, bAnimListElem *ale, float ymi
 	 *	- special hack: make the top a bit higher, since we are first... 
 	 */
 	UI_draw_roundbox_corner_set(UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT);
-	UI_draw_roundbox_gl_mode_3fvAlpha(GL_POLYGON, 0,  yminc - 2, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymaxc, 8, color, 1.0f);
+	UI_draw_roundbox_gl_mode_3fvAlpha(GL_TRIANGLE_FAN, 0,  yminc - 2, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymaxc, 8, color, 1.0f);
 }
 
 /* name for summary entries */
@@ -831,7 +831,7 @@ static void acf_group_backdrop(bAnimContext *ac, bAnimListElem *ale, float yminc
 	
 	/* rounded corners on LHS only - top only when expanded, but bottom too when collapsed */
 	UI_draw_roundbox_corner_set(expanded ? UI_CNR_TOP_LEFT : (UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT));
-	UI_draw_roundbox_gl_mode_3fvAlpha(GL_POLYGON, offset,  yminc, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymaxc, 8, color, 1.0f);
+	UI_draw_roundbox_gl_mode_3fvAlpha(GL_TRIANGLE_FAN, offset,  yminc, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymaxc, 8, color, 1.0f);
 }
 
 /* name for group entries */
@@ -1087,7 +1087,7 @@ static void acf_nla_controls_backdrop(bAnimContext *ac, bAnimListElem *ale, floa
 	
 	/* rounded corners on LHS only - top only when expanded, but bottom too when collapsed */	
 	UI_draw_roundbox_corner_set(expanded ? UI_CNR_TOP_LEFT : (UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT));
-	UI_draw_roundbox_gl_mode_3fvAlpha(GL_POLYGON, offset,  yminc, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymaxc, 5, color, 1.0f);
+	UI_draw_roundbox_gl_mode_3fvAlpha(GL_TRIANGLE_FAN, offset,  yminc, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymaxc, 5, color, 1.0f);
 }
 
 /* name for nla controls expander entries */
@@ -3441,7 +3441,7 @@ static void acf_nlaaction_backdrop(bAnimContext *ac, bAnimListElem *ale, float y
 	/* draw slightly shifted up vertically to look like it has more separation from other channels,
 	 * but we then need to slightly shorten it so that it doesn't look like it overlaps
 	 */
-	UI_draw_roundbox_gl_mode(GL_POLYGON, offset,  yminc + NLACHANNEL_SKIP, (float)v2d->cur.xmax, ymaxc + NLACHANNEL_SKIP - 1, 8, color);
+	UI_draw_roundbox_gl_mode(GL_TRIANGLE_FAN, offset,  yminc + NLACHANNEL_SKIP, (float)v2d->cur.xmax, ymaxc + NLACHANNEL_SKIP - 1, 8, color);
 }
 
 /* name for nla action entries */
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index 5e27dc12a1..a4bd4b8010 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -311,13 +311,13 @@ typedef enum {
 void UI_draw_roundbox(float minx, float miny, float maxx, float maxy, float rad, const float color[4]);
 void UI_draw_roundbox_corner_set(int type);
 int  UI_draw_roundbox_corner_get(void);
-void UI_draw_roundbox_unfilled(float minx, float miny, float maxx, float maxy, float rad);
+void UI_draw_roundbox_unfilled(float minx, float miny, float maxx, float maxy, float rad, const float color[4]);
 void UI_draw_box_shadow(unsigned char alpha, float minx, float miny, float maxx, float maxy);
 void UI_draw_roundbox_gl_mode_3ubAlpha(int mode, float minx, float miny, float maxx, float maxy, float rad, unsigned char col[3], unsigned char alpha);
 void UI_draw_roundbox_gl_mode_3fvAlpha(int mode, float minx, float miny, float maxx, float maxy, float rad, float col[3], float alpha);
 void UI_draw_roundbox_gl_mode(int mode, float minx, float miny, float maxx, float maxy, float rad, float col[4]);
-void UI_draw_roundbox_shade_x(int mode, float minx, float miny, float maxx, float maxy, float rad, float shadetop, float shadedown, float col[4]);
-void UI_draw_roundbox_shade_y(int mode, float minx, float miny, float maxx, float maxy, float rad, float shadeleft, float shaderight, float col[4]);
+void UI_draw_roundbox_shade_x(int mode, float minx, float miny, float maxx, float maxy, float rad, float shadetop, float shadedown, const float col[4]);
+void UI_draw_roundbox_shade_y(int mode, float minx, float miny, float maxx, float maxy, float rad, float shadeleft, float shaderight, const float col[4]);
 void UI_draw_text_underline(int pos_x, int pos_y, int len, int height);
 
 void UI_draw_safe_areas(
diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c
index bfd90142e9..b3769f537e 100644
--- a/source/blender/editors/interface/interface_draw.c
+++ b/source/blender/editors/interface/interface_draw.c
@@ -114,9 +114,7 @@ void UI_draw_roundbox_gl_mode(int mode, float minx, float miny, float maxx, floa
 		mul_v2_fl(vec[a], rad);
 	}
 
-	if (mode == GL_POLYGON) {
-		mode = GL_TRIANGLE_FAN;
-	}
+	BLI_assert(mode != GL_POLYGON);
 
 	immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
 	immUniformColor4fv(col);
@@ -189,7 +187,7 @@ static void round_box_shade_col(unsigned attrib, const float col1[3], float cons
 /* view2d scrollers use it */
 void UI_draw_roundbox_shade_x(
         int mode, float minx, float miny, float maxx, float maxy,
-        float rad, float shadetop, float shadedown, float col[4])
+        float rad, float shadetop, float shadedown, const float col[4])
 {
 	float vec[7][2] = {{0.195, 0.02}, {0.383, 0.067}, {0.55, 0.169}, {0.707, 0.293},
 	                   {0.831, 0.45}, {0.924, 0.617}, {0.98, 0.805}};
@@ -210,6 +208,8 @@ void UI_draw_roundbox_shade_x(
 		mul_v2_fl(vec[a], rad);
 	}
 
+	BLI_assert(mode != GL_POLYGON);
+
 	/* 'shade' defines strength of shading */
 	coltop[0]  = min_ff(1.0f, col[0] + shadetop);
 	coltop[1]  = min_ff(1.0f, col[1] + shadetop);
@@ -308,7 +308,7 @@ void UI_draw_roundbox_shade_x(
 /* view2d scrollers use it */
 void UI_draw_roundbox_shade_y(
         int mode, float minx, float miny, float maxx, float maxy,
-        float rad, float shadeleft, float shaderight, float col[4])
+        float rad, float shadeleft, float shaderight, const float col[4])
 {
 	float vec[7][2] = {{0.195, 0.02}, {0.383, 0.067}, {0.55, 0.169}, {0.707, 0.293},
 	                   {0.831, 0.45}, {0.924, 0.617}, {0.98, 0.805}};
@@ -323,6 +323,8 @@ void UI_draw_roundbox_shade_y(
 		mul_v2_fl(vec[a], rad);
 	}
 
+	BLI_assert(mode != GL_POLYGON);
+
 	VertexFormat *format = immVertexFormat();
 	unsigned pos = add_attrib(format, "pos", GL_FLOAT, 2, KEEP_FLOAT);
 	unsigned color = add_attrib(format, "color", GL_FLOAT, 4, KEEP_FLOAT);
@@ -422,21 +424,20 @@ void UI_draw_roundbox_shade_y(
 }
 
 /* plain antialiased unfilled rectangle */
-void UI_draw_roundbox_unfilled(float minx, float miny, float maxx, float maxy, float rad)
+void UI_draw_roundbox_unfilled(float minx, float miny, float maxx, float maxy, float rad, const float color[4])
 {
-	float color[4];
-	
+	float col[4];
+
+	copy_v4_v4(col, color);
+
 	if (roundboxtype & UI_RB_ALPHA) {
-		glGetFloatv(GL_CURRENT_COLOR, color);
-		color[3] = 0.5;
-		glColor4fv(color);
-		glEnable(GL_BLEND);
+		col[3] = 0.5;
 	}
 	
 	/* set antialias line */
 	glEnable(GL_LINE_SMOOTH);
 	glEnable(GL_BLEND);
-	UI_draw_roundbox_gl_mode(GL_LINE_LOOP, minx, miny, maxx, maxy, rad, color);
+	UI_draw_roundbox_gl_mode(GL_LINE_LOOP, minx, miny, maxx, maxy, rad, col);
 
 	glDisable(GL_BLEND);
 	glDisable(GL_LINE_SMOOTH);
@@ -445,7 +446,7 @@ void UI_draw_roundbox_unfilled(float minx, float miny, float maxx, float maxy, f
 /* (old, used in outliner) plain antialiased filled box */
 void UI_draw_roundbox(float minx, float miny, float maxx, float maxy, float rad, const float color[4])
 {
-	ui_draw_anti_roundbox(GL_POLYGON, minx, miny, maxx, maxy, rad, roundboxtype & UI_RB_ALPHA, color);
+	ui_draw_anti_roundbox(GL_TRIANGLE_FAN, minx, miny, maxx, maxy, rad, roundboxtype & UI_RB_ALPHA, color);
 }
 
 void UI_draw_text_underline(int pos_x, int pos_y, int len, int height)
@@ -623,7 +624,7 @@ void ui_draw_but_HISTOGRAM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol)
 	float color[4];
 	UI_GetThemeColor4fv(TH_PREVIEW_BACK, color);
 	UI_draw_roundbox_corner_set(UI_CNR_ALL);
-	UI_draw_roundbox_gl_mode(GL_POLYGON, rect.xmin - 1, rect.ymin - 1, rect.xmax + 1, rect.ymax + 1, 3.0f, color);
+	UI_draw_roundbox_gl_mode(GL_TRIANGLE_FAN, rect.xmin - 1, rect.ymin - 1, rect.xmax + 1, rect.ymax + 1, 3.0f, color);
 
 	/* need scissor test, histogram can draw outside of boundary */
 	GLint scissor[4];
@@ -711,7 +712,7 @@ void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol),
 	float color[4];
 	UI_GetThemeColor4fv(TH_PREVIEW_BACK, color);
 	UI_draw_roundbox_corner_set(UI_CNR_ALL);
-	UI_draw_roundbox_gl_mode(GL_POLYGON, rect.xmin - 1, rect.ymin - 1, rect.xmax + 1, rect.ymax + 1, 3.0f, color);
+	UI_draw_roundbox_gl_mode(GL_TRIANGLE_FAN, rect.xmin - 1, rect.ymin - 1, rect.xmax + 1, rect.ymax + 1, 3.0f, color);
 
 	/* need scissor test, waveform can draw outside of boundary */
 	glGetIntegerv(GL_VIEWPORT, scissor);
@@ -956,7 +957,7 @@ void ui_draw_but_VECTORSCOPE(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wco
 	float color[4];
 	UI_GetThemeColor4fv(TH_PREVIEW_BACK, color);
 	UI_draw_roundbox_corner_set(UI_CNR_ALL);
-	UI_draw_roundbox_gl_mode(GL_POLYGON, rect.xmin - 1, rect.ymin - 1, rect.xmax + 1, rect.ymax + 1, 3.0f, color);
+	UI_draw_roundbox_gl_mode(GL_TRIANGLE_FAN, rect.xmin - 1, rect.ymin - 1, rect.xmax + 1, rect.ymax + 1, 3.0f, color);
 
 	/* need scissor test, hvectorscope can draw outside of boundary */
 	GLint scissor[4];
@@ -1240,7 +1241,7 @@ void ui_draw_but_UNITVEC(uiBut *but, ui

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list