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

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

Issue 393913002: Remove SkRefPtr. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix parameter. 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/ports/SkFontConfigInterface_android.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 /** Wrapper class for SkRefCnt pointers. This manages ref/unref of a pointer to
252 a SkRefCnt (or subclass) object.
253 */
254 template <typename T> class SkRefPtr {
255 public:
256 SkRefPtr() : fObj(NULL) {}
257 SkRefPtr(T* obj) : fObj(obj) { SkSafeRef(fObj); }
258 SkRefPtr(const SkRefPtr& o) : fObj(o.fObj) { SkSafeRef(fObj); }
259 ~SkRefPtr() { SkSafeUnref(fObj); }
260
261 SkRefPtr& operator=(const SkRefPtr& rp) {
262 SkRefCnt_SafeAssign(fObj, rp.fObj);
263 return *this;
264 }
265 SkRefPtr& operator=(T* obj) {
266 SkRefCnt_SafeAssign(fObj, obj);
267 return *this;
268 }
269
270 T* get() const { return fObj; }
271 T& operator*() const { return *fObj; }
272 T* operator->() const { return fObj; }
273
274 typedef T* SkRefPtr::*unspecified_bool_type;
275 operator unspecified_bool_type() const {
276 return fObj ? &SkRefPtr::fObj : NULL;
277 }
278
279 private:
280 T* fObj;
281 };
282
283 #endif 251 #endif
OLDNEW
« no previous file with comments | « no previous file | src/ports/SkFontConfigInterface_android.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698