diff options
author | Tom Sepez <tsepez@chromium.org> | 2016-01-20 14:33:49 -0800 |
---|---|---|
committer | Tom Sepez <tsepez@chromium.org> | 2016-01-20 14:33:49 -0800 |
commit | fcb6398ea511e32a09d192543f70041b82646df1 (patch) | |
tree | 5e7809400749292195e47ec24af1018d3b002343 /core/src/fxge | |
parent | 49e4932735292790c77b5362603d9f5d7f6adaaa (diff) | |
download | pdfium-fcb6398ea511e32a09d192543f70041b82646df1.tar.xz |
Merge to XFA: Replace more CFX_MapPtrToPtr.
Original Review URL: https://codereview.chromium.org/1580573002 .
(cherry picked from commit a505d9d3e13485e090e50d5d83f882fb707d3f48)
R=ochang@chromium.org
Review URL: https://codereview.chromium.org/1610163003 .
Diffstat (limited to 'core/src/fxge')
-rw-r--r-- | core/src/fxge/android/fpf_skiafontmgr.cpp | 23 | ||||
-rw-r--r-- | core/src/fxge/android/fpf_skiafontmgr.h | 6 |
2 files changed, 14 insertions, 15 deletions
diff --git a/core/src/fxge/android/fpf_skiafontmgr.cpp b/core/src/fxge/android/fpf_skiafontmgr.cpp index 9dbe35d0e5..d4de2b812e 100644 --- a/core/src/fxge/android/fpf_skiafontmgr.cpp +++ b/core/src/fxge/android/fpf_skiafontmgr.cpp @@ -219,14 +219,11 @@ CFPF_SkiaFontMgr::CFPF_SkiaFontMgr() : m_bLoaded(FALSE), m_FTLibrary(NULL) {} CFPF_SkiaFontMgr::~CFPF_SkiaFontMgr() { void* pkey = NULL; CFPF_SkiaFont* pValue = NULL; - FX_POSITION pos = m_FamilyFonts.GetStartPosition(); - while (pos) { - m_FamilyFonts.GetNextAssoc(pos, pkey, (void*&)pValue); - if (pValue) { - pValue->Release(); - } + for (const auto& pair : m_FamilyFonts) { + if (pair.second) + pair.second->Release(); } - m_FamilyFonts.RemoveAll(); + m_FamilyFonts.clear(); for (int32_t i = m_FontFaces.GetUpperBound(); i >= 0; i--) { CFPF_SkiaFontDescriptor* pFont = (CFPF_SkiaFontDescriptor*)m_FontFaces.ElementAt(i); @@ -259,12 +256,10 @@ IFPF_Font* CFPF_SkiaFontMgr::CreateFont(const CFX_ByteStringC& bsFamilyname, FX_DWORD dwStyle, FX_DWORD dwMatch) { FX_DWORD dwHash = FPF_SKIAGetFamilyHash(bsFamilyname, dwStyle, uCharset); - IFPF_Font* pFont = NULL; - if (m_FamilyFonts.Lookup((void*)(uintptr_t)dwHash, (void*&)pFont)) { - if (pFont) { - return pFont->Retain(); - } - } + auto it = m_FamilyFonts.find(dwHash); + if (it != m_FamilyFonts.end() && it->second) + return it->second->Retain(); + FX_DWORD dwFaceName = FPF_SKIANormalizeFontName(bsFamilyname); FX_DWORD dwSubst = FPF_SkiaGetSubstFont(dwFaceName); FX_DWORD dwSubstSans = FPF_SkiaGetSansFont(dwFaceName); @@ -335,7 +330,7 @@ IFPF_Font* CFPF_SkiaFontMgr::CreateFont(const CFX_ByteStringC& bsFamilyname, (CFPF_SkiaFontDescriptor*)m_FontFaces.ElementAt(nItem); CFPF_SkiaFont* pFont = new CFPF_SkiaFont; if (pFont->InitFont(this, pFontDes, bsFamilyname, dwStyle, uCharset)) { - m_FamilyFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); + m_FamilyFonts[dwHash] = pFont; return pFont->Retain(); } pFont->Release(); diff --git a/core/src/fxge/android/fpf_skiafontmgr.h b/core/src/fxge/android/fpf_skiafontmgr.h index cd503f58a9..4625e8c605 100644 --- a/core/src/fxge/android/fpf_skiafontmgr.h +++ b/core/src/fxge/android/fpf_skiafontmgr.h @@ -9,6 +9,8 @@ #if _FX_OS_ == _FX_ANDROID_ +#include <map> + #include "core/include/fxge/fpf.h" #define FPF_SKIAFONTTYPE_Unknown 0 @@ -16,6 +18,8 @@ #define FPF_SKIAFONTTYPE_File 2 #define FPF_SKIAFONTTYPE_Buffer 3 +class CFPF_SkiaFont; + class CFPF_SkiaFontDescriptor { public: CFPF_SkiaFontDescriptor() @@ -110,7 +114,7 @@ class CFPF_SkiaFontMgr : public IFPF_FontMgr { FX_BOOL m_bLoaded; CFX_PtrArray m_FontFaces; FXFT_Library m_FTLibrary; - CFX_MapPtrToPtr m_FamilyFonts; + std::map<FX_DWORD, CFPF_SkiaFont*> m_FamilyFonts; }; #endif |