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

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

Issue 1189753007: Move FontConfig factory into separate file. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Add to ignored header list. Created 5 years, 6 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 | « include/ports/SkFontMgr_fontconfig.h ('k') | src/ports/SkFontMgr_fontconfig_factory.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 "SkFontDescriptor.h" 9 #include "SkFontDescriptor.h"
10 #include "SkFontHost_FreeType_common.h" 10 #include "SkFontHost_FreeType_common.h"
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 FcPatternReference(pattern); 583 FcPatternReference(pattern);
584 face = SkTypeface_fontconfig::Create(pattern); 584 face = SkTypeface_fontconfig::Create(pattern);
585 if (face) { 585 if (face) {
586 fTFCache.add(face, SkFontStyle()); 586 fTFCache.add(face, SkFontStyle());
587 } 587 }
588 } 588 }
589 return face; 589 return face;
590 } 590 }
591 591
592 public: 592 public:
593 SkFontMgr_fontconfig()
594 : fFC(FcInitLoadConfigAndFonts())
595 , fFamilyNames(GetFamilyNames(fFC)) { }
596
597 /** Takes control of the reference to 'config'. */ 593 /** Takes control of the reference to 'config'. */
598 explicit SkFontMgr_fontconfig(FcConfig* config) 594 explicit SkFontMgr_fontconfig(FcConfig* config)
599 : fFC(config) 595 : fFC(config ? config : FcInitLoadConfigAndFonts())
600 , fFamilyNames(GetFamilyNames(fFC)) { } 596 , fFamilyNames(GetFamilyNames(fFC)) { }
601 597
602 virtual ~SkFontMgr_fontconfig() { 598 virtual ~SkFontMgr_fontconfig() {
603 // Hold the lock while unrefing the config. 599 // Hold the lock while unrefing the config.
604 FCLocker lock; 600 FCLocker lock;
605 fFC.reset(); 601 fFC.reset();
606 } 602 }
607 603
608 protected: 604 protected:
609 int onCountFamilies() const override { 605 int onCountFamilies() const override {
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
866 : SkFontStyle::kUpright_Slant); 862 : SkFontStyle::kUpright_Slant);
867 SkAutoTUnref<SkTypeface> typeface(this->matchFamilyStyle(familyName, sty le)); 863 SkAutoTUnref<SkTypeface> typeface(this->matchFamilyStyle(familyName, sty le));
868 if (typeface.get()) { 864 if (typeface.get()) {
869 return typeface.detach(); 865 return typeface.detach();
870 } 866 }
871 867
872 return this->matchFamilyStyle(NULL, style); 868 return this->matchFamilyStyle(NULL, style);
873 } 869 }
874 }; 870 };
875 871
876 SkFontMgr* SkFontMgr::Factory() { 872 SK_API SkFontMgr* SkFontMgr_New_FontConfig(FcConfig* fc) {
877 return SkNEW(SkFontMgr_fontconfig); 873 return new SkFontMgr_fontconfig(fc);
878 } 874 }
OLDNEW
« no previous file with comments | « include/ports/SkFontMgr_fontconfig.h ('k') | src/ports/SkFontMgr_fontconfig_factory.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698