From 30d58306a93d4325f6388b8d05b9db91026c7c55 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Thu, 30 Mar 2017 16:13:49 +0100 Subject: ofz#968 short-cut slow create mask when we are our own mask already MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I5969226bf2da34d34e30e44ae763792cdc072bc8 Reviewed-on: https://gerrit.libreoffice.org/35921 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- vcl/source/gdi/bitmap.cxx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'vcl') diff --git a/vcl/source/gdi/bitmap.cxx b/vcl/source/gdi/bitmap.cxx index d7c9d909a753..6ec5a842f30a 100644 --- a/vcl/source/gdi/bitmap.cxx +++ b/vcl/source/gdi/bitmap.cxx @@ -1107,9 +1107,16 @@ bool Bitmap::Expand( sal_uLong nDX, sal_uLong nDY, const Color* pInitColor ) Bitmap Bitmap::CreateMask( const Color& rTransColor, sal_uLong nTol ) const { - Bitmap aNewBmp( GetSizePixel(), 1 ); - ScopedReadAccess pReadAcc(const_cast(*this)); + ScopedReadAccess pReadAcc(const_cast(*this)); + + if (!nTol && (pReadAcc->GetScanlineFormat() == ScanlineFormat::N1BitLsbPal || pReadAcc->GetScanlineFormat() == ScanlineFormat::N1BitMsbPal) + && pReadAcc->GetBestMatchingColor(Color(COL_WHITE)) == pReadAcc->GetBestMatchingColor(rTransColor)) + { + //if we're a 1 bit pixel already, and the transcolor matches the color that would replace it already already, then just return a copy + return *this; + } + Bitmap aNewBmp(GetSizePixel(), 1); ScopedWriteAccess pWriteAcc(aNewBmp); bool bRet = false; -- cgit