[Libreoffice-commits] core.git: Branch 'distro/collabora/cd-5.3' - sw/source
Michael Meeks
michael.meeks at collabora.com
Wed Nov 29 03:55:44 UTC 2017
sw/source/core/layout/paintfrm.cxx | 41 ++++++++++++++++++++++++++-----------
1 file changed, 29 insertions(+), 12 deletions(-)
New commits:
commit badd7363df0cdd95ddd9ab7f2008edd54dc0cbc9
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/45426
Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
Tested-by: Ashod Nakashian <ashnakash at gmail.com>
diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx
index 7626f1cbee60..bee3cd75d2ed 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,29 @@ 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);
+ SAL_DEBUG("Intersect " << aComplete << " with " << aTile << " to " << aRender << "bitmap is " << rBitmapEx.GetSizePixel());
+ if (aRender.IsEmpty())
+ break;
+ pOut->DrawBitmapEx(pOut->PixelToLogic(aRender.TopLeft()),
+ pOut->PixelToLogic(aRender.GetSize()),
+ Point(0, 0), aRender.GetSize(),
+ rBitmapEx);
+ }
+
}
/**
@@ -6192,8 +6209,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 +6230,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 +6242,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 +6252,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