diff options
author | tsepez <tsepez@chromium.org> | 2017-01-06 09:48:18 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2017-01-06 09:48:18 -0800 |
commit | 6fd07ef0a817dca5acbcadea41b8f880376f339a (patch) | |
tree | e330419f0289e503478bffc7638e836e113a7fe7 /xfa/fgas/font/cfgas_gefont.cpp | |
parent | 8d94b6687f27e1238f352939434704f75b330c1d (diff) | |
download | pdfium-6fd07ef0a817dca5acbcadea41b8f880376f339a.tar.xz |
Remove CFX_MapPtrToPtr in xfa/fgas, part 2
Review-Url: https://codereview.chromium.org/2616623005
Diffstat (limited to 'xfa/fgas/font/cfgas_gefont.cpp')
-rw-r--r-- | xfa/fgas/font/cfgas_gefont.cpp | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/xfa/fgas/font/cfgas_gefont.cpp b/xfa/fgas/font/cfgas_gefont.cpp index fc202f6bc3..49639c2005 100644 --- a/xfa/fgas/font/cfgas_gefont.cpp +++ b/xfa/fgas/font/cfgas_gefont.cpp @@ -214,6 +214,7 @@ bool CFGAS_GEFont::LoadFontInternal(std::unique_ptr<CFX_Font> pInternalFont) { bool CFGAS_GEFont::InitFont() { if (!m_pFont) return false; + if (!m_pFontEncoding) { m_pFontEncoding.reset(FX_CreateFontEncodingEx(m_pFont)); if (!m_pFontEncoding) @@ -225,9 +226,6 @@ bool CFGAS_GEFont::InitFont() { } if (!m_pRectArray) m_pRectArray = pdfium::MakeUnique<CFX_MassArrayTemplate<CFX_Rect>>(16); - if (!m_pBBoxMap) - m_pBBoxMap = pdfium::MakeUnique<CFX_MapPtrToPtr>(16); - return true; } @@ -312,19 +310,19 @@ bool CFGAS_GEFont::GetCharWidthInternal(FX_WCHAR wUnicode, } bool CFGAS_GEFont::GetCharBBox(FX_WCHAR wUnicode, - CFX_Rect& bbox, + CFX_Rect* bbox, bool bCharCode) { return GetCharBBoxInternal(wUnicode, bbox, true, bCharCode); } bool CFGAS_GEFont::GetCharBBoxInternal(FX_WCHAR wUnicode, - CFX_Rect& bbox, + CFX_Rect* bbox, bool bRecursive, bool bCharCode) { ASSERT(m_pRectArray); - ASSERT(m_pBBoxMap); - void* pRect = nullptr; - if (!m_pBBoxMap->Lookup((void*)(uintptr_t)wUnicode, pRect)) { + CFX_Rect* pRect = nullptr; + auto it = m_BBoxMap.find(wUnicode); + if (it == m_BBoxMap.end()) { CFX_RetainPtr<CFGAS_GEFont> pFont; int32_t iGlyph = GetGlyphIndex(wUnicode, true, &pFont, bCharCode); if (iGlyph != 0xFFFF && pFont) { @@ -335,28 +333,31 @@ bool CFGAS_GEFont::GetCharBBoxInternal(FX_WCHAR wUnicode, rt.Set(rtBBox.left, rtBBox.top, rtBBox.Width(), rtBBox.Height()); int32_t index = m_pRectArray->Add(rt); pRect = m_pRectArray->GetPtrAt(index); - m_pBBoxMap->SetAt((void*)(uintptr_t)wUnicode, pRect); + m_BBoxMap[wUnicode] = pRect; } } else if (pFont->GetCharBBoxInternal(wUnicode, bbox, false, bCharCode)) { return true; } } + } else { + pRect = it->second; } if (!pRect) return false; - bbox = *static_cast<const CFX_Rect*>(pRect); + *bbox = *pRect; return true; } -bool CFGAS_GEFont::GetBBox(CFX_Rect& bbox) { +bool CFGAS_GEFont::GetBBox(CFX_Rect* bbox) { FX_RECT rt(0, 0, 0, 0); if (!m_pFont->GetBBox(rt)) return false; - bbox.left = rt.left; - bbox.width = rt.Width(); - bbox.top = rt.bottom; - bbox.height = -rt.Height(); + + bbox->left = rt.left; + bbox->width = rt.Width(); + bbox->top = rt.bottom; + bbox->height = -rt.Height(); return true; } |