[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [50425] branches/soc-2011-tomato/source/ blender: Color Management: RGB curves transform as a part of display transform

Sergey Sharybin sergey.vfx at gmail.com
Wed Sep 5 18:08:37 CEST 2012


Revision: 50425
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=50425
Author:   nazgul
Date:     2012-09-05 16:08:36 +0000 (Wed, 05 Sep 2012)
Log Message:
-----------
Color Management: RGB curves transform as a part of display transform

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.

Modified Paths:
--------------
    branches/soc-2011-tomato/source/blender/blenkernel/BKE_colortools.h
    branches/soc-2011-tomato/source/blender/blenkernel/intern/colortools.c
    branches/soc-2011-tomato/source/blender/blenkernel/intern/scene.c
    branches/soc-2011-tomato/source/blender/blenloader/intern/readfile.c
    branches/soc-2011-tomato/source/blender/blenloader/intern/writefile.c
    branches/soc-2011-tomato/source/blender/editors/interface/interface_templates.c
    branches/soc-2011-tomato/source/blender/editors/space_image/image_buttons.c
    branches/soc-2011-tomato/source/blender/editors/space_image/image_ops.c
    branches/soc-2011-tomato/source/blender/editors/space_image/space_image.c
    branches/soc-2011-tomato/source/blender/imbuf/intern/colormanagement.c
    branches/soc-2011-tomato/source/blender/makesdna/DNA_color_types.h
    branches/soc-2011-tomato/source/blender/makesdna/DNA_scene_types.h
    branches/soc-2011-tomato/source/blender/makesdna/DNA_space_types.h
    branches/soc-2011-tomato/source/blender/makesrna/intern/rna_color.c
    branches/soc-2011-tomato/source/blender/makesrna/intern/rna_space.c

Modified: branches/soc-2011-tomato/source/blender/blenkernel/BKE_colortools.h
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/BKE_colortools.h	2012-09-05 14:29:15 UTC (rev 50424)
+++ branches/soc-2011-tomato/source/blender/blenkernel/BKE_colortools.h	2012-09-05 16:08:36 UTC (rev 50425)
@@ -104,6 +104,7 @@
 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,

Modified: branches/soc-2011-tomato/source/blender/blenkernel/intern/colortools.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/intern/colortools.c	2012-09-05 14:29:15 UTC (rev 50424)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/colortools.c	2012-09-05 16:08:36 UTC (rev 50425)
@@ -175,6 +175,7 @@
 	}
 
 	curvemapping_set_black_white_ex(cumap->black, cumap->white, cumap->bwmul);
+	cumap->changed_timestamp++;
 }
 
 /* ***************** operations on single curve ************* */
@@ -1289,10 +1290,20 @@
 {
 	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)
 {
 	BLI_strncpy(colorspace_settings->name, "NONE", sizeof(colorspace_settings->name));

Modified: branches/soc-2011-tomato/source/blender/blenkernel/intern/scene.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/intern/scene.c	2012-09-05 14:29:15 UTC (rev 50424)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/scene.c	2012-09-05 16:08:36 UTC (rev 50425)
@@ -342,6 +342,8 @@
 		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)

Modified: branches/soc-2011-tomato/source/blender/blenloader/intern/readfile.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenloader/intern/readfile.c	2012-09-05 14:29:15 UTC (rev 50424)
+++ branches/soc-2011-tomato/source/blender/blenloader/intern/readfile.c	2012-09-05 16:08:36 UTC (rev 50425)
@@ -4904,6 +4904,14 @@
 	}
 }
 
+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 @@
 	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 ***************** */

Modified: branches/soc-2011-tomato/source/blender/blenloader/intern/writefile.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenloader/intern/writefile.c	2012-09-05 14:29:15 UTC (rev 50424)
+++ branches/soc-2011-tomato/source/blender/blenloader/intern/writefile.c	2012-09-05 16:08:36 UTC (rev 50425)
@@ -2119,6 +2119,13 @@
 	}
 }
 
+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 @@
 			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 */

Modified: branches/soc-2011-tomato/source/blender/editors/interface/interface_templates.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/interface/interface_templates.c	2012-09-05 14:29:15 UTC (rev 50424)
+++ branches/soc-2011-tomato/source/blender/editors/interface/interface_templates.c	2012-09-05 16:08:36 UTC (rev 50425)
@@ -2848,4 +2848,9 @@
 	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);
 }

Modified: branches/soc-2011-tomato/source/blender/editors/space_image/image_buttons.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/space_image/image_buttons.c	2012-09-05 14:29:15 UTC (rev 50424)
+++ branches/soc-2011-tomato/source/blender/editors/space_image/image_buttons.c	2012-09-05 16:08:36 UTC (rev 50425)
@@ -169,47 +169,6 @@
 
 /* ************ 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 @@
 {
 	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");

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-05 14:29:15 UTC (rev 50424)
+++ branches/soc-2011-tomato/source/blender/editors/space_image/image_ops.c	2012-09-05 16:08:36 UTC (rev 50425)
@@ -2053,7 +2053,9 @@
 	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 @@
 			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
 		{

Modified: branches/soc-2011-tomato/source/blender/editors/space_image/space_image.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/space_image/space_image.c	2012-09-05 14:29:15 UTC (rev 50424)
+++ branches/soc-2011-tomato/source/blender/editors/space_image/space_image.c	2012-09-05 16:08:36 UTC (rev 50425)
@@ -195,9 +195,7 @@
 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 @@
 	SpaceImage *simagen = MEM_dupallocN(sl);
 	
 	/* clear or remove stuff from old */
-	if (simagen->cumap)
-		simagen->cumap = curvemapping_copy(simagen->cumap);
 
 	scopes_new(&simagen->scopes);
 

Modified: branches/soc-2011-tomato/source/blender/imbuf/intern/colormanagement.c
===================================================================
--- branches/soc-2011-tomato/source/blender/imbuf/intern/colormanagement.c	2012-09-05 14:29:15 UTC (rev 50424)
+++ branches/soc-2011-tomato/source/blender/imbuf/intern/colormanagement.c	2012-09-05 16:08:36 UTC (rev 50425)
@@ -56,6 +56,7 @@
 #include "BLI_string.h"

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list