Follow general mathutils rules for naming straight<->premul functions
authorSergey Sharybin <sergey.vfx@gmail.com>
Tue, 15 Jan 2013 08:37:17 +0000 (08:37 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Tue, 15 Jan 2013 08:37:17 +0000 (08:37 +0000)
source/blender/blenlib/BLI_math_color.h
source/blender/blenlib/intern/math_color_inline.c
source/blender/imbuf/intern/colormanagement.c
source/blender/imbuf/intern/divers.c
source/blender/imbuf/intern/png.c

index 3831ec3cbb4110f3a7054822d50b174de6d05fc5..145427ea52952088f86003f75dc3f5535f5ab8ec 100644 (file)
@@ -102,8 +102,10 @@ void BLI_init_srgb_conversion(void);
 
 /**************** Alpha Transformations *****************/
 
-MINLINE void premul_to_straight_v4(float straight[4], const float premul[4]);
-MINLINE void straight_to_premul_v4(float straight[4], const float premul[4]);
+MINLINE void premul_to_straight_v4_v4(float straight[4], const float premul[4]);
+MINLINE void premul_to_straight_v4(float color[4]);
+MINLINE void straight_to_premul_v4_v4(float straight[4], const float premul[4]);
+MINLINE void straight_to_premul_v4(float color[4]);
 MINLINE void straight_uchar_to_premul_float(float result[4], const unsigned char color[4]);
 MINLINE void premul_float_to_straight_uchar(unsigned char *result, const float color[4]);
 
index b8eeca50db665f7501ac84df6c40b31cc0072410..c24da9fcf80a96c9d125278f2a802549fd00fb4d 100644 (file)
@@ -270,7 +270,7 @@ MINLINE int compare_rgb_uchar(const unsigned char col_a[3], const unsigned char
 
 /**************** Alpha Transformations *****************/
 
-MINLINE void premul_to_straight_v4(float straight[4], const float premul[4])
+MINLINE void premul_to_straight_v4_v4(float straight[4], const float premul[4])
 {
        if (premul[3] == 0.0f || premul[3] == 1.0f) {
                straight[0] = premul[0];
@@ -287,7 +287,12 @@ MINLINE void premul_to_straight_v4(float straight[4], const float premul[4])
        }
 }
 
-MINLINE void straight_to_premul_v4(float premul[4], const float straight[4])
+MINLINE void premul_to_straight_v4(float color[4])
+{
+       premul_to_straight_v4_v4(color, color);
+}
+
+MINLINE void straight_to_premul_v4_v4(float premul[4], const float straight[4])
 {
        float alpha = straight[3];
        premul[0] = straight[0] * alpha;
@@ -296,6 +301,11 @@ MINLINE void straight_to_premul_v4(float premul[4], const float straight[4])
        premul[3] = straight[3];
 }
 
+MINLINE void straight_to_premul_v4(float color[4])
+{
+       straight_to_premul_v4_v4(color, color);
+}
+
 MINLINE void straight_uchar_to_premul_float(float result[4], const unsigned char color[4])
 {
        float alpha = color[3] / 255.0f;
index 2c6e46cb664864ff3c73e0294cb10d37729200d5..86f47fe07c47b50152f63512fce25d4b7b7c78f7 100644 (file)
@@ -1222,7 +1222,7 @@ static void *display_buffer_apply_get_linear_buffer(DisplayBufferThread *handle)
                        }
                        else if (channels == 4) {
                                rgba_uchar_to_float(fp, cp);
-                               straight_to_premul_v4(fp, fp);
+                               straight_to_premul_v4(fp);
                        }
                        else {
                                BLI_assert(!"Buffers of 3 or 4 channels are only supported here");
@@ -2347,7 +2347,7 @@ static void partial_buffer_update_rect(ImBuf *ibuf, unsigned char *display_buffe
                        else if (byte_buffer) {
                                rgba_uchar_to_float(pixel, byte_buffer + linear_index);
                                IMB_colormanagement_colorspace_to_scene_linear_v3(pixel, rect_colorspace);
-                               straight_to_premul_v4(pixel, pixel);
+                               straight_to_premul_v4(pixel);
                        }
 
                        if (!is_data) {
@@ -2361,7 +2361,7 @@ static void partial_buffer_update_rect(ImBuf *ibuf, unsigned char *display_buffe
                        }
                        else {
                                float pixel_straight[4];
-                               premul_to_straight_v4(pixel_straight, pixel);
+                               premul_to_straight_v4_v4(pixel_straight, pixel);
                                rgba_float_to_uchar(display_buffer + display_index, pixel_straight);
                        }
                }
index 84339b51721e469362f7bffc6409ae00e08f165d..20d51fddb359de4b07ee4cdf995b55f88666d37d 100644 (file)
@@ -255,7 +255,7 @@ void IMB_buffer_byte_from_float(uchar *rect_to, const float *rect_from,
                                /* no color space conversion */
                                if (dither && predivide) {
                                        for (x = 0; x < width; x++, from += 4, to += 4) {
-                                               premul_to_straight_v4(straight, from);
+                                               premul_to_straight_v4_v4(straight, from);
                                                float_to_byte_dither_v4(to, straight, di);
                                        }
                                }
@@ -265,7 +265,7 @@ void IMB_buffer_byte_from_float(uchar *rect_to, const float *rect_from,
                                }
                                else if (predivide) {
                                        for (x = 0; x < width; x++, from += 4, to += 4) {
-                                               premul_to_straight_v4(straight, from);
+                                               premul_to_straight_v4_v4(straight, from);
                                                rgba_float_to_uchar(to, straight);
                                        }
                                }
@@ -281,7 +281,7 @@ void IMB_buffer_byte_from_float(uchar *rect_to, const float *rect_from,
 
                                if (dither && predivide) {
                                        for (x = 0; x < width; x++, from += 4, to += 4) {
-                                               premul_to_straight_v4(straight, from);
+                                               premul_to_straight_v4_v4(straight, from);
                                                linearrgb_to_srgb_ushort4(us, from);
                                                ushort_to_byte_dither_v4(to, us, di);
                                        }
@@ -294,7 +294,7 @@ void IMB_buffer_byte_from_float(uchar *rect_to, const float *rect_from,
                                }
                                else if (predivide) {
                                        for (x = 0; x < width; x++, from += 4, to += 4) {
-                                               premul_to_straight_v4(straight, from);
+                                               premul_to_straight_v4_v4(straight, from);
                                                linearrgb_to_srgb_ushort4(us, from);
                                                ushort_to_byte_v4(to, us);
                                        }
@@ -690,20 +690,20 @@ void IMB_buffer_float_clamp(float *buf, int width, int height)
 void IMB_buffer_float_unpremultiply(float *buf, int width, int height)
 {
        int total = width * height;
-       float *cp = buf;
+       float *fp = buf;
        while (total--) {
-               premul_to_straight_v4(cp, cp);
-               cp += 4;
+               premul_to_straight_v4(fp);
+               fp += 4;
        }
 }
 
 void IMB_buffer_float_premultiply(float *buf, int width, int height)
 {
        int total = width * height;
-       float *cp = buf;
+       float *fp = buf;
        while (total--) {
-               straight_to_premul_v4(cp, cp);
-               cp += 4;
+               straight_to_premul_v4(fp);
+               fp += 4;
        }
 }
 
index 02aea4b9965f7e01ae651e1eb6d3bbd0058da342..cc73f688e703a660f637649c4edbfa0309333dae 100644 (file)
@@ -204,7 +204,7 @@ int imb_savepng(struct ImBuf *ibuf, const char *name, int flags)
                        if (is_16bit) {
                                if (has_float) {
                                        for (i = ibuf->x * ibuf->y; i > 0; i--) {
-                                               premul_to_straight_v4(from_straight, from_float);
+                                               premul_to_straight_v4_v4(from_straight, from_float);
                                                to16[0] = ftoshort(chanel_colormanage_cb(from_straight[0]));
                                                to16[1] = ftoshort(chanel_colormanage_cb(from_straight[1]));
                                                to16[2] = ftoshort(chanel_colormanage_cb(from_straight[2]));
@@ -237,7 +237,7 @@ int imb_savepng(struct ImBuf *ibuf, const char *name, int flags)
                        if (is_16bit) {
                                if (has_float) {
                                        for (i = ibuf->x * ibuf->y; i > 0; i--) {
-                                               premul_to_straight_v4(from_straight, from_float);
+                                               premul_to_straight_v4_v4(from_straight, from_float);
                                                to16[0] = ftoshort(chanel_colormanage_cb(from_straight[0]));
                                                to16[1] = ftoshort(chanel_colormanage_cb(from_straight[1]));
                                                to16[2] = ftoshort(chanel_colormanage_cb(from_straight[2]));
@@ -267,7 +267,7 @@ int imb_savepng(struct ImBuf *ibuf, const char *name, int flags)
                        if (is_16bit) {
                                if (has_float) {
                                        for (i = ibuf->x * ibuf->y; i > 0; i--) {
-                                               premul_to_straight_v4(from_straight, from_float);
+                                               premul_to_straight_v4_v4(from_straight, from_float);
                                                to16[0] = ftoshort(chanel_colormanage_cb(from_straight[0]));
                                                to16++; from_float += 4;
                                        }