[Libreoffice-commits] core.git: Branch 'libreoffice-5-0' - include/vcl vcl/inc vcl/opengl vcl/source

Michael Meeks michael.meeks at collabora.com
Tue Sep 1 00:41:56 PDT 2015


 include/vcl/opengl/OpenGLContext.hxx |    1 +
 vcl/inc/opengl/framebuffer.hxx       |    1 +
 vcl/opengl/framebuffer.cxx           |    9 +++++++--
 vcl/opengl/texture.cxx               |   10 ++++++++++
 vcl/source/opengl/OpenGLContext.cxx  |   20 ++++++++++++++++++++
 5 files changed, 39 insertions(+), 2 deletions(-)

New commits:
commit 0a3cfc66d5c82e5c44ef5220bdbe4344b9d1e2ce
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Mon Aug 31 12:11:50 2015 +0100

    tdf#93751 - ensure textures are unbound from framebuffers post destroy.
    
    Change-Id: I81aec0e6f8db57905826c54c3442528be6068700
    Reviewed-on: https://gerrit.libreoffice.org/18184
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Jan Holesovsky <kendy at collabora.com>

diff --git a/include/vcl/opengl/OpenGLContext.hxx b/include/vcl/opengl/OpenGLContext.hxx
index 73434a0..8c756b7 100644
--- a/include/vcl/opengl/OpenGLContext.hxx
+++ b/include/vcl/opengl/OpenGLContext.hxx
@@ -193,6 +193,7 @@ public:
     bool               AcquireDefaultFramebuffer();
     OpenGLFramebuffer* AcquireFramebuffer( const OpenGLTexture& rTexture );
     static void        ReleaseFramebuffer( OpenGLFramebuffer* pFramebuffer );
+    void UnbindTextureFromFramebuffers( GLuint nTexture );
 #ifdef DBG_UTIL
     void AddRef(SalGraphicsImpl*);
     void DeRef(SalGraphicsImpl*);
diff --git a/vcl/inc/opengl/framebuffer.hxx b/vcl/inc/opengl/framebuffer.hxx
index 4e8f9cc..89bf1a4 100644
--- a/vcl/inc/opengl/framebuffer.hxx
+++ b/vcl/inc/opengl/framebuffer.hxx
@@ -35,6 +35,7 @@ public:
     static void Unbind();
 
     bool    IsFree() const;
+    bool    IsAttached( GLuint nTexture ) const;
     bool    IsAttached( const OpenGLTexture& rTexture ) const;
     void    AttachTexture( const OpenGLTexture& rTexture );
     void    DetachTexture();
diff --git a/vcl/opengl/framebuffer.cxx b/vcl/opengl/framebuffer.cxx
index 87af985..7e19981 100644
--- a/vcl/opengl/framebuffer.cxx
+++ b/vcl/opengl/framebuffer.cxx
@@ -46,12 +46,17 @@ void OpenGLFramebuffer::Unbind()
 
 bool OpenGLFramebuffer::IsFree() const
 {
-    return (!mnAttachedTexture);
+    return !mnAttachedTexture;
+}
+
+bool OpenGLFramebuffer::IsAttached( GLuint nTexture ) const
+{
+    return mnAttachedTexture == nTexture;
 }
 
 bool OpenGLFramebuffer::IsAttached( const OpenGLTexture& rTexture ) const
 {
-    return ( mnAttachedTexture == rTexture.Id() );
+    return mnAttachedTexture == rTexture.Id();
 }
 
 void OpenGLFramebuffer::AttachTexture( const OpenGLTexture& rTexture )
diff --git a/vcl/opengl/texture.cxx b/vcl/opengl/texture.cxx
index 5861f76..b33d990 100644
--- a/vcl/opengl/texture.cxx
+++ b/vcl/opengl/texture.cxx
@@ -107,7 +107,17 @@ ImplOpenGLTexture::~ImplOpenGLTexture()
 {
     VCL_GL_INFO( "vcl.opengl", "~OpenGLTexture " << mnTexture );
     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 );
+    }
 }
 
 bool ImplOpenGLTexture::InsertBuffer(int nX, int nY, int nWidth, int nHeight, int nFormat, int nType, sal_uInt8* pData)
diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx
index 20b510f..8f3cce8 100644
--- a/vcl/source/opengl/OpenGLContext.cxx
+++ b/vcl/source/opengl/OpenGLContext.cxx
@@ -1625,6 +1625,26 @@ OpenGLFramebuffer* OpenGLContext::AcquireFramebuffer( const OpenGLTexture& rText
     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 )
 {
     if( pFramebuffer )


More information about the Libreoffice-commits mailing list