Follow general mathutils rules for naming straight<->premul functions
This commit is contained in:
@@ -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]);
|
||||
|
||||
|
@@ -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;
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
|
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user