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>2012-09-19 19:01:36 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2012-09-19 19:01:36 +0400
commitd0f4c9639450ec1b90e7041e3d9c30e4927a745d (patch)
tree98c72ca38b3b6f186d04aa3f591b709d45eaed1b /source/blender/imbuf
parent16a698ad4abdcf77b32ec9c797cdb462eec051c4 (diff)
Color Management: don't apply display transform on Non-Color images
Also don't color manage data buffers in texture painting. Makes it possible to view heights and normal maps in proper space and also paint on them without applying extra transformation.
Diffstat (limited to 'source/blender/imbuf')
-rw-r--r--source/blender/imbuf/IMB_imbuf_types.h5
-rw-r--r--source/blender/imbuf/intern/IMB_colormanagement_intern.h3
-rw-r--r--source/blender/imbuf/intern/colormanagement.c40
3 files changed, 38 insertions, 10 deletions
diff --git a/source/blender/imbuf/IMB_imbuf_types.h b/source/blender/imbuf/IMB_imbuf_types.h
index 93e213dc486..f03f709f13f 100644
--- a/source/blender/imbuf/IMB_imbuf_types.h
+++ b/source/blender/imbuf/IMB_imbuf_types.h
@@ -131,6 +131,7 @@ typedef struct ImBuf {
struct ColorSpace *float_colorspace; /* color space of float buffer, used by sequencer only */
unsigned int *display_buffer_flags; /* array of per-display display buffers dirty flags */
struct ColormanageCache *colormanage_cache; /* cache used by color management */
+ int colormanage_flag;
/* information for compressed textures */
struct DDSData dds_data;
@@ -260,4 +261,8 @@ extern const char *imb_ext_image_qt[];
extern const char *imb_ext_movie[];
extern const char *imb_ext_audio[];
+enum {
+ IMB_COLORMANAGE_IS_DATA = (1 << 0)
+};
+
#endif
diff --git a/source/blender/imbuf/intern/IMB_colormanagement_intern.h b/source/blender/imbuf/intern/IMB_colormanagement_intern.h
index 0c002b78848..059bdee00eb 100644
--- a/source/blender/imbuf/intern/IMB_colormanagement_intern.h
+++ b/source/blender/imbuf/intern/IMB_colormanagement_intern.h
@@ -48,6 +48,7 @@ typedef struct ColorSpace {
struct ConstProcessorRcPtr *from_scene_linear;
int is_invertible;
+ int is_data;
} ColorSpace;
typedef struct ColorManagedDisplay {
@@ -79,7 +80,7 @@ struct ColorManagedView *colormanage_view_add(const char *name);
struct ColorManagedView *colormanage_view_get_indexed(int index);
struct ColorManagedView *colormanage_view_get_named(const char *name);
-struct ColorSpace *colormanage_colorspace_add(const char *name, const char *description, int is_invertible);
+struct ColorSpace *colormanage_colorspace_add(const char *name, const char *description, int is_invertible, int is_data);
struct ColorSpace *colormanage_colorspace_get_named(const char *name);
struct ColorSpace *colormanage_colorspace_get_roled(int role);
struct ColorSpace *colormanage_colorspace_get_indexed(int index);
diff --git a/source/blender/imbuf/intern/colormanagement.c b/source/blender/imbuf/intern/colormanagement.c
index 0e0937576eb..310448074fb 100644
--- a/source/blender/imbuf/intern/colormanagement.c
+++ b/source/blender/imbuf/intern/colormanagement.c
@@ -450,15 +450,16 @@ static void colormanage_load_config(ConstConfigRcPtr *config)
for (index = 0 ; index < tot_colorspace; index++) {
ConstColorSpaceRcPtr *ocio_colorspace;
const char *description;
- int is_invertible;
+ int is_invertible, is_data;
name = OCIO_configGetColorSpaceNameByIndex(config, index);
ocio_colorspace = OCIO_configGetColorSpace(config, name);
description = OCIO_colorSpaceGetDescription(ocio_colorspace);
is_invertible = OCIO_colorSpaceIsInvertible(ocio_colorspace);
+ is_data = OCIO_colorSpaceIsData(ocio_colorspace);
- colormanage_colorspace_add(name, description, is_invertible);
+ colormanage_colorspace_add(name, description, is_invertible, is_data);
OCIO_colorSpaceRelease(ocio_colorspace);
}
@@ -847,9 +848,15 @@ void colormanage_imbuf_set_default_spaces(ImBuf *ibuf)
void colormanage_imbuf_make_linear(ImBuf *ibuf, const char *from_colorspace)
{
if (ibuf->rect_float) {
+ ColorSpace *colorspace = colormanage_colorspace_get_named(from_colorspace);
const char *to_colorspace = global_role_scene_linear;
int predivide = ibuf->flags & IB_cm_predivide;
+ if (colorspace->is_data) {
+ ibuf->colormanage_flag |= IMB_COLORMANAGE_IS_DATA;
+ return;
+ }
+
if (ibuf->rect)
imb_freerectImBuf(ibuf);
@@ -1049,6 +1056,7 @@ typedef struct DisplayBufferThread {
int channels;
float dither;
int predivide;
+ int is_data;
const char *byte_colorspace;
const char *float_colorspace;
@@ -1078,6 +1086,7 @@ static void display_buffer_init_handle(void *handle_v, int start_line, int tot_l
int predivide = ibuf->flags & IB_cm_predivide;
int channels = ibuf->channels;
float dither = ibuf->dither;
+ int is_data = ibuf->colormanage_flag & IMB_COLORMANAGE_IS_DATA;
int offset = channels * start_line * ibuf->x;
@@ -1105,6 +1114,7 @@ static void display_buffer_init_handle(void *handle_v, int start_line, int tot_l
handle->channels = channels;
handle->dither = dither;
handle->predivide = predivide;
+ handle->is_data = is_data;
handle->byte_colorspace = init_data->byte_colorspace;
handle->float_colorspace = init_data->float_colorspace;
@@ -1189,11 +1199,19 @@ static void *do_display_buffer_apply_thread(void *handle_v)
int height = handle->tot_line;
float dither = handle->dither;
int predivide = handle->predivide;
+ int is_data = handle->is_data;
float *linear_buffer = display_buffer_apply_get_linear_buffer(handle);
- /* apply processor */
- IMB_colormanagement_processor_apply(cm_processor, linear_buffer, width, height, channels, predivide);
+ if (is_data) {
+ /* special case for data buffers - no color space conversions,
+ * only generate byte buffers
+ */
+ }
+ else {
+ /* apply processor */
+ IMB_colormanagement_processor_apply(cm_processor, linear_buffer, width, height, channels, predivide);
+ }
/* copy result to output buffers */
if (display_buffer_byte) {
@@ -1938,7 +1956,7 @@ static void colormanage_description_strip(char *description)
}
}
-ColorSpace *colormanage_colorspace_add(const char *name, const char *description, int is_invertible)
+ColorSpace *colormanage_colorspace_add(const char *name, const char *description, int is_invertible, int is_data)
{
ColorSpace *colorspace, *prev_space;
int counter = 1;
@@ -1954,6 +1972,7 @@ ColorSpace *colormanage_colorspace_add(const char *name, const char *description
}
colorspace->is_invertible = is_invertible;
+ colorspace->is_data = is_data;
for (prev_space = global_colorspaces.first; prev_space; prev_space = prev_space->next) {
if (BLI_strcasecmp(prev_space->name, colorspace->name) > 0)
@@ -2141,6 +2160,7 @@ static void partial_buffer_update_rect(ImBuf *ibuf, unsigned char *display_buffe
float *display_buffer_float = NULL;
int width = xmax - xmin;
int height = ymax - ymin;
+ int is_data = ibuf->colormanage_flag & IMB_COLORMANAGE_IS_DATA;
if (dither != 0.0f) {
display_buffer_float = MEM_callocN(channels * width * height * sizeof(float), "display buffer for dither");
@@ -2161,10 +2181,12 @@ static void partial_buffer_update_rect(ImBuf *ibuf, unsigned char *display_buffe
IMB_colormanagement_colorspace_to_scene_linear_v3(pixel, rect_colorspace);
}
- if (predivide)
- IMB_colormanagement_processor_apply_v4(cm_processor, pixel);
- else
- IMB_colormanagement_processor_apply_v4(cm_processor, pixel);
+ if (!is_data) {
+ if (predivide)
+ IMB_colormanagement_processor_apply_v4(cm_processor, pixel);
+ else
+ IMB_colormanagement_processor_apply_v4(cm_processor, pixel);
+ }
if (display_buffer_float) {
int index = ((y - ymin) * width + (x - xmin)) * channels;