| OLD | NEW |
| 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 Loading... |
| 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 } | |
| OLD | NEW |