[Bf-blender-cvs] [05cf746] blender2.8: more theme color functions: UI_GetThemeColorBlendShade4fv, immUniformThemeColorBlendShade

Dalai Felinto noreply at git.blender.org
Thu Oct 13 22:09:19 CEST 2016


Commit: 05cf74622f6b50d92cf077dcfb9d5086f4018e50
Author: Dalai Felinto
Date:   Thu Oct 13 20:06:44 2016 +0000
Branches: blender2.8
https://developer.blender.org/rB05cf74622f6b50d92cf077dcfb9d5086f4018e50

more theme color functions: UI_GetThemeColorBlendShade4fv, immUniformThemeColorBlendShade

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

M	source/blender/editors/include/UI_resources.h
M	source/blender/editors/interface/resources.c
M	source/blender/gpu/GPU_immediate.h
M	source/blender/gpu/intern/gpu_immediate.c

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

diff --git a/source/blender/editors/include/UI_resources.h b/source/blender/editors/include/UI_resources.h
index b3641f3..be03647 100644
--- a/source/blender/editors/include/UI_resources.h
+++ b/source/blender/editors/include/UI_resources.h
@@ -353,6 +353,8 @@ void    UI_GetThemeColor4fv(int colorid, float col[4]);
 // get four color values, range 0.0-1.0, complete with shading offset for the RGB components
 void    UI_GetThemeColorShade4fv(int colorid, int offset, float col[4]);
 void	UI_GetThemeColorShadeAlpha4fv(int colorid, int coloffset, int alphaoffset, float col[4]);
+// get four color values, range 0.0-1.0, complete with shading offset for the RGB components and blending
+void    UI_GetThemeColorBlendShade4fv(int colorid1, int colorid2, float fac, int offset, float col[4]);
 
 // get the 3 or 4 byte values
 void UI_GetThemeColor3ubv(int colorid, unsigned char col[3]);
diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c
index 9d9cae6..4cd2b5b 100644
--- a/source/blender/editors/interface/resources.c
+++ b/source/blender/editors/interface/resources.c
@@ -1488,6 +1488,31 @@ void UI_GetThemeColorShadeAlpha4fv(int colorid, int coloffset, int alphaoffset,
 	col[3] = ((float)a) / 255.0f;
 }
 
+void UI_GetThemeColorBlendShade4fv(int colorid1, int colorid2, float fac, int offset, float col[4])
+{
+	int r, g, b, a;
+	const unsigned char *cp1, *cp2;
+
+	cp1 = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid1);
+	cp2 = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid2);
+
+	CLAMP(fac, 0.0f, 1.0f);
+
+	r = offset + floorf((1.0f - fac) * cp1[0] + fac * cp2[0]);
+	CLAMP(r, 0, 255);
+	g = offset + floorf((1.0f - fac) * cp1[1] + fac * cp2[1]);
+	CLAMP(g, 0, 255);
+	b = offset + floorf((1.0f - fac) * cp1[2] + fac * cp2[2]);
+	CLAMP(b, 0, 255);
+	a = offset + floorf((1.0f - fac) * cp1[3] + fac * cp2[3]);
+	CLAMP(a, 0, 255);
+
+	col[0] = ((float)r) / 255.0f;
+	col[1] = ((float)g) / 255.0f;
+	col[2] = ((float)b) / 255.0f;
+	col[3] = ((float)a) / 255.0f;
+}
+
 /* get the color, in char pointer */
 void UI_GetThemeColor3ubv(int colorid, unsigned char col[3])
 {
diff --git a/source/blender/gpu/GPU_immediate.h b/source/blender/gpu/GPU_immediate.h
index cce5f51..1b4f26a 100644
--- a/source/blender/gpu/GPU_immediate.h
+++ b/source/blender/gpu/GPU_immediate.h
@@ -43,3 +43,4 @@ void immBindBuiltinProgram(GPUBuiltinShader shader_id);
  */
 void immUniformThemeColor(int colorid);
 void immUniformThemeColorShade(int colorid, int offset);
+void immUniformThemeColorBlendShade(int colorid1, int colorid2, float fac, int offset);
diff --git a/source/blender/gpu/intern/gpu_immediate.c b/source/blender/gpu/intern/gpu_immediate.c
index 444a885..e0241db 100644
--- a/source/blender/gpu/intern/gpu_immediate.c
+++ b/source/blender/gpu/intern/gpu_immediate.c
@@ -50,4 +50,11 @@ void immUniformThemeColorShade(int colorid, int offset)
 	float color[4];
 	UI_GetThemeColorShade4fv(colorid, offset, color);
 	immUniformColor4fv(color);
-}
\ No newline at end of file
+}
+
+void immUniformThemeColorBlendShade(int colorid1, int colorid2, float fac, int offset)
+{
+	float color[4];
+	UI_GetThemeColorBlendShade4fv(colorid1, colorid2, fac, offset, color);
+	immUniformColor4fv(color);
+}




More information about the Bf-blender-cvs mailing list