[Bf-blender-cvs] [af61b5eb0c1] blender2.8: cleanup use of immUniformColor

Mike Erwin noreply at git.blender.org
Sun Apr 16 19:45:25 CEST 2017


Commit: af61b5eb0c1bef93e8df1434b174944e2b40445d
Author: Mike Erwin
Date:   Sun Apr 16 13:44:34 2017 -0400
Branches: blender2.8
https://developer.blender.org/rBaf61b5eb0c1bef93e8df1434b174944e2b40445d

cleanup use of immUniformColor

- use best function for the job
- don't specify alpha if 100%
- 'f' for floating point literals

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

M	source/blender/editors/interface/interface_widgets.c
M	source/blender/editors/space_action/action_draw.c
M	source/blender/editors/space_graph/graph_draw.c
M	source/blender/editors/space_image/image_draw.c
M	source/blender/editors/space_nla/nla_draw.c
M	source/blender/editors/space_outliner/outliner_draw.c
M	source/blender/editors/space_sequencer/sequencer_draw.c
M	source/blender/editors/space_view3d/drawobject.c
M	source/blender/windowmanager/intern/wm_gesture.c
M	source/blender/windowmanager/intern/wm_playanim.c

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

diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index 20add65d02f..d0ec40bbb70 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -703,7 +703,7 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol)
 				widget_draw_vertex_buffer(pos, 0, GL_TRIANGLE_FAN, wtb->inner_v, NULL, wtb->totvert);
 
 				/* 1/2 solid color */
-				immUniformColor4ub(wcol->inner[0], wcol->inner[1], wcol->inner[2], 255);
+				immUniformColor3ubv((unsigned char *)wcol->inner);
 
 				for (a = 0; a < wtb->totvert; a++) {
 					inner_v_half[a][0] = MIN2(wtb->inner_v[a][0], x_mid);
@@ -3165,7 +3165,7 @@ static void widget_swatch(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat
 		unsigned int pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT);
 		immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
 
-		immUniformColor4f(bw, bw, bw, 1.0f);
+		immUniformColor3f(bw, bw, bw);
 		immBegin(PRIM_TRIANGLES, 3);
 		immVertex2f(pos, rect->xmin + 0.1f * width, rect->ymin + 0.9f * height);
 		immVertex2f(pos, rect->xmin + 0.1f * width, rect->ymin + 0.5f * height);
diff --git a/source/blender/editors/space_action/action_draw.c b/source/blender/editors/space_action/action_draw.c
index 6d6d649b12a..1cf97af7a35 100644
--- a/source/blender/editors/space_action/action_draw.c
+++ b/source/blender/editors/space_action/action_draw.c
@@ -239,16 +239,14 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
 						case ANIMTYPE_SCENE:
 						case ANIMTYPE_OBJECT:
 						{
-							if (sel) immUniformColor4ub(col1b[0], col1b[1], col1b[2], 0x45);
-							else immUniformColor4ub(col1b[0], col1b[1], col1b[2], 0x22);
+							immUniformColor3ubvAlpha(col1b, sel ? 0x45 : 0x22);
 							break;
 						}
 						case ANIMTYPE_FILLACTD:
 						case ANIMTYPE_DSSKEY:
 						case ANIMTYPE_DSWOR:
 						{
-							if (sel) immUniformColor4ub(col2b[0], col2b[1], col2b[2], 0x45);
-							else immUniformColor4ub(col2b[0], col2b[1], col2b[2], 0x22);
+							immUniformColor3ubvAlpha(col2b, sel ? 0x45 : 0x22);
 							break;
 						}
 						case ANIMTYPE_GROUP:
@@ -256,17 +254,14 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
 							bActionGroup *agrp = ale->data;
 							if (show_group_colors && agrp->customCol) {
 								if (sel) {
-									char *cp = agrp->cs.select;
-									immUniformColor4ub(cp[0], cp[1], cp[2], 0x45);
+									immUniformColor3ubvAlpha((unsigned char *)agrp->cs.select, 0x45);
 								}
 								else {
-									char *cp = agrp->cs.solid;
-									immUniformColor4ub(cp[0], cp[1], cp[2], 0x1D);
+									immUniformColor3ubvAlpha((unsigned char *)agrp->cs.solid, 0x1D);
 								}
 							}
 							else {
-								if (sel) immUniformColor4ub(col1a[0], col1a[1], col1a[2], 0x22);
-								else immUniformColor4ub(col2a[0], col2a[1], col2a[2], 0x22);
+								immUniformColor3ubvAlpha(sel ? col1a : col2a, 0x22);
 							}
 							break;
 						}
@@ -274,22 +269,16 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
 						{
 							FCurve *fcu = ale->data;
 							if (show_group_colors && fcu->grp && fcu->grp->customCol) {
-								unsigned char *cp = (unsigned char *)fcu->grp->cs.active;
-								
-								if (sel) immUniformColor4ub(cp[0], cp[1], cp[2], 0x65);
-								else immUniformColor4ub(cp[0], cp[1], cp[2], 0x0B);
+								immUniformColor3ubvAlpha((unsigned char *)fcu->grp->cs.active, sel ? 0x65 : 0x0B);
 							}
 							else {
-								if (sel) immUniformColor4ub(col1[0], col1[1], col1[2], 0x22);
-								else immUniformColor4ub(col2[0], col2[1], col2[2], 0x22);
+								immUniformColor3ubvAlpha(sel ? col1 : col2, 0x22);
 							}
 							break;
 						}
 						default:
 						{
-							if (sel) immUniformColor4ub(col1[0], col1[1], col1[2], 0x22);
-							else immUniformColor4ub(col2[0], col2[1], col2[2], 0x22);
-							break;
+							immUniformColor3ubvAlpha(sel ? col1 : col2, 0x22);
 						}
 					}
 					
@@ -301,25 +290,21 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
 				}
 				else if (ac->datatype == ANIMCONT_GPENCIL) {
 					/* frames less than one get less saturated background */
-					if (sel) immUniformColor4ub(col1[0], col1[1], col1[2], 0x22);
-					else immUniformColor4ub(col2[0], col2[1], col2[2], 0x22);
+					immUniformColor3ubvAlpha(sel ? col1 : col2, 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) immUniformColor4ub(col1[0], col1[1], col1[2], 0x44);
-					else immUniformColor4ub(col2[0], col2[1], col2[2], 0x44);
+					immUniformColor3ubvAlpha(sel ? col1 : col2, 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) immUniformColor4ub(col1[0], col1[1], col1[2], 0x22);
-					else immUniformColor4ub(col2[0], col2[1], col2[2], 0x22);
+					immUniformColor3ubvAlpha(sel ? col1 : col2, 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) immUniformColor4ub(col1[0], col1[1], col1[2], 0x44);
-					else immUniformColor4ub(col2[0], col2[1], col2[2], 0x44);
+					immUniformColor3ubvAlpha(sel ? col1 : col2, 0x44);
 					immRectf(pos, v2d->cur.xmin, (float)y - ACHANNEL_HEIGHT_HALF(ac), v2d->cur.xmax + EXTRA_SCROLL_PAD,  (float)y + ACHANNEL_HEIGHT_HALF(ac));
 				}
 			}
diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c
index 37ce5d8075b..a732cc77aa9 100644
--- a/source/blender/editors/space_graph/graph_draw.c
+++ b/source/blender/editors/space_graph/graph_draw.c
@@ -952,7 +952,7 @@ void graph_draw_ghost_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar)
 		 *  - this is set by the function which creates these
 		 *	- draw with a fixed opacity of 2
 		 */
-		immUniformColor4f(fcu->color[0], fcu->color[1], fcu->color[2], 0.5f);
+		immUniformColor3fvAlpha(fcu->color, 0.5f);
 		
 		/* simply draw the stored samples */
 		draw_fcurve_curve_samples(ac, NULL, fcu, &ar->v2d, pos);
@@ -1036,7 +1036,7 @@ void graph_draw_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGrid
 				/* set whatever color the curve has set
 				 *	- unselected curves draw less opaque to help distinguish the selected ones
 				 */
-				immUniformColor4f(fcu->color[0], fcu->color[1], fcu->color[2], fcurve_display_alpha(fcu));
+				immUniformColor3fvAlpha(fcu->color, fcurve_display_alpha(fcu));
 			}
 
 			/* draw F-Curve */
diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c
index f66234ab22c..cdd9906271c 100644
--- a/source/blender/editors/space_image/image_draw.c
+++ b/source/blender/editors/space_image/image_draw.c
@@ -355,7 +355,7 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, bool color_manage, bool use_d
 		immRecti(pos, color_rect_half.xmin, color_rect_half.ymin, color_quater_x, color_quater_y);
 
 		glEnable(GL_BLEND);
-		immUniformColor4f(UNPACK3(finalcol), fp ? fp[3] : (cp[3] / 255.0f));
+		immUniformColor3fvAlpha(finalcol, fp ? fp[3] : (cp[3] / 255.0f));
 		immRecti(pos, color_rect.xmin, color_rect.ymin, color_rect.xmax, color_rect.ymax);
 		glDisable(GL_BLEND);
 	}
diff --git a/source/blender/editors/space_nla/nla_draw.c b/source/blender/editors/space_nla/nla_draw.c
index 576e3eb2d60..1898ee41c40 100644
--- a/source/blender/editors/space_nla/nla_draw.c
+++ b/source/blender/editors/space_nla/nla_draw.c
@@ -286,7 +286,7 @@ static void nla_strip_get_color_inside(AnimData *adt, NlaStrip *strip, float col
 /* helper call for drawing influence/time control curves for a given NLA-strip */
 static void nla_draw_strip_curves(NlaStrip *strip, float yminc, float ymaxc, unsigned int pos)
 {
-	immUniformColor4f(0.7f, 0.7f, 0.7f, 1.0f);
+	immUniformColor3f(0.7f, 0.7f, 0.7f);
 
 	const float yheight = ymaxc - yminc;
 		
@@ -674,7 +674,7 @@ void draw_nla_main_data(bAnimContext *ac, SpaceNla *snla, ARegion *ar)
 					/* draw 'embossed' lines above and below the strip for effect */
 					/* white base-lines */
 					glLineWidth(2.0f);
-					immUniformColor4f(1.0f, 1.0f, 1.0f, 0.3);
+					immUniformColor4f(1.0f, 1.0f, 1.0f, 0.3f);
 					immBegin(PRIM_LINES, 4);
 					immVertex2f(pos, v2d->cur.xmin, yminc + NLACHANNEL_SKIP);
 					immVertex2f(pos, v2d->cur.xmax, yminc + NLACHANNEL_SKIP);
diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c
index bf620686c74..82fdee675b9 100644
--- a/source/blender/editors/space_outliner/outliner_draw.c
+++ b/source/blender/editors/space_outliner/outliner_draw.c
@@ -1527,14 +1527,14 @@ static void outliner_draw_tree_element_floating(
 	unsigned int pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT);
 	int coord_y = te_insert->ys;
 	int coord_x = te_insert->xs;
-	unsigned char col[4];
+	float col[4];
 
 	if (te_insert == te_floating) {
 		/* don't draw anything */
 		return;
 	}
 
-	UI_GetThemeColorShade4ubv(TH_BACK, -40, col);
+	UI_GetThemeColorShade4fv(TH_BACK, -40, col);
 	immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
 	glEnable(GL_BLEND);
 
@@ -1542,7 +1542,7 @@ static void outliner_draw_tree_element_floating(
 		if (te_floating->drag_data->insert_type == TE_INSERT_BEFORE) {
 			coord_y += UI_UNIT_Y;
 		}
-		immUniformColor4ubv(col);
+		immUniformColor4fv(col);
 		glLineWidth(line_width);
 
 		immBegin(PRIM_LINE_STRIP, 2);
@@ -1552,7 +1552,7 @@ static void outliner_draw_tree_element_floating(
 	}
 	else {
 		BLI_assert(te_floating->drag_data->insert_type == TE_INSERT_INTO);
-		immUniformColor4ub(UNPACK3(col), col[3] * 0.5f);
+		immUniformColor3fvAlpha(col, col[

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list