From c38cd6eb274429a5755e04d2e22a606375851717 Mon Sep 17 00:00:00 2001 From: weili Date: Thu, 21 Jul 2016 14:44:17 -0700 Subject: Use smart pointers for graphics device classes Use unique_ptr for class owned member variables. Also clean up some style issues such as removing unused functions and casting to raw pointer. BUG=pdfium:518 Review-Url: https://codereview.chromium.org/2163103002 --- core/fxge/win32/fx_win32_device.cpp | 12 ++++++------ core/fxge/win32/fx_win32_print.cpp | 6 +++--- 2 files changed, 9 insertions(+), 9 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 0b08bba8df..78abd5da1d 100644 --- a/core/fxge/win32/fx_win32_device.cpp +++ b/core/fxge/win32/fx_win32_device.cpp @@ -14,6 +14,7 @@ #include #include "core/fxcodec/include/fx_codec.h" +#include "core/fxcrt/include/fx_memory.h" #ifndef _SKIA_SUPPORT_ #include "core/fxge/agg/fx_agg_driver.h" @@ -1253,7 +1254,7 @@ FX_BOOL CGdiDisplayDriver::SetDIBits(const CFX_DIBSource* pSource, return SetDIBits(&bitmap, 0, &src_rect, left, top, FXDIB_BLEND_NORMAL); } CFX_DIBExtractor temp(pSource); - CFX_DIBitmap* pBitmap = temp; + CFX_DIBitmap* pBitmap = temp.GetBitmap(); if (!pBitmap) return FALSE; return GDI_SetDIBits(pBitmap, pSrcRect, left, top); @@ -1335,7 +1336,7 @@ FX_BOOL CGdiDisplayDriver::StretchDIBits(const CFX_DIBSource* pSource, (CWin32Platform*)CFX_GEModule::Get()->GetPlatformData(); if (pPlatform->m_GdiplusExt.IsAvailable() && !pSource->IsCmykImage()) { CFX_DIBExtractor temp(pSource); - CFX_DIBitmap* pBitmap = temp; + CFX_DIBitmap* pBitmap = temp.GetBitmap(); if (!pBitmap) return FALSE; return pPlatform->m_GdiplusExt.StretchDIBits( @@ -1346,7 +1347,7 @@ FX_BOOL CGdiDisplayDriver::StretchDIBits(const CFX_DIBSource* pSource, dest_width, dest_height, pClipRect, flags); } CFX_DIBExtractor temp(pSource); - CFX_DIBitmap* pBitmap = temp; + CFX_DIBitmap* pBitmap = temp.GetBitmap(); if (!pBitmap) return FALSE; return GDI_StretchDIBits(pBitmap, dest_left, dest_top, dest_width, @@ -1364,7 +1365,7 @@ FX_BOOL CGdiDisplayDriver::StartDIBits(const CFX_DIBSource* pBitmap, } CFX_WindowsDevice::CFX_WindowsDevice(HDC hDC) { - SetDeviceDriver(CreateDriver(hDC)); + SetDeviceDriver(WrapUnique(CreateDriver(hDC))); } CFX_WindowsDevice::~CFX_WindowsDevice() {} @@ -1407,8 +1408,7 @@ CFX_WinBitmapDevice::CFX_WinBitmapDevice(int width, SetBitmap(pBitmap); m_hDC = ::CreateCompatibleDC(nullptr); m_hOldBitmap = (HBITMAP)SelectObject(m_hDC, m_hBitmap); - IFX_RenderDeviceDriver* pDriver = new CGdiDisplayDriver(m_hDC); - SetDeviceDriver(pDriver); + SetDeviceDriver(WrapUnique(new CGdiDisplayDriver(m_hDC))); } CFX_WinBitmapDevice::~CFX_WinBitmapDevice() { diff --git a/core/fxge/win32/fx_win32_print.cpp b/core/fxge/win32/fx_win32_print.cpp index e1071e79f0..9e19873577 100644 --- a/core/fxge/win32/fx_win32_print.cpp +++ b/core/fxge/win32/fx_win32_print.cpp @@ -86,7 +86,7 @@ FX_BOOL CGdiPrinterDriver::SetDIBits(const CFX_DIBSource* pSource, return FALSE; CFX_DIBExtractor temp(pSource); - CFX_DIBitmap* pBitmap = temp; + CFX_DIBitmap* pBitmap = temp.GetBitmap(); if (!pBitmap) return FALSE; @@ -124,7 +124,7 @@ FX_BOOL CGdiPrinterDriver::StretchDIBits(const CFX_DIBSource* pSource, } CFX_DIBExtractor temp(pSource); - CFX_DIBitmap* pBitmap = temp; + CFX_DIBitmap* pBitmap = temp.GetBitmap(); if (!pBitmap) return FALSE; return GDI_StretchBitMask(pBitmap, dest_left, dest_top, dest_width, @@ -150,7 +150,7 @@ FX_BOOL CGdiPrinterDriver::StretchDIBits(const CFX_DIBSource* pSource, } CFX_DIBExtractor temp(pSource); - CFX_DIBitmap* pBitmap = temp; + CFX_DIBitmap* pBitmap = temp.GetBitmap(); if (!pBitmap) return FALSE; return GDI_StretchDIBits(pBitmap, dest_left, dest_top, dest_width, -- cgit v1.2.3