Kaydet (Commit) 0a3cfc66 authored tarafından Michael Meeks's avatar Michael Meeks Kaydeden (comit) Jan Holesovsky

tdf#93751 - ensure textures are unbound from framebuffers post destroy.

Change-Id: I81aec0e6f8db57905826c54c3442528be6068700
Reviewed-on: https://gerrit.libreoffice.org/18184Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarJan Holesovsky <kendy@collabora.com>
üst 3253cc2b
...@@ -193,6 +193,7 @@ public: ...@@ -193,6 +193,7 @@ public:
bool AcquireDefaultFramebuffer(); bool AcquireDefaultFramebuffer();
OpenGLFramebuffer* AcquireFramebuffer( const OpenGLTexture& rTexture ); OpenGLFramebuffer* AcquireFramebuffer( const OpenGLTexture& rTexture );
static void ReleaseFramebuffer( OpenGLFramebuffer* pFramebuffer ); static void ReleaseFramebuffer( OpenGLFramebuffer* pFramebuffer );
void UnbindTextureFromFramebuffers( GLuint nTexture );
#ifdef DBG_UTIL #ifdef DBG_UTIL
void AddRef(SalGraphicsImpl*); void AddRef(SalGraphicsImpl*);
void DeRef(SalGraphicsImpl*); void DeRef(SalGraphicsImpl*);
......
...@@ -35,6 +35,7 @@ public: ...@@ -35,6 +35,7 @@ public:
static void Unbind(); static void Unbind();
bool IsFree() const; bool IsFree() const;
bool IsAttached( GLuint nTexture ) const;
bool IsAttached( const OpenGLTexture& rTexture ) const; bool IsAttached( const OpenGLTexture& rTexture ) const;
void AttachTexture( const OpenGLTexture& rTexture ); void AttachTexture( const OpenGLTexture& rTexture );
void DetachTexture(); void DetachTexture();
......
...@@ -46,12 +46,17 @@ void OpenGLFramebuffer::Unbind() ...@@ -46,12 +46,17 @@ void OpenGLFramebuffer::Unbind()
bool OpenGLFramebuffer::IsFree() const bool OpenGLFramebuffer::IsFree() const
{ {
return (!mnAttachedTexture); return !mnAttachedTexture;
}
bool OpenGLFramebuffer::IsAttached( GLuint nTexture ) const
{
return mnAttachedTexture == nTexture;
} }
bool OpenGLFramebuffer::IsAttached( const OpenGLTexture& rTexture ) const bool OpenGLFramebuffer::IsAttached( const OpenGLTexture& rTexture ) const
{ {
return ( mnAttachedTexture == rTexture.Id() ); return mnAttachedTexture == rTexture.Id();
} }
void OpenGLFramebuffer::AttachTexture( const OpenGLTexture& rTexture ) void OpenGLFramebuffer::AttachTexture( const OpenGLTexture& rTexture )
......
...@@ -107,7 +107,17 @@ ImplOpenGLTexture::~ImplOpenGLTexture() ...@@ -107,7 +107,17 @@ ImplOpenGLTexture::~ImplOpenGLTexture()
{ {
VCL_GL_INFO( "vcl.opengl", "~OpenGLTexture " << mnTexture ); VCL_GL_INFO( "vcl.opengl", "~OpenGLTexture " << mnTexture );
if( mnTexture != 0 ) if( mnTexture != 0 )
{
// FIXME: this is really not optimal performance-wise.
// Check we have been correctly un-bound from all framebuffers.
ImplSVData* pSVData = ImplGetSVData();
OpenGLContext* pContext = pSVData->maGDIData.mpLastContext;
if (pContext)
pContext->UnbindTextureFromFramebuffers( mnTexture );
glDeleteTextures( 1, &mnTexture ); glDeleteTextures( 1, &mnTexture );
}
} }
bool ImplOpenGLTexture::InsertBuffer(int nX, int nY, int nWidth, int nHeight, int nFormat, int nType, sal_uInt8* pData) bool ImplOpenGLTexture::InsertBuffer(int nX, int nY, int nWidth, int nHeight, int nFormat, int nType, sal_uInt8* pData)
......
...@@ -1625,6 +1625,26 @@ OpenGLFramebuffer* OpenGLContext::AcquireFramebuffer( const OpenGLTexture& rText ...@@ -1625,6 +1625,26 @@ OpenGLFramebuffer* OpenGLContext::AcquireFramebuffer( const OpenGLTexture& rText
return pFramebuffer; return pFramebuffer;
} }
// FIXME: this method is rather grim from a perf. perspective.
// We should instead (eventually) use pointers to associate the
// framebuffer and texture cleanly.
void OpenGLContext::UnbindTextureFromFramebuffers( GLuint nTexture )
{
OpenGLFramebuffer* pFramebuffer;
// see if there is a framebuffer attached to that texture
pFramebuffer = mpLastFramebuffer;
while( pFramebuffer )
{
if (pFramebuffer->IsAttached(nTexture))
{
BindFramebuffer(pFramebuffer);
pFramebuffer->DetachTexture();
}
pFramebuffer = pFramebuffer->mpPrevFramebuffer;
}
}
void OpenGLContext::ReleaseFramebuffer( OpenGLFramebuffer* pFramebuffer ) void OpenGLContext::ReleaseFramebuffer( OpenGLFramebuffer* pFramebuffer )
{ {
if( pFramebuffer ) if( pFramebuffer )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment