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

Side by Side Diff: src/ports/SkFontConfigTypeface.h

Issue 2346333002: Split SkFontConfigInterface globals and factory. (Closed)
Patch Set: Created 4 years, 3 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 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 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 "SkFontConfigInterface.h" 8 #include "SkFontConfigInterface.h"
9 #include "SkFontDescriptor.h" 9 #include "SkFontDescriptor.h"
10 #include "SkFontHost_FreeType_common.h" 10 #include "SkFontHost_FreeType_common.h"
11 #include "SkRefCnt.h" 11 #include "SkRefCnt.h"
12 #include "SkStream.h" 12 #include "SkStream.h"
13 13
14 class SkFontDescriptor; 14 class SkFontDescriptor;
15 15
16 class SkTypeface_FCI : public SkTypeface_FreeType { 16 class SkTypeface_FCI : public SkTypeface_FreeType {
17 sk_sp<SkFontConfigInterface> fFCI; 17 sk_sp<SkFontConfigInterface> fFCI;
18 SkFontConfigInterface::FontIdentity fIdentity; 18 SkFontConfigInterface::FontIdentity fIdentity;
19 SkString fFamilyName; 19 SkString fFamilyName;
20 std::unique_ptr<SkFontData> fFontData; 20 std::unique_ptr<SkFontData> fFontData;
21 21
22 public: 22 public:
23 static SkTypeface_FCI* Create(SkFontConfigInterface* fci, 23 static SkTypeface_FCI* Create(sk_sp<SkFontConfigInterface> fci,
24 const SkFontConfigInterface::FontIdentity& fi, 24 const SkFontConfigInterface::FontIdentity& fi,
25 const SkString& familyName, 25 const SkString& familyName,
26 const SkFontStyle& style) 26 const SkFontStyle& style)
27 { 27 {
28 return new SkTypeface_FCI(fci, fi, familyName, style); 28 return new SkTypeface_FCI(std::move(fci), fi, familyName, style);
29 } 29 }
30 30
31 static SkTypeface_FCI* Create(std::unique_ptr<SkFontData> data, 31 static SkTypeface_FCI* Create(std::unique_ptr<SkFontData> data,
32 SkFontStyle style, bool isFixedPitch) 32 SkFontStyle style, bool isFixedPitch)
33 { 33 {
34 return new SkTypeface_FCI(std::move(data), style, isFixedPitch); 34 return new SkTypeface_FCI(std::move(data), style, isFixedPitch);
35 } 35 }
36 36
37 const SkFontConfigInterface::FontIdentity& getIdentity() const { 37 const SkFontConfigInterface::FontIdentity& getIdentity() const {
38 return fIdentity; 38 return fIdentity;
39 } 39 }
40 40
41 protected: 41 protected:
42 SkTypeface_FCI(SkFontConfigInterface* fci, 42 SkTypeface_FCI(sk_sp<SkFontConfigInterface> fci,
43 const SkFontConfigInterface::FontIdentity& fi, 43 const SkFontConfigInterface::FontIdentity& fi,
44 const SkString& familyName, 44 const SkString& familyName,
45 const SkFontStyle& style) 45 const SkFontStyle& style)
46 : INHERITED(style, false) 46 : INHERITED(style, false)
47 , fFCI(SkRef(fci)) 47 , fFCI(std::move(fci))
48 , fIdentity(fi) 48 , fIdentity(fi)
49 , fFamilyName(familyName) 49 , fFamilyName(familyName)
50 , fFontData(nullptr) {} 50 , fFontData(nullptr) {}
51 51
52 SkTypeface_FCI(std::unique_ptr<SkFontData> data, SkFontStyle style, bool isF ixedPitch) 52 SkTypeface_FCI(std::unique_ptr<SkFontData> data, SkFontStyle style, bool isF ixedPitch)
53 : INHERITED(style, isFixedPitch) 53 : INHERITED(style, isFixedPitch)
54 , fFontData(std::move(data)) 54 , fFontData(std::move(data))
55 { 55 {
56 SkASSERT(fFontData); 56 SkASSERT(fFontData);
57 fIdentity.fTTCIndex = fFontData->getIndex(); 57 fIdentity.fTTCIndex = fFontData->getIndex();
58 } 58 }
59 59
60 void onGetFamilyName(SkString* familyName) const override { *familyName = fF amilyName; } 60 void onGetFamilyName(SkString* familyName) const override { *familyName = fF amilyName; }
61 void onGetFontDescriptor(SkFontDescriptor*, bool*) const override; 61 void onGetFontDescriptor(SkFontDescriptor*, bool*) const override;
62 SkStreamAsset* onOpenStream(int* ttcIndex) const override; 62 SkStreamAsset* onOpenStream(int* ttcIndex) const override;
63 std::unique_ptr<SkFontData> onMakeFontData() const override; 63 std::unique_ptr<SkFontData> onMakeFontData() const override;
64 64
65 private: 65 private:
66 typedef SkTypeface_FreeType INHERITED; 66 typedef SkTypeface_FreeType INHERITED;
67 }; 67 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698