-some small performance enhancements
This commit is contained in:
wagic.the.homebrew@gmail.com
2009-10-14 14:35:26 +00:00
parent 0bff0c564b
commit ad1492b888
3 changed files with 17 additions and 26 deletions
+5 -1
View File
@@ -58,9 +58,12 @@ void CardGui::Render()
float cardScale = quad ? 40 / quad->mHeight : 1; float cardScale = quad ? 40 / quad->mHeight : 1;
float scale = actZ * cardScale; float scale = actZ * cardScale;
JQuad* shadow = resources.GetQuad("shadow"); JQuad* shadow = NULL;
if (actZ > 1) {
shadow = resources.GetQuad("shadow");
shadow->SetColor(ARGB(static_cast<unsigned char>(actA)/2,255,255,255)); shadow->SetColor(ARGB(static_cast<unsigned char>(actA)/2,255,255,255));
renderer->RenderQuad(shadow, actX + (actZ-1)*15, actY + (actZ-1)*15, actT, 28*actZ/16, 40*actZ/16); renderer->RenderQuad(shadow, actX + (actZ-1)*15, actY + (actZ-1)*15, actT, 28*actZ/16, 40*actZ/16);
}
if (quad) { if (quad) {
quad->SetColor(ARGB(static_cast<unsigned char>(actA),255,255,255)); quad->SetColor(ARGB(static_cast<unsigned char>(actA),255,255,255));
@@ -105,6 +108,7 @@ void CardGui::Render()
} }
if (tc && !tc->canTarget(card)) { if (tc && !tc->canTarget(card)) {
if (!shadow) shadow = resources.GetQuad("shadow");
shadow->SetColor(ARGB(200,255,255,255)); shadow->SetColor(ARGB(200,255,255,255));
renderer->RenderQuad(shadow, actX, actY, actT, (28*actZ + 1)/16 , 40*actZ/16); renderer->RenderQuad(shadow, actX, actY, actT, (28*actZ + 1)/16 , 40*actZ/16);
} }
+5
View File
@@ -8,6 +8,7 @@
#include <JFileSystem.h> #include <JFileSystem.h>
#include "../include/GameOptions.h" #include "../include/GameOptions.h"
#include "../include/WResourceManager.h" #include "../include/WResourceManager.h"
#include <assert.h>
//WResource //WResource
@@ -277,6 +278,10 @@ bool WCachedTexture::Attempt(string filename, int submode, int & error){
if(submode & TEXTURE_SUB_5551) if(submode & TEXTURE_SUB_5551)
format = GU_PSM_5551; format = GU_PSM_5551;
if(!realname.size()){
error = CACHE_ERROR_404;
return false;
}
texture = JRenderer::GetInstance()->LoadTexture(realname.c_str(),TEX_TYPE_USE_VRAM,format); texture = JRenderer::GetInstance()->LoadTexture(realname.c_str(),TEX_TYPE_USE_VRAM,format);
+2 -20
View File
@@ -965,23 +965,9 @@ cacheItem* WCache<cacheItem, cacheActual>::AttemptNew(string filename, int submo
cacheItem* item = NEW cacheItem; cacheItem* item = NEW cacheItem;
if(!item) { if(!item) {
//Try a few times to get an item.
for(int attempt=0;attempt<MAX_CACHE_ATTEMPTS;attempt++){
if(!RemoveOldest() || item)
break;
item = NEW cacheItem;
}
//We /really/ shouldn't get this far.
if(!item){
resources.ClearUnlocked();
item = NEW cacheItem;
if(!item){
//Nothing let us make an item. Failure.
mError = CACHE_ERROR_BAD_ALLOC; mError = CACHE_ERROR_BAD_ALLOC;
return NULL; return NULL;
} }
}
}
mError = CACHE_ERROR_NONE; mError = CACHE_ERROR_NONE;
@@ -1137,9 +1123,8 @@ cacheItem * WCache<cacheItem, cacheActual>::Get(string id, int style, int submod
it = cache.find(lookup); it = cache.find(lookup);
//Well, we've found something... //Well, we've found something...
if(it != cache.end()) { if(it != cache.end()) {
if(!it->second && (submode & CACHE_EXISTING)){ if (!it->second)
mError = CACHE_ERROR_404; mError = CACHE_ERROR_404;
}
return it->second; //A hit. return it->second; //A hit.
} }
} }
@@ -1154,15 +1139,12 @@ cacheItem * WCache<cacheItem, cacheActual>::Get(string id, int style, int submod
cacheItem * item = AttemptNew(id,submode); cacheItem * item = AttemptNew(id,submode);
if(style == RETRIEVE_MANAGE){ if(style == RETRIEVE_MANAGE){
managed[lookup] = item; //Record a hit or miss.
if(item){ if(item){
managed[lookup] = item; //Record a hit.
item->deadbolt(); //Make permanent. item->deadbolt(); //Make permanent.
} }
else if(mError == CACHE_ERROR_404)
managed[lookup] = NULL; //File not found. Record a miss
} }
else { else {
if(item || mError == CACHE_ERROR_404)
cache[lookup] = item; cache[lookup] = item;
} }