Fix an indirect movie texture crash (reset PixelStore)
Simplify texture handling: m_ID is const (can't be changed after load at all); preference overrides are handled in RageTexture; reloads no longer need a parameter
This commit is contained in:
@@ -117,9 +117,9 @@ RageBitmapTexture::~RageBitmapTexture()
|
|||||||
glDeleteTextures(1, &m_uGLTextureID);
|
glDeleteTextures(1, &m_uGLTextureID);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RageBitmapTexture::Reload( RageTextureID ID )
|
void RageBitmapTexture::Reload()
|
||||||
{
|
{
|
||||||
RageTexture::Reload(ID);
|
RageTexture::Reload();
|
||||||
DISPLAY->SetTexture(0);
|
DISPLAY->SetTexture(0);
|
||||||
|
|
||||||
if(m_uGLTextureID)
|
if(m_uGLTextureID)
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ public:
|
|||||||
virtual ~RageBitmapTexture();
|
virtual ~RageBitmapTexture();
|
||||||
/* only called by RageTextureManager::InvalidateTextures */
|
/* only called by RageTextureManager::InvalidateTextures */
|
||||||
virtual void Invalidate() { m_uGLTextureID = 0; }
|
virtual void Invalidate() { m_uGLTextureID = 0; }
|
||||||
virtual void Reload( RageTextureID name );
|
virtual void Reload();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void Create(); // called by constructor and Reload
|
void Create(); // called by constructor and Reload
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ RageMovieTexture::~RageMovieTexture()
|
|||||||
glDeleteTextures(1, &m_uGLTextureID);
|
glDeleteTextures(1, &m_uGLTextureID);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RageMovieTexture::Reload( RageTextureID ID )
|
void RageMovieTexture::Reload()
|
||||||
{
|
{
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
@@ -116,6 +116,9 @@ void RageMovieTexture::Update(float fDeltaTime)
|
|||||||
min(m_iSourceHeight, m_iTextureHeight),
|
min(m_iSourceHeight, m_iTextureHeight),
|
||||||
GL_BGR, GL_UNSIGNED_BYTE, buffer);
|
GL_BGR, GL_UNSIGNED_BYTE, buffer);
|
||||||
|
|
||||||
|
/* Must unset PixelStore when we're done! */
|
||||||
|
glPixelStorei(GL_UNPACK_SWAP_BYTES, 0);
|
||||||
|
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
||||||
glFlush();
|
glFlush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ public:
|
|||||||
virtual ~RageMovieTexture();
|
virtual ~RageMovieTexture();
|
||||||
void Update(float fDeltaTime);
|
void Update(float fDeltaTime);
|
||||||
|
|
||||||
virtual void Reload( RageTextureID ID );
|
virtual void Reload();
|
||||||
|
|
||||||
virtual void Play();
|
virtual void Play();
|
||||||
virtual void Pause();
|
virtual void Pause();
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ void RageTextureID::Init()
|
|||||||
iAlphaBits = 4;
|
iAlphaBits = 4;
|
||||||
bDither = false;
|
bDither = false;
|
||||||
bStretch = false;
|
bStretch = false;
|
||||||
iColorDepth = TEXTUREMAN->GetTextureColorDepth();
|
iColorDepth = -1; /* default */
|
||||||
bHotPinkColorKey = false;
|
bHotPinkColorKey = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,19 +39,36 @@ bool RageTextureID::equal(const RageTextureID &rhs) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
RageTexture::RageTexture( RageTextureID name )
|
RageTexture::RageTexture( RageTextureID name ):
|
||||||
|
m_ID(name)
|
||||||
{
|
{
|
||||||
// LOG->Trace( "RageTexture::RageTexture()" );
|
// LOG->Trace( "RageTexture::RageTexture()" );
|
||||||
|
|
||||||
m_ID = m_ActualID = name;
|
|
||||||
m_iRefCount = 1;
|
m_iRefCount = 1;
|
||||||
|
|
||||||
|
SetActualID();
|
||||||
m_iSourceWidth = m_iSourceHeight = 0;
|
m_iSourceWidth = m_iSourceHeight = 0;
|
||||||
m_iTextureWidth = m_iTextureHeight = 0;
|
m_iTextureWidth = m_iTextureHeight = 0;
|
||||||
m_iImageWidth = m_iImageHeight = 0;
|
m_iImageWidth = m_iImageHeight = 0;
|
||||||
m_iFramesWide = m_iFramesHigh = 0;
|
m_iFramesWide = m_iFramesHigh = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Set the initial ActualID; this is what the actual texture will start
|
||||||
|
* from. */
|
||||||
|
void RageTexture::SetActualID()
|
||||||
|
{
|
||||||
|
m_ActualID = m_ID;
|
||||||
|
|
||||||
|
/* Texture color depth preference can be overridden. */
|
||||||
|
if(m_ID.iColorDepth == -1)
|
||||||
|
m_ActualID.iColorDepth = TEXTUREMAN->GetTextureColorDepth();
|
||||||
|
|
||||||
|
/* The max texture size can never be higher than the preference,
|
||||||
|
* since it might be set to something to fix driver problems. */
|
||||||
|
m_ActualID.iMaxSize = min(m_ActualID.iMaxSize, TEXTUREMAN->GetMaxTextureResolution());
|
||||||
|
}
|
||||||
|
|
||||||
RageTexture::~RageTexture()
|
RageTexture::~RageTexture()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ public:
|
|||||||
RageTexture( RageTextureID file );
|
RageTexture( RageTextureID file );
|
||||||
virtual ~RageTexture() = 0;
|
virtual ~RageTexture() = 0;
|
||||||
virtual void Update( float fDeltaTime ) {}
|
virtual void Update( float fDeltaTime ) {}
|
||||||
virtual void Reload( RageTextureID ID ) { m_ID = m_ActualID = ID; }
|
virtual void Reload() { SetActualID(); }
|
||||||
virtual void Invalidate() { } /* only called by RageTextureManager::InvalidateTextures */
|
virtual void Invalidate() { } /* only called by RageTextureManager::InvalidateTextures */
|
||||||
virtual unsigned int GetGLTextureID() = 0; // accessed by RageDisplay
|
virtual unsigned int GetGLTextureID() = 0; // accessed by RageDisplay
|
||||||
|
|
||||||
@@ -99,7 +99,9 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
/* The file we were asked to load. (This is never changed.) */
|
/* The file we were asked to load. (This is never changed.) */
|
||||||
RageTextureID m_ID;
|
const RageTextureID m_ID;
|
||||||
|
|
||||||
|
void SetActualID();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/* We might change settings when loading (due to hints, hardware
|
/* We might change settings when loading (due to hints, hardware
|
||||||
|
|||||||
@@ -88,8 +88,6 @@ RageTexture* RageTextureManager::LoadTexture( RageTextureID ID )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// the texture is not already loaded. Load it.
|
// the texture is not already loaded. Load it.
|
||||||
ID.iColorDepth = TEXTUREMAN->GetTextureColorDepth();
|
|
||||||
ID.iMaxSize = TEXTUREMAN->GetMaxTextureResolution();
|
|
||||||
|
|
||||||
CString sDir, sFName, sExt;
|
CString sDir, sFName, sExt;
|
||||||
splitpath( ID.filename, sDir, sFName, sExt );
|
splitpath( ID.filename, sDir, sFName, sExt );
|
||||||
@@ -200,24 +198,7 @@ void RageTextureManager::ReloadAll()
|
|||||||
for( std::map<RageTextureID, RageTexture*>::iterator i = m_mapPathToTexture.begin();
|
for( std::map<RageTextureID, RageTexture*>::iterator i = m_mapPathToTexture.begin();
|
||||||
i != m_mapPathToTexture.end(); ++i)
|
i != m_mapPathToTexture.end(); ++i)
|
||||||
{
|
{
|
||||||
RageTexture* pTexture = i->second;
|
i->second->Reload();
|
||||||
|
|
||||||
/* A note on how this really works:
|
|
||||||
*
|
|
||||||
* The ID identifies a texture, and all of the parameters needed
|
|
||||||
* to produce it. When we load a texture, iColorDepth is pulled
|
|
||||||
* from GetTextureColorDepth(). Now we're reloading it, probably
|
|
||||||
* due to a change in display settings, so we need to update that
|
|
||||||
* to the current setting and reload it. This will also change
|
|
||||||
* the data in our map (which is OK; it's not part of the ordering)
|
|
||||||
* to reflect this. */
|
|
||||||
|
|
||||||
/* Update the settings that are based on preferences. */
|
|
||||||
RageTextureID ID = i->first;
|
|
||||||
ID.iColorDepth = TEXTUREMAN->GetTextureColorDepth();
|
|
||||||
ID.iMaxSize = TEXTUREMAN->GetMaxTextureResolution();
|
|
||||||
|
|
||||||
pTexture->Reload( ID );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user