Chromium Code Reviews| 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 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 227 | 227 |
| 228 /** | 228 /** |
| 229 * SkAutoTUnref assumes ownership of the ref. As a result, it is an error | 229 * SkAutoTUnref assumes ownership of the ref. As a result, it is an error |
| 230 * for the user to ref or unref through SkAutoTUnref. Therefore | 230 * for the user to ref or unref through SkAutoTUnref. Therefore |
| 231 * SkAutoTUnref::operator-> returns BlockRef<T>*. This prevents use of | 231 * SkAutoTUnref::operator-> returns BlockRef<T>*. This prevents use of |
| 232 * skAutoTUnrefInstance->ref() and skAutoTUnrefInstance->unref(). | 232 * skAutoTUnrefInstance->ref() and skAutoTUnrefInstance->unref(). |
| 233 */ | 233 */ |
| 234 BlockRefType *operator->() const { | 234 BlockRefType *operator->() const { |
| 235 return static_cast<BlockRefType*>(fObj); | 235 return static_cast<BlockRefType*>(fObj); |
| 236 } | 236 } |
| 237 operator T*() { return fObj; } | 237 operator T*() const { return fObj; } |
|
bungeman-skia
2014/09/18 14:50:09
mtklein and I have stated a couple of times that t
| |
| 238 | 238 |
| 239 private: | 239 private: |
| 240 T* fObj; | 240 T* fObj; |
| 241 }; | 241 }; |
| 242 // Can't use the #define trick below to guard a bare SkAutoTUnref(...) because i t's templated. :( | 242 // Can't use the #define trick below to guard a bare SkAutoTUnref(...) because i t's templated. :( |
| 243 | 243 |
| 244 class SkAutoUnref : public SkAutoTUnref<SkRefCnt> { | 244 class SkAutoUnref : public SkAutoTUnref<SkRefCnt> { |
| 245 public: | 245 public: |
| 246 SkAutoUnref(SkRefCnt* obj) : SkAutoTUnref<SkRefCnt>(obj) {} | 246 SkAutoUnref(SkRefCnt* obj) : SkAutoTUnref<SkRefCnt>(obj) {} |
| 247 }; | 247 }; |
| 248 #define SkAutoUnref(...) SK_REQUIRE_LOCAL_VAR(SkAutoUnref) | 248 #define SkAutoUnref(...) SK_REQUIRE_LOCAL_VAR(SkAutoUnref) |
| 249 | 249 |
| 250 #endif | 250 #endif |
| OLD | NEW |