[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [48438] branches/soc-2011-tomato: Color management cleanup and improvements

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


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

- De-duplicate code used by color management panel drawing,
  moved this panel to utility file in bl_ui

- Added support of per-window color management control
  which means view transform. exposure and gamma could be
  set per window and all spaces would use this settings.

  This is default behavior for older files now.

- Added support of color management display of movie clips
  in clip editor.

  Supported both texture buffer and fallback draw methods.

- Fixed default values for exposure and gamma

Modified Paths:
--------------
    branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_clip.py
    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/editors/include/ED_clip.h
    branches/soc-2011-tomato/source/blender/editors/space_clip/clip_draw.c
    branches/soc-2011-tomato/source/blender/editors/space_clip/clip_editor.c
    branches/soc-2011-tomato/source/blender/editors/space_clip/space_clip.c
    branches/soc-2011-tomato/source/blender/editors/space_image/image_draw.c
    branches/soc-2011-tomato/source/blender/editors/space_node/drawnode.c
    branches/soc-2011-tomato/source/blender/imbuf/IMB_colormanagement.h
    branches/soc-2011-tomato/source/blender/imbuf/intern/colormanagement.c
    branches/soc-2011-tomato/source/blender/makesdna/DNA_space_types.h
    branches/soc-2011-tomato/source/blender/makesdna/DNA_windowmanager_types.h
    branches/soc-2011-tomato/source/blender/makesrna/intern/rna_color.c
    branches/soc-2011-tomato/source/blender/makesrna/intern/rna_space.c
    branches/soc-2011-tomato/source/blender/makesrna/intern/rna_wm.c

Added Paths:
-----------
    branches/soc-2011-tomato/release/scripts/startup/bl_ui/properties_color_management.py

Added: branches/soc-2011-tomato/release/scripts/startup/bl_ui/properties_color_management.py
===================================================================
--- branches/soc-2011-tomato/release/scripts/startup/bl_ui/properties_color_management.py	                        (rev 0)
+++ branches/soc-2011-tomato/release/scripts/startup/bl_ui/properties_color_management.py	2012-06-30 12:37:41 UTC (rev 48438)
@@ -0,0 +1,44 @@
+# ##### BEGIN GPL LICENSE BLOCK #####
+#
+#  This program is free software; you can redistribute it and/or
+#  modify it under the terms of the GNU General Public License
+#  as published by the Free Software Foundation; either version 2
+#  of the License, or (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program; if not, write to the Free Software Foundation,
+#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# ##### END GPL LICENSE BLOCK #####
+
+# <pep8 compliant>
+
+class ColorManagedViewSettingsPanel:
+
+    def draw(self, context):
+        layout = self.layout
+
+        space = context.space_data
+        window = context.window
+        space_view_settings = space.view_settings
+
+        if space_view_settings.use_global_settings:
+            view_settings = window.view_settings
+        else:
+            view_settings = space.view_settings
+
+        col = layout.column()
+        col.prop(space_view_settings, "use_global_settings")
+        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")
+

Modified: branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_clip.py
===================================================================
--- branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_clip.py	2012-06-30 12:37:24 UTC (rev 48437)
+++ branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_clip.py	2012-06-30 12:37:41 UTC (rev 48438)
@@ -20,6 +20,7 @@
 
 import bpy
 from bpy.types import Panel, Header, Menu
+from bl_ui.properties_color_management import ColorManagedViewSettingsPanel
 
 
 class CLIP_HT_header(Header):
@@ -1002,6 +1003,13 @@
         col.prop(sc.clip_user, "use_render_undistorted")
 
 
+class CLIP_PT_display_properties(Panel, ColorManagedViewSettingsPanel):
+    bl_space_type = 'CLIP_EDITOR'
+    bl_region_type = 'UI'
+    bl_label = "Display Properties"
+    bl_options = {'DEFAULT_CLOSED'}
+
+
 class CLIP_PT_footage(CLIP_PT_clip_view_panel, Panel):
     bl_space_type = 'CLIP_EDITOR'
     bl_region_type = 'UI'

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:37:24 UTC (rev 48437)
+++ branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_image.py	2012-06-30 12:37:41 UTC (rev 48438)
@@ -20,6 +20,7 @@
 import bpy
 from bpy.types import Header, Menu, Panel
 from bl_ui.properties_paint_common import UnifiedPaintPanel
+from bl_ui.properties_color_management import ColorManagedViewSettingsPanel
 
 
 class ImagePaintPanel(UnifiedPaintPanel):
@@ -427,29 +428,12 @@
             layout.prop(sima, "use_realtime_update", text="", icon_only=True, icon='LOCKED')
 
 
-class IMAGE_PT_display_properties(Panel):
+class IMAGE_PT_display_properties(Panel, ColorManagedViewSettingsPanel):
     bl_space_type = 'IMAGE_EDITOR'
     bl_region_type = 'UI'
     bl_label = "Display Properties"
 
-    def draw(self, context):
-        layout = self.layout
 
-        sima = context.space_data
-        window = context.window
-        view_settings = sima.view_settings
-
-        # 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:37:24 UTC (rev 48437)
+++ branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_node.py	2012-06-30 12:37:41 UTC (rev 48438)
@@ -19,6 +19,7 @@
 # <pep8 compliant>
 import bpy
 from bpy.types import Header, Menu, Panel
+from bl_ui.properties_color_management import ColorManagedViewSettingsPanel
 
 
 class NODE_HT_header(Header):
@@ -184,29 +185,12 @@
         layout.operator("node.read_fullsamplelayers")
 
 
-class NODE_PT_display_properties(Panel):
+class NODE_PT_display_properties(Panel, ColorManagedViewSettingsPanel):
     bl_space_type = 'NODE_EDITOR'
     bl_region_type = 'UI'
     bl_label = "Display Properties"
 
-    def draw(self, context):
-        layout = self.layout
 
-        snode = context.space_data
-        window = context.window
-        view_settings = snode.view_settings
-
-        # 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/editors/include/ED_clip.h
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/include/ED_clip.h	2012-06-30 12:37:24 UTC (rev 48437)
+++ branches/soc-2011-tomato/source/blender/editors/include/ED_clip.h	2012-06-30 12:37:41 UTC (rev 48438)
@@ -81,7 +81,7 @@
 
 /* textures buffer */
 int ED_space_clip_texture_buffer_supported(struct SpaceClip *sc);
-int ED_space_clip_load_movieclip_buffer(struct SpaceClip *sc, struct ImBuf *ibuf);
+int ED_space_clip_load_movieclip_buffer(struct SpaceClip *sc, struct ImBuf *ibuf, const unsigned char *display_buffer);
 void ED_space_clip_unload_movieclip_buffer(struct SpaceClip *sc);
 void ED_space_clip_free_texture_buffer(struct SpaceClip *sc);
 

Modified: branches/soc-2011-tomato/source/blender/editors/space_clip/clip_draw.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/space_clip/clip_draw.c	2012-06-30 12:37:24 UTC (rev 48437)
+++ branches/soc-2011-tomato/source/blender/editors/space_clip/clip_draw.c	2012-06-30 12:37:41 UTC (rev 48438)
@@ -42,6 +42,7 @@
 #include "BKE_tracking.h"
 #include "BKE_mask.h"
 
+#include "IMB_colormanagement.h"
 #include "IMB_imbuf_types.h"
 #include "IMB_imbuf.h"
 
@@ -251,7 +252,7 @@
 	}
 }
 
-static void draw_movieclip_buffer(SpaceClip *sc, ARegion *ar, ImBuf *ibuf,
+static void draw_movieclip_buffer(wmWindow *win, SpaceClip *sc, ARegion *ar, ImBuf *ibuf,
                                   int width, int height, float zoomx, float zoomy)
 {
 	int x, y;
@@ -265,13 +266,20 @@
 		glRectf(x, y, x + zoomx * width, y + zoomy * height);
 	}
 	else {
+		const ColorManagedViewSettings *view_settings;
+		unsigned char *display_buffer;
+		void *cache_handle;
+
 		verify_buffer_float(ibuf);
 
-		if (ibuf->rect) {
+		view_settings = IMB_view_settings_get_effective(win, &sc->view_settings);
+		display_buffer = IMB_display_buffer_acquire(ibuf, view_settings, win->display_device, &cache_handle);
+
+		if (display_buffer) {
 			int need_fallback = 1;
 
 			if (ED_space_clip_texture_buffer_supported(sc)) {
-				if (ED_space_clip_load_movieclip_buffer(sc, ibuf)) {
+				if (ED_space_clip_load_movieclip_buffer(sc, ibuf, display_buffer)) {
 					glPushMatrix();
 					glTranslatef(x, y, 0.0f);
 					glScalef(zoomx, zoomy, 1.0f);
@@ -297,12 +305,14 @@
 				/* set zoom */
 				glPixelZoom(zoomx * width / ibuf->x, zoomy * height / ibuf->y);
 
-				glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect);
+				glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, display_buffer);
 
 				/* reset zoom */
 				glPixelZoom(1.0f, 1.0f);
 			}
 		}
+
+		IMB_display_buffer_release(cache_handle);
 	}
 
 	/* draw boundary border for frame if stabilization is enabled */
@@ -1410,6 +1420,7 @@
 
 void clip_draw_main(const bContext *C, ARegion *ar)
 {
+	wmWindow *win = CTX_wm_window(C);
 	SpaceClip *sc = CTX_wm_space_clip(C);
 	MovieClip *clip = ED_space_clip_get_clip(sc);
 	Scene *scene = CTX_data_scene(C);
@@ -1460,7 +1471,7 @@
 	}
 
 	if (ibuf) {
-		draw_movieclip_buffer(sc, ar, ibuf, width, height, zoomx, zoomy);
+		draw_movieclip_buffer(win, sc, ar, ibuf, width, height, zoomx, zoomy);
 		IMB_freeImBuf(ibuf);
 	}
 	else {

Modified: branches/soc-2011-tomato/source/blender/editors/space_clip/clip_editor.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/space_clip/clip_editor.c	2012-06-30 12:37:24 UTC (rev 48437)
+++ branches/soc-2011-tomato/source/blender/editors/space_clip/clip_editor.c	2012-06-30 12:37:41 UTC (rev 48438)
@@ -533,6 +533,7 @@
 	GLuint texture;			/* OGL texture ID */
 	short texture_allocated;	/* flag if texture was allocated by glGenTextures */
 	struct ImBuf *texture_ibuf;	/* image buffer for which texture was created */
+	const unsigned char *display_buffer; /* display buffer for which texture was created */
 	int image_width, image_height;	/* image width and height for which texture was created */

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list