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

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

Issue 355573006: Fix race condition in parallel font initialization. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 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
OLDNEW
1 /* 1 /*
2 * Copyright 2009 Google Inc. 2 * Copyright 2009 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 /* migrated from chrome/src/skia/ext/SkFontHost_fontconfig_direct.cpp */ 8 /* migrated from chrome/src/skia/ext/SkFontHost_fontconfig_direct.cpp */
9 9
10 #include <string> 10 #include <string>
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 // new APIs 117 // new APIs
118 virtual SkDataTable* getFamilyNames() SK_OVERRIDE; 118 virtual SkDataTable* getFamilyNames() SK_OVERRIDE;
119 virtual bool matchFamilySet(const char inFamilyName[], 119 virtual bool matchFamilySet(const char inFamilyName[],
120 SkString* outFamilyName, 120 SkString* outFamilyName,
121 SkTArray<FontIdentity>*) SK_OVERRIDE; 121 SkTArray<FontIdentity>*) SK_OVERRIDE;
122 122
123 private: 123 private:
124 SkMutex mutex_; 124 SkMutex mutex_;
125 }; 125 };
126 126
127 SkFontConfigInterface* SkFontConfigInterface::GetSingletonDirectInterface() { 127 SkFontConfigInterface* SkFontConfigInterface::GetSingletonDirectInterface(SkBase Mutex& mutex) {
128 SkAutoMutexAcquire ac(mutex);
128 SK_DECLARE_STATIC_LAZY_PTR(SkFontConfigInterfaceDirect, direct); 129 SK_DECLARE_STATIC_LAZY_PTR(SkFontConfigInterfaceDirect, direct);
mtklein 2014/06/26 18:59:07 Given the mutex lock, this can become simply stat
tomhudson 2014/06/26 21:01:52 SK_DECLARE_STATIC_LAZY_PTR does nicely describe wh
129 return direct.get(); 130 return direct.get();
130 } 131 }
131 132
132 /////////////////////////////////////////////////////////////////////////////// 133 ///////////////////////////////////////////////////////////////////////////////
133 134
134 // Returns the string from the pattern, or NULL 135 // Returns the string from the pattern, or NULL
135 static const char* get_name(FcPattern* pattern, const char field[], 136 static const char* get_name(FcPattern* pattern, const char field[],
136 int index = 0) { 137 int index = 0) {
137 const char* name; 138 const char* name;
138 if (FcPatternGetString(pattern, field, index, 139 if (FcPatternGetString(pattern, field, index,
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 *trimmedMatches.append() = match[i]; 721 *trimmedMatches.append() = match[i];
721 } 722 }
722 } 723 }
723 724
724 SkFontStyleSet_FC* sset = SkNEW_ARGS(SkFontStyleSet_FC, 725 SkFontStyleSet_FC* sset = SkNEW_ARGS(SkFontStyleSet_FC,
725 (trimmedMatches.begin(), 726 (trimmedMatches.begin(),
726 trimmedMatches.count())); 727 trimmedMatches.count()));
727 #endif 728 #endif
728 return false; 729 return false;
729 } 730 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698