diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2023-05-08 10:48:42 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2023-05-08 13:06:21 +0200 |
commit | 772ce2e0a98a7acc2b80bdf1143782849151e77b (patch) | |
tree | e10de9c7cd76bc82f33be38df26c6ab54ae10d22 /vcl | |
parent | c5c83c8e6c4ddbb7f1fa88b9ab0a67ccbb2627c3 (diff) |
unique_ptr->optional for Bitmap
since Bitmap is really just a tiny wrapper around SalBmp
Change-Id: Ie2c9be40f6abba72c600c6778ec42d0689c66558
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151498
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/bitmap/BitmapEx.cxx | 2 | ||||
-rw-r--r-- | vcl/source/bitmap/BitmapMosaicFilter.cxx | 4 | ||||
-rw-r--r-- | vcl/source/bitmap/BitmapTools.cxx | 8 | ||||
-rw-r--r-- | vcl/source/bitmap/impvect.cxx | 2 | ||||
-rw-r--r-- | vcl/source/filter/jpeg/JpegReader.cxx | 12 | ||||
-rw-r--r-- | vcl/source/filter/jpeg/JpegReader.hxx | 4 |
6 files changed, 16 insertions, 16 deletions
diff --git a/vcl/source/bitmap/BitmapEx.cxx b/vcl/source/bitmap/BitmapEx.cxx index f83f44d5007a..af712a0561a5 100644 --- a/vcl/source/bitmap/BitmapEx.cxx +++ b/vcl/source/bitmap/BitmapEx.cxx @@ -423,7 +423,7 @@ bool BitmapEx::CopyPixel( const tools::Rectangle& rRectDst, const tools::Rectang else { sal_uInt8 cBlack = 0; - std::unique_ptr<AlphaMask> pAlpha(new AlphaMask(GetSizePixel(), &cBlack)); + std::optional<AlphaMask> pAlpha(std::in_place, GetSizePixel(), &cBlack); maAlphaMask = pAlpha->ImplGetBitmap(); pAlpha.reset(); diff --git a/vcl/source/bitmap/BitmapMosaicFilter.cxx b/vcl/source/bitmap/BitmapMosaicFilter.cxx index a146a142bb69..25d323d023f0 100644 --- a/vcl/source/bitmap/BitmapMosaicFilter.cxx +++ b/vcl/source/bitmap/BitmapMosaicFilter.cxx @@ -22,7 +22,7 @@ BitmapEx BitmapMosaicFilter::execute(BitmapEx const& rBitmapEx) const if (mnTileWidth > 1 || mnTileHeight > 1) { - std::unique_ptr<Bitmap> pNewBmp; + std::optional<Bitmap> pNewBmp; BitmapReadAccess* pReadAcc; BitmapWriteAccess* pWriteAcc; @@ -32,7 +32,7 @@ BitmapEx BitmapMosaicFilter::execute(BitmapEx const& rBitmapEx) const } else { - pNewBmp.reset(new Bitmap(aBitmap.GetSizePixel(), vcl::PixelFormat::N24_BPP)); + pNewBmp.emplace(aBitmap.GetSizePixel(), vcl::PixelFormat::N24_BPP); pReadAcc = aBitmap.AcquireReadAccess(); pWriteAcc = pNewBmp->AcquireWriteAccess(); } diff --git a/vcl/source/bitmap/BitmapTools.cxx b/vcl/source/bitmap/BitmapTools.cxx index 164a5606debb..beec528b2f0e 100644 --- a/vcl/source/bitmap/BitmapTools.cxx +++ b/vcl/source/bitmap/BitmapTools.cxx @@ -160,11 +160,11 @@ BitmapEx CreateFromData(sal_uInt8 const *pData, sal_Int32 nWidth, sal_Int32 nHei assert(pWrite.get()); if( !pWrite ) return BitmapEx(); - std::unique_ptr<AlphaMask> pAlphaMask; + std::optional<AlphaMask> pAlphaMask; AlphaScopedWriteAccess xMaskAcc; if (nBitCount == 32) { - pAlphaMask.reset( new AlphaMask( Size(nWidth, nHeight) ) ); + pAlphaMask.emplace( Size(nWidth, nHeight) ); xMaskAcc = AlphaScopedWriteAccess(*pAlphaMask); } if (nBitCount == 1) @@ -244,11 +244,11 @@ BitmapEx CreateFromData( RawBitmap&& rawBitmap ) assert(pWrite.get()); if( !pWrite ) return BitmapEx(); - std::unique_ptr<AlphaMask> pAlphaMask; + std::optional<AlphaMask> pAlphaMask; AlphaScopedWriteAccess xMaskAcc; if (nBitCount == 32) { - pAlphaMask.reset( new AlphaMask( rawBitmap.maSize ) ); + pAlphaMask.emplace( rawBitmap.maSize ); xMaskAcc = AlphaScopedWriteAccess(*pAlphaMask); } diff --git a/vcl/source/bitmap/impvect.cxx b/vcl/source/bitmap/impvect.cxx index f3bdff4a9a4f..81a463727bb3 100644 --- a/vcl/source/bitmap/impvect.cxx +++ b/vcl/source/bitmap/impvect.cxx @@ -648,7 +648,7 @@ bool ImplVectorize( const Bitmap& rColorBmp, GDIMetaFile& rMtf, VECT_PROGRESS( pProgress, 0 ); - std::unique_ptr<Bitmap> xBmp(new Bitmap( rColorBmp )); + std::optional<Bitmap> xBmp(std::in_place, rColorBmp ); Bitmap::ScopedReadAccess pRAcc(*xBmp); if( pRAcc ) diff --git a/vcl/source/filter/jpeg/JpegReader.cxx b/vcl/source/filter/jpeg/JpegReader.cxx index f7443f3bfe9e..8d190200face 100644 --- a/vcl/source/filter/jpeg/JpegReader.cxx +++ b/vcl/source/filter/jpeg/JpegReader.cxx @@ -179,8 +179,8 @@ JPEGReader::JPEGReader( SvStream& rStream, GraphicFilterImportFlags nImportFlags if (!(nImportFlags & GraphicFilterImportFlags::UseExistingBitmap)) { - mpBitmap.reset(new Bitmap()); - mpIncompleteAlpha.reset(new Bitmap()); + mpBitmap.emplace(); + mpIncompleteAlpha.emplace(); } } @@ -199,7 +199,7 @@ bool JPEGReader::CreateBitmap(JPEGCreateBitmapParam const & rParam) Size aSize(rParam.nWidth, rParam.nHeight); bool bGray = rParam.bGray; - mpBitmap.reset(new Bitmap()); + mpBitmap.emplace(); sal_uInt64 nSize = aSize.Width() * aSize.Height(); @@ -216,11 +216,11 @@ bool JPEGReader::CreateBitmap(JPEGCreateBitmapParam const & rParam) aGrayPal[ n ] = BitmapColor( cGray, cGray, cGray ); } - mpBitmap.reset(new Bitmap(aSize, vcl::PixelFormat::N8_BPP, &aGrayPal)); + mpBitmap.emplace(aSize, vcl::PixelFormat::N8_BPP, &aGrayPal); } else { - mpBitmap.reset(new Bitmap(aSize, vcl::PixelFormat::N24_BPP)); + mpBitmap.emplace(aSize, vcl::PixelFormat::N24_BPP); } if (mbSetLogSize) @@ -249,7 +249,7 @@ Graphic JPEGReader::CreateIntermediateGraphic(tools::Long nLines) if (!mnLastLines) { - mpIncompleteAlpha.reset(new Bitmap(aSizePixel, vcl::PixelFormat::N8_BPP, &Bitmap::GetGreyPalette(256))); + mpIncompleteAlpha.emplace(aSizePixel, vcl::PixelFormat::N8_BPP, &Bitmap::GetGreyPalette(256)); mpIncompleteAlpha->Erase(COL_WHITE); } diff --git a/vcl/source/filter/jpeg/JpegReader.hxx b/vcl/source/filter/jpeg/JpegReader.hxx index 5766ef9a61d9..a4df7e212119 100644 --- a/vcl/source/filter/jpeg/JpegReader.hxx +++ b/vcl/source/filter/jpeg/JpegReader.hxx @@ -48,8 +48,8 @@ struct JPEGCreateBitmapParam class JPEGReader : public GraphicReader { SvStream& mrStream; - std::unique_ptr<Bitmap> mpBitmap; - std::unique_ptr<Bitmap> mpIncompleteAlpha; + std::optional<Bitmap> mpBitmap; + std::optional<Bitmap> mpIncompleteAlpha; tools::Long mnLastPos; tools::Long mnLastLines; |