diff options
author | tsepez <tsepez@chromium.org> | 2016-04-27 16:59:30 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-04-27 16:59:30 -0700 |
commit | bb0d446df18ee34504a165f3fc96fbb81b274f31 (patch) | |
tree | 9c2615b4c8a8d597f22e8504c23e2fdbf1df4de5 /xfa/fgas | |
parent | df96690d4e3799536b981e3673d64018fa5fd037 (diff) | |
download | pdfium-bb0d446df18ee34504a165f3fc96fbb81b274f31.tar.xz |
Replace CFX_PtrArray with typesafe CFX_ArrayTemplate<>, part 3
Review-Url: https://codereview.chromium.org/1924093003
Diffstat (limited to 'xfa/fgas')
-rw-r--r-- | xfa/fgas/font/fgas_stdfontmgr.cpp | 34 | ||||
-rw-r--r-- | xfa/fgas/font/fgas_stdfontmgr.h | 2 |
2 files changed, 14 insertions, 22 deletions
diff --git a/xfa/fgas/font/fgas_stdfontmgr.cpp b/xfa/fgas/font/fgas_stdfontmgr.cpp index a3964d2bb8..54dd641319 100644 --- a/xfa/fgas/font/fgas_stdfontmgr.cpp +++ b/xfa/fgas/font/fgas_stdfontmgr.cpp @@ -17,7 +17,6 @@ IFX_FontMgr* IFX_FontMgr::Create(FX_LPEnumAllFonts pEnumerator) { CFX_StdFontMgrImp::CFX_StdFontMgrImp(FX_LPEnumAllFonts pEnumerator) : m_pEnumerator(pEnumerator), m_FontFaces(), - m_Fonts(), m_CPFonts(8), m_FamilyFonts(16), m_UnicodeFonts(16), @@ -39,14 +38,10 @@ CFX_StdFontMgrImp::~CFX_StdFontMgrImp() { m_FileFonts.RemoveAll(); m_StreamFonts.RemoveAll(); m_DeriveFonts.RemoveAll(); - for (int32_t i = m_Fonts.GetUpperBound(); i >= 0; i--) { - IFX_Font* pFont = (IFX_Font*)m_Fonts[i]; - if (pFont != NULL) { - pFont->Release(); - } - } - m_Fonts.RemoveAll(); + for (int32_t i = m_Fonts.GetUpperBound(); i >= 0; i--) + m_Fonts[i]->Release(); } + IFX_Font* CFX_StdFontMgrImp::GetDefFontByCodePage( uint16_t wCodePage, uint32_t dwFontStyles, @@ -65,7 +60,7 @@ IFX_Font* CFX_StdFontMgrImp::GetDefFontByCodePage( } ASSERT(pFD != NULL); pFont = IFX_Font::LoadFont(pFD->wsFontFace, dwFontStyles, wCodePage, this); - if (pFont != NULL) { + if (pFont) { m_Fonts.Add(pFont); m_CPFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); dwHash = FGAS_GetFontFamilyHash(pFD->wsFontFace, dwFontStyles, wCodePage); @@ -149,7 +144,7 @@ IFX_Font* CFX_StdFontMgrImp::LoadFont(const FX_WCHAR* pszFontFamily, wCodePage = FX_GetCodePageFromCharset(pFD->uCharSet); } pFont = IFX_Font::LoadFont(pFD->wsFontFace, dwFontStyles, wCodePage, this); - if (pFont != NULL) { + if (pFont) { m_Fonts.Add(pFont); m_FamilyFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); dwHash = FGAS_GetFontHashCode(wCodePage, dwFontStyles); @@ -167,7 +162,7 @@ IFX_Font* CFX_StdFontMgrImp::LoadFont(const uint8_t* pBuffer, int32_t iLength) { } } pFont = IFX_Font::LoadFont(pBuffer, iLength, this); - if (pFont != NULL) { + if (pFont) { m_Fonts.Add(pFont); m_BufferFonts.SetAt((void*)pBuffer, pFont); return pFont->Retain(); @@ -184,7 +179,7 @@ IFX_Font* CFX_StdFontMgrImp::LoadFont(const FX_WCHAR* pszFileName) { } } pFont = IFX_Font::LoadFont(pszFileName, NULL); - if (pFont != NULL) { + if (pFont) { m_Fonts.Add(pFont); m_FileFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); return pFont->Retain(); @@ -209,7 +204,7 @@ IFX_Font* CFX_StdFontMgrImp::LoadFont(IFX_Stream* pFontStream, } } pFont = IFX_Font::LoadFont(pFontStream, this, bSaveStream); - if (pFont != NULL) { + if (pFont) { m_Fonts.Add(pFont); m_StreamFonts.SetAt((void*)pFontStream, (void*)pFont); if (pszFontAlias != NULL) { @@ -240,7 +235,7 @@ IFX_Font* CFX_StdFontMgrImp::LoadFont(IFX_Font* pSrcFont, } } pFont = pSrcFont->Derive(dwFontStyles, wCodePage); - if (pFont != NULL) { + if (pFont) { m_DeriveFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); int32_t index = m_Fonts.Find(pFont); if (index < 0) { @@ -251,15 +246,12 @@ IFX_Font* CFX_StdFontMgrImp::LoadFont(IFX_Font* pSrcFont, } return NULL; } + void CFX_StdFontMgrImp::ClearFontCache() { - int32_t iCount = m_Fonts.GetSize(); - for (int32_t i = 0; i < iCount; i++) { - IFX_Font* pFont = (IFX_Font*)m_Fonts[i]; - if (pFont != NULL) { - pFont->Reset(); - } - } + for (int32_t i = 0; i < m_Fonts.GetSize(); i++) + m_Fonts[i]->Reset(); } + void CFX_StdFontMgrImp::RemoveFont(CFX_MapPtrToPtr& fontMap, IFX_Font* pFont) { FX_POSITION pos = fontMap.GetStartPosition(); void* pKey; diff --git a/xfa/fgas/font/fgas_stdfontmgr.h b/xfa/fgas/font/fgas_stdfontmgr.h index cc11517e34..e66dd3131a 100644 --- a/xfa/fgas/font/fgas_stdfontmgr.h +++ b/xfa/fgas/font/fgas_stdfontmgr.h @@ -64,7 +64,7 @@ class CFX_StdFontMgrImp : public IFX_FontMgr { FX_LPEnumAllFonts m_pEnumerator; CFX_FontDescriptors m_FontFaces; - CFX_PtrArray m_Fonts; + CFX_ArrayTemplate<IFX_Font*> m_Fonts; CFX_MapPtrToPtr m_CPFonts; CFX_MapPtrToPtr m_FamilyFonts; CFX_MapPtrToPtr m_UnicodeFonts; |