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

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

Issue 23904003: Remove GrRefCnt.h in favor of SkRefCnt.h (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: rm GrRefCnt.h Created 7 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « gyp/public_headers.gypi ('k') | include/gpu/GrContext.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 /* 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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 } 153 }
154 154
155 /** Check if the argument is non-null, and if so, call obj->unref() 155 /** Check if the argument is non-null, and if so, call obj->unref()
156 */ 156 */
157 template <typename T> static inline void SkSafeUnref(T* obj) { 157 template <typename T> static inline void SkSafeUnref(T* obj) {
158 if (obj) { 158 if (obj) {
159 obj->unref(); 159 obj->unref();
160 } 160 }
161 } 161 }
162 162
163 template<typename T> static inline void SkSafeSetNull(T*& obj) {
164 if (NULL != obj) {
165 obj->unref();
166 obj = NULL;
167 }
168 }
169
163 /////////////////////////////////////////////////////////////////////////////// 170 ///////////////////////////////////////////////////////////////////////////////
164 171
165 /** 172 /**
166 * Utility class that simply unref's its argument in the destructor. 173 * Utility class that simply unref's its argument in the destructor.
167 */ 174 */
168 template <typename T> class SkAutoTUnref : SkNoncopyable { 175 template <typename T> class SkAutoTUnref : SkNoncopyable {
169 public: 176 public:
170 explicit SkAutoTUnref(T* obj = NULL) : fObj(obj) {} 177 explicit SkAutoTUnref(T* obj = NULL) : fObj(obj) {}
171 ~SkAutoTUnref() { SkSafeUnref(fObj); } 178 ~SkAutoTUnref() { SkSafeUnref(fObj); }
172 179
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 typedef T* SkRefPtr::*unspecified_bool_type; 272 typedef T* SkRefPtr::*unspecified_bool_type;
266 operator unspecified_bool_type() const { 273 operator unspecified_bool_type() const {
267 return fObj ? &SkRefPtr::fObj : NULL; 274 return fObj ? &SkRefPtr::fObj : NULL;
268 } 275 }
269 276
270 private: 277 private:
271 T* fObj; 278 T* fObj;
272 }; 279 };
273 280
274 #endif 281 #endif
OLDNEW
« no previous file with comments | « gyp/public_headers.gypi ('k') | include/gpu/GrContext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698