clean up RageTextureManager prefs, ModelManager prefs

add pref DelayedModelDelete
This commit is contained in:
Chris Danford
2004-05-26 06:39:38 +00:00
parent ff5ec77fec
commit 8f4792dd6a
7 changed files with 116 additions and 41 deletions
+11 -3
View File
@@ -71,9 +71,17 @@ void ModelManager::UnloadModel( RageModelGeometry *m )
{
if( i->second == m )
{
m_mapFileToModel.erase( i ); // remove map entry
SAFE_DELETE( m ); // free the texture
return;
if( m_Prefs.m_bDelayedUnload )
{
// leave this Model loaded
return;
}
else
{
m_mapFileToModel.erase( i ); // remove map entry
SAFE_DELETE( m ); // free the texture
return;
}
}
}
+25
View File
@@ -15,6 +15,26 @@
#include <map>
struct ModelManagerPrefs
{
bool m_bDelayedUnload;
ModelManagerPrefs()
{
m_bDelayedUnload = false;
}
ModelManagerPrefs( bool bDelayedUnload )
{
m_bDelayedUnload = bDelayedUnload;
}
bool operator!=( const ModelManagerPrefs& rhs )
{
return
m_bDelayedUnload != rhs.m_bDelayedUnload;
}
};
class ModelManager
{
public:
@@ -25,9 +45,14 @@ public:
void UnloadModel( RageModelGeometry *m );
// void ReloadAll();
bool SetPrefs( ModelManagerPrefs prefs ) { m_Prefs = prefs; return true; }
ModelManagerPrefs GetPrefs() { return m_Prefs; }
protected:
std::map<CString, RageModelGeometry*> m_mapFileToModel;
ModelManagerPrefs m_Prefs;
};
extern ModelManager* MODELMAN; // global and accessable from anywhere in our program
+3
View File
@@ -155,6 +155,7 @@ void PrefsManager::Init()
m_bDelayedTextureDelete = true;
m_bTexturePreload = false;
m_bDelayedScreenLoad = false;
m_bDelayedModelDelete = false;
m_BannerCache = BNCACHE_LOW_RES;
m_bFastLoad = true;
m_MusicWheelUsesSections = ALWAYS;
@@ -438,6 +439,7 @@ void PrefsManager::ReadPrefsFromFile( CString sIni )
ini.GetValue( "Options", "DelayedTextureDelete", m_bDelayedTextureDelete );
ini.GetValue( "Options", "TexturePreload", m_bTexturePreload );
ini.GetValue( "Options", "DelayedScreenLoad", m_bDelayedScreenLoad );
ini.GetValue( "Options", "DelayedModelDelete", m_bDelayedModelDelete );
ini.GetValue( "Options", "BannerCache", (int&)m_BannerCache );
ini.GetValue( "Options", "FastLoad", m_bFastLoad );
ini.GetValue( "Options", "MusicWheelUsesSections", (int&)m_MusicWheelUsesSections );
@@ -672,6 +674,7 @@ void PrefsManager::SaveGlobalPrefsToDisk() const
ini.SetValue( "Options", "DelayedTextureDelete", m_bDelayedTextureDelete );
ini.SetValue( "Options", "TexturePreload", m_bTexturePreload );
ini.SetValue( "Options", "DelayedScreenLoad", m_bDelayedScreenLoad );
ini.SetValue( "Options", "DelayedModelDelete", m_bDelayedModelDelete );
ini.SetValue( "Options", "BannerCache", m_BannerCache );
ini.SetValue( "Options", "FastLoad", m_bFastLoad );
ini.SetValue( "Options", "MusicWheelUsesSections", m_MusicWheelUsesSections );
+1
View File
@@ -49,6 +49,7 @@ public:
bool m_bDelayedTextureDelete;
bool m_bTexturePreload;
bool m_bDelayedScreenLoad;
bool m_bDelayedModelDelete;
enum BannerCacheMode { BNCACHE_OFF, BNCACHE_LOW_RES, BNCACHE_FULL };
BannerCacheMode m_BannerCache;
bool m_bFastLoad;
+10 -20
View File
@@ -43,10 +43,6 @@ RageTextureManager::RageTextureManager()
{
m_iNoWarnAboutOddDimensions = 0;
m_TexturePolicy = RageTextureID::TEX_DEFAULT;
m_bDelayedDelete = false;
m_iMovieColorDepth = 16;
m_iTextureColorDepth = 16;
m_iMaxTextureResolution = 1024;
}
RageTextureManager::~RageTextureManager()
@@ -74,8 +70,8 @@ void RageTextureManager::Update( float fDeltaTime )
void RageTextureManager::AdjustTextureID(RageTextureID &ID) const
{
if( ID.iColorDepth == -1 )
ID.iColorDepth = m_iTextureColorDepth;
ID.iMaxSize = min( ID.iMaxSize, m_iMaxTextureResolution );
ID.iColorDepth = m_Prefs.m_iTextureColorDepth;
ID.iMaxSize = min( ID.iMaxSize, m_Prefs.m_iMaxTextureResolution );
}
/* If you've set up a texture yourself, register it here so it can be referenced
@@ -177,7 +173,7 @@ void RageTextureManager::UnloadTexture( RageTexture *t )
bDeleteThis = true;
/* Delete normal textures immediately unless m_bDelayedDelete is is on. */
if( t->GetPolicy() == RageTextureID::TEX_DEFAULT && !m_bDelayedDelete )
if( t->GetPolicy() == RageTextureID::TEX_DEFAULT && !m_Prefs.m_bDelayedDelete )
bDeleteThis = true;
/* Delete volatile textures after they've been used at least once. */
@@ -233,11 +229,11 @@ void RageTextureManager::GarbageCollect( GCType type )
/* If m_bDelayedDelete, wait until delayed_delete. If !m_bDelayedDelete,
* it should have been deleted when it reached no references, but we
* might have just changed the preference. */
if( !m_bDelayedDelete )
if( !m_Prefs.m_bDelayedDelete )
bDeleteThis = true;
break;
case RageTextureID::TEX_CACHED:
if( !m_bDelayedDelete )
if( !m_Prefs.m_bDelayedDelete )
bDeleteThis = true;
break;
case RageTextureID::TEX_VOLATILE:
@@ -290,22 +286,16 @@ void RageTextureManager::InvalidateTextures()
}
}
bool RageTextureManager::SetPrefs( int iTextureColorDepth, int iMovieColorDepth, bool bDelayedDelete, int iMaxTextureResolution )
bool RageTextureManager::SetPrefs( RageTextureManagerPrefs prefs )
{
bool need_reload = false;
if( m_bDelayedDelete != bDelayedDelete ||
m_iMovieColorDepth != iMovieColorDepth ||
m_iTextureColorDepth != iTextureColorDepth ||
m_iMaxTextureResolution != iMaxTextureResolution )
if( m_Prefs != prefs )
need_reload = true;
m_bDelayedDelete = bDelayedDelete;
m_iTextureColorDepth = iTextureColorDepth;
m_iMaxTextureResolution = iMaxTextureResolution;
m_iMovieColorDepth = iMovieColorDepth;
m_Prefs = prefs;
ASSERT( m_iTextureColorDepth==16 || m_iTextureColorDepth==32 );
ASSERT( m_iMovieColorDepth==16 || m_iMovieColorDepth==32 );
ASSERT( m_Prefs.m_iTextureColorDepth==16 || m_Prefs.m_iTextureColorDepth==32 );
ASSERT( m_Prefs.m_iMovieColorDepth==16 || m_Prefs.m_iMovieColorDepth==32 );
return need_reload;
}
+39 -9
View File
@@ -9,6 +9,42 @@
#include <map>
struct RageTextureManagerPrefs
{
int m_iTextureColorDepth;
int m_iMovieColorDepth;
bool m_bDelayedDelete;
int m_iMaxTextureResolution;
RageTextureManagerPrefs()
{
m_bDelayedDelete = false;
m_iMovieColorDepth = 16;
m_iTextureColorDepth = 16;
m_iMaxTextureResolution = 1024;
}
RageTextureManagerPrefs(
int iTextureColorDepth,
int iMovieColorDepth,
bool bDelayedDelete,
int iMaxTextureResolution )
{
m_bDelayedDelete = bDelayedDelete ;
m_iMovieColorDepth = iMovieColorDepth;
m_iTextureColorDepth = iTextureColorDepth;
m_iMaxTextureResolution = iMaxTextureResolution;
}
bool operator!=( const RageTextureManagerPrefs& rhs )
{
return
m_iTextureColorDepth != rhs.m_iTextureColorDepth ||
m_iMovieColorDepth != rhs.m_iMovieColorDepth ||
m_bDelayedDelete != rhs.m_bDelayedDelete ||
m_iMaxTextureResolution != rhs.m_iMaxTextureResolution;
}
};
class RageTextureManager
{
public:
@@ -24,11 +60,8 @@ public:
void UnloadTexture( RageTexture *t );
void ReloadAll();
bool SetPrefs( int iTextureColorDepth, int iMovieColorDepth, bool bDelayedDelete, int iMaxTextureResolution );
int GetTextureColorDepth() { return m_iTextureColorDepth; };
int GetMovieColorDepth() { return m_iMovieColorDepth; };
bool GetDelayedDelete() { return m_bDelayedDelete; };
int GetMaxTextureResolution() { return m_iMaxTextureResolution; };
bool SetPrefs( RageTextureManagerPrefs prefs );
RageTextureManagerPrefs GetPrefs() { return m_Prefs; };
RageTextureID::TexPolicy GetDefaultTexturePolicy() const { return m_TexturePolicy; }
void SetDefaultTexturePolicy( RageTextureID::TexPolicy p ) { m_TexturePolicy = p; }
@@ -53,10 +86,7 @@ protected:
enum GCType { screen_changed, delayed_delete };
void GarbageCollect( GCType type );
int m_iTextureColorDepth;
int m_iMovieColorDepth;
bool m_bDelayedDelete;
int m_iMaxTextureResolution;
RageTextureManagerPrefs m_Prefs;
RageTexture* LoadTextureInternal( RageTextureID ID );
+27 -9
View File
@@ -161,10 +161,19 @@ void ApplyGraphicOptions()
PREFSMAN->m_fCenterImageScaleY );
bNeedReload |= TEXTUREMAN->SetPrefs(
PREFSMAN->m_iTextureColorDepth,
PREFSMAN->m_iMovieColorDepth,
PREFSMAN->m_bDelayedTextureDelete,
PREFSMAN->m_iMaxTextureResolution );
RageTextureManagerPrefs(
PREFSMAN->m_iTextureColorDepth,
PREFSMAN->m_iMovieColorDepth,
PREFSMAN->m_bDelayedTextureDelete,
PREFSMAN->m_iMaxTextureResolution
)
);
bNeedReload |= MODELMAN->SetPrefs(
ModelManagerPrefs(
PREFSMAN->m_bDelayedModelDelete
)
);
if( bNeedReload )
TEXTUREMAN->ReloadAll();
@@ -1059,7 +1068,6 @@ int main(int argc, char* argv[])
PROFILEMAN = new ProfileManager;
PROFILEMAN->Init(); // must load after SONGMAN
UNLOCKMAN = new UnlockSystem;
MODELMAN = new ModelManager;
delete loading_window; // destroy this before init'ing Display
NSMAN = new NetworkSyncManager;
@@ -1079,10 +1087,20 @@ int main(int argc, char* argv[])
TEXTUREMAN = new RageTextureManager();
TEXTUREMAN->SetPrefs(
PREFSMAN->m_iTextureColorDepth,
PREFSMAN->m_iMovieColorDepth,
PREFSMAN->m_bDelayedTextureDelete,
PREFSMAN->m_iMaxTextureResolution );
RageTextureManagerPrefs(
PREFSMAN->m_iTextureColorDepth,
PREFSMAN->m_iMovieColorDepth,
PREFSMAN->m_bDelayedTextureDelete,
PREFSMAN->m_iMaxTextureResolution
)
);
MODELMAN = new ModelManager;
MODELMAN->SetPrefs(
ModelManagerPrefs(
PREFSMAN->m_bDelayedModelDelete
)
);
StoreActualGraphicOptions( true );