diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-07-08 16:36:28 +0200 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2015-08-06 12:55:50 +0200 |
commit | f8aab0505dcda18e4bdf77dbc9aec62a08dbc6d3 (patch) | |
tree | 8753b945f613c8df3bceb3417fa8c1901c29c101 /vcl | |
parent | 4b4c20a7c7adfd89fea98aa0e8d7ad2c4d7fc390 (diff) |
vcl rendercontext: fix off-by-one error in PaintHelper::PaintBuffer()
With this, Writer no longer has leftover 1-pixel-width/height lines on
scrolling at the right/bottom of the SwEditWin area.
The problem was that PaintBuffer() painted one less row/column of pixels
than intended. This happened because Rectangle::GetSize() uses
GetWidth() and GetHeight(), which return "bound2 - bound1 + 1", but
because the map mode was in twips, the +1 had no effect.
For example, if top=127 and bottom=762 in pixels, then the needed height
is 636, but (assuming e.g. 96 DPI) counting 11430-1905+1 in twips, then
converting to pixels is only 635, so the last row/column is not painted.
Fix the problem by making sure that GetSize() is invoked on a rectangle
that has the size in pixels, that's how e.g.
SdrPreRenderDevice::OutputPreRenderDevice() uses DrawOutDev(), too.
Change-Id: I6f8686e0a91ba402db93982c25be76992c260abe
(cherry picked from commit b3e645cde951906d883f015d342f85fc0eedb2ec)
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/window/paint.cxx | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/vcl/source/window/paint.cxx b/vcl/source/window/paint.cxx index 4a6fb2ef114d..e4e7531d5af2 100644 --- a/vcl/source/window/paint.cxx +++ b/vcl/source/window/paint.cxx @@ -182,7 +182,19 @@ void PaintHelper::PaintBuffer() m_pWindow->SetMapMode(m_aPaintRectMapMode); m_pBuffer->SetMapMode(m_aPaintRectMapMode); - m_pWindow->DrawOutDev(m_aPaintRect.TopLeft(), m_aPaintRect.GetSize(), m_aPaintRect.TopLeft(), m_aPaintRect.GetSize(), *m_pBuffer.get()); + // 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, *m_pBuffer.get()); } } |