diff options
author | thestig <thestig@chromium.org> | 2016-05-12 15:35:00 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-05-12 15:35:00 -0700 |
commit | 39fbb7e1c2282a46d9bd3adfd030916dcb0155ef (patch) | |
tree | 096b3687e8641d73c8513b4805f046b59b0102eb /core/fpdfapi/fpdf_font | |
parent | a0a3bc3482e78a545e8f8290f7d35f42aa968814 (diff) | |
download | pdfium-39fbb7e1c2282a46d9bd3adfd030916dcb0155ef.tar.xz |
Clean up CFX_ImageTransformer.
Review-Url: https://codereview.chromium.org/1973913002
Diffstat (limited to 'core/fpdfapi/fpdf_font')
-rw-r--r-- | core/fpdfapi/fpdf_font/cpdf_type3char.cpp | 38 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_font/cpdf_type3char.h | 6 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_font/cpdf_type3font.cpp | 6 |
3 files changed, 23 insertions, 27 deletions
diff --git a/core/fpdfapi/fpdf_font/cpdf_type3char.cpp b/core/fpdfapi/fpdf_font/cpdf_type3char.cpp index 44219ee02d..9bfda99fd1 100644 --- a/core/fpdfapi/fpdf_font/cpdf_type3char.cpp +++ b/core/fpdfapi/fpdf_font/cpdf_type3char.cpp @@ -13,31 +13,27 @@ #include "core/fxge/include/fx_dib.h" CPDF_Type3Char::CPDF_Type3Char(CPDF_Form* pForm) - : m_pForm(pForm), m_pBitmap(nullptr), m_bColored(FALSE) {} + : m_pForm(pForm), m_bColored(FALSE) {} CPDF_Type3Char::~CPDF_Type3Char() { - delete m_pForm; - delete m_pBitmap; } FX_BOOL CPDF_Type3Char::LoadBitmap(CPDF_RenderContext* pContext) { - if (m_pBitmap || !m_pForm) { + if (m_pBitmap || !m_pForm) return TRUE; - } - if (m_pForm->GetPageObjectList()->size() == 1 && !m_bColored) { - auto& pPageObj = m_pForm->GetPageObjectList()->front(); - if (pPageObj->IsImage()) { - m_ImageMatrix = pPageObj->AsImage()->m_Matrix; - const CFX_DIBSource* pSource = - pPageObj->AsImage()->m_pImage->LoadDIBSource(); - if (pSource) { - m_pBitmap = pSource->Clone(); - delete pSource; - } - delete m_pForm; - m_pForm = NULL; - return TRUE; - } - } - return FALSE; + + if (m_pForm->GetPageObjectList()->size() != 1 || m_bColored) + return FALSE; + + auto& pPageObj = m_pForm->GetPageObjectList()->front(); + if (!pPageObj->IsImage()) + return FALSE; + + m_ImageMatrix = pPageObj->AsImage()->m_Matrix; + std::unique_ptr<CFX_DIBSource> pSource( + pPageObj->AsImage()->m_pImage->LoadDIBSource()); + if (pSource) + m_pBitmap.reset(pSource->Clone()); + m_pForm.reset(); + return TRUE; } diff --git a/core/fpdfapi/fpdf_font/cpdf_type3char.h b/core/fpdfapi/fpdf_font/cpdf_type3char.h index c67620b5f6..7b101d3172 100644 --- a/core/fpdfapi/fpdf_font/cpdf_type3char.h +++ b/core/fpdfapi/fpdf_font/cpdf_type3char.h @@ -7,6 +7,8 @@ #ifndef CORE_FPDFAPI_FPDF_FONT_CPDF_TYPE3CHAR_H_ #define CORE_FPDFAPI_FPDF_FONT_CPDF_TYPE3CHAR_H_ +#include <memory> + #include "core/fxcrt/include/fx_coordinates.h" #include "core/fxcrt/include/fx_system.h" @@ -22,8 +24,8 @@ class CPDF_Type3Char { FX_BOOL LoadBitmap(CPDF_RenderContext* pContext); - CPDF_Form* m_pForm; - CFX_DIBitmap* m_pBitmap; + std::unique_ptr<CPDF_Form> m_pForm; + std::unique_ptr<CFX_DIBitmap> m_pBitmap; FX_BOOL m_bColored; int m_Width; CFX_Matrix m_ImageMatrix; diff --git a/core/fpdfapi/fpdf_font/cpdf_type3font.cpp b/core/fpdfapi/fpdf_font/cpdf_type3font.cpp index be280948ae..6c339ea5a7 100644 --- a/core/fpdfapi/fpdf_font/cpdf_type3font.cpp +++ b/core/fpdfapi/fpdf_font/cpdf_type3font.cpp @@ -136,10 +136,8 @@ CPDF_Type3Char* CPDF_Type3Font::LoadChar(uint32_t charcode, int level) { ASSERT(!pdfium::ContainsKey(m_CacheMap, charcode)); CPDF_Type3Char* pCachedChar = pNewChar.release(); m_CacheMap[charcode] = pCachedChar; - if (pCachedChar->m_pForm->GetPageObjectList()->empty()) { - delete pCachedChar->m_pForm; - pCachedChar->m_pForm = nullptr; - } + if (pCachedChar->m_pForm->GetPageObjectList()->empty()) + pCachedChar->m_pForm.reset(); return pCachedChar; } |