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

Side by Side Diff: tests/RefCntTest.cpp

Issue 1753973002: sk_make_sp<T>() (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 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 | « include/core/SkRefCnt.h ('k') | no next file » | 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 2012 Google Inc. 2 * Copyright 2012 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 "SkRefCnt.h" 8 #include "SkRefCnt.h"
9 #include "SkThreadUtils.h" 9 #include "SkThreadUtils.h"
10 #include "SkTypes.h" 10 #include "SkTypes.h"
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 if (0 == --fRefCnt) { 113 if (0 == --fRefCnt) {
114 gDeleteCounter += 1; 114 gDeleteCounter += 1;
115 delete this; 115 delete this;
116 } 116 }
117 } 117 }
118 118
119 int* method() const { return new int; } 119 int* method() const { return new int; }
120 }; 120 };
121 121
122 static sk_sp<Effect> Create() { 122 static sk_sp<Effect> Create() {
123 return sk_sp<Effect>(new Effect); 123 return sk_make_sp<Effect>();
124 } 124 }
125 125
126 class Paint { 126 class Paint {
127 public: 127 public:
128 sk_sp<Effect> fEffect; 128 sk_sp<Effect> fEffect;
129 129
130 const sk_sp<Effect>& get() const { return fEffect; } 130 const sk_sp<Effect>& get() const { return fEffect; }
131 131
132 void set(sk_sp<Effect> value) { 132 void set(sk_sp<Effect> value) {
133 fEffect = std::move(value); 133 fEffect = std::move(value);
(...skipping 28 matching lines...) Expand all
162 162
163 Paint paint2; 163 Paint paint2;
164 paint2.set(paint.get()); 164 paint2.set(paint.get());
165 check(reporter, 2, 1, 2, 1); 165 check(reporter, 2, 1, 2, 1);
166 REPORTER_ASSERT(reporter, paint.fEffect.get()->fRefCnt == 3); 166 REPORTER_ASSERT(reporter, paint.fEffect.get()->fRefCnt == 3);
167 167
168 delete paint.get()->method(); 168 delete paint.get()->method();
169 check(reporter, 2, 1, 2, 1); 169 check(reporter, 2, 1, 2, 1);
170 } 170 }
171 171
OLDNEW
« no previous file with comments | « include/core/SkRefCnt.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698