Jeck - Extremely minor speedup for cache access in GameStateDeckViewer, minor fix to WResourceManager::cleanup().

This commit is contained in:
wagic.jeck
2009-09-11 08:17:05 +00:00
parent 421d2655ee
commit 9d203619aa
3 changed files with 12 additions and 8 deletions

View File

@@ -80,7 +80,6 @@ public:
WResourceManager();
~WResourceManager();
bool isCardInCache(MTGCard * card, int type = CACHE_CARD);
JQuad * RetrieveCard(MTGCard * card, int type = CACHE_CARD, int style = RETRIEVE_NORMAL);
JSample * RetrieveSample(string filename, int style = RETRIEVE_NORMAL);
JTexture * RetrieveTexture(string filename, int style = RETRIEVE_NORMAL);

View File

@@ -543,13 +543,18 @@ void GameStateDeckViewer::renderCard(int id, float rotation){
int alpha = (int) (255 * (scale + 1.0 - max_scale));
if (!card) return;
JQuad * quad = backQuad;
JQuad * quad = NULL;
int showName = 1;
if (resources.RetrieveCard(card,CACHE_CARD,RETRIEVE_EXISTING) || last_user_activity > (abs(2-id) + 1)* NO_USER_ACTIVITY_SHOWCARD_DELAY){
quad = resources.RetrieveCard(card);
showName = 0;
}
int showName = 0;
quad = resources.RetrieveCard(card,CACHE_CARD,RETRIEVE_EXISTING);
if (!quad){
if(last_user_activity > (abs(2-id) + 1)* NO_USER_ACTIVITY_SHOWCARD_DELAY)
quad = resources.RetrieveCard(card);
else{
quad = backQuad;
showName = 1;
}
}
if (quad){

View File

@@ -163,8 +163,8 @@ bool WResourceManager::cleanup(){
long maxSize = options[Options::CACHESIZE].number * 100000;
if (!maxSize) maxSize = CACHE_SIZE_PIXELS;
ClearMisses();
while (textureCache.size() > MAX_CACHE_OBJECTS - 1 || totalsize > maxSize){
ClearMisses();
int result = RemoveOldestTexture();
if (!result) return false;
}