[Bf-blender-cvs] [2e36bebc77] temp-blender2.8-stable: cleanup from recent commits

Mike Erwin noreply at git.blender.org
Wed Feb 8 07:44:27 CET 2017


Commit: 2e36bebc774392a7eb4969300e79effc8d1b77c6
Author: Mike Erwin
Date:   Wed Feb 8 01:43:53 2017 -0500
Branches: temp-blender2.8-stable
https://developer.blender.org/rB2e36bebc774392a7eb4969300e79effc8d1b77c6

cleanup from recent commits

coding style, float literals

Converted some (expr / literal) to (expr * literal) where it does not impact readability.

Simplified a few function calls.

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

M	source/blender/editors/animation/anim_channels_defines.c
M	source/blender/editors/interface/interface_draw.c
M	source/blender/editors/space_clip/clip_graph_draw.c

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

diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c
index a7263f9fdb..9b05802552 100644
--- a/source/blender/editors/animation/anim_channels_defines.c
+++ b/source/blender/editors/animation/anim_channels_defines.c
@@ -143,15 +143,14 @@ static void acf_generic_dataexpand_backdrop(bAnimContext *ac, bAnimListElem *ale
 	short offset = (acf->get_offset) ? acf->get_offset(ac, ale) : 0;
 	float color[3];
 
-	VertexFormat *format = immVertexFormat();
-	unsigned pos = add_attrib(format, "pos", GL_FLOAT, 2, KEEP_FLOAT);
-	
+	unsigned pos = add_attrib(immVertexFormat(), "pos", GL_FLOAT, 2, KEEP_FLOAT);
+
 	/* set backdrop drawing color */
 	acf->get_backdrop_color(ac, ale, color);
 
 	immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
 	immUniformColor3fv(color);
-	
+
 	/* no rounded corner - just rectangular box */
 	immRectf(pos, offset, yminc,  v2d->cur.xmax + EXTRA_SCROLL_PAD, ymaxc);
 
@@ -233,8 +232,7 @@ static void acf_generic_channel_backdrop(bAnimContext *ac, bAnimListElem *ale, f
 	short offset = (acf->get_offset) ? acf->get_offset(ac, ale) : 0;
 	float color[3];
 
-	VertexFormat *format = immVertexFormat();
-	unsigned pos = add_attrib(format, "pos", GL_FLOAT, 2, KEEP_FLOAT);
+	unsigned pos = add_attrib(immVertexFormat(), "pos", GL_FLOAT, 2, KEEP_FLOAT);
 	
 	/* set backdrop drawing color */
 	acf->get_backdrop_color(ac, ale, color);
@@ -3864,8 +3862,7 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float
 			/* for F-Curves, draw color-preview of curve behind checkbox */
 			if (ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE)) {
 				FCurve *fcu = (FCurve *)ale->data;
-				VertexFormat *format = immVertexFormat();
-				unsigned pos = add_attrib(format, "pos", GL_FLOAT, 2, KEEP_FLOAT);
+				unsigned pos = add_attrib(immVertexFormat(), "pos", GL_FLOAT, 2, KEEP_FLOAT);
 
 				immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
 				
@@ -3906,12 +3903,7 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float
 		
 		/* set text color */
 		/* XXX: if active, highlight differently? */
-		if (selected) {
-			UI_FontThemeColor(fstyle->uifont_id, TH_TEXT_HI);
-		}
-		else {
-			UI_FontThemeColor(fstyle->uifont_id, TH_TEXT);
-		}
+		UI_FontThemeColor(fstyle->uifont_id, selected ? TH_TEXT_HI : TH_TEXT);
 		
 		/* get name */
 		acf->name(ale, name);
@@ -3921,15 +3913,14 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float
 		
 		/* draw red underline if channel is disabled */
 		if (ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE) && (ale->flag & FCURVE_DISABLED)) {
-			VertexFormat *format = immVertexFormat();
-			unsigned pos = add_attrib(format, "pos", GL_FLOAT, 2, KEEP_FLOAT);
+			unsigned pos = add_attrib(immVertexFormat(), "pos", GL_FLOAT, 2, KEEP_FLOAT);
 
 			immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
 
 			/* FIXME: replace hardcoded color here, and check on extents! */
 			immUniformColor3f(1.0f, 0.0f, 0.0f);
 
-			glLineWidth(2.0);
+			glLineWidth(2.0f);
 
 			immBegin(GL_LINES, 2);
 			immVertex2f(pos, (float)offset, yminc);
@@ -3950,8 +3941,7 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float
 		short draw_sliders = 0;
 		float ymin_ofs = 0.0f;
 		float color[3];
-		VertexFormat *format = immVertexFormat();
-		unsigned pos = add_attrib(format, "pos", GL_FLOAT, 2, KEEP_FLOAT);
+		unsigned pos = add_attrib(immVertexFormat(), "pos", GL_FLOAT, 2, KEEP_FLOAT);
 
 		immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
 		
diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c
index 47497947dc..b1f4db3ff7 100644
--- a/source/blender/editors/interface/interface_draw.c
+++ b/source/blender/editors/interface/interface_draw.c
@@ -492,7 +492,7 @@ void ui_draw_but_IMAGE(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSED(w
 #endif
 	
 	glEnable(GL_BLEND);
-	glColor4f(0.0, 0.0, 0.0, 0.0);
+	glColor4f(0.0f, 0.0f, 0.0f, 0.0f);
 	
 	if (w != ibuf->x || h != ibuf->y) {
 		float facx = (float)w / (float)ibuf->x;
@@ -589,7 +589,7 @@ static void histogram_draw_one(
 	}
 	else {
 		/* under the curve */
-		immBegin(GL_TRIANGLE_STRIP, res*2);
+		immBegin(GL_TRIANGLE_STRIP, res * 2);
 		immVertex2f(pos_attrib, x, y);
 		immVertex2f(pos_attrib, x, y + (data[0] * h));
 		for (int i = 1; i < res; i++) {
@@ -600,7 +600,7 @@ static void histogram_draw_one(
 		immEnd();
 
 		/* curve outline */
-		immUniformColor4f(0.f, 0.f, 0.f, 0.25f);
+		immUniformColor4f(0.0f, 0.0f, 0.0f, 0.25f);
 
 		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
 		immBegin(GL_LINE_STRIP, res);
@@ -653,7 +653,7 @@ void ui_draw_but_HISTOGRAM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol)
 
 	immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
 
-	immUniformColor4f(1.f, 1.f, 1.f, 0.08f);
+	immUniformColor4f(1.0f, 1.0f, 1.0f, 0.08f);
 	/* draw grid lines here */
 	for (int i = 1; i <= HISTOGRAM_TOT_GRID_LINES; i++) {
 		const float fac = (float)i / (float)HISTOGRAM_TOT_GRID_LINES;
@@ -703,7 +703,7 @@ static void waveform_draw_one(float *waveform, int nbr, const float col[3])
 	/* TODO store the Batch inside the scope */
 	Batch *batch = Batch_create(GL_POINTS, vbo, NULL);
 	Batch_set_builtin_program(batch, GPU_SHADER_2D_UNIFORM_COLOR);
-	Batch_Uniform4f(batch, "color", col[0], col[1], col[2], 1.f);
+	Batch_Uniform4f(batch, "color", col[0], col[1], col[2], 1.0f);
 	Batch_draw(batch);
 
 	Batch_discard_all(batch);
@@ -731,7 +731,7 @@ void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol),
 		scopes->wavefrm_yfac = 0.98f;
 	float w = BLI_rctf_size_x(&rect) - 7;
 	float h = BLI_rctf_size_y(&rect) * scopes->wavefrm_yfac;
-	float yofs = rect.ymin + (BLI_rctf_size_y(&rect) - h) / 2.0f;
+	float yofs = rect.ymin + (BLI_rctf_size_y(&rect) - h) * 0.5f;
 	float w3 = w / 3.0f;
 	
 	/* log scale for alpha */
@@ -764,11 +764,10 @@ void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol),
 	/* draw scale numbers first before binding any shader */
 	for (int i = 0; i < 6; i++) {
 		char str[4];
-		const int font_id = BLF_default();
 		BLI_snprintf(str, sizeof(str), "%-3d", i * 20);
 		str[3] = '\0';
-		BLF_color4f(font_id, 1.f, 1.f, 1.f, 0.08f);
-		BLF_draw_default(rect.xmin + 1, yofs - 5 + (i / 5.f) * h, 0, str, sizeof(str) - 1);
+		BLF_color4f(BLF_default(), 1.0f, 1.0f, 1.0f, 0.08f);
+		BLF_draw_default(rect.xmin + 1, yofs - 5 + (i * 0.2f) * h, 0, str, sizeof(str) - 1);
 	}
 
 	glEnable(GL_BLEND);
@@ -779,10 +778,10 @@ void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol),
 
 	immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
 
-	immUniformColor4f(1.f, 1.f, 1.f, 0.08f);
+	immUniformColor4f(1.0f, 1.0f, 1.0f, 0.08f);
 	/* draw grid lines here */
 	for (int i = 0; i < 6; i++) {
-		imm_draw_line(pos, rect.xmin + 22, yofs + (i / 5.f) * h, rect.xmax + 1, yofs + (i / 5.f) * h);
+		imm_draw_line(pos, rect.xmin + 22, yofs + (i * 0.2f) * h, rect.xmax + 1, yofs + (i * 0.2f) * h);
 	}
 	/* 3 vertical separation */
 	if (scopes->wavefrm_mode != SCOPES_WAVEFRM_LUMA) {
@@ -794,7 +793,7 @@ void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol),
 	/* separate min max zone on the right */
 	imm_draw_line(pos, rect.xmin + w, rect.ymin, rect.xmin + w, rect.ymax);
 	/* 16-235-240 level in case of ITU-R BT601/709 */
-	immUniformColor4f(1.f, 0.4f, 0.f, 0.2f);
+	immUniformColor4f(1.0f, 0.4f, 0.0f, 0.2f);
 	if (ELEM(scopes->wavefrm_mode, SCOPES_WAVEFRM_YCC_601, SCOPES_WAVEFRM_YCC_709)) {
 		imm_draw_line(pos, rect.xmin + 22, yofs + h * 16.0f / 255.0f, rect.xmax + 1, yofs + h * 16.0f / 255.0f);
 		imm_draw_line(pos, rect.xmin + 22, yofs + h * 235.0f / 255.0f, rect.xmin + w3, yofs + h * 235.0f / 255.0f);
@@ -815,8 +814,8 @@ void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol),
 			float col[3] = {alpha, alpha, alpha};
 
 			gpuPushMatrix();
-			gpuTranslate3f(rect.xmin, yofs, 0.f);
-			gpuScale3f(w, h, 0.f);
+			gpuTranslate3f(rect.xmin, yofs, 0.0f);
+			gpuScale3f(w, h, 0.0f);
 
 			waveform_draw_one(scopes->waveform_1, scopes->waveform_tot, col);
 
@@ -833,8 +832,8 @@ void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol),
 		/* RGB (3 channel) */
 		else if (scopes->wavefrm_mode == SCOPES_WAVEFRM_RGB) {
 			gpuPushMatrix();
-			gpuTranslate3f(rect.xmin, yofs, 0.f);
-			gpuScale3f(w, h, 0.f);
+			gpuTranslate3f(rect.xmin, yofs, 0.0f);
+			gpuScale3f(w, h, 0.0f);
 
 			waveform_draw_one(scopes->waveform_1, scopes->waveform_tot, colors_alpha[0]);
 			waveform_draw_one(scopes->waveform_2, scopes->waveform_tot, colors_alpha[1]);
@@ -853,15 +852,15 @@ void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol),
 			int rgb = (scopes->wavefrm_mode == SCOPES_WAVEFRM_RGB_PARADE);
 
 			gpuPushMatrix();
-			gpuTranslate3f(rect.xmin, yofs, 0.f);
-			gpuScale3f(w3, h, 0.f);
+			gpuTranslate3f(rect.xmin, yofs, 0.0f);
+			gpuScale3f(w3, h, 0.0f);
 
 			waveform_draw_one(scopes->waveform_1, scopes->waveform_tot, (rgb) ? colors_alpha[0] : colorsycc_alpha[0]);
 
-			gpuTranslate3f(1.f, 0.f, 0.f);
+			gpuTranslate3f(1.0f, 0.0f, 0.0f);
 			waveform_draw_one(scopes->waveform_2, scopes->waveform_tot, (rgb) ? colors_alpha[1] : colorsycc_alpha[1]);
 
-			gpuTranslate3f(1.f, 0.f, 0.f);
+			gpuTranslate3f(1.0f, 0.0f, 0.0f);
 			waveform_draw_one(scopes->waveform_3, scopes->waveform_tot, (rgb) ? colors_alpha[2] : colorsycc_alpha[2]);
 
 			gpuPopMatrix();
@@ -905,7 +904,7 @@ static float polar_to_y(float center, float diam, float ampli, float angle)
 static void vectorscope_draw_target(unsigned int pos, float centerx, float centery, float diam, const float colf[3])
 {
 	float y, u, v;
-	float tangle = 0.f, tampli;
+	float tangle = 0.0f, tampli;
 	float dangle, dampli, dangle2, dampli2;
 
 	rgb_to_yuv(colf[0], colf[1], colf[2], &y, &u, &v);
@@ -972,8 +971,8 @@ void ui_draw_but_VECTORSCOPE(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wco
 	
 	float w = BLI_rctf_size_x(&rect);
 	float h = BLI_rctf_size_y(&rect);
-	float centerx = rect.xmin + w / 2;
-	float centery = rect.ymin + h / 2;
+	float centerx = rect.xmin + 

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list