Kaydet (Commit) 94a6daa0 authored tarafından Miklos Vajna's avatar Miklos Vajna

tdf#92982 vcl rendercontext: set correct offset for the frame-level buffer

In case we had a toplevel window W1, the paint was triggered for window
W2 and we had a sub-widget W3, then previously the buffer was created
for W2, so the pixel offsets had to be set relative to W2 when rendering
W3. As a consequence, if a single window was painted, then it was
always painted in the top left corner.

Now that the buffer is persistent and is always created for W1, make
sure that we paint to the correct offset, and W3 is always painted at
the same offset, regardless if it was painted directly, or just because
it's a child of W2.

With this, the buffer conents is closer to what is on the screen, even
if it's not perfect yet.

Change-Id: Ibf0e89ad18e5763bd2a01e69d91da163c24a309d
üst 9ce9b66e
...@@ -116,24 +116,22 @@ void PaintHelper::StartBufferedPaint() ...@@ -116,24 +116,22 @@ void PaintHelper::StartBufferedPaint()
// painting over, as VirtualDevice::ImplInitVirDev() would do. // painting over, as VirtualDevice::ImplInitVirDev() would do.
// The painted area is m_aPaintRect, or in case it's empty, then the whole window. // The painted area is m_aPaintRect, or in case it's empty, then the whole window.
pFrameData->mpBuffer->SetBackground(Wallpaper(Color(COL_WHITE))); 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()) if (m_aPaintRect.IsEmpty())
pFrameData->mpBuffer->Erase(Rectangle(Point(0, 0), m_pWindow->GetOutputSize())); pFrameData->mpBuffer->Erase(Rectangle(Point(0, 0), m_pWindow->GetOutputSize()));
else else
pFrameData->mpBuffer->Erase(m_aPaintRect); pFrameData->mpBuffer->Erase(m_aPaintRect);
pFrameData->mpBuffer->mnOutOffX = nOutOffX;
pFrameData->mpBuffer->mnOutOffY = nOutOffY;
pFrameData->mbInBufferedPaint = true; pFrameData->mbInBufferedPaint = true;
m_bStartedBufferedPaint = true; m_bStartedBufferedPaint = true;
// Remember what was the map mode of m_aPaintRect. // Remember what was the map mode of m_aPaintRect.
m_aPaintRectMapMode = m_pWindow->GetMapMode(); m_aPaintRectMapMode = m_pWindow->GetMapMode();
// 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 buffer is always created for the main window.
pFrameData->mpBuffer->mnOutOffX = m_pWindow->GetOutOffXPixel();
pFrameData->mpBuffer->mnOutOffY = m_pWindow->GetOutOffYPixel();
} }
void PaintHelper::SetupBuffer() void PaintHelper::SetupBuffer()
...@@ -171,9 +169,6 @@ void PaintHelper::PaintBuffer() ...@@ -171,9 +169,6 @@ void PaintHelper::PaintBuffer()
assert(pFrameData->mbInBufferedPaint); assert(pFrameData->mbInBufferedPaint);
assert(m_bStartedBufferedPaint); assert(m_bStartedBufferedPaint);
pFrameData->mpBuffer->mnOutOffX = 0;
pFrameData->mpBuffer->mnOutOffY = 0;
// copy the buffer content to the actual window // copy the buffer content to the actual window
// export VCL_DOUBLEBUFFERING_AVOID_PAINT=1 to see where we are // export VCL_DOUBLEBUFFERING_AVOID_PAINT=1 to see where we are
// painting directly instead of using Invalidate() // painting directly instead of using Invalidate()
...@@ -199,7 +194,13 @@ void PaintHelper::PaintBuffer() ...@@ -199,7 +194,13 @@ void PaintHelper::PaintBuffer()
aPaintRectSize = m_pWindow->PixelToLogic(aRectanglePixel.GetSize()); 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();
m_pWindow->DrawOutDev(m_aPaintRect.TopLeft(), aPaintRectSize, m_aPaintRect.TopLeft(), aPaintRectSize, *pFrameData->mpBuffer.get()); m_pWindow->DrawOutDev(m_aPaintRect.TopLeft(), aPaintRectSize, m_aPaintRect.TopLeft(), aPaintRectSize, *pFrameData->mpBuffer.get());
pFrameData->mpBuffer->mnOutOffX = nOutOffX;
pFrameData->mpBuffer->mnOutOffY = nOutOffY;
} }
} }
...@@ -250,19 +251,12 @@ void PaintHelper::DoPaint(const vcl::Region* pRegion) ...@@ -250,19 +251,12 @@ void PaintHelper::DoPaint(const vcl::Region* pRegion)
SetupBuffer(); SetupBuffer();
m_pWindow->ApplySettings(*pFrameData->mpBuffer.get()); m_pWindow->ApplySettings(*pFrameData->mpBuffer.get());
// temporarily decrease the mnOutOffX/Y of the buffer for the
// subwidgets (because the buffer is our base here)
// FIXME: once everything's double-buffered, this is (hopefully) not
// necessary as the buffer is always created for the main window.
long nOutOffX = pFrameData->mpBuffer->mnOutOffX; long nOutOffX = pFrameData->mpBuffer->mnOutOffX;
long nOutOffY = pFrameData->mpBuffer->mnOutOffY; long nOutOffY = pFrameData->mpBuffer->mnOutOffY;
pFrameData->mpBuffer->mnOutOffX = m_pWindow->GetOutOffXPixel() - pFrameData->mpBuffer->mnOutOffX; pFrameData->mpBuffer->mnOutOffX = m_pWindow->GetOutOffXPixel();
pFrameData->mpBuffer->mnOutOffY = m_pWindow->GetOutOffYPixel() - pFrameData->mpBuffer->mnOutOffY; pFrameData->mpBuffer->mnOutOffY = m_pWindow->GetOutOffYPixel();
m_pWindow->PushPaintHelper(this, *pFrameData->mpBuffer.get()); m_pWindow->PushPaintHelper(this, *pFrameData->mpBuffer.get());
m_pWindow->Paint(*pFrameData->mpBuffer.get(), m_aPaintRect); m_pWindow->Paint(*pFrameData->mpBuffer.get(), m_aPaintRect);
// restore the mnOutOffX/Y value
pFrameData->mpBuffer->mnOutOffX = nOutOffX; pFrameData->mpBuffer->mnOutOffX = nOutOffX;
pFrameData->mpBuffer->mnOutOffY = nOutOffY; pFrameData->mpBuffer->mnOutOffY = nOutOffY;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment