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

Markus Mohrhard markus.mohrhard at collabora.co.uk
Tue Jan 20 03:05:19 PST 2015


 include/vcl/opengl/OpenGLContext.hxx |   11 ++++++++
 include/vcl/virdev.hxx               |    3 --
 vcl/opengl/gdiimpl.cxx               |   16 ++++++++++++
 vcl/source/app/svdata.cxx            |    6 ++++
 vcl/source/app/svmain.cxx            |    6 ++++
 vcl/source/opengl/OpenGLContext.cxx  |   44 ++++++++++++++++++++++++++++-------
 6 files changed, 76 insertions(+), 10 deletions(-)

New commits:
commit 229891d6cbc24f9e6291d8057d0d51326b059d9b
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Tue Jan 20 12:00:59 2015 +0100

    lets do that before we delete our object
    
    Change-Id: I8c7166ba66f74f5c548bb6fb30dfc3d28880e9a2

diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx
index d237249..5df70f4 100644
--- a/vcl/source/opengl/OpenGLContext.cxx
+++ b/vcl/source/opengl/OpenGLContext.cxx
@@ -114,13 +114,14 @@ void OpenGLContext::AddRef(SalGraphicsImpl* pImpl)
 
 void OpenGLContext::DeRef(SalGraphicsImpl* pImpl)
 {
-    assert(mnRefCount > 0);
-    if( --mnRefCount == 0 )
-        delete this;
 
     auto it = maParents.find(pImpl);
     if(it != maParents.end())
         maParents.erase(it);
+
+    assert(mnRefCount > 0);
+    if( --mnRefCount == 0 )
+        delete this;
 }
 #else
 void OpenGLContext::AddRef()
commit 145ad1964389d363e389490be4b9acad1b6b7b99
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Tue Jan 20 04:12:18 2015 +0100

    some debug code for finding leaked OpenGLContexts
    
    Change-Id: I10e8c344ae6aa2e0a4ef562154f57e2070c70e2f

diff --git a/include/vcl/opengl/OpenGLContext.hxx b/include/vcl/opengl/OpenGLContext.hxx
index 18fc710..0178e21 100644
--- a/include/vcl/opengl/OpenGLContext.hxx
+++ b/include/vcl/opengl/OpenGLContext.hxx
@@ -56,9 +56,12 @@ class NSOpenGLView;
 #include <tools/gen.hxx>
 #include <vcl/syschild.hxx>
 
+#include <set>
+
 class OpenGLFramebuffer;
 class OpenGLProgram;
 class OpenGLTexture;
+class SalGraphicsImpl;
 
 /// Holds the information of our new child window
 struct GLWindow
@@ -189,8 +192,13 @@ public:
     bool               AcquireDefaultFramebuffer();
     OpenGLFramebuffer* AcquireFramebuffer( const OpenGLTexture& rTexture );
     void               ReleaseFramebuffer( OpenGLFramebuffer* pFramebuffer );
+#ifdef DBG_UTIL
+    void AddRef(SalGraphicsImpl*);
+    void DeRef(SalGraphicsImpl*);
+#else
     void AddRef();
     void DeRef();
+#endif
     void               ReleaseFramebuffer( const OpenGLTexture& rTexture );
     void               ReleaseFramebuffers();
 
@@ -260,6 +268,9 @@ private:
 
     boost::ptr_map<ProgramKey, OpenGLProgram> maPrograms;
     OpenGLProgram* mpCurrentProgram;
+#ifdef DBG_UTIL
+    std::set<SalGraphicsImpl*> maParents;
+#endif
 
 public:
     vcl::Region maClipRegion;
diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index bae5302..da2ace3 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -80,7 +80,11 @@ bool OpenGLSalGraphicsImpl::AcquireContext( )
     {
         if( mpContext->isInitialized() )
             return true;
+#ifdef DBG_UTIL
+        mpContext->DeRef(this);
+#else
         mpContext->DeRef();
+#endif
     }
 
 
@@ -94,7 +98,13 @@ bool OpenGLSalGraphicsImpl::AcquireContext( )
     }
 
     if( pContext )
+    {
+#ifdef DBG_UTIL
+        pContext->AddRef(this);
+#else
         pContext->AddRef();
+#endif
+    }
     else
         pContext = mbOffscreen ? GetDefaultContext() : CreateWinContext();
 
@@ -105,7 +115,13 @@ bool OpenGLSalGraphicsImpl::AcquireContext( )
 bool OpenGLSalGraphicsImpl::ReleaseContext()
 {
     if( mpContext )
+    {
+#ifdef DBG_UTIL
+        mpContext->DeRef(this);
+#else
         mpContext->DeRef();
+#endif
+    }
     mpContext = NULL;
     return true;
 }
diff --git a/vcl/source/app/svdata.cxx b/vcl/source/app/svdata.cxx
index c539a76..155b5cc 100644
--- a/vcl/source/app/svdata.cxx
+++ b/vcl/source/app/svdata.cxx
@@ -130,7 +130,13 @@ vcl::Window* ImplGetDefaultWindow()
             // Add a reference to the default context so it never gets deleted
             OpenGLContext* pContext = pSVData->mpDefaultWin->GetGraphics()->GetOpenGLContext();
             if( pContext )
+            {
+#ifdef DBG_UTIL
+                pContext->AddRef(NULL);
+#else
                 pContext->AddRef();
+#endif
+            }
         }
         Application::GetSolarMutex().release();
     }
diff --git a/vcl/source/app/svmain.cxx b/vcl/source/app/svmain.cxx
index 8ae3592..c0979a6 100644
--- a/vcl/source/app/svmain.cxx
+++ b/vcl/source/app/svmain.cxx
@@ -444,7 +444,13 @@ void DeInitVCL()
     {
         OpenGLContext* pContext = pSVData->mpDefaultWin->GetGraphics()->GetOpenGLContext();
         if( pContext )
+        {
+#ifdef DBG_UTIL
+            pContext->DeRef(NULL);
+#else
             pContext->DeRef();
+#endif
+        }
         delete pSVData->mpDefaultWin;
         pSVData->mpDefaultWin = NULL;
     }
diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx
index 32d2c28..d237249 100644
--- a/vcl/source/opengl/OpenGLContext.cxx
+++ b/vcl/source/opengl/OpenGLContext.cxx
@@ -103,6 +103,26 @@ OpenGLContext::~OpenGLContext()
         pSVData->maGDIData.mpLastContext = mpPrevContext;
 }
 
+#ifdef DBG_UTIL
+void OpenGLContext::AddRef(SalGraphicsImpl* pImpl)
+{
+    assert(mnRefCount > 0);
+    mnRefCount++;
+
+    maParents.insert(pImpl);
+}
+
+void OpenGLContext::DeRef(SalGraphicsImpl* pImpl)
+{
+    assert(mnRefCount > 0);
+    if( --mnRefCount == 0 )
+        delete this;
+
+    auto it = maParents.find(pImpl);
+    if(it != maParents.end())
+        maParents.erase(it);
+}
+#else
 void OpenGLContext::AddRef()
 {
     assert(mnRefCount > 0);
@@ -115,6 +135,7 @@ void OpenGLContext::DeRef()
     if( --mnRefCount == 0 )
         delete this;
 }
+#endif
 
 void OpenGLContext::requestLegacyContext()
 {
commit 99f809c7eb0a2298f9c0044aeabdfc1bb72e2287
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Tue Jan 20 02:07:52 2015 +0100

    I was just missing the code for the ARB version
    
    Change-Id: Id1a7eef76967a9fdc5279d3c5e7694e6c6b2b907

diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx
index 1812a08..32d2c28 100644
--- a/vcl/source/opengl/OpenGLContext.cxx
+++ b/vcl/source/opengl/OpenGLContext.cxx
@@ -991,8 +991,6 @@ bool OpenGLContext::InitGLEW()
 
 #ifdef DBG_UTIL
     // only enable debug output in dbgutil build
-    // somehow there are implementations where the feature is present and the function
-    // pointer is still NULL
     if( GLEW_ARB_debug_output)
     {
         if (glDebugMessageCallbackARB)
commit 9becabc9bd0ef07fbeb42af7076a1a0a66d767a4
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Tue Jan 20 02:07:06 2015 +0100

    only enable these error handlers in dbgutil builds
    
    They might become expensive with our repeated calls to makeCurrent
    
    Change-Id: I1d30460f2cad34c6ab676754682651422e545c90

diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx
index db4f90e..1812a08 100644
--- a/vcl/source/opengl/OpenGLContext.cxx
+++ b/vcl/source/opengl/OpenGLContext.cxx
@@ -709,7 +709,9 @@ bool OpenGLContext::init(Display* dpy, Pixmap pix, unsigned int width, unsigned
 bool OpenGLContext::ImplInit()
 {
     GLXContext pSharedCtx( NULL );
+#ifdef DBG_UTIL
     TempErrorHandler aErrorHandler(m_aGLWin.dpy, unxErrorHandler);
+#endif
 
     SAL_INFO("vcl.opengl", "OpenGLContext::ImplInit----start");
 
@@ -1341,7 +1343,9 @@ void OpenGLContext::makeCurrent()
 #elif defined( IOS ) || defined( ANDROID )
     // nothing
 #elif defined( UNX )
+#ifdef DBG_UTIL
     TempErrorHandler aErrorHandler(m_aGLWin.dpy, unxErrorHandler);
+#endif
 
     GLXDrawable nDrawable = mbPixmap ? m_aGLWin.glPix : m_aGLWin.win;
     if (!glXMakeCurrent( m_aGLWin.dpy, nDrawable, m_aGLWin.ctx ))
commit 8384350ee6abb69043ec3c063cabdd02c340696d
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Tue Jan 20 02:04:52 2015 +0100

    fix the life cycle of my RAII object
    
    Change-Id: Ifcd4ab79192be965b57439062354e27af80136b3

diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx
index 06001aa..db4f90e 100644
--- a/vcl/source/opengl/OpenGLContext.cxx
+++ b/vcl/source/opengl/OpenGLContext.cxx
@@ -434,9 +434,13 @@ namespace {
 
 int unxErrorHandler(Display* dpy, XErrorEvent* event)
 {
-    char errorString[256];
-    XGetErrorText(dpy, event->type, errorString, 256);
-    SAL_WARN("vcl.opengl", errorString);
+    char err[256];
+    char req[256];
+    char minor[256];
+    XGetErrorText(dpy, event->error_code, err, 256);
+    XGetErrorText(dpy, event->request_code, req, 256);
+    XGetErrorText(dpy, event->minor_code, minor, 256);
+    SAL_WARN("vcl.opengl", "Error: " << err << ", Req: " << req << ", Minor: " << minor);
     return 0;
 }
 
@@ -705,7 +709,7 @@ bool OpenGLContext::init(Display* dpy, Pixmap pix, unsigned int width, unsigned
 bool OpenGLContext::ImplInit()
 {
     GLXContext pSharedCtx( NULL );
-    TempErrorHandler(m_aGLWin.dpy, unxErrorHandler);
+    TempErrorHandler aErrorHandler(m_aGLWin.dpy, unxErrorHandler);
 
     SAL_INFO("vcl.opengl", "OpenGLContext::ImplInit----start");
 
@@ -798,7 +802,7 @@ bool OpenGLContext::ImplInit()
         glXSwapIntervalProc glXSwapInterval = reinterpret_cast<glXSwapIntervalProc>(glXGetProcAddress( reinterpret_cast<const GLubyte*>("glXSwapIntervalSGI") ));
         if( glXSwapInterval )
         {
-            TempErrorHandler(m_aGLWin.dpy, oglErrorHandler);
+            TempErrorHandler aLocalErrorHandler(m_aGLWin.dpy, oglErrorHandler);
 
             errorTriggered = false;
 
@@ -1337,7 +1341,7 @@ void OpenGLContext::makeCurrent()
 #elif defined( IOS ) || defined( ANDROID )
     // nothing
 #elif defined( UNX )
-    TempErrorHandler(m_aGLWin.dpy, unxErrorHandler);
+    TempErrorHandler aErrorHandler(m_aGLWin.dpy, unxErrorHandler);
 
     GLXDrawable nDrawable = mbPixmap ? m_aGLWin.glPix : m_aGLWin.win;
     if (!glXMakeCurrent( m_aGLWin.dpy, nDrawable, m_aGLWin.ctx ))
commit 1bb284fb1443117dab5850d1e00c68d4287a5145
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Tue Jan 20 00:25:16 2015 +0100

    remove wrong comment
    
    Looking into the code we handle more cases correctly so remove this
    misleading comment.
    
    Change-Id: Id738bb8af312dfce97560a43122a81a6708f64d3

diff --git a/include/vcl/virdev.hxx b/include/vcl/virdev.hxx
index b6361bf..5776f5f 100644
--- a/include/vcl/virdev.hxx
+++ b/include/vcl/virdev.hxx
@@ -88,8 +88,7 @@ public:
 
         @param nBitCount
         Bit depth of the generated virtual device. Use 0 here, to
-        indicate: take default screen depth. Only 0 and 1
-        are allowed here, with 1 denoting binary mask.
+        indicate: take default screen depth.
      */
      explicit           VirtualDevice( const OutputDevice& rCompDev,
                                        sal_uInt16 nBitCount = 0 );


More information about the Libreoffice-commits mailing list