include/vcl/outdev.hxx | 18 ++++++++++++-- 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 | 28 ++++------------------ 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 ----- 17 files changed, 77 insertions(+), 88 deletions(-)
New commits: commit 5096dd689db9fdd97ae0399f78f95710196b7786 Author: Michael Meeks <michael.me...@collabora.com> Date: Wed Sep 16 09:17:37 2015 +0100 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. Conflicts: vcl/inc/generic/genpspgraphics.h vcl/win/source/gdi/salgdi.cxx Change-Id: I1062be0b02a91fc9009deaa3ec29c5dbb227df20 Reviewed-on: https://gerrit.libreoffice.org/18611 Reviewed-by: Tor Lillqvist <t...@collabora.com> Tested-by: Tor Lillqvist <t...@collabora.com> 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/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 9ea8a7c..d452f5d 100644 --- a/vcl/opengl/gdiimpl.cxx +++ b/vcl/opengl/gdiimpl.cxx @@ -1873,30 +1873,12 @@ bool OpenGLSalGraphicsImpl::drawGradient(const tools::PolyPolygon& rPolyPoly, return true; } -void OpenGLSalGraphicsImpl::beginPaint() +OpenGLContext *OpenGLSalGraphicsImpl::beginPaint() { - if( !AcquireContext() ) - return; - - mpContext->mnPainting++; -} - -void OpenGLSalGraphicsImpl::endPaint() -{ - 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/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: */ _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits