diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2018-09-15 21:49:40 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-09-20 15:42:59 +0200 |
commit | be30b7616cef6efa607eba00f52c8192759f7099 (patch) | |
tree | 911fd38bb1d8134923932397404f3f24c49c0e92 /vcl/quartz | |
parent | 35e1658e7275777ee94902b5014fd93b8daf975c (diff) |
loplugin:useuniqueptr in ImplPixelFormat
Change-Id: If116578f68438550bddab5d2257b9af4ec8a69b0
Reviewed-on: https://gerrit.libreoffice.org/60705
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'vcl/quartz')
-rw-r--r-- | vcl/quartz/salbmp.cxx | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/vcl/quartz/salbmp.cxx b/vcl/quartz/salbmp.cxx index b46a7f174168..94c02fd92aee 100644 --- a/vcl/quartz/salbmp.cxx +++ b/vcl/quartz/salbmp.cxx @@ -348,7 +348,7 @@ namespace { class ImplPixelFormat { public: - static ImplPixelFormat* GetFormat( sal_uInt16 nBits, const BitmapPalette& rPalette ); + static std::unique_ptr<ImplPixelFormat> GetFormat( sal_uInt16 nBits, const BitmapPalette& rPalette ); virtual void StartLine( sal_uInt8* pLine ) = 0; virtual void SkipPixel( sal_uInt32 nPixel ) = 0; @@ -572,16 +572,16 @@ public: } }; -ImplPixelFormat* ImplPixelFormat::GetFormat( sal_uInt16 nBits, const BitmapPalette& rPalette ) +std::unique_ptr<ImplPixelFormat> ImplPixelFormat::GetFormat( sal_uInt16 nBits, const BitmapPalette& rPalette ) { switch( nBits ) { - case 1: return new ImplPixelFormat1( rPalette ); - case 4: return new ImplPixelFormat4( rPalette ); - case 8: return new ImplPixelFormat8( rPalette ); - case 16: return new ImplPixelFormat16; - case 24: return new ImplPixelFormat24; - case 32: return new ImplPixelFormat32; + case 1: return o3tl::make_unique<ImplPixelFormat1>( rPalette ); + case 4: return o3tl::make_unique<ImplPixelFormat4>( rPalette ); + case 8: return o3tl::make_unique<ImplPixelFormat8>( rPalette ); + case 16: return o3tl::make_unique<ImplPixelFormat16>(); + case 24: return o3tl::make_unique<ImplPixelFormat24>(); + case 32: return o3tl::make_unique<ImplPixelFormat32>(); default: assert(false); return nullptr; @@ -635,8 +635,8 @@ void QuartzSalBitmap::ConvertBitmapData( sal_uInt32 nWidth, sal_uInt32 nHeight, { // TODO: this implementation is for clarity, not for speed - ImplPixelFormat* pD = ImplPixelFormat::GetFormat( nDestBits, rDestPalette ); - ImplPixelFormat* pS = ImplPixelFormat::GetFormat( nSrcBits, rSrcPalette ); + std::unique_ptr<ImplPixelFormat> pD = ImplPixelFormat::GetFormat( nDestBits, rDestPalette ); + std::unique_ptr<ImplPixelFormat> pS = ImplPixelFormat::GetFormat( nSrcBits, rSrcPalette ); if( pD && pS ) { @@ -655,8 +655,6 @@ void QuartzSalBitmap::ConvertBitmapData( sal_uInt32 nWidth, sal_uInt32 nHeight, pDestData += nDestBytesPerRow; } } - delete pS; - delete pD; } } @@ -940,7 +938,7 @@ CGImageRef QuartzSalBitmap::CreateColorMask( int nX, int nY, int nWidth, std::unique_ptr<sal_uInt32[]> pMaskBuffer(new (std::nothrow) sal_uInt32[ nHeight * nDestBytesPerRow / 4] ); sal_uInt32* pDest = pMaskBuffer.get(); - ImplPixelFormat* pSourcePixels = ImplPixelFormat::GetFormat( mnBits, maPalette ); + std::unique_ptr<ImplPixelFormat> pSourcePixels = ImplPixelFormat::GetFormat( mnBits, maPalette ); if( pMaskBuffer && pSourcePixels ) { @@ -972,8 +970,6 @@ CGImageRef QuartzSalBitmap::CreateColorMask( int nX, int nY, int nWidth, SAL_INFO("vcl.cg", "CGImageCreate(" << nWidth << "x" << nHeight << "x8) = " << xMask ); CFRelease(xDataProvider); } - - delete pSourcePixels; } return xMask; } |