Jeck - GameStateMenu releases background image from cache, minor cache fixes.
This commit is contained in:
@@ -86,7 +86,6 @@ public:
|
||||
bool ReleaseQuad(JQuad* quad); //We're done with this quad, so delete and stop tracking. True if existed.
|
||||
protected:
|
||||
JTexture * texture;
|
||||
bool bVRAM;
|
||||
vector<WTrackedQuad*> trackedQuads;
|
||||
static vector<WTrackedQuad*> garbageTQs;
|
||||
};
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#define LARGE_CACHE_LIMIT 5000000
|
||||
#define LARGE_CACHE_ITEMS 200
|
||||
|
||||
#define SMALL_CACHE_LIMIT 2000000
|
||||
#define SMALL_CACHE_LIMIT 1000000
|
||||
#define SMALL_CACHE_ITEMS 100
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#define MAX_CACHE_OBJECTS HUGE_CACHE_ITEMS
|
||||
#define MAX_CACHE_ATTEMPTS 10
|
||||
#define MAX_CACHE_MISSES 200
|
||||
#define MAX_CACHED_SAMPLES 0
|
||||
#define MAX_CACHED_SAMPLES 4
|
||||
#define MAX_CACHE_GARBAGE 10
|
||||
|
||||
enum ENUM_WRES_INFO{
|
||||
@@ -137,7 +137,6 @@ public:
|
||||
void Release(JTexture * tex);
|
||||
void Release(JQuad * quad);
|
||||
void Release(JSample * sample);
|
||||
|
||||
bool RemoveOldest();
|
||||
|
||||
bool Cleanup(); //Force a cleanup. Return false if nothing removed.
|
||||
|
||||
@@ -163,7 +163,7 @@ void GameStateMenu::Start(){
|
||||
SAFE_DELETE(playerdata);
|
||||
|
||||
#if defined DEBUG_CACHE
|
||||
resources.ClearUnlocked(); //So we can tell if we've any extra locks.
|
||||
/*resources.ClearUnlocked(); //So we can tell if we've any extra locks.
|
||||
|
||||
if(!resources.menuCached)
|
||||
resources.menuCached = resources.CountCached();
|
||||
@@ -174,7 +174,7 @@ void GameStateMenu::Start(){
|
||||
sprintf(buf,"Warning: %u leftover locked items.",i);
|
||||
resources.debugMessage = buf;
|
||||
}
|
||||
|
||||
*/
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -292,6 +292,10 @@ void GameStateMenu::End()
|
||||
|
||||
resources.Release(bgTexture);
|
||||
resources.Release(movingWTexture);
|
||||
|
||||
|
||||
resources.Release(mBg);
|
||||
resources.Release(mMovingW);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -317,7 +317,7 @@ void WCachedTexture::Nullify(){
|
||||
texture = NULL;
|
||||
}
|
||||
void WCachedTexture::Trash(){
|
||||
SAFE_DELETE(texture);
|
||||
SAFE_DELETE(texture);
|
||||
|
||||
vector<WTrackedQuad*>::iterator it;
|
||||
WTrackedQuad * tq = NULL;
|
||||
|
||||
@@ -29,6 +29,7 @@ bool WResourceManager::RemoveOldest(){
|
||||
void WResourceManager::DebugRender(){
|
||||
JRenderer* renderer = JRenderer::GetInstance();
|
||||
JLBFont * font = resources.GetJLBFont(Constants::MAIN_FONT);
|
||||
font->SetColor(ARGB(255,255,255,255));
|
||||
|
||||
if(!font || !renderer)
|
||||
return;
|
||||
@@ -274,7 +275,7 @@ JQuad * WResourceManager::GetQuad(int id){
|
||||
}
|
||||
|
||||
JQuad * WResourceManager::RetrieveTempQuad(string filename){
|
||||
return RetrieveQuad(filename,0,0,0,0,"",RETRIEVE_NORMAL);
|
||||
return RetrieveQuad(filename,0,0,0,0,"temporary",RETRIEVE_NORMAL);
|
||||
}
|
||||
|
||||
JQuad * WResourceManager::RetrieveQuad(string filename, float offX, float offY, float width, float height, string resname, int style, int submode){
|
||||
@@ -501,18 +502,12 @@ JSample * WResourceManager::RetrieveSample(string filename, int style, int submo
|
||||
//Check cache. This just tracks misses.
|
||||
return NULL;
|
||||
WCachedSample * tc = NULL;
|
||||
tc = sampleWCache.Get(filename,submode);
|
||||
tc = sampleWCache.Retrieve(filename,style,submode);
|
||||
lastError = sampleWCache.mError;
|
||||
|
||||
//Sample exists! Get it.
|
||||
if(tc && tc->isGood()){
|
||||
JSample * js = tc->Actual();
|
||||
|
||||
//Samples are freed when played, so remove this. Because maxCached is 0, this will Nullify() first.
|
||||
sampleWCache.RemoveItem(tc,true);
|
||||
//Adjust sizes accordingly.
|
||||
sampleWCache.cacheSize = 0;
|
||||
sampleWCache.totalSize = 0;
|
||||
return js;
|
||||
}
|
||||
|
||||
@@ -1167,7 +1162,7 @@ cacheItem * WCache<cacheItem, cacheActual>::Retrieve(string filename, int style,
|
||||
}
|
||||
else{
|
||||
//Something went wrong.
|
||||
Delete(tc);
|
||||
RemoveItem(tc);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1359,11 +1354,11 @@ template <class cacheItem, class cacheActual>
|
||||
WCache<cacheItem, cacheActual>::~WCache(){
|
||||
typename map<string,cacheItem*>::iterator it;
|
||||
|
||||
//Delete from cache & managed
|
||||
for(it=cache.begin();it!=cache.end();it++){
|
||||
if(!it->second)
|
||||
continue;
|
||||
|
||||
//Delete(it->second);
|
||||
|
||||
SAFE_DELETE(it->second);
|
||||
}
|
||||
|
||||
@@ -1371,10 +1366,10 @@ WCache<cacheItem, cacheActual>::~WCache(){
|
||||
if(!it->second)
|
||||
continue;
|
||||
|
||||
//Delete(it->second);
|
||||
SAFE_DELETE(it->second);
|
||||
}
|
||||
|
||||
//Clean up all the garbage
|
||||
typename vector<cacheItem*>::iterator g;
|
||||
for(g=garbage.begin();g!=garbage.end();g++){
|
||||
SAFE_DELETE(*g);
|
||||
@@ -1497,6 +1492,8 @@ bool WCache<cacheItem, cacheActual>::Delete(cacheItem * item){
|
||||
SAFE_DELETE(item);
|
||||
else{
|
||||
item->Trash();
|
||||
item->lastTime = 0;
|
||||
item->loadedMode = 0;
|
||||
garbage.push_back(item);
|
||||
}
|
||||
return true;
|
||||
@@ -1520,11 +1517,10 @@ bool WCache<cacheItem, cacheActual>::Release(cacheActual* actual){
|
||||
it->second->unlock(); //Release one lock.
|
||||
if(it->second->isLocked())
|
||||
return true; //Still locked, won't delete, not technically a failure.
|
||||
|
||||
Delete(it->second);
|
||||
}
|
||||
|
||||
//Released!
|
||||
Delete(it->second);
|
||||
cache.erase(it);
|
||||
return true;
|
||||
}
|
||||
Reference in New Issue
Block a user