From b8642f8a3c3a6d359c4e319b8ba91f8df6448a4f Mon Sep 17 00:00:00 2001 From: tsepez Date: Wed, 14 Dec 2016 19:48:47 -0800 Subject: More unique_ptr returns from DIB methods. Review-Url: https://codereview.chromium.org/2572293002 --- core/fxge/win32/fx_win32_device.cpp | 9 +++------ core/fxge/win32/fx_win32_print.cpp | 12 ++++++------ 2 files changed, 9 insertions(+), 12 deletions(-) (limited to 'core/fxge/win32') diff --git a/core/fxge/win32/fx_win32_device.cpp b/core/fxge/win32/fx_win32_device.cpp index 2746587be2..679479160f 100644 --- a/core/fxge/win32/fx_win32_device.cpp +++ b/core/fxge/win32/fx_win32_device.cpp @@ -795,7 +795,7 @@ bool CGdiDeviceDriver::GDI_SetDIBits(CFX_DIBitmap* pBitmap1, int left, int top) { if (m_DeviceClass == FXDC_PRINTER) { - std::unique_ptr pBitmap(pBitmap1->FlipImage(false, true)); + std::unique_ptr pBitmap = pBitmap1->FlipImage(false, true); if (!pBitmap) return false; @@ -814,7 +814,7 @@ bool CGdiDeviceDriver::GDI_SetDIBits(CFX_DIBitmap* pBitmap1, dst_height, pBuffer, (BITMAPINFO*)info.c_str(), DIB_RGB_COLORS, SRCCOPY); } else { - CFX_DIBitmap* pBitmap = pBitmap1; + CFX_MaybeOwned pBitmap(pBitmap1); if (pBitmap->IsCmykImage()) { pBitmap = pBitmap->CloneConvert(FXDIB_Rgb).release(); if (!pBitmap) @@ -822,14 +822,11 @@ bool CGdiDeviceDriver::GDI_SetDIBits(CFX_DIBitmap* pBitmap1, } int width = pSrcRect->Width(), height = pSrcRect->Height(); LPBYTE pBuffer = pBitmap->GetBuffer(); - CFX_ByteString info = CFX_WindowsDIB::GetBitmapInfo(pBitmap); + CFX_ByteString info = CFX_WindowsDIB::GetBitmapInfo(pBitmap.Get()); ::SetDIBitsToDevice(m_hDC, left, top, width, height, pSrcRect->left, pBitmap->GetHeight() - pSrcRect->bottom, 0, pBitmap->GetHeight(), pBuffer, (BITMAPINFO*)info.c_str(), DIB_RGB_COLORS); - if (pBitmap != pBitmap1) { - delete pBitmap; - } } return true; } diff --git a/core/fxge/win32/fx_win32_print.cpp b/core/fxge/win32/fx_win32_print.cpp index 5a1a01a418..2ff072f6a5 100644 --- a/core/fxge/win32/fx_win32_print.cpp +++ b/core/fxge/win32/fx_win32_print.cpp @@ -108,8 +108,8 @@ bool CGdiPrinterDriver::StretchDIBits(const CFX_DIBSource* pSource, return false; if (dest_width < 0 || dest_height < 0) { - std::unique_ptr pFlipped( - pSource->FlipImage(dest_width < 0, dest_height < 0)); + std::unique_ptr pFlipped = + pSource->FlipImage(dest_width < 0, dest_height < 0); if (!pFlipped) return false; @@ -135,8 +135,8 @@ bool CGdiPrinterDriver::StretchDIBits(const CFX_DIBSource* pSource, return false; if (dest_width < 0 || dest_height < 0) { - std::unique_ptr pFlipped( - pSource->FlipImage(dest_width < 0, dest_height < 0)); + std::unique_ptr pFlipped = + pSource->FlipImage(dest_width < 0, dest_height < 0); if (!pFlipped) return false; @@ -184,8 +184,8 @@ bool CGdiPrinterDriver::StartDIBits(const CFX_DIBSource* pSource, if (FXSYS_fabs(pMatrix->a) >= 0.5f || FXSYS_fabs(pMatrix->d) >= 0.5f) return false; - std::unique_ptr pTransformed( - pSource->SwapXY(pMatrix->c > 0, pMatrix->b < 0)); + std::unique_ptr pTransformed = + pSource->SwapXY(pMatrix->c > 0, pMatrix->b < 0); if (!pTransformed) return false; -- cgit v1.2.3