| OLD | NEW |
| 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 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 * so unref() will not be called in our destructor. A subsequent call to | 182 * so unref() will not be called in our destructor. A subsequent call to |
| 183 * detach() will do nothing and return null. | 183 * detach() will do nothing and return null. |
| 184 */ | 184 */ |
| 185 T* detach() { | 185 T* detach() { |
| 186 T* obj = fObj; | 186 T* obj = fObj; |
| 187 fObj = NULL; | 187 fObj = NULL; |
| 188 return obj; | 188 return obj; |
| 189 } | 189 } |
| 190 | 190 |
| 191 /** | 191 /** |
| 192 * BlockRef<B> is a type which inherits from B, cannot be created, | 192 * BlockRef<B> is a type which inherits from B, cannot be created, |
| 193 * and makes ref and unref private. | 193 * cannot be deleted, and makes ref and unref private. |
| 194 */ | 194 */ |
| 195 template<typename B> class BlockRef : public B { | 195 template<typename B> class BlockRef : public B { |
| 196 private: | 196 private: |
| 197 BlockRef(); | 197 BlockRef(); |
| 198 ~BlockRef(); |
| 198 void ref() const; | 199 void ref() const; |
| 199 void unref() const; | 200 void unref() const; |
| 200 }; | 201 }; |
| 201 | 202 |
| 202 /** If T is const, the type returned from operator-> will also be const. */ | 203 /** If T is const, the type returned from operator-> will also be const. */ |
| 203 typedef typename SkTConstType<BlockRef<T>, SkTIsConst<T>::value>::type Block
RefType; | 204 typedef typename SkTConstType<BlockRef<T>, SkTIsConst<T>::value>::type Block
RefType; |
| 204 | 205 |
| 205 /** | 206 /** |
| 206 * SkAutoTUnref assumes ownership of the ref. As a result, it is an error | 207 * SkAutoTUnref assumes ownership of the ref. As a result, it is an error |
| 207 * for the user to ref or unref through SkAutoTUnref. Therefore | 208 * for the user to ref or unref through SkAutoTUnref. Therefore |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 typedef T* SkRefPtr::*unspecified_bool_type; | 257 typedef T* SkRefPtr::*unspecified_bool_type; |
| 257 operator unspecified_bool_type() const { | 258 operator unspecified_bool_type() const { |
| 258 return fObj ? &SkRefPtr::fObj : NULL; | 259 return fObj ? &SkRefPtr::fObj : NULL; |
| 259 } | 260 } |
| 260 | 261 |
| 261 private: | 262 private: |
| 262 T* fObj; | 263 T* fObj; |
| 263 }; | 264 }; |
| 264 | 265 |
| 265 #endif | 266 #endif |
| OLD | NEW |