OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
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 | 10 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 return fPtr; | 59 return fPtr; |
60 } | 60 } |
61 | 61 |
62 /** | 62 /** |
63 * Copy src into this, and return a pointer to a copy of it. Note this | 63 * Copy src into this, and return a pointer to a copy of it. Note this |
64 * will always return the same pointer, so if it is called on a lazy that | 64 * will always return the same pointer, so if it is called on a lazy that |
65 * has already been initialized, then this will copy over the previous | 65 * has already been initialized, then this will copy over the previous |
66 * contents. | 66 * contents. |
67 */ | 67 */ |
68 T* set(const T& src) { | 68 T* set(const T& src) { |
69 // Diagnoistic. May remove later. See crbug.com/364224 | |
70 if (NULL == &src) { | |
71 sk_throw(); | |
72 } | |
73 | |
74 if (this->isValid()) { | 69 if (this->isValid()) { |
75 *fPtr = src; | 70 *fPtr = src; |
76 } else { | 71 } else { |
77 fPtr = new (SkTCast<T*>(fStorage)) T(src); | 72 fPtr = new (SkTCast<T*>(fStorage)) T(src); |
78 } | 73 } |
79 return fPtr; | 74 return fPtr; |
80 } | 75 } |
81 | 76 |
82 /** | 77 /** |
83 * Destroy the lazy object (if it was created via init() or set()) | 78 * Destroy the lazy object (if it was created via init() or set()) |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 operator const T*() const { return fObj; } | 183 operator const T*() const { return fObj; } |
189 | 184 |
190 const T& operator *() const { return *fObj; } | 185 const T& operator *() const { return *fObj; } |
191 | 186 |
192 private: | 187 private: |
193 const T* fObj; | 188 const T* fObj; |
194 SkTLazy<T> fLazy; | 189 SkTLazy<T> fLazy; |
195 }; | 190 }; |
196 | 191 |
197 #endif | 192 #endif |
OLD | NEW |