diff options
author | Michael Meeks <michael.meeks@collabora.com> | 2015-09-15 14:07:27 +0100 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2015-09-16 02:00:16 +0000 |
commit | 6f0f4ee720ef1e8262731f59f254b83d5bdd058c (patch) | |
tree | cee592beb82cd65ba34661ea1c809bc296316443 /vcl/opengl | |
parent | a60db559d409514fb93af0167c543ad2f852b499 (diff) |
tdf#94213 - release offscreen texture properly on re-size.
We need to ensure that we use an initialized context, and that
(when we re-parent) we DeInit and so reset the previous OpenGLContext.
Make UseContext more paranoid as well for good measure.
Change-Id: Ia45334222045e5d2f48da47560fab8511223a9a5
Reviewed-on: https://gerrit.libreoffice.org/18601
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Diffstat (limited to 'vcl/opengl')
-rw-r--r-- | vcl/opengl/gdiimpl.cxx | 9 | ||||
-rw-r--r-- | vcl/opengl/win/gdiimpl.cxx | 18 |
2 files changed, 24 insertions, 3 deletions
diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx index 6580f43f556a..943e1b43fe21 100644 --- a/vcl/opengl/gdiimpl.cxx +++ b/vcl/opengl/gdiimpl.cxx @@ -115,7 +115,8 @@ void OpenGLSalGraphicsImpl::Init() // check if we can simply re-use the same context if( mpContext.is() ) { - if( !UseContext( mpContext ) ) + if( !mpContext->isInitialized() || + !UseContext( mpContext ) ) ReleaseContext(); } @@ -124,8 +125,12 @@ void OpenGLSalGraphicsImpl::Init() maOffscreenTex.GetWidth() != GetWidth() || maOffscreenTex.GetHeight() != GetHeight() ) { - if( mpContext.is() ) // valid context + if( maOffscreenTex && // don't work to release empty textures + mpContext.is() ) // valid context + { + mpContext->makeCurrent(); mpContext->ReleaseFramebuffer( maOffscreenTex ); + } maOffscreenTex = OpenGLTexture(); } } diff --git a/vcl/opengl/win/gdiimpl.cxx b/vcl/opengl/win/gdiimpl.cxx index 30088a9deb88..3ba269487ea9 100644 --- a/vcl/opengl/win/gdiimpl.cxx +++ b/vcl/opengl/win/gdiimpl.cxx @@ -43,7 +43,23 @@ bool WinOpenGLSalGraphicsImpl::UseContext( const rtl::Reference<OpenGLContext> & return false; if( IsOffscreen() ) return true; - return pContext->getOpenGLWindow().hWnd == mrParent.mhWnd; + return pContext->getOpenGLWindow().hWnd == mrParent.mhWnd && + pContext->getOpenGLWindow().hDC == mrParent.mhLocalDC; +} + +void WinOpenGLSalGraphicsImpl::Init() +{ + if ( !IsOffscreen() && mpContext.is() && mpContext->isInitialized() && + ( mpContext->getOpenGLWindow().hWnd != mrParent.mhWnd || + mpContext->getOpenGLWindow().hDC == mrParent.mhLocalDC ) ) + { + // This can legitimiately happen, SalFrame keeps 2x + // SalGraphics which share the same hWnd and hDC. + // The shape 'Area' dialog does reparenting to trigger this. + SAL_WARN("vcl.opengl", "Unusual: Windows handle / DC changed without DeInit"); + } + + OpenGLSalGraphicsImpl::Init(); } namespace |