diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-02-09 22:03:05 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-02-10 03:07:44 +0300 |
commit | f75a1e7af1db4be56430765e19a5aee75284dd3e (patch) | |
tree | 621a4a764758d8ff36aaebd58f5534e00cc64bce | |
parent | a89e756f00adb4e20be74590b624b3fd632c8a95 (diff) | |
download | plus-f75a1e7af1db4be56430765e19a5aee75284dd3e.tar.gz plus-f75a1e7af1db4be56430765e19a5aee75284dd3e.tar.bz2 plus-f75a1e7af1db4be56430765e19a5aee75284dd3e.tar.xz plus-f75a1e7af1db4be56430765e19a5aee75284dd3e.zip |
Improve font cache cleaning.
Add missing font cache cleaning code.
-rw-r--r-- | src/gui/gui.cpp | 12 | ||||
-rw-r--r-- | src/gui/sdlfont.cpp | 20 | ||||
-rw-r--r-- | src/gui/sdlfont.h | 2 |
3 files changed, 20 insertions, 14 deletions
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 3a459b55f..3a5964924 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -296,15 +296,17 @@ void Gui::slowLogic() mMouseCursorAlpha = std::max(0.0f, mMouseCursorAlpha - 0.005f); } if (mGuiFont) - mGuiFont->slowLogic(); + mGuiFont->slowLogic(0); if (mInfoParticleFont) - mInfoParticleFont->slowLogic(); + mInfoParticleFont->slowLogic(1); if (mHelpFont) - mHelpFont->slowLogic(); + mHelpFont->slowLogic(2); if (mSecureFont) - mSecureFont->slowLogic(); + mSecureFont->slowLogic(3); if (boldFont) - boldFont->slowLogic(); + boldFont->slowLogic(4); + if (mNpcFont) + mNpcFont->slowLogic(5); BLOCK_END("Gui::slowLogic") } 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 diff --git a/src/gui/sdlfont.h b/src/gui/sdlfont.h index 22cbb53cb..4e77943f8 100644 --- a/src/gui/sdlfont.h +++ b/src/gui/sdlfont.h @@ -87,7 +87,7 @@ class SDLFont final : public gcn::Font void doClean(); - void slowLogic(); + void slowLogic(const int rnd); int getCreateCounter() const A_WARN_UNUSED { return mCreateCounter; } |