diff options
author | Noel Grandin <noelgrandin@collabora.co.uk> | 2023-12-18 10:24:26 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2023-12-18 11:26:02 +0100 |
commit | 956dc23fb132632f0bc2ab742f02a51699b40ae4 (patch) | |
tree | f2f7c0f05bfd84b99d707abf9802d3c05991745b | |
parent | cbc6bb9fdaf4acc815b9f11fba73c33d25a81e8f (diff) |
no need to allocate these on the heap
Change-Id: Ic8a2bd941fa0f6b66e5ec386de5d15a38e6c75da
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160899
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | vcl/win/gdi/gdiimpl.cxx | 4 | ||||
-rw-r--r-- | vcl/win/gdi/salbmp.cxx | 18 | ||||
-rw-r--r-- | vcl/win/gdi/salgdi2.cxx | 17 |
3 files changed, 19 insertions, 20 deletions
diff --git a/vcl/win/gdi/gdiimpl.cxx b/vcl/win/gdi/gdiimpl.cxx index 5cb6a05bda48..bda9559036a5 100644 --- a/vcl/win/gdi/gdiimpl.cxx +++ b/vcl/win/gdi/gdiimpl.cxx @@ -531,12 +531,12 @@ void ImplDrawBitmap( HDC hDC, const SalTwoRect& rPosAry, const WinSalBitmap& rSa { HGLOBAL hDrawDIB; HBITMAP hDrawDDB = rSalBitmap.ImplGethDDB(); - std::unique_ptr<WinSalBitmap> xTmpSalBmp; + std::optional<WinSalBitmap> xTmpSalBmp; bool bPrintDDB = ( bPrinter && hDrawDDB ); if( bPrintDDB ) { - xTmpSalBmp.reset(new WinSalBitmap); + xTmpSalBmp.emplace(); xTmpSalBmp->Create(rSalBitmap, vcl::bitDepthToPixelFormat(rSalBitmap.GetBitCount())); hDrawDIB = xTmpSalBmp->ImplGethDIB(); } diff --git a/vcl/win/gdi/salbmp.cxx b/vcl/win/gdi/salbmp.cxx index 71c099e952b6..46c7ea0fa932 100644 --- a/vcl/win/gdi/salbmp.cxx +++ b/vcl/win/gdi/salbmp.cxx @@ -209,14 +209,14 @@ std::shared_ptr<Gdiplus::Bitmap> WinSalBitmap::ImplCreateGdiPlusBitmap() { std::shared_ptr<Gdiplus::Bitmap> pRetval; WinSalBitmap* pSalRGB = this; - std::unique_ptr<WinSalBitmap> pExtraWinSalRGB; + std::optional<WinSalBitmap> pExtraWinSalRGB; if(!pSalRGB->ImplGethDIB()) { // we need DIB for success with AcquireBuffer, create a replacement WinSalBitmap - pExtraWinSalRGB.reset(new WinSalBitmap()); + pExtraWinSalRGB.emplace(); pExtraWinSalRGB->Create(*pSalRGB, vcl::bitDepthToPixelFormat(pSalRGB->GetBitCount())); - pSalRGB = pExtraWinSalRGB.get(); + pSalRGB = &*pExtraWinSalRGB; } BitmapBuffer* pRGB = pSalRGB->AcquireBuffer(BitmapAccessMode::Read); @@ -291,14 +291,14 @@ std::shared_ptr<Gdiplus::Bitmap> WinSalBitmap::ImplCreateGdiPlusBitmap(const Win { std::shared_ptr<Gdiplus::Bitmap> pRetval; WinSalBitmap* pSalRGB = this; - std::unique_ptr<WinSalBitmap> pExtraWinSalRGB; + std::optional<WinSalBitmap> pExtraWinSalRGB; if(!pSalRGB->ImplGethDIB()) { // we need DIB for success with AcquireBuffer, create a replacement WinSalBitmap - pExtraWinSalRGB.reset(new WinSalBitmap()); + pExtraWinSalRGB.emplace(); pExtraWinSalRGB->Create(*pSalRGB, vcl::bitDepthToPixelFormat(pSalRGB->GetBitCount())); - pSalRGB = pExtraWinSalRGB.get(); + pSalRGB = &*pExtraWinSalRGB; } BitmapBuffer* pRGB = pSalRGB->AcquireBuffer(BitmapAccessMode::Read); @@ -318,14 +318,14 @@ std::shared_ptr<Gdiplus::Bitmap> WinSalBitmap::ImplCreateGdiPlusBitmap(const Win } WinSalBitmap* pSalA = const_cast< WinSalBitmap* >(&rAlphaSource); - std::unique_ptr<WinSalBitmap> pExtraWinSalA; + std::optional<WinSalBitmap> pExtraWinSalA; if(!pSalA->ImplGethDIB()) { // we need DIB for success with AcquireBuffer, create a replacement WinSalBitmap - pExtraWinSalA.reset(new WinSalBitmap()); + pExtraWinSalA.emplace(); pExtraWinSalA->Create(*pSalA, vcl::bitDepthToPixelFormat(pSalA->GetBitCount())); - pSalA = pExtraWinSalA.get(); + pSalA = &*pExtraWinSalA; } BitmapBuffer* pA = pSalA->AcquireBuffer(BitmapAccessMode::Read); diff --git a/vcl/win/gdi/salgdi2.cxx b/vcl/win/gdi/salgdi2.cxx index 409fcc74bd82..a28a59116518 100644 --- a/vcl/win/gdi/salgdi2.cxx +++ b/vcl/win/gdi/salgdi2.cxx @@ -166,10 +166,10 @@ void WinSalGraphics::drawBitmap(const SalTwoRect& rPosAry, const SalBitmap& rSal #endif ) { - std::unique_ptr<WinSalBitmap> pWinSalBitmap(new WinSalBitmap()); + WinSalBitmap aWinSalBitmap; SalBitmap& rConstBitmap = const_cast<SalBitmap&>(rSalBitmap); - convertToWinSalBitmap(rConstBitmap, *pWinSalBitmap); - mpImpl->drawBitmap(rPosAry, *pWinSalBitmap); + convertToWinSalBitmap(rConstBitmap, aWinSalBitmap); + mpImpl->drawBitmap(rPosAry, aWinSalBitmap); } else { @@ -187,16 +187,15 @@ void WinSalGraphics::drawBitmap( const SalTwoRect& rPosAry, #endif ) { - std::unique_ptr<WinSalBitmap> pWinSalBitmap(new WinSalBitmap()); + WinSalBitmap aWinSalBitmap; SalBitmap& rConstBitmap = const_cast<SalBitmap&>(rSSalBitmap); - convertToWinSalBitmap(rConstBitmap, *pWinSalBitmap); + convertToWinSalBitmap(rConstBitmap, aWinSalBitmap); - - std::unique_ptr<WinSalBitmap> pWinTransparentSalBitmap(new WinSalBitmap()); + WinSalBitmap aWinTransparentSalBitmap; SalBitmap& rConstTransparentBitmap = const_cast<SalBitmap&>(rSTransparentBitmap); - convertToWinSalBitmap(rConstTransparentBitmap, *pWinTransparentSalBitmap); + convertToWinSalBitmap(rConstTransparentBitmap, aWinTransparentSalBitmap); - mpImpl->drawBitmap(rPosAry, *pWinSalBitmap, *pWinTransparentSalBitmap); + mpImpl->drawBitmap(rPosAry, aWinSalBitmap, aWinTransparentSalBitmap); } else { |