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

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

Issue 2616623005: Remove CFX_MapPtrToPtr in xfa/fgas, part 2 (Closed)
Patch Set: typo 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
« no previous file with comments | « xfa/fgas/font/cfgas_fontmgr.h ('k') | xfa/fgas/font/cfgas_gefont.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 PDFium Authors. All rights reserved. 1 // Copyright 2015 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_fontmgr.h" 7 #include "xfa/fgas/font/cfgas_fontmgr.h"
8 8
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 return nullptr; 568 return nullptr;
569 return pFontMgr; 569 return pFontMgr;
570 } 570 }
571 571
572 CFGAS_FontMgr::CFGAS_FontMgr(CFX_FontSourceEnum_File* pFontEnum) 572 CFGAS_FontMgr::CFGAS_FontMgr(CFX_FontSourceEnum_File* pFontEnum)
573 : m_pFontSource(pFontEnum) {} 573 : m_pFontSource(pFontEnum) {}
574 574
575 CFGAS_FontMgr::~CFGAS_FontMgr() { 575 CFGAS_FontMgr::~CFGAS_FontMgr() {
576 for (int32_t i = 0; i < m_InstalledFonts.GetSize(); i++) 576 for (int32_t i = 0; i < m_InstalledFonts.GetSize(); i++)
577 delete m_InstalledFonts[i]; 577 delete m_InstalledFonts[i];
578 FX_POSITION pos = m_Hash2CandidateList.GetStartPosition();
579 while (pos) {
580 uint32_t dwHash;
581 CFX_FontDescriptorInfos* pDescs;
582 m_Hash2CandidateList.GetNextAssoc(pos, dwHash, pDescs);
583 delete pDescs;
584 }
585 m_Hash2Fonts.clear();
586 } 578 }
587 579
588 bool CFGAS_FontMgr::EnumFontsFromFontMapper() { 580 bool CFGAS_FontMgr::EnumFontsFromFontMapper() {
589 CFX_FontMapper* pFontMapper = 581 CFX_FontMapper* pFontMapper =
590 CFX_GEModule::Get()->GetFontMgr()->GetBuiltinMapper(); 582 CFX_GEModule::Get()->GetFontMgr()->GetBuiltinMapper();
591 if (!pFontMapper) 583 if (!pFontMapper)
592 return false; 584 return false;
593 585
594 IFX_SystemFontInfo* pSystemFontInfo = pFontMapper->GetSystemFontInfo(); 586 IFX_SystemFontInfo* pSystemFontInfo = pFontMapper->GetSystemFontInfo();
595 if (!pSystemFontInfo) 587 if (!pSystemFontInfo)
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 uint32_t dwFontStyles, 630 uint32_t dwFontStyles,
639 const FX_WCHAR* pszFontFamily) { 631 const FX_WCHAR* pszFontFamily) {
640 CFX_ByteString bsHash; 632 CFX_ByteString bsHash;
641 bsHash.Format("%d, %d", wCodePage, dwFontStyles); 633 bsHash.Format("%d, %d", wCodePage, dwFontStyles);
642 bsHash += CFX_WideString(pszFontFamily).UTF8Encode(); 634 bsHash += CFX_WideString(pszFontFamily).UTF8Encode();
643 uint32_t dwHash = FX_HashCode_GetA(bsHash.AsStringC(), false); 635 uint32_t dwHash = FX_HashCode_GetA(bsHash.AsStringC(), false);
644 std::vector<CFX_RetainPtr<CFGAS_GEFont>>* pFontArray = &m_Hash2Fonts[dwHash]; 636 std::vector<CFX_RetainPtr<CFGAS_GEFont>>* pFontArray = &m_Hash2Fonts[dwHash];
645 if (!pFontArray->empty()) 637 if (!pFontArray->empty())
646 return (*pFontArray)[0]; 638 return (*pFontArray)[0];
647 639
648 CFX_FontDescriptorInfos* sortedFonts = nullptr; 640 CFX_FontDescriptorInfos* sortedFonts = m_Hash2CandidateList[dwHash].get();
649 if (!m_Hash2CandidateList.Lookup(dwHash, sortedFonts)) { 641 if (!sortedFonts) {
650 sortedFonts = new CFX_FontDescriptorInfos; 642 auto pNewFonts = pdfium::MakeUnique<CFX_FontDescriptorInfos>();
643 sortedFonts = pNewFonts.get();
651 MatchFonts(*sortedFonts, wCodePage, dwFontStyles, 644 MatchFonts(*sortedFonts, wCodePage, dwFontStyles,
652 CFX_WideString(pszFontFamily), 0); 645 CFX_WideString(pszFontFamily), 0);
653 m_Hash2CandidateList.SetAt(dwHash, sortedFonts); 646 m_Hash2CandidateList[dwHash] = std::move(pNewFonts);
654 } 647 }
655 if (sortedFonts->GetSize() == 0) 648 if (sortedFonts->GetSize() == 0)
656 return nullptr; 649 return nullptr;
657 650
658 CFX_FontDescriptor* pDesc = sortedFonts->GetAt(0).pFont; 651 CFX_FontDescriptor* pDesc = sortedFonts->GetAt(0).pFont;
659 CFX_RetainPtr<CFGAS_GEFont> pFont = 652 CFX_RetainPtr<CFGAS_GEFont> pFont =
660 LoadFont(pDesc->m_wsFaceName, pDesc->m_nFaceIndex, nullptr); 653 LoadFont(pDesc->m_wsFaceName, pDesc->m_nFaceIndex, nullptr);
661 if (!pFont) 654 if (!pFont)
662 return nullptr; 655 return nullptr;
663 656
(...skipping 17 matching lines...) Expand all
681 bsHash.Format("%d, %d, %d", wCodePage, wBitField, dwFontStyles); 674 bsHash.Format("%d, %d, %d", wCodePage, wBitField, dwFontStyles);
682 else 675 else
683 bsHash.Format("%d, %d", wCodePage, dwFontStyles); 676 bsHash.Format("%d, %d", wCodePage, dwFontStyles);
684 bsHash += CFX_WideString(pszFontFamily).UTF8Encode(); 677 bsHash += CFX_WideString(pszFontFamily).UTF8Encode();
685 uint32_t dwHash = FX_HashCode_GetA(bsHash.AsStringC(), false); 678 uint32_t dwHash = FX_HashCode_GetA(bsHash.AsStringC(), false);
686 std::vector<CFX_RetainPtr<CFGAS_GEFont>>* pFonts = &m_Hash2Fonts[dwHash]; 679 std::vector<CFX_RetainPtr<CFGAS_GEFont>>* pFonts = &m_Hash2Fonts[dwHash];
687 for (size_t i = 0; i < pFonts->size(); ++i) { 680 for (size_t i = 0; i < pFonts->size(); ++i) {
688 if (VerifyUnicode((*pFonts)[i], wUnicode)) 681 if (VerifyUnicode((*pFonts)[i], wUnicode))
689 return (*pFonts)[i]; 682 return (*pFonts)[i];
690 } 683 }
691 CFX_FontDescriptorInfos* sortedFonts = nullptr; 684 CFX_FontDescriptorInfos* sortedFonts = m_Hash2CandidateList[dwHash].get();
692 if (!m_Hash2CandidateList.Lookup(dwHash, sortedFonts)) { 685 if (!sortedFonts) {
693 sortedFonts = new CFX_FontDescriptorInfos; 686 auto pNewFonts = pdfium::MakeUnique<CFX_FontDescriptorInfos>();
687 sortedFonts = pNewFonts.get();
694 MatchFonts(*sortedFonts, wCodePage, dwFontStyles, 688 MatchFonts(*sortedFonts, wCodePage, dwFontStyles,
695 CFX_WideString(pszFontFamily), wUnicode); 689 CFX_WideString(pszFontFamily), wUnicode);
696 m_Hash2CandidateList.SetAt(dwHash, sortedFonts); 690 m_Hash2CandidateList[dwHash] = std::move(pNewFonts);
697 } 691 }
698 for (int32_t i = 0; i < sortedFonts->GetSize(); ++i) { 692 for (int32_t i = 0; i < sortedFonts->GetSize(); ++i) {
699 CFX_FontDescriptor* pDesc = sortedFonts->GetAt(i).pFont; 693 CFX_FontDescriptor* pDesc = sortedFonts->GetAt(i).pFont;
700 if (!VerifyUnicode(pDesc, wUnicode)) 694 if (!VerifyUnicode(pDesc, wUnicode))
701 continue; 695 continue;
702 CFX_RetainPtr<CFGAS_GEFont> pFont = 696 CFX_RetainPtr<CFGAS_GEFont> pFont =
703 LoadFont(pDesc->m_wsFaceName, pDesc->m_nFaceIndex, nullptr); 697 LoadFont(pDesc->m_wsFaceName, pDesc->m_nFaceIndex, nullptr);
704 if (!pFont) 698 if (!pFont)
705 continue; 699 continue;
706 pFont->SetLogicalFontStyle(dwFontStyles); 700 pFont->SetLogicalFontStyle(dwFontStyles);
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
1150 } 1144 }
1151 1145
1152 int32_t CFGAS_FontMgr::IsPartName(const CFX_WideString& Name1, 1146 int32_t CFGAS_FontMgr::IsPartName(const CFX_WideString& Name1,
1153 const CFX_WideString& Name2) { 1147 const CFX_WideString& Name2) {
1154 if (Name1.Find(Name2.c_str()) != -1) 1148 if (Name1.Find(Name2.c_str()) != -1)
1155 return 1; 1149 return 1;
1156 return 0; 1150 return 0;
1157 } 1151 }
1158 1152
1159 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ 1153 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
OLDNEW
« no previous file with comments | « xfa/fgas/font/cfgas_fontmgr.h ('k') | xfa/fgas/font/cfgas_gefont.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698