[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [48582] branches/soc-2012-swiss_cheese/ source/blender/editors: GPU Safety Fixes: Not locking in drawnode.c ( probably not a complete fix)

Jason Wilkins Jason.A.Wilkins at gmail.com
Wed Jul 4 11:41:58 CEST 2012


Revision: 48582
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=48582
Author:   jwilkins
Date:     2012-07-04 09:41:57 +0000 (Wed, 04 Jul 2012)
Log Message:
-----------
GPU Safety Fixes: Not locking in drawnode.c (probably not a complete fix)

Modified Paths:
--------------
    branches/soc-2012-swiss_cheese/source/blender/editors/include/UI_resources.h
    branches/soc-2012-swiss_cheese/source/blender/editors/interface/resources.c
    branches/soc-2012-swiss_cheese/source/blender/editors/space_node/drawnode.c
    branches/soc-2012-swiss_cheese/source/blender/editors/space_node/node_draw.c

Modified: branches/soc-2012-swiss_cheese/source/blender/editors/include/UI_resources.h
===================================================================
--- branches/soc-2012-swiss_cheese/source/blender/editors/include/UI_resources.h	2012-07-04 09:08:05 UTC (rev 48581)
+++ branches/soc-2012-swiss_cheese/source/blender/editors/include/UI_resources.h	2012-07-04 09:41:57 UTC (rev 48582)
@@ -238,6 +238,7 @@
 
 // sets color plus offset for alpha
 void    UI_ThemeColorShadeAlpha(int colorid, int coloffset, int alphaoffset);
+void    UI_ThemeAppendColorShadeAlpha(int colorid, int coloffset, int alphaoffset);
 
 // sets color, which is blend between two theme colors
 void    UI_ThemeColorBlend(int colorid1, int colorid2, float fac);

Modified: branches/soc-2012-swiss_cheese/source/blender/editors/interface/resources.c
===================================================================
--- branches/soc-2012-swiss_cheese/source/blender/editors/interface/resources.c	2012-07-04 09:08:05 UTC (rev 48581)
+++ branches/soc-2012-swiss_cheese/source/blender/editors/interface/resources.c	2012-07-04 09:41:57 UTC (rev 48582)
@@ -1030,6 +1030,23 @@
 	gpuCurrentColor4ub(r, g, b, a);
 }
 
+void UI_ThemeAppendColorShadeAlpha(int colorid, int coloffset, int alphaoffset)
+{
+	int r, g, b, a;
+	const unsigned char *cp;
+	
+	cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
+	r = coloffset + (int) cp[0];
+	CLAMP(r, 0, 255);
+	g = coloffset + (int) cp[1];
+	CLAMP(g, 0, 255);
+	b = coloffset + (int) cp[2];
+	CLAMP(b, 0, 255);
+	a = alphaoffset + (int) cp[3];
+	CLAMP(a, 0, 255);
+	gpuColor4ub(r, g, b, a);
+}
+
 // blend between to theme colors, and set it
 void UI_ThemeColorBlend(int colorid1, int colorid2, float fac)
 {

Modified: branches/soc-2012-swiss_cheese/source/blender/editors/space_node/drawnode.c
===================================================================
--- branches/soc-2012-swiss_cheese/source/blender/editors/space_node/drawnode.c	2012-07-04 09:08:05 UTC (rev 48581)
+++ branches/soc-2012-swiss_cheese/source/blender/editors/space_node/drawnode.c	2012-07-04 09:41:57 UTC (rev 48582)
@@ -3147,7 +3147,9 @@
 		dist = 1.0f/(float)LINK_RESOL;
 		
 		glEnable(GL_LINE_SMOOTH);
-		
+
+		gpuImmediateFormat_V2();
+
 		drawarrow = (link->tonode && (link->tonode->type == NODE_REROUTE)) && (link->fromnode && (link->fromnode->type == NODE_REROUTE));
 		if (drawarrow) {
 			// draw arrow in line segment LINK_ARROW
@@ -3167,11 +3169,13 @@
 		if (do_triple) {
 			UI_ThemeColorShadeAlpha(th_col3, -80, -120);
 			glLineWidth(4.0f);
-			
+
 			gpuBegin(GL_LINE_STRIP);
+
 			for (i=0; i<=LINK_RESOL; i++) {
 				gpuVertex2fv(coord_array[i]);
 			}
+
 			gpuEnd();
 
 			if (drawarrow) {
@@ -3192,10 +3196,10 @@
 		if (do_shaded) {
 			gpuBegin(GL_LINES);
 			for (i=0; i<LINK_RESOL; i++) {
-				UI_ThemeColorBlend(th_col1, th_col2, spline_step);
+				UI_ThemeAppendColorBlend(th_col1, th_col2, spline_step);
 				gpuVertex2fv(coord_array[i]);
 				
-				UI_ThemeColorBlend(th_col1, th_col2, spline_step+dist);
+				UI_ThemeAppendColorBlend(th_col1, th_col2, spline_step+dist);
 				gpuVertex2fv(coord_array[i+1]);
 				
 				spline_step += dist;
@@ -3224,6 +3228,8 @@
 		
 		/* restore previuos linewidth */
 		glLineWidth(linew);
+
+		gpuImmediateUnformat();
 	}
 }
 

Modified: branches/soc-2012-swiss_cheese/source/blender/editors/space_node/node_draw.c
===================================================================
--- branches/soc-2012-swiss_cheese/source/blender/editors/space_node/node_draw.c	2012-07-04 09:08:05 UTC (rev 48581)
+++ branches/soc-2012-swiss_cheese/source/blender/editors/space_node/node_draw.c	2012-07-04 09:41:57 UTC (rev 48582)
@@ -585,7 +585,7 @@
 		glLineWidth(1.5f);
 	}
 	else {
-		gpuColor4x(CPACK_BLACK, 0.588f);
+		gpuCurrentColor4x(CPACK_BLACK, 0.588f);
 	}
 	glEnable(GL_BLEND);
 	glEnable(GL_LINE_SMOOTH);
@@ -826,29 +826,32 @@
 	if (node->flag & NODE_MUTED)
 		node_draw_mute_line(v2d, snode, node);
 
-	
+	gpuImmediateFormat_C4_V2();
+
 	/* socket inputs, buttons */
 	for (sock= node->inputs.first; sock; sock= sock->next) {
 		if (nodeSocketIsHidden(sock))
 			continue;
-		
+
 		node_socket_circle_draw(ntree, sock, NODE_SOCKSIZE, sock->flag & SELECT);
 		
 		node->typeinfo->drawinputfunc(C, node->block, ntree, node, sock, IFACE_(sock->name),
 		                              sock->locx+NODE_DYS, sock->locy-NODE_DYS, node->width-NODE_DY);
 	}
-	
+
 	/* socket outputs */
 	for (sock= node->outputs.first; sock; sock= sock->next) {
 		if (nodeSocketIsHidden(sock))
 			continue;
-		
+
 		node_socket_circle_draw(ntree, sock, NODE_SOCKSIZE, sock->flag & SELECT);
 		
 		node->typeinfo->drawoutputfunc(C, node->block, ntree, node, sock, IFACE_(sock->name),
 		                               sock->locx-node->width+NODE_DYS, sock->locy-NODE_DYS, node->width-NODE_DY);
 	}
-	
+
+	gpuImmediateUnformat();
+
 	/* preview */
 	if (node->flag & NODE_PREVIEW) {
 		BLI_lock_thread(LOCK_PREVIEW);




More information about the Bf-blender-cvs mailing list