[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [50508] branches/soc-2011-tomato/source/ blender: Color Management: port image stamp to new color management system

Sergey Sharybin sergey.vfx at gmail.com
Mon Sep 10 19:24:48 CEST 2012


Revision: 50508
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=50508
Author:   nazgul
Date:     2012-09-10 17:24:48 +0000 (Mon, 10 Sep 2012)
Log Message:
-----------
Color Management: port image stamp to new color management system

Use the same approach as interface does by using default view which
is supposed to be invertible to convert color from display space to
scene linear.

Modified Paths:
--------------
    branches/soc-2011-tomato/source/blender/blenfont/BLF_api.h
    branches/soc-2011-tomato/source/blender/blenfont/CMakeLists.txt
    branches/soc-2011-tomato/source/blender/blenfont/SConscript
    branches/soc-2011-tomato/source/blender/blenfont/intern/blf.c
    branches/soc-2011-tomato/source/blender/blenfont/intern/blf_font.c
    branches/soc-2011-tomato/source/blender/blenfont/intern/blf_internal_types.h
    branches/soc-2011-tomato/source/blender/blenkernel/intern/image.c
    branches/soc-2011-tomato/source/blender/blenkernel/intern/image_gen.c
    branches/soc-2011-tomato/source/blender/imbuf/IMB_imbuf.h
    branches/soc-2011-tomato/source/blender/imbuf/intern/rectop.c

Modified: branches/soc-2011-tomato/source/blender/blenfont/BLF_api.h
===================================================================
--- branches/soc-2011-tomato/source/blender/blenfont/BLF_api.h	2012-09-10 16:30:15 UTC (rev 50507)
+++ branches/soc-2011-tomato/source/blender/blenfont/BLF_api.h	2012-09-10 17:24:48 UTC (rev 50508)
@@ -33,6 +33,7 @@
 #define __BLF_API_H__
 
 struct rctf;
+struct ColorManagedDisplay;
 
 int BLF_init(int points, int dpi);
 void BLF_exit(void);
@@ -151,7 +152,7 @@
  *
  *     BLF_buffer(NULL, NULL, 0, 0, 0, FALSE);
  */
-void BLF_buffer(int fontid, float *fbuf, unsigned char *cbuf, int w, int h, int nch, int do_color_management);
+void BLF_buffer(int fontid, float *fbuf, unsigned char *cbuf, int w, int h, int nch, struct ColorManagedDisplay *display);
 
 /* Set the color to be used for text. */
 void BLF_buffer_col(int fontid, float r, float g, float b, float a);

Modified: branches/soc-2011-tomato/source/blender/blenfont/CMakeLists.txt
===================================================================
--- branches/soc-2011-tomato/source/blender/blenfont/CMakeLists.txt	2012-09-10 16:30:15 UTC (rev 50507)
+++ branches/soc-2011-tomato/source/blender/blenfont/CMakeLists.txt	2012-09-10 17:24:48 UTC (rev 50508)
@@ -27,6 +27,7 @@
 	../blenlib
 	../editors/include
 	../makesdna
+	../imbuf
 	../../../intern/guardedalloc
 )
 

Modified: branches/soc-2011-tomato/source/blender/blenfont/SConscript
===================================================================
--- branches/soc-2011-tomato/source/blender/blenfont/SConscript	2012-09-10 16:30:15 UTC (rev 50507)
+++ branches/soc-2011-tomato/source/blender/blenfont/SConscript	2012-09-10 17:24:48 UTC (rev 50508)
@@ -4,7 +4,7 @@
 
 sources = env.Glob('intern/*.c')
 
-incs = '. intern  #/intern/guardedalloc ../blenkernel ../blenlib ../makesdna ../editors/include'
+incs = '. intern  #/intern/guardedalloc ../blenkernel ../blenlib ../makesdna ,,/imbuf ../editors/include'
 incs += ' #/extern/glew/include'
 incs += ' ' + env['BF_FREETYPE_INC']
 incs += ' ' + env['BF_GETTEXT_INC']

Modified: branches/soc-2011-tomato/source/blender/blenfont/intern/blf.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenfont/intern/blf.c	2012-09-10 16:30:15 UTC (rev 50507)
+++ branches/soc-2011-tomato/source/blender/blenfont/intern/blf.c	2012-09-10 17:24:48 UTC (rev 50508)
@@ -50,7 +50,6 @@
 #include "blf_internal_types.h"
 #include "blf_internal.h"
 
-
 /* Max number of font in memory.
  * Take care that now every font have a glyph cache per size/dpi,
  * so we don't need load the same font with different size, just
@@ -746,7 +745,7 @@
 	}
 }
 
-void BLF_buffer(int fontid, float *fbuf, unsigned char *cbuf, int w, int h, int nch, int do_color_management)
+void BLF_buffer(int fontid, float *fbuf, unsigned char *cbuf, int w, int h, int nch, struct ColorManagedDisplay *display)
 {
 	FontBLF *font = BLF_get(fontid);
 
@@ -756,7 +755,7 @@
 		font->buf_info.w = w;
 		font->buf_info.h = h;
 		font->buf_info.ch = nch;
-		font->buf_info.do_color_management = do_color_management;
+		font->buf_info.display = display;
 	}
 }
 

Modified: branches/soc-2011-tomato/source/blender/blenfont/intern/blf_font.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenfont/intern/blf_font.c	2012-09-10 16:30:15 UTC (rev 50507)
+++ branches/soc-2011-tomato/source/blender/blenfont/intern/blf_font.c	2012-09-10 17:24:48 UTC (rev 50508)
@@ -53,6 +53,8 @@
 #include "BIF_gl.h"
 #include "BLF_api.h"
 
+#include "IMB_colormanagement.h"
+
 #include "blf_internal_types.h"
 #include "blf_internal.h"
 
@@ -245,11 +247,12 @@
 	blf_font_ensure_ascii_table(font);
 
 	/* another buffer specific call for color conversion */
-	if (buf_info->do_color_management) {
-		srgb_to_linearrgb_v4(b_col_float, buf_info->col);
+	if (buf_info->display) {
+		copy_v4_v4(b_col_float, buf_info->col);
+		IMB_colormanagement_display_to_scene_linear_v3(b_col_float, buf_info->display);
 	}
 	else {
-		copy_v4_v4(b_col_float, buf_info->col);
+		srgb_to_linearrgb_v4(b_col_float, buf_info->col);
 	}
 
 	while (str[i]) {

Modified: branches/soc-2011-tomato/source/blender/blenfont/intern/blf_internal_types.h
===================================================================
--- branches/soc-2011-tomato/source/blender/blenfont/intern/blf_internal_types.h	2012-09-10 16:30:15 UTC (rev 50507)
+++ branches/soc-2011-tomato/source/blender/blenfont/intern/blf_internal_types.h	2012-09-10 17:24:48 UTC (rev 50508)
@@ -145,8 +145,8 @@
 	/* number of channels. */
 	int ch;
 
-	/* is the float buffer linear */
-	int do_color_management;
+	/* display device used for color management */
+	struct ColorManagedDisplay *display;
 
 	/* and the color, the alphas is get from the glyph!
 	 * color is srgb space */

Modified: branches/soc-2011-tomato/source/blender/blenkernel/intern/image.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/intern/image.c	2012-09-10 16:30:15 UTC (rev 50507)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/image.c	2012-09-10 17:24:48 UTC (rev 50508)
@@ -1505,19 +1505,21 @@
 	int x, y, y_ofs;
 	float h_fixed;
 	const int mono = blf_mono_font_render; // XXX
+	struct ColorManagedDisplay *display;
+	const char *display_device;
 
 	/* this could be an argument if we want to operate on non linear float imbuf's
 	 * for now though this is only used for renders which use scene settings */
 
-	/* OCIO_TODO: for now harcode sRGB to linearrgb conversion, need to be fixed ASAP */
-	const int do_color_management = TRUE;
-
 #define BUFF_MARGIN_X 2
 #define BUFF_MARGIN_Y 1
 
 	if (!rect && !rectf)
 		return;
 
+	display_device = scene->display_settings.display_device;
+	display = IMB_colormanagement_display_get_named(display_device);
+
 	stampdata(scene, camera, &stamp_data, 1);
 
 	/* TODO, do_versions */
@@ -1527,7 +1529,7 @@
 	/* set before return */
 	BLF_size(mono, scene->r.stamp_font_id, 72);
 
-	BLF_buffer(mono, rectf, rect, width, height, channels, do_color_management);
+	BLF_buffer(mono, rectf, rect, width, height, channels, display);
 	BLF_buffer_col(mono, scene->r.fg_stamp[0], scene->r.fg_stamp[1], scene->r.fg_stamp[2], 1.0);
 	pad = BLF_width_max(mono);
 
@@ -1544,7 +1546,7 @@
 		y -= h;
 
 		/* also a little of space to the background. */
-		buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, do_color_management,
+		buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, display,
 						  x - BUFF_MARGIN_X, y - BUFF_MARGIN_Y, w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y);
 
 		/* and draw the text. */
@@ -1561,7 +1563,7 @@
 		y -= h;
 
 		/* and space for background. */
-		buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, do_color_management,
+		buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, display,
 						  0, y - BUFF_MARGIN_Y, w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y);
 
 		BLF_position(mono, x, y + y_ofs, 0.0);
@@ -1577,7 +1579,7 @@
 		y -= h;
 
 		/* and space for background. */
-		buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, do_color_management,
+		buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, display,
 						  0, y - BUFF_MARGIN_Y, w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y);
 
 		BLF_position(mono, x, y + y_ofs, 0.0);
@@ -1593,7 +1595,7 @@
 		y -= h;
 
 		/* and space for background. */
-		buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, do_color_management,
+		buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, display,
 						  0, y - BUFF_MARGIN_Y, w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y);
 
 		BLF_position(mono, x, y + y_ofs, 0.0);
@@ -1608,7 +1610,7 @@
 		BLF_width_and_height(mono, stamp_data.marker, &w, &h); h = h_fixed;
 
 		/* extra space for background. */
-		buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp,  do_color_management,
+		buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp,  display,
 						  x - BUFF_MARGIN_X, y - BUFF_MARGIN_Y, w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y);
 
 		/* and pad the text. */
@@ -1624,7 +1626,7 @@
 		BLF_width_and_height(mono, stamp_data.time, &w, &h); h = h_fixed;
 
 		/* extra space for background */
-		buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, do_color_management,
+		buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, display,
 						  x - BUFF_MARGIN_X, y, x + w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y);
 
 		/* and pad the text. */
@@ -1639,7 +1641,7 @@
 		BLF_width_and_height(mono, stamp_data.frame, &w, &h); h = h_fixed;
 
 		/* extra space for background. */
-		buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, do_color_management,
+		buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, display,
 						  x - BUFF_MARGIN_X, y - BUFF_MARGIN_Y, x + w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y);
 
 		/* and pad the text. */
@@ -1654,7 +1656,7 @@
 		BLF_width_and_height(mono, stamp_data.camera, &w, &h); h = h_fixed;
 
 		/* extra space for background. */
-		buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, do_color_management,
+		buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, display,
 						  x - BUFF_MARGIN_X, y - BUFF_MARGIN_Y, x + w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y);
 		BLF_position(mono, x, y + y_ofs, 0.0);
 		BLF_draw_buffer(mono, stamp_data.camera);
@@ -1667,7 +1669,7 @@
 		BLF_width_and_height(mono, stamp_data.cameralens, &w, &h); h = h_fixed;
 
 		/* extra space for background. */
-		buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, do_color_management,
+		buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, display,
 						  x - BUFF_MARGIN_X, y - BUFF_MARGIN_Y, x + w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y);
 		BLF_position(mono, x, y + y_ofs, 0.0);
 		BLF_draw_buffer(mono, stamp_data.cameralens);
@@ -1680,7 +1682,7 @@
 		x = width - w - 2;
 
 		/* extra space for background. */
-		buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, do_color_management,
+		buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, display,
 						  x - BUFF_MARGIN_X, y - BUFF_MARGIN_Y, x + w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y);
 
 		/* and pad the text. */
@@ -1696,7 +1698,7 @@
 		y = height - h;
 
 		/* extra space for background. */

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list