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

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Fri May 3 15:32:22 UTC 2019


 vcl/source/gdi/bmpacc3.cxx |   26 +++++++++++++++++---------
 1 file changed, 17 insertions(+), 9 deletions(-)

New commits:
commit 8712344cf4c31f020ec9bc47f43994869d64ac08
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Fri May 3 14:55:47 2019 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Fri May 3 17:31:06 2019 +0200

    ofz#14119 make erasing bitmap faster
    
    Change-Id: I6adb2618926bab652244c33acf870907e5fc159e
    Reviewed-on: https://gerrit.libreoffice.org/71748
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/vcl/source/gdi/bmpacc3.cxx b/vcl/source/gdi/bmpacc3.cxx
index f6ffe913de36..d85f50ea8ec2 100644
--- a/vcl/source/gdi/bmpacc3.cxx
+++ b/vcl/source/gdi/bmpacc3.cxx
@@ -78,19 +78,27 @@ void BitmapWriteAccess::Erase( const Color& rColor )
     {
         aColor = BitmapColor(static_cast<sal_uInt8>(GetBestPaletteIndex(rColor)));
     }
+
     // try fast bitmap method first
     if (ImplFastEraseBitmap(*mpBuffer, aColor))
         return;
 
-    // use the canonical method to clear the bitmap
-    boost::optional<BitmapColor> pOldFillColor(mpFillColor);
-    const Point aPoint;
-    const tools::Rectangle aRect(aPoint, maBitmap.GetSizePixel());
-
-    SetFillColor(rColor);
-    FillRect(aRect);
-
-    mpFillColor = pOldFillColor;
+    tools::Rectangle aRect(Point(), maBitmap.GetSizePixel());
+    if (aRect.IsEmpty())
+        return;
+    // clear the bitmap by filling the first line pixel by pixel,
+    // then dup the first line over each other line
+    Scanline pFirstScanline = GetScanline(0);
+    const long nEndX = aRect.Right();
+    for (long nX = 0; nX <= nEndX; ++nX)
+        SetPixelOnData(pFirstScanline, nX, rColor);
+    const auto nScanlineSize = GetScanlineSize();
+    const long nEndY = aRect.Bottom();
+    for (long nY = 1; nY <= nEndY; nY++)
+    {
+        Scanline pDestScanline = GetScanline(nY);
+        memcpy(pDestScanline, pFirstScanline, nScanlineSize);
+    }
 }
 
 void BitmapWriteAccess::DrawLine( const Point& rStart, const Point& rEnd )


More information about the Libreoffice-commits mailing list