From 1a1d7648d3e338b756e464cebb2ae1a815359afa Mon Sep 17 00:00:00 2001 From: tsepez Date: Tue, 6 Dec 2016 06:29:28 -0800 Subject: Return unique_ptrs from CFX_DIBitmap::Clone(). Because that's what clone does. Perform immediate release in some spots to avoid disrupting too much at once. Review-Url: https://codereview.chromium.org/2534953004 --- core/fxge/win32/fx_win32_device.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'core/fxge/win32/fx_win32_device.cpp') diff --git a/core/fxge/win32/fx_win32_device.cpp b/core/fxge/win32/fx_win32_device.cpp index 004f344d67..e0d2e60a15 100644 --- a/core/fxge/win32/fx_win32_device.cpp +++ b/core/fxge/win32/fx_win32_device.cpp @@ -11,6 +11,7 @@ #include #include "core/fxcodec/fx_codec.h" +#include "core/fxcrt/cfx_maybe_owned.h" #include "core/fxcrt/fx_memory.h" #include "core/fxcrt/fx_system.h" #include "core/fxge/cfx_fontmapper.h" @@ -813,7 +814,7 @@ bool CGdiDeviceDriver::GDI_SetDIBits(CFX_DIBitmap* pBitmap1, } else { CFX_DIBitmap* pBitmap = pBitmap1; if (pBitmap->IsCmykImage()) { - pBitmap = pBitmap->CloneConvert(FXDIB_Rgb); + pBitmap = pBitmap->CloneConvert(FXDIB_Rgb).release(); if (!pBitmap) return false; } @@ -852,23 +853,19 @@ bool CGdiDeviceDriver::GDI_StretchDIBits(CFX_DIBitmap* pBitmap1, } else { SetStretchBltMode(m_hDC, COLORONCOLOR); } - CFX_DIBitmap* pToStrechBitmap = pBitmap; - bool del = false; + CFX_MaybeOwned pToStrechBitmap(pBitmap); if (m_DeviceClass == FXDC_PRINTER && ((int64_t)pBitmap->GetWidth() * pBitmap->GetHeight() > (int64_t)abs(dest_width) * abs(dest_height))) { pToStrechBitmap = pBitmap->StretchTo(dest_width, dest_height); - del = true; } CFX_ByteString toStrechBitmapInfo = - CFX_WindowsDIB::GetBitmapInfo(pToStrechBitmap); + CFX_WindowsDIB::GetBitmapInfo(pToStrechBitmap.Get()); ::StretchDIBits(m_hDC, dest_left, dest_top, dest_width, dest_height, 0, 0, pToStrechBitmap->GetWidth(), pToStrechBitmap->GetHeight(), pToStrechBitmap->GetBuffer(), (BITMAPINFO*)toStrechBitmapInfo.c_str(), DIB_RGB_COLORS, SRCCOPY); - if (del) - delete pToStrechBitmap; return true; } -- cgit v1.2.3