diff options
Diffstat (limited to 'core/fpdfapi/render')
-rw-r--r-- | core/fpdfapi/render/cpdf_type3cache.cpp | 20 | ||||
-rw-r--r-- | core/fpdfapi/render/cpdf_type3cache.h | 10 | ||||
-rw-r--r-- | core/fpdfapi/render/cpdf_type3glyphs.cpp | 5 | ||||
-rw-r--r-- | core/fpdfapi/render/cpdf_type3glyphs.h | 3 |
4 files changed, 19 insertions, 19 deletions
diff --git a/core/fpdfapi/render/cpdf_type3cache.cpp b/core/fpdfapi/render/cpdf_type3cache.cpp index b7a4cb808f..699b24f15c 100644 --- a/core/fpdfapi/render/cpdf_type3cache.cpp +++ b/core/fpdfapi/render/cpdf_type3cache.cpp @@ -104,19 +104,21 @@ CFX_GlyphBitmap* CPDF_Type3Cache::LoadGlyph(uint32_t charcode, } auto it2 = pSizeCache->m_GlyphMap.find(charcode); if (it2 != pSizeCache->m_GlyphMap.end()) - return it2->second; + return it2->second.get(); - CFX_GlyphBitmap* pGlyphBitmap = + std::unique_ptr<CFX_GlyphBitmap> pNewBitmap = RenderGlyph(pSizeCache, charcode, pMatrix, retinaScaleX, retinaScaleY); - pSizeCache->m_GlyphMap[charcode] = pGlyphBitmap; + CFX_GlyphBitmap* pGlyphBitmap = pNewBitmap.get(); + pSizeCache->m_GlyphMap[charcode] = std::move(pNewBitmap); return pGlyphBitmap; } -CFX_GlyphBitmap* CPDF_Type3Cache::RenderGlyph(CPDF_Type3Glyphs* pSize, - uint32_t charcode, - const CFX_Matrix* pMatrix, - float retinaScaleX, - float retinaScaleY) { +std::unique_ptr<CFX_GlyphBitmap> CPDF_Type3Cache::RenderGlyph( + CPDF_Type3Glyphs* pSize, + uint32_t charcode, + const CFX_Matrix* pMatrix, + float retinaScaleX, + float retinaScaleY) { const CPDF_Type3Char* pChar = m_pFont->LoadChar(charcode); if (!pChar || !pChar->m_pBitmap) return nullptr; @@ -163,7 +165,7 @@ CFX_GlyphBitmap* CPDF_Type3Cache::RenderGlyph(CPDF_Type3Glyphs* pSize, if (!pResBitmap) return nullptr; - CFX_GlyphBitmap* pGlyph = new CFX_GlyphBitmap; + auto pGlyph = pdfium::MakeUnique<CFX_GlyphBitmap>(); pGlyph->m_Left = left; pGlyph->m_Top = -top; pGlyph->m_pBitmap->TakeOver(std::move(pResBitmap)); diff --git a/core/fpdfapi/render/cpdf_type3cache.h b/core/fpdfapi/render/cpdf_type3cache.h index dc3e91b359..3c7d95b8c0 100644 --- a/core/fpdfapi/render/cpdf_type3cache.h +++ b/core/fpdfapi/render/cpdf_type3cache.h @@ -32,11 +32,11 @@ class CPDF_Type3Cache : public CFX_Retainable { explicit CPDF_Type3Cache(CPDF_Type3Font* pFont); ~CPDF_Type3Cache() override; - CFX_GlyphBitmap* RenderGlyph(CPDF_Type3Glyphs* pSize, - uint32_t charcode, - const CFX_Matrix* pMatrix, - float retinaScaleX, - float retinaScaleY); + std::unique_ptr<CFX_GlyphBitmap> RenderGlyph(CPDF_Type3Glyphs* pSize, + uint32_t charcode, + const CFX_Matrix* pMatrix, + float retinaScaleX, + float retinaScaleY); CPDF_Type3Font* const m_pFont; std::map<CFX_ByteString, std::unique_ptr<CPDF_Type3Glyphs>> m_SizeMap; diff --git a/core/fpdfapi/render/cpdf_type3glyphs.cpp b/core/fpdfapi/render/cpdf_type3glyphs.cpp index 5fce32ce93..01b689f80f 100644 --- a/core/fpdfapi/render/cpdf_type3glyphs.cpp +++ b/core/fpdfapi/render/cpdf_type3glyphs.cpp @@ -13,10 +13,7 @@ CPDF_Type3Glyphs::CPDF_Type3Glyphs() : m_TopBlueCount(0), m_BottomBlueCount(0) {} -CPDF_Type3Glyphs::~CPDF_Type3Glyphs() { - for (const auto& pair : m_GlyphMap) - delete pair.second; -} +CPDF_Type3Glyphs::~CPDF_Type3Glyphs() {} static int _AdjustBlue(float pos, int& count, int blues[]) { float min_distance = 1000000.0f; diff --git a/core/fpdfapi/render/cpdf_type3glyphs.h b/core/fpdfapi/render/cpdf_type3glyphs.h index 443910dac0..778b639642 100644 --- a/core/fpdfapi/render/cpdf_type3glyphs.h +++ b/core/fpdfapi/render/cpdf_type3glyphs.h @@ -8,6 +8,7 @@ #define CORE_FPDFAPI_RENDER_CPDF_TYPE3GLYPHS_H_ #include <map> +#include <memory> #include "core/fxcrt/fx_system.h" @@ -22,7 +23,7 @@ class CPDF_Type3Glyphs { void AdjustBlue(float top, float bottom, int& top_line, int& bottom_line); - std::map<uint32_t, CFX_GlyphBitmap*> m_GlyphMap; + std::map<uint32_t, std::unique_ptr<CFX_GlyphBitmap>> m_GlyphMap; int m_TopBlue[TYPE3_MAX_BLUES]; int m_BottomBlue[TYPE3_MAX_BLUES]; int m_TopBlueCount; |