Jeck - Quad locking restored, minor cache fiddling.
* Restored quad locking to textures, but ignore quad locks when Release(JTexture*) is explicitly called. (I just copied and modified the code from the template, rather than do anything elegant). * Some minor fiddling with cache error states.
This commit is contained in:
@@ -66,6 +66,7 @@ public:
|
|||||||
void Refresh();
|
void Refresh();
|
||||||
unsigned long size();
|
unsigned long size();
|
||||||
bool isGood();
|
bool isGood();
|
||||||
|
bool isLocked(); //Is the resource locked?
|
||||||
bool Attempt(string filename, int submode, int & error);
|
bool Attempt(string filename, int submode, int & error);
|
||||||
bool compare(JTexture * t) {return (t == texture);};
|
bool compare(JTexture * t) {return (t == texture);};
|
||||||
JTexture * Actual(); //Return this texture as is. Does not make a new one.
|
JTexture * Actual(); //Return this texture as is. Does not make a new one.
|
||||||
|
|||||||
@@ -84,6 +84,18 @@ WCachedTexture::~WCachedTexture(){
|
|||||||
JTexture * WCachedTexture::Actual(){
|
JTexture * WCachedTexture::Actual(){
|
||||||
return texture;
|
return texture;
|
||||||
}
|
}
|
||||||
|
bool WCachedTexture::isLocked(){
|
||||||
|
if(locks != WRES_UNLOCKED)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
for(vector<WTrackedQuad*>::iterator it=trackedQuads.begin();it!=trackedQuads.end();it++){
|
||||||
|
if((*it)->isLocked())
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool WCachedTexture::ReleaseQuad(JQuad* quad){
|
bool WCachedTexture::ReleaseQuad(JQuad* quad){
|
||||||
if(quad == NULL)
|
if(quad == NULL)
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -333,7 +333,25 @@ void WResourceManager::Release(JTexture * tex){
|
|||||||
if(!tex)
|
if(!tex)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
textureWCache.Release(tex);
|
//Copied direct from WCache::Release(). This is quick and dirty.
|
||||||
|
map<int,WCachedTexture*>::iterator it;
|
||||||
|
for(it=textureWCache.cache.begin();it!=textureWCache.cache.end();it++){
|
||||||
|
if(it->second && it->second->compare(tex))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(it == textureWCache.cache.end())
|
||||||
|
return; //Not here, can't release.
|
||||||
|
|
||||||
|
if(it->second){
|
||||||
|
it->second->unlock(); //Release one lock.
|
||||||
|
if(it->second->locks != WRES_UNLOCKED) //Normally we'd call isLocked, but this way ignores quads.
|
||||||
|
return; //Locked
|
||||||
|
}
|
||||||
|
|
||||||
|
textureWCache.Delete(it->second);
|
||||||
|
textureWCache.cache.erase(it);
|
||||||
|
return; //Released!
|
||||||
}
|
}
|
||||||
|
|
||||||
void WResourceManager::Unmiss(string filename){
|
void WResourceManager::Unmiss(string filename){
|
||||||
@@ -977,6 +995,7 @@ cacheItem * WCache<cacheItem, cacheActual>::Retrieve(int id, string filename, in
|
|||||||
}
|
}
|
||||||
//Something went wrong.
|
//Something went wrong.
|
||||||
RemoveItem(tc);
|
RemoveItem(tc);
|
||||||
|
mError = CACHE_ERROR_BAD;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Record managed failure. Cache failure is recorded in Get().
|
//Record managed failure. Cache failure is recorded in Get().
|
||||||
@@ -1030,7 +1049,8 @@ cacheItem * WCache<cacheItem, cacheActual>::Get(int id, string filename, int sty
|
|||||||
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()){
|
||||||
mError = CACHE_ERROR_NONE; //We found an entry in cache, so not an error.
|
if(!it->second)
|
||||||
|
mError = CACHE_ERROR_404;
|
||||||
return it->second; //A hit, or maybe a miss.
|
return it->second; //A hit, or maybe a miss.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user