| 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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 | 163 |
| 164 private: | 164 private: |
| 165 T* fObj; | 165 T* fObj; |
| 166 }; | 166 }; |
| 167 | 167 |
| 168 // Calls ~T() in the destructor. | 168 // Calls ~T() in the destructor. |
| 169 template <typename T> class SkAutoTDestroy : SkNoncopyable { | 169 template <typename T> class SkAutoTDestroy : SkNoncopyable { |
| 170 public: | 170 public: |
| 171 SkAutoTDestroy(T* obj = NULL) : fObj(obj) {} | 171 SkAutoTDestroy(T* obj = NULL) : fObj(obj) {} |
| 172 ~SkAutoTDestroy() { | 172 ~SkAutoTDestroy() { |
| 173 if (NULL != fObj) { | 173 if (fObj) { |
| 174 fObj->~T(); | 174 fObj->~T(); |
| 175 } | 175 } |
| 176 } | 176 } |
| 177 | 177 |
| 178 T* get() const { return fObj; } | 178 T* get() const { return fObj; } |
| 179 T& operator*() const { SkASSERT(fObj); return *fObj; } | 179 T& operator*() const { SkASSERT(fObj); return *fObj; } |
| 180 T* operator->() const { SkASSERT(fObj); return fObj; } | 180 T* operator->() const { SkASSERT(fObj); return fObj; } |
| 181 | 181 |
| 182 private: | 182 private: |
| 183 T* fObj; | 183 T* fObj; |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 /** | 483 /** |
| 484 * Returns void* because this object does not initialize the | 484 * Returns void* because this object does not initialize the |
| 485 * memory. Use placement new for types that require a cons. | 485 * memory. Use placement new for types that require a cons. |
| 486 */ | 486 */ |
| 487 void* get() { return fStorage.get(); } | 487 void* get() { return fStorage.get(); } |
| 488 private: | 488 private: |
| 489 SkAlignedSStorage<sizeof(T)*N> fStorage; | 489 SkAlignedSStorage<sizeof(T)*N> fStorage; |
| 490 }; | 490 }; |
| 491 | 491 |
| 492 #endif | 492 #endif |
| OLD | NEW |