sw/source/core/layout/paintfrm.cxx | 41 ++++++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 9 deletions(-)
New commits: commit 195ad7f4a780320f47f68b8a7dc381f8e2d492cc Author: Michael Meeks <michael.me...@collabora.com> Date: Tue Jan 9 10:14:21 2018 +0000 tdf#114480 - Revert "Writer page shadow - avoid scaling ..." Unfortunately, when rendering tiles this gives garbage borders in odd places unexpectedly. This reverts commit 268d019c4b05f37e99e1da85472dc9255f186a27. Change-Id: I0071d05469cf8b7859b79c035c4239e4089b2de2 Reviewed-on: https://gerrit.libreoffice.org/47642 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Jan Holesovsky <ke...@collabora.com> diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx index e2187a1da863..4024f341defc 100644 --- a/sw/source/core/layout/paintfrm.cxx +++ b/sw/source/core/layout/paintfrm.cxx @@ -5876,6 +5876,7 @@ bool SwPageFrame::IsLeftShadowNeeded() const } enum PaintArea {LEFT, RIGHT, TOP, BOTTOM}; +#define BORDER_TILE_SIZE 512 /// Wrapper around pOut->DrawBitmapEx. static void lcl_paintBitmapExToRect(vcl::RenderContext *pOut, const Point& aPoint, const Size& aSize, const BitmapEx& rBitmapEx, PaintArea eArea) @@ -5897,14 +5898,24 @@ static void lcl_paintBitmapExToRect(vcl::RenderContext *pOut, const Point& aPoin pOut->SetLineColor(); pOut->DrawRect(pOut->PixelToLogic(aRect)); - Size aOutSize = pOut->PixelToLogic(aSize); - Point aOutPoint = pOut->PixelToLogic(aPoint); + // Tiled render if necessary + tools::Rectangle aComplete(aPoint, aSize); + Size aTileSize(BORDER_TILE_SIZE, BORDER_TILE_SIZE); + + long iterX = eArea != RIGHT && eArea != LEFT ? BORDER_TILE_SIZE : 0; + long iterY = eArea == RIGHT || eArea == LEFT ? BORDER_TILE_SIZE : 0; + + for (tools::Rectangle aTile = tools::Rectangle(aPoint, aTileSize); true; aTile.Move(iterX, iterY)) + { + tools::Rectangle aRender = aComplete.GetIntersection(aTile); + if (aRender.IsEmpty()) + break; + pOut->DrawBitmapEx(pOut->PixelToLogic(aRender.TopLeft()), + pOut->PixelToLogic(aRender.GetSize()), + Point(0, 0), aRender.GetSize(), + rBitmapEx); + } - pOut->DrawTransformedBitmapEx( - basegfx::utils::createScaleTranslateB2DHomMatrix( - aOutSize.Width(), aOutSize.Height(), - aOutPoint.X(), aOutPoint.Y()), - rBitmapEx); } /** @@ -6016,6 +6027,9 @@ static void lcl_paintBitmapExToRect(vcl::RenderContext *pOut, const Point& aPoin { const long nWidth = aPageRightShadow.GetSizePixel().Width(); const long nHeight = aPagePxRect.Height() - 2 * (mnShadowPxWidth - 1); + if (aPageRightShadow.GetSizePixel().Height() < BORDER_TILE_SIZE) + aPageRightShadow.Scale(Size(nWidth, BORDER_TILE_SIZE), BmpScaleFlag::Fast); + lcl_paintBitmapExToRect(pOut, Point(aPaintRect.Right() + mnShadowPxWidth, aPagePxRect.Top() + mnShadowPxWidth - 1), Size(nWidth, nHeight), @@ -6034,6 +6048,9 @@ static void lcl_paintBitmapExToRect(vcl::RenderContext *pOut, const Point& aPoin { const long nWidth = aPageLeftShadow.GetSizePixel().Width(); const long nHeight = aPagePxRect.Height() - 2 * (mnShadowPxWidth - 1); + if (aPageLeftShadow.GetSizePixel().Height() < BORDER_TILE_SIZE) + aPageLeftShadow.Scale(Size(nWidth, BORDER_TILE_SIZE), BmpScaleFlag::Fast); + lcl_paintBitmapExToRect(pOut, Point(lLeft, aPagePxRect.Top() + mnShadowPxWidth - 1), Size(nWidth, nHeight), @@ -6043,16 +6060,22 @@ static void lcl_paintBitmapExToRect(vcl::RenderContext *pOut, const Point& aPoin // Bottom shadow const long nBottomHeight = aPageBottomShadow.GetSizePixel().Height(); + if (aPageBottomShadow.GetSizePixel().Width() < BORDER_TILE_SIZE) + aPageBottomShadow.Scale(Size(BORDER_TILE_SIZE, nBottomHeight), BmpScaleFlag::Fast); + lcl_paintBitmapExToRect(pOut, Point(aPaintRect.Left(), aPagePxRect.Bottom() + 2), - Size(aPaintRect.Width() - 1, nBottomHeight), + Size(aPaintRect.Width(), nBottomHeight), aPageBottomShadow, BOTTOM); // Top shadow const long nTopHeight = aPageTopShadow.GetSizePixel().Height(); + if (aPageTopShadow.GetSizePixel().Width() < BORDER_TILE_SIZE) + aPageTopShadow.Scale(Size(BORDER_TILE_SIZE, nTopHeight), BmpScaleFlag::Fast); + lcl_paintBitmapExToRect(pOut, Point(aPaintRect.Left(), aPagePxRect.Top() - mnShadowPxWidth), - Size(aPaintRect.Width() - 1, nTopHeight), + Size(aPaintRect.Width(), nTopHeight), aPageTopShadow, TOP); } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits