summaryrefslogtreecommitdiff
path: root/xfa
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2017-03-02 09:47:08 -0800
committerChromium commit bot <commit-bot@chromium.org>2017-03-02 18:57:52 +0000
commit4df55209c2f922f33c2f69fadfff5d30026e89d2 (patch)
tree75d6daefb1f8355d64799378f3bb0088a11f4187 /xfa
parent9642d924668222ee06eb897761646dd964bd5a29 (diff)
downloadpdfium-4df55209c2f922f33c2f69fadfff5d30026e89d2.tar.xz
Remove CFX_MassArrayTemplate<CFX_Rect> backing array.
The map is one-to-one, so no need for a pointer to an externally stored rect. Change-Id: I4cd6f728cdadeb4c7b25b6f34f5d50bb5db89623 Reviewed-on: https://pdfium-review.googlesource.com/2896 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa')
-rw-r--r--xfa/fgas/font/cfgas_gefont.cpp41
-rw-r--r--xfa/fgas/font/cfgas_gefont.h3
2 files changed, 18 insertions, 26 deletions
diff --git a/xfa/fgas/font/cfgas_gefont.cpp b/xfa/fgas/font/cfgas_gefont.cpp
index a175202e7d..a57962d084 100644
--- a/xfa/fgas/font/cfgas_gefont.cpp
+++ b/xfa/fgas/font/cfgas_gefont.cpp
@@ -220,8 +220,6 @@ bool CFGAS_GEFont::InitFont() {
m_pCharWidthMap =
pdfium::MakeUnique<CFX_DiscreteArrayTemplate<uint16_t>>(1024);
}
- if (!m_pRectArray)
- m_pRectArray = pdfium::MakeUnique<CFX_MassArrayTemplate<CFX_Rect>>(16);
return true;
}
@@ -315,32 +313,27 @@ bool CFGAS_GEFont::GetCharBBoxInternal(FX_WCHAR wUnicode,
CFX_Rect* bbox,
bool bRecursive,
bool bCharCode) {
- ASSERT(m_pRectArray);
- 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) {
- if (pFont.Get() == this) {
- FX_RECT rtBBox;
- if (m_pFont->GetGlyphBBox(iGlyph, rtBBox)) {
- CFX_Rect rt(rtBBox.left, rtBBox.top, rtBBox.Width(), rtBBox.Height());
- int32_t index = m_pRectArray->Add(rt);
- pRect = m_pRectArray->GetPtrAt(index);
- m_BBoxMap[wUnicode] = pRect;
- }
- } else if (pFont->GetCharBBoxInternal(wUnicode, bbox, false, bCharCode)) {
- return true;
- }
- }
- } else {
- pRect = it->second;
+ if (it != m_BBoxMap.end()) {
+ *bbox = it->second;
+ return true;
}
- if (!pRect)
+
+ CFX_RetainPtr<CFGAS_GEFont> pFont;
+ int32_t iGlyph = GetGlyphIndex(wUnicode, true, &pFont, bCharCode);
+ if (!pFont || iGlyph == 0xFFFF)
+ return false;
+
+ if (pFont.Get() != this)
+ return pFont->GetCharBBoxInternal(wUnicode, bbox, false, bCharCode);
+
+ FX_RECT rtBBox;
+ if (!m_pFont->GetGlyphBBox(iGlyph, rtBBox))
return false;
- *bbox = *pRect;
+ CFX_Rect rt(rtBBox.left, rtBBox.top, rtBBox.Width(), rtBBox.Height());
+ m_BBoxMap[wUnicode] = rt;
+ *bbox = rt;
return true;
}
diff --git a/xfa/fgas/font/cfgas_gefont.h b/xfa/fgas/font/cfgas_gefont.h
index 6c9d890df4..2201721a93 100644
--- a/xfa/fgas/font/cfgas_gefont.h
+++ b/xfa/fgas/font/cfgas_gefont.h
@@ -109,8 +109,7 @@ class CFGAS_GEFont : public CFX_Retainable {
CFX_RetainPtr<IFX_SeekableReadStream> m_pFileRead;
std::unique_ptr<CFX_UnicodeEncoding> m_pFontEncoding;
std::unique_ptr<CFX_DiscreteArrayTemplate<uint16_t>> m_pCharWidthMap;
- std::unique_ptr<CFX_MassArrayTemplate<CFX_Rect>> m_pRectArray;
- std::map<FX_WCHAR, CFX_Rect*> m_BBoxMap; // Rect owned by m_pRectArray.
+ std::map<FX_WCHAR, CFX_Rect> m_BBoxMap;
CXFA_PDFFontMgr* m_pProvider; // not owned.
std::vector<CFX_RetainPtr<CFGAS_GEFont>> m_SubstFonts;
std::map<FX_WCHAR, CFX_RetainPtr<CFGAS_GEFont>> m_FontMapper;