[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [50382] branches/soc-2011-tomato/source/ blender: Color Management: fix for color sample information line

Sergey Sharybin sergey.vfx at gmail.com
Tue Sep 4 14:32:32 CEST 2012


Revision: 50382
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=50382
Author:   nazgul
Date:     2012-09-04 12:32:32 +0000 (Tue, 04 Sep 2012)
Log Message:
-----------
Color Management: fix for color sample information line

- Color managed RGB values wouldn't be displayed anymore for
  byte images (which are currently unsupported to be managed).

- Color rectangle would now be color managed

- Sequencer was passing non-linear float to information line,
  now it'll pass linear float.

Modified Paths:
--------------
    branches/soc-2011-tomato/source/blender/editors/space_image/image_draw.c
    branches/soc-2011-tomato/source/blender/editors/space_image/image_ops.c
    branches/soc-2011-tomato/source/blender/editors/space_node/node_view.c
    branches/soc-2011-tomato/source/blender/editors/space_sequencer/sequencer_view.c
    branches/soc-2011-tomato/source/blender/imbuf/IMB_colormanagement.h
    branches/soc-2011-tomato/source/blender/imbuf/intern/colormanagement.c

Modified: branches/soc-2011-tomato/source/blender/editors/space_image/image_draw.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/space_image/image_draw.c	2012-09-04 12:32:25 UTC (rev 50381)
+++ branches/soc-2011-tomato/source/blender/editors/space_image/image_draw.c	2012-09-04 12:32:32 UTC (rev 50382)
@@ -222,8 +222,7 @@
 			dx += BLF_width(blf_mono_font, str);
 		}
 
-		/* OCIO_TODO: make it fit better to overall color interaction */
-		if (fp && channels == 4) {
+		if (color_manage && channels == 4) {
 			float pixel[4];
 
 			IMB_display_buffer_pixel(pixel, fp,  &scene->view_settings, &scene->display_settings);
@@ -276,11 +275,12 @@
 	}
 
 	if (color_manage) {
-		linearrgb_to_srgb_v4(finalcol, col);
+		IMB_display_buffer_pixel(finalcol, col,  &scene->view_settings, &scene->display_settings);
 	}
 	else {
 		copy_v4_v4(finalcol, col);
 	}
+
 	glDisable(GL_BLEND);
 	glColor3fv(finalcol);
 	dx += 5;

Modified: branches/soc-2011-tomato/source/blender/editors/space_image/image_ops.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/space_image/image_ops.c	2012-09-04 12:32:25 UTC (rev 50381)
+++ branches/soc-2011-tomato/source/blender/editors/space_image/image_ops.c	2012-09-04 12:32:32 UTC (rev 50382)
@@ -1986,6 +1986,7 @@
 	float *zfp;
 
 	int draw;
+	int color_manage;
 } ImageSampleInfo;
 
 static void image_sample_draw(const bContext *C, ARegion *ar, void *arg_info)
@@ -1994,8 +1995,7 @@
 	if (info->draw) {
 		Scene *scene = CTX_data_scene(C);
 
-		/* no color management needed for images (color_manage=0) */
-		ED_image_draw_info(scene, ar, 0, info->channels, info->x, info->y, info->colp, info->colfp, info->zp, info->zfp);
+		ED_image_draw_info(scene, ar, info->color_manage, info->channels, info->x, info->y, info->colp, info->colfp, info->zp, info->zfp);
 	}
 }
 
@@ -2094,6 +2094,8 @@
 			info->colf[2] = (float)cp[2] / 255.0f;
 			info->colf[3] = (float)cp[3] / 255.0f;
 			info->colfp = info->colf;
+
+			info->color_manage = FALSE;
 		}
 		if (ibuf->rect_float) {
 			fp = (ibuf->rect_float + (ibuf->channels) * (y * ibuf->x + x));
@@ -2103,6 +2105,8 @@
 			info->colf[2] = fp[2];
 			info->colf[3] = fp[3];
 			info->colfp = info->colf;
+
+			info->color_manage = TRUE;
 		}
 
 		if (ibuf->zbuf) {

Modified: branches/soc-2011-tomato/source/blender/editors/space_node/node_view.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/space_node/node_view.c	2012-09-04 12:32:25 UTC (rev 50381)
+++ branches/soc-2011-tomato/source/blender/editors/space_node/node_view.c	2012-09-04 12:32:32 UTC (rev 50382)
@@ -327,12 +327,12 @@
 	void *draw_handle;
 	int x, y;
 	int channels;
-	int color_manage;
 
 	unsigned char col[4];
 	float colf[4];
 
 	int draw;
+	int color_manage;
 } ImageSampleInfo;
 
 static void sample_draw(const bContext *C, ARegion *ar, void *arg_info)
@@ -341,7 +341,7 @@
 	ImageSampleInfo *info = arg_info;
 
 	if (info->draw) {
-		ED_image_draw_info(scene, ar, (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT), info->channels,
+		ED_image_draw_info(scene, ar, info->color_manage, info->channels,
 		                   info->x, info->y, info->col, info->colf,
 		                   NULL, NULL /* zbuf - unused for nodes */
 		                   );
@@ -457,6 +457,8 @@
 			info->colf[1] = (float)cp[1] / 255.0f;
 			info->colf[2] = (float)cp[2] / 255.0f;
 			info->colf[3] = (float)cp[3] / 255.0f;
+
+			info->color_manage = FALSE;
 		}
 		if (ibuf->rect_float) {
 			fp = (ibuf->rect_float + (ibuf->channels) * (y * ibuf->x + x));
@@ -465,6 +467,8 @@
 			info->colf[1] = fp[1];
 			info->colf[2] = fp[2];
 			info->colf[3] = fp[3];
+
+			info->color_manage = TRUE;
 		}
 
 		ED_node_sample_set(info->colf);

Modified: branches/soc-2011-tomato/source/blender/editors/space_sequencer/sequencer_view.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/space_sequencer/sequencer_view.c	2012-09-04 12:32:25 UTC (rev 50381)
+++ branches/soc-2011-tomato/source/blender/editors/space_sequencer/sequencer_view.c	2012-09-04 12:32:32 UTC (rev 50382)
@@ -49,6 +49,7 @@
 
 #include "IMB_imbuf.h"
 #include "IMB_imbuf_types.h"
+#include "IMB_colormanagement.h"
 
 #include "UI_view2d.h"
 
@@ -70,6 +71,7 @@
 	float *colfp;
 
 	int draw;
+int color_manage;
 } ImageSampleInfo;
 
 static void sample_draw(const bContext *C, ARegion *ar, void *arg_info)
@@ -78,8 +80,8 @@
 	ImageSampleInfo *info = arg_info;
 
 	if (info->draw) {
-		ED_image_draw_info(scene, ar, (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT), info->channels,
-		                   info->x, info->y, info->col, info->colf, NULL, NULL);
+		ED_image_draw_info(scene, ar, info->color_manage, info->channels,
+		                   info->x, info->y, info->colp, info->colfp, NULL, NULL);
 	}
 }
 
@@ -131,6 +133,8 @@
 			info->colf[2] = (float)cp[2] / 255.0f;
 			info->colf[3] = (float)cp[3] / 255.0f;
 			info->colfp = info->colf;
+
+			info->color_manage = FALSE;
 		}
 		if (ibuf->rect_float) {
 			fp = (ibuf->rect_float + (ibuf->channels) * (y * ibuf->x + x));
@@ -140,6 +144,11 @@
 			info->colf[2] = fp[2];
 			info->colf[3] = fp[3];
 			info->colfp = info->colf;
+
+			/* sequencer's image buffers are in non-linear space, need to make them linear */
+			IMB_colormanagement_pixel_from_sequencer_space(info->colf);
+
+			info->color_manage = TRUE;
 		}
 	}
 	else {

Modified: branches/soc-2011-tomato/source/blender/imbuf/IMB_colormanagement.h
===================================================================
--- branches/soc-2011-tomato/source/blender/imbuf/IMB_colormanagement.h	2012-09-04 12:32:25 UTC (rev 50381)
+++ branches/soc-2011-tomato/source/blender/imbuf/IMB_colormanagement.h	2012-09-04 12:32:32 UTC (rev 50382)
@@ -54,15 +54,15 @@
 void IMB_colormanagement_colorspace_transform(float *buffer, int width, int height, int channels,
                                               const char *from_colorspace, const char *to_colorspace);
 
+void IMB_colormanagement_pixel_to_role(float pixel[4], int role);
+void IMB_colormanagement_pixel_from_role(float pixel[4], int role);
+
 void IMB_colormanagement_imbuf_to_role(struct ImBuf *ibuf, int role);
 void IMB_colormanagement_imbuf_from_role(struct ImBuf *ibuf, int role);
 
 void IMB_colormanagement_imbuf_make_scene_linear(struct ImBuf *ibuf,
 		struct ColorManagedColorspaceSettings *colorspace_settings);
 
-void IMB_colormanagement_imbuf_to_sequencer_space(struct ImBuf *ibuf, int make_float);
-void IMB_colormanagement_imbuf_from_sequencer_space(struct ImBuf *ibuf);
-
 /* ** Public display buffers interfaces ** */
 
 void IMB_colormanage_cache_free(struct ImBuf *ibuf);
@@ -109,6 +109,17 @@
                                        int stride, int offset_x, int offset_y,
                                        int xmin, int ymin, int xmax, int ymax);
 
+/* ** Area-specific functions ** */
+
+/* Sequencer */
+
+void IMB_colormanagement_imbuf_to_sequencer_space(struct ImBuf *ibuf, int make_float);
+void IMB_colormanagement_imbuf_from_sequencer_space(struct ImBuf *ibuf);
+
+void IMB_colormanagement_pixel_from_sequencer_space(float pixel[4]);
+
+
+/* Roles */
 enum {
 	COLOR_ROLE_SCENE_LINEAR = 0,
 	COLOR_ROLE_COLOR_PICKING,

Modified: branches/soc-2011-tomato/source/blender/imbuf/intern/colormanagement.c
===================================================================
--- branches/soc-2011-tomato/source/blender/imbuf/intern/colormanagement.c	2012-09-04 12:32:25 UTC (rev 50381)
+++ branches/soc-2011-tomato/source/blender/imbuf/intern/colormanagement.c	2012-09-04 12:32:32 UTC (rev 50382)
@@ -1019,81 +1019,60 @@
 #endif
 }
 
-void IMB_colormanagement_imbuf_make_scene_linear(ImBuf *ibuf, ColorManagedColorspaceSettings *colorspace_settings)
+void IMB_colormanagement_pixel_to_role(float pixel[4], int role)
 {
 #ifdef WITH_OCIO
-	if (ibuf->rect_float) {
-		const char *from_colorspace = colorspace_settings->name;
-		const char *to_colorspace = global_role_scene_linear;
+		ConstProcessorRcPtr *processor;
+		const char *from_colorspace = global_role_scene_linear;
+		const char *to_colorspace = role_colorspace_name_get(role);
 
-		IMB_colormanagement_colorspace_transform(ibuf->rect_float, ibuf->x, ibuf->y, ibuf->channels,
-		                                         from_colorspace, to_colorspace);
-	}
+		processor = create_colorspace_transform_processor(from_colorspace, to_colorspace);
+
+		if (processor) {
+			OCIO_processorApplyRGBA(processor, pixel);
+
+			OCIO_processorRelease(processor);
+		}
 #else
-	(void) ibuf;
-	(void) colorspace_settings;
+	(void) pixel;
+	(void) role;
 #endif
 }
 
-void IMB_colormanagement_imbuf_to_sequencer_space(ImBuf *ibuf, int make_float)
+void IMB_colormanagement_pixel_from_role(float pixel[4], int role)
 {
-	(void) make_float;
+#ifdef WITH_OCIO
+		ConstProcessorRcPtr *processor;
+		const char *from_colorspace = role_colorspace_name_get(role);
+		const char *to_colorspace = global_role_scene_linear;
 
-	if (!ibuf->rect_float) {
-		if (make_float && ibuf->rect) {
-			/* when converting byte buffer to float in sequencer we need to make float
-			 * buffer be in sequencer's working space, which is currently only doable
-			 * from linear space.
-			 *
-			 */
+		processor = create_colorspace_transform_processor(from_colorspace, to_colorspace);
 
-			/*
-			 * OCIO_TODO: would be nice to support direct single transform from byte to sequencer's
-			 */
+		if (processor) {
+			OCIO_processorApplyRGBA(processor, pixel);
 
-			ibuf->profile = IB_PROFILE_SRGB;
-			IMB_float_from_rect(ibuf);
+			OCIO_processorRelease(processor);
 		}
-		else {
-			/* if there's only byte buffer in image it's already in compositor's working space,
-			 * nothing to do here
-			 */
-
-			return;
-		}
-	}
-
-#ifdef WITH_OCIO
-	if (global_role_sequencer[0]) {
-		IMB_colormanagement_imbuf_to_role(ibuf, COLOR_ROLE_SEQUENCER);
-
-		ibuf->profile = IB_PROFILE_NONE;
-	}
-	else
+#else
+	(void) pixel;
+	(void) role;
 #endif
-	{
-		/* if no sequencer's working space defined fallback to legacy sRGB space */
-		IMB_convert_profile(ibuf, IB_PROFILE_NONE);
-	}
 }
 
-void IMB_colormanagement_imbuf_from_sequencer_space(ImBuf *ibuf)
+void IMB_colormanagement_imbuf_make_scene_linear(ImBuf *ibuf, ColorManagedColorspaceSettings *colorspace_settings)
 {
-	if (!ibuf->rect_float)
-		return;
+#ifdef WITH_OCIO
+	if (ibuf->rect_float) {

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list