diff options
Diffstat (limited to 'core/src/fpdfapi')
-rw-r--r-- | core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp | 8 | ||||
-rw-r--r-- | core/src/fpdfapi/fpdf_render/fpdf_render_text.cpp | 22 | ||||
-rw-r--r-- | core/src/fpdfapi/fpdf_render/render_int.h | 13 |
3 files changed, 18 insertions, 25 deletions
diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp index f91ddfa5dc..ad4038d71b 100644 --- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp +++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp @@ -227,11 +227,11 @@ CPDF_Object* CPDF_Object::GetDirect() const { return pRef->m_pObjList->GetIndirectObject(pRef->GetRefObjNum()); } CPDF_Object* CPDF_Object::Clone(FX_BOOL bDirect) const { - CFX_MapPtrToPtr visited; + std::set<FX_DWORD> visited; return CloneInternal(bDirect, &visited); } CPDF_Object* CPDF_Object::CloneInternal(FX_BOOL bDirect, - CFX_MapPtrToPtr* visited) const { + std::set<FX_DWORD>* visited) const { switch (m_Type) { case PDFOBJ_BOOLEAN: return new CPDF_Boolean(AsBoolean()->m_bValue); @@ -285,8 +285,8 @@ CPDF_Object* CPDF_Object::CloneInternal(FX_BOOL bDirect, case PDFOBJ_REFERENCE: { const CPDF_Reference* pRef = AsReference(); FX_DWORD obj_num = pRef->GetRefObjNum(); - if (bDirect && !visited->GetValueAt((void*)(uintptr_t)obj_num)) { - visited->SetAt((void*)(uintptr_t)obj_num, (void*)1); + if (bDirect && visited->find(obj_num) == visited->end()) { + visited->insert(obj_num); if (!pRef->GetDirect()) return nullptr; diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render_text.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render_text.cpp index 47876a2280..227a208080 100644 --- a/core/src/fpdfapi/fpdf_render/fpdf_render_text.cpp +++ b/core/src/fpdfapi/fpdf_render/fpdf_render_text.cpp @@ -34,24 +34,18 @@ CFX_GlyphBitmap* CPDF_Type3Cache::LoadGlyph(FX_DWORD charcode, } else { pSizeCache = it->second; } - CFX_GlyphBitmap* pGlyphBitmap; - if (pSizeCache->m_GlyphMap.Lookup((void*)(uintptr_t)charcode, - (void*&)pGlyphBitmap)) { - return pGlyphBitmap; - } - pGlyphBitmap = + auto it2 = pSizeCache->m_GlyphMap.find(charcode); + if (it2 != pSizeCache->m_GlyphMap.end()) + return it2->second; + + CFX_GlyphBitmap* pGlyphBitmap = RenderGlyph(pSizeCache, charcode, pMatrix, retinaScaleX, retinaScaleY); - pSizeCache->m_GlyphMap.SetAt((void*)(uintptr_t)charcode, pGlyphBitmap); + pSizeCache->m_GlyphMap[charcode] = pGlyphBitmap; return pGlyphBitmap; } CPDF_Type3Glyphs::~CPDF_Type3Glyphs() { - FX_POSITION pos = m_GlyphMap.GetStartPosition(); - void* Key; - CFX_GlyphBitmap* pGlyphBitmap; - while (pos) { - m_GlyphMap.GetNextAssoc(pos, Key, (void*&)pGlyphBitmap); - delete pGlyphBitmap; - } + for (const auto& pair : m_GlyphMap) + delete pair.second; } static int _AdjustBlue(FX_FLOAT pos, int& count, int blues[]) { FX_FLOAT min_distance = 1000000.0f * 1.0f; diff --git a/core/src/fpdfapi/fpdf_render/render_int.h b/core/src/fpdfapi/fpdf_render/render_int.h index d173f47b7c..d348b48dfd 100644 --- a/core/src/fpdfapi/fpdf_render/render_int.h +++ b/core/src/fpdfapi/fpdf_render/render_int.h @@ -21,19 +21,18 @@ class CPDF_QuickStretcher; class CPDF_Type3Glyphs { public: - CPDF_Type3Glyphs() { - m_GlyphMap.InitHashTable(253); - m_TopBlueCount = m_BottomBlueCount = 0; - } + CPDF_Type3Glyphs() : m_TopBlueCount(0), m_BottomBlueCount(0) {} ~CPDF_Type3Glyphs(); - CFX_MapPtrToPtr m_GlyphMap; void AdjustBlue(FX_FLOAT top, FX_FLOAT bottom, int& top_line, int& bottom_line); - int m_TopBlue[TYPE3_MAX_BLUES], m_BottomBlue[TYPE3_MAX_BLUES]; - int m_TopBlueCount, m_BottomBlueCount; + std::map<FX_DWORD, CFX_GlyphBitmap*> m_GlyphMap; + int m_TopBlue[TYPE3_MAX_BLUES]; + int m_BottomBlue[TYPE3_MAX_BLUES]; + int m_TopBlueCount; + int m_BottomBlueCount; }; class CPDF_Type3Cache { public: |