Kaydet (Commit) 3538e039 authored tarafından Michael Meeks's avatar Michael Meeks

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/20796Reviewed-by: 's avatarMichael Meeks <michael.meeks@collabora.com>
Tested-by: 's avatarMichael Meeks <michael.meeks@collabora.com>
üst 3119440a
......@@ -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();
......
......@@ -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();
}
......
......@@ -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;
......
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