OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 #ifndef SkTypefacePriv_DEFINED | 8 #ifndef SkTypefacePriv_DEFINED |
9 #define SkTypefacePriv_DEFINED | 9 #define SkTypefacePriv_DEFINED |
10 | 10 |
11 #include "SkTypeface.h" | 11 #include "SkTypeface.h" |
12 | 12 |
13 /** | 13 /** |
14 * Return a ref'd typeface, which must later be unref'd | 14 * Return a ref'd typeface, which must later be unref'd |
15 * | 15 * |
16 * If the parameter is non-null, it will be ref'd and returned, otherwise | 16 * If the parameter is non-null, it will be ref'd and returned, otherwise |
17 * it will be the default typeface. | 17 * it will be the default typeface. |
18 */ | 18 */ |
19 static inline SkTypeface* ref_or_default(SkTypeface* face) { | 19 static inline sk_sp<SkTypeface> ref_or_default(SkTypeface* face) { |
20 return face ? SkRef(face) : SkTypeface::RefDefault(); | 20 return face ? sk_ref_sp(face) : SkTypeface::MakeDefault(); |
21 } | 21 } |
22 | 22 |
23 /** | 23 /** |
24 * Always resolves to a non-null typeface, either the value passed to its | 24 * Always resolves to a non-null typeface, either the value passed to its |
25 * constructor, or the default typeface if null was passed. | 25 * constructor, or the default typeface if null was passed. |
26 */ | 26 */ |
27 class SkAutoResolveDefaultTypeface : public SkAutoTUnref<SkTypeface> { | 27 class SkAutoResolveDefaultTypeface : public sk_sp<SkTypeface> { |
28 public: | 28 public: |
29 SkAutoResolveDefaultTypeface() : INHERITED(SkTypeface::RefDefault()) {} | 29 SkAutoResolveDefaultTypeface() : INHERITED(SkTypeface::MakeDefault()) {} |
30 | 30 |
31 SkAutoResolveDefaultTypeface(SkTypeface* face) | 31 SkAutoResolveDefaultTypeface(SkTypeface* face) |
32 : INHERITED(ref_or_default(face)) {} | 32 : INHERITED(ref_or_default(face)) {} |
33 | 33 |
34 private: | 34 private: |
35 typedef SkAutoTUnref<SkTypeface> INHERITED; | 35 typedef sk_sp<SkTypeface> INHERITED; |
36 }; | 36 }; |
37 | 37 |
38 #endif | 38 #endif |
OLD | NEW |