summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-07-20 02:57:47 +0300
committerAndrei Karas <akaras@inbox.ru>2011-07-20 03:41:35 +0300
commite645959d2dc85ee6a50d9927df3d9f6e374c8317 (patch)
tree6e5c348a7c89c4c864bab299fc9989fc0b0a5791 /src/gui
parentca945c9bd62318109246443c6d43091885e817b1 (diff)
downloadmanaverse-e645959d2dc85ee6a50d9927df3d9f6e374c8317.tar.gz
manaverse-e645959d2dc85ee6a50d9927df3d9f6e374c8317.tar.bz2
manaverse-e645959d2dc85ee6a50d9927df3d9f6e374c8317.tar.xz
manaverse-e645959d2dc85ee6a50d9927df3d9f6e374c8317.zip
Improve perfomance in creation SDL font surfaces.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/sdlfont.cpp21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/gui/sdlfont.cpp b/src/gui/sdlfont.cpp
index 9cbee4e89..a0f8699f8 100644
--- a/src/gui/sdlfont.cpp
+++ b/src/gui/sdlfont.cpp
@@ -64,7 +64,7 @@ class SDLTextChunk
return (chunk.text == text && chunk.color == color);
}
- void generate(TTF_Font *font)
+ void generate(TTF_Font *font, float alpha)
{
SDL_Color sdlCol;
sdlCol.b = static_cast<Uint8>(color.b);
@@ -83,7 +83,8 @@ class SDLTextChunk
return;
}
- img = Image::load(surface);
+ img = Image::createTextSurface(surface, alpha);
+// img = Image::load(surface);
SDL_FreeSurface(surface);
}
@@ -243,7 +244,7 @@ void SDLFont::drawString(gcn::Graphics *graphics,
mCreateCounter ++;
#endif
cache->push_front(chunk);
- cache->front().generate(mFont);
+ cache->front().generate(mFont, alpha);
if (!mCleanTime)
{
@@ -254,9 +255,13 @@ void SDLFont::drawString(gcn::Graphics *graphics,
doClean();
mCleanTime = cur_time + CLEAN_TIME;
}
+ if (cache->front().img)
+ {
+// cache->front().img->setAlpha(alpha);
+ g->drawImage(cache->front().img, x, y);
+ }
}
-
- if (cache->front().img)
+ else if (cache->front().img)
{
cache->front().img->setAlpha(alpha);
g->drawImage(cache->front().img, x, y);
@@ -271,9 +276,9 @@ void SDLFont::createSDLTextChunk(SDLTextChunk *chunk)
const float alpha = static_cast<float>(chunk->color.a) / 255.0f;
chunk->color.a = 255;
- chunk->generate(mFont);
- if (chunk->img)
- chunk->img->setAlpha(alpha);
+ chunk->generate(mFont, alpha);
+// if (chunk->img)
+// chunk->img->setAlpha(alpha);
}
int SDLFont::getWidth(const std::string &text) const