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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 */ | 92 */ |
93 T* get() const { SkASSERT(this->isValid()); return fPtr; } | 93 T* get() const { SkASSERT(this->isValid()); return fPtr; } |
94 | 94 |
95 /** | 95 /** |
96 * Like above but doesn't assert if object isn't initialized (in which case | 96 * Like above but doesn't assert if object isn't initialized (in which case |
97 * nullptr is returned). | 97 * nullptr is returned). |
98 */ | 98 */ |
99 T* getMaybeNull() const { return fPtr; } | 99 T* getMaybeNull() const { return fPtr; } |
100 | 100 |
101 private: | 101 private: |
102 T* fPtr; // nullptr or fStorage | |
103 SkAlignedSTStorage<1, T> fStorage; | 102 SkAlignedSTStorage<1, T> fStorage; |
| 103 T* fPtr; // nullptr or fStorage |
104 }; | 104 }; |
105 | 105 |
106 /** | 106 /** |
107 * A helper built on top of SkTLazy to do copy-on-first-write. The object is ini
tialized | 107 * A helper built on top of SkTLazy to do copy-on-first-write. The object is ini
tialized |
108 * with a const pointer but provides a non-const pointer accessor. The first tim
e the | 108 * with a const pointer but provides a non-const pointer accessor. The first tim
e the |
109 * accessor is called (if ever) the object is cloned. | 109 * accessor is called (if ever) the object is cloned. |
110 * | 110 * |
111 * In the following example at most one copy of constThing is made: | 111 * In the following example at most one copy of constThing is made: |
112 * | 112 * |
113 * SkTCopyOnFirstWrite<Thing> thing(&constThing); | 113 * SkTCopyOnFirstWrite<Thing> thing(&constThing); |
(...skipping 50 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 |