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

Side by Side Diff: src/ports/SkFontMgr_fontconfig.cpp

Issue 2211143002: Move to SkDataTable::MakeXXX and sk_sp. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Use bare pointer for global. Created 4 years, 4 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 | « src/ports/SkFontMgr_FontConfigInterface.cpp ('k') | src/ports/SkRemotableFontMgr_win_dw.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkDataTable.h" 8 #include "SkDataTable.h"
9 #include "SkFixed.h" 9 #include "SkFixed.h"
10 #include "SkFontDescriptor.h" 10 #include "SkFontDescriptor.h"
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 : INHERITED(skfontstyle_from_fcpattern(pattern), 496 : INHERITED(skfontstyle_from_fcpattern(pattern),
497 FC_PROPORTIONAL != get_int(pattern, FC_SPACING, FC_PROPORTIO NAL)) 497 FC_PROPORTIONAL != get_int(pattern, FC_SPACING, FC_PROPORTIO NAL))
498 , fPattern(pattern) 498 , fPattern(pattern)
499 { }; 499 { };
500 500
501 typedef SkTypeface_FreeType INHERITED; 501 typedef SkTypeface_FreeType INHERITED;
502 }; 502 };
503 503
504 class SkFontMgr_fontconfig : public SkFontMgr { 504 class SkFontMgr_fontconfig : public SkFontMgr {
505 mutable SkAutoFcConfig fFC; 505 mutable SkAutoFcConfig fFC;
506 SkAutoTUnref<SkDataTable> fFamilyNames; 506 sk_sp<SkDataTable> fFamilyNames;
507 SkTypeface_FreeType::Scanner fScanner; 507 SkTypeface_FreeType::Scanner fScanner;
508 508
509 class StyleSet : public SkFontStyleSet { 509 class StyleSet : public SkFontStyleSet {
510 public: 510 public:
511 /** @param parent does not take ownership of the reference. 511 /** @param parent does not take ownership of the reference.
512 * @param fontSet takes ownership of the reference. 512 * @param fontSet takes ownership of the reference.
513 */ 513 */
514 StyleSet(const SkFontMgr_fontconfig* parent, FcFontSet* fontSet) 514 StyleSet(const SkFontMgr_fontconfig* parent, FcFontSet* fontSet)
515 : fFontMgr(SkRef(parent)), fFontSet(fontSet) 515 : fFontMgr(SkRef(parent)), fFontSet(fontSet)
516 { } 516 { }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 static bool FindName(const SkTDArray<const char*>& list, const char* str) { 572 static bool FindName(const SkTDArray<const char*>& list, const char* str) {
573 int count = list.count(); 573 int count = list.count();
574 for (int i = 0; i < count; ++i) { 574 for (int i = 0; i < count; ++i) {
575 if (!strcmp(list[i], str)) { 575 if (!strcmp(list[i], str)) {
576 return true; 576 return true;
577 } 577 }
578 } 578 }
579 return false; 579 return false;
580 } 580 }
581 581
582 static SkDataTable* GetFamilyNames(FcConfig* fcconfig) { 582 static sk_sp<SkDataTable> GetFamilyNames(FcConfig* fcconfig) {
583 FCLocker lock; 583 FCLocker lock;
584 584
585 SkTDArray<const char*> names; 585 SkTDArray<const char*> names;
586 SkTDArray<size_t> sizes; 586 SkTDArray<size_t> sizes;
587 587
588 static const FcSetName fcNameSet[] = { FcSetSystem, FcSetApplication }; 588 static const FcSetName fcNameSet[] = { FcSetSystem, FcSetApplication };
589 for (int setIndex = 0; setIndex < (int)SK_ARRAY_COUNT(fcNameSet); ++setI ndex) { 589 for (int setIndex = 0; setIndex < (int)SK_ARRAY_COUNT(fcNameSet); ++setI ndex) {
590 // Return value of FcConfigGetFonts must not be destroyed. 590 // Return value of FcConfigGetFonts must not be destroyed.
591 FcFontSet* allFonts(FcConfigGetFonts(fcconfig, fcNameSet[setIndex])) ; 591 FcFontSet* allFonts(FcConfigGetFonts(fcconfig, fcNameSet[setIndex])) ;
592 if (nullptr == allFonts) { 592 if (nullptr == allFonts) {
(...skipping 13 matching lines...) Expand all
606 } 606 }
607 const char* familyName = reinterpret_cast<const char*>(fcFam ilyName); 607 const char* familyName = reinterpret_cast<const char*>(fcFam ilyName);
608 if (familyName && !FindName(names, familyName)) { 608 if (familyName && !FindName(names, familyName)) {
609 *names.append() = familyName; 609 *names.append() = familyName;
610 *sizes.append() = strlen(familyName) + 1; 610 *sizes.append() = strlen(familyName) + 1;
611 } 611 }
612 } 612 }
613 } 613 }
614 } 614 }
615 615
616 return SkDataTable::NewCopyArrays((void const *const *)names.begin(), 616 return SkDataTable::MakeCopyArrays((void const *const *)names.begin(),
617 sizes.begin(), names.count()); 617 sizes.begin(), names.count());
618 } 618 }
619 619
620 static bool FindByFcPattern(SkTypeface* cached, void* ctx) { 620 static bool FindByFcPattern(SkTypeface* cached, void* ctx) {
621 SkTypeface_fontconfig* cshFace = static_cast<SkTypeface_fontconfig*>(cac hed); 621 SkTypeface_fontconfig* cshFace = static_cast<SkTypeface_fontconfig*>(cac hed);
622 FcPattern* ctxPattern = static_cast<FcPattern*>(ctx); 622 FcPattern* ctxPattern = static_cast<FcPattern*>(ctx);
623 return FcTrue == FcPatternEqual(cshFace->fPattern, ctxPattern); 623 return FcTrue == FcPatternEqual(cshFace->fPattern, ctxPattern);
624 } 624 }
625 625
626 mutable SkMutex fTFCacheMutex; 626 mutable SkMutex fTFCacheMutex;
627 mutable SkTypefaceCache fTFCache; 627 mutable SkTypefaceCache fTFCache;
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
933 return typeface.release(); 933 return typeface.release();
934 } 934 }
935 935
936 return this->matchFamilyStyle(nullptr, style); 936 return this->matchFamilyStyle(nullptr, style);
937 } 937 }
938 }; 938 };
939 939
940 SK_API SkFontMgr* SkFontMgr_New_FontConfig(FcConfig* fc) { 940 SK_API SkFontMgr* SkFontMgr_New_FontConfig(FcConfig* fc) {
941 return new SkFontMgr_fontconfig(fc); 941 return new SkFontMgr_fontconfig(fc);
942 } 942 }
OLDNEW
« no previous file with comments | « src/ports/SkFontMgr_FontConfigInterface.cpp ('k') | src/ports/SkRemotableFontMgr_win_dw.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698