Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(431)

Side by Side Diff: xfa/fgas/font/cfgas_gefont.cpp

Issue 2616623005: Remove CFX_MapPtrToPtr in xfa/fgas, part 2 (Closed)
Patch Set: unique_ptr Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« xfa/fgas/font/cfgas_gefont.h ('K') | « xfa/fgas/font/cfgas_gefont.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "xfa/fgas/font/cfgas_gefont.h" 7 #include "xfa/fgas/font/cfgas_gefont.h"
8 8
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 return false; 207 return false;
208 208
209 m_pFont = pInternalFont.release(); 209 m_pFont = pInternalFont.release();
210 m_bExternalFont = false; 210 m_bExternalFont = false;
211 return InitFont(); 211 return InitFont();
212 } 212 }
213 213
214 bool CFGAS_GEFont::InitFont() { 214 bool CFGAS_GEFont::InitFont() {
215 if (!m_pFont) 215 if (!m_pFont)
216 return false; 216 return false;
217
217 if (!m_pFontEncoding) { 218 if (!m_pFontEncoding) {
218 m_pFontEncoding.reset(FX_CreateFontEncodingEx(m_pFont)); 219 m_pFontEncoding.reset(FX_CreateFontEncodingEx(m_pFont));
219 if (!m_pFontEncoding) 220 if (!m_pFontEncoding)
220 return false; 221 return false;
221 } 222 }
222 if (!m_pCharWidthMap) { 223 if (!m_pCharWidthMap) {
223 m_pCharWidthMap = 224 m_pCharWidthMap =
224 pdfium::MakeUnique<CFX_DiscreteArrayTemplate<uint16_t>>(1024); 225 pdfium::MakeUnique<CFX_DiscreteArrayTemplate<uint16_t>>(1024);
225 } 226 }
226 if (!m_pRectArray) 227 if (!m_pRectArray)
227 m_pRectArray = pdfium::MakeUnique<CFX_MassArrayTemplate<CFX_Rect>>(16); 228 m_pRectArray = pdfium::MakeUnique<CFX_MassArrayTemplate<CFX_Rect>>(16);
228 if (!m_pBBoxMap)
229 m_pBBoxMap = pdfium::MakeUnique<CFX_MapPtrToPtr>(16);
230
231 return true; 229 return true;
232 } 230 }
233 231
234 CFX_RetainPtr<CFGAS_GEFont> CFGAS_GEFont::Derive(uint32_t dwFontStyles, 232 CFX_RetainPtr<CFGAS_GEFont> CFGAS_GEFont::Derive(uint32_t dwFontStyles,
235 uint16_t wCodePage) { 233 uint16_t wCodePage) {
236 CFX_RetainPtr<CFGAS_GEFont> pFont(this); 234 CFX_RetainPtr<CFGAS_GEFont> pFont(this);
237 if (GetFontStyles() == dwFontStyles) 235 if (GetFontStyles() == dwFontStyles)
238 return pFont; 236 return pFont;
239 return pdfium::MakeRetain<CFGAS_GEFont>(pFont, dwFontStyles); 237 return pdfium::MakeRetain<CFGAS_GEFont>(pFont, dwFontStyles);
240 } 238 }
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 return iWidth > 0; 309 return iWidth > 0;
312 } 310 }
313 311
314 bool CFGAS_GEFont::GetCharBBox(FX_WCHAR wUnicode, 312 bool CFGAS_GEFont::GetCharBBox(FX_WCHAR wUnicode,
315 CFX_Rect& bbox, 313 CFX_Rect& bbox,
316 bool bCharCode) { 314 bool bCharCode) {
317 return GetCharBBoxInternal(wUnicode, bbox, true, bCharCode); 315 return GetCharBBoxInternal(wUnicode, bbox, true, bCharCode);
318 } 316 }
319 317
320 bool CFGAS_GEFont::GetCharBBoxInternal(FX_WCHAR wUnicode, 318 bool CFGAS_GEFont::GetCharBBoxInternal(FX_WCHAR wUnicode,
321 CFX_Rect& bbox, 319 CFX_Rect& bbox,
dsinclair 2017/01/06 02:40:29 Out param should be *
Tom Sepez 2017/01/06 17:27:03 Done.
322 bool bRecursive, 320 bool bRecursive,
323 bool bCharCode) { 321 bool bCharCode) {
324 ASSERT(m_pRectArray); 322 ASSERT(m_pRectArray);
325 ASSERT(m_pBBoxMap); 323 CFX_Rect* pRect = nullptr;
326 void* pRect = nullptr; 324 auto it = m_BBoxMap.find(wUnicode);
327 if (!m_pBBoxMap->Lookup((void*)(uintptr_t)wUnicode, pRect)) { 325 if (it == m_BBoxMap.end()) {
328 CFX_RetainPtr<CFGAS_GEFont> pFont; 326 CFX_RetainPtr<CFGAS_GEFont> pFont;
329 int32_t iGlyph = GetGlyphIndex(wUnicode, true, &pFont, bCharCode); 327 int32_t iGlyph = GetGlyphIndex(wUnicode, true, &pFont, bCharCode);
330 if (iGlyph != 0xFFFF && pFont) { 328 if (iGlyph != 0xFFFF && pFont) {
331 if (pFont.Get() == this) { 329 if (pFont.Get() == this) {
332 FX_RECT rtBBox; 330 FX_RECT rtBBox;
333 if (m_pFont->GetGlyphBBox(iGlyph, rtBBox)) { 331 if (m_pFont->GetGlyphBBox(iGlyph, rtBBox)) {
334 CFX_Rect rt; 332 CFX_Rect rt;
335 rt.Set(rtBBox.left, rtBBox.top, rtBBox.Width(), rtBBox.Height()); 333 rt.Set(rtBBox.left, rtBBox.top, rtBBox.Width(), rtBBox.Height());
336 int32_t index = m_pRectArray->Add(rt); 334 int32_t index = m_pRectArray->Add(rt);
337 pRect = m_pRectArray->GetPtrAt(index); 335 pRect = m_pRectArray->GetPtrAt(index);
338 m_pBBoxMap->SetAt((void*)(uintptr_t)wUnicode, pRect); 336 m_BBoxMap[wUnicode] = pRect;
339 } 337 }
340 } else if (pFont->GetCharBBoxInternal(wUnicode, bbox, false, bCharCode)) { 338 } else if (pFont->GetCharBBoxInternal(wUnicode, bbox, false, bCharCode)) {
341 return true; 339 return true;
342 } 340 }
343 } 341 }
342 } else {
343 pRect = it->second;
344 } 344 }
345 if (!pRect) 345 if (!pRect)
346 return false; 346 return false;
347 347
348 bbox = *static_cast<const CFX_Rect*>(pRect); 348 bbox = *pRect;
349 return true; 349 return true;
350 } 350 }
351 351
352 bool CFGAS_GEFont::GetBBox(CFX_Rect& bbox) { 352 bool CFGAS_GEFont::GetBBox(CFX_Rect& bbox) {
353 FX_RECT rt(0, 0, 0, 0); 353 FX_RECT rt(0, 0, 0, 0);
354 if (!m_pFont->GetBBox(rt)) 354 if (!m_pFont->GetBBox(rt))
355 return false; 355 return false;
356 bbox.left = rt.left; 356 bbox.left = rt.left;
357 bbox.width = rt.Width(); 357 bbox.width = rt.Width();
358 bbox.top = rt.bottom; 358 bbox.top = rt.bottom;
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 return m_pFont->GetDescent(); 428 return m_pFont->GetDescent();
429 } 429 }
430 430
431 CFX_RetainPtr<CFGAS_GEFont> CFGAS_GEFont::GetSubstFont( 431 CFX_RetainPtr<CFGAS_GEFont> CFGAS_GEFont::GetSubstFont(
432 int32_t iGlyphIndex) const { 432 int32_t iGlyphIndex) const {
433 iGlyphIndex = static_cast<uint32_t>(iGlyphIndex) >> 24; 433 iGlyphIndex = static_cast<uint32_t>(iGlyphIndex) >> 24;
434 if (iGlyphIndex == 0) 434 if (iGlyphIndex == 0)
435 return CFX_RetainPtr<CFGAS_GEFont>(const_cast<CFGAS_GEFont*>(this)); 435 return CFX_RetainPtr<CFGAS_GEFont>(const_cast<CFGAS_GEFont*>(this));
436 return m_SubstFonts[iGlyphIndex - 1]; 436 return m_SubstFonts[iGlyphIndex - 1];
437 } 437 }
OLDNEW
« xfa/fgas/font/cfgas_gefont.h ('K') | « xfa/fgas/font/cfgas_gefont.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698