From 02c9c9adf65883ecaeef0e86a4b0b70ee3d5cf52 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Thu, 19 Aug 2021 20:36:03 +0200 Subject: make BitmapPalette a COW type so we can avoid copying it during rendering Change-Id: Id83d2bb2682f46188ee6ccc90c92d338a1e05b98 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120759 Tested-by: Jenkins Reviewed-by: Noel Grandin --- vcl/source/bitmap/bitmap.cxx | 40 ---------------------------------------- 1 file changed, 40 deletions(-) (limited to 'vcl/source/bitmap/bitmap.cxx') diff --git a/vcl/source/bitmap/bitmap.cxx b/vcl/source/bitmap/bitmap.cxx index e688296aa606..07f2c7bf8219 100644 --- a/vcl/source/bitmap/bitmap.cxx +++ b/vcl/source/bitmap/bitmap.cxx @@ -229,46 +229,6 @@ const BitmapPalette& Bitmap::GetGreyPalette( int nEntries ) return GetGreyPalette(2); } -bool BitmapPalette::IsGreyPaletteAny() const -{ - const int nEntryCount = GetEntryCount(); - if( !nEntryCount ) // NOTE: an empty palette means 1:1 mapping - return true; - // See above: only certain entry values will result in a valid call to GetGreyPalette - if( nEntryCount == 2 || nEntryCount == 4 || nEntryCount == 16 || nEntryCount == 256 ) - { - const BitmapPalette& rGreyPalette = Bitmap::GetGreyPalette( nEntryCount ); - if( rGreyPalette == *this ) - return true; - } - - bool bRet = false; - // TODO: is it worth to compare the entries for the general case? - if (nEntryCount == 2) - { - const BitmapColor& rCol0(maBitmapColor[0]); - const BitmapColor& rCol1(maBitmapColor[1]); - bRet = rCol0.GetRed() == rCol0.GetGreen() && rCol0.GetRed() == rCol0.GetBlue() && - rCol1.GetRed() == rCol1.GetGreen() && rCol1.GetRed() == rCol1.GetBlue(); - } - return bRet; -} - -bool BitmapPalette::IsGreyPalette8Bit() const -{ - const int nEntryCount = GetEntryCount(); - if( !nEntryCount ) // NOTE: an empty palette means 1:1 mapping - return true; - if( nEntryCount != 256 ) - return false; - for (sal_uInt16 i = 0; i < 256; ++i) - { - if( maBitmapColor[i] != BitmapColor(i, i, i)) - return false; - } - return true; -} - Bitmap& Bitmap::operator=( const Bitmap& rBitmap ) { if (this == &rBitmap) -- cgit