| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef SkTLazy_DEFINED | 8 #ifndef SkTLazy_DEFINED |
| 9 #define SkTLazy_DEFINED | 9 #define SkTLazy_DEFINED |
| 10 | 10 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 SkTLazy() : fPtr(NULL) {} | 22 SkTLazy() : fPtr(NULL) {} |
| 23 | 23 |
| 24 explicit SkTLazy(const T* src) : fPtr(NULL) { | 24 explicit SkTLazy(const T* src) : fPtr(NULL) { |
| 25 if (src) { | 25 if (src) { |
| 26 fPtr = new (fStorage.get()) T(*src); | 26 fPtr = new (fStorage.get()) T(*src); |
| 27 } | 27 } |
| 28 } | 28 } |
| 29 | 29 |
| 30 SkTLazy(const SkTLazy<T>& src) : fPtr(NULL) { | 30 SkTLazy(const SkTLazy<T>& src) : fPtr(NULL) { |
| 31 if (src.isValid()) { | 31 if (src.isValid()) { |
| 32 fPtr = new (fStorage.get()) T(*src->get()); | 32 fPtr = new (fStorage.get()) T(*src.get()); |
| 33 } else { | 33 } else { |
| 34 fPtr = NULL; | 34 fPtr = NULL; |
| 35 } | 35 } |
| 36 } | 36 } |
| 37 | 37 |
| 38 ~SkTLazy() { | 38 ~SkTLazy() { |
| 39 if (this->isValid()) { | 39 if (this->isValid()) { |
| 40 fPtr->~T(); | 40 fPtr->~T(); |
| 41 } | 41 } |
| 42 } | 42 } |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 operator const T*() const { return fObj; } | 164 operator const T*() const { return fObj; } |
| 165 | 165 |
| 166 const T& operator *() const { return *fObj; } | 166 const T& operator *() const { return *fObj; } |
| 167 | 167 |
| 168 private: | 168 private: |
| 169 const T* fObj; | 169 const T* fObj; |
| 170 SkTLazy<T> fLazy; | 170 SkTLazy<T> fLazy; |
| 171 }; | 171 }; |
| 172 | 172 |
| 173 #endif | 173 #endif |
| OLD | NEW |