From b4d1b576bccb5ca6cebe29288af014bd0f512af1 Mon Sep 17 00:00:00 2001 From: weili Date: Wed, 10 Aug 2016 14:50:48 -0700 Subject: Use smart pointers for class owned pointers in xfa/fxfa Use smart pointers instead of raw pointer to make memory management easier for classes mainly under xfa/fxfa. Also change the return type of IFGAS_FontMgr::Create() to smart pointer type. BUG=pdfium:518 Review-Url: https://codereview.chromium.org/2227883002 --- xfa/fxfa/app/xfa_ffwidget.cpp | 49 +++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 25 deletions(-) (limited to 'xfa/fxfa/app/xfa_ffwidget.cpp') diff --git a/xfa/fxfa/app/xfa_ffwidget.cpp b/xfa/fxfa/app/xfa_ffwidget.cpp index ed42aa4825..446fcd6303 100644 --- a/xfa/fxfa/app/xfa_ffwidget.cpp +++ b/xfa/fxfa/app/xfa_ffwidget.cpp @@ -564,11 +564,20 @@ class CXFA_ImageRenderer { FX_BOOL Continue(IFX_Pause* pPause); protected: + FX_BOOL StartDIBSource(); + void CompositeDIBitmap(CFX_DIBitmap* pDIBitmap, + int left, + int top, + FX_ARGB mask_argb, + int bitmap_alpha, + int blend_mode, + int Transparency); + CFX_RenderDevice* m_pDevice; int m_Status; CFX_Matrix m_ImageMatrix; CFX_DIBSource* m_pDIBSource; - CFX_DIBitmap* m_pCloneConvert; + std::unique_ptr m_pCloneConvert; int m_BitmapAlpha; FX_ARGB m_FillArgb; uint32_t m_Flags; @@ -577,31 +586,21 @@ class CXFA_ImageRenderer { int32_t m_BlendType; FX_BOOL m_Result; FX_BOOL m_bPrint; - FX_BOOL StartDIBSource(); - void CompositeDIBitmap(CFX_DIBitmap* pDIBitmap, - int left, - int top, - FX_ARGB mask_argb, - int bitmap_alpha, - int blend_mode, - int Transparency); }; -CXFA_ImageRenderer::CXFA_ImageRenderer() { - m_pDevice = nullptr; - m_Status = 0; - m_pDIBSource = nullptr; - m_pCloneConvert = nullptr; - m_BitmapAlpha = 255; - m_FillArgb = 0; - m_Flags = 0; - m_DeviceHandle = nullptr; - m_BlendType = FXDIB_BLEND_NORMAL; - m_Result = TRUE; - m_bPrint = FALSE; -} + +CXFA_ImageRenderer::CXFA_ImageRenderer() + : m_pDevice(nullptr), + m_Status(0), + m_pDIBSource(nullptr), + m_BitmapAlpha(255), + m_FillArgb(0), + m_Flags(0), + m_DeviceHandle(nullptr), + m_BlendType(FXDIB_BLEND_NORMAL), + m_Result(TRUE), + m_bPrint(FALSE) {} CXFA_ImageRenderer::~CXFA_ImageRenderer() { - delete m_pCloneConvert; if (m_DeviceHandle) m_pDevice->CancelDIBits(m_DeviceHandle); } @@ -647,12 +646,12 @@ FX_BOOL CXFA_ImageRenderer::StartDIBSource() { if (m_pDIBSource->HasAlpha() && !(m_pDevice->GetRenderCaps() & FXRC_ALPHA_IMAGE) && !(m_pDevice->GetRenderCaps() & FXRC_GET_BITS)) { - m_pCloneConvert = m_pDIBSource->CloneConvert(FXDIB_Rgb); + m_pCloneConvert.reset(m_pDIBSource->CloneConvert(FXDIB_Rgb)); if (!m_pCloneConvert) { m_Result = FALSE; return FALSE; } - pDib = m_pCloneConvert; + pDib = m_pCloneConvert.get(); } FX_RECT clip_box = m_pDevice->GetClipBox(); clip_box.Intersect(image_rect); -- cgit v1.2.3