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

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

Issue 210283002: Clean up SkOnce usage in SkFontMgr_Indirect. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | src/fonts/SkFontMgr_indirect.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 #ifndef SkFontMgr_indirect_DEFINED 8 #ifndef SkFontMgr_indirect_DEFINED
9 #define SkFontMgr_indirect_DEFINED 9 #define SkFontMgr_indirect_DEFINED
10 10
11 #include "SkDataTable.h" 11 #include "SkDataTable.h"
12 #include "SkFontMgr.h" 12 #include "SkFontMgr.h"
13 #include "SkFontStyle.h" 13 #include "SkFontStyle.h"
14 #include "SkOnce.h" 14 #include "SkOnce.h"
15 #include "SkRemotableFontMgr.h" 15 #include "SkRemotableFontMgr.h"
16 #include "SkTArray.h" 16 #include "SkTArray.h"
17 #include "SkTypeface.h" 17 #include "SkTypeface.h"
18 18
19 class SkData; 19 class SkData;
20 class SkStream; 20 class SkStream;
21 class SkString; 21 class SkString;
22 class SkTypeface; 22 class SkTypeface;
23 23
24 class SK_API SkFontMgr_Indirect : public SkFontMgr { 24 class SK_API SkFontMgr_Indirect : public SkFontMgr {
25 public: 25 public:
26 // TODO: The SkFontMgr is only used for createFromStream/File/Data. 26 // TODO: The SkFontMgr is only used for createFromStream/File/Data.
27 // In the future these calls should be broken out into their own interface 27 // In the future these calls should be broken out into their own interface
28 // with a name like SkFontRenderer. 28 // with a name like SkFontRenderer.
29 SkFontMgr_Indirect(SkFontMgr* impl, SkRemotableFontMgr* proxy) 29 SkFontMgr_Indirect(SkFontMgr* impl, SkRemotableFontMgr* proxy)
30 : fImpl(SkRef(impl)), fProxy(SkRef(proxy)) 30 : fImpl(SkRef(impl)), fProxy(SkRef(proxy)), fFamilyNamesInited(false)
31 { 31 { }
32 fOnce.done = false;
33 fOnce.lock.thisIsPrivate = 0;
34 SkDEBUGCODE(fOnce.lock.shouldBeZero = 0;)
35 }
36 32
37 protected: 33 protected:
38 virtual int onCountFamilies() const SK_OVERRIDE; 34 virtual int onCountFamilies() const SK_OVERRIDE;
39 virtual void onGetFamilyName(int index, SkString* familyName) const SK_OVERR IDE; 35 virtual void onGetFamilyName(int index, SkString* familyName) const SK_OVERR IDE;
40 virtual SkFontStyleSet* onCreateStyleSet(int index) const SK_OVERRIDE; 36 virtual SkFontStyleSet* onCreateStyleSet(int index) const SK_OVERRIDE;
41 37
42 virtual SkFontStyleSet* onMatchFamily(const char familyName[]) const SK_OVER RIDE; 38 virtual SkFontStyleSet* onMatchFamily(const char familyName[]) const SK_OVER RIDE;
43 39
44 virtual SkTypeface* onMatchFamilyStyle(const char familyName[], 40 virtual SkTypeface* onMatchFamilyStyle(const char familyName[],
45 const SkFontStyle& fontStyle) const S K_OVERRIDE; 41 const SkFontStyle& fontStyle) const S K_OVERRIDE;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 /** 88 /**
93 * This cache is essentially { dataId: { ttcIndex: typeface } } 89 * This cache is essentially { dataId: { ttcIndex: typeface } }
94 * For data caching we want a mapping from data id to weak references to 90 * For data caching we want a mapping from data id to weak references to
95 * typefaces with that data id. By storing the index next to the typeface, 91 * typefaces with that data id. By storing the index next to the typeface,
96 * this data cache also acts as a typeface cache. 92 * this data cache also acts as a typeface cache.
97 */ 93 */
98 mutable SkTArray<DataEntry> fDataCache; 94 mutable SkTArray<DataEntry> fDataCache;
99 mutable SkMutex fDataCacheMutex; 95 mutable SkMutex fDataCacheMutex;
100 96
101 mutable SkAutoTUnref<SkDataTable> fFamilyNames; 97 mutable SkAutoTUnref<SkDataTable> fFamilyNames;
102 mutable SkOnceFlag fOnce; 98 mutable bool fFamilyNamesInited;
99 mutable SkMutex fFamilyNamesMutex;
103 static void set_up_family_names(const SkFontMgr_Indirect* self); 100 static void set_up_family_names(const SkFontMgr_Indirect* self);
104 101
105 friend class SkStyleSet_Indirect; 102 friend class SkStyleSet_Indirect;
106 }; 103 };
107 104
108 #endif 105 #endif
109 106
OLDNEW
« no previous file with comments | « no previous file | src/fonts/SkFontMgr_indirect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698