From 9e4ae7e3bd56f68753edee41628b3a1b0ba06440 Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Thu, 25 Aug 2011 13:48:02 +0200 Subject: [PATCH] Don't render a textSurface again if nothing has changed. --- code/classes.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/code/classes.h b/code/classes.h index d5ec867..475e985 100644 --- a/code/classes.h +++ b/code/classes.h @@ -659,6 +659,15 @@ class Graphics { void textSurface(int index, const char *inString, int x, int y, int fontColor) { + /* Shortcut: if we already rendered the same string in the same color, don't render it again. */ + if(textShape[index].text && textShape[index].image && textShape[index].fontColor == fontColor && !strcmp(textShape[index].text, inString)) { + textShape[index].x = x; + textShape[index].y = y; + if (x == -1) + textShape[index].x = (800 - textShape[index].image->w) / 2; + return; + } + strcpy(textShape[index].text, inString); textShape[index].x = x; textShape[index].y = y;