[Libreoffice-commits] core.git: Branch 'feature/fixes10' - include/vcl slideshow/source vcl/inc vcl/opengl vcl/source vcl/unx vcl/win
Michael Meeks
michael.meeks at collabora.com
Wed Sep 16 02:45:29 PDT 2015
include/vcl/outdev.hxx | 18 +++
slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionerImpl.cxx | 2
vcl/inc/generic/genpspgraphics.h | 3
vcl/inc/headless/svpgdi.hxx | 3
vcl/inc/openglgdiimpl.hxx | 3
vcl/inc/quartz/salgdi.h | 3
vcl/inc/salgdi.hxx | 3
vcl/inc/salgdiimpl.hxx | 4
vcl/inc/unx/salgdi.h | 3
vcl/inc/win/salgdi.h | 3
vcl/opengl/gdiimpl.cxx | 37 +++-----
vcl/opengl/win/gdiimpl.cxx | 1
vcl/source/opengl/OpenGLHelper.cxx | 46 +++++++++-
vcl/source/outdev/outdev.cxx | 12 --
vcl/source/window/paint.cxx | 16 ---
vcl/unx/generic/gdi/gdiimpl.hxx | 3
vcl/unx/generic/gdi/salgdi.cxx | 7 -
vcl/win/source/gdi/gdiimpl.hxx | 3
vcl/win/source/gdi/salgdi.cxx | 7 -
vcl/win/source/window/salframe.cxx | 2
20 files changed, 90 insertions(+), 89 deletions(-)
New commits:
commit 60d91a56430f55128003f2a5331db5390fcd2663
Author: Michael Meeks <michael.meeks at collabora.com>
Date: Wed Sep 16 09:13:11 2015 +0100
Squash 4x patches for quicker testing.
tdf#94213 - cleanup associated GL contexts properly when DCs released.
Change-Id: I6b9fb899777d8e460999ac3ff038a1302e434bb5
tdf#94006 - need an explicit dispose for slideshow's GLContext.
Fixes crasher exiting slideshow.
Change-Id: I14b6a2c1abc946f590bf91cab19099753172fd95
tdf#94252 - avoid switching contexts un-necessarily to reduce flicker.
Change-Id: Id4ac387174fa03c5886a990d89fd53a4f18db11c
GL paint-flushing guard re-work.
Unfortunately, since we can have 2x SalGraphics' on a OutputDevice,
and one of these can be a printer - things got very confused around
which context to glFlush. This de-tangles the various reference-counts.
Change-Id: I1062be0b02a91fc9009deaa3ec29c5dbb227df20
diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx
index f0057b3..dbd57e6 100644
--- a/include/vcl/outdev.hxx
+++ b/include/vcl/outdev.hxx
@@ -608,9 +608,21 @@ public:
const Point& rSrcPt, const Size& rSrcSize,
bool bWindowInvalidate = false );
- // Call before and after a paint operation to reduce flushing
- void BeginPaint();
- void EndPaint();
+ /**
+ * Instantiate across a paint operation to defer flushing
+ * to the end.
+ *
+ * NB. holding a handle avoids problems with
+ * the underlying SalGraphics and it's implementation
+ * changing.
+ */
+ class PaintScope {
+ void *pHandle;
+ public:
+ PaintScope(OutputDevice *);
+ ~PaintScope();
+ void flush();
+ };
protected:
diff --git a/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionerImpl.cxx b/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionerImpl.cxx
index f468f87..e57ed70 100644
--- a/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionerImpl.cxx
+++ b/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionerImpl.cxx
@@ -1324,6 +1324,8 @@ void OGLTransitionerImpl::impl_dispose()
{
impl_finishTransition();
disposeTextures();
+ if( mpContext.is() )
+ mpContext->dispose();
mpContext.clear();
}
diff --git a/vcl/inc/generic/genpspgraphics.h b/vcl/inc/generic/genpspgraphics.h
index 8b78faa..2049e26 100644
--- a/vcl/inc/generic/genpspgraphics.h
+++ b/vcl/inc/generic/genpspgraphics.h
@@ -208,9 +208,6 @@ public:
virtual css::uno::Any GetNativeSurfaceHandle(cairo::SurfaceSharedPtr& rSurface, const basegfx::B2ISize& rSize) const SAL_OVERRIDE;
virtual SystemFontData GetSysFontData( int nFallbacklevel ) const SAL_OVERRIDE;
-
- virtual void BeginPaint() SAL_OVERRIDE { };
- virtual void EndPaint() SAL_OVERRIDE { };
};
#endif // INCLUDED_VCL_INC_GENERIC_GENPSPGRAPHICS_H
diff --git a/vcl/inc/headless/svpgdi.hxx b/vcl/inc/headless/svpgdi.hxx
index 9b8a25a..f4503e8 100644
--- a/vcl/inc/headless/svpgdi.hxx
+++ b/vcl/inc/headless/svpgdi.hxx
@@ -215,9 +215,6 @@ public:
void clipRegion(cairo_t* cr);
#endif // ENABLE_CAIRO_CANVAS
-
- virtual void BeginPaint() SAL_OVERRIDE { };
- virtual void EndPaint() SAL_OVERRIDE { };
};
#endif
diff --git a/vcl/inc/openglgdiimpl.hxx b/vcl/inc/openglgdiimpl.hxx
index e16dd61..55f2e70 100644
--- a/vcl/inc/openglgdiimpl.hxx
+++ b/vcl/inc/openglgdiimpl.hxx
@@ -326,8 +326,7 @@ public:
virtual bool drawGradient(const tools::PolyPolygon& rPolygon, const Gradient& rGradient) SAL_OVERRIDE;
- virtual void beginPaint() SAL_OVERRIDE;
- virtual void endPaint() SAL_OVERRIDE;
+ virtual OpenGLContext *beginPaint() SAL_OVERRIDE;
private:
};
diff --git a/vcl/inc/quartz/salgdi.h b/vcl/inc/quartz/salgdi.h
index 12c3144..518390c 100644
--- a/vcl/inc/quartz/salgdi.h
+++ b/vcl/inc/quartz/salgdi.h
@@ -421,9 +421,6 @@ public:
virtual css::uno::Any GetNativeSurfaceHandle(cairo::SurfaceSharedPtr& rSurface, const ::basegfx::B2ISize& rSize) const SAL_OVERRIDE;
virtual SystemFontData GetSysFontData( int /* nFallbacklevel */ ) const SAL_OVERRIDE;
- virtual void BeginPaint() SAL_OVERRIDE { };
- virtual void EndPaint() SAL_OVERRIDE { };
-
private:
// differences between VCL, Quartz and kHiThemeOrientation coordinate systems
// make some graphics seem to be vertically-mirrored from a VCL perspective
diff --git a/vcl/inc/salgdi.hxx b/vcl/inc/salgdi.hxx
index f00aae4..afd3b42 100644
--- a/vcl/inc/salgdi.hxx
+++ b/vcl/inc/salgdi.hxx
@@ -433,8 +433,7 @@ public:
sal_uInt8 nTransparency,
const OutputDevice *pOutDev );
- virtual void BeginPaint() = 0;
- virtual void EndPaint() = 0;
+ virtual OpenGLContext *BeginPaint() { return NULL; }
virtual SystemGraphicsData GetGraphicsData() const = 0;
diff --git a/vcl/inc/salgdiimpl.hxx b/vcl/inc/salgdiimpl.hxx
index b29405d..97daa80 100644
--- a/vcl/inc/salgdiimpl.hxx
+++ b/vcl/inc/salgdiimpl.hxx
@@ -36,6 +36,7 @@ class SalGraphics;
class SalBitmap;
class SalFrame;
class Gradient;
+class OpenGLContext;
class SalVirtualDevice;
class VCL_PLUGIN_PUBLIC SalGraphicsImpl
@@ -216,8 +217,7 @@ public:
virtual bool drawGradient(const tools::PolyPolygon& rPolygon, const Gradient& rGradient) = 0;
- virtual void beginPaint() = 0;
- virtual void endPaint() = 0;
+ virtual OpenGLContext *beginPaint() { return NULL; }
};
#endif
diff --git a/vcl/inc/unx/salgdi.h b/vcl/inc/unx/salgdi.h
index a44ef1e..84f1e8f 100644
--- a/vcl/inc/unx/salgdi.h
+++ b/vcl/inc/unx/salgdi.h
@@ -269,8 +269,7 @@ public:
virtual css::uno::Any GetNativeSurfaceHandle(cairo::SurfaceSharedPtr& rSurface, const basegfx::B2ISize& rSize) const SAL_OVERRIDE;
virtual SystemFontData GetSysFontData( int nFallbackLevel ) const SAL_OVERRIDE;
- virtual void BeginPaint() SAL_OVERRIDE;
- virtual void EndPaint() SAL_OVERRIDE;
+ virtual OpenGLContext *BeginPaint() SAL_OVERRIDE;
bool TryRenderCachedNativeControl(ControlCacheKey& aControlCacheKey,
int nX, int nY);
diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h
index f499a31..18b7ecf 100644
--- a/vcl/inc/win/salgdi.h
+++ b/vcl/inc/win/salgdi.h
@@ -445,8 +445,7 @@ public:
virtual css::uno::Any GetNativeSurfaceHandle(cairo::SurfaceSharedPtr& rSurface, const ::basegfx::B2ISize& rSize) const SAL_OVERRIDE;
virtual SystemFontData GetSysFontData( int nFallbacklevel ) const SAL_OVERRIDE;
- virtual void BeginPaint() SAL_OVERRIDE;
- virtual void EndPaint() SAL_OVERRIDE;
+ virtual OpenGLContext *BeginPaint() SAL_OVERRIDE;
/// Update settings based on the platform values
static void updateSettingsNative( AllSettings& rSettings );
diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index 4e29a7e..7d664c7 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -77,8 +77,17 @@ bool OpenGLSalGraphicsImpl::AcquireContext( )
{
ImplSVData* pSVData = ImplGetSVData();
+ // We always prefer to bind our VirtualDevice / offscreen graphics
+ // to the current OpenGLContext - to avoid switching contexts.
+ if (mpContext.is() && mbOffscreen)
+ {
+ if (OpenGLContext::hasCurrent() && !mpContext->isCurrent())
+ mpContext.clear();
+ }
+
if( mpContext.is() )
{
+ // Check whether the context was reset underneath us.
if( mpContext->isInitialized() )
return true;
mpContext.clear();
@@ -1858,30 +1867,12 @@ bool OpenGLSalGraphicsImpl::drawGradient(const tools::PolyPolygon& rPolyPoly,
return true;
}
-void OpenGLSalGraphicsImpl::beginPaint()
-{
- if( !AcquireContext() )
- return;
-
- mpContext->mnPainting++;
-}
-
-void OpenGLSalGraphicsImpl::endPaint()
+OpenGLContext *OpenGLSalGraphicsImpl::beginPaint()
{
- if( !AcquireContext() )
- return;
-
- mpContext->mnPainting--;
- assert( mpContext->mnPainting >= 0 );
- if( mpContext->mnPainting == 0 && !mbOffscreen )
- {
- mpContext->makeCurrent();
- mpContext->AcquireDefaultFramebuffer();
- glFlush();
- mpContext->swapBuffers();
-
- CHECK_GL_ERROR();
- }
+ if( mbOffscreen || !AcquireContext() )
+ return NULL;
+ else
+ return mpContext.get();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/opengl/win/gdiimpl.cxx b/vcl/opengl/win/gdiimpl.cxx
index 3ba2694..517cff1 100644
--- a/vcl/opengl/win/gdiimpl.cxx
+++ b/vcl/opengl/win/gdiimpl.cxx
@@ -57,6 +57,7 @@ void WinOpenGLSalGraphicsImpl::Init()
// 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();
diff --git a/vcl/source/opengl/OpenGLHelper.cxx b/vcl/source/opengl/OpenGLHelper.cxx
index 1b48fec..5840853 100644
--- a/vcl/source/opengl/OpenGLHelper.cxx
+++ b/vcl/source/opengl/OpenGLHelper.cxx
@@ -27,7 +27,7 @@
#include <vector>
#include "svdata.hxx"
-
+#include "salgdi.hxx"
#include "salinst.hxx"
#include "opengl/zone.hxx"
#include "opengl/watchdog.hxx"
@@ -816,4 +816,48 @@ GLXFBConfig OpenGLHelper::GetPixmapFBConfig( Display* pDisplay, bool& bInverted
#endif
+OutputDevice::PaintScope::PaintScope(OutputDevice *pDev)
+ : pHandle( NULL )
+{
+ if( pDev->mpGraphics || pDev->AcquireGraphics() )
+ {
+ OpenGLContext *pContext = pDev->mpGraphics->BeginPaint();
+ if( pContext )
+ {
+ assert( pContext->mnPainting >= 0 );
+ pContext->mnPainting++;
+ pContext->acquire();
+ pHandle = static_cast<void *>( pContext );
+ }
+ }
+}
+
+/**
+ * Flush all the queued rendering commands to the screen for this context.
+ */
+void OutputDevice::PaintScope::flush()
+{
+ if( pHandle )
+ {
+ OpenGLContext *pContext = static_cast<OpenGLContext *>( pHandle );
+ pHandle = NULL;
+ pContext->mnPainting--;
+ assert( pContext->mnPainting >= 0 );
+ if( pContext->mnPainting == 0 )
+ {
+ pContext->makeCurrent();
+ pContext->AcquireDefaultFramebuffer();
+ glFlush();
+ pContext->swapBuffers();
+ CHECK_GL_ERROR();
+ }
+ pContext->release();
+ }
+}
+
+OutputDevice::PaintScope::~PaintScope()
+{
+ flush();
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/outdev/outdev.cxx b/vcl/source/outdev/outdev.cxx
index 0d9842d..1c29559 100644
--- a/vcl/source/outdev/outdev.cxx
+++ b/vcl/source/outdev/outdev.cxx
@@ -870,16 +870,4 @@ bool OutputDevice::DrawEPS( const Point& rPoint, const Size& rSize,
return bDrawn;
}
-void OutputDevice::BeginPaint()
-{
- if( mpGraphics || AcquireGraphics() )
- mpGraphics->BeginPaint();
-}
-
-void OutputDevice::EndPaint()
-{
- if( mpGraphics || AcquireGraphics() )
- mpGraphics->EndPaint();
-}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/window/paint.cxx b/vcl/source/window/paint.cxx
index ae846ae..79aa1ed 100644
--- a/vcl/source/window/paint.cxx
+++ b/vcl/source/window/paint.cxx
@@ -276,7 +276,7 @@ void PaintHelper::DoPaint(const vcl::Region* pRegion)
VCL_GL_INFO("vcl.opengl", "PaintHelper::DoPaint on " <<
typeid( *m_pWindow ).name() << " '" << m_pWindow->GetText() << "' begin");
- m_pWindow->BeginPaint();
+ OutputDevice::PaintScope aScope( m_pWindow );
// double-buffering: setup the buffer if it does not exist
if (!pFrameData->mbInBufferedPaint && m_pWindow->SupportsDoubleBuffering())
@@ -306,8 +306,6 @@ void PaintHelper::DoPaint(const vcl::Region* pRegion)
m_pWindow->Paint(*m_pWindow, m_aPaintRect);
}
- m_pWindow->EndPaint();
-
VCL_GL_INFO("vcl.opengl", "PaintHelper::DoPaint end on " <<
typeid( *m_pWindow ).name() << " '" << m_pWindow->GetText() << "'");
}
@@ -629,10 +627,8 @@ void Window::ImplCallOverlapPaint()
{
// - RTL - notify ImplCallPaint to check for re-mirroring (CHECKRTL)
// because we were called from the Sal layer
- OutputDevice *pOutDev = GetOutDev();
- pOutDev->BeginPaint();
+ OutputDevice::PaintScope aScope( GetOutDev() );
ImplCallPaint(NULL, mpWindowImpl->mnPaintFlags /*| IMPL_PAINT_CHECKRTL */);
- pOutDev->EndPaint();
}
}
@@ -651,7 +647,7 @@ IMPL_LINK_NOARG_TYPED(Window, ImplHandlePaintHdl, Idle *, void)
return;
}
- BeginPaint();
+ OutputDevice::PaintScope aScope(this);
// save paint events until resizing or initial sizing done
if (!ImplDoTiledRendering() && mpWindowImpl->mbFrame &&
@@ -664,15 +660,13 @@ IMPL_LINK_NOARG_TYPED(Window, ImplHandlePaintHdl, Idle *, void)
{
ImplCallOverlapPaint();
}
-
- EndPaint();
}
IMPL_LINK_NOARG_TYPED(Window, ImplHandleResizeTimerHdl, Idle *, void)
{
if( mpWindowImpl->mbReallyVisible )
{
- BeginPaint();
+ OutputDevice::PaintScope aScope(this);
ImplCallResize();
if( ImplDoTiledRendering() )
@@ -684,8 +678,6 @@ IMPL_LINK_NOARG_TYPED(Window, ImplHandleResizeTimerHdl, Idle *, void)
mpWindowImpl->mpFrameData->maPaintIdle.Stop();
mpWindowImpl->mpFrameData->maPaintIdle.GetIdleHdl().Call( NULL );
}
-
- EndPaint();
}
}
diff --git a/vcl/unx/generic/gdi/gdiimpl.hxx b/vcl/unx/generic/gdi/gdiimpl.hxx
index 2cf40f9..6e8a278 100644
--- a/vcl/unx/generic/gdi/gdiimpl.hxx
+++ b/vcl/unx/generic/gdi/gdiimpl.hxx
@@ -275,9 +275,6 @@ public:
virtual bool drawGradient(const tools::PolyPolygon& rPolygon, const Gradient& rGradient) SAL_OVERRIDE;
- virtual void beginPaint() SAL_OVERRIDE { }
- virtual void endPaint() SAL_OVERRIDE { }
-
public:
// implementation of X11GraphicsImpl
diff --git a/vcl/unx/generic/gdi/salgdi.cxx b/vcl/unx/generic/gdi/salgdi.cxx
index e9262e1..e2a25b5 100644
--- a/vcl/unx/generic/gdi/salgdi.cxx
+++ b/vcl/unx/generic/gdi/salgdi.cxx
@@ -548,16 +548,11 @@ bool X11SalGraphics::drawGradient(const tools::PolyPolygon& rPoly, const Gradien
return mxImpl->drawGradient(rPoly, rGradient);
}
-void X11SalGraphics::BeginPaint()
+OpenGLContext *X11SalGraphics::BeginPaint()
{
return mxImpl->beginPaint();
}
-void X11SalGraphics::EndPaint()
-{
- return mxImpl->endPaint();
-}
-
SalGeometryProvider *X11SalGraphics::GetGeometryProvider() const
{
if (m_pFrame)
diff --git a/vcl/win/source/gdi/gdiimpl.hxx b/vcl/win/source/gdi/gdiimpl.hxx
index 82a8333..8e7d7f8 100644
--- a/vcl/win/source/gdi/gdiimpl.hxx
+++ b/vcl/win/source/gdi/gdiimpl.hxx
@@ -225,9 +225,6 @@ public:
virtual bool drawGradient(const tools::PolyPolygon& rPolygon,
const Gradient& rGradient) SAL_OVERRIDE;
- virtual void beginPaint() SAL_OVERRIDE { }
- virtual void endPaint() SAL_OVERRIDE { }
-
virtual bool TryRenderCachedNativeControl(ControlCacheKey& rControlCacheKey, int nX, int nY);
virtual bool RenderAndCacheNativeControl(OpenGLCompatibleDC& rWhite, OpenGLCompatibleDC& rBlack,
diff --git a/vcl/win/source/gdi/salgdi.cxx b/vcl/win/source/gdi/salgdi.cxx
index 99cebee..3ed0c07 100644
--- a/vcl/win/source/gdi/salgdi.cxx
+++ b/vcl/win/source/gdi/salgdi.cxx
@@ -1210,14 +1210,9 @@ css::uno::Any WinSalGraphics::GetNativeSurfaceHandle(cairo::SurfaceSharedPtr& rS
return css::uno::Any( args );
}
-void WinSalGraphics::BeginPaint()
+OpenGLContext *WinSalGraphics::BeginPaint()
{
return mpImpl->beginPaint();
}
-void WinSalGraphics::EndPaint()
-{
- return mpImpl->endPaint();
-}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/win/source/window/salframe.cxx b/vcl/win/source/window/salframe.cxx
index 86f72a9..0a6fb73 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,
More information about the Libreoffice-commits
mailing list