diff options
author | weili <weili@chromium.org> | 2016-07-21 14:44:17 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-07-21 14:44:17 -0700 |
commit | c38cd6eb274429a5755e04d2e22a606375851717 (patch) | |
tree | 158c1e58b7d66a715cd7ba1459c55d329f08c49d /core/fxge/dib | |
parent | 1d3348ce0092d6d2a40de5f8433c0d0c16a1e12e (diff) | |
download | pdfium-c38cd6eb274429a5755e04d2e22a606375851717.tar.xz |
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
Diffstat (limited to 'core/fxge/dib')
-rw-r--r-- | core/fxge/dib/fx_dib_main.cpp | 35 |
1 files changed, 12 insertions, 23 deletions
diff --git a/core/fxge/dib/fx_dib_main.cpp b/core/fxge/dib/fx_dib_main.cpp index b977a6239c..4c294adf5f 100644 --- a/core/fxge/dib/fx_dib_main.cpp +++ b/core/fxge/dib/fx_dib_main.cpp @@ -6,8 +6,8 @@ #include "core/fxge/include/fx_dib.h" -#include <algorithm> #include <limits.h> +#include <algorithm> #include "core/fxcodec/include/fx_codec.h" #include "core/fxge/dib/dib_int.h" @@ -1459,36 +1459,28 @@ CFX_DIBitmap* CFX_DIBSource::FlipImage(FX_BOOL bXFlip, FX_BOOL bYFlip) const { } CFX_DIBExtractor::CFX_DIBExtractor(const CFX_DIBSource* pSrc) { - m_pBitmap = nullptr; if (pSrc->GetBuffer()) { - m_pBitmap = new CFX_DIBitmap; + m_pBitmap.reset(new CFX_DIBitmap); if (!m_pBitmap->Create(pSrc->GetWidth(), pSrc->GetHeight(), pSrc->GetFormat(), pSrc->GetBuffer())) { - delete m_pBitmap; - m_pBitmap = nullptr; + m_pBitmap.reset(); return; } m_pBitmap->CopyPalette(pSrc->GetPalette()); m_pBitmap->CopyAlphaMask(pSrc->m_pAlphaMask); } else { - m_pBitmap = pSrc->Clone(); + m_pBitmap.reset(pSrc->Clone()); } } -CFX_DIBExtractor::~CFX_DIBExtractor() { - delete m_pBitmap; -} +CFX_DIBExtractor::~CFX_DIBExtractor() {} -CFX_FilteredDIB::CFX_FilteredDIB() { - m_pScanline = nullptr; - m_pSrc = nullptr; -} +CFX_FilteredDIB::CFX_FilteredDIB() : m_pSrc(nullptr) {} CFX_FilteredDIB::~CFX_FilteredDIB() { if (m_bAutoDropSrc) { delete m_pSrc; } - FX_Free(m_pScanline); } void CFX_FilteredDIB::LoadSrc(const CFX_DIBSource* pSrc, FX_BOOL bAutoDropSrc) { @@ -1501,12 +1493,12 @@ void CFX_FilteredDIB::LoadSrc(const CFX_DIBSource* pSrc, FX_BOOL bAutoDropSrc) { m_AlphaFlag = (uint8_t)(format >> 8); m_Pitch = (m_Width * (format & 0xff) + 31) / 32 * 4; m_pPalette.reset(GetDestPalette()); - m_pScanline = FX_Alloc(uint8_t, m_Pitch); + m_Scanline.resize(m_Pitch); } const uint8_t* CFX_FilteredDIB::GetScanline(int line) const { - TranslateScanline(m_pScanline, m_pSrc->GetScanline(line)); - return m_pScanline; + TranslateScanline(m_pSrc->GetScanline(line), &m_Scanline); + return m_Scanline.data(); } void CFX_FilteredDIB::DownSampleScanline(int line, @@ -1523,14 +1515,11 @@ void CFX_FilteredDIB::DownSampleScanline(int line, CFX_ImageRenderer::CFX_ImageRenderer() { m_Status = 0; - m_pTransformer = nullptr; m_bRgbByteOrder = FALSE; m_BlendType = FXDIB_BLEND_NORMAL; } -CFX_ImageRenderer::~CFX_ImageRenderer() { - delete m_pTransformer; -} +CFX_ImageRenderer::~CFX_ImageRenderer() {} FX_BOOL CFX_ImageRenderer::Start(CFX_DIBitmap* pDevice, const CFX_ClipRgn* pClipRgn, @@ -1587,8 +1576,8 @@ FX_BOOL CFX_ImageRenderer::Start(CFX_DIBitmap* pDevice, return TRUE; } m_Status = 2; - m_pTransformer = - new CFX_ImageTransformer(pSource, &m_Matrix, dib_flags, &m_ClipBox); + m_pTransformer.reset( + new CFX_ImageTransformer(pSource, &m_Matrix, dib_flags, &m_ClipBox)); m_pTransformer->Start(); return TRUE; } |