| 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 template <typename T> class SkAutoTDelete : public std::unique_ptr<T> { | 94 template <typename T> class SkAutoTDelete : public std::unique_ptr<T> { |
| 95 public: | 95 public: |
| 96 SkAutoTDelete(T* obj = NULL) : std::unique_ptr<T>(obj) {} | 96 SkAutoTDelete(T* obj = NULL) : std::unique_ptr<T>(obj) {} |
| 97 | 97 |
| 98 operator T*() const { return this->get(); } | 98 operator T*() const { return this->get(); } |
| 99 | 99 |
| 100 #if defined(SK_BUILD_FOR_ANDROID_FRAMEWORK) | 100 #if defined(SK_BUILD_FOR_ANDROID_FRAMEWORK) |
| 101 // Need to update graphics/BitmapRegionDecoder.cpp. | 101 // Need to update graphics/BitmapRegionDecoder.cpp. |
| 102 T* detach() { return this->release(); } | 102 T* detach() { return this->release(); } |
| 103 #endif | 103 #endif |
| 104 | |
| 105 // See SkAutoTUnref for why we do this. | |
| 106 explicit operator bool() const { return this->get() != nullptr; } | |
| 107 }; | 104 }; |
| 108 | 105 |
| 109 template <typename T> class SkAutoTDeleteArray : public std::unique_ptr<T[]> { | 106 template <typename T> class SkAutoTDeleteArray : public std::unique_ptr<T[]> { |
| 110 public: | 107 public: |
| 111 SkAutoTDeleteArray(T array[]) : std::unique_ptr<T[]>(array) {} | 108 SkAutoTDeleteArray(T array[]) : std::unique_ptr<T[]>(array) {} |
| 112 }; | 109 }; |
| 113 | 110 |
| 114 /** Allocate an array of T elements, and free the array in the destructor | 111 /** Allocate an array of T elements, and free the array in the destructor |
| 115 */ | 112 */ |
| 116 template <typename T> class SkAutoTArray : SkNoncopyable { | 113 template <typename T> class SkAutoTArray : SkNoncopyable { |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 467 * Returns void* because this object does not initialize the | 464 * Returns void* because this object does not initialize the |
| 468 * memory. Use placement new for types that require a cons. | 465 * memory. Use placement new for types that require a cons. |
| 469 */ | 466 */ |
| 470 void* get() { return fStorage.get(); } | 467 void* get() { return fStorage.get(); } |
| 471 const void* get() const { return fStorage.get(); } | 468 const void* get() const { return fStorage.get(); } |
| 472 private: | 469 private: |
| 473 SkAlignedSStorage<sizeof(T)*N> fStorage; | 470 SkAlignedSStorage<sizeof(T)*N> fStorage; |
| 474 }; | 471 }; |
| 475 | 472 |
| 476 #endif | 473 #endif |
| OLD | NEW |