-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

View File

@@ -58,9 +58,12 @@ void CardGui::Render()
float cardScale = quad ? 40 / quad->mHeight : 1;
float scale = actZ * cardScale;
JQuad* shadow = resources.GetQuad("shadow");
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);
JQuad* shadow = NULL;
if (actZ > 1) {
shadow = resources.GetQuad("shadow");
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);
}
if (quad) {
quad->SetColor(ARGB(static_cast<unsigned char>(actA),255,255,255));
@@ -105,6 +108,7 @@ void CardGui::Render()
}
if (tc && !tc->canTarget(card)) {
if (!shadow) shadow = resources.GetQuad("shadow");
shadow->SetColor(ARGB(200,255,255,255));
renderer->RenderQuad(shadow, actX, actY, actT, (28*actZ + 1)/16 , 40*actZ/16);
}

View File

@@ -8,6 +8,7 @@
#include <JFileSystem.h>
#include "../include/GameOptions.h"
#include "../include/WResourceManager.h"
#include <assert.h>
//WResource
@@ -277,6 +278,10 @@ bool WCachedTexture::Attempt(string filename, int submode, int & error){
if(submode & TEXTURE_SUB_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);

View File

@@ -965,22 +965,8 @@ cacheItem* WCache<cacheItem, cacheActual>::AttemptNew(string filename, int submo
cacheItem* item = NEW cacheItem;
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;
return NULL;
}
}
mError = CACHE_ERROR_BAD_ALLOC;
return NULL;
}
mError = CACHE_ERROR_NONE;
@@ -1137,9 +1123,8 @@ cacheItem * WCache<cacheItem, cacheActual>::Get(string id, int style, int submod
it = cache.find(lookup);
//Well, we've found something...
if(it != cache.end()) {
if(!it->second && (submode & CACHE_EXISTING)){
mError = CACHE_ERROR_404;
}
if (!it->second)
mError = CACHE_ERROR_404;
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);
if(style == RETRIEVE_MANAGE){
managed[lookup] = item; //Record a hit or miss.
if(item){
managed[lookup] = item; //Record a hit.
item->deadbolt(); //Make permanent.
}
else if(mError == CACHE_ERROR_404)
managed[lookup] = NULL; //File not found. Record a miss
}
else {
if(item || mError == CACHE_ERROR_404)
cache[lookup] = item;
}