[Scummvm-cvs-logs] scummvm master -> 4efd40e41eb44e13c28b73c4eb06b3d2105f88e0

somaen einarjohan at somadalen.com
Sun Dec 2 07:26:03 CET 2012


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
4efd40e41e WINTERMUTE: Make the TTF-cache actually use LRU.


Commit: 4efd40e41eb44e13c28b73c4eb06b3d2105f88e0
    https://github.com/scummvm/scummvm/commit/4efd40e41eb44e13c28b73c4eb06b3d2105f88e0
Author: Einar Johan Trøan Sømåen (einarjohants at gmail.com)
Date: 2012-12-01T22:25:12-08:00

Commit Message:
WINTERMUTE: Make the TTF-cache actually use LRU.

Changed paths:
    engines/wintermute/base/font/base_font_truetype.cpp
    engines/wintermute/base/font/base_font_truetype.h



diff --git a/engines/wintermute/base/font/base_font_truetype.cpp b/engines/wintermute/base/font/base_font_truetype.cpp
index f236329..85844b5 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 02dca74..2b69d16 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;
 		}
 






More information about the Scummvm-git-logs mailing list