[Bf-blender-cvs] [ffda096413b] master: Cleanup: meaningful names for color blending
Campbell Barton
noreply at git.blender.org
Sat Apr 28 14:48:56 CEST 2018
Commit: ffda096413b496c3d65d8d64c728020be8699d91
Author: Campbell Barton
Date: Sat Apr 28 14:43:05 2018 +0200
Branches: master
https://developer.blender.org/rBffda096413b496c3d65d8d64c728020be8699d91
Cleanup: meaningful names for color blending
===================================================================
M source/blender/editors/sculpt_paint/paint_vertex_color_utils.c
===================================================================
diff --git a/source/blender/editors/sculpt_paint/paint_vertex_color_utils.c b/source/blender/editors/sculpt_paint/paint_vertex_color_utils.c
index 398512287c4..0cdb1e2f57e 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex_color_utils.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex_color_utils.c
@@ -75,12 +75,12 @@ bool ED_vpaint_color_transform(
}
for (int j = 0; j < mp->totloop; j++, lcol++) {
- float col[3];
- rgb_uchar_to_float(col, &lcol->r);
+ float col_mix[3];
+ rgb_uchar_to_float(col_mix, &lcol->r);
- vpaint_tx_fn(col, user_data, col);
+ vpaint_tx_fn(col_mix, user_data, col_mix);
- rgb_float_to_uchar(&lcol->r, col);
+ rgb_float_to_uchar(&lcol->r, col_mix);
}
}
@@ -96,437 +96,437 @@ bool ED_vpaint_color_transform(
/** \name Color Blending Modes
* \{ */
-BLI_INLINE uint mcol_blend(uint col1, uint col2, int fac)
+BLI_INLINE uint mcol_blend(uint col_src, uint col_dst, int fac)
{
- uchar *cp1, *cp2, *cp;
+ uchar *cp_src, *cp_dst, *cp_mix;
int mfac;
- uint col = 0;
+ uint col_mix = 0;
if (fac == 0) {
- return col1;
+ return col_src;
}
if (fac >= 255) {
- return col2;
+ return col_dst;
}
mfac = 255 - fac;
- cp1 = (uchar *)&col1;
- cp2 = (uchar *)&col2;
- cp = (uchar *)&col;
+ cp_src = (uchar *)&col_src;
+ cp_dst = (uchar *)&col_dst;
+ cp_mix = (uchar *)&col_mix;
/* Updated to use the rgb squared color model which blends nicer. */
- int r1 = cp1[0] * cp1[0];
- int g1 = cp1[1] * cp1[1];
- int b1 = cp1[2] * cp1[2];
- int a1 = cp1[3] * cp1[3];
-
- int r2 = cp2[0] * cp2[0];
- int g2 = cp2[1] * cp2[1];
- int b2 = cp2[2] * cp2[2];
- int a2 = cp2[3] * cp2[3];
-
- cp[0] = round_fl_to_uchar(sqrtf(divide_round_i((mfac * r1 + fac * r2), 255)));
- cp[1] = round_fl_to_uchar(sqrtf(divide_round_i((mfac * g1 + fac * g2), 255)));
- cp[2] = round_fl_to_uchar(sqrtf(divide_round_i((mfac * b1 + fac * b2), 255)));
- cp[3] = round_fl_to_uchar(sqrtf(divide_round_i((mfac * a1 + fac * a2), 255)));
-
- return col;
+ int r1 = cp_src[0] * cp_src[0];
+ int g1 = cp_src[1] * cp_src[1];
+ int b1 = cp_src[2] * cp_src[2];
+ int a1 = cp_src[3] * cp_src[3];
+
+ int r2 = cp_dst[0] * cp_dst[0];
+ int g2 = cp_dst[1] * cp_dst[1];
+ int b2 = cp_dst[2] * cp_dst[2];
+ int a2 = cp_dst[3] * cp_dst[3];
+
+ cp_mix[0] = round_fl_to_uchar(sqrtf(divide_round_i((mfac * r1 + fac * r2), 255)));
+ cp_mix[1] = round_fl_to_uchar(sqrtf(divide_round_i((mfac * g1 + fac * g2), 255)));
+ cp_mix[2] = round_fl_to_uchar(sqrtf(divide_round_i((mfac * b1 + fac * b2), 255)));
+ cp_mix[3] = round_fl_to_uchar(sqrtf(divide_round_i((mfac * a1 + fac * a2), 255)));
+
+ return col_mix;
}
-BLI_INLINE uint mcol_add(uint col1, uint col2, int fac)
+BLI_INLINE uint mcol_add(uint col_src, uint col_dst, int fac)
{
- uchar *cp1, *cp2, *cp;
+ uchar *cp_src, *cp_dst, *cp_mix;
int temp;
- uint col = 0;
+ uint col_mix = 0;
if (fac == 0) {
- return col1;
+ return col_src;
}
- cp1 = (uchar *)&col1;
- cp2 = (uchar *)&col2;
- cp = (uchar *)&col;
+ cp_src = (uchar *)&col_src;
+ cp_dst = (uchar *)&col_dst;
+ cp_mix = (uchar *)&col_mix;
- temp = cp1[0] + divide_round_i((fac * cp2[0]), 255);
- cp[0] = (temp > 254) ? 255 : temp;
- temp = cp1[1] + divide_round_i((fac * cp2[1]), 255);
- cp[1] = (temp > 254) ? 255 : temp;
- temp = cp1[2] + divide_round_i((fac * cp2[2]), 255);
- cp[2] = (temp > 254) ? 255 : temp;
- temp = cp1[3] + divide_round_i((fac * cp2[3]), 255);
- cp[3] = (temp > 254) ? 255 : temp;
+ temp = cp_src[0] + divide_round_i((fac * cp_dst[0]), 255);
+ cp_mix[0] = (temp > 254) ? 255 : temp;
+ temp = cp_src[1] + divide_round_i((fac * cp_dst[1]), 255);
+ cp_mix[1] = (temp > 254) ? 255 : temp;
+ temp = cp_src[2] + divide_round_i((fac * cp_dst[2]), 255);
+ cp_mix[2] = (temp > 254) ? 255 : temp;
+ temp = cp_src[3] + divide_round_i((fac * cp_dst[3]), 255);
+ cp_mix[3] = (temp > 254) ? 255 : temp;
- return col;
+ return col_mix;
}
-BLI_INLINE uint mcol_sub(uint col1, uint col2, int fac)
+BLI_INLINE uint mcol_sub(uint col_src, uint col_dst, int fac)
{
- uchar *cp1, *cp2, *cp;
+ uchar *cp_src, *cp_dst, *cp_mix;
int temp;
- uint col = 0;
+ uint col_mix = 0;
if (fac == 0) {
- return col1;
+ return col_src;
}
- cp1 = (uchar *)&col1;
- cp2 = (uchar *)&col2;
- cp = (uchar *)&col;
+ cp_src = (uchar *)&col_src;
+ cp_dst = (uchar *)&col_dst;
+ cp_mix = (uchar *)&col_mix;
- temp = cp1[0] - divide_round_i((fac * cp2[0]), 255);
- cp[0] = (temp < 0) ? 0 : temp;
- temp = cp1[1] - divide_round_i((fac * cp2[1]), 255);
- cp[1] = (temp < 0) ? 0 : temp;
- temp = cp1[2] - divide_round_i((fac * cp2[2]), 255);
- cp[2] = (temp < 0) ? 0 : temp;
- temp = cp1[3] - divide_round_i((fac * cp2[3]), 255);
- cp[3] = (temp < 0) ? 0 : temp;
+ temp = cp_src[0] - divide_round_i((fac * cp_dst[0]), 255);
+ cp_mix[0] = (temp < 0) ? 0 : temp;
+ temp = cp_src[1] - divide_round_i((fac * cp_dst[1]), 255);
+ cp_mix[1] = (temp < 0) ? 0 : temp;
+ temp = cp_src[2] - divide_round_i((fac * cp_dst[2]), 255);
+ cp_mix[2] = (temp < 0) ? 0 : temp;
+ temp = cp_src[3] - divide_round_i((fac * cp_dst[3]), 255);
+ cp_mix[3] = (temp < 0) ? 0 : temp;
- return col;
+ return col_mix;
}
-BLI_INLINE uint mcol_mul(uint col1, uint col2, int fac)
+BLI_INLINE uint mcol_mul(uint col_src, uint col_dst, int fac)
{
- uchar *cp1, *cp2, *cp;
+ uchar *cp_src, *cp_dst, *cp_mix;
int mfac;
- uint col = 0;
+ uint col_mix = 0;
if (fac == 0) {
- return col1;
+ return col_src;
}
mfac = 255 - fac;
- cp1 = (uchar *)&col1;
- cp2 = (uchar *)&col2;
- cp = (uchar *)&col;
+ cp_src = (uchar *)&col_src;
+ cp_dst = (uchar *)&col_dst;
+ cp_mix = (uchar *)&col_mix;
/* first mul, then blend the fac */
- cp[0] = divide_round_i(mfac * cp1[0] * 255 + fac * cp2[0] * cp1[0], 255 * 255);
- cp[1] = divide_round_i(mfac * cp1[1] * 255 + fac * cp2[1] * cp1[1], 255 * 255);
- cp[2] = divide_round_i(mfac * cp1[2] * 255 + fac * cp2[2] * cp1[2], 255 * 255);
- cp[3] = divide_round_i(mfac * cp1[3] * 255 + fac * cp2[3] * cp1[3], 255 * 255);
+ cp_mix[0] = divide_round_i(mfac * cp_src[0] * 255 + fac * cp_dst[0] * cp_src[0], 255 * 255);
+ cp_mix[1] = divide_round_i(mfac * cp_src[1] * 255 + fac * cp_dst[1] * cp_src[1], 255 * 255);
+ cp_mix[2] = divide_round_i(mfac * cp_src[2] * 255 + fac * cp_dst[2] * cp_src[2], 255 * 255);
+ cp_mix[3] = divide_round_i(mfac * cp_src[3] * 255 + fac * cp_dst[3] * cp_src[3], 255 * 255);
- return col;
+ return col_mix;
}
-BLI_INLINE uint mcol_lighten(uint col1, uint col2, int fac)
+BLI_INLINE uint mcol_lighten(uint col_src, uint col_dst, int fac)
{
- uchar *cp1, *cp2, *cp;
+ uchar *cp_src, *cp_dst, *cp_mix;
int mfac;
- uint col = 0;
+ uint col_mix = 0;
if (fac == 0) {
- return col1;
+ return col_src;
}
else if (fac >= 255) {
- return col2;
+ return col_dst;
}
mfac = 255 - fac;
- cp1 = (uchar *)&col1;
- cp2 = (uchar *)&col2;
- cp = (uchar *)&col;
+ cp_src = (uchar *)&col_src;
+ cp_dst = (uchar *)&col_dst;
+ cp_mix = (uchar *)&col_mix;
/* See if are lighter, if so mix, else don't do anything.
- * if the paint col is darker then the original, then ignore */
- if (IMB_colormanagement_get_luminance_byte(cp1) > IMB_colormanagement_get_luminance_byte(cp2)) {
- return col1;
+ * if the paint color is darker then the original, then ignore */
+ if (IMB_colormanagement_get_luminance_byte(cp_src) > IMB_colormanagement_get_luminance_byte(cp_dst)) {
+ return col_src;
}
- cp[0] = divide_round_i(mfac * cp1[0] + fac * cp2[0], 255);
- cp[1] = divide_round_i(mfac * cp1[1] + fac * cp2[1], 255);
- cp[2] = divide_round_i(mfac * cp1[2] + fac * cp2[2], 255);
- cp[3] = divide_round_i(mfac * cp1[3] + fac * cp2[3], 255);
+ cp_mix[0] = divide_round_i(mfac * cp_src[0] + fac * cp_dst[0], 255);
+ cp_mix[1] = divide_round_i(mfac * cp_src[1] + fac * cp_dst[1], 255);
+ cp_mix[2] = divide_round_i(mfac * cp_src[2] + fac * cp_dst[2], 255);
+ cp_mix[3] = divide_round_i(mfac * cp_src[3] + fac * cp_dst[3], 255);
- return col;
+ return col_mix;
}
-BLI_INLINE uint mcol_darken(uint col1, uint col2, int fac)
+BLI_INLINE uint mcol_darken(uint col_src, uint col_dst, int fac)
{
- uchar *cp1, *cp2, *cp;
+ uchar *cp_src, *cp_dst, *cp_mix;
int mfac;
- uint col = 0;
+ uint col_mix = 0;
if (fac == 0) {
- return col1;
+ return col_src;
}
else if (fac >= 255) {
- return col2;
+ return col_dst;
}
mfac = 255 - fac;
- cp1 = (uchar *)&col1;
- cp2 = (uchar *)&col2;
- cp = (uchar *)&col;
+ cp_src = (uchar *)&col_src;
+ cp_dst = (uchar *)&col_dst;
+ cp_mix = (uchar *)&col_mix;
/* See if were darker, if so mix, else don't do anything.
- * if the paint col is brighter then the original, then ignore */
- if (IMB_colormanagement_get_luminance_byte(cp1) < IMB_colormanagement_get_luminance_byte(cp2)) {
- return col1;
+ * if the paint color is brighter then the original, then ignore */
+ if (IMB_colormanagement_get_luminance_byte(cp_src) < IMB_colormanagement_get_luminance_byte(cp_dst)) {
+ return col_src;
}
- cp[0] = divide_round_i((mfac * cp1[0] + fac * cp2[0]), 255);
- cp[1] = divide_round_i((mfac * cp1[1] + fac * cp2[1]), 255);
- cp[2] = divide_round_i((mfac * cp1[2] + fac * cp2[2]), 255);
- cp[3] = divide_round_i((mfac * cp1[3] + fac * cp2[3]), 255);
- return col;
+ cp_mix[0] = divide_round_i((mfac * cp_src[0] + fac * cp_dst[0]), 255);
+ cp_mix[1] = divide_round_i((mfac * cp_src[1] + fac * cp_dst[1]), 255);
+ cp_mix[2] = divide_round_i((mfac * cp_src[2] + fac * cp_dst[2]), 255);
+ cp_mix[3] = divide_round_i((mfac * cp_src[3] + fac * cp_dst[3]), 255);
+ return col_mix;
}
-BLI_INLINE uint mcol_colordodge(uint col1, uint col2, int fac)
+BLI_INLINE uint mcol_colordodge(uint col_src, uint col_dst, int fac)
{
- uchar *cp1, *cp2, *cp;
+ uchar *cp_src, *cp_dst, *cp_mix;
int mfac, temp;
- uint col = 0;
+ uint col_mix = 0;
if (fac == 0) {
- return col1;
+ return col_src;
}
mfac = 255 - fac;
- cp1 = (uchar *)&col1;
- cp2 = (uchar *)&col2;
- cp = (uchar *)&col;
-
- temp = (cp2[0] == 255) ? 255 : min_ii((cp1[0] * 225) / (255 - cp2[0]), 255);
- cp[0] = (mfac * cp1[0] + temp * fac) / 255;
- temp = (cp2[1] == 255) ? 255 : min_ii((cp1[1] * 225) / (255 - cp2[1]), 255);
- cp[1] = (mfac * cp1[1] + temp * fac) / 255;
- temp = (cp2[2] == 255) ? 255 : min
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list