Color management: added utility function to apply processor on a pixel
authorSergey Sharybin <sergey.vfx@gmail.com>
Wed, 18 Dec 2013 09:51:09 +0000 (15:51 +0600)
committerSergey Sharybin <sergey.vfx@gmail.com>
Wed, 18 Dec 2013 09:51:09 +0000 (15:51 +0600)
It applies color management on a pixel in a way, based on number of
channels of this pixel.

Simplifies partial update code a bit.

source/blender/imbuf/IMB_colormanagement.h
source/blender/imbuf/intern/colormanagement.c

index 98962f73b73213b4db309654defc69c3779f7073..263216cc5da8fd2431a5c5ace2689412df67befb 100644 (file)
@@ -166,6 +166,7 @@ struct ColormanageProcessor *IMB_colormanagement_colorspace_processor_new(const
 void IMB_colormanagement_processor_apply_v4(struct ColormanageProcessor *cm_processor, float pixel[4]);
 void IMB_colormanagement_processor_apply_v4_predivide(struct ColormanageProcessor *cm_processor, float pixel[4]);
 void IMB_colormanagement_processor_apply_v3(struct ColormanageProcessor *cm_processor, float pixel[3]);
+void IMB_colormanagement_processor_apply_pixel(struct ColormanageProcessor *cm_processor, float *pixel, int channels);
 void IMB_colormanagement_processor_apply(struct ColormanageProcessor *cm_processor, float *buffer, int width, int height,
                                          int channels, bool predivide);
 void IMB_colormanagement_processor_free(struct ColormanageProcessor *cm_processor);
index 91d558c9aed34a8d821402dd703bfe44aada2bd0..cc8a453c1691bc6d7e618dd83e9cfe9d36395ee1 100644 (file)
@@ -2690,17 +2690,7 @@ static void partial_buffer_update_rect(ImBuf *ibuf, unsigned char *display_buffe
                                }
 
                                if (!is_data) {
-                                       if (channels == 4) {
-                                               IMB_colormanagement_processor_apply_v4_predivide(cm_processor, pixel);
-                                       }
-                                       else if (channels == 3) {
-                                               IMB_colormanagement_processor_apply_v3(cm_processor, pixel);
-                                       }
-                                       else /* if (channels == 1) */ {
-                                               if (cm_processor->curve_mapping) {
-                                                       curve_mapping_apply_pixel(cm_processor->curve_mapping, pixel, 1);
-                                               }
-                                       }
+                                       IMB_colormanagement_processor_apply_pixel(cm_processor, pixel, channels);
                                }
 
                                if (display_buffer_float) {
@@ -2917,6 +2907,24 @@ void IMB_colormanagement_processor_apply_v3(ColormanageProcessor *cm_processor,
                OCIO_processorApplyRGB(cm_processor->processor, pixel);
 }
 
+void IMB_colormanagement_processor_apply_pixel(struct ColormanageProcessor *cm_processor, float *pixel, int channels)
+{
+       if (channels == 4) {
+               IMB_colormanagement_processor_apply_v4_predivide(cm_processor, pixel);
+       }
+       else if (channels == 3) {
+               IMB_colormanagement_processor_apply_v3(cm_processor, pixel);
+       }
+       else if (channels == 1) {
+               if (cm_processor->curve_mapping) {
+                       curve_mapping_apply_pixel(cm_processor->curve_mapping, pixel, 1);
+               }
+       }
+       else {
+               BLI_assert(!"Incorrect number of channels passed to IMB_colormanagement_processor_apply_pixel");
+       }
+}
+
 void IMB_colormanagement_processor_apply(ColormanageProcessor *cm_processor, float *buffer, int width, int height,
                                          int channels, bool predivide)
 {