diff options
author | Caolán McNamara <caolanm@redhat.com> | 2017-03-30 16:13:49 +0100 |
---|---|---|
committer | Ashod Nakashian <ashod.nakashian@collabora.co.uk> | 2017-12-05 08:17:22 -0500 |
commit | 2923bf33c1591323f5aaae0b121bdda4cc8c9e61 (patch) | |
tree | 2e5886319f9f7f607c5c4b894b15a6e5cfd839a2 | |
parent | accc63099a6c006f40bb224418e8e4e2a344cf54 (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>
(cherry picked from commit 30d58306a93d4325f6388b8d05b9db91026c7c55)
(cherry picked from commit b4e6579b3ad574bf44cda3a15e6ef6dc7d233c01)
-rw-r--r-- | vcl/source/gdi/bitmap.cxx | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/vcl/source/gdi/bitmap.cxx b/vcl/source/gdi/bitmap.cxx index 83d73573fa40..621449fa3ff4 100644 --- a/vcl/source/gdi/bitmap.cxx +++ b/vcl/source/gdi/bitmap.cxx @@ -1121,9 +1121,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; |