Agar-SVN | 22 Jun 05:13
Favicon

Agar: r8204 - in trunk: core gui math rg

Author: vedge
Date: 2009-06-22 00:13:09 -0300 (Mon, 22 Jun 2009)
New Revision: 8204

Modified:
   trunk/core/config.c
   trunk/core/config.h
   trunk/gui/label.c
   trunk/gui/progress_bar.c
   trunk/math/m_matview.c
   trunk/rg/tileview.c
Log:
backout r8148 (agTextCache optimization) for now

Modified: trunk/core/config.c
===================================================================
--- trunk/core/config.c	2009-06-22 02:59:08 UTC (rev 8203)
+++ trunk/core/config.c	2009-06-22 03:13:09 UTC (rev 8204)
@@ -53,6 +53,7 @@
 int agTextComposition = 1;		/* Built-in input composition */
 int agTextBidi = 0;			/* Bidirectionnal text display */
 int agTextAntialiasing = 1;		/* Use font antialiasing */
+int agTextCache = 0;			/* Dynamic text caching */
 int agTextTabWidth = 40;		/* Tab width (px) */
 int agTextBlinkRate = 250;		/* Cursor blink rate (ms) */
 int agTextSymbols = 1;			/* Process special symbols in text */

Modified: trunk/core/config.h
===================================================================
--- trunk/core/config.h	2009-06-22 02:59:08 UTC (rev 8203)
+++ trunk/core/config.h	2009-06-22 03:13:09 UTC (rev 8204)
@@ -14,7 +14,7 @@
 extern int agMouseDblclickDelay, agMouseSpinDelay, agMouseSpinIval;
 extern int agTextComposition, agTextBidi, agTextAntialiasing, agTextTabWidth,
 	   agTextBlinkRate, agTextAntialiasing, agPageIncrement,
-	   agTextSymbols;
+	   agTextSymbols, agTextCache;
 extern int agIdleThresh;
 extern int agScreenshotQuality;
 extern int agWindowAnySize;

Modified: trunk/gui/label.c
===================================================================
--- trunk/gui/label.c	2009-06-22 02:59:08 UTC (rev 8203)
+++ trunk/gui/label.c	2009-06-22 03:13:09 UTC (rev 8204)
@@ -60,7 +60,7 @@
 #ifdef AG_THREADS
 	lbl->poll.lock = NULL;
 #endif
-	lbl->tCache = AG_TextCacheNew(lbl, 64, 16);
+	lbl->tCache = agTextCache ? AG_TextCacheNew(lbl, 64, 16) : NULL;

 	va_start(ap, fmt);
 	for (p = fmt; *p != '\0'; p++) {
@@ -107,7 +107,7 @@
 #ifdef AG_THREADS
 	lbl->poll.lock = mutex;
 #endif
-	lbl->tCache = AG_TextCacheNew(lbl, 64, 16);
+	lbl->tCache = agTextCache ? AG_TextCacheNew(lbl, 64, 16) : NULL;

 	va_start(ap, fmt);
 	for (p = fmt; *p != '\0'; p++) {
@@ -537,7 +537,6 @@
 	char *f;
 	int i, fPos = 0;
 	int x, y;
-	int su;

 	if (lbl->text == NULL || lbl->text[0] == '\0') {
 		return;
@@ -626,9 +625,16 @@
 		}
 	}

-	su = AG_TextCacheGet(lbl->tCache,s);
-	GetPosition(lbl, WSURFACE(lbl,su), &x, &y);
-	AG_WidgetBlitSurface(lbl, su, x, y);
+	if (agTextCache) {
+		int su = AG_TextCacheGet(lbl->tCache,s);
+		GetPosition(lbl, WSURFACE(lbl,su), &x, &y);
+		AG_WidgetBlitSurface(lbl, su, x, y);
+	} else {
+		AG_Surface *su = AG_TextRender(s);
+		GetPosition(lbl, su, &x, &y);
+		AG_WidgetBlit(lbl, su, x, y);
+		AG_SurfaceFree(su);
+	}
 }

 static void

Modified: trunk/gui/progress_bar.c
===================================================================
--- trunk/gui/progress_bar.c	2009-06-22 02:59:08 UTC (rev 8203)
+++ trunk/gui/progress_bar.c	2009-06-22 03:13:09 UTC (rev 8204)
@@ -87,7 +87,7 @@
 	pb->max = 100;
 	pb->width = 25;
 	pb->pad = 2;
-	pb->tCache = AG_TextCacheNew(pb, 50, 10);
+	pb->tCache = agTextCache ? AG_TextCacheNew(pb, 50, 10) : NULL;
 }

 static void
@@ -158,7 +158,7 @@
 	AG_ProgressBar *pb = obj;
 	char pctText[32];
 	AG_Rect rd;
-	int min, max, val, su, wAvail;
+	int min, max, val, wAvail;

 	min = AG_GetInt(pb, "min");
 	max = AG_GetInt(pb, "max");
@@ -193,10 +193,18 @@

 		AG_PushTextState();
 		AG_TextColor(TEXT_COLOR);
-		su = AG_TextCacheGet(pb->tCache, pctText);
-		AG_WidgetBlitSurface(pb, su,
-		    WIDTH(pb)/2  - WSURFACE(pb,su)->w/2,
-		    HEIGHT(pb)/2 - WSURFACE(pb,su)->h/2);
+		if (agTextCache) {
+			int su = AG_TextCacheGet(pb->tCache, pctText);
+			AG_WidgetBlitSurface(pb, su,
+			    WIDTH(pb)/2  - WSURFACE(pb,su)->w/2,
+			    HEIGHT(pb)/2 - WSURFACE(pb,su)->h/2);
+		} else {
+			SDL_Surface *suTmp = AG_TextRender(pctText);
+			AG_WidgetBlit(pb, suTmp,
+			    WIDTH(pb)/2  - suTmp->w/2,
+			    HEIGHT(pb)/2 - suTmp->h/2);
+			AG_SurfaceFree(suTmp);
+		}
 		AG_PopTextState();
 	}
 }

Modified: trunk/math/m_matview.c
===================================================================
--- trunk/math/m_matview.c	2009-06-22 02:59:08 UTC (rev 8203)
+++ trunk/math/m_matview.c	2009-06-22 03:13:09 UTC (rev 8204)
@@ -123,7 +123,7 @@
 	mv->mPre = 0;
 	mv->nPre = 0;
 	mv->numFmt = "%g";
-	mv->tCache = AG_TextCacheNew(mv, 64, 16);
+	mv->tCache = agTextCache ? AG_TextCacheNew(mv, 64, 16) : NULL;
 	mv->r = AG_RECT(0,0,0,0);
 	
 	AG_BindInt(mv->hBar, "value", &mv->xOffs);
@@ -218,7 +218,6 @@
 	int xMin = 5, xMax = 0;
 	int xOffs = -mv-≥xOffs*mv->wEnt + 8;
 	int yOffs = -mv-≥yOffs*mv->hEnt + 8;
-	int su;

 	AG_DrawBox(mv, mv->r, -1, AG_COLOR(BG_COLOR));
 	AG_PushClipRect(mv, mv->r);
@@ -233,9 +232,16 @@
 		     n < MCOLS(M) && x < mv->r.w;
 		     n++, x += (mv->wEnt + mv->hSpacing)) {
 			Snprintf(text, sizeof(text), mv->numFmt, M_Get(M,m,n));
-			su = AG_TextCacheGet(mv->tCache,text);
-			AG_WidgetBlitSurface(mv, su, x, y);
-			xMax = MAX(xMax, x+WSURFACE(mv,su)->w);
+			if (agTextCache) {
+				int su = AG_TextCacheGet(mv->tCache,text);
+				AG_WidgetBlitSurface(mv, su, x, y);
+				xMax = MAX(xMax, x+WSURFACE(mv,su)->w);
+			} else {
+				AG_Surface *su = AG_TextRender(text);
+				AG_WidgetBlit(mv, su, x, y);
+				xMax = MAX(xMax, x+su->w);
+				AG_SurfaceFree(su);
+			}
 			xMin = MIN(xMin, x);
 		}
 	}

Modified: trunk/rg/tileview.c
===================================================================
--- trunk/rg/tileview.c	2009-06-22 02:59:08 UTC (rev 8203)
+++ trunk/rg/tileview.c	2009-06-22 03:13:09 UTC (rev 8204)
@@ -775,7 +775,7 @@
 	tv->menu = NULL;
 	tv->menu_item = NULL;
 	tv->menu_win = NULL;
-	tv->tCache = AG_TextCacheNew(tv, 64, 16);
+	tv->tCache = agTextCache ? AG_TextCacheNew(tv, 64, 16) : NULL;
 	TAILQ_INIT(&tv->tools);
 	TAILQ_INIT(&tv->ctrls);

@@ -1114,13 +1114,21 @@
 static void
 DrawStatusText(RG_Tileview *tv, const char *label)
 {
-	int su, wSu, hSu;
+	SDL_Surface *suTmp = NULL;		/* Make compiler happy */
+	int su = -1;
+	int wSu, hSu;

 	AG_PushTextState();
 	AG_TextColor(TILEVIEW_TEXT_COLOR);
-	su = AG_TextCacheGet(tv->tCache, label);
-	wSu = WSURFACE(tv,su)->w;
-	hSu = WSURFACE(tv,su)->h;
+	if (agTextCache) {
+		su = AG_TextCacheGet(tv->tCache, label);
+		wSu = WSURFACE(tv,su)->w;
+		hSu = WSURFACE(tv,su)->h;
+	} else {
+		suTmp = AG_TextRender(label);
+		wSu = suTmp->w;
+		hSu = suTmp->h;
+	}
 	AG_PopTextState();

 	AG_DrawRectFilled(tv,
@@ -1128,7 +1136,12 @@
 	            HEIGHT(tv)-hSu-2, WIDTH(tv), HEIGHT(tv)),
 	    AG_COLOR(TILEVIEW_TEXTBG_COLOR));

-	AG_WidgetBlitSurface(tv, su, WIDTH(tv)-wSu-1, HEIGHT(tv)-hSu-1);
+	if (agTextCache) {
+		AG_WidgetBlitSurface(tv, su, WIDTH(tv)-wSu-1, HEIGHT(tv)-hSu-1);
+	} else {
+		AG_WidgetBlit(tv, suTmp, WIDTH(tv)-wSu-1, HEIGHT(tv)-hSu-1);
+		AG_SurfaceFree(suTmp);
+	}
 }

 void

Gmane