From 6fd07ef0a817dca5acbcadea41b8f880376f339a Mon Sep 17 00:00:00 2001 From: tsepez Date: Fri, 6 Jan 2017 09:48:18 -0800 Subject: Remove CFX_MapPtrToPtr in xfa/fgas, part 2 Review-Url: https://codereview.chromium.org/2616623005 --- xfa/fgas/font/cfgas_gefont.cpp | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) (limited to 'xfa/fgas/font/cfgas_gefont.cpp') 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 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>(16); - if (!m_pBBoxMap) - m_pBBoxMap = pdfium::MakeUnique(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 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(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; } -- cgit v1.2.3