summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@collabora.com>2015-09-01 15:09:25 +0100
committerMichael Meeks <michael.meeks@collabora.com>2015-09-01 15:16:08 +0100
commit6a12aecf6f7791f00894b08bb394ee0139e10d6f (patch)
treef85f363162ab3da63ce35d7e07dfeb9536f98f5b
parent34ebb26d4c63d73d42d711c9a6e09aae9afae61e (diff)
tdf#93839 - Encourage vdevs to pick up new GL Contexts when they go invalid.
Change-Id: I21726d0dd052fdc87e8dd36ff7122518325f6313
-rw-r--r--vcl/inc/openglgdiimpl.hxx2
-rw-r--r--vcl/inc/salgdiimpl.hxx2
-rw-r--r--vcl/opengl/gdiimpl.cxx13
-rw-r--r--vcl/source/opengl/OpenGLContext.cxx3
-rw-r--r--vcl/win/source/gdi/salgdi.cxx2
-rw-r--r--vcl/win/source/gdi/salvd.cxx2
6 files changed, 23 insertions, 1 deletions
diff --git a/vcl/inc/openglgdiimpl.hxx b/vcl/inc/openglgdiimpl.hxx
index c95453e75aef..62a51e1b6df1 100644
--- a/vcl/inc/openglgdiimpl.hxx
+++ b/vcl/inc/openglgdiimpl.hxx
@@ -153,6 +153,8 @@ public:
virtual void Init() SAL_OVERRIDE;
+ virtual void DeInit() SAL_OVERRIDE;
+
virtual void freeResources() SAL_OVERRIDE;
const vcl::Region& getClipRegion() const;
diff --git a/vcl/inc/salgdiimpl.hxx b/vcl/inc/salgdiimpl.hxx
index 237f60b34736..15dd11ba705b 100644
--- a/vcl/inc/salgdiimpl.hxx
+++ b/vcl/inc/salgdiimpl.hxx
@@ -46,6 +46,8 @@ public:
virtual void Init() = 0;
+ virtual void DeInit() {}
+
virtual void freeResources() = 0;
virtual bool setClipRegion( const vcl::Region& ) = 0;
diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index c16b93bfe1a1..a1508f37cd9b 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -149,6 +149,19 @@ void OpenGLSalGraphicsImpl::Init()
}
}
+// Currently only used to get windows ordering right.
+void OpenGLSalGraphicsImpl::DeInit()
+{
+ // tdf#93839:
+ // Our window handles and resources are being free underneath us.
+ // These can be bound into a context, which relies on them. So
+ // 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 && !IsOffscreen() )
+ mpContext->reset();
+}
+
void OpenGLSalGraphicsImpl::PreDraw()
{
OpenGLZone::enter();
diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx
index d20d6fdcbe53..91ebb755cffc 100644
--- a/vcl/source/opengl/OpenGLContext.cxx
+++ b/vcl/source/opengl/OpenGLContext.cxx
@@ -1165,6 +1165,9 @@ void OpenGLContext::reset()
OpenGLZone aZone;
+ // don't reset a context in the middle of stack frames rendering to it
+ assert( mnPainting == 0 );
+
// reset the clip region
maClipRegion.SetEmpty();
diff --git a/vcl/win/source/gdi/salgdi.cxx b/vcl/win/source/gdi/salgdi.cxx
index cf77cf1e1ae2..58c0f7e0ca91 100644
--- a/vcl/win/source/gdi/salgdi.cxx
+++ b/vcl/win/source/gdi/salgdi.cxx
@@ -497,6 +497,8 @@ void WinSalGraphics::DeInitGraphics()
SelectBrush( getHDC(), mhDefBrush );
if ( mhDefFont )
SelectFont( getHDC(), mhDefFont );
+
+ mpImpl->DeInit();
}
HDC ImplGetCachedDC( sal_uLong nID, HBITMAP hBmp )
diff --git a/vcl/win/source/gdi/salvd.cxx b/vcl/win/source/gdi/salvd.cxx
index ac01d92e86af..2a492b83413b 100644
--- a/vcl/win/source/gdi/salvd.cxx
+++ b/vcl/win/source/gdi/salvd.cxx
@@ -181,7 +181,7 @@ WinSalVirtualDevice::~WinSalVirtualDevice()
// destroy saved DC
if( mpGraphics->getDefPal() )
SelectPalette( mpGraphics->getHDC(), mpGraphics->getDefPal(), TRUE );
- mpGraphics->InitGraphics();
+ mpGraphics->DeInitGraphics();
if( mhDefBmp )
SelectBitmap( mpGraphics->getHDC(), mhDefBmp );
if( !mbForeignDC )