| 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 SkTemplates_DEFINED | 10 #ifndef SkTemplates_DEFINED |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 guarantees of T. | 108 guarantees of T. |
| 109 | 109 |
| 110 The size of a SkAutoTDelete is small: sizeof(SkAutoTDelete<T>) == sizeof(T*) | 110 The size of a SkAutoTDelete is small: sizeof(SkAutoTDelete<T>) == sizeof(T*) |
| 111 */ | 111 */ |
| 112 template <typename T> class SkAutoTDelete : SkNoncopyable { | 112 template <typename T> class SkAutoTDelete : SkNoncopyable { |
| 113 public: | 113 public: |
| 114 SkAutoTDelete(T* obj = NULL) : fObj(obj) {} | 114 SkAutoTDelete(T* obj = NULL) : fObj(obj) {} |
| 115 ~SkAutoTDelete() { SkDELETE(fObj); } | 115 ~SkAutoTDelete() { SkDELETE(fObj); } |
| 116 | 116 |
| 117 T* get() const { return fObj; } | 117 T* get() const { return fObj; } |
| 118 operator T*() { return fObj; } |
| 118 T& operator*() const { SkASSERT(fObj); return *fObj; } | 119 T& operator*() const { SkASSERT(fObj); return *fObj; } |
| 119 T* operator->() const { SkASSERT(fObj); return fObj; } | 120 T* operator->() const { SkASSERT(fObj); return fObj; } |
| 120 | 121 |
| 121 void reset(T* obj) { | 122 void reset(T* obj) { |
| 122 if (fObj != obj) { | 123 if (fObj != obj) { |
| 123 SkDELETE(fObj); | 124 SkDELETE(fObj); |
| 124 fObj = obj; | 125 fObj = obj; |
| 125 } | 126 } |
| 126 } | 127 } |
| 127 | 128 |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 /** | 471 /** |
| 471 * Returns void* because this object does not initialize the | 472 * Returns void* because this object does not initialize the |
| 472 * memory. Use placement new for types that require a cons. | 473 * memory. Use placement new for types that require a cons. |
| 473 */ | 474 */ |
| 474 void* get() { return fStorage.get(); } | 475 void* get() { return fStorage.get(); } |
| 475 private: | 476 private: |
| 476 SkAlignedSStorage<sizeof(T)*N> fStorage; | 477 SkAlignedSStorage<sizeof(T)*N> fStorage; |
| 477 }; | 478 }; |
| 478 | 479 |
| 479 #endif | 480 #endif |
| OLD | NEW |