[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [48342] branches/soc-2011-tomato: Clean-up and refactor of current OCIO integration

Sergey Sharybin sergey.vfx at gmail.com
Wed Jun 27 20:10:53 CEST 2012


Revision: 48342
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=48342
Author:   nazgul
Date:     2012-06-27 18:10:53 +0000 (Wed, 27 Jun 2012)
Log Message:
-----------
Clean-up and refactor of current OCIO integration

- Cleaned up some files -- seems there were some wrongly resolved
  conflicts which resulted into duplicated code in space_image.py
  and some build configuration files.
- Store all color space related data (such as display device, view
  transform and so) as strings, so it could easily be ported to new
  OCIO configuration files and it'll be much more portable between
  different configurations.

  This required adding some look-ups to RNA associated with such
  settings, but it's indeed the only way to do this. If it'll be
  figured out such look-ups causes performance issues it's possible
  to optimize this further using hash. So far it's only few elements
  in list to be looked up.
- Added support of display device transformation from OCIO
  configuration files. Display device is setting per-window and
  different windows could have different display devices, so it's
  possible to have one blender window opened on sRGB monitor and
  another one on xyz projector.

  Display device is ignored when using ACES ODT Tonecurve view
  transform due to it's not an OCIO transformation. Probably it'll
  be possible to get rid of this tone curve soon (if it'll be
  proved useless or it'll be implemented as a part of OCIO LUT).
- Movie Cache now supports deleter functions for user keys, so
  such keys could have some allocated data which would be removed
  as soon as element in cache is being removed.
- Movie Cache now support callbacks to check whether current
  cache element could be removed from a cache due to it wouldn't
  be accessed anymore.
- Re-written cache stuff for display buffers of ImBuf. Now it's
  using Movie Cache which is global for all ImBufs.

  Probably it's not implemented in fastest way, would be investigated
  further and probably changed it performance wouldn't be good enough.

Modified Paths:
--------------
    branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_image.py
    branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_info.py
    branches/soc-2011-tomato/source/blender/blenkernel/intern/movieclip.c
    branches/soc-2011-tomato/source/blender/blenkernel/intern/seqcache.c
    branches/soc-2011-tomato/source/blender/blenloader/intern/readfile.c
    branches/soc-2011-tomato/source/blender/compositor/operations/COM_ViewerBaseOperation.cpp
    branches/soc-2011-tomato/source/blender/editors/space_image/image_draw.c
    branches/soc-2011-tomato/source/blender/editors/space_image/image_intern.h
    branches/soc-2011-tomato/source/blender/editors/space_image/space_image.c
    branches/soc-2011-tomato/source/blender/imbuf/CMakeLists.txt
    branches/soc-2011-tomato/source/blender/imbuf/IMB_colormanagement.h
    branches/soc-2011-tomato/source/blender/imbuf/IMB_imbuf.h
    branches/soc-2011-tomato/source/blender/imbuf/IMB_imbuf_types.h
    branches/soc-2011-tomato/source/blender/imbuf/IMB_moviecache.h
    branches/soc-2011-tomato/source/blender/imbuf/SConscript
    branches/soc-2011-tomato/source/blender/imbuf/intern/IMB_filter.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/imbuf/intern/divers.c
    branches/soc-2011-tomato/source/blender/imbuf/intern/filter.c
    branches/soc-2011-tomato/source/blender/imbuf/intern/moviecache.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_space.c
    branches/soc-2011-tomato/source/blender/makesrna/intern/rna_wm.c
    branches/soc-2011-tomato/source/blender/windowmanager/CMakeLists.txt
    branches/soc-2011-tomato/source/blender/windowmanager/SConscript
    branches/soc-2011-tomato/source/blender/windowmanager/intern/wm_init_exit.c
    branches/soc-2011-tomato/source/blender/windowmanager/intern/wm_window.c

Added Paths:
-----------
    branches/soc-2011-tomato/source/blender/imbuf/intern/IMB_colormanagement_intern.h

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-27 17:48:39 UTC (rev 48341)
+++ branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_image.py	2012-06-27 18:10:53 UTC (rev 48342)
@@ -107,15 +107,6 @@
         layout.operator("uv.select_linked")
 
 
-class IMAGE_PT_view_transform(Panel):
-    bl_label = "View Transform"
-
-    def draw(self, context):
-        layout = self.layout
-
-        sima = context.space_data
-
-        layout.prop(sima, "view_transform")
 class IMAGE_MT_image(Menu):
     bl_label = "Image"
 
@@ -436,17 +427,19 @@
             layout.prop(sima, "use_realtime_update", text="", icon_only=True, icon='LOCKED')
 
 
-class IMAGE_PT_view_transform(Panel):
+class IMAGE_PT_display_properties(Panel):
     bl_space_type = 'IMAGE_EDITOR'
     bl_region_type = 'UI'
-    bl_label = "View Transform"
+    bl_label = "Display Properties"
 
     def draw(self, context):
         layout = self.layout
 
         sima = context.space_data
+        window = context.window
 
-        layout.prop(sima, "view_transform", text="")
+        layout.prop(window, "display_device", text="Display")
+        layout.prop(sima, "view_transform", text="View")
 
 
 class IMAGE_PT_image_properties(Panel):

Modified: branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_info.py
===================================================================
--- branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_info.py	2012-06-27 17:48:39 UTC (rev 48341)
+++ branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_info.py	2012-06-27 18:10:53 UTC (rev 48342)
@@ -356,6 +356,8 @@
     def draw(self, context):
         import sys
 
+        window = context.window
+
         layout = self.layout
 
         layout.operator("wm.window_duplicate")
@@ -364,7 +366,10 @@
             layout.separator()
             layout.operator("wm.console_toggle", icon='CONSOLE')
 
+        layout.separator()
+        layout.prop_menu_enum(window, "display_device", text="Display")
 
+
 class INFO_MT_help(Menu):
     bl_label = "Help"
 

Modified: branches/soc-2011-tomato/source/blender/blenkernel/intern/movieclip.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/intern/movieclip.c	2012-06-27 17:48:39 UTC (rev 48341)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/movieclip.c	2012-06-27 18:10:53 UTC (rev 48342)
@@ -407,8 +407,8 @@
 	if (!clip->cache) {
 		clip->cache = MEM_callocN(sizeof(MovieClipCache), "movieClipCache");
 
-		clip->cache->moviecache = IMB_moviecache_create(sizeof(MovieClipImBufCacheKey), moviecache_hashhash,
-		                                                moviecache_hashcmp, moviecache_keydata);
+		clip->cache->moviecache = IMB_moviecache_create(sizeof(MovieClipImBufCacheKey), NULL, moviecache_hashhash,
+		                                                moviecache_hashcmp, moviecache_keydata, NULL);
 	}
 
 	key.framenr = user->framenr;

Modified: branches/soc-2011-tomato/source/blender/blenkernel/intern/seqcache.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/intern/seqcache.c	2012-06-27 17:48:39 UTC (rev 48341)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/seqcache.c	2012-06-27 18:10:53 UTC (rev 48342)
@@ -98,8 +98,8 @@
 {
 	if (moviecache) {
 		IMB_moviecache_free(moviecache);
-		moviecache = IMB_moviecache_create(sizeof(SeqCacheKey), seqcache_hashhash,
-		                                   seqcache_hashcmp, NULL);
+		moviecache = IMB_moviecache_create(sizeof(SeqCacheKey), NULL, seqcache_hashhash,
+		                                   seqcache_hashcmp, NULL, NULL);
 	}
 }
 
@@ -133,8 +133,8 @@
 	}
 
 	if (!moviecache) {
-		moviecache = IMB_moviecache_create(sizeof(SeqCacheKey), seqcache_hashhash,
-		                                   seqcache_hashcmp, NULL);
+		moviecache = IMB_moviecache_create(sizeof(SeqCacheKey), NULL, seqcache_hashhash,
+		                                   seqcache_hashcmp, NULL, NULL);
 	}
 
 	key.seq = seq;

Modified: branches/soc-2011-tomato/source/blender/blenloader/intern/readfile.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenloader/intern/readfile.c	2012-06-27 17:48:39 UTC (rev 48341)
+++ branches/soc-2011-tomato/source/blender/blenloader/intern/readfile.c	2012-06-27 18:10:53 UTC (rev 48342)
@@ -144,6 +144,7 @@
 #include "BKE_sound.h"
 
 #include "IMB_imbuf.h"  // for proxy / timecode versioning stuff
+#include "IMB_colormanagement.h"
 
 #include "NOD_socket.h"
 
@@ -8007,7 +8008,10 @@
 	fix_relpaths_library(fd->relabase, bfd->main); /* make all relative paths, relative to the open blend file */
 	
 	link_global(fd, bfd);	/* as last */
-	
+
+	/* OCIO_TODO: is there nicer place for this? */
+	IMB_colormanagement_check_file_config(bfd->main);
+
 	return bfd;
 }
 

Modified: branches/soc-2011-tomato/source/blender/compositor/operations/COM_ViewerBaseOperation.cpp
===================================================================
--- branches/soc-2011-tomato/source/blender/compositor/operations/COM_ViewerBaseOperation.cpp	2012-06-27 17:48:39 UTC (rev 48341)
+++ branches/soc-2011-tomato/source/blender/compositor/operations/COM_ViewerBaseOperation.cpp	2012-06-27 18:10:53 UTC (rev 48342)
@@ -35,6 +35,7 @@
 	#include "MEM_guardedalloc.h"
 	#include "IMB_imbuf.h"
 	#include "IMB_imbuf_types.h"
+	#include "IMB_colormanagement.h"
 }
 
 
@@ -72,7 +73,10 @@
 		anImage->ok = IMA_OK_LOADED;
 	}
 
-	imb_freerectviewImBuf_all(ibuf);
+	/* viewer might have been change size, invalidate cached
+	 * display buffers so they'll be used with a proper size
+	 */
+	IMB_display_buffer_invalidate(ibuf);
 
 	/* now we combine the input with ibuf */
 	this->m_outputBuffer = ibuf->rect_float;
@@ -88,7 +92,7 @@
 void ViewerBaseOperation::deinitExecution()
 {
 	ImBuf *ibuf = BKE_image_acquire_ibuf(this->m_image, this->m_imageUser, &this->m_lock);
-	imb_freerectviewImBuf_all(ibuf);
+	IMB_display_buffer_invalidate(ibuf);
 	BKE_image_release_ibuf(this->m_image, this->m_lock);
 
 	this->m_outputBuffer = NULL;

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-27 17:48:39 UTC (rev 48341)
+++ branches/soc-2011-tomato/source/blender/editors/space_image/image_draw.c	2012-06-27 18:10:53 UTC (rev 48342)
@@ -50,6 +50,7 @@
 
 #include "IMB_imbuf.h"
 #include "IMB_imbuf_types.h"
+#include "IMB_colormanagement.h"
 
 #include "BKE_context.h"
 #include "BKE_global.h"
@@ -69,6 +70,8 @@
 #include "UI_resources.h"
 #include "UI_view2d.h"
 
+#include "WM_api.h"
+#include "WM_types.h"
 
 #include "RE_pipeline.h"
 
@@ -76,7 +79,7 @@
 
 #define HEADER_HEIGHT 18
 
-static void image_verify_buffer_float(Image *ima, ImBuf *ibuf, int color_manage, int view_transform)
+static void image_verify_buffer_float(Image *ima, ImBuf *ibuf, int color_manage)
 {
 	/* detect if we need to redo the curve map.
 	 * ibuf->rect is zero for compositor and render results after change 
@@ -85,9 +88,7 @@
 	 * NOTE: if float buffer changes, we have to manually remove the rect
 	 */
 
-	unsigned int *rect = imb_getrectviewImBuf(ibuf, view_transform);
-
-	if (ibuf->rect_float && (rect == NULL || (ibuf->userflags & IB_RECT_INVALID)) ) {
+	if (ibuf->rect_float && (ibuf->rect == NULL || (ibuf->userflags & IB_RECT_INVALID)) ) {
 		if (color_manage) {
 			if (ima && ima->source == IMA_SRC_VIEWER)
 				ibuf->profile = IB_PROFILE_LINEAR_RGB;
@@ -95,7 +96,7 @@
 		else
 			ibuf->profile = IB_PROFILE_NONE;
 
-		IMB_rect_from_float_with_view_transform(ibuf, view_transform);
+		IMB_rect_from_float(ibuf);
 	}
 }
 
@@ -419,7 +420,7 @@
 	MEM_freeN(rectf);
 }
 
-static void draw_image_buffer(SpaceImage *sima, ARegion *ar, Scene *scene, Image *ima, ImBuf *ibuf, float fx, float fy, float zoomx, float zoomy)
+static void draw_image_buffer(wmWindow *win, SpaceImage *sima, ARegion *ar, Scene *scene, Image *ima, ImBuf *ibuf, float fx, float fy, float zoomx, float zoomy)
 {
 	int x, y;
 	int color_manage = scene->r.color_mgt_flag & R_COLOR_MANAGEMENT;
@@ -432,10 +433,8 @@
 
 	/* this part is generic image display */
 	if (sima->flag & SI_SHOW_ALPHA) {
-		unsigned int *rect = imb_getrectviewImBuf(ibuf, sima->view_transform);
-
-		if (rect)
-			sima_draw_alpha_pixels(x, y, ibuf->x, ibuf->y, rect);
+		if (ibuf->rect)
+			sima_draw_alpha_pixels(x, y, ibuf->x, ibuf->y, ibuf->rect);
 		else if (ibuf->rect_float && ibuf->channels == 4)
 			sima_draw_alpha_pixelsf(x, y, ibuf->x, ibuf->y, ibuf->rect_float);
 	}
@@ -448,7 +447,8 @@
 			sima_draw_zbuffloat_pixels(scene, x, y, ibuf->x, ibuf->y, ibuf->rect_float);
 	}
 	else {
-		unsigned int *rect;
+		unsigned char *display_buffer;
+		void *cache_handle;
 
 		if (sima->flag & SI_USE_ALPHA) {
 			fdrawcheckerboard(x, y, x + ibuf->x * zoomx, y + ibuf->y * zoomy);
@@ -459,17 +459,19 @@
 
 		/* we don't draw floats buffers directly but
 		 * convert them, and optionally apply curves */
-		image_verify_buffer_float(ima, ibuf, color_manage, sima->view_transform);
+		image_verify_buffer_float(ima, ibuf, color_manage);
 
-		rect = imb_getrectviewImBuf(ibuf, sima->view_transform);
+		display_buffer = IMB_display_buffer_acquire(ibuf, sima->view_transform, win->display_device, &cache_handle);
 
-		if (rect)
-			glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, rect);
+		if (display_buffer)
+			glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, display_buffer);
 #if 0
 		else
 			glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_FLOAT, ibuf->rect_float);
 #endif
-		
+
+		IMB_display_buffer_release(cache_handle);
+
 		if (sima->flag & SI_USE_ALPHA)
 			glDisable(GL_BLEND);
 	}
@@ -478,15 +480,14 @@
 	glPixelZoom(1.0f, 1.0f);
 }
 
-static unsigned int *get_part_from_ibuf(ImBuf *ibuf, short startx, short starty, short endx, short endy, int view_transform)
+static unsigned int *get_part_from_ibuf(ImBuf *ibuf, short startx, short starty, short endx, short endy)
 {
 	unsigned int *rt, *rp, *rectmain;
 	short y, heigth, len;
-	unsigned int *rect = imb_getrectviewImBuf(ibuf, view_transform);
 

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list