Kaydet (Commit) d419639b authored tarafından Michael Meeks's avatar Michael Meeks Kaydeden (comit) Andras Timar

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/18607Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarTor Lillqvist <tml@collabora.com>
üst d58e3c72
...@@ -34,6 +34,7 @@ protected: ...@@ -34,6 +34,7 @@ protected:
virtual bool UseContext( const rtl::Reference<OpenGLContext> &pContext ) SAL_OVERRIDE; virtual bool UseContext( const rtl::Reference<OpenGLContext> &pContext ) SAL_OVERRIDE;
public: public:
virtual void Init() SAL_OVERRIDE;
virtual void copyBits( const SalTwoRect& rPosAry, SalGraphics* pSrcGraphics ) SAL_OVERRIDE; virtual void copyBits( const SalTwoRect& rPosAry, SalGraphics* pSrcGraphics ) SAL_OVERRIDE;
......
...@@ -115,7 +115,8 @@ void OpenGLSalGraphicsImpl::Init() ...@@ -115,7 +115,8 @@ void OpenGLSalGraphicsImpl::Init()
// check if we can simply re-use the same context // check if we can simply re-use the same context
if( mpContext.is() ) if( mpContext.is() )
{ {
if( !UseContext( mpContext ) ) if( !mpContext->isInitialized() ||
!UseContext( mpContext ) )
ReleaseContext(); ReleaseContext();
} }
...@@ -124,8 +125,12 @@ void OpenGLSalGraphicsImpl::Init() ...@@ -124,8 +125,12 @@ void OpenGLSalGraphicsImpl::Init()
maOffscreenTex.GetWidth() != GetWidth() || maOffscreenTex.GetWidth() != GetWidth() ||
maOffscreenTex.GetHeight() != GetHeight() ) 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 ); mpContext->ReleaseFramebuffer( maOffscreenTex );
}
maOffscreenTex = OpenGLTexture(); maOffscreenTex = OpenGLTexture();
} }
} }
......
...@@ -43,7 +43,24 @@ bool WinOpenGLSalGraphicsImpl::UseContext( const rtl::Reference<OpenGLContext> & ...@@ -43,7 +43,24 @@ bool WinOpenGLSalGraphicsImpl::UseContext( const rtl::Reference<OpenGLContext> &
return false; return false;
if( IsOffscreen() ) if( IsOffscreen() )
return true; 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 namespace
......
...@@ -1690,6 +1690,9 @@ void OpenGLContext::ReleaseFramebuffer( const OpenGLTexture& rTexture ) ...@@ -1690,6 +1690,9 @@ void OpenGLContext::ReleaseFramebuffer( const OpenGLTexture& rTexture )
{ {
OpenGLZone aZone; OpenGLZone aZone;
if (!rTexture) // no texture to release.
return;
OpenGLFramebuffer* pFramebuffer = mpLastFramebuffer; OpenGLFramebuffer* pFramebuffer = mpLastFramebuffer;
while( pFramebuffer ) while( pFramebuffer )
......
...@@ -651,6 +651,8 @@ IMPL_LINK_NOARG_TYPED(Window, ImplHandlePaintHdl, Idle *, void) ...@@ -651,6 +651,8 @@ IMPL_LINK_NOARG_TYPED(Window, ImplHandlePaintHdl, Idle *, void)
return; return;
} }
BeginPaint();
// save paint events until resizing or initial sizing done // save paint events until resizing or initial sizing done
if (!ImplDoTiledRendering() && mpWindowImpl->mbFrame && if (!ImplDoTiledRendering() && mpWindowImpl->mbFrame &&
(mpWindowImpl->mpFrameData->maResizeIdle.IsActive() || (mpWindowImpl->mpFrameData->maResizeIdle.IsActive() ||
...@@ -662,12 +664,16 @@ IMPL_LINK_NOARG_TYPED(Window, ImplHandlePaintHdl, Idle *, void) ...@@ -662,12 +664,16 @@ IMPL_LINK_NOARG_TYPED(Window, ImplHandlePaintHdl, Idle *, void)
{ {
ImplCallOverlapPaint(); ImplCallOverlapPaint();
} }
EndPaint();
} }
IMPL_LINK_NOARG_TYPED(Window, ImplHandleResizeTimerHdl, Idle *, void) IMPL_LINK_NOARG_TYPED(Window, ImplHandleResizeTimerHdl, Idle *, void)
{ {
if( mpWindowImpl->mbReallyVisible ) if( mpWindowImpl->mbReallyVisible )
{ {
BeginPaint();
ImplCallResize(); ImplCallResize();
if( ImplDoTiledRendering() ) if( ImplDoTiledRendering() )
{ {
...@@ -678,6 +684,8 @@ IMPL_LINK_NOARG_TYPED(Window, ImplHandleResizeTimerHdl, Idle *, void) ...@@ -678,6 +684,8 @@ IMPL_LINK_NOARG_TYPED(Window, ImplHandleResizeTimerHdl, Idle *, void)
mpWindowImpl->mpFrameData->maPaintIdle.Stop(); mpWindowImpl->mpFrameData->maPaintIdle.Stop();
mpWindowImpl->mpFrameData->maPaintIdle.GetIdleHdl().Call( NULL ); mpWindowImpl->mpFrameData->maPaintIdle.GetIdleHdl().Call( NULL );
} }
EndPaint();
} }
} }
......
...@@ -1048,7 +1048,7 @@ void WinSalFrame::ReleaseGraphics( SalGraphics* pGraphics ) ...@@ -1048,7 +1048,7 @@ void WinSalFrame::ReleaseGraphics( SalGraphics* pGraphics )
SalData* pSalData = GetSalData(); SalData* pSalData = GetSalData();
if ( mpGraphics2->getDefPal() ) if ( mpGraphics2->getDefPal() )
SelectPalette( mpGraphics2->getHDC(), mpGraphics2->getDefPal(), TRUE ); SelectPalette( mpGraphics2->getHDC(), mpGraphics2->getDefPal(), TRUE );
mpGraphics2->InitGraphics(); mpGraphics2->DeInitGraphics();
SendMessageW( pSalData->mpFirstInstance->mhComWnd, SendMessageW( pSalData->mpFirstInstance->mhComWnd,
SAL_MSG_RELEASEDC, SAL_MSG_RELEASEDC,
(WPARAM)mhWnd, (WPARAM)mhWnd,
...@@ -1498,7 +1498,7 @@ static void ImplSetParentFrame( WinSalFrame* pThis, HWND hNewParentWnd, bool bAs ...@@ -1498,7 +1498,7 @@ static void ImplSetParentFrame( WinSalFrame* pThis, HWND hNewParentWnd, bool bAs
{ {
if ( pThis->mpGraphics->getDefPal() ) if ( pThis->mpGraphics->getDefPal() )
SelectPalette( pThis->mpGraphics->getHDC(), pThis->mpGraphics->getDefPal(), TRUE ); SelectPalette( pThis->mpGraphics->getHDC(), pThis->mpGraphics->getDefPal(), TRUE );
pThis->mpGraphics->InitGraphics(); pThis->mpGraphics->DeInitGraphics();
ReleaseDC( pThis->mhWnd, pThis->mpGraphics->getHDC() ); ReleaseDC( pThis->mhWnd, pThis->mpGraphics->getHDC() );
} }
......
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