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

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

Issue 1322933005: Port uses of SkLazyPtr to SkOncePtr. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: name Created 5 years, 3 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 "SkLazyPtr.h" 10 #include "SkOncePtr.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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 return nullptr; 151 return nullptr;
152 } 152 }
153 return this->onCreateFromFile(path, ttcIndex); 153 return this->onCreateFromFile(path, ttcIndex);
154 } 154 }
155 155
156 SkTypeface* SkFontMgr::legacyCreateTypeface(const char familyName[], 156 SkTypeface* SkFontMgr::legacyCreateTypeface(const char familyName[],
157 unsigned styleBits) const { 157 unsigned styleBits) const {
158 return this->onLegacyCreateTypeface(familyName, styleBits); 158 return this->onLegacyCreateTypeface(familyName, styleBits);
159 } 159 }
160 160
161 // As a template argument this must have external linkage. 161 SK_DECLARE_STATIC_ONCE_PTR(SkFontMgr, singleton);
162 SkFontMgr* sk_fontmgr_create_default() { 162 SkFontMgr* SkFontMgr::RefDefault() {
163 SkFontMgr* fm = SkFontMgr::Factory(); 163 return SkRef(singleton.get([]{
164 return fm ? fm : new SkEmptyFontMgr; 164 SkFontMgr* fm = SkFontMgr::Factory();
165 return fm ? fm : new SkEmptyFontMgr;
166 }));
165 } 167 }
166
167 SK_DECLARE_STATIC_LAZY_PTR(SkFontMgr, singleton, sk_fontmgr_create_default);
168
169 SkFontMgr* SkFontMgr::RefDefault() {
170 return SkRef(singleton.get());
171 }
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