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

Side by Side Diff: core/src/fxge/android/fpf_skiafontmgr.cpp

Issue 1580573002: Replace more CFX_MapPtrToPtr and remove it. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: And remove it. Created 4 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
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 "core/include/fxcrt/fx_ext.h" 7 #include "core/include/fxcrt/fx_ext.h"
8 #include "fx_fpf.h" 8 #include "fx_fpf.h"
9 9
10 #if _FX_OS_ == _FX_ANDROID_ 10 #if _FX_OS_ == _FX_ANDROID_
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 } 212 }
213 static FX_BOOL FPF_SkiaMaybeArabic(const CFX_ByteStringC& bsFacename) { 213 static FX_BOOL FPF_SkiaMaybeArabic(const CFX_ByteStringC& bsFacename) {
214 CFX_ByteString bsName = bsFacename; 214 CFX_ByteString bsName = bsFacename;
215 bsName.MakeLower(); 215 bsName.MakeLower();
216 return bsName.Find("arabic") > -1; 216 return bsName.Find("arabic") > -1;
217 } 217 }
218 CFPF_SkiaFontMgr::CFPF_SkiaFontMgr() : m_bLoaded(FALSE), m_FTLibrary(NULL) {} 218 CFPF_SkiaFontMgr::CFPF_SkiaFontMgr() : m_bLoaded(FALSE), m_FTLibrary(NULL) {}
219 CFPF_SkiaFontMgr::~CFPF_SkiaFontMgr() { 219 CFPF_SkiaFontMgr::~CFPF_SkiaFontMgr() {
220 void* pkey = NULL; 220 void* pkey = NULL;
221 CFPF_SkiaFont* pValue = NULL; 221 CFPF_SkiaFont* pValue = NULL;
222 FX_POSITION pos = m_FamilyFonts.GetStartPosition(); 222 for (const auto& pair : m_FamilyFonts) {
223 while (pos) { 223 if (pair.second)
224 m_FamilyFonts.GetNextAssoc(pos, pkey, (void*&)pValue); 224 pair.second->Release();
225 if (pValue) {
226 pValue->Release();
227 }
228 } 225 }
229 m_FamilyFonts.RemoveAll(); 226 m_FamilyFonts.clear();
230 for (int32_t i = m_FontFaces.GetUpperBound(); i >= 0; i--) { 227 for (int32_t i = m_FontFaces.GetUpperBound(); i >= 0; i--) {
231 CFPF_SkiaFontDescriptor* pFont = 228 CFPF_SkiaFontDescriptor* pFont =
232 (CFPF_SkiaFontDescriptor*)m_FontFaces.ElementAt(i); 229 (CFPF_SkiaFontDescriptor*)m_FontFaces.ElementAt(i);
233 delete pFont; 230 delete pFont;
234 } 231 }
235 m_FontFaces.RemoveAll(); 232 m_FontFaces.RemoveAll();
236 if (m_FTLibrary) { 233 if (m_FTLibrary) {
237 FXFT_Done_FreeType(m_FTLibrary); 234 FXFT_Done_FreeType(m_FTLibrary);
238 } 235 }
239 } 236 }
(...skipping 12 matching lines...) Expand all
252 m_bLoaded = TRUE; 249 m_bLoaded = TRUE;
253 } 250 }
254 void CFPF_SkiaFontMgr::LoadPrivateFont(IFX_FileRead* pFontFile) {} 251 void CFPF_SkiaFontMgr::LoadPrivateFont(IFX_FileRead* pFontFile) {}
255 void CFPF_SkiaFontMgr::LoadPrivateFont(const CFX_ByteStringC& bsFileName) {} 252 void CFPF_SkiaFontMgr::LoadPrivateFont(const CFX_ByteStringC& bsFileName) {}
256 void CFPF_SkiaFontMgr::LoadPrivateFont(void* pBuffer, size_t szBuffer) {} 253 void CFPF_SkiaFontMgr::LoadPrivateFont(void* pBuffer, size_t szBuffer) {}
257 IFPF_Font* CFPF_SkiaFontMgr::CreateFont(const CFX_ByteStringC& bsFamilyname, 254 IFPF_Font* CFPF_SkiaFontMgr::CreateFont(const CFX_ByteStringC& bsFamilyname,
258 uint8_t uCharset, 255 uint8_t uCharset,
259 FX_DWORD dwStyle, 256 FX_DWORD dwStyle,
260 FX_DWORD dwMatch) { 257 FX_DWORD dwMatch) {
261 FX_DWORD dwHash = FPF_SKIAGetFamilyHash(bsFamilyname, dwStyle, uCharset); 258 FX_DWORD dwHash = FPF_SKIAGetFamilyHash(bsFamilyname, dwStyle, uCharset);
259 auto it = m_FamilyFonts.find(dwHash);
260 if (it != m_FamilyFonts.end() && it->second)
261 return it->second->Retain();
262
262 IFPF_Font* pFont = NULL; 263 IFPF_Font* pFont = NULL;
Oliver Chang 2016/01/20 21:34:24 nit: I don't think this |pFont| variable is needed
Tom Sepez 2016/01/20 22:18:30 Done.
263 if (m_FamilyFonts.Lookup((void*)(uintptr_t)dwHash, (void*&)pFont)) {
264 if (pFont) {
265 return pFont->Retain();
266 }
267 }
268 FX_DWORD dwFaceName = FPF_SKIANormalizeFontName(bsFamilyname); 264 FX_DWORD dwFaceName = FPF_SKIANormalizeFontName(bsFamilyname);
269 FX_DWORD dwSubst = FPF_SkiaGetSubstFont(dwFaceName); 265 FX_DWORD dwSubst = FPF_SkiaGetSubstFont(dwFaceName);
270 FX_DWORD dwSubstSans = FPF_SkiaGetSansFont(dwFaceName); 266 FX_DWORD dwSubstSans = FPF_SkiaGetSansFont(dwFaceName);
271 FX_BOOL bMaybeSymbol = FPF_SkiaMaybeSymbol(bsFamilyname); 267 FX_BOOL bMaybeSymbol = FPF_SkiaMaybeSymbol(bsFamilyname);
272 if (uCharset != FXFONT_ARABIC_CHARSET && FPF_SkiaMaybeArabic(bsFamilyname)) { 268 if (uCharset != FXFONT_ARABIC_CHARSET && FPF_SkiaMaybeArabic(bsFamilyname)) {
273 uCharset = FXFONT_ARABIC_CHARSET; 269 uCharset = FXFONT_ARABIC_CHARSET;
274 } else if (uCharset == FXFONT_ANSI_CHARSET && 270 } else if (uCharset == FXFONT_ANSI_CHARSET &&
275 (dwMatch & FPF_MATCHFONT_REPLACEANSI)) { 271 (dwMatch & FPF_MATCHFONT_REPLACEANSI)) {
276 uCharset = FXFONT_DEFAULT_CHARSET; 272 uCharset = FXFONT_DEFAULT_CHARSET;
277 } 273 }
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 if (nExpectVal <= nFind) { 324 if (nExpectVal <= nFind) {
329 nItem = i; 325 nItem = i;
330 break; 326 break;
331 } 327 }
332 } 328 }
333 if (nItem > -1) { 329 if (nItem > -1) {
334 CFPF_SkiaFontDescriptor* pFontDes = 330 CFPF_SkiaFontDescriptor* pFontDes =
335 (CFPF_SkiaFontDescriptor*)m_FontFaces.ElementAt(nItem); 331 (CFPF_SkiaFontDescriptor*)m_FontFaces.ElementAt(nItem);
336 CFPF_SkiaFont* pFont = new CFPF_SkiaFont; 332 CFPF_SkiaFont* pFont = new CFPF_SkiaFont;
337 if (pFont->InitFont(this, pFontDes, bsFamilyname, dwStyle, uCharset)) { 333 if (pFont->InitFont(this, pFontDes, bsFamilyname, dwStyle, uCharset)) {
338 m_FamilyFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); 334 m_FamilyFonts[dwHash] = pFont;
339 return pFont->Retain(); 335 return pFont->Retain();
340 } 336 }
341 pFont->Release(); 337 pFont->Release();
342 } 338 }
343 return NULL; 339 return NULL;
344 } 340 }
345 FXFT_Face CFPF_SkiaFontMgr::GetFontFace(IFX_FileRead* pFileRead, 341 FXFT_Face CFPF_SkiaFontMgr::GetFontFace(IFX_FileRead* pFileRead,
346 int32_t iFaceIndex) { 342 int32_t iFaceIndex) {
347 if (!pFileRead) { 343 if (!pFileRead) {
348 return NULL; 344 return NULL;
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 } 518 }
523 if (pOS2 && (pOS2->ulCodePageRange1 & (1 << 31))) { 519 if (pOS2 && (pOS2->ulCodePageRange1 & (1 << 31))) {
524 pFontDesc->m_dwStyle |= FXFONT_SYMBOLIC; 520 pFontDesc->m_dwStyle |= FXFONT_SYMBOLIC;
525 } 521 }
526 pFontDesc->m_dwCharsets = FPF_SkiaGetFaceCharset(pOS2); 522 pFontDesc->m_dwCharsets = FPF_SkiaGetFaceCharset(pOS2);
527 pFontDesc->m_iFaceIndex = face->face_index; 523 pFontDesc->m_iFaceIndex = face->face_index;
528 pFontDesc->m_iGlyphNum = face->num_glyphs; 524 pFontDesc->m_iGlyphNum = face->num_glyphs;
529 } 525 }
530 void CFPF_SkiaFontMgr::OutputSystemFonts() {} 526 void CFPF_SkiaFontMgr::OutputSystemFonts() {}
531 #endif 527 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698