summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2017-03-30 16:13:49 +0100
committerCaolán McNamara <caolanm@redhat.com>2017-03-30 20:12:21 +0000
commit30d58306a93d4325f6388b8d05b9db91026c7c55 (patch)
tree897bcd8160d62493fe86803478b586743f066c8c
parentd9d94d716903e34863b8e28fde90dcfbd4786284 (diff)
ofz#968 short-cut slow create mask when we are our own mask already
Change-Id: I5969226bf2da34d34e30e44ae763792cdc072bc8 Reviewed-on: https://gerrit.libreoffice.org/35921 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--vcl/source/gdi/bitmap.cxx11
1 files changed, 9 insertions, 2 deletions
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<Bitmap&>(*this));
+ ScopedReadAccess pReadAcc(const_cast<Bitmap&>(*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;