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

Side by Side Diff: include/ports/SkFontMgr_indirect.h

Issue 1894893002: Modernize and trim down SkOnce. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: might as well class Created 4 years, 8 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 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
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
OLDNEW
« no previous file with comments | « include/gpu/GrResourceKey.h ('k') | include/private/SkOnce.h » ('j') | include/private/SkOnce.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698