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

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

Issue 178583002: Use SkTLazy to hold path in SkClipStack::Element (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: add comment Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « include/core/SkClipStack.h ('k') | src/core/SkClipStack.cpp » ('j') | 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 /* 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 T* set(const T& src) { 68 T* set(const T& src) {
69 if (this->isValid()) { 69 if (this->isValid()) {
70 *fPtr = src; 70 *fPtr = src;
71 } else { 71 } else {
72 fPtr = new (SkTCast<T*>(fStorage)) T(src); 72 fPtr = new (SkTCast<T*>(fStorage)) T(src);
73 } 73 }
74 return fPtr; 74 return fPtr;
75 } 75 }
76 76
77 /** 77 /**
78 * Destroy the lazy object (if it was created via init() or set())
79 */
80 void reset() {
81 if (this->isValid()) {
82 fPtr->~T();
83 fPtr = NULL;
84 }
85 }
86
87 /**
78 * Returns true if a valid object has been initialized in the SkTLazy, 88 * Returns true if a valid object has been initialized in the SkTLazy,
79 * false otherwise. 89 * false otherwise.
80 */ 90 */
81 bool isValid() const { return NULL != fPtr; } 91 bool isValid() const { return NULL != fPtr; }
82 92
83 /** 93 /**
84 * Returns the object. This version should only be called when the caller 94 * Returns the object. This version should only be called when the caller
85 * knows that the object has been initialized. 95 * knows that the object has been initialized.
86 */ 96 */
87 T* get() const { SkASSERT(this->isValid()); return fPtr; } 97 T* get() const { SkASSERT(this->isValid()); return fPtr; }
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 operator const T*() const { return fObj; } 183 operator const T*() const { return fObj; }
174 184
175 const T& operator *() const { return *fObj; } 185 const T& operator *() const { return *fObj; }
176 186
177 private: 187 private:
178 const T* fObj; 188 const T* fObj;
179 SkTLazy<T> fLazy; 189 SkTLazy<T> fLazy;
180 }; 190 };
181 191
182 #endif 192 #endif
OLDNEW
« no previous file with comments | « include/core/SkClipStack.h ('k') | src/core/SkClipStack.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698