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 #include "SkFontMgr_indirect.h" | 8 #include "SkFontMgr_indirect.h" |
9 | 9 |
10 #include "SkDataTable.h" | 10 #include "SkDataTable.h" |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 SkAutoTUnref<const SkFontMgr_Indirect> fOwner; | 148 SkAutoTUnref<const SkFontMgr_Indirect> fOwner; |
149 int fFamilyIndex; | 149 int fFamilyIndex; |
150 SkAutoTUnref<SkRemotableFontIdentitySet> fData; | 150 SkAutoTUnref<SkRemotableFontIdentitySet> fData; |
151 }; | 151 }; |
152 | 152 |
153 void SkFontMgr_Indirect::set_up_family_names(const SkFontMgr_Indirect* self) { | 153 void SkFontMgr_Indirect::set_up_family_names(const SkFontMgr_Indirect* self) { |
154 self->fFamilyNames.reset(self->fProxy->getFamilyNames()); | 154 self->fFamilyNames.reset(self->fProxy->getFamilyNames()); |
155 } | 155 } |
156 | 156 |
157 int SkFontMgr_Indirect::onCountFamilies() const { | 157 int SkFontMgr_Indirect::onCountFamilies() const { |
158 SkOnce(&fOnce, SkFontMgr_Indirect::set_up_family_names, this); | 158 SkOnce(&fFamilyNamesInited, &fFamilyNamesMutex, SkFontMgr_Indirect::set_up_f
amily_names, this); |
159 return fFamilyNames->count(); | 159 return fFamilyNames->count(); |
160 } | 160 } |
161 | 161 |
162 void SkFontMgr_Indirect::onGetFamilyName(int index, SkString* familyName) const
{ | 162 void SkFontMgr_Indirect::onGetFamilyName(int index, SkString* familyName) const
{ |
163 SkOnce(&fOnce, SkFontMgr_Indirect::set_up_family_names, this); | 163 SkOnce(&fFamilyNamesInited, &fFamilyNamesMutex, SkFontMgr_Indirect::set_up_f
amily_names, this); |
164 if (index >= fFamilyNames->count()) { | 164 if (index >= fFamilyNames->count()) { |
165 familyName->reset(); | 165 familyName->reset(); |
166 return; | 166 return; |
167 } | 167 } |
168 familyName->set(fFamilyNames->atStr(index)); | 168 familyName->set(fFamilyNames->atStr(index)); |
169 } | 169 } |
170 | 170 |
171 SkFontStyleSet* SkFontMgr_Indirect::onCreateStyleSet(int index) const { | 171 SkFontStyleSet* SkFontMgr_Indirect::onCreateStyleSet(int index) const { |
172 SkRemotableFontIdentitySet* set = fProxy->getIndex(index); | 172 SkRemotableFontIdentitySet* set = fProxy->getIndex(index); |
173 if (NULL == set) { | 173 if (NULL == set) { |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 face.reset(this->matchFamilyStyle(NULL, style)); | 288 face.reset(this->matchFamilyStyle(NULL, style)); |
289 } | 289 } |
290 | 290 |
291 if (NULL == face.get()) { | 291 if (NULL == face.get()) { |
292 SkFontIdentity fontId = this->fProxy->matchIndexStyle(0, style); | 292 SkFontIdentity fontId = this->fProxy->matchIndexStyle(0, style); |
293 face.reset(this->createTypefaceFromFontId(fontId)); | 293 face.reset(this->createTypefaceFromFontId(fontId)); |
294 } | 294 } |
295 | 295 |
296 return face.detach(); | 296 return face.detach(); |
297 } | 297 } |
OLD | NEW |