diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-08-04 09:48:11 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-08-04 11:29:26 +0200 |
commit | 28e465d2611adee62aac984a9c0bf731adcb793b (patch) | |
tree | d782cba6e612ade47c1002c3b92112e58b9ae770 | |
parent | c36a00b811471b81abf189d80e07b5ff96243288 (diff) |
tdf#92982 vcl rendercontext: let PaintBufferGuard also manage pixel offset
Change-Id: Ifd6a75c4312f93c815f5d137f515724f3629fa0d
-rw-r--r-- | include/vcl/outdev.hxx | 3 | ||||
-rw-r--r-- | vcl/source/outdev/outdev.cxx | 10 | ||||
-rw-r--r-- | vcl/source/window/paint.cxx | 44 |
3 files changed, 33 insertions, 24 deletions
diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx index 3dab4e0b75af..3eb6300898d2 100644 --- a/include/vcl/outdev.hxx +++ b/include/vcl/outdev.hxx @@ -319,7 +319,6 @@ namespace vcl { class VCL_DLLPUBLIC OutputDevice { - friend class PaintHelper; friend class Printer; friend class VirtualDevice; friend class vcl::Window; @@ -500,6 +499,8 @@ public: long GetOutputHeightPixel() const { return mnOutHeight; } long GetOutOffXPixel() const { return mnOutOffX; } long GetOutOffYPixel() const { return mnOutOffY; } + void SetOutOffXPixel(long nOutOffX); + void SetOutOffYPixel(long nOutOffY); Size GetOutputSize() const { return PixelToLogic( GetOutputSizePixel() ); } diff --git a/vcl/source/outdev/outdev.cxx b/vcl/source/outdev/outdev.cxx index ecc6c8f31ed2..7ccaf3229154 100644 --- a/vcl/source/outdev/outdev.cxx +++ b/vcl/source/outdev/outdev.cxx @@ -426,6 +426,16 @@ sal_uInt16 OutputDevice::GetBitCount() const return (sal_uInt16)mpGraphics->GetBitCount(); } +void OutputDevice::SetOutOffXPixel(long nOutOffX) +{ + mnOutOffX = nOutOffX; +} + +void OutputDevice::SetOutOffYPixel(long nOutOffY) +{ + mnOutOffY = nOutOffY; +} + sal_uLong OutputDevice::GetColorCount() const { diff --git a/vcl/source/window/paint.cxx b/vcl/source/window/paint.cxx index 75c51284416f..68ae9971b2e6 100644 --- a/vcl/source/window/paint.cxx +++ b/vcl/source/window/paint.cxx @@ -47,10 +47,14 @@ class PaintBufferGuard bool mbBackground; Wallpaper maBackground; AllSettings maSettings; + long mnOutOffX; + long mnOutOffY; public: PaintBufferGuard(ImplFrameData* pFrameData, vcl::Window* pWindow) : mpFrameData(pFrameData), - mbBackground(false) + mbBackground(false), + mnOutOffX(0), + mnOutOffY(0) { // transfer various settings // FIXME: this must disappear as we move to RenderContext only, @@ -97,10 +101,18 @@ public: pFrameData->mpBuffer->SetRasterOp(pWindow->GetRasterOp()); pFrameData->mpBuffer->SetLayoutMode(pWindow->GetLayoutMode()); pFrameData->mpBuffer->SetDigitLanguage(pWindow->GetDigitLanguage()); + + mnOutOffX = pFrameData->mpBuffer->GetOutOffXPixel(); + mnOutOffY = pFrameData->mpBuffer->GetOutOffYPixel(); + pFrameData->mpBuffer->SetOutOffXPixel(pWindow->GetOutOffXPixel()); + pFrameData->mpBuffer->SetOutOffYPixel(pWindow->GetOutOffYPixel()); } ~PaintBufferGuard() { // Restore buffer state. + mpFrameData->mpBuffer->SetOutOffXPixel(mnOutOffX); + mpFrameData->mpBuffer->SetOutOffYPixel(mnOutOffY); + mpFrameData->mpBuffer->Pop(); mpFrameData->mpBuffer->SetSettings(maSettings); if (mbBackground) @@ -183,16 +195,13 @@ void PaintHelper::StartBufferedPaint() // painting over, as VirtualDevice::ImplInitVirDev() would do. // The painted area is m_aPaintRect, or in case it's empty, then the whole window. pFrameData->mpBuffer->SetBackground(Wallpaper(Color(COL_WHITE))); - long nOutOffX = pFrameData->mpBuffer->GetOutOffXPixel(); - long nOutOffY = pFrameData->mpBuffer->GetOutOffYPixel(); - pFrameData->mpBuffer->mnOutOffX = m_pWindow->GetOutOffXPixel(); - pFrameData->mpBuffer->mnOutOffY = m_pWindow->GetOutOffYPixel(); - if (m_aPaintRect.IsEmpty()) - pFrameData->mpBuffer->Erase(Rectangle(Point(0, 0), m_pWindow->GetOutputSize())); - else - pFrameData->mpBuffer->Erase(m_aPaintRect); - pFrameData->mpBuffer->mnOutOffX = nOutOffX; - pFrameData->mpBuffer->mnOutOffY = nOutOffY; + { + PaintBufferGuard g(pFrameData, m_pWindow); + if (m_aPaintRect.IsEmpty()) + pFrameData->mpBuffer->Erase(Rectangle(Point(0, 0), m_pWindow->GetOutputSize())); + else + pFrameData->mpBuffer->Erase(m_aPaintRect); + } pFrameData->mbInBufferedPaint = true; m_bStartedBufferedPaint = true; @@ -232,13 +241,8 @@ void PaintHelper::PaintBuffer() aPaintRectSize = m_pWindow->PixelToLogic(aRectanglePixel.GetSize()); } - long nOutOffX = pFrameData->mpBuffer->GetOutOffXPixel(); - long nOutOffY = pFrameData->mpBuffer->GetOutOffYPixel(); - pFrameData->mpBuffer->mnOutOffX = m_pWindow->GetOutOffXPixel(); - pFrameData->mpBuffer->mnOutOffY = m_pWindow->GetOutOffYPixel(); + PaintBufferGuard g(pFrameData, m_pWindow); m_pWindow->DrawOutDev(m_aPaintRect.TopLeft(), aPaintRectSize, m_aPaintRect.TopLeft(), aPaintRectSize, *pFrameData->mpBuffer.get()); - pFrameData->mpBuffer->mnOutOffX = nOutOffX; - pFrameData->mpBuffer->mnOutOffY = nOutOffY; } } @@ -289,14 +293,8 @@ void PaintHelper::DoPaint(const vcl::Region* pRegion) PaintBufferGuard g(pFrameData, m_pWindow); m_pWindow->ApplySettings(*pFrameData->mpBuffer.get()); - long nOutOffX = pFrameData->mpBuffer->mnOutOffX; - long nOutOffY = pFrameData->mpBuffer->mnOutOffY; - pFrameData->mpBuffer->mnOutOffX = m_pWindow->GetOutOffXPixel(); - pFrameData->mpBuffer->mnOutOffY = m_pWindow->GetOutOffYPixel(); m_pWindow->PushPaintHelper(this, *pFrameData->mpBuffer.get()); m_pWindow->Paint(*pFrameData->mpBuffer.get(), m_aPaintRect); - pFrameData->mpBuffer->mnOutOffX = nOutOffX; - pFrameData->mpBuffer->mnOutOffY = nOutOffY; } else { |