[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [24030] trunk/blender/source/blender/ editors/space_graph/graph_draw.c: Graph Editor: Small optimisations for drawing

Joshua Leung aligorith at gmail.com
Wed Oct 21 01:51:31 CEST 2009


Revision: 24030
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=24030
Author:   aligorith
Date:     2009-10-21 01:51:31 +0200 (Wed, 21 Oct 2009)

Log Message:
-----------
Graph Editor: Small optimisations for drawing

Moving out a few gl state changes to higher-level calls to improve performance when drawing handles. This already improves the responsiveness a lot on a few files, though a few other tweaks will also help.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/space_graph/graph_draw.c

Modified: trunk/blender/source/blender/editors/space_graph/graph_draw.c
===================================================================
--- trunk/blender/source/blender/editors/space_graph/graph_draw.c	2009-10-20 23:18:00 UTC (rev 24029)
+++ trunk/blender/source/blender/editors/space_graph/graph_draw.c	2009-10-20 23:51:31 UTC (rev 24030)
@@ -202,7 +202,10 @@
 }
 
 
-/* helper func - draw handle vertex for an F-Curve as a round unfilled circle */
+/* helper func - draw handle vertex for an F-Curve as a round unfilled circle 
+ * NOTE: the caller MUST HAVE GL_LINE_SMOOTH & GL_BLEND ENABLED, otherwise, the controls don't 
+ * have a consistent appearance (due to off-pixel alignments)...
+ */
 static void draw_fcurve_handle_control (float x, float y, float xscale, float yscale, float hsize)
 {
 	static GLuint displist=0;
@@ -226,16 +229,9 @@
 	glTranslatef(x, y, 0.0f);
 	glScalef(1.0f/xscale*hsize, 1.0f/yscale*hsize, 1.0f);
 	
-	/* anti-aliased lines for more consistent appearance */
-	glEnable(GL_LINE_SMOOTH);
-	glEnable(GL_BLEND);
-	
 	/* draw! */
 	glCallList(displist);
 	
-	glDisable(GL_LINE_SMOOTH);
-	glDisable(GL_BLEND);
-	
 	/* restore view transform */
 	glScalef(xscale/hsize, yscale/hsize, 1.0);
 	glTranslatef(-x, -y, 0.0f);
@@ -257,6 +253,10 @@
 	if (sel) UI_ThemeColor(TH_HANDLE_VERTEX_SELECT);
 	else UI_ThemeColor(TH_HANDLE_VERTEX);
 	
+	/* anti-aliased lines for more consistent appearance */
+	glEnable(GL_LINE_SMOOTH);
+	glEnable(GL_BLEND);
+	
 	for (i=0; i < fcu->totvert; i++, prevbezt=bezt, bezt++) {
 		/* Draw the editmode handels for a bezier curve (others don't have handles) 
 		 * if their selection status matches the selection status we're drawing for
@@ -273,6 +273,9 @@
 				draw_fcurve_handle_control(bezt->vec[2][0], bezt->vec[2][1], xscale, yscale, hsize);
 		}
 	}
+	
+	glDisable(GL_LINE_SMOOTH);
+	glDisable(GL_BLEND);
 }
 
 /* helper func - set color to draw F-Curve data with */
@@ -399,7 +402,10 @@
 
 /* Samples ---------------- */
 
-/* helper func - draw sample-range marker for an F-Curve as a cross */
+/* helper func - draw sample-range marker for an F-Curve as a cross 
+ * NOTE: the caller MUST HAVE GL_LINE_SMOOTH & GL_BLEND ENABLED, otherwise, the controls don't 
+ * have a consistent appearance (due to off-pixel alignments)...
+ */
 static void draw_fcurve_sample_control (float x, float y, float xscale, float yscale, float hsize)
 {
 	static GLuint displist=0;
@@ -424,16 +430,9 @@
 	glTranslatef(x, y, 0.0f);
 	glScalef(1.0f/xscale*hsize, 1.0f/yscale*hsize, 1.0f);
 	
-	/* anti-aliased lines for more consistent appearance */
-	glEnable(GL_LINE_SMOOTH);
-	glEnable(GL_BLEND);
-	
 	/* draw! */
 	glCallList(displist);
 	
-	glDisable(GL_BLEND);
-	glDisable(GL_LINE_SMOOTH);
-	
 	/* restore view transform */
 	glScalef(xscale/hsize, yscale/hsize, 1.0);
 	glTranslatef(-x, -y, 0.0f);
@@ -459,8 +458,15 @@
 	
 	/* draw */
 	if (first && last) {
+		/* anti-aliased lines for more consistent appearance */
+		glEnable(GL_LINE_SMOOTH);
+		glEnable(GL_BLEND);
+		
 		draw_fcurve_sample_control(first->vec[0], first->vec[1], xscale, yscale, hsize);
 		draw_fcurve_sample_control(last->vec[0], last->vec[1], xscale, yscale, hsize);
+		
+		glDisable(GL_BLEND);
+		glDisable(GL_LINE_SMOOTH);
 	}
 }
 





More information about the Bf-blender-cvs mailing list