OLD | NEW |
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 Loading... |
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 SK_DECLARE_STATIC_LAZY_PTR(SkFontConfigInterfaceDirect, direct); | 128 SkAutoMutexAcquire ac(mutex); |
129 return direct.get(); | 129 static SkFontConfigInterfaceDirect* singleton = NULL; |
| 130 if (singleton == NULL) { |
| 131 singleton = SkNEW(SkFontConfigInterfaceDirect); |
| 132 } |
| 133 return singleton; |
130 } | 134 } |
131 | 135 |
132 /////////////////////////////////////////////////////////////////////////////// | 136 /////////////////////////////////////////////////////////////////////////////// |
133 | 137 |
134 // Returns the string from the pattern, or NULL | 138 // Returns the string from the pattern, or NULL |
135 static const char* get_name(FcPattern* pattern, const char field[], | 139 static const char* get_name(FcPattern* pattern, const char field[], |
136 int index = 0) { | 140 int index = 0) { |
137 const char* name; | 141 const char* name; |
138 if (FcPatternGetString(pattern, field, index, | 142 if (FcPatternGetString(pattern, field, index, |
139 (FcChar8**)&name) != FcResultMatch) { | 143 (FcChar8**)&name) != FcResultMatch) { |
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
720 *trimmedMatches.append() = match[i]; | 724 *trimmedMatches.append() = match[i]; |
721 } | 725 } |
722 } | 726 } |
723 | 727 |
724 SkFontStyleSet_FC* sset = SkNEW_ARGS(SkFontStyleSet_FC, | 728 SkFontStyleSet_FC* sset = SkNEW_ARGS(SkFontStyleSet_FC, |
725 (trimmedMatches.begin(), | 729 (trimmedMatches.begin(), |
726 trimmedMatches.count())); | 730 trimmedMatches.count())); |
727 #endif | 731 #endif |
728 return false; | 732 return false; |
729 } | 733 } |
OLD | NEW |