sw/source/core/layout/paintfrm.cxx | 39 +++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-)
New commits: commit 3f4f6771e939fbe2fd12be6897ca0e27aaa4d55e Author: Michael Meeks <michael.me...@collabora.com> Date: Mon Nov 27 20:53:48 2017 +0000 Tile the writer surround rendering to avoid large image scaling. This also fixes a potentially large memory leak depending on zoom, and particularly with non-paginated rendering. Change-Id: Ia24e0b7baea725020f000a369708b0be3fc20c95 Reviewed-on: https://gerrit.libreoffice.org/45426 Reviewed-by: Ashod Nakashian <ashnak...@gmail.com> Tested-by: Ashod Nakashian <ashnak...@gmail.com> (cherry picked from commit badd7363df0cdd95ddd9ab7f2008edd54dc0cbc9) Reviewed-on: https://gerrit.libreoffice.org/45427 diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx index 0572d4cf5b7a..7a764e73b6dc 100644 --- a/sw/source/core/layout/paintfrm.cxx +++ b/sw/source/core/layout/paintfrm.cxx @@ -6057,6 +6057,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) @@ -6074,13 +6075,27 @@ static void lcl_paintBitmapExToRect(vcl::RenderContext *pOut, const Point& aPoin case BOTTOM: aRect.Bottom() = aRect.Top() + 1; break; } - pOut->SetFillColor( SwViewOption::GetAppBackgroundColor()); + pOut->SetFillColor(SwViewOption::GetAppBackgroundColor()); pOut->SetLineColor(); pOut->DrawRect(pOut->PixelToLogic(aRect)); - pOut->DrawBitmapEx(pOut->PixelToLogic(aPoint), pOut->PixelToLogic(aSize), - Point(0, 0), aSize, - rBitmapEx); + // Tiled render if necessary + 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 (Rectangle aTile = Rectangle(aPoint, aTileSize); true; aTile.Move(iterX, iterY)) + { + 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); + } } /** @@ -6192,8 +6207,8 @@ 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() < nHeight) - aPageRightShadow.Scale(Size(nWidth, nHeight), BmpScaleFlag::Fast); + 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), @@ -6213,8 +6228,8 @@ 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() < nHeight) - aPageLeftShadow.Scale(Size(nWidth, nHeight), BmpScaleFlag::Fast); + 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), @@ -6225,8 +6240,8 @@ static void lcl_paintBitmapExToRect(vcl::RenderContext *pOut, const Point& aPoin // Bottom shadow const long nBottomHeight = aPageBottomShadow.GetSizePixel().Height(); - if (aPageBottomShadow.GetSizePixel().Width() < aPaintRect.Width()) - aPageBottomShadow.Scale(Size(aPaintRect.Width(), nBottomHeight), BmpScaleFlag::Fast); + 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), @@ -6235,8 +6250,8 @@ static void lcl_paintBitmapExToRect(vcl::RenderContext *pOut, const Point& aPoin // Top shadow const long nTopHeight = aPageTopShadow.GetSizePixel().Height(); - if (aPageTopShadow.GetSizePixel().Width() < aPaintRect.Width()) - aPageTopShadow.Scale(Size(aPaintRect.Width(), nTopHeight), BmpScaleFlag::Fast); + 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), _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits