Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2013-04-15 19:41:53 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2013-04-15 19:41:53 +0400
commit9b1a7b1cb55ecdc677072b5c7c8e2b598adeb433 (patch)
tree1ee90ae56f72cf8ceae24f538bb09e0a27de40b4 /source/blender/imbuf
parent59ca83c3a9a94efa1e7415c83f0fe2033fcfcd28 (diff)
Fix #34967: Display transform makes byte image with alpha=0 black
Skip premultiplication/de-premultiplication when acquiring display buffer for a byte image. Will make conversion a bit faster also :)
Diffstat (limited to 'source/blender/imbuf')
-rw-r--r--source/blender/imbuf/intern/colormanagement.c35
1 files changed, 28 insertions, 7 deletions
diff --git a/source/blender/imbuf/intern/colormanagement.c b/source/blender/imbuf/intern/colormanagement.c
index b8de1cf75d1..8f4fd2923f8 100644
--- a/source/blender/imbuf/intern/colormanagement.c
+++ b/source/blender/imbuf/intern/colormanagement.c
@@ -1213,7 +1213,7 @@ static void display_buffer_init_handle(void *handle_v, int start_line, int tot_l
handle->float_colorspace = init_data->float_colorspace;
}
-static void *display_buffer_apply_get_linear_buffer(DisplayBufferThread *handle)
+static float *display_buffer_apply_get_linear_buffer(DisplayBufferThread *handle, bool *is_straight_alpha)
{
float *linear_buffer = NULL;
@@ -1248,7 +1248,6 @@ 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);
}
else {
BLI_assert(!"Buffers of 3 or 4 channels are only supported here");
@@ -1258,8 +1257,10 @@ static void *display_buffer_apply_get_linear_buffer(DisplayBufferThread *handle)
if (!is_data && !is_data_display) {
/* convert float buffer to scene linear space */
IMB_colormanagement_transform(linear_buffer, width, height, channels,
- from_colorspace, to_colorspace, TRUE);
+ from_colorspace, to_colorspace, FALSE);
}
+
+ *is_straight_alpha = true;
}
else if (handle->float_colorspace) {
/* currently float is non-linear only in sequencer, which is working
@@ -1275,6 +1276,8 @@ static void *display_buffer_apply_get_linear_buffer(DisplayBufferThread *handle)
IMB_colormanagement_transform(linear_buffer, width, height, channels,
from_colorspace, to_colorspace, TRUE);
+
+ *is_straight_alpha = false;
}
else {
/* some processors would want to modify float original buffer
@@ -1287,6 +1290,8 @@ static void *display_buffer_apply_get_linear_buffer(DisplayBufferThread *handle)
*/
memcpy(linear_buffer, handle->buffer, buffer_size * sizeof(float));
+
+ *is_straight_alpha = false;
}
return linear_buffer;
@@ -1316,7 +1321,9 @@ static void *do_display_buffer_apply_thread(void *handle_v)
}
}
else {
- float *linear_buffer = display_buffer_apply_get_linear_buffer(handle);
+ bool is_straight_alpha;
+ float *linear_buffer = display_buffer_apply_get_linear_buffer(handle, &is_straight_alpha);
+ bool predivide = is_straight_alpha == false;
if (is_data) {
/* special case for data buffers - no color space conversions,
@@ -1325,7 +1332,8 @@ static void *do_display_buffer_apply_thread(void *handle_v)
}
else {
/* apply processor */
- IMB_colormanagement_processor_apply(cm_processor, linear_buffer, width, height, channels, TRUE);
+ IMB_colormanagement_processor_apply(cm_processor, linear_buffer, width, height, channels,
+ predivide);
}
/* copy result to output buffers */
@@ -1333,12 +1341,25 @@ static void *do_display_buffer_apply_thread(void *handle_v)
/* do conversion */
IMB_buffer_byte_from_float(display_buffer_byte, linear_buffer,
channels, dither, IB_PROFILE_SRGB, IB_PROFILE_SRGB,
- TRUE, width, height, width, width);
+ predivide, width, height, width, width);
}
- if (display_buffer)
+ if (display_buffer) {
memcpy(display_buffer, linear_buffer, width * height * channels * sizeof(float));
+ if (is_straight_alpha && channels == 4) {
+ int i;
+ float *fp;
+
+ for (i = 0, fp = display_buffer;
+ i < width * height;
+ i++, fp += channels)
+ {
+ straight_to_premul_v4(fp);
+ }
+ }
+ }
+
MEM_freeN(linear_buffer);
}