Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(139)

Side by Side Diff: include/core/SkTLazy.h

Issue 2278633002: Fix SkTLazy(const T*) initialization (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698