OLD | NEW |
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 #ifndef SkFontMgr_indirect_DEFINED | 8 #ifndef SkFontMgr_indirect_DEFINED |
9 #define SkFontMgr_indirect_DEFINED | 9 #define SkFontMgr_indirect_DEFINED |
10 | 10 |
11 #include "../private/SkMutex.h" | 11 #include "../private/SkMutex.h" |
| 12 #include "../private/SkOnce.h" |
12 #include "../private/SkTArray.h" | 13 #include "../private/SkTArray.h" |
13 #include "SkDataTable.h" | 14 #include "SkDataTable.h" |
14 #include "SkFontMgr.h" | 15 #include "SkFontMgr.h" |
15 #include "SkRefCnt.h" | 16 #include "SkRefCnt.h" |
16 #include "SkRemotableFontMgr.h" | 17 #include "SkRemotableFontMgr.h" |
17 #include "SkTypeface.h" | 18 #include "SkTypeface.h" |
18 #include "SkTypes.h" | 19 #include "SkTypes.h" |
19 | 20 |
20 class SkData; | 21 class SkData; |
21 class SkFontStyle; | 22 class SkFontStyle; |
22 class SkStreamAsset; | 23 class SkStreamAsset; |
23 class SkString; | 24 class SkString; |
24 | 25 |
25 class SK_API SkFontMgr_Indirect : public SkFontMgr { | 26 class SK_API SkFontMgr_Indirect : public SkFontMgr { |
26 public: | 27 public: |
27 // TODO: The SkFontMgr is only used for createFromStream/File/Data. | 28 // TODO: The SkFontMgr is only used for createFromStream/File/Data. |
28 // In the future these calls should be broken out into their own interface | 29 // In the future these calls should be broken out into their own interface |
29 // with a name like SkFontRenderer. | 30 // with a name like SkFontRenderer. |
30 SkFontMgr_Indirect(SkFontMgr* impl, SkRemotableFontMgr* proxy) | 31 SkFontMgr_Indirect(SkFontMgr* impl, SkRemotableFontMgr* proxy) |
31 : fImpl(SkRef(impl)), fProxy(SkRef(proxy)), fFamilyNamesInited(false) | 32 : fImpl(SkRef(impl)), fProxy(SkRef(proxy)) |
32 { } | 33 { } |
33 | 34 |
34 protected: | 35 protected: |
35 int onCountFamilies() const override; | 36 int onCountFamilies() const override; |
36 void onGetFamilyName(int index, SkString* familyName) const override; | 37 void onGetFamilyName(int index, SkString* familyName) const override; |
37 SkFontStyleSet* onCreateStyleSet(int index) const override; | 38 SkFontStyleSet* onCreateStyleSet(int index) const override; |
38 | 39 |
39 SkFontStyleSet* onMatchFamily(const char familyName[]) const override; | 40 SkFontStyleSet* onMatchFamily(const char familyName[]) const override; |
40 | 41 |
41 SkTypeface* onMatchFamilyStyle(const char familyName[], | 42 SkTypeface* onMatchFamilyStyle(const char familyName[], |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 /** | 89 /** |
89 * This cache is essentially { dataId: { ttcIndex: typeface } } | 90 * This cache is essentially { dataId: { ttcIndex: typeface } } |
90 * For data caching we want a mapping from data id to weak references to | 91 * For data caching we want a mapping from data id to weak references to |
91 * typefaces with that data id. By storing the index next to the typeface, | 92 * typefaces with that data id. By storing the index next to the typeface, |
92 * this data cache also acts as a typeface cache. | 93 * this data cache also acts as a typeface cache. |
93 */ | 94 */ |
94 mutable SkTArray<DataEntry> fDataCache; | 95 mutable SkTArray<DataEntry> fDataCache; |
95 mutable SkMutex fDataCacheMutex; | 96 mutable SkMutex fDataCacheMutex; |
96 | 97 |
97 mutable SkAutoTUnref<SkDataTable> fFamilyNames; | 98 mutable SkAutoTUnref<SkDataTable> fFamilyNames; |
98 mutable bool fFamilyNamesInited; | 99 mutable SkOnce fFamilyNamesInitOnce; |
99 mutable SkMutex fFamilyNamesMutex; | |
100 static void set_up_family_names(const SkFontMgr_Indirect* self); | 100 static void set_up_family_names(const SkFontMgr_Indirect* self); |
101 | 101 |
102 friend class SkStyleSet_Indirect; | 102 friend class SkStyleSet_Indirect; |
103 }; | 103 }; |
104 | 104 |
105 #endif | 105 #endif |
OLD | NEW |