[Libreoffice-commits] core.git: Branch 'libreoffice-6-0' - sw/source
Michael Meeks
michael.meeks at collabora.com
Thu Nov 30 12:17:01 UTC 2017
sw/source/core/layout/paintfrm.cxx | 40 +++++++++++++++++++++++++------------
1 file changed, 28 insertions(+), 12 deletions(-)
New commits:
commit 28fba41403d80c224c744cdf477acbab326b01c0
Author: Michael Meeks <michael.meeks at 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/45414
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Michael Meeks <michael.meeks at collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/45466
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx
index 51370b19b021..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)
@@ -5893,13 +5894,28 @@ 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
+ 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);
+ }
+
}
/**
@@ -6011,8 +6027,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),
@@ -6032,8 +6048,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),
@@ -6044,8 +6060,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),
@@ -6054,8 +6070,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),
More information about the Libreoffice-commits
mailing list