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

Side by Side Diff: include/core/SkRefCnt.h

Issue 393953004: SkAutoRef seems lonely. Might as well delete it. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: simpler Created 6 years, 5 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 | « no previous file | src/gpu/GrTextStrike.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 /* 2 /*
3 * Copyright 2006 The Android Open Source Project 3 * Copyright 2006 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #ifndef SkRefCnt_DEFINED 10 #ifndef SkRefCnt_DEFINED
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 T* fObj; 241 T* fObj;
242 }; 242 };
243 // Can't use the #define trick below to guard a bare SkAutoTUnref(...) because i t's templated. :( 243 // Can't use the #define trick below to guard a bare SkAutoTUnref(...) because i t's templated. :(
244 244
245 class SkAutoUnref : public SkAutoTUnref<SkRefCnt> { 245 class SkAutoUnref : public SkAutoTUnref<SkRefCnt> {
246 public: 246 public:
247 SkAutoUnref(SkRefCnt* obj) : SkAutoTUnref<SkRefCnt>(obj) {} 247 SkAutoUnref(SkRefCnt* obj) : SkAutoTUnref<SkRefCnt>(obj) {}
248 }; 248 };
249 #define SkAutoUnref(...) SK_REQUIRE_LOCAL_VAR(SkAutoUnref) 249 #define SkAutoUnref(...) SK_REQUIRE_LOCAL_VAR(SkAutoUnref)
250 250
251 class SkAutoRef : SkNoncopyable {
252 public:
253 SkAutoRef(SkRefCnt* obj) : fObj(obj) { SkSafeRef(obj); }
254 ~SkAutoRef() { SkSafeUnref(fObj); }
255 private:
256 SkRefCnt* fObj;
257 };
258 #define SkAutoRef(...) SK_REQUIRE_LOCAL_VAR(SkAutoRef)
259
260 /** Wrapper class for SkRefCnt pointers. This manages ref/unref of a pointer to 251 /** Wrapper class for SkRefCnt pointers. This manages ref/unref of a pointer to
261 a SkRefCnt (or subclass) object. 252 a SkRefCnt (or subclass) object.
262 */ 253 */
263 template <typename T> class SkRefPtr { 254 template <typename T> class SkRefPtr {
264 public: 255 public:
265 SkRefPtr() : fObj(NULL) {} 256 SkRefPtr() : fObj(NULL) {}
266 SkRefPtr(T* obj) : fObj(obj) { SkSafeRef(fObj); } 257 SkRefPtr(T* obj) : fObj(obj) { SkSafeRef(fObj); }
267 SkRefPtr(const SkRefPtr& o) : fObj(o.fObj) { SkSafeRef(fObj); } 258 SkRefPtr(const SkRefPtr& o) : fObj(o.fObj) { SkSafeRef(fObj); }
268 ~SkRefPtr() { SkSafeUnref(fObj); } 259 ~SkRefPtr() { SkSafeUnref(fObj); }
269 260
(...skipping 13 matching lines...) Expand all
283 typedef T* SkRefPtr::*unspecified_bool_type; 274 typedef T* SkRefPtr::*unspecified_bool_type;
284 operator unspecified_bool_type() const { 275 operator unspecified_bool_type() const {
285 return fObj ? &SkRefPtr::fObj : NULL; 276 return fObj ? &SkRefPtr::fObj : NULL;
286 } 277 }
287 278
288 private: 279 private:
289 T* fObj; 280 T* fObj;
290 }; 281 };
291 282
292 #endif 283 #endif
OLDNEW
« no previous file with comments | « no previous file | src/gpu/GrTextStrike.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698