summaryrefslogtreecommitdiff
path: root/src/gui/sdlfont.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-02-09 22:03:05 +0300
committerAndrei Karas <akaras@inbox.ru>2013-02-10 03:07:44 +0300
commitf75a1e7af1db4be56430765e19a5aee75284dd3e (patch)
tree621a4a764758d8ff36aaebd58f5534e00cc64bce /src/gui/sdlfont.cpp
parenta89e756f00adb4e20be74590b624b3fd632c8a95 (diff)
downloadmv-f75a1e7af1db4be56430765e19a5aee75284dd3e.tar.gz
mv-f75a1e7af1db4be56430765e19a5aee75284dd3e.tar.bz2
mv-f75a1e7af1db4be56430765e19a5aee75284dd3e.tar.xz
mv-f75a1e7af1db4be56430765e19a5aee75284dd3e.zip
Improve font cache cleaning.
Add missing font cache cleaning code.
Diffstat (limited to 'src/gui/sdlfont.cpp')
-rw-r--r--src/gui/sdlfont.cpp20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/gui/sdlfont.cpp b/src/gui/sdlfont.cpp
index 3a8f4a0b8..404e1d319 100644
--- a/src/gui/sdlfont.cpp
+++ b/src/gui/sdlfont.cpp
@@ -41,7 +41,7 @@ const unsigned int CACHE_SIZE = 256;
const unsigned int CACHE_SIZE_SMALL1 = 2;
const unsigned int CACHE_SIZE_SMALL2 = 50;
const unsigned int CACHE_SIZE_SMALL3 = 170;
-const unsigned int CLEAN_TIME = 5;
+const unsigned int CLEAN_TIME = 7;
const int OUTLINE_SIZE = 1;
char *strBuf;
@@ -327,17 +327,17 @@ void SDLFont::drawString(gcn::Graphics *const graphics,
BLOCK_END("SDLFont::drawString")
}
-void SDLFont::slowLogic()
+void SDLFont::slowLogic(const int rnd)
{
BLOCK_START("SDLFont::slowLogic")
if (!mCleanTime)
{
- mCleanTime = cur_time + CLEAN_TIME;
+ mCleanTime = cur_time + CLEAN_TIME + rnd;
}
else if (mCleanTime < cur_time)
{
doClean();
- mCleanTime = cur_time + CLEAN_TIME;
+ mCleanTime = cur_time + CLEAN_TIME + rnd;
}
BLOCK_END("SDLFont::slowLogic")
}
@@ -410,8 +410,10 @@ void SDLFont::doClean()
#ifdef DEBUG_FONT_COUNTERS
mDeleteCounter += 100;
#endif
- for (int d = 0; d < 100; d ++)
- cache->pop_back();
+ const std::list<SDLTextChunk>::iterator it_end = cache->end();
+ std::list<SDLTextChunk>::iterator it = cache->begin();
+ std::advance(it, -100);
+ cache->erase(it, it_end);
#ifdef DEBUG_FONT_COUNTERS
logger->log("delete3");
#endif
@@ -421,8 +423,10 @@ void SDLFont::doClean()
#ifdef DEBUG_FONT_COUNTERS
mDeleteCounter += 20;
#endif
- for (int d = 0; d < 20; d ++)
- cache->pop_back();
+ const std::list<SDLTextChunk>::iterator it_end = cache->end();
+ std::list<SDLTextChunk>::iterator it = cache->begin();
+ std::advance(it, -20);
+ cache->erase(it, it_end);
#ifdef DEBUG_FONT_COUNTERS
logger->log("delete2");
#endif