[Bf-blender-cvs] [834b0b8262f] temp-vr-draw-thread: Share code of new functions in resources.c
Julian Eisel
noreply at git.blender.org
Tue Aug 6 15:48:33 CEST 2019
Commit: 834b0b8262fc84dce3b8fc16f3cc72529b178893
Author: Julian Eisel
Date: Mon Aug 5 18:38:23 2019 +0200
Branches: temp-vr-draw-thread
https://developer.blender.org/rB834b0b8262fc84dce3b8fc16f3cc72529b178893
Share code of new functions in resources.c
===================================================================
M source/blender/editors/interface/resources.c
===================================================================
diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c
index 2a940bc5ce0..7db872b46b7 100644
--- a/source/blender/editors/interface/resources.c
+++ b/source/blender/editors/interface/resources.c
@@ -1233,24 +1233,12 @@ void UI_GetThemeColorShade4ubv(int colorid, int offset, uchar col[4])
void UI_GetThemeColorShadeAlpha4fv(int colorid, int coloffset, int alphaoffset, float col[4])
{
- int r, g, b, a;
const uchar *cp;
+ float cp_f[4];
cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
-
- r = coloffset + (int)cp[0];
- CLAMP(r, 0, 255);
- g = coloffset + (int)cp[1];
- CLAMP(g, 0, 255);
- b = coloffset + (int)cp[2];
- CLAMP(b, 0, 255);
- a = alphaoffset + (int)cp[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;
+ rgba_uchar_to_float(cp_f, cp);
+ UI_GetColorPtrShadeAlpha4fv(cp_f, col, coloffset, alphaoffset);
}
void UI_GetThemeColorBlendShade3fv(int colorid1, int colorid2, float fac, int offset, float col[3])
@@ -1277,27 +1265,14 @@ void UI_GetThemeColorBlendShade3fv(int colorid1, int colorid2, float fac, int of
void UI_GetThemeColorBlendShade4fv(int colorid1, int colorid2, float fac, int offset, float col[4])
{
- int r, g, b, a;
const uchar *cp1, *cp2;
+ float cp1_f[4], cp2_f[4];
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;
+ rgba_uchar_to_float(cp1_f, cp1);
+ rgba_uchar_to_float(cp2_f, cp2);
+ UI_GetColorPtrBlendShade4fv(cp1_f, cp2_f, col, fac, offset);
}
/* get the color, in char pointer */
@@ -1314,25 +1289,12 @@ void UI_GetThemeColor3ubv(int colorid, uchar col[3])
/* get the color, range 0.0-1.0, complete with shading offset */
void UI_GetThemeColorShade4fv(int colorid, int offset, float col[4])
{
- int r, g, b, a;
const uchar *cp;
+ float cp_f[4];
cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
-
- r = offset + (int)cp[0];
- CLAMP(r, 0, 255);
- g = offset + (int)cp[1];
- CLAMP(g, 0, 255);
- b = offset + (int)cp[2];
- CLAMP(b, 0, 255);
-
- a = (int)cp[3]; /* no shading offset... */
- 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;
+ rgba_uchar_to_float(cp_f, cp);
+ UI_GetColorPtrShadeAlpha4fv(cp_f, col, offset, 0);
}
/* get the color, in char pointer */
More information about the Bf-blender-cvs
mailing list