[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [48436] branches/soc-2011-tomato: Color management refactoiring and some extra options

Sergey Sharybin sergey.vfx at gmail.com
Sat Jun 30 14:37:18 CEST 2012


Revision: 48436
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=48436
Author:   nazgul
Date:     2012-06-30 12:37:16 +0000 (Sat, 30 Jun 2012)
Log Message:
-----------
Color management refactoiring and some extra options

- Move space-being settings (such as view transform) into own
  DNA and RNA structure to avoid code duplication in some areas
  and save some arguments on display buffer acquiring function.

  Also added some utility functions to BKE to manipulate this
  settings.

- Replace static sized color managed buffer flags array with
  dynamically sized array which matches actual number of displays.

  Probably this flags better be transfposed so it'll support
  any number of view transforms and 32 displays (currently it's
  other way around). it's runtime flags only, so would be simple
  to change any time.

- Added support of configurable exposure and gamma.

  Changing this settings wouldn't generate new item in cache,
  it'll affect on buffer with the same color spaces conversion.

  It'll also run full color transform from scratch on every run,
  this could be changes in a way that it'll re-use color managed
  buffer, but from quick glance it doesn't give really noticeable
  boost.

  Currently this settings are stored as pointer in ImBuf structure
  itself. Probably it make sense removing them from ImBuf and make
  moviecache be able to store some kind of tags associated with
  cached ImBuf.

Modified Paths:
--------------
    branches/soc-2011-tomato/intern/opencolorio/ocio_capi.cpp
    branches/soc-2011-tomato/intern/opencolorio/ocio_capi.h
    branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_image.py
    branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_node.py
    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/editors/space_image/image_draw.c
    branches/soc-2011-tomato/source/blender/editors/space_image/space_image.c
    branches/soc-2011-tomato/source/blender/editors/space_node/drawnode.c
    branches/soc-2011-tomato/source/blender/editors/space_node/space_node.c
    branches/soc-2011-tomato/source/blender/imbuf/IMB_colormanagement.h
    branches/soc-2011-tomato/source/blender/imbuf/IMB_imbuf_types.h
    branches/soc-2011-tomato/source/blender/imbuf/intern/allocimbuf.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_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/intern/opencolorio/ocio_capi.cpp
===================================================================
--- branches/soc-2011-tomato/intern/opencolorio/ocio_capi.cpp	2012-06-30 12:36:53 UTC (rev 48435)
+++ branches/soc-2011-tomato/intern/opencolorio/ocio_capi.cpp	2012-06-30 12:37:16 UTC (rev 48436)
@@ -361,6 +361,16 @@
 	(*dt)->setView(name);
 }
 
+extern void OCIO_displayTransformSetDisplayCC(DisplayTransformRcPtr *dt, ConstTransformRcPtr *t)
+{
+	(*dt)->setDisplayCC(*t);
+}
+
+extern void OCIO_displayTransformSetLinearCC(DisplayTransformRcPtr *dt, ConstTransformRcPtr *t)
+{
+	(*dt)->setLinearCC(*t);
+}
+
 extern void OCIO_displayTransformRelease(DisplayTransformRcPtr* dt)
 {
 	if(dt){
@@ -392,3 +402,45 @@
 	}
 }
 
+ExponentTransformRcPtr *OCIO_createExponentTransform(void)
+{
+	ExponentTransformRcPtr *et =  new ExponentTransformRcPtr();
+
+	*et = ExponentTransform::Create();
+
+	return et;
+}
+
+void OCIO_exponentTransformSetValue(ExponentTransformRcPtr *et, const float *exponent)
+{
+	(*et)->setValue(exponent);
+}
+
+void OCIO_exponentTransformRelease(ExponentTransformRcPtr *et)
+{
+	delete et;
+}
+
+MatrixTransformRcPtr *OCIO_createMatrixTransform(void)
+{
+	MatrixTransformRcPtr *mt =  new MatrixTransformRcPtr();
+
+	*mt = MatrixTransform::Create();
+
+	return mt;
+}
+
+void OCIO_matrixTransformSetValue(MatrixTransformRcPtr *mt, const float *m44, const float *offset4)
+{
+	(*mt)->setValue(m44, offset4);
+}
+
+void OCIO_matrixTransformRelease(MatrixTransformRcPtr *mt)
+{
+	delete mt;
+}
+
+void OCIO_matrixTransformScale(float * m44, float * offset4, const float *scale4f)
+{
+	MatrixTransform::Scale(m44, offset4, scale4f);
+}

Modified: branches/soc-2011-tomato/intern/opencolorio/ocio_capi.h
===================================================================
--- branches/soc-2011-tomato/intern/opencolorio/ocio_capi.h	2012-06-30 12:36:53 UTC (rev 48435)
+++ branches/soc-2011-tomato/intern/opencolorio/ocio_capi.h	2012-06-30 12:37:16 UTC (rev 48436)
@@ -49,6 +49,8 @@
 	OCIO_DECLARE_HANDLE(PackedImageDesc);
 	OCIO_DECLARE_HANDLE(DisplayTransformRcPtr);
 	OCIO_DECLARE_HANDLE(ConstTransformRcPtr);
+	OCIO_DECLARE_HANDLE(ExponentTransformRcPtr);
+	OCIO_DECLARE_HANDLE(MatrixTransformRcPtr);
 #endif
 
 
@@ -92,6 +94,8 @@
 extern void OCIO_displayTransformSetInputColorSpaceName(DisplayTransformRcPtr* dt, const char * name);
 extern void OCIO_displayTransformSetDisplay(DisplayTransformRcPtr* dt, const char * name);
 extern void OCIO_displayTransformSetView(DisplayTransformRcPtr* dt, const char * name);
+extern void OCIO_displayTransformSetDisplayCC(DisplayTransformRcPtr *dt, ConstTransformRcPtr *et);
+extern void OCIO_displayTransformSetLinearCC(DisplayTransformRcPtr *dt, ConstTransformRcPtr *et);
 extern void OCIO_displayTransformRelease(DisplayTransformRcPtr* dt);
 
 PackedImageDesc* OCIO_createPackedImageDesc(float * data, long width, long height, long numChannels,
@@ -99,6 +103,16 @@
 
 extern void OCIO_packedImageDescRelease(PackedImageDesc* p);
 
+ExponentTransformRcPtr *OCIO_createExponentTransform(void);
+void OCIO_exponentTransformSetValue(ExponentTransformRcPtr *et, const float *exponent);
+void OCIO_exponentTransformRelease(ExponentTransformRcPtr *et);
+
+MatrixTransformRcPtr *OCIO_createMatrixTransform(void);
+void OCIO_matrixTransformSetValue(MatrixTransformRcPtr *et, const float *m44, const float *offset4);
+void OCIO_matrixTransformRelease(MatrixTransformRcPtr *mt);
+
+void OCIO_matrixTransformScale(float * m44, float * offset4, const float * scale4);
+
 #ifdef __cplusplus
 }
 #endif

Modified: branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_image.py
===================================================================
--- branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_image.py	2012-06-30 12:36:53 UTC (rev 48435)
+++ branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_image.py	2012-06-30 12:37:16 UTC (rev 48436)
@@ -437,11 +437,19 @@
 
         sima = context.space_data
         window = context.window
+        view_settings = sima.view_settings
 
-        layout.prop(window, "display_device", text="Display")
-        layout.prop(sima, "view_transform", text="View")
+        # OCIO_TODO: de-duplicate this between different spaces
+        col = layout.column()
+        col.prop(window, "display_device", text="Display")
+        col.prop(view_settings, "view_transform", text="View")
 
+        col = layout.column()
+        col.active = view_settings.view_transform not in {'ACES ODT Tonecurve', 'NONE'}
+        col.prop(view_settings, "exposure")
+        col.prop(view_settings, "gamma")
 
+
 class IMAGE_PT_image_properties(Panel):
     bl_space_type = 'IMAGE_EDITOR'
     bl_region_type = 'UI'

Modified: branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_node.py
===================================================================
--- branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_node.py	2012-06-30 12:36:53 UTC (rev 48435)
+++ branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_node.py	2012-06-30 12:37:16 UTC (rev 48436)
@@ -194,11 +194,19 @@
 
         snode = context.space_data
         window = context.window
+        view_settings = snode.view_settings
 
-        layout.prop(window, "display_device", text="Display")
-        layout.prop(snode, "view_transform", text="View")
+        # OCIO_TODO: de-duplicate this between different spaces
+        col = layout.column()
+        col.prop(window, "display_device", text="Display")
+        col.prop(view_settings, "view_transform", text="View")
 
+        col = layout.column()
+        col.active = view_settings.view_transform not in {'ACES ODT Tonecurve', 'NONE'}
+        col.prop(view_settings, "exposure")
+        col.prop(view_settings, "gamma")
 
+
 # Node Backdrop options
 class NODE_PT_properties(Panel):
     bl_space_type = 'NODE_EDITOR'

Modified: branches/soc-2011-tomato/source/blender/blenkernel/BKE_colortools.h
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/BKE_colortools.h	2012-06-30 12:36:53 UTC (rev 48435)
+++ branches/soc-2011-tomato/source/blender/blenkernel/BKE_colortools.h	2012-06-30 12:37:16 UTC (rev 48436)
@@ -31,6 +31,7 @@
  *  \ingroup bke
  */
 
+struct ColorManagedViewSettings;
 struct CurveMapping;
 struct CurveMap;
 struct CurveMapPoint;
@@ -80,5 +81,8 @@
 void                scopes_free(struct Scopes *scopes);
 void                scopes_new(struct Scopes *scopes);
 
+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);
+
 #endif
-

Modified: branches/soc-2011-tomato/source/blender/blenkernel/intern/colortools.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/intern/colortools.c	2012-06-30 12:36:53 UTC (rev 48435)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/colortools.c	2012-06-30 12:37:16 UTC (rev 48436)
@@ -1207,3 +1207,21 @@
 	scopes->waveform_3 = NULL;
 	scopes->vecscope = NULL;
 }
+
+void BKE_color_managed_view_settings_init(ColorManagedViewSettings *settings)
+{
+	/* OCIO_TODO: use default view transform here when OCIO is completely integrated
+	*             and proper versioning stuff is added.
+	*             for now use NONE to be compatible with all current files
+	*/
+	BLI_strncpy(settings->view_transform, "NONE", sizeof(settings->view_transform));
+
+	settings->gamma = 1.0f;
+	settings->exposure = 0.5f;
+}
+
+void BKE_color_managed_view_settings_copy(ColorManagedViewSettings *new_settings,
+                                          const ColorManagedViewSettings *settings)
+{
+	*new_settings = *settings;
+}

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-06-30 12:36:53 UTC (rev 48435)
+++ branches/soc-2011-tomato/source/blender/editors/space_image/image_draw.c	2012-06-30 12:37:16 UTC (rev 48436)
@@ -461,7 +461,8 @@
 		 * convert them, and optionally apply curves */
 		image_verify_buffer_float(ima, ibuf, color_manage);
 
-		display_buffer = IMB_display_buffer_acquire(ibuf, sima->view_transform, win->display_device, &cache_handle);
+		display_buffer = IMB_display_buffer_acquire(ibuf, &sima->view_settings,
+		                                            win->display_device, &cache_handle);
 
 		if (display_buffer)
 			glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, display_buffer);

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-06-30 12:36:53 UTC (rev 48435)
+++ branches/soc-2011-tomato/source/blender/editors/space_image/space_image.c	2012-06-30 12:37:16 UTC (rev 48436)
@@ -387,11 +387,7 @@
 	simage->zoom = 1;
 	simage->lock = 1;
 
-	/* OCIO_TODO: use default view transform here when OCIO is completely integrated
-	*             and proper versioning stuff is added.
-	*             for now use NONE to be compatible with all current files
-	*/
-	BLI_strncpy(simage->view_transform, "NONE", sizeof(simage->view_transform));
+	BKE_color_managed_view_settings_init(&simage->view_settings);
 
 	simage->iuser.ok = 1;
 	simage->iuser.fie_ima = 2;
@@ -464,7 +460,7 @@
 
 	scopes_new(&simagen->scopes);
 
-	BLI_strncpy(simagen->view_transform, simage->view_transform, sizeof(simage->view_transform));
+	BKE_color_managed_view_settings_copy(&simagen->view_settings, &simage->view_settings);
 
 	return (SpaceLink *)simagen;
 }

Modified: branches/soc-2011-tomato/source/blender/editors/space_node/drawnode.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/space_node/drawnode.c	2012-06-30 12:36:53 UTC (rev 48435)
+++ branches/soc-2011-tomato/source/blender/editors/space_node/drawnode.c	2012-06-30 12:37:16 UTC (rev 48436)
@@ -2984,7 +2984,8 @@
 			y = (ar->winy - snode->zoom * ibuf->y) / 2 + snode->yof;
 			
 

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list