diff options
author | Einar Johan Trøan Sømåen | 2012-12-02 07:25:12 +0100 |
---|---|---|
committer | Einar Johan Trøan Sømåen | 2012-12-02 07:25:12 +0100 |
commit | 4efd40e41eb44e13c28b73c4eb06b3d2105f88e0 (patch) | |
tree | 7e3671f6a7edf5f8a640e87e91013aa444c1cda3 /engines/wintermute | |
parent | 8c4beffdf05126c5798e23ef78e1cc98face1256 (diff) | |
download | scummvm-rg350-4efd40e41eb44e13c28b73c4eb06b3d2105f88e0.tar.gz scummvm-rg350-4efd40e41eb44e13c28b73c4eb06b3d2105f88e0.tar.bz2 scummvm-rg350-4efd40e41eb44e13c28b73c4eb06b3d2105f88e0.zip |
WINTERMUTE: Make the TTF-cache actually use LRU.
Diffstat (limited to 'engines/wintermute')
-rw-r--r-- | engines/wintermute/base/font/base_font_truetype.cpp | 12 | ||||
-rw-r--r-- | engines/wintermute/base/font/base_font_truetype.h | 3 |
2 files changed, 8 insertions, 7 deletions
diff --git a/engines/wintermute/base/font/base_font_truetype.cpp b/engines/wintermute/base/font/base_font_truetype.cpp index f236329fcd..85844b5080 100644 --- a/engines/wintermute/base/font/base_font_truetype.cpp +++ b/engines/wintermute/base/font/base_font_truetype.cpp @@ -173,25 +173,25 @@ void BaseFontTT::drawText(const byte *text, int x, int y, int width, TTextAlign BaseRenderer *renderer = _gameRef->_renderer; // find cached surface, if exists - int minPriority = INT_MAX; + int minUseTime = INT_MAX; int minIndex = -1; BaseSurface *surface = NULL; int textOffset = 0; for (int i = 0; i < NUM_CACHED_TEXTS; i++) { if (_cachedTexts[i] == NULL) { - minPriority = 0; + minUseTime = 0; minIndex = i; } else { if (_cachedTexts[i]->_text == textStr && _cachedTexts[i]->_align == align && _cachedTexts[i]->_width == width && _cachedTexts[i]->_maxHeight == maxHeight && _cachedTexts[i]->_maxLength == maxLength) { surface = _cachedTexts[i]->_surface; textOffset = _cachedTexts[i]->_textOffset; - _cachedTexts[i]->_priority++; _cachedTexts[i]->_marked = true; + _cachedTexts[i]->_lastUsed = g_system->getMillis(); break; } else { - if (_cachedTexts[i]->_priority < minPriority) { - minPriority = _cachedTexts[i]->_priority; + if (_cachedTexts[i]->_lastUsed < minUseTime) { + minUseTime = _cachedTexts[i]->_lastUsed; minIndex = i; } } @@ -214,10 +214,10 @@ void BaseFontTT::drawText(const byte *text, int x, int y, int width, TTextAlign _cachedTexts[minIndex]->_width = width; _cachedTexts[minIndex]->_maxHeight = maxHeight; _cachedTexts[minIndex]->_maxLength = maxLength; - _cachedTexts[minIndex]->_priority = 1; _cachedTexts[minIndex]->_text = textStr; _cachedTexts[minIndex]->_textOffset = textOffset; _cachedTexts[minIndex]->_marked = true; + _cachedTexts[minIndex]->_lastUsed = g_system->getMillis(); } } diff --git a/engines/wintermute/base/font/base_font_truetype.h b/engines/wintermute/base/font/base_font_truetype.h index 02dca7439f..2b69d1655d 100644 --- a/engines/wintermute/base/font/base_font_truetype.h +++ b/engines/wintermute/base/font/base_font_truetype.h @@ -54,6 +54,7 @@ private: int _priority; int _textOffset; bool _marked; + uint32 _lastUsed; BaseCachedTTFontText() { //_text = L""; @@ -61,8 +62,8 @@ private: _width = _maxHeight = _maxLength = -1; _align = TAL_LEFT; _surface = NULL; - _priority = -1; _textOffset = 0; + _lastUsed = 0; _marked = false; } |