diff --git a/stepmania/src/RageTextureID.h b/stepmania/src/RageTextureID.h index 787d456cd0..454f40dbcc 100644 --- a/stepmania/src/RageTextureID.h +++ b/stepmania/src/RageTextureID.h @@ -53,7 +53,7 @@ struct RageTextureID * Note that this property is not considered for ordering/equality. Loading * a texture with a different loading policy will reuse the same texture with * a different policy. */ - enum TexPolicy { TEX_CACHED, TEX_VOLATILE, TEX_DEFAULT } Policy; + enum TexPolicy { TEX_PERMANENT, TEX_CACHED, TEX_VOLATILE, TEX_DEFAULT } Policy; void Init(); diff --git a/stepmania/src/RageTextureManager.cpp b/stepmania/src/RageTextureManager.cpp index cc44864a48..d1a10d1897 100644 --- a/stepmania/src/RageTextureManager.cpp +++ b/stepmania/src/RageTextureManager.cpp @@ -21,8 +21,11 @@ * player could actually view all banners long enough to transition to them * all in the course of one song select screen. * - * Policy priority is in the order CACHED, VOLATILE, DEFAULT. Textures that are - * loaded DEFAULT can be changed to VOLATILE and CACHED; VOLATILE textures can only + * Permanent: Never delete the texture. + * This is only used for BannerCache=2 mode. + * + * Policy priority is in the order PERMANENT, CACHED, VOLATILE, DEFAULT. Textures that + * are loaded DEFAULT can be changed to VOLATILE and CACHED; VOLATILE textures can only * be changed to CACHED. CACHED flags are normally set explicitly on a per-texture * basis. VOLATILE flags are set for all banners, but banners which are explicitly * set to CACHED should stay CACHED. Finally, all textures, when they're finally used, @@ -153,6 +156,13 @@ void RageTextureManager::VolatileTexture( RageTextureID ID ) UnloadTexture( pTexture ); } +void RageTextureManager::PermanentTexture( RageTextureID ID ) +{ + RageTexture* pTexture = LoadTextureInternal( ID ); + pTexture->GetPolicy() = min( pTexture->GetPolicy(), RageTextureID::TEX_PERMANENT ); + UnloadTexture( pTexture ); +} + void RageTextureManager::UnloadTexture( RageTexture *t ) { t->m_iRefCount--; @@ -161,6 +171,8 @@ void RageTextureManager::UnloadTexture( RageTexture *t ) if( t->m_iRefCount ) return; /* Can't unload textures that are still referenced. */ + if( t->GetPolicy() == RageTextureID::TEX_PERMANENT ) + return; /* Never unload TEX_PERMANENT textures. */ bool bDeleteThis = false; /* Always unload movies, so we don't waste time decoding. @@ -219,6 +231,8 @@ void RageTextureManager::GarbageCollect( GCType type ) if( t->m_iRefCount ) continue; /* Can't unload textures that are still referenced. */ + if( t->GetPolicy() == RageTextureID::TEX_PERMANENT ) + return; /* Never unload TEX_PERMANENT textures. */ bool bDeleteThis = false; if( type==screen_changed ) diff --git a/stepmania/src/RageTextureManager.h b/stepmania/src/RageTextureManager.h index a864139bb6..bb007bc016 100644 --- a/stepmania/src/RageTextureManager.h +++ b/stepmania/src/RageTextureManager.h @@ -57,6 +57,7 @@ public: void RegisterTexture( RageTextureID ID, RageTexture *p ); void CacheTexture( RageTextureID ID ); void VolatileTexture( RageTextureID ID ); + void PermanentTexture( RageTextureID ID ); void UnloadTexture( RageTexture *t ); void ReloadAll();