diff options
Diffstat (limited to 'core/src/fpdfapi/fpdf_render')
-rw-r--r-- | core/src/fpdfapi/fpdf_render/fpdf_render_text.cpp | 19 | ||||
-rw-r--r-- | core/src/fpdfapi/fpdf_render/render_int.h | 11 |
2 files changed, 16 insertions, 14 deletions
diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render_text.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render_text.cpp index d36125e1b8..50388332f8 100644 --- a/core/src/fpdfapi/fpdf_render/fpdf_render_text.cpp +++ b/core/src/fpdfapi/fpdf_render/fpdf_render_text.cpp @@ -11,14 +11,10 @@ #include "render_int.h" extern FX_BOOL IsAvailableMatrix(const CFX_AffineMatrix& matrix); CPDF_Type3Cache::~CPDF_Type3Cache() { - FX_POSITION pos = m_SizeMap.GetStartPosition(); - CFX_ByteString Key; - CPDF_Type3Glyphs* pSizeCache = NULL; - while (pos) { - pSizeCache = (CPDF_Type3Glyphs*)m_SizeMap.GetNextValue(pos); - delete pSizeCache; + for (const auto& pair : m_SizeMap) { + delete pair.second; } - m_SizeMap.RemoveAll(); + m_SizeMap.clear(); } CFX_GlyphBitmap* CPDF_Type3Cache::LoadGlyph(FX_DWORD charcode, const CFX_AffineMatrix* pMatrix, @@ -29,10 +25,13 @@ CFX_GlyphBitmap* CPDF_Type3Cache::LoadGlyph(FX_DWORD charcode, 4, FXSYS_round(pMatrix->a * 10000), FXSYS_round(pMatrix->b * 10000), FXSYS_round(pMatrix->c * 10000), FXSYS_round(pMatrix->d * 10000)); CFX_ByteStringC FaceGlyphsKey(keygen.m_Key, keygen.m_KeyLen); - CPDF_Type3Glyphs* pSizeCache = NULL; - if (!m_SizeMap.Lookup(FaceGlyphsKey, (void*&)pSizeCache)) { + CPDF_Type3Glyphs* pSizeCache; + auto it = m_SizeMap.find(FaceGlyphsKey); + if (it == m_SizeMap.end()) { pSizeCache = new CPDF_Type3Glyphs; - m_SizeMap.SetAt(FaceGlyphsKey, pSizeCache); + m_SizeMap[FaceGlyphsKey] = pSizeCache; + } else { + pSizeCache = it->second; } CFX_GlyphBitmap* pGlyphBitmap; if (pSizeCache->m_GlyphMap.Lookup((void*)(uintptr_t)charcode, diff --git a/core/src/fpdfapi/fpdf_render/render_int.h b/core/src/fpdfapi/fpdf_render/render_int.h index 733e24cbcf..e195472ac1 100644 --- a/core/src/fpdfapi/fpdf_render/render_int.h +++ b/core/src/fpdfapi/fpdf_render/render_int.h @@ -12,8 +12,11 @@ #include "../../../../third_party/base/nonstd_unique_ptr.h" #include "../../../include/fpdfapi/fpdf_pageobj.h" +class CFX_GlyphBitmap; class CPDF_QuickStretcher; + #define TYPE3_MAX_BLUES 16 + class CPDF_Type3Glyphs { public: CPDF_Type3Glyphs() { @@ -30,11 +33,11 @@ class CPDF_Type3Glyphs { int m_TopBlue[TYPE3_MAX_BLUES], m_BottomBlue[TYPE3_MAX_BLUES]; int m_TopBlueCount, m_BottomBlueCount; }; -class CFX_GlyphBitmap; class CPDF_Type3Cache { public: - CPDF_Type3Cache(CPDF_Type3Font* pFont) { m_pFont = pFont; } + explicit CPDF_Type3Cache(CPDF_Type3Font* pFont) : m_pFont(pFont) {} ~CPDF_Type3Cache(); + CFX_GlyphBitmap* LoadGlyph(FX_DWORD charcode, const CFX_AffineMatrix* pMatrix, FX_FLOAT retinaScaleX = 1.0f, @@ -46,8 +49,8 @@ class CPDF_Type3Cache { const CFX_AffineMatrix* pMatrix, FX_FLOAT retinaScaleX = 1.0f, FX_FLOAT retinaScaleY = 1.0f); - CPDF_Type3Font* m_pFont; - CFX_MapByteStringToPtr m_SizeMap; + CPDF_Type3Font* const m_pFont; + std::map<CFX_ByteString, CPDF_Type3Glyphs*> m_SizeMap; }; class CPDF_TransferFunc { public: |