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
path: root/source
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2012-09-22 00:44:41 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2012-09-22 00:44:41 +0400
commitf61ef65adb3949742d291dc38ad31266e6877384 (patch)
treebb1723987dcd0c3a282676d1950c96600c143a82 /source
parenta1123252a3ad70345e1a85c220faa84526a063d2 (diff)
Color Management: different fixes for byte buffers
- Color space of byte buffer for generated images haven't been updated properly on change - Byte buffers weren't handling data color spaces on display transform properly
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/intern/image.c11
-rw-r--r--source/blender/imbuf/IMB_colormanagement.h1
-rw-r--r--source/blender/imbuf/intern/colormanagement.c33
-rw-r--r--source/blender/windowmanager/intern/wm_init_exit.c6
4 files changed, 36 insertions, 15 deletions
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index b0fdbba2aa9..0e4d8a89386 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -603,7 +603,8 @@ Image *BKE_image_load_exists(const char *filepath)
return BKE_image_load(filepath);
}
-static ImBuf *add_ibuf_size(unsigned int width, unsigned int height, const char *name, int depth, int floatbuf, short gen_type, float color[4])
+static ImBuf *add_ibuf_size(unsigned int width, unsigned int height, const char *name, int depth, int floatbuf, short gen_type,
+ float color[4], const char *colorspace)
{
ImBuf *ibuf;
unsigned char *rect = NULL;
@@ -616,6 +617,9 @@ static ImBuf *add_ibuf_size(unsigned int width, unsigned int height, const char
else {
ibuf = IMB_allocImBuf(width, height, depth, IB_rect);
rect = (unsigned char *)ibuf->rect;
+
+ if (colorspace)
+ IMB_colormanagement_assign_rect_colorspace(ibuf, colorspace);
}
BLI_strncpy(ibuf->name, name, sizeof(ibuf->name));
@@ -651,7 +655,7 @@ Image *BKE_image_add_generated(unsigned int width, unsigned int height, const ch
ima->gen_type = gen_type;
ima->gen_flag |= (floatbuf ? IMA_GEN_FLOAT : 0);
- ibuf = add_ibuf_size(width, height, ima->name, depth, floatbuf, gen_type, color);
+ ibuf = add_ibuf_size(width, height, ima->name, depth, floatbuf, gen_type, color, NULL);
image_assign_ibuf(ima, ibuf, IMA_NO_INDEX, 0);
/* assign colorspaces */
@@ -2793,7 +2797,8 @@ ImBuf *BKE_image_acquire_ibuf(Image *ima, ImageUser *iuser, void **lock_r)
/* UV testgrid or black or solid etc */
if (ima->gen_x == 0) ima->gen_x = 1024;
if (ima->gen_y == 0) ima->gen_y = 1024;
- ibuf = add_ibuf_size(ima->gen_x, ima->gen_y, ima->name, 24, (ima->gen_flag & IMA_GEN_FLOAT) != 0, ima->gen_type, color);
+ ibuf = add_ibuf_size(ima->gen_x, ima->gen_y, ima->name, 24, (ima->gen_flag & IMA_GEN_FLOAT) != 0, ima->gen_type,
+ color, ima->colorspace_settings.name);
image_assign_ibuf(ima, ibuf, IMA_NO_INDEX, 0);
ima->ok = IMA_OK_LOADED;
}
diff --git a/source/blender/imbuf/IMB_colormanagement.h b/source/blender/imbuf/IMB_colormanagement.h
index d09007985b0..5d0ab5e57d4 100644
--- a/source/blender/imbuf/IMB_colormanagement.h
+++ b/source/blender/imbuf/IMB_colormanagement.h
@@ -62,6 +62,7 @@ void IMB_colormanagement_validate_settings(struct ColorManagedDisplaySettings *d
struct ColorManagedViewSettings *view_settings);
const char *IMB_colormanagement_role_colorspace_name_get(int role);
+void IMB_colormanagement_assign_rect_colorspace(struct ImBuf *ibuf, const char *name);
/* ** Color space transformation functions ** */
void IMB_colormanagement_transform(float *buffer, int width, int height, int channels,
diff --git a/source/blender/imbuf/intern/colormanagement.c b/source/blender/imbuf/intern/colormanagement.c
index de7d78897f8..50495d39252 100644
--- a/source/blender/imbuf/intern/colormanagement.c
+++ b/source/blender/imbuf/intern/colormanagement.c
@@ -847,16 +847,17 @@ void colormanage_imbuf_set_default_spaces(ImBuf *ibuf)
void colormanage_imbuf_make_linear(ImBuf *ibuf, const char *from_colorspace)
{
+ ColorSpace *colorspace = colormanage_colorspace_get_named(from_colorspace);
+
+ if (colorspace->is_data) {
+ ibuf->colormanage_flag |= IMB_COLORMANAGE_IS_DATA;
+ return;
+ }
+
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);
@@ -1038,6 +1039,17 @@ const char *IMB_colormanagement_role_colorspace_name_get(int role)
return NULL;
}
+void IMB_colormanagement_assign_rect_colorspace(ImBuf *ibuf, const char *name)
+{
+ ColorSpace *colorspace = colormanage_colorspace_get_named(name);
+ ibuf->rect_colorspace = colorspace;
+
+ if (colorspace->is_data)
+ ibuf->colormanage_flag |= IMB_COLORMANAGE_IS_DATA;
+ else
+ ibuf->colormanage_flag &= ~IMB_COLORMANAGE_IS_DATA;
+}
+
/*********************** Threaded display buffer transform routines *************************/
typedef struct DisplayBufferThread {
@@ -1132,6 +1144,7 @@ static void *display_buffer_apply_get_linear_buffer(DisplayBufferThread *handle)
int buffer_size = channels * width * height;
int predivide = handle->predivide;
+ int is_data = handle->is_data;
linear_buffer = MEM_callocN(buffer_size * sizeof(float), "color conversion linear buffer");
@@ -1153,9 +1166,11 @@ static void *display_buffer_apply_get_linear_buffer(DisplayBufferThread *handle)
*fp = (float)(*cp) / 255.0f;
}
- /* convert float buffer to scene linear space */
- IMB_colormanagement_transform(linear_buffer, width, height, channels,
- from_colorspace, to_colorspace, predivide);
+ if (!is_data) {
+ /* convert float buffer to scene linear space */
+ IMB_colormanagement_transform(linear_buffer, width, height, channels,
+ from_colorspace, to_colorspace, predivide);
+ }
}
else if (handle->float_colorspace) {
/* currently float is non-linear only in sequencer, which is working
diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c
index ab9c2ac1003..db4f5003b0d 100644
--- a/source/blender/windowmanager/intern/wm_init_exit.c
+++ b/source/blender/windowmanager/intern/wm_init_exit.c
@@ -144,15 +144,15 @@ void WM_init(bContext *C, int argc, const char **argv)
ED_spacetypes_init(); /* editors/space_api/spacetype.c */
+ /* initialize color management stuff */
+ IMB_colormanagement_init();
+
ED_file_init(); /* for fsmenu */
ED_node_init_butfuncs();
BLF_init(11, U.dpi); /* Please update source/gamengine/GamePlayer/GPG_ghost.cpp if you change this */
BLF_lang_init();
- /* initialize color management stuff */
- IMB_colormanagement_init();
-
/* get the default database, plus a wm */
WM_homefile_read(C, NULL, G.factory_startup);