[Libreoffice-commits] core.git: sw/source

Michael Meeks michael.meeks at collabora.com
Tue Jan 9 12:13:52 UTC 2018


 sw/source/core/layout/paintfrm.cxx |   41 ++++++++++++++++++++++++++++---------
 1 file changed, 32 insertions(+), 9 deletions(-)

New commits:
commit 1c1653e4d6520aa8fbe5d3dc8a94cfb9330916cf
Author: Michael Meeks <michael.meeks at 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

diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx
index 30872d45e6f4..c4edfba5a5b0 100644
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -5652,6 +5652,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)
@@ -5673,14 +5674,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);
 }
 
 /**
@@ -5792,6 +5803,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),
@@ -5810,6 +5824,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),
@@ -5819,16 +5836,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);
 }
 


More information about the Libreoffice-commits mailing list