diff options
author | Michael Meeks <michael.meeks@collabora.com> | 2015-09-01 15:09:25 +0100 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2015-09-01 14:33:28 +0000 |
commit | eb9e5a863336f9c1a28f5ad59d7e143b16b543fe (patch) | |
tree | e7a910b4c4a4198a8c153153b605ec2eb293fd4b | |
parent | dae95dbb12c84d99819cd3accacf7d8794bf0b9d (diff) |
tdf#93839 - Encourage vdevs to pick up new GL Contexts when they go invalid.
Change-Id: I21726d0dd052fdc87e8dd36ff7122518325f6313
Reviewed-on: https://gerrit.libreoffice.org/18242
Reviewed-by: Jan Holesovsky <kendy@collabora.com>
Tested-by: Jan Holesovsky <kendy@collabora.com>
-rw-r--r-- | vcl/inc/openglgdiimpl.hxx | 2 | ||||
-rw-r--r-- | vcl/inc/salgdiimpl.hxx | 2 | ||||
-rw-r--r-- | vcl/opengl/gdiimpl.cxx | 13 | ||||
-rw-r--r-- | vcl/source/opengl/OpenGLContext.cxx | 3 | ||||
-rw-r--r-- | vcl/win/source/gdi/salgdi.cxx | 2 | ||||
-rw-r--r-- | vcl/win/source/gdi/salvd.cxx | 2 |
6 files changed, 23 insertions, 1 deletions
diff --git a/vcl/inc/openglgdiimpl.hxx b/vcl/inc/openglgdiimpl.hxx index 1809476a41ba..2ed88f1ee645 100644 --- a/vcl/inc/openglgdiimpl.hxx +++ b/vcl/inc/openglgdiimpl.hxx @@ -154,6 +154,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 aa08cf005b08..b29405d73f5f 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 7d71d8bb85f2..0b31dd641d13 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 4f39bef92a38..c4ff6d8d2a0b 100644 --- a/vcl/source/opengl/OpenGLContext.cxx +++ b/vcl/source/opengl/OpenGLContext.cxx @@ -1253,6 +1253,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 64d495282332..99cebeee5fbf 100644 --- a/vcl/win/source/gdi/salgdi.cxx +++ b/vcl/win/source/gdi/salgdi.cxx @@ -502,6 +502,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 ) |