Color Management: RGB curves transform as a part of display transform
authorSergey Sharybin <sergey.vfx@gmail.com>
Wed, 5 Sep 2012 16:08:36 +0000 (16:08 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Wed, 5 Sep 2012 16:08:36 +0000 (16:08 +0000)
This replaces per-image editor curve mapping which didn't behave properly
(it was possible to open the same image in two image editors and setup
different curves in this editors, but only last changed curve was applied
on image)

After discussion with Brecht decided to have something which works reliable
and predictable and ended up with adding RGB curves as a part of display
transform, which is applied before OCIO processor (to match old behavior).

Setting white/black values from image editor (Ctrl/Shift + LMB) would
affect on scene settings.

This could break compatibility, but there's no reliable way to convert
old semi-working settings into new one.

15 files changed:
source/blender/blenkernel/BKE_colortools.h
source/blender/blenkernel/intern/colortools.c
source/blender/blenkernel/intern/scene.c
source/blender/blenloader/intern/readfile.c
source/blender/blenloader/intern/writefile.c
source/blender/editors/interface/interface_templates.c
source/blender/editors/space_image/image_buttons.c
source/blender/editors/space_image/image_ops.c
source/blender/editors/space_image/space_image.c
source/blender/imbuf/intern/colormanagement.c
source/blender/makesdna/DNA_color_types.h
source/blender/makesdna/DNA_scene_types.h
source/blender/makesdna/DNA_space_types.h
source/blender/makesrna/intern/rna_color.c
source/blender/makesrna/intern/rna_space.c

index 51d5b45cd5de74363f209bf0bcbc940d792ff97a..7c2c9bb62ce5f66d16253dc36b0eb75bda34a9a2 100644 (file)
@@ -104,6 +104,7 @@ void BKE_color_managed_display_settings_copy(struct ColorManagedDisplaySettings
 void BKE_color_managed_view_settings_init(struct ColorManagedViewSettings *settings);
 void BKE_color_managed_view_settings_copy(struct ColorManagedViewSettings *new_settings,
                                           const struct ColorManagedViewSettings *settings);
+void BKE_color_managed_view_settings_free(struct ColorManagedViewSettings *settings);
 
 void BKE_color_managed_colorspace_settings_init(struct ColorManagedColorspaceSettings *colorspace_settings);
 void BKE_color_managed_colorspace_settings_copy(struct ColorManagedColorspaceSettings *colorspace_settings,
index 252add2c4233bbee3db482ec9c96045b9cc3e32b..65bffe42a1e6d5fb28d0e4ed83430123361d4d1a 100644 (file)
@@ -175,6 +175,7 @@ void curvemapping_set_black_white(CurveMapping *cumap, const float black[3], con
        }
 
        curvemapping_set_black_white_ex(cumap->black, cumap->white, cumap->bwmul);
+       cumap->changed_timestamp++;
 }
 
 /* ***************** operations on single curve ************* */
@@ -1289,8 +1290,18 @@ void BKE_color_managed_view_settings_copy(ColorManagedViewSettings *new_settings
 {
        BLI_strncpy(new_settings->view_transform, settings->view_transform, sizeof(new_settings->view_transform));
 
+       new_settings->flag = settings->flag;
        new_settings->exposure = settings->exposure;
        new_settings->gamma = settings->gamma;
+
+       if (settings->curve_mapping)
+               new_settings->curve_mapping = curvemapping_copy(settings->curve_mapping);
+}
+
+void BKE_color_managed_view_settings_free(ColorManagedViewSettings *settings)
+{
+       if (settings->curve_mapping)
+               curvemapping_free(settings->curve_mapping);
 }
 
 void BKE_color_managed_colorspace_settings_init(ColorManagedColorspaceSettings *colorspace_settings)
index e74413c3198d3a75dea1d325b5ffd26dd90e81b5..1bd8f3dfcd2b94af08045507499e10bcf0e3d795 100644 (file)
@@ -342,6 +342,8 @@ void BKE_scene_free(Scene *sce)
                MEM_freeN(sce->fps_info);
 
        sound_destroy_scene(sce);
+
+       BKE_color_managed_view_settings_free(&sce->view_settings);
 }
 
 Scene *BKE_scene_add(const char *name)
index 33693cf994bfa30c03167615692eba5fb79214e9..4dc1ad1e5c95af536cb4e53e02ef2f948cd12690 100644 (file)
@@ -4904,6 +4904,14 @@ static void direct_link_sequence_modifiers(FileData *fd, ListBase *lb)
        }
 }
 
+static void direct_link_view_settings(FileData *fd, ColorManagedViewSettings *view_settings)
+{
+       view_settings->curve_mapping = newdataadr(fd, view_settings->curve_mapping);
+
+       if (view_settings->curve_mapping)
+               direct_link_curvemapping(fd, view_settings->curve_mapping);
+}
+
 static void direct_link_scene(FileData *fd, Scene *sce)
 {
        Editing *ed;
@@ -5081,6 +5089,8 @@ static void direct_link_scene(FileData *fd, Scene *sce)
        sce->nodetree = newdataadr(fd, sce->nodetree);
        if (sce->nodetree)
                direct_link_nodetree(fd, sce->nodetree);
+
+       direct_link_view_settings(fd, &sce->view_settings);
 }
 
 /* ************ READ WM ***************** */
index 109a844352f56262bd3d68f8c483f2bb5e5b41f6..b8d63b3c5d5a93a973a3e50aeb733add1cbcf6f5 100644 (file)
@@ -2119,6 +2119,13 @@ static void write_sequence_modifiers(WriteData *wd, ListBase *modbase)
        }
 }
 
+static void write_view_settings(WriteData *wd, ColorManagedViewSettings *view_settings)
+{
+       if (view_settings->curve_mapping) {
+               write_curvemapping(wd, view_settings->curve_mapping);
+       }
+}
+
 static void write_scenes(WriteData *wd, ListBase *scebase)
 {
        Scene *sce;
@@ -2261,7 +2268,9 @@ static void write_scenes(WriteData *wd, ListBase *scebase)
                        writestruct(wd, DATA, "bNodeTree", 1, sce->nodetree);
                        write_nodetree(wd, sce->nodetree);
                }
-               
+
+               write_view_settings(wd, &sce->view_settings);
+
                sce= sce->id.next;
        }
        /* flush helps the compression for undo-save */
index 543ac18801c0393b8d3baa6d061574e285b3b3f7..79b9d3137755c6ba3c004d2d2c8c3e0c3a6d2044 100644 (file)
@@ -2848,4 +2848,9 @@ void uiTemplateColormanagedViewSettings(uiLayout *layout, bContext *UNUSED(C), P
        col = uiLayoutColumn(layout, FALSE);
        uiItemR(col, &view_transform_ptr, "exposure", 0, NULL, ICON_NONE);
        uiItemR(col, &view_transform_ptr, "gamma", 0, NULL, ICON_NONE);
+
+       col = uiLayoutColumn(layout, FALSE);
+       uiItemR(col, &view_transform_ptr, "use_curve_mapping", 0, NULL, ICON_NONE);
+       if (view_settings->flag & COLORMANAGE_VIEW_USE_CURVES)
+               uiTemplateCurveMapping(col, &view_transform_ptr, "curve_mapping", 'c', TRUE, 0);
 }
index 799ecc3075ea9935d93fa7670221176cd0887fb4..90c6a5ef50926245ba148654955ffc3bfe346cb1 100644 (file)
@@ -169,47 +169,6 @@ struct ImageUser *ntree_get_active_iuser(bNodeTree *ntree)
 
 /* ************ panel stuff ************* */
 
-/* is used for both read and write... */
-
-static int image_panel_poll(const bContext *C, PanelType *UNUSED(pt))
-{
-       SpaceImage *sima = CTX_wm_space_image(C);
-       ImBuf *ibuf;
-       void *lock;
-       int result;
-
-       ibuf = ED_space_image_acquire_buffer(sima, &lock);
-       result = ibuf && ibuf->rect_float;
-       ED_space_image_release_buffer(sima, lock);
-       
-       return result;
-}
-
-static void image_panel_curves(const bContext *C, Panel *pa)
-{
-       bScreen *sc = CTX_wm_screen(C);
-       SpaceImage *sima = CTX_wm_space_image(C);
-       ImBuf *ibuf;
-       PointerRNA simaptr;
-       int levels;
-       void *lock;
-       
-       ibuf = ED_space_image_acquire_buffer(sima, &lock);
-       
-       if (ibuf) {
-               if (sima->cumap == NULL)
-                       sima->cumap = curvemapping_add(4, 0.0f, 0.0f, 1.0f, 1.0f);
-
-               /* curvemap black/white levels only works for RGBA */
-               levels = (ibuf->channels == 4);
-
-               RNA_pointer_create(&sc->id, &RNA_SpaceImageEditor, sima, &simaptr);
-               uiTemplateCurveMapping(pa->layout, &simaptr, "curve", 'c', levels, 0);
-       }
-
-       ED_space_image_release_buffer(sima, lock);
-}
-
 #if 0
 /* 0: disable preview 
  * otherwise refresh preview
@@ -913,14 +872,6 @@ void image_buttons_register(ARegionType *art)
 {
        PanelType *pt;
 
-       pt = MEM_callocN(sizeof(PanelType), "spacetype image panel curves");
-       strcpy(pt->idname, "IMAGE_PT_curves");
-       strcpy(pt->label, "Curves");
-       pt->draw = image_panel_curves;
-       pt->poll = image_panel_poll;
-       pt->flag |= PNL_DEFAULT_CLOSED;
-       BLI_addtail(&art->paneltypes, pt);
-       
        pt = MEM_callocN(sizeof(PanelType), "spacetype image panel gpencil");
        strcpy(pt->idname, "IMAGE_PT_gpencil");
        strcpy(pt->label, "Grease Pencil");
index bc518645e4380357c66ddf2bdac29a01af051a17..44cb3ae578f67cd55934aa961290ded14ef36873 100644 (file)
@@ -2053,7 +2053,9 @@ static void image_sample_apply(bContext *C, wmOperator *op, wmEvent *event)
        ImBuf *ibuf = ED_space_image_acquire_buffer(sima, &lock);
        ImageSampleInfo *info = op->customdata;
        float fx, fy;
-       
+       Scene *scene = CTX_data_scene(C);
+       CurveMapping *curve_mapping = scene->view_settings.curve_mapping;
+
        if (ibuf == NULL) {
                ED_space_image_release_buffer(sima, lock);
                info->draw = 0;
@@ -2117,25 +2119,21 @@ static void image_sample_apply(bContext *C, wmOperator *op, wmEvent *event)
                        info->zf = ibuf->zbuf_float[y * ibuf->x + x];
                        info->zfp = &info->zf;
                }
-               
-               if (sima->cumap && ibuf->channels == 4) {
+
+               if (curve_mapping && ibuf->channels == 4) {
                        /* we reuse this callback for set curves point operators */
                        if (RNA_struct_find_property(op->ptr, "point")) {
                                int point = RNA_enum_get(op->ptr, "point");
 
                                if (point == 1) {
-                                       curvemapping_set_black_white(sima->cumap, NULL, info->colfp);
-                                       if (ibuf->rect_float)
-                                               curvemapping_do_ibuf(sima->cumap, ibuf);
+                                       curvemapping_set_black_white(curve_mapping, NULL, info->colfp);
                                }
                                else if (point == 0) {
-                                       curvemapping_set_black_white(sima->cumap, info->colfp, NULL);
-                                       if (ibuf->rect_float)
-                                               curvemapping_do_ibuf(sima->cumap, ibuf);
+                                       curvemapping_set_black_white(curve_mapping, info->colfp, NULL);
                                }
                        }
                }
-                               
+
                // XXX node curve integration ..
 #if 0
                {
index 439f6a49c7fd4af9993f20cdf42667ad6d4dc518..970f9d6d35da3be9eff5ef2ea0c4c4af601ff3db 100644 (file)
@@ -195,9 +195,7 @@ static SpaceLink *image_new(const bContext *UNUSED(C))
 static void image_free(SpaceLink *sl)
 {      
        SpaceImage *simage = (SpaceImage *) sl;
-       
-       if (simage->cumap)
-               curvemapping_free(simage->cumap);
+
        scopes_free(&simage->scopes);
 }
 
@@ -217,8 +215,6 @@ static SpaceLink *image_duplicate(SpaceLink *sl)
        SpaceImage *simagen = MEM_dupallocN(sl);
        
        /* clear or remove stuff from old */
-       if (simagen->cumap)
-               simagen->cumap = curvemapping_copy(simagen->cumap);
 
        scopes_new(&simagen->scopes);
 
index f0b6a1bda1da3de02b2045faeacec9670b32664c..3fff419895e87adddf869f3e7fbef79318f4fb06 100644 (file)
@@ -56,6 +56,7 @@
 #include "BLI_string.h"
 #include "BLI_threads.h"
 
+#include "BKE_colortools.h"
 #include "BKE_context.h"
 #include "BKE_utildefines.h"
 #include "BKE_main.h"
@@ -159,9 +160,11 @@ static int global_tot_view = 0;
  *       to color management cache system and keeps calls small and nice.
  */
 typedef struct ColormanageCacheViewSettings {
+       int flag;
        int view;
        float exposure;
        float gamma;
+       CurveMapping *curve_mapping;
 } ColormanageCacheViewSettings;
 
 typedef struct ColormanageCacheDisplaySettings {
@@ -174,9 +177,12 @@ typedef struct ColormanageCacheKey {
 } ColormanageCacheKey;
 
 typedef struct ColormnaageCacheData {
+       int flag;        /* view flags of cached buffer */
        float exposure;  /* exposure value cached buffer is calculated with */
        float gamma;     /* gamma value cached buffer is calculated with */
        int predivide;   /* predivide flag of cached buffer */
+       CurveMapping *curve_mapping;  /* curve mapping used for cached buffer */
+       int curve_mapping_timestamp;  /* time stamp of curve mapping used for cached buffer */
 } ColormnaageCacheData;
 
 typedef struct ColormanageCache {
@@ -264,6 +270,8 @@ static void colormanage_view_settings_to_cache(ColormanageCacheViewSettings *cac
        cache_view_settings->view = view;
        cache_view_settings->exposure = view_settings->exposure;
        cache_view_settings->gamma = view_settings->gamma;
+       cache_view_settings->flag = view_settings->flag;
+       cache_view_settings->curve_mapping = view_settings->curve_mapping;
 }
 
 static void colormanage_display_settings_to_cache(ColormanageCacheDisplaySettings *cache_display_settings,
@@ -338,7 +346,10 @@ static unsigned char *colormanage_cache_get(ImBuf *ibuf, const ColormanageCacheV
 
                if (cache_data->exposure != view_settings->exposure ||
                    cache_data->gamma != view_settings->gamma ||
-                       cache_data->predivide != predivide)
+                       cache_data->predivide != predivide ||
+                       cache_data->flag != view_settings->flag ||
+                       cache_data->curve_mapping != view_settings->curve_mapping ||
+                       cache_data->curve_mapping_timestamp != view_settings->curve_mapping->changed_timestamp)
                {
                        *cache_handle = NULL;
 
@@ -381,6 +392,9 @@ static void colormanage_cache_put(ImBuf *ibuf, const ColormanageCacheViewSetting
        cache_data->exposure = view_settings->exposure;
        cache_data->gamma = view_settings->gamma;
        cache_data->predivide = predivide;
+       cache_data->flag = view_settings->flag;
+       cache_data->curve_mapping = view_settings->curve_mapping;
+       cache_data->curve_mapping_timestamp = view_settings->curve_mapping->changed_timestamp;
 
        colormanage_cachedata_set(cache_ibuf, cache_data);
 
@@ -600,6 +614,7 @@ void IMB_colormanagement_exit(void)
 
 #ifdef WITH_OCIO
 typedef struct DisplayBufferThread {
+       CurveMapping *curve_mapping;
        void *processor;
 
        float *buffer;
@@ -621,6 +636,7 @@ typedef struct DisplayBufferThread {
 
 typedef struct DisplayBufferInitData {
        ImBuf *ibuf;
+       CurveMapping *curve_mapping;
        void *processor;
        float *buffer;
        unsigned char *byte_buffer;
@@ -636,6 +652,7 @@ static void display_buffer_init_handle(void *handle_v, int start_line, int tot_l
        DisplayBufferThread *handle = (DisplayBufferThread *) handle_v;
        DisplayBufferInitData *init_data = (DisplayBufferInitData *) init_data_v;
        ImBuf *ibuf = init_data->ibuf;
+       CurveMapping *curve_mapping = init_data->curve_mapping;
 
        int predivide = ibuf->flags & IB_cm_predivide;
        int channels = ibuf->channels;
@@ -667,17 +684,19 @@ 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->curve_mapping = curve_mapping;
 
        handle->nolinear_float = ibuf->colormanage_flags & IMB_COLORMANAGE_NOLINEAR_FLOAT;
 }
 
 static void display_buffer_apply_threaded(ImBuf *ibuf, float *buffer, unsigned char *byte_buffer,
                                           float *display_buffer, unsigned char *display_buffer_byte,
-                                          void *processor, void *(do_thread) (void *))
+                                          CurveMapping *curve_mapping, void *processor, void *(do_thread) (void *))
 {
        DisplayBufferInitData init_data;
 
        init_data.ibuf = ibuf;
+       init_data.curve_mapping = curve_mapping;
        init_data.processor = processor;
        init_data.buffer = buffer;
        init_data.byte_buffer = byte_buffer;
@@ -746,6 +765,7 @@ static void *display_buffer_apply_get_linear_buffer(DisplayBufferThread *handle)
 static void *do_display_buffer_apply_thread(void *handle_v)
 {
        DisplayBufferThread *handle = (DisplayBufferThread *) handle_v;
+       CurveMapping *curve_mapping = handle->curve_mapping;
        ConstProcessorRcPtr *processor = (ConstProcessorRcPtr *) handle->processor;
        PackedImageDesc *img;
        float *buffer = handle->buffer;
@@ -759,6 +779,27 @@ static void *do_display_buffer_apply_thread(void *handle_v)
 
        float *linear_buffer = display_buffer_apply_get_linear_buffer(handle);
 
+       if (curve_mapping) {
+               int x, y;
+
+               for (y = 0; y < height; y++) {
+                       for (x = 0; x < width; x++) {
+                               float *pixel = linear_buffer + channels * (y * width + x);
+
+                               if (channels == 1) {
+                                       pixel[0] = curvemap_evaluateF(curve_mapping->cm, pixel[0]);
+                               }
+                               else if (channels == 2) {
+                                       pixel[0] = curvemap_evaluateF(curve_mapping->cm, pixel[0]);
+                                       pixel[1] = curvemap_evaluateF(curve_mapping->cm, pixel[1]);
+                               }
+                               else {
+                                       curvemapping_evaluate_premulRGBF(curve_mapping, pixel, pixel);
+                               }
+                       }
+               }
+       }
+
        img = OCIO_createPackedImageDesc(linear_buffer, width, height, channels, sizeof(float),
                                         channels * sizeof(float), channels * sizeof(float) * width);
 
@@ -848,9 +889,20 @@ static void colormanage_display_buffer_process_ex(ImBuf *ibuf, float *display_bu
        processor = create_display_buffer_processor(view_transform, display, exposure, gamma);
 
        if (processor) {
+               CurveMapping *curve_mapping = NULL;
+
+               if (view_settings->flag & COLORMANAGE_VIEW_USE_CURVES) {
+                       curve_mapping = view_settings->curve_mapping;
+
+                       curvemapping_premultiply(curve_mapping, FALSE);
+               }
+
                display_buffer_apply_threaded(ibuf, ibuf->rect_float, (unsigned char *) ibuf->rect,
-                                             display_buffer, display_buffer_byte, processor,
+                                             display_buffer, display_buffer_byte, curve_mapping, processor,
                                              do_display_buffer_apply_thread);
+
+               if (curve_mapping)
+                       curvemapping_premultiply(curve_mapping, TRUE);
        }
 
        OCIO_processorRelease(processor);
@@ -1324,8 +1376,32 @@ void IMB_display_buffer_pixel(float result[4], const float pixel[4],  const Colo
 
        processor = create_display_buffer_processor(view_transform, display, exposure, gamma);
 
-       if (processor)
-               OCIO_processorApplyRGBA(processor, result);
+       if (processor) {
+
+               if (view_settings->flag & COLORMANAGE_VIEW_USE_CURVES) {
+                       CurveMapping *curve_mapping = NULL;
+
+                       /* curve mapping could be used meanwhile to compute display buffer,
+                        * so need to lock here to be sure we're not changing curve mapping
+                        * from separated threads
+                        */
+                       BLI_lock_thread(LOCK_COLORMANAGE);
+
+                       curve_mapping = view_settings->curve_mapping;
+
+                       curvemapping_premultiply(curve_mapping, FALSE);
+
+                       curvemapping_evaluate_premulRGBF(curve_mapping, result, result);
+                       OCIO_processorApplyRGBA(processor, result);
+
+                       curvemapping_premultiply(curve_mapping, TRUE);
+
+                       BLI_unlock_thread(LOCK_COLORMANAGE);
+               }
+               else {
+                       OCIO_processorApplyRGBA(processor, result);
+               }
+       }
 #else
        (void) view_settings;
        (void) display_settings;
index 5ccc2579179787eebd02f78608b97e0c29455eeb..560caa40cff0e7c588fb7e6d8b6b821b44a1fd4d 100644 (file)
@@ -161,9 +161,11 @@ typedef struct Scopes {
 #define SCOPES_WAVEFRM_YCC_JPEG        4
 
 typedef struct ColorManagedViewSettings {
+       int flag, pad;
        char view_transform[64];   /* view transform which is being applied when displaying buffer on the screen */
        float exposure;            /* fstop exposure */
        float gamma;               /* post-display gamma transform */
+       struct CurveMapping *curve_mapping;  /* pre-display RGB curves transform */
 } ColorManagedViewSettings;
 
 typedef struct ColorManagedDisplaySettings {
@@ -174,5 +176,9 @@ typedef struct ColorManagedColorspaceSettings {
        char name[64];
 } ColorManagedColorspaceSettings;
 
-#endif
+/* ColorManagedViewSettings->flag */
+enum {
+       COLORMANAGE_VIEW_USE_CURVES = (1 << 0)
+};
 
+#endif
index ed0e27917adb4b7f2d4866e8165fa61b057001f8..51186c9bb6e9833ae3ec4a96b17abc6443d9e1b9 100644 (file)
@@ -41,7 +41,7 @@
 extern "C" {
 #endif
 
-#include "DNA_color_types.h"  // color management
+#include "DNA_color_types.h"  /* color management */
 #include "DNA_vec_types.h"
 #include "DNA_listBase.h"
 #include "DNA_ID.h"
index 7196b6b7059ac29e2b463fe4143b85d60d83f2b3..6cc4541f19e19754d03aa0d347fceee900584d4a 100644 (file)
@@ -40,7 +40,7 @@
 #include "DNA_outliner_types.h"     /* for TreeStoreElem */
 #include "DNA_image_types.h"        /* ImageUser */
 #include "DNA_movieclip_types.h"    /* MovieClipUser */
-#include "DNA_sequence_types.h"    /* SequencerScopes */
+#include "DNA_sequence_types.h"     /* SequencerScopes */
 /* Hum ... Not really nice... but needed for spacebuts. */
 #include "DNA_view2d_types.h"
 
@@ -688,8 +688,9 @@ typedef struct SpaceImage {
 
        struct Image *image;
        struct ImageUser iuser;
-       struct CurveMapping *cumap;
-       
+
+       struct CurveMapping *cumap DNA_DEPRECATED;  /* was switched to scene's color management settings */
+
        struct Scopes scopes;           /* histogram waveform and vectorscope */
        struct Histogram sample_line_hist;  /* sample line histogram */
 
index 45d6ea2951e2cd5a3044c989533ca9432a8a17bd..facadf4258b0c3220eba127d9a5610b5bc6d1c94 100644 (file)
@@ -423,6 +423,22 @@ static EnumPropertyItem* rna_ColorManagedViewSettings_view_transform_itemf(bCont
        return items;
 }
 
+static void rna_ColorManagedViewSettings_use_curves_set(PointerRNA *ptr, int value)
+{
+       ColorManagedViewSettings *view_settings = (ColorManagedViewSettings *) ptr->data;
+
+       if (value) {
+               view_settings->flag |= COLORMANAGE_VIEW_USE_CURVES;
+
+               if (view_settings->curve_mapping == NULL) {
+                       view_settings->curve_mapping = curvemapping_add(4, 0.0f, 0.0f, 1.0f, 1.0f);
+               }
+       }
+       else {
+               view_settings->flag &= ~COLORMANAGE_VIEW_USE_CURVES;
+       }
+}
+
 static int rna_ColorManagedColorspaceSettings_colorspace_get(struct PointerRNA *ptr)
 {
        ColorManagedColorspaceSettings *colorspace = (ColorManagedColorspaceSettings *) ptr->data;
@@ -869,14 +885,25 @@ static void rna_def_colormanage(BlenderRNA *brna)
        RNA_def_property_float_sdna(prop, NULL, "exposure");
        RNA_def_property_range(prop, -10.0f, 10.0f);
        RNA_def_property_float_default(prop, 0.0f);
-       RNA_def_property_ui_text(prop, "Exposure", "Exposure (stops) applied on displaying image buffers");
+       RNA_def_property_ui_text(prop, "Exposure", "Exposure (stops) applied after display transform");
        RNA_def_property_update(prop, NC_WINDOW, "rna_ColorManagement_update");
 
        prop = RNA_def_property(srna, "gamma", PROP_FLOAT, PROP_FACTOR);
        RNA_def_property_float_sdna(prop, NULL, "gamma");
        RNA_def_property_float_default(prop, 1.0f);
        RNA_def_property_range(prop, 0.0f, 5.0f);
-       RNA_def_property_ui_text(prop, "Gamma", "Amount f gamma modification for displaying image buffers");
+       RNA_def_property_ui_text(prop, "Gamma", "Amount of gamma modification applied after display transform");
+       RNA_def_property_update(prop, NC_WINDOW, "rna_ColorManagement_update");
+
+       prop = RNA_def_property(srna, "curve_mapping", PROP_POINTER, PROP_NONE);
+       RNA_def_property_pointer_sdna(prop, NULL, "curve_mapping");
+       RNA_def_property_ui_text(prop, "Curve", "Color curve mapping applied before display transform");
+       RNA_def_property_update(prop, NC_WINDOW, "rna_ColorManagement_update");
+
+       prop = RNA_def_property(srna, "use_curve_mapping", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "flag", COLORMANAGE_VIEW_USE_CURVES);
+       RNA_def_property_boolean_funcs(prop, NULL, "rna_ColorManagedViewSettings_use_curves_set");
+       RNA_def_property_ui_text(prop, "Use Curves", "Use RGB curved for pre-display transformation");
        RNA_def_property_update(prop, NC_WINDOW, "rna_ColorManagement_update");
 
        /* ** Colorspace **  */
index c4a60dba0256526af512137b097897850e51711d..80860dbdf26af7fd92b672427dfc251944f57e6d 100644 (file)
@@ -658,20 +658,6 @@ static void rna_SpaceImageEditor_cursor_location_set(PointerRNA *ptr, const floa
        }
 }
 
-static void rna_SpaceImageEditor_curves_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
-{
-       SpaceImage *sima = (SpaceImage *)ptr->data;
-       ImBuf *ibuf;
-       void *lock;
-
-       ibuf = ED_space_image_acquire_buffer(sima, &lock);
-       if (ibuf->rect_float)
-               curvemapping_do_ibuf(sima->cumap, ibuf);
-       ED_space_image_release_buffer(sima, lock);
-
-       WM_main_add_notifier(NC_IMAGE, sima->image);
-}
-
 static void rna_SpaceImageEditor_scopes_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *ptr)
 {
        SpaceImage *sima = (SpaceImage *)ptr->data;
@@ -1980,11 +1966,6 @@ static void rna_def_space_image(BlenderRNA *brna)
                                 "Parameters defining which layer, pass and frame of the image is displayed");
        RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, NULL);
 
-       prop = RNA_def_property(srna, "curve", PROP_POINTER, PROP_NONE);
-       RNA_def_property_pointer_sdna(prop, NULL, "cumap");
-       RNA_def_property_ui_text(prop, "Curve", "Color curve mapping to use for displaying the image");
-       RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, "rna_SpaceImageEditor_curves_update");
-
        prop = RNA_def_property(srna, "scopes", PROP_POINTER, PROP_NONE);
        RNA_def_property_pointer_sdna(prop, NULL, "scopes");
        RNA_def_property_struct_type(prop, "Scopes");