summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2015-08-07 14:52:45 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2015-08-07 16:35:22 +0200
commita6c7a0bf105c399d087e2d9f843dbd9b175fdf42 (patch)
tree57c9443c4214d68c8208c0d836ee7941e3ea3adc
parent25534a62b2ba398c6298c6b9e521f20de1087540 (diff)
tdf#92982 vcl rendercontext: move buffer paint logic to PaintBufferGuard
The motivation is that this way vcl::Cursor will be able to reuse it. Change-Id: I7e89d5acb5d63d3297d7c3c8050ccd2172c8608d
-rw-r--r--vcl/inc/window.h4
-rw-r--r--vcl/source/window/paint.cxx61
2 files changed, 43 insertions, 22 deletions
diff --git a/vcl/inc/window.h b/vcl/inc/window.h
index e2acda805f76..27d5ccc1c1bf 100644
--- a/vcl/inc/window.h
+++ b/vcl/inc/window.h
@@ -386,14 +386,18 @@ public:
class PaintBufferGuard
{
ImplFrameData* mpFrameData;
+ VclPtr<vcl::Window> m_pWindow;
bool mbBackground;
Wallpaper maBackground;
AllSettings maSettings;
long mnOutOffX;
long mnOutOffY;
+ Rectangle m_aPaintRect;
public:
PaintBufferGuard(ImplFrameData* pFrameData, vcl::Window* pWindow);
~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);
};
// helper methods
diff --git a/vcl/source/window/paint.cxx b/vcl/source/window/paint.cxx
index 1438f2cf1b7d..c06d7017116b 100644
--- a/vcl/source/window/paint.cxx
+++ b/vcl/source/window/paint.cxx
@@ -44,10 +44,14 @@
PaintBufferGuard::PaintBufferGuard(ImplFrameData* pFrameData, vcl::Window* pWindow)
: mpFrameData(pFrameData),
+ m_pWindow(pWindow),
mbBackground(false),
mnOutOffX(0),
mnOutOffY(0)
{
+ if (!pFrameData->mpBuffer)
+ return;
+
// transfer various settings
// FIXME: this must disappear as we move to RenderContext only,
// the painting must become state-less, so that no actual
@@ -102,6 +106,34 @@ PaintBufferGuard::PaintBufferGuard(ImplFrameData* pFrameData, vcl::Window* pWind
PaintBufferGuard::~PaintBufferGuard()
{
+ if (!mpFrameData->mpBuffer)
+ return;
+
+ if (!m_aPaintRect.IsEmpty())
+ {
+ // copy the buffer content to the actual window
+ // export VCL_DOUBLEBUFFERING_AVOID_PAINT=1 to see where we are
+ // painting directly instead of using Invalidate()
+ // [ie. everything you can see was painted directly to the
+ // window either above or in eg. an event handler]
+ if (!getenv("VCL_DOUBLEBUFFERING_AVOID_PAINT"))
+ {
+ // Make sure that the +1 value GetSize() adds to the size is in pixels.
+ Size aPaintRectSize;
+ if (m_pWindow->GetMapMode().GetMapUnit() == MAP_PIXEL)
+ {
+ aPaintRectSize = m_aPaintRect.GetSize();
+ }
+ else
+ {
+ Rectangle aRectanglePixel = m_pWindow->LogicToPixel(m_aPaintRect);
+ aPaintRectSize = m_pWindow->PixelToLogic(aRectanglePixel.GetSize());
+ }
+
+ m_pWindow->DrawOutDev(m_aPaintRect.TopLeft(), aPaintRectSize, m_aPaintRect.TopLeft(), aPaintRectSize, *mpFrameData->mpBuffer.get());
+ }
+ }
+
// Restore buffer state.
mpFrameData->mpBuffer->SetOutOffXPixel(mnOutOffX);
mpFrameData->mpBuffer->SetOutOffYPixel(mnOutOffY);
@@ -114,6 +146,11 @@ PaintBufferGuard::~PaintBufferGuard()
mpFrameData->mpBuffer->SetBackground();
}
+void PaintBufferGuard::SetPaintRect(const Rectangle& rRectangle)
+{
+ m_aPaintRect = rRectangle;
+}
+
class PaintHelper
{
private:
@@ -192,28 +229,8 @@ void PaintHelper::PaintBuffer()
assert(pFrameData->mbInBufferedPaint);
assert(m_bStartedBufferedPaint);
- // copy the buffer content to the actual window
- // export VCL_DOUBLEBUFFERING_AVOID_PAINT=1 to see where we are
- // painting directly instead of using Invalidate()
- // [ie. everything you can see was painted directly to the
- // window either above or in eg. an event handler]
- if (!getenv("VCL_DOUBLEBUFFERING_AVOID_PAINT"))
- {
- // Make sure that the +1 value GetSize() adds to the size is in pixels.
- Size aPaintRectSize;
- if (m_pWindow->GetMapMode().GetMapUnit() == MAP_PIXEL)
- {
- aPaintRectSize = m_aPaintRect.GetSize();
- }
- else
- {
- Rectangle aRectanglePixel = m_pWindow->LogicToPixel(m_aPaintRect);
- aPaintRectSize = m_pWindow->PixelToLogic(aRectanglePixel.GetSize());
- }
-
- PaintBufferGuard g(pFrameData, m_pWindow);
- m_pWindow->DrawOutDev(m_aPaintRect.TopLeft(), aPaintRectSize, m_aPaintRect.TopLeft(), aPaintRectSize, *pFrameData->mpBuffer.get());
- }
+ PaintBufferGuard aGuard(pFrameData, m_pWindow);
+ aGuard.SetPaintRect(m_aPaintRect);
}
void PaintHelper::DoPaint(const vcl::Region* pRegion)