diff options
author | Jan Holesovsky <kendy@collabora.com> | 2015-05-21 17:42:26 +0200 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2015-05-29 20:16:50 +0200 |
commit | a0a6cd51e59d79586df79acd64d2f67241a1b671 (patch) | |
tree | aa1d529702a0bf7da58ef2e2d5e500d30c823ada | |
parent | f57b4e5cba3a418b1f94c87c5b4785f86bfd9d61 (diff) |
rendercontext: Position the double-buffered subwidgets correctly.
Change-Id: I707ff09ac2b7b610f0f13440a215abf083f9815d
-rw-r--r-- | include/vcl/outdev.hxx | 1 | ||||
-rw-r--r-- | vcl/source/window/paint.cxx | 46 |
2 files changed, 41 insertions, 6 deletions
diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx index 27cee53d4c00..b00f2d316d28 100644 --- a/include/vcl/outdev.hxx +++ b/include/vcl/outdev.hxx @@ -314,6 +314,7 @@ namespace vcl { class VCL_DLLPUBLIC OutputDevice { + friend class PaintHelper; friend class Printer; friend class VirtualDevice; friend class vcl::Window; diff --git a/vcl/source/window/paint.cxx b/vcl/source/window/paint.cxx index 35317103bc28..af64a31acaa7 100644 --- a/vcl/source/window/paint.cxx +++ b/vcl/source/window/paint.cxx @@ -85,6 +85,9 @@ public: void DoPaint(const vcl::Region* pRegion); /// Create m_pBuffer, and set it up to have the same settings as m_pWindow. + void CreateBuffer(); + + /// Setup m_pBuffer according to the settings of the current m_pWindow. void SetupBuffer(); /// Paint the content of the buffer to the current m_pWindow. @@ -104,13 +107,29 @@ PaintHelper::PaintHelper(vcl::Window *pWindow, const VclPtr<VirtualDevice>& rBuf { } -void PaintHelper::SetupBuffer() +void PaintHelper::CreateBuffer() { assert(!m_pBuffer); m_pBuffer = VclPtrInstance<VirtualDevice>(); m_bCreatedBuffer = true; + SetupBuffer(); + + // update the output size now, after all the settings were copied + m_pBuffer->SetOutputSize(m_pWindow->GetOutputSize()); + + // we need to remember the mnOutOffX / mnOutOffY, but actually really + // set it just temporarily for the subwidgets - so we are setting it here + // only to remember the value & to be able to pass it to the descendants + // FIXME: once everything's double-buffered, this is (hopefully) not + // necessary as the m_pBuffer is always created for the main window. + m_pBuffer->mnOutOffX = m_pWindow->GetOutOffXPixel(); + m_pBuffer->mnOutOffY = m_pWindow->GetOutOffYPixel(); +} + +void PaintHelper::SetupBuffer() +{ // transfer various settings // FIXME: this must disappear as we move to RenderContext only, // the painting must become state-less, so that no actual @@ -133,17 +152,17 @@ void PaintHelper::SetupBuffer() m_pBuffer->SetTextFillColor(m_pWindow->GetTextFillColor()); m_pBuffer->SetTextAlign(m_pWindow->GetTextAlign()); m_pBuffer->SetRasterOp(m_pWindow->GetRasterOp()); - m_pBuffer->SetRefPoint(m_pWindow->GetRefPoint()); m_pBuffer->SetLayoutMode(m_pWindow->GetLayoutMode()); m_pBuffer->SetDigitLanguage(m_pWindow->GetDigitLanguage()); - - // update the output size now, after all the settings were copied - m_pBuffer->SetOutputSize(m_pWindow->GetOutputSize()); } void PaintHelper::PaintBuffer() { assert(m_pBuffer); + assert(m_bCreatedBuffer); + + m_pBuffer->mnOutOffX = 0; + m_pBuffer->mnOutOffY = 0; // copy the buffer content to the actual window // export VCL_DOUBLEBUFFERING_AVOID_PAINT=1 to see where we are @@ -186,7 +205,7 @@ void PaintHelper::DoPaint(const vcl::Region* pRegion) // double-buffering: setup the buffer if it does not exist if (!m_pBuffer && m_pWindow->SupportsDoubleBuffering()) - SetupBuffer(); + CreateBuffer(); // double-buffering: if this window does not support double-buffering, // but we are in the middle of double-buffered paint, we might be @@ -197,9 +216,24 @@ void PaintHelper::DoPaint(const vcl::Region* pRegion) if (m_pBuffer && m_pWindow->SupportsDoubleBuffering()) { // double-buffering + SetupBuffer(); + + // temporarily decrease the mnOutOffX/Y of the buffer for the + // subwidgets (because the m_pBuffer is our base here) + // FIXME: once everything's double-buffered, this is (hopefully) not + // necessary as the m_pBuffer is always created for the main window. + long nOutOffX = m_pBuffer->mnOutOffX; + long nOutOffY = m_pBuffer->mnOutOffY; + m_pBuffer->mnOutOffX = m_pWindow->GetOutOffXPixel() - m_pBuffer->mnOutOffX; + m_pBuffer->mnOutOffY = m_pWindow->GetOutOffYPixel() - m_pBuffer->mnOutOffY; + m_pWindow->PushPaintHelper(this, *m_pWindow); m_pWindow->ApplySettings(*m_pBuffer.get()); m_pWindow->Paint(*m_pBuffer.get(), m_aPaintRect); + + // restore the mnOutOffX/Y value + m_pBuffer->mnOutOffX = nOutOffX; + m_pBuffer->mnOutOffY = nOutOffY; } else { |