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

Side by Side Diff: src/core/SkTypefacePriv.h

Issue 1933393002: Move SkTypeface to sk_sp. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Restore deleted Android code. 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/SkTypeface.cpp ('k') | src/fonts/SkGScalerContext.h » ('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 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
OLDNEW
« no previous file with comments | « src/core/SkTypeface.cpp ('k') | src/fonts/SkGScalerContext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698