[Libreoffice-commits] core.git: 2 commits - include/vcl vcl/inc vcl/opengl vcl/source

Michael Meeks michael.meeks at collabora.com
Mon Aug 31 12:10:12 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 ++++++++++++++++++++
 vcl/source/opengl/OpenGLHelper.cxx   |    1 +
 vcl/source/window/paint.cxx          |    8 ++++++++
 7 files changed, 48 insertions(+), 2 deletions(-)

New commits:
commit 18dd07ba4fd9ede98ce576e6024831658bbd5401
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

diff --git a/include/vcl/opengl/OpenGLContext.hxx b/include/vcl/opengl/OpenGLContext.hxx
index 2f14762..96abe49 100644
--- a/include/vcl/opengl/OpenGLContext.hxx
+++ b/include/vcl/opengl/OpenGLContext.hxx
@@ -191,6 +191,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 385b11a..5d5e870 100644
--- a/vcl/inc/opengl/framebuffer.hxx
+++ b/vcl/inc/opengl/framebuffer.hxx
@@ -34,6 +34,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 4e62915..217b8bf 100644
--- a/vcl/opengl/texture.cxx
+++ b/vcl/opengl/texture.cxx
@@ -108,7 +108,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 8253241..cb05356 100644
--- a/vcl/source/opengl/OpenGLContext.cxx
+++ b/vcl/source/opengl/OpenGLContext.cxx
@@ -1537,6 +1537,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 )
commit 6cf43cf6b98866401702d3275a7a026d8fa01edf
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Sat Aug 29 20:54:21 2015 +0100

    Extended GL painting debug tracing.
    
    Change-Id: I52158729d240ca3cb9e7977bc6d1f5acb14437ad

diff --git a/vcl/source/opengl/OpenGLHelper.cxx b/vcl/source/opengl/OpenGLHelper.cxx
index 68b8d50..3eb8514 100644
--- a/vcl/source/opengl/OpenGLHelper.cxx
+++ b/vcl/source/opengl/OpenGLHelper.cxx
@@ -138,6 +138,7 @@ GLint OpenGLHelper::LoadShaders(const OUString& rVertexShaderName,const OUString
 {
     OpenGLZone aZone;
 
+    VCL_GL_INFO("vcl.opengl", "Load shader: vertex " << rVertexShaderName << " fragment " << rFragmentShaderName);
     // Create the shaders
     GLuint VertexShaderID = glCreateShader(GL_VERTEX_SHADER);
     GLuint FragmentShaderID = glCreateShader(GL_FRAGMENT_SHADER);
diff --git a/vcl/source/window/paint.cxx b/vcl/source/window/paint.cxx
index 2edcd09..8fc4c23 100644
--- a/vcl/source/window/paint.cxx
+++ b/vcl/source/window/paint.cxx
@@ -32,6 +32,7 @@
 #include <salframe.hxx>
 #include <svdata.hxx>
 #include <comphelper/lok.hxx>
+#include <vcl/opengl/OpenGLHelper.hxx>
 
 #define IMPL_PAINT_PAINT            ((sal_uInt16)0x0001)
 #define IMPL_PAINT_PAINTALL         ((sal_uInt16)0x0002)
@@ -245,6 +246,7 @@ void PaintHelper::PaintBuffer()
 void PaintHelper::DoPaint(const vcl::Region* pRegion)
 {
     WindowImpl* pWindowImpl = m_pWindow->ImplGetWindowImpl();
+
     vcl::Region* pWinChildClipRegion = m_pWindow->ImplGetWinChildClipRegion();
     ImplFrameData* pFrameData = m_pWindow->mpWindowImpl->mpFrameData;
     if (pWindowImpl->mnPaintFlags & IMPL_PAINT_PAINTALL || pFrameData->mbInBufferedPaint)
@@ -271,6 +273,9 @@ void PaintHelper::DoPaint(const vcl::Region* pRegion)
     pWindowImpl->mnPaintFlags = 0;
     if (!pWindowImpl->maInvalidateRegion.IsEmpty())
     {
+        VCL_GL_INFO("vcl.opengl", "PaintHelper::DoPaint on " <<
+                    typeid( *m_pWindow ).name() << " '" << m_pWindow->GetText() << "' begin");
+
         m_pWindow->BeginPaint();
 
         // double-buffering: setup the buffer if it does not exist
@@ -302,6 +307,9 @@ void PaintHelper::DoPaint(const vcl::Region* pRegion)
         }
 
         m_pWindow->EndPaint();
+
+        VCL_GL_INFO("vcl.opengl", "PaintHelper::DoPaint end on " <<
+                    typeid( *m_pWindow ).name() << " '" << m_pWindow->GetText() << "'");
     }
 }
 


More information about the Libreoffice-commits mailing list