[Bf-committers] ATI significant speed fix

Joe Eagar joeedh at gmail.com
Tue Feb 28 09:48:00 CET 2006


I have found a source of major slowdown on some ATI cards.

Apparently some ATI's do *not* do bitmapped fonts very well.  Certainly 
my laptop ATI radeon mobility xpress goes really slow.   To test this, I 
opened the Node Editor which uses all BIF_DrawString calls.  I edited 
nodes with the "International Fonts" user option both on and off, and 
turning international fonts on provided a major speedup.

Short intro to those uninformed, Blender has 2 font rendering libraries, 
one that uses the standard OpenGL bitmapped-font methed, and bFTGL, a 
modified version of FTGL that uses textured non-bitmapped fonts.  The 
first is used by default (and is used always by the file selector), 
while the second is only on is the "International Fonts" option is set.

Anyway, this fix isn't exactly obvious, especially as the file selector 
doesn't use it, causing major headaches.  I've attached a patch that 
modifies the file selector code to use all BIF_ string calls, along with 
modifying BIF_RasterPos to use glRasterPos2f if bFTGL is turned off.  
With this code, the file selector actually works if "International 
fonts" are on!  Usually the selector lags about a half-second or more, 
but after changing all the text draws to BIF_DrawString (and turning 
"International Fonts" on, of course) it has no lag at all.

Files changed:
source/blender/src/filesel.c
source/blender/src/language.c

Tracker URL: 
http://projects.blender.org/tracker/index.php?func=detail&aid=3971&group_id=9&atid=127

joeedh
-------------- next part --------------
Index: source/blender/src/filesel.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/src/filesel.c,v
retrieving revision 1.71
diff -u -r1.71 filesel.c
--- source/blender/src/filesel.c	5 Feb 2006 19:30:37 -0000	1.71
+++ source/blender/src/filesel.c	28 Feb 2006 08:16:17 -0000
@@ -92,6 +92,7 @@
 #include "BIF_space.h"
 #include "BIF_screen.h"
 #include "BIF_resources.h"
+#include "BIF_language.h"
 
 #include "BLO_readfile.h"
 
@@ -617,7 +618,7 @@
 
 	for (num=0; num<sfile->totfile; num++) {
 		
-		len = BMF_GetStringWidth(G.font, sfile->filelist[num].relname);
+		len = BIF_GetStringWidth(G.font, sfile->filelist[num].relname, 0);
 		if (len > sfile->maxnamelen) sfile->maxnamelen = len;
 		
 		if(filetoname) {
@@ -914,46 +915,47 @@
 
 	s = files->string;
 	if(s) {
-		glRasterPos2i(x,  y);
-		BMF_DrawString(G.font, files->relname);
+		//BIF_SetScale(1.0f);
+		BIF_RasterPos((float)x,  (float)y);
+		BIF_DrawString(G.font, files->relname, 0);
 		
 		x += sfile->maxnamelen + 100;
 
-		glRasterPos2i(x - BMF_GetStringWidth(G.font, files->size),  y);
-		BMF_DrawString(G.font, files->size);
+		BIF_RasterPos((float)(x - BIF_GetStringWidth(G.font, files->size,0)), (float) y);
+		BIF_DrawString(G.font, files->size, 0);
 
 		if(sfile->flag & FILE_SHOWSHORT) return;
 
 #ifndef WIN32
 		/* rwx rwx rwx */
-			x += 20; glRasterPos2i(x, y); 
-			BMF_DrawString(G.font, files->mode1); 
+			x += 20; BIF_RasterPos((float)x,  (float)y); 
+			BIF_DrawString(G.font, files->mode1, 0); 
 		
-			x += 30; glRasterPos2i(x, y); 
-			BMF_DrawString(G.font, files->mode2); 
+			x += 30; BIF_RasterPos((float)x,  (float)y); 
+			BIF_DrawString(G.font, files->mode2, 0); 
 		
-			x += 30; glRasterPos2i(x, y); 
-			BMF_DrawString(G.font, files->mode3); 
+			x += 30; BIF_RasterPos((float)x,  (float)y); 
+			BIF_DrawString(G.font, files->mode3, 0); 
 		
 		/* owner time date */
-			x += 30; glRasterPos2i(x, y); 
-			BMF_DrawString(G.font, files->owner); 
+			x += 30; BIF_RasterPos((float)x,  (float)y);
+			BIF_DrawString(G.font, files->owner, 0); 
 #endif
 		
-			x += 60; glRasterPos2i(x, y); 
-			BMF_DrawString(G.font, files->time); 
+			x += 60; BIF_RasterPos((float)x,  (float)y);
+			BIF_DrawString(G.font, files->time, 0); 
 		
-			x += 50; glRasterPos2i(x, y); 
-			BMF_DrawString(G.font, files->date); 
+			x += 50; BIF_RasterPos((float)x,  (float)y); 
+			BIF_DrawString(G.font, files->date, 0); 
 	}
 	else {
-		glRasterPos2i(x,  y);
-		BMF_DrawString(G.font, files->relname);
+		BIF_RasterPos((float)x,  (float)y);
+		BIF_DrawString(G.font, files->relname, 0);
 		
 		if(files->nr) {	/* extra info */
 			x+= sfile->maxnamelen+20;
-			glRasterPos2i(x,  y);
-			BMF_DrawString(G.font, files->extra);
+			BIF_RasterPos((float)x,  (float)y);;
+			BIF_DrawString(G.font, files->extra, 0);
 		}
 	}
 }
@@ -1106,7 +1108,7 @@
 	uiSetButLock( sfile->type==FILE_MAIN && sfile->returnfunc, NULL);
 
 	/* space available for load/save buttons? */
-	loadbutton= MAX2(80, 20+BMF_GetStringWidth(G.font, sfile->title));
+	loadbutton= MAX2(80, 20+BIF_GetStringWidth(G.font, sfile->title, 0));
 	if(textrct.xmax-textrct.xmin > loadbutton+20) {
 		if(sfile->title[0]==0) loadbutton= 0;
 	}
@@ -2355,7 +2357,7 @@
 	
 	sfile->maxnamelen= 0;
 	for(i=0; i<sfile->totfile; i++) {
-		int len = BMF_GetStringWidth(G.font, sfile->filelist[i].relname);
+		int len = BIF_GetStringWidth(G.font, sfile->filelist[i].relname, 0);
 		if (len > sfile->maxnamelen)
 			sfile->maxnamelen = len;
 	}
@@ -2589,7 +2591,7 @@
 
 	sfile->maxnamelen= 0;
 	for(a=0; a<sfile->totfile; a++) {
-		len = BMF_GetStringWidth(G.font, sfile->filelist[a].relname);
+		len = BIF_GetStringWidth(G.font, sfile->filelist[a].relname, 0);
 		if (len > sfile->maxnamelen) sfile->maxnamelen = len;
 		
 		if(filetoname) {
Index: source/blender/src/language.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/src/language.c,v
retrieving revision 1.34
diff -u -r1.34 language.c
--- source/blender/src/language.c	28 May 2005 13:22:09 -0000	1.34
+++ source/blender/src/language.c	28 Feb 2006 08:16:17 -0000
@@ -73,7 +73,11 @@
 void BIF_RasterPos(float x, float y)
 {
 #ifdef INTERNATIONAL
-	FTF_SetPosition(x, y);
+	if(G.ui_international == TRUE) {
+		FTF_SetPosition(x, y);
+	} else glRasterPos2f(x, y);
+#else
+	glRasterPos2f(x, y);
 #endif // INTERNATIONAL
 }
 


More information about the Bf-committers mailing list