diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-08-07 16:35:11 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-08-07 16:35:23 +0200 |
commit | c64a7ce1fcd1e30956a77530d0b76ad493841024 (patch) | |
tree | 723796de700b511614ffeb9c36b12284fa5d3255 | |
parent | a6c7a0bf105c399d087e2d9f843dbd9b175fdf42 (diff) |
Resolves: tdf#92982 vcl rendercontext: handle buffered paint of vcl::Cursor
Instead of painting on the vcl::Window directly, take a
PaintBufferGuard, and use the vcl::RenderContext of it, that may be
either the vcl::Window or the toplevel frame's buffer.
Trigger the paint of the buffer by informing the guard what area was
painted. In case of direct painting, both the ctor and the dtor of the
guard is a NOP.
This means that finally we can also assert Invert() calls on the output
device, so that direct paint can't happen when double-buffering.
Change-Id: I0322563369dc63b3c49061cbe7c4a911cb13a2e2
-rw-r--r-- | vcl/inc/window.h | 2 | ||||
-rw-r--r-- | vcl/source/outdev/rect.cxx | 2 | ||||
-rw-r--r-- | vcl/source/window/cursor.cxx | 9 | ||||
-rw-r--r-- | vcl/source/window/paint.cxx | 8 |
4 files changed, 20 insertions, 1 deletions
diff --git a/vcl/inc/window.h b/vcl/inc/window.h index 27d5ccc1c1bf..07bc09d78679 100644 --- a/vcl/inc/window.h +++ b/vcl/inc/window.h @@ -398,6 +398,8 @@ public: ~PaintBufferGuard(); /// If this is called, then the dtor will also copy rRectangle to the window from the buffer, before restoring the state. void SetPaintRect(const Rectangle& rRectangle); + /// Returns either the frame's buffer or the window, in case of no buffering. + vcl::RenderContext* GetRenderContext(); }; // helper methods diff --git a/vcl/source/outdev/rect.cxx b/vcl/source/outdev/rect.cxx index d786649c0cb4..e8ecf440de50 100644 --- a/vcl/source/outdev/rect.cxx +++ b/vcl/source/outdev/rect.cxx @@ -131,6 +131,7 @@ void OutputDevice::DrawRect( const Rectangle& rRect, void OutputDevice::Invert( const Rectangle& rRect, InvertFlags nFlags ) { + assert(!is_double_buffered_window()); if ( !IsDeviceOutputNecessary() ) return; @@ -163,6 +164,7 @@ void OutputDevice::Invert( const Rectangle& rRect, InvertFlags nFlags ) void OutputDevice::Invert( const Polygon& rPoly, InvertFlags nFlags ) { + assert(!is_double_buffered_window()); if ( !IsDeviceOutputNecessary() ) return; diff --git a/vcl/source/window/cursor.cxx b/vcl/source/window/cursor.cxx index 2eaa5517eade..d022aaa87093 100644 --- a/vcl/source/window/cursor.cxx +++ b/vcl/source/window/cursor.cxx @@ -44,7 +44,9 @@ struct ImplCursorData static void ImplCursorInvert( ImplCursorData* pData ) { vcl::Window* pWindow = pData->mpWindow; - vcl::RenderContext* pRenderContext = pWindow->GetOutDev(); + PaintBufferGuard aGuard(pWindow->ImplGetWindowImpl()->mpFrameData, pWindow); + vcl::RenderContext* pRenderContext = aGuard.GetRenderContext(); + Rectangle aPaintRect; bool bMapMode = pRenderContext->IsMapModeEnabled(); pRenderContext->EnableMapMode( false ); InvertFlags nInvertStyle; @@ -109,11 +111,16 @@ static void ImplCursorInvert( ImplCursorData* pData ) if ( pData->mnOrientation ) aPoly.Rotate( pData->maPixRotOff, pData->mnOrientation ); pRenderContext->Invert( aPoly, nInvertStyle ); + aPaintRect = aPoly.GetBoundRect(); } } else + { pRenderContext->Invert( aRect, nInvertStyle ); + aPaintRect = aRect; + } pRenderContext->EnableMapMode( bMapMode ); + aGuard.SetPaintRect(pRenderContext->PixelToLogic(aPaintRect)); } void vcl::Cursor::ImplDraw() diff --git a/vcl/source/window/paint.cxx b/vcl/source/window/paint.cxx index c06d7017116b..4fef67fb6531 100644 --- a/vcl/source/window/paint.cxx +++ b/vcl/source/window/paint.cxx @@ -151,6 +151,14 @@ void PaintBufferGuard::SetPaintRect(const Rectangle& rRectangle) m_aPaintRect = rRectangle; } +vcl::RenderContext* PaintBufferGuard::GetRenderContext() +{ + if (mpFrameData->mpBuffer) + return mpFrameData->mpBuffer; + else + return m_pWindow; +} + class PaintHelper { private: |