[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [50507] branches/soc-2011-tomato/source/ blender/editors/interface: Color Management: resolve TODOs related on HSV widgets

Sergey Sharybin sergey.vfx at gmail.com
Mon Sep 10 18:30:15 CEST 2012


Revision: 50507
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=50507
Author:   nazgul
Date:     2012-09-10 16:30:15 +0000 (Mon, 10 Sep 2012)
Log Message:
-----------
Color Management: resolve TODOs related on HSV widgets

Modified Paths:
--------------
    branches/soc-2011-tomato/source/blender/editors/interface/interface_handlers.c
    branches/soc-2011-tomato/source/blender/editors/interface/interface_widgets.c

Modified: branches/soc-2011-tomato/source/blender/editors/interface/interface_handlers.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/interface/interface_handlers.c	2012-09-10 14:47:47 UTC (rev 50506)
+++ branches/soc-2011-tomato/source/blender/editors/interface/interface_handlers.c	2012-09-10 16:30:15 UTC (rev 50507)
@@ -3163,9 +3163,11 @@
 
 	ui_get_but_vectorf(but, rgb);
 
+	if (color_profile && (int)but->a1)
+		ui_block_to_display_space_v3(but->block, rgb);
+
 	rgb_to_hsv_compat_v(rgb, hsv);
 
-
 	/* relative position within box */
 	x = ((float)mx_fl - but->rect.xmin) / BLI_RCT_SIZE_X(&but->rect);
 	y = ((float)my_fl - but->rect.ymin) / BLI_RCT_SIZE_Y(&but->rect);
@@ -3200,19 +3202,16 @@
 			/* exception only for value strip - use the range set in but->min/max */
 			hsv[2] = y * (but->softmax - but->softmin) + but->softmin;
 
-			if (color_profile) {
-				/* OCIO_TODO: how to handle this situation? */
-				hsv[2] = srgb_to_linearrgb(hsv[2]);
-			}
-
-			if (hsv[2] > but->softmax)
-				hsv[2] = but->softmax;
 			break;
 		default:
 			assert(!"invalid hsv type");
 	}
 
 	hsv_to_rgb_v(hsv, rgb);
+
+	if (color_profile && (int)but->a1)
+		ui_block_to_scene_linear_v3(but->block, rgb);
+
 	copy_v3_v3(data->vec, rgb);
 
 	data->draglastx = mx;
@@ -3235,6 +3234,10 @@
 	}
 
 	ui_get_but_vectorf(but, rgb);
+
+	if (color_profile && (int)but->a1)
+		ui_block_to_display_space_v3(but->block, rgb);
+
 	rgb_to_hsv_compat_v(rgb, hsv);
 	
 	switch ((int)but->a1) {
@@ -3265,17 +3268,16 @@
 			/* exception only for value strip - use the range set in but->min/max */
 			hsv[2] += ndof->rx * sensitivity;
 			
-			if (color_profile) {
-				/* OCIO_TODO: how to handle this situation? */
-				hsv[2] = srgb_to_linearrgb(hsv[2]);
-			}
-			
 			CLAMP(hsv[2], but->softmin, but->softmax);
 		default:
 			assert(!"invalid hsv type");
 	}
-	
+
 	hsv_to_rgb_v(hsv, rgb);
+
+	if (color_profile && (int)but->a1)
+		ui_block_to_scene_linear_v3(but->block, rgb);
+
 	copy_v3_v3(data->vec, rgb);
 	ui_set_but_vectorf(but, data->vec);
 }

Modified: branches/soc-2011-tomato/source/blender/editors/interface/interface_widgets.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/interface/interface_widgets.c	2012-09-10 14:47:47 UTC (rev 50506)
+++ branches/soc-2011-tomato/source/blender/editors/interface/interface_widgets.c	2012-09-10 16:30:15 UTC (rev 50507)
@@ -1885,19 +1885,20 @@
 	
 	/* color */
 	ui_get_but_vectorf(but, rgb);
-	copy_v3_v3(hsv, ui_block_hsv_get(but->block));
+	/* copy_v3_v3(hsv, ui_block_hsv_get(but->block)); */ /* UNUSED */
+
+	rgb_to_hsv_compat_v(rgb, hsvo);
+
+	if (color_profile)
+		ui_block_to_display_space_v3(but->block, rgb);
+
 	rgb_to_hsv_compat_v(rgb, hsv);
-	copy_v3_v3(hsvo, hsv);
 	
 	/* exception: if 'lock' is set
 	 * lock the value of the color wheel to 1.
 	 * Useful for color correction tools where you're only interested in hue. */
 	if (but->flag & UI_BUT_COLOR_LOCK)
 		hsv[2] = 1.f;
-	else if (color_profile) {
-		/* OCIO_TODO: how to handle this situation? */
-		hsv[2] = linearrgb_to_srgb(hsv[2]);
-	}
 	
 	hsv_to_rgb(0.f, 0.f, hsv[2], colcent, colcent + 1, colcent + 2);
 	
@@ -2142,14 +2143,13 @@
 		color_profile = FALSE;
 
 	ui_get_but_vectorf(but, rgb);
+
+	if (color_profile)
+		ui_block_to_display_space_v3(but->block, rgb);
+
 	rgb_to_hsv_v(rgb, hsv);
 	v = hsv[2];
 	
-	if (color_profile) {
-		/* OCIO_TODO: how to handle this situation? */
-		v = linearrgb_to_srgb(v);
-	}
-
 	/* map v from property range to [0,1] */
 	range = but->softmax - but->softmin;
 	v = (v - but->softmin) / range;




More information about the Bf-blender-cvs mailing list