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

Side by Side Diff: src/core/SkFontMgr.cpp

Issue 1949313003: Reland of SkOncePtr -> SkOnce (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 7 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
« no previous file with comments | « src/core/SkData.cpp ('k') | src/core/SkGlyphCache.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 2015 Google Inc. 2 * Copyright 2015 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 "SkFontDescriptor.h" 8 #include "SkFontDescriptor.h"
9 #include "SkFontMgr.h" 9 #include "SkFontMgr.h"
10 #include "SkOncePtr.h" 10 #include "SkOnce.h"
11 #include "SkStream.h" 11 #include "SkStream.h"
12 #include "SkTypes.h" 12 #include "SkTypes.h"
13 13
14 class SkFontStyle; 14 class SkFontStyle;
15 class SkTypeface; 15 class SkTypeface;
16 16
17 class SkEmptyFontStyleSet : public SkFontStyleSet { 17 class SkEmptyFontStyleSet : public SkFontStyleSet {
18 public: 18 public:
19 int count() override { return 0; } 19 int count() override { return 0; }
20 void getStyle(int, SkFontStyle*, SkString*) override { 20 void getStyle(int, SkFontStyle*, SkString*) override {
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 if (nullptr == path) { 162 if (nullptr == path) {
163 return nullptr; 163 return nullptr;
164 } 164 }
165 return this->onCreateFromFile(path, ttcIndex); 165 return this->onCreateFromFile(path, ttcIndex);
166 } 166 }
167 167
168 SkTypeface* SkFontMgr::legacyCreateTypeface(const char familyName[], SkFontStyle style) const { 168 SkTypeface* SkFontMgr::legacyCreateTypeface(const char familyName[], SkFontStyle style) const {
169 return this->onLegacyCreateTypeface(familyName, style); 169 return this->onLegacyCreateTypeface(familyName, style);
170 } 170 }
171 171
172 SK_DECLARE_STATIC_ONCE_PTR(SkFontMgr, singleton);
173 SkFontMgr* SkFontMgr::RefDefault() { 172 SkFontMgr* SkFontMgr::RefDefault() {
174 return SkRef(singleton.get([]{ 173 static SkOnce once;
174 static SkFontMgr* singleton;
175
176 once([]{
175 SkFontMgr* fm = SkFontMgr::Factory(); 177 SkFontMgr* fm = SkFontMgr::Factory();
176 return fm ? fm : new SkEmptyFontMgr; 178 singleton = fm ? fm : new SkEmptyFontMgr;
177 })); 179 });
180 return SkRef(singleton);
178 } 181 }
179 182
180 /** 183 /**
181 * Width has the greatest priority. 184 * Width has the greatest priority.
182 * If the value of pattern.width is 5 (normal) or less, 185 * If the value of pattern.width is 5 (normal) or less,
183 * narrower width values are checked first, then wider values. 186 * narrower width values are checked first, then wider values.
184 * If the value of pattern.width is greater than 5 (normal), 187 * If the value of pattern.width is greater than 5 (normal),
185 * wider values are checked first, followed by narrower values. 188 * wider values are checked first, followed by narrower values.
186 * 189 *
187 * Italic/Oblique has the next highest priority. 190 * Italic/Oblique has the next highest priority.
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 } 288 }
286 } 289 }
287 290
288 if (maxScore < currentScore) { 291 if (maxScore < currentScore) {
289 maxScore = currentScore; 292 maxScore = currentScore;
290 } 293 }
291 } 294 }
292 295
293 return this->createTypeface(maxScore.index); 296 return this->createTypeface(maxScore.index);
294 } 297 }
OLDNEW
« no previous file with comments | « src/core/SkData.cpp ('k') | src/core/SkGlyphCache.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698