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

Side by Side Diff: src/fonts/SkFontMgr_indirect.cpp

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 #include "SkDataTable.h" 8 #include "SkDataTable.h"
9 #include "SkFontMgr.h" 9 #include "SkFontMgr.h"
10 #include "SkFontMgr_indirect.h" 10 #include "SkFontMgr_indirect.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 SkAutoTUnref<const SkFontMgr_Indirect> fOwner; 58 SkAutoTUnref<const SkFontMgr_Indirect> fOwner;
59 int fFamilyIndex; 59 int fFamilyIndex;
60 SkAutoTUnref<SkRemotableFontIdentitySet> fData; 60 SkAutoTUnref<SkRemotableFontIdentitySet> fData;
61 }; 61 };
62 62
63 void SkFontMgr_Indirect::set_up_family_names(const SkFontMgr_Indirect* self) { 63 void SkFontMgr_Indirect::set_up_family_names(const SkFontMgr_Indirect* self) {
64 self->fFamilyNames.reset(self->fProxy->getFamilyNames()); 64 self->fFamilyNames.reset(self->fProxy->getFamilyNames());
65 } 65 }
66 66
67 int SkFontMgr_Indirect::onCountFamilies() const { 67 int SkFontMgr_Indirect::onCountFamilies() const {
68 SkOnce(&fFamilyNamesInited, &fFamilyNamesMutex, SkFontMgr_Indirect::set_up_f amily_names, this); 68 fFamilyNamesInitOnce(SkFontMgr_Indirect::set_up_family_names, this);
69 return fFamilyNames->count(); 69 return fFamilyNames->count();
70 } 70 }
71 71
72 void SkFontMgr_Indirect::onGetFamilyName(int index, SkString* familyName) const { 72 void SkFontMgr_Indirect::onGetFamilyName(int index, SkString* familyName) const {
73 SkOnce(&fFamilyNamesInited, &fFamilyNamesMutex, SkFontMgr_Indirect::set_up_f amily_names, this); 73 fFamilyNamesInitOnce(SkFontMgr_Indirect::set_up_family_names, this);
74 if (index >= fFamilyNames->count()) { 74 if (index >= fFamilyNames->count()) {
75 familyName->reset(); 75 familyName->reset();
76 return; 76 return;
77 } 77 }
78 familyName->set(fFamilyNames->atStr(index)); 78 familyName->set(fFamilyNames->atStr(index));
79 } 79 }
80 80
81 SkFontStyleSet* SkFontMgr_Indirect::onCreateStyleSet(int index) const { 81 SkFontStyleSet* SkFontMgr_Indirect::onCreateStyleSet(int index) const {
82 SkRemotableFontIdentitySet* set = fProxy->getIndex(index); 82 SkRemotableFontIdentitySet* set = fProxy->getIndex(index);
83 if (nullptr == set) { 83 if (nullptr == set) {
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 face.reset(this->matchFamilyStyle(nullptr, style)); 192 face.reset(this->matchFamilyStyle(nullptr, style));
193 } 193 }
194 194
195 if (nullptr == face.get()) { 195 if (nullptr == face.get()) {
196 SkFontIdentity fontId = this->fProxy->matchIndexStyle(0, style); 196 SkFontIdentity fontId = this->fProxy->matchIndexStyle(0, style);
197 face.reset(this->createTypefaceFromFontId(fontId)); 197 face.reset(this->createTypefaceFromFontId(fontId));
198 } 198 }
199 199
200 return face.release(); 200 return face.release();
201 } 201 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698