forked from bartvdbraak/blender
Fix #32763: Image flickering appears if Movie Clip Editor and compositor opened
The issue was caused by compositor was allocating float buffer for image and then this buffer was filled with data converted from byte buffer. If display happens at time between float was allocated and it was filled black areas were appearing on the screen. Made it so IMB_float_from_rect locks color management thread so display transform wouldn't use uninitialized buffer anymore.
This commit is contained in:
parent
282f98a84d
commit
41202e25e7
@ -88,6 +88,13 @@ static int global_tot_colorspace = 0;
|
||||
static int global_tot_display = 0;
|
||||
static int global_tot_view = 0;
|
||||
|
||||
/* lock used by pre-cached processors getters, so processor wouldn't
|
||||
* be created several times
|
||||
* LOCK_COLORMANAGE can not be used since this mutex could be needed to
|
||||
* be locked before pre-cached processor are creating
|
||||
*/
|
||||
static pthread_mutex_t processor_lock = BLI_MUTEX_INITIALIZER;
|
||||
|
||||
typedef struct ColormanageProcessor {
|
||||
ConstProcessorRcPtr *processor;
|
||||
CurveMapping *curve_mapping;
|
||||
@ -732,7 +739,7 @@ static ConstProcessorRcPtr *create_colorspace_transform_processor(const char *fr
|
||||
static ConstProcessorRcPtr *colorspace_to_scene_linear_processor(ColorSpace *colorspace)
|
||||
{
|
||||
if (colorspace->to_scene_linear == NULL) {
|
||||
BLI_lock_thread(LOCK_COLORMANAGE);
|
||||
BLI_mutex_lock(&processor_lock);
|
||||
|
||||
if (colorspace->to_scene_linear == NULL) {
|
||||
ConstProcessorRcPtr *to_scene_linear;
|
||||
@ -740,7 +747,7 @@ static ConstProcessorRcPtr *colorspace_to_scene_linear_processor(ColorSpace *col
|
||||
colorspace->to_scene_linear = (struct ConstProcessorRcPtr *) to_scene_linear;
|
||||
}
|
||||
|
||||
BLI_unlock_thread(LOCK_COLORMANAGE);
|
||||
BLI_mutex_unlock(&processor_lock);
|
||||
}
|
||||
|
||||
return (ConstProcessorRcPtr *) colorspace->to_scene_linear;
|
||||
@ -749,7 +756,7 @@ static ConstProcessorRcPtr *colorspace_to_scene_linear_processor(ColorSpace *col
|
||||
static ConstProcessorRcPtr *colorspace_from_scene_linear_processor(ColorSpace *colorspace)
|
||||
{
|
||||
if (colorspace->from_scene_linear == NULL) {
|
||||
BLI_lock_thread(LOCK_COLORMANAGE);
|
||||
BLI_mutex_lock(&processor_lock);
|
||||
|
||||
if (colorspace->from_scene_linear == NULL) {
|
||||
ConstProcessorRcPtr *from_scene_linear;
|
||||
@ -757,7 +764,7 @@ static ConstProcessorRcPtr *colorspace_from_scene_linear_processor(ColorSpace *c
|
||||
colorspace->from_scene_linear = (struct ConstProcessorRcPtr *) from_scene_linear;
|
||||
}
|
||||
|
||||
BLI_unlock_thread(LOCK_COLORMANAGE);
|
||||
BLI_mutex_unlock(&processor_lock);
|
||||
}
|
||||
|
||||
return (ConstProcessorRcPtr *) colorspace->from_scene_linear;
|
||||
@ -766,7 +773,7 @@ static ConstProcessorRcPtr *colorspace_from_scene_linear_processor(ColorSpace *c
|
||||
static ConstProcessorRcPtr *display_from_scene_linear_processor(ColorManagedDisplay *display)
|
||||
{
|
||||
if (display->from_scene_linear == NULL) {
|
||||
BLI_lock_thread(LOCK_COLORMANAGE);
|
||||
BLI_mutex_lock(&processor_lock);
|
||||
|
||||
if (display->from_scene_linear == NULL) {
|
||||
const char *view_name = colormanage_view_get_default_name(display);
|
||||
@ -783,7 +790,7 @@ static ConstProcessorRcPtr *display_from_scene_linear_processor(ColorManagedDisp
|
||||
display->from_scene_linear = (struct ConstProcessorRcPtr *) processor;
|
||||
}
|
||||
|
||||
BLI_unlock_thread(LOCK_COLORMANAGE);
|
||||
BLI_mutex_unlock(&processor_lock);
|
||||
}
|
||||
|
||||
return (ConstProcessorRcPtr *) display->from_scene_linear;
|
||||
@ -792,7 +799,7 @@ static ConstProcessorRcPtr *display_from_scene_linear_processor(ColorManagedDisp
|
||||
static ConstProcessorRcPtr *display_to_scene_linear_processor(ColorManagedDisplay *display)
|
||||
{
|
||||
if (display->to_scene_linear == NULL) {
|
||||
BLI_lock_thread(LOCK_COLORMANAGE);
|
||||
BLI_mutex_lock(&processor_lock);
|
||||
|
||||
if (display->to_scene_linear == NULL) {
|
||||
const char *view_name = colormanage_view_get_default_name(display);
|
||||
@ -809,7 +816,7 @@ static ConstProcessorRcPtr *display_to_scene_linear_processor(ColorManagedDispla
|
||||
display->to_scene_linear = (struct ConstProcessorRcPtr *) processor;
|
||||
}
|
||||
|
||||
BLI_unlock_thread(LOCK_COLORMANAGE);
|
||||
BLI_mutex_unlock(&processor_lock);
|
||||
}
|
||||
|
||||
return (ConstProcessorRcPtr *) display->to_scene_linear;
|
||||
@ -1263,7 +1270,7 @@ static void *do_display_buffer_apply_thread(void *handle_v)
|
||||
if (cm_processor == NULL) {
|
||||
if (display_buffer_byte) {
|
||||
IMB_buffer_byte_from_byte(display_buffer_byte, handle->byte_buffer, IB_PROFILE_SRGB, IB_PROFILE_SRGB,
|
||||
FALSE, width, height, width, width);
|
||||
FALSE, width, height, width, width);
|
||||
}
|
||||
|
||||
if (display_buffer) {
|
||||
|
@ -43,6 +43,8 @@
|
||||
#include "IMB_colormanagement.h"
|
||||
#include "IMB_colormanagement_intern.h"
|
||||
|
||||
#include "BLI_threads.h"
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
/**************************** Interlace/Deinterlace **************************/
|
||||
@ -599,9 +601,18 @@ void IMB_float_from_rect(ImBuf *ibuf)
|
||||
if (ibuf->rect == NULL)
|
||||
return;
|
||||
|
||||
/* lock the color management thread
|
||||
* need this because allocated but not filled float buffer will confuse
|
||||
* display transform which lead to black areas across the frame
|
||||
*/
|
||||
BLI_lock_thread(LOCK_COLORMANAGE);
|
||||
|
||||
if (ibuf->rect_float == NULL) {
|
||||
if (imb_addrectfloatImBuf(ibuf) == 0)
|
||||
if (imb_addrectfloatImBuf(ibuf) == 0) {
|
||||
BLI_unlock_thread(LOCK_COLORMANAGE);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* first, create float buffer in non-linear space */
|
||||
@ -611,6 +622,8 @@ void IMB_float_from_rect(ImBuf *ibuf)
|
||||
/* then make float be in linear space */
|
||||
IMB_colormanagement_colorspace_to_scene_linear(ibuf->rect_float, ibuf->x, ibuf->y, ibuf->channels,
|
||||
ibuf->rect_colorspace, predivide);
|
||||
|
||||
BLI_unlock_thread(LOCK_COLORMANAGE);
|
||||
}
|
||||
|
||||
/* no profile conversion */
|
||||
|
Loading…
Reference in New Issue
Block a user