summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@collabora.com>2015-09-14 18:09:25 +0100
committerAndras Timar <andras.timar@collabora.com>2015-09-19 21:32:18 +0200
commit07806776e04086b7db406ad1a92ed5922050e2aa (patch)
tree080e32e425b0aa8701f73dd47f3a280040c53fb3
parentf4bf1255c989cf51e04ebba8f2349da34ea7616b (diff)
tdf#94213 - defer glFlushing until we've re-rendered after a re-size.
Avoids a rather horrible flickering problem in GL mode. Squashing: 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. Squashing: tdf#94213 - cleanup associated GL contexts properly when DCs released. Change-Id: I6b9fb899777d8e460999ac3ff038a1302e434bb5 Reviewed-on: https://gerrit.libreoffice.org/18607 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Tor Lillqvist <tml@collabora.com>
-rw-r--r--vcl/inc/opengl/win/gdiimpl.hxx1
-rw-r--r--vcl/opengl/gdiimpl.cxx9
-rw-r--r--vcl/opengl/win/gdiimpl.cxx19
-rw-r--r--vcl/source/opengl/OpenGLContext.cxx3
-rw-r--r--vcl/source/window/paint.cxx8
-rw-r--r--vcl/win/source/window/salframe.cxx4
6 files changed, 39 insertions, 5 deletions
diff --git a/vcl/inc/opengl/win/gdiimpl.hxx b/vcl/inc/opengl/win/gdiimpl.hxx
index 04bb15194de6..5c91727f3800 100644
--- a/vcl/inc/opengl/win/gdiimpl.hxx
+++ b/vcl/inc/opengl/win/gdiimpl.hxx
@@ -34,6 +34,7 @@ protected:
virtual bool UseContext( const rtl::Reference<OpenGLContext> &pContext ) SAL_OVERRIDE;
public:
+ virtual void Init() SAL_OVERRIDE;
virtual void copyBits( const SalTwoRect& rPosAry, SalGraphics* pSrcGraphics ) SAL_OVERRIDE;
diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index 85c3a3a1ab13..37b21f36edc1 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..517cff1b853f 100644
--- a/vcl/opengl/win/gdiimpl.cxx
+++ b/vcl/opengl/win/gdiimpl.cxx
@@ -43,7 +43,24 @@ 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");
+ DeInit();
+ }
+
+ OpenGLSalGraphicsImpl::Init();
}
namespace
diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx
index ea9664e43e1f..2502a830a4e4 100644
--- a/vcl/source/opengl/OpenGLContext.cxx
+++ b/vcl/source/opengl/OpenGLContext.cxx
@@ -1690,6 +1690,9 @@ void OpenGLContext::ReleaseFramebuffer( const OpenGLTexture& rTexture )
{
OpenGLZone aZone;
+ if (!rTexture) // no texture to release.
+ return;
+
OpenGLFramebuffer* pFramebuffer = mpLastFramebuffer;
while( pFramebuffer )
diff --git a/vcl/source/window/paint.cxx b/vcl/source/window/paint.cxx
index 80de1a403d8c..ae846ae59a54 100644
--- a/vcl/source/window/paint.cxx
+++ b/vcl/source/window/paint.cxx
@@ -651,6 +651,8 @@ IMPL_LINK_NOARG_TYPED(Window, ImplHandlePaintHdl, Idle *, void)
return;
}
+ BeginPaint();
+
// save paint events until resizing or initial sizing done
if (!ImplDoTiledRendering() && mpWindowImpl->mbFrame &&
(mpWindowImpl->mpFrameData->maResizeIdle.IsActive() ||
@@ -662,12 +664,16 @@ IMPL_LINK_NOARG_TYPED(Window, ImplHandlePaintHdl, Idle *, void)
{
ImplCallOverlapPaint();
}
+
+ EndPaint();
}
IMPL_LINK_NOARG_TYPED(Window, ImplHandleResizeTimerHdl, Idle *, void)
{
if( mpWindowImpl->mbReallyVisible )
{
+ BeginPaint();
+
ImplCallResize();
if( ImplDoTiledRendering() )
{
@@ -678,6 +684,8 @@ IMPL_LINK_NOARG_TYPED(Window, ImplHandleResizeTimerHdl, Idle *, void)
mpWindowImpl->mpFrameData->maPaintIdle.Stop();
mpWindowImpl->mpFrameData->maPaintIdle.GetIdleHdl().Call( NULL );
}
+
+ EndPaint();
}
}
diff --git a/vcl/win/source/window/salframe.cxx b/vcl/win/source/window/salframe.cxx
index f8e0b69623e6..0a6fb73a8f50 100644
--- a/vcl/win/source/window/salframe.cxx
+++ b/vcl/win/source/window/salframe.cxx
@@ -1048,7 +1048,7 @@ void WinSalFrame::ReleaseGraphics( SalGraphics* pGraphics )
SalData* pSalData = GetSalData();
if ( mpGraphics2->getDefPal() )
SelectPalette( mpGraphics2->getHDC(), mpGraphics2->getDefPal(), TRUE );
- mpGraphics2->InitGraphics();
+ mpGraphics2->DeInitGraphics();
SendMessageW( pSalData->mpFirstInstance->mhComWnd,
SAL_MSG_RELEASEDC,
(WPARAM)mhWnd,
@@ -1498,7 +1498,7 @@ static void ImplSetParentFrame( WinSalFrame* pThis, HWND hNewParentWnd, bool bAs
{
if ( pThis->mpGraphics->getDefPal() )
SelectPalette( pThis->mpGraphics->getHDC(), pThis->mpGraphics->getDefPal(), TRUE );
- pThis->mpGraphics->InitGraphics();
+ pThis->mpGraphics->DeInitGraphics();
ReleaseDC( pThis->mhWnd, pThis->mpGraphics->getHDC() );
}