[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [36293] trunk/blender/source/blender/ editors: Color info in node editor backdrop now supports color management.

Lukas Toenne lukas.toenne at googlemail.com
Sat Apr 23 10:30:29 CEST 2011


Revision: 36293
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=36293
Author:   lukastoenne
Date:     2011-04-23 08:30:28 +0000 (Sat, 23 Apr 2011)
Log Message:
-----------
Color info in node editor backdrop now supports color management.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/space_image/image_draw.c
    trunk/blender/source/blender/editors/space_image/image_intern.h
    trunk/blender/source/blender/editors/space_image/image_ops.c
    trunk/blender/source/blender/editors/space_node/drawnode.c
    trunk/blender/source/blender/editors/space_node/node_edit.c
    trunk/blender/source/blender/editors/space_node/node_intern.h

Modified: trunk/blender/source/blender/editors/space_image/image_draw.c
===================================================================
--- trunk/blender/source/blender/editors/space_image/image_draw.c	2011-04-23 08:02:29 UTC (rev 36292)
+++ trunk/blender/source/blender/editors/space_image/image_draw.c	2011-04-23 08:30:28 UTC (rev 36293)
@@ -45,7 +45,7 @@
 
 #include "PIL_time.h"
 
-#include "BLI_math_color.h"
+#include "BLI_math.h"
 #include "BLI_threads.h"
 #include "BLI_string.h"
 #include "BLI_utildefines.h"
@@ -133,7 +133,7 @@
 	BKE_image_release_renderresult(scene, ima);
 }
 
-void draw_image_info(ARegion *ar, int channels, int x, int y, char *cp, float *fp, int *zp, float *zpf)
+void draw_image_info(ARegion *ar, int color_manage, int channels, int x, int y, char *cp, float *fp, int *zp, float *zpf)
 {
 	char str[256];
 	float dx= 6;
@@ -149,6 +149,7 @@
 	unsigned char blue[3] = {255, 255, 255};
 	#endif
 	float hue=0, sat=0, val=0, lum=0, u=0, v=0;
+	float col[4], finalcol[4];
 
 	glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
 	glEnable(GL_BLEND);
@@ -230,31 +231,47 @@
 		}
 	}
 	
-	glDisable(GL_BLEND);
+	/* color rectangle */
 	if (channels==1) {
 		if (fp)
-			glColor3f(fp[0], fp[0], fp[0]);
+			col[0] = col[1] = col[2] = fp[0];
 		else if (cp)
-			glColor3ub(cp[0], cp[0], cp[0]);
+			col[0] = col[1] = col[2] = (float)cp[0]/255.0f;
 		else
-			glColor3ub(0, 0, 0);
+			col[0] = col[1] = col[2] = 0.0f;
 	}
 	else if (channels==3) {
 		if (fp)
-			glColor3fv(fp);
-		else if (cp)
-			glColor3ub(cp[0], cp[1], cp[2]);
+			copy_v3_v3(col, fp);
+		else if (cp) {
+			col[0] = (float)cp[0]/255.0f;
+			col[1] = (float)cp[1]/255.0f;
+			col[2] = (float)cp[2]/255.0f;
+		}
 		else
-			glColor3ub(0, 0, 0);
+			zero_v3(col);
 	}
 	else if (channels==4) {
 		if (fp)
-			glColor4fv(fp);
-		else if (cp)
-			glColor4ub(cp[0], cp[1], cp[2], cp[3]);
+			copy_v4_v4(col, fp);
+		else if (cp) {
+			col[0] = (float)cp[0]/255.0f;
+			col[1] = (float)cp[1]/255.0f;
+			col[2] = (float)cp[2]/255.0f;
+			col[3] = (float)cp[3]/255.0f;
+		}
 		else
-			glColor3ub(0, 0, 0);
+			zero_v4(col);
 	}
+	if (color_manage) {
+		linearrgb_to_srgb_v3_v3(finalcol, col);
+		finalcol[3] = col[3];
+	}
+	else {
+		copy_v4_v4(finalcol, col);
+	}
+	glDisable(GL_BLEND);
+	glColor3fv(finalcol);
 	dx += 5;
 	glBegin(GL_QUADS);
 	glVertex2f(dx, 3);

Modified: trunk/blender/source/blender/editors/space_image/image_intern.h
===================================================================
--- trunk/blender/source/blender/editors/space_image/image_intern.h	2011-04-23 08:02:29 UTC (rev 36292)
+++ trunk/blender/source/blender/editors/space_image/image_intern.h	2011-04-23 08:30:28 UTC (rev 36293)
@@ -60,7 +60,7 @@
 
 /* image_draw.c */
 void draw_image_main(struct SpaceImage *sima, struct ARegion *ar, struct Scene *scene);
-void draw_image_info(struct ARegion *ar, int channels, int x, int y, char *cp, float *fp, int *zp, float *zpf);
+void draw_image_info(struct ARegion *ar, int color_manage, int channels, int x, int y, char *cp, float *fp, int *zp, float *zpf);
 void draw_image_grease_pencil(struct bContext *C, short onlyv2d);
 
 /* image_ops.c */

Modified: trunk/blender/source/blender/editors/space_image/image_ops.c
===================================================================
--- trunk/blender/source/blender/editors/space_image/image_ops.c	2011-04-23 08:02:29 UTC (rev 36292)
+++ trunk/blender/source/blender/editors/space_image/image_ops.c	2011-04-23 08:30:28 UTC (rev 36293)
@@ -1632,7 +1632,8 @@
 {
 	ImageSampleInfo *info= arg_info;
 	if(info->draw) {
-		draw_image_info(ar, info->channels, info->x, info->y, info->colp, info->colfp, info->zp, info->zfp);
+		/* no color management needed for images (color_manage=0) */
+		draw_image_info(ar, 0, info->channels, info->x, info->y, info->colp, info->colfp, info->zp, info->zfp);
 	}
 }
 

Modified: trunk/blender/source/blender/editors/space_node/drawnode.c
===================================================================
--- trunk/blender/source/blender/editors/space_node/drawnode.c	2011-04-23 08:02:29 UTC (rev 36292)
+++ trunk/blender/source/blender/editors/space_node/drawnode.c	2011-04-23 08:30:28 UTC (rev 36293)
@@ -1442,7 +1442,7 @@
 	}
 }
 
-void draw_nodespace_color_info(ARegion *ar, int channels, int x, int y, char *cp, float *fp)
+void draw_nodespace_color_info(ARegion *ar, int color_manage, int channels, int x, int y, char *cp, float *fp)
 {
 	char str[256];
 	float dx= 6;
@@ -1458,6 +1458,7 @@
 	unsigned char blue[3] = {255, 255, 255};
 	#endif
 	float hue=0, sat=0, val=0, lum=0, u=0, v=0;
+	float col[4], finalcol[4];
 
 	glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
 	glEnable(GL_BLEND);
@@ -1541,31 +1542,47 @@
 		}
 	}
 	
-	glDisable(GL_BLEND);
+	/* color rectangle */
 	if (channels==1) {
 		if (fp)
-			glColor3f(fp[0], fp[0], fp[0]);
+			col[0] = col[1] = col[2] = fp[0];
 		else if (cp)
-			glColor3ub(cp[0], cp[0], cp[0]);
+			col[0] = col[1] = col[2] = (float)cp[0]/255.0f;
 		else
-			glColor3ub(0, 0, 0);
+			col[0] = col[1] = col[2] = 0.0f;
 	}
 	else if (channels==3) {
 		if (fp)
-			glColor3fv(fp);
-		else if (cp)
-			glColor3ub(cp[0], cp[1], cp[2]);
+			copy_v3_v3(col, fp);
+		else if (cp) {
+			col[0] = (float)cp[0]/255.0f;
+			col[1] = (float)cp[1]/255.0f;
+			col[2] = (float)cp[2]/255.0f;
+		}
 		else
-			glColor3ub(0, 0, 0);
+			zero_v3(col);
 	}
 	else if (channels==4) {
 		if (fp)
-			glColor4fv(fp);
-		else if (cp)
-			glColor4ub(cp[0], cp[1], cp[2], cp[3]);
+			copy_v4_v4(col, fp);
+		else if (cp) {
+			col[0] = (float)cp[0]/255.0f;
+			col[1] = (float)cp[1]/255.0f;
+			col[2] = (float)cp[2]/255.0f;
+			col[3] = (float)cp[3]/255.0f;
+		}
 		else
-			glColor3ub(0, 0, 0);
+			zero_v4(col);
 	}
+	if (color_manage) {
+		linearrgb_to_srgb_v3_v3(finalcol, col);
+		finalcol[3] = col[3];
+	}
+	else {
+		copy_v4_v4(finalcol, col);
+	}
+	glDisable(GL_BLEND);
+	glColor3fv(finalcol);
 	dx += 5;
 	glBegin(GL_QUADS);
 	glVertex2f(dx, 3);

Modified: trunk/blender/source/blender/editors/space_node/node_edit.c
===================================================================
--- trunk/blender/source/blender/editors/space_node/node_edit.c	2011-04-23 08:02:29 UTC (rev 36292)
+++ trunk/blender/source/blender/editors/space_node/node_edit.c	2011-04-23 08:30:28 UTC (rev 36293)
@@ -1142,11 +1142,12 @@
 	int draw;
 } ImageSampleInfo;
 
-static void sample_draw(const bContext *UNUSED(C), ARegion *ar, void *arg_info)
+static void sample_draw(const bContext *C, ARegion *ar, void *arg_info)
 {
 	ImageSampleInfo *info= arg_info;
 
-	draw_nodespace_color_info(ar, info->channels, info->x, info->y, info->col, info->colf);
+	draw_nodespace_color_info(ar, (CTX_data_scene(C)->r.color_mgt_flag & R_COLOR_MANAGEMENT), info->channels,
+							  info->x, info->y, info->col, info->colf);
 }
 
 static void sample_apply(bContext *C, wmOperator *op, wmEvent *event)

Modified: trunk/blender/source/blender/editors/space_node/node_intern.h
===================================================================
--- trunk/blender/source/blender/editors/space_node/node_intern.h	2011-04-23 08:02:29 UTC (rev 36292)
+++ trunk/blender/source/blender/editors/space_node/node_intern.h	2011-04-23 08:30:28 UTC (rev 36293)
@@ -90,7 +90,7 @@
 void node_draw_link_bezier(View2D *v2d, SpaceNode *snode, bNodeLink *link, int th_col1, int do_shaded, int th_col2, int do_triple, int th_col3 );
 int node_link_bezier_points(View2D *v2d, SpaceNode *snode, bNodeLink *link, float coord_array[][2], int resol);
 void draw_nodespace_back_pix(ARegion *ar, SpaceNode *snode, int color_manage);
-void draw_nodespace_color_info(ARegion *ar, int channels, int x, int y, char *cp, float *fp);
+void draw_nodespace_color_info(struct ARegion *ar, int color_manage, int channels, int x, int y, char *cp, float *fp);
 
 /* node_edit.c */
 void node_tree_from_ID(ID *id, bNodeTree **ntree, bNodeTree **edittree, int *treetype);




More information about the Bf-blender-cvs mailing list