diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2021-04-05 22:34:32 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2021-04-06 08:40:35 +0200 |
commit | e992f5c53aadbbfdf93a45f4011fc8733315585f (patch) | |
tree | 3f9d085b98465bc932b36db79f8a65343ee3954a /vcl/quartz | |
parent | 615ceb107e9faf01b568b0a2440a3f09c8f88ca6 (diff) |
vcl: use PixelFormat enum in SalBitmap interface and backends
This changes all backends to use PixelFormat as the input to
the SalBitmap::Create method (and all the backends). This is the
first part as we need to make sure to also limit the use of
GetBitCount method and also use of it in SalGraphics.
Change-Id: I8d2b6adfcb8fe3dd78010538411f338c9a1c3996
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113603
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'vcl/quartz')
-rw-r--r-- | vcl/quartz/salbmp.cxx | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/vcl/quartz/salbmp.cxx b/vcl/quartz/salbmp.cxx index 1b9a777616de..72c0b8d5634f 100644 --- a/vcl/quartz/salbmp.cxx +++ b/vcl/quartz/salbmp.cxx @@ -48,12 +48,6 @@ const unsigned long k32BitRedColorMask = 0x00ff0000; const unsigned long k32BitGreenColorMask = 0x0000ff00; const unsigned long k32BitBlueColorMask = 0x000000ff; -static bool isValidBitCount( sal_uInt16 nBitCount ) -{ - return (nBitCount == 1) || (nBitCount == 4) || (nBitCount == 8) || - (nBitCount == 24) || (nBitCount == 32); -} - QuartzSalBitmap::QuartzSalBitmap() : mxCachedImage( nullptr ) , mnBits(0) @@ -68,13 +62,13 @@ QuartzSalBitmap::~QuartzSalBitmap() doDestroy(); } -bool QuartzSalBitmap::Create( const Size& rSize, sal_uInt16 nBits, const BitmapPalette& rBitmapPalette ) +bool QuartzSalBitmap::Create( const Size& rSize, vcl::PixelFormat ePixelFormat, const BitmapPalette& rBitmapPalette ) { - if( !isValidBitCount( nBits ) ) + if (ePixelFormat == vcl::PixelFormat::INVALID) return false; maPalette = rBitmapPalette; - mnBits = nBits; + mnBits = vcl::pixelFormatBitCount(ePixelFormat); mnWidth = rSize.Width(); mnHeight = rSize.Height(); return AllocateUserData(); @@ -82,21 +76,28 @@ bool QuartzSalBitmap::Create( const Size& rSize, sal_uInt16 nBits, const BitmapP bool QuartzSalBitmap::Create( const SalBitmap& rSalBmp ) { - return Create( rSalBmp, rSalBmp.GetBitCount() ); + vcl::PixelFormat ePixelFormat = vcl::bitDepthToPixelFormat(rSalBmp.GetBitCount()); + return Create( rSalBmp, ePixelFormat); } bool QuartzSalBitmap::Create( const SalBitmap& rSalBmp, SalGraphics* pGraphics ) { - return Create( rSalBmp, pGraphics ? pGraphics->GetBitCount() : rSalBmp.GetBitCount() ); + vcl::PixelFormat ePixelFormat = vcl::PixelFormat::INVALID; + if (pGraphics) + ePixelFormat = vcl::bitDepthToPixelFormat(pGraphics->GetBitCount()); + else + ePixelFormat = vcl::bitDepthToPixelFormat(rSalBmp.GetBitCount()); + + return Create( rSalBmp, ePixelFormat); } -bool QuartzSalBitmap::Create( const SalBitmap& rSalBmp, sal_uInt16 nNewBitCount ) +bool QuartzSalBitmap::Create( const SalBitmap& rSalBmp, vcl::PixelFormat eNewPixelFormat ) { const QuartzSalBitmap& rSourceBitmap = static_cast<const QuartzSalBitmap&>(rSalBmp); - if (isValidBitCount(nNewBitCount) && rSourceBitmap.m_pUserBuffer) + if (eNewPixelFormat != vcl::PixelFormat::INVALID && rSourceBitmap.m_pUserBuffer) { - mnBits = nNewBitCount; + mnBits = vcl::pixelFormatBitCount(eNewPixelFormat); mnWidth = rSourceBitmap.mnWidth; mnHeight = rSourceBitmap.mnHeight; maPalette = rSourceBitmap.maPalette; |