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

Michael Meeks michael.meeks at collabora.com
Fri Dec 18 12:29:10 PST 2015


 vcl/inc/svdata.hxx        |    1 +
 vcl/opengl/gdiimpl.cxx    |   12 ++++++++++--
 vcl/source/app/svdata.cxx |   19 ++++++++++---------
 3 files changed, 21 insertions(+), 11 deletions(-)

New commits:
commit 3538e039ea82076202ac4b341fc81ffe0d916f21
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Fri Dec 18 17:25:17 2015 +0000

    vcl: always re-use context from default window.
    
    This avoids problems with the initial default context getting destroyed.
    
    Change-Id: If465dfcd185a3336036b98cb2a205e0502d3f80b
    Reviewed-on: https://gerrit.libreoffice.org/20796
    Reviewed-by: Michael Meeks <michael.meeks at collabora.com>
    Tested-by: Michael Meeks <michael.meeks at collabora.com>

diff --git a/vcl/inc/svdata.hxx b/vcl/inc/svdata.hxx
index 46527f0..b559cf3 100644
--- a/vcl/inc/svdata.hxx
+++ b/vcl/inc/svdata.hxx
@@ -357,6 +357,7 @@ struct ImplSVData
 
 void        ImplDeInitSVData();
 VCL_PLUGIN_PUBLIC vcl::Window* ImplGetDefaultWindow();
+VCL_PLUGIN_PUBLIC vcl::Window* ImplGetDefaultContextWindow();
 VCL_PLUGIN_PUBLIC ResMgr*     ImplGetResMgr();
 VCL_PLUGIN_PUBLIC ResId VclResId( sal_Int32 nId ); // throws std::bad_alloc if no res mgr
 DockingManager*     ImplGetDockingManager();
diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index 41f8e93..1c6be71 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -121,6 +121,8 @@ bool OpenGLSalGraphicsImpl::AcquireContext( bool bForceCreate )
         mpContext.clear();
     }
 
+    // We don't care what context we have - but not switching context
+    // is rather useful from a performance perspective.
     OpenGLContext *pContext = pSVData->maGDIData.mpLastContext;
     while( pContext )
     {
@@ -181,7 +183,10 @@ void OpenGLSalGraphicsImpl::Init()
     }
 
     if( mpWindowContext.is() )
+    {
         mpWindowContext->reset();
+        mpWindowContext.clear();
+    }
 }
 
 // Currently only used to get windows ordering right.
@@ -193,8 +198,11 @@ void OpenGLSalGraphicsImpl::DeInit()
     // let it know. Other eg. VirtualDevice contexts which have
     // references on and rely on this context continuing to work will
     // get a shiny new context in AcquireContext:: next PreDraw.
-    if( mpContext.is() && !IsOffscreen() )
-        mpContext->reset();
+    if( mpWindowContext.is() )
+    {
+        mpWindowContext->reset();
+        mpWindowContext.clear();
+    }
     mpContext.clear();
 }
 
diff --git a/vcl/source/app/svdata.cxx b/vcl/source/app/svdata.cxx
index edfdbc9..fbde610 100644
--- a/vcl/source/app/svdata.cxx
+++ b/vcl/source/app/svdata.cxx
@@ -113,23 +113,25 @@ void ImplDeInitSVData()
         delete pSVData->mpPaperNames, pSVData->mpPaperNames = nullptr;
 }
 
+/// Returns either the application window, or the default GL context window
 vcl::Window* ImplGetDefaultWindow()
 {
     ImplSVData* pSVData = ImplGetSVData();
     if ( pSVData->maWinData.mpAppWin )
         return pSVData->maWinData.mpAppWin;
+    else
+        return ImplGetDefaultContextWindow();
+}
 
-    // First test if we already have a default window.
-    // Don't only place a single if..else inside solar mutex lockframe
-    // because then we might have to wait for the solar mutex what is not necessary
-    // if we already have a default window.
+/// returns the default window created to hold the persistent VCL GL context.
+vcl::Window *ImplGetDefaultContextWindow()
+{
+    ImplSVData* pSVData = ImplGetSVData();
 
+    // Double check locking on mpDefaultWin.
     if ( !pSVData->mpDefaultWin )
     {
-        Application::GetSolarMutex().acquire();
-
-        // Test again because the thread who released the solar mutex could have called
-        // the same method
+        SolarMutexGuard aGuard;
 
         if ( !pSVData->mpDefaultWin && !pSVData->mbDeInit )
         {
@@ -142,7 +144,6 @@ vcl::Window* ImplGetDefaultWindow()
             if( pContext.is() )
                 pContext->acquire();
         }
-        Application::GetSolarMutex().release();
     }
 
     return pSVData->mpDefaultWin;


More information about the Libreoffice-commits mailing list