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:
Diffstat (limited to 'source/blender/imbuf')
-rw-r--r--source/blender/imbuf/intern/colormanagement.c25
-rw-r--r--source/blender/imbuf/intern/divers.c15
2 files changed, 30 insertions, 10 deletions
diff --git a/source/blender/imbuf/intern/colormanagement.c b/source/blender/imbuf/intern/colormanagement.c
index bb1449060dd..50000b9eeea 100644
--- a/source/blender/imbuf/intern/colormanagement.c
+++ b/source/blender/imbuf/intern/colormanagement.c
@@ -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) {
diff --git a/source/blender/imbuf/intern/divers.c b/source/blender/imbuf/intern/divers.c
index 9ce5d0e30da..aa236af3507 100644
--- a/source/blender/imbuf/intern/divers.c
+++ b/source/blender/imbuf/intern/divers.c
@@ -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 */