diff options
author | Caolán McNamara <caolanm@redhat.com> | 2019-05-03 14:55:47 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2019-05-03 17:31:06 +0200 |
commit | 8712344cf4c31f020ec9bc47f43994869d64ac08 (patch) | |
tree | 28713232cc48c38ee54e5b8a3b25bfdda8031945 | |
parent | 8d902026dc45af7b239fc6f68096a3dd31279dc9 (diff) |
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@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | vcl/source/gdi/bmpacc3.cxx | 26 |
1 files changed, 17 insertions, 9 deletions
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 ) |