Don't render a textSurface again if nothing has changed.

This commit is contained in:
Guus Sliepen 2011-08-25 13:48:02 +02:00
parent 39ca89d91c
commit 9e4ae7e3bd
1 changed files with 9 additions and 0 deletions

View File

@ -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;