diff --git a/projects/mtg/include/WCachedResource.h b/projects/mtg/include/WCachedResource.h index e7726146b..276eba6f6 100644 --- a/projects/mtg/include/WCachedResource.h +++ b/projects/mtg/include/WCachedResource.h @@ -16,8 +16,6 @@ public: WResource(); virtual ~WResource(); - virtual void Trash()=0; //Delete the cacheActual. - virtual void Nullify()=0; //For when our size is 0, so we don't free anything by mistake. virtual unsigned long size()=0; //Size of cached item in bytes. virtual bool isGood()=0; //Return true if this has data. virtual bool isLocked(); //Is the resource locked? @@ -51,8 +49,6 @@ class WTrackedQuad: public WResource { public: WTrackedQuad(string _resname); ~WTrackedQuad(); - void Nullify(); - void Trash(); bool isGood(); unsigned long size(); string resname; @@ -72,9 +68,6 @@ public: bool isLocked(); bool Attempt(string filename, int submode, int & error); bool compare(JTexture * t) {return (t == texture);}; - - void Nullify(); - void Trash(); JTexture * Actual(); //Return this texture as is. Does not make a new one. JQuad * GetQuad(string resname); @@ -87,7 +80,6 @@ public: protected: JTexture * texture; vector trackedQuads; - static vector garbageTQs; }; class WCachedParticles: public WCachedResource{ @@ -96,11 +88,8 @@ public: template friend class WCache; WCachedParticles(); ~WCachedParticles(); - - void Nullify(); - void Trash(); void Refresh(); - unsigned long size(); + unsigned long size(); bool isGood(); bool Attempt(string filename, int submode, int & error); @@ -117,8 +106,6 @@ public: template friend class WCache; WCachedSample(); ~WCachedSample(); - void Nullify(); - void Trash(); bool compare(JSample * s) {return (s == sample);}; unsigned long size(); bool isGood(); diff --git a/projects/mtg/include/WResourceManager.h b/projects/mtg/include/WResourceManager.h index 0b4e034a1..a89a6eb62 100644 --- a/projects/mtg/include/WResourceManager.h +++ b/projects/mtg/include/WResourceManager.h @@ -80,9 +80,7 @@ public: bool RemoveMiss(int id=0); //Removes a cache miss. bool RemoveOldest(); //Remove oldest unlocked item. bool Cleanup(); //Repeats RemoveOldest() until cache fits in size limits - void Clear(); //Removes everything cached. Not lock safe, does not remove managed items. void ClearUnlocked(); //Remove all unlocked items. - void ClearMisses(); //Clear all cache misses. void Refresh(); //Refreshes all cache items. unsigned int Flatten(); //Ensures that the times don't loop. Returns new lastTime. void Resize(unsigned long size, int items); //Sets new limits, then enforces them. Lock safe, so not a "hard limit". @@ -108,8 +106,6 @@ protected: unsigned int cacheItems; int mError; - - }; @@ -139,7 +135,6 @@ public: bool RemoveOldest(); bool Cleanup(); //Force a cleanup. Return false if nothing removed. - void ClearMisses(); //Remove all cache misses. void ClearUnlocked(); //Remove unlocked items. void Refresh(); //Refreshes all files in cache, for when mode/profile changes. diff --git a/projects/mtg/src/WCachedResource.cpp b/projects/mtg/src/WCachedResource.cpp index 3304aafb5..84283de59 100644 --- a/projects/mtg/src/WCachedResource.cpp +++ b/projects/mtg/src/WCachedResource.cpp @@ -60,8 +60,6 @@ void WResource::hit(){ lastTime = resources.nowTime(); } //WCachedTexture -vector WCachedTexture::garbageTQs; - WCachedTexture::WCachedTexture(){ texture = NULL; } @@ -112,14 +110,8 @@ bool WCachedTexture::ReleaseQuad(JQuad* quad){ tq->unlock(); if(!tq->isLocked()){ - if(WCachedTexture::garbageTQs.size() < MAX_CACHE_GARBAGE){ - tq->Trash(); - garbageTQs.push_back(tq); - } - else SAFE_DELETE(tq); - - trackedQuads.erase(it); + trackedQuads.erase(it); } return true; //Returns true when found. @@ -307,39 +299,7 @@ bool WCachedTexture::Attempt(string filename, int submode, int & error){ return true; } -void WCachedTexture::Nullify(){ - if(texture) - texture = NULL; -} -void WCachedTexture::Trash(){ - SAFE_DELETE(texture); - - vector::iterator it; - WTrackedQuad * tq = NULL; - - for(it=trackedQuads.begin();it!=trackedQuads.end();it++){ - tq = (*it); - if(WCachedTexture::garbageTQs.size() > MAX_CACHE_GARBAGE) - SAFE_DELETE(tq); - else{ - tq->Trash(); - WCachedTexture::garbageTQs.push_back(tq); - } - } - trackedQuads.clear(); -} - //WCachedSample -void WCachedSample::Nullify(){ - if(sample){ - sample = NULL; - } -} - -void WCachedSample::Trash(){ - SAFE_DELETE(sample); -} - WCachedSample::WCachedSample(){ sample = NULL; } @@ -454,25 +414,7 @@ WCachedParticles::~WCachedParticles(){ SAFE_DELETE(particles); } -void WCachedParticles::Nullify(){ - if(particles) - particles = NULL; -} - -void WCachedParticles::Trash(){ - SAFE_DELETE(particles); -} - //WTrackedQuad -void WTrackedQuad::Nullify() { - quad = NULL; -} - -void WTrackedQuad::Trash(){ - resname.clear(); - SAFE_DELETE(quad); -} - unsigned long WTrackedQuad::size() { return sizeof(JQuad); } diff --git a/projects/mtg/src/WResourceManager.cpp b/projects/mtg/src/WResourceManager.cpp index 0d3425064..003c57907 100644 --- a/projects/mtg/src/WResourceManager.cpp +++ b/projects/mtg/src/WResourceManager.cpp @@ -181,13 +181,6 @@ WResourceManager::~WResourceManager(){ SAFE_DELETE(wm); } managedQuads.clear(); - - //Remove all our reserved WTrackedQuads from WCachedTexture - vector::iterator g; - for(g=WCachedTexture::garbageTQs.begin();g!=WCachedTexture::garbageTQs.end();g++){ - WTrackedQuad * tq = *g; - SAFE_DELETE(tq); - } LOG("==Successfully Destroyed WResourceManager=="); } @@ -356,13 +349,6 @@ void WResourceManager::Release(JQuad * quad){ if(it != textureWCache.cache.end() && it->second) textureWCache.RemoveItem(it->second,false); //won't remove locked. } - -void WResourceManager::ClearMisses(){ - textureWCache.ClearMisses(); - sampleWCache.ClearMisses(); - psiWCache.ClearMisses(); -} - void WResourceManager::ClearUnlocked(){ textureWCache.ClearUnlocked(); sampleWCache.ClearUnlocked(); @@ -889,27 +875,6 @@ bool WCache::RemoveOldest(){ return false; } -template -void WCache::Clear(){ - typename map::iterator it, next; - - for(it = cache.begin(); it != cache.end();it=next){ - next = it; - next++; - - if(it->second) - Delete(it->second); - cache.erase(it); - } - for(it = managed.begin(); it != managed.end();it=next){ - next = it; - next++; - - if(!it->second) - managed.erase(it); - } -} - template void WCache::ClearUnlocked(){ typename map::iterator it, next; @@ -927,31 +892,11 @@ void WCache::ClearUnlocked(){ } } } - -template -void WCache::ClearMisses(){ - typename map::iterator it, next; - - for(it = cache.begin(); it != cache.end();it=next){ - next = it; - next++; - - if(!it->second) - cache.erase(it); - } - for(it = managed.begin(); it != managed.end();it=next){ - next = it; - next++; - - if(!it->second) - managed.erase(it); - } -} template void WCache::Resize(unsigned long size, int items){ maxCacheSize = size; - if(items > MAX_CACHE_OBJECTS || items < 0) + if(items > MAX_CACHE_OBJECTS || items < 1) maxCached = MAX_CACHE_OBJECTS; else maxCached = items; @@ -1200,7 +1145,7 @@ bool WCache::Cleanup(){ template unsigned int WCache::Flatten(){ - unsigned int youngest = 65535; + unsigned int youngest = (unsigned int) 65535; unsigned int oldest = 0; for (typename map::iterator it = cache.begin(); it != cache.end(); ++it){ @@ -1283,8 +1228,6 @@ template bool WCache::Delete(cacheItem * item){ if(!item) return false; - if(maxCached == 0) - item->Nullify(); unsigned long isize = item->size(); totalSize -= isize;