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

Side by Side Diff: src/core/SkPath.cpp

Issue 22471002: Restore SkPath(const SkPath&) to copy the generation ID on Android. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: comments Created 7 years, 4 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
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2006 The Android Open Source Project 3 * Copyright 2006 The Android Open Source Project
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 #include "SkBuffer.h" 10 #include "SkBuffer.h"
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 fDirection = kUnknown_Direction; 178 fDirection = kUnknown_Direction;
179 fIsFinite = false; 179 fIsFinite = false;
180 fIsOval = false; 180 fIsOval = false;
181 #ifdef SK_BUILD_FOR_ANDROID 181 #ifdef SK_BUILD_FOR_ANDROID
182 GEN_ID_INC; 182 GEN_ID_INC;
183 fSourcePath = NULL; 183 fSourcePath = NULL;
184 #endif 184 #endif
185 } 185 }
186 186
187 SkPath::SkPath(const SkPath& that) 187 SkPath::SkPath(const SkPath& that)
188 : fPathRef(SkRef(that.fPathRef.get())) 188 : fPathRef(SkRef(that.fPathRef.get())) {
189 this->copyFields(that);
189 #ifdef SK_BUILD_FOR_ANDROID 190 #ifdef SK_BUILD_FOR_ANDROID
190 , fGenerationID(0) 191 fGenerationID = that.fGenerationID;
192 fSourcePath = NULL; // TODO(mtklein): follow up with Android: do we want to copy this too?
191 #endif 193 #endif
192 {
193 this->copyFields(that);
194 SkDEBUGCODE(that.validate();) 194 SkDEBUGCODE(that.validate();)
195 } 195 }
196 196
197 SkPath::~SkPath() { 197 SkPath::~SkPath() {
198 SkDEBUGCODE(this->validate();) 198 SkDEBUGCODE(this->validate();)
199 } 199 }
200 200
201 SkPath& SkPath::operator=(const SkPath& that) { 201 SkPath& SkPath::operator=(const SkPath& that) {
202 SkDEBUGCODE(that.validate();) 202 SkDEBUGCODE(that.validate();)
203 203
204 if (this != &that) { 204 if (this != &that) {
205 fPathRef.reset(SkRef(that.fPathRef.get())); 205 fPathRef.reset(SkRef(that.fPathRef.get()));
206 this->copyFields(that); 206 this->copyFields(that);
207 #ifdef SK_BUILD_FOR_ANDROID
208 GEN_ID_INC; // Similar to swap, we can't just copy this or it could go back in time.
209 fSourcePath = NULL; // TODO(mtklein): follow up with Android: do we wan t to copy this too?
210 #endif
207 } 211 }
208 SkDEBUGCODE(this->validate();) 212 SkDEBUGCODE(this->validate();)
209 return *this; 213 return *this;
210 } 214 }
211 215
212 void SkPath::copyFields(const SkPath& that) { 216 void SkPath::copyFields(const SkPath& that) {
213 //fPathRef is assumed to have been set by the caller. 217 //fPathRef is assumed to have been set by the caller.
214 fBounds = that.fBounds; 218 fBounds = that.fBounds;
215 fLastMoveToIndex = that.fLastMoveToIndex; 219 fLastMoveToIndex = that.fLastMoveToIndex;
216 fFillType = that.fFillType; 220 fFillType = that.fFillType;
217 fSegmentMask = that.fSegmentMask; 221 fSegmentMask = that.fSegmentMask;
218 fBoundsIsDirty = that.fBoundsIsDirty; 222 fBoundsIsDirty = that.fBoundsIsDirty;
219 fConvexity = that.fConvexity; 223 fConvexity = that.fConvexity;
220 fDirection = that.fDirection; 224 fDirection = that.fDirection;
221 fIsFinite = that.fIsFinite; 225 fIsFinite = that.fIsFinite;
222 fIsOval = that.fIsOval; 226 fIsOval = that.fIsOval;
223 #ifdef SK_BUILD_FOR_ANDROID
224 GEN_ID_INC;
225 fSourcePath = NULL;
226 #endif
227 } 227 }
228 228
229 SK_API bool operator==(const SkPath& a, const SkPath& b) { 229 SK_API bool operator==(const SkPath& a, const SkPath& b) {
230 // note: don't need to look at isConvex or bounds, since just comparing the 230 // note: don't need to look at isConvex or bounds, since just comparing the
231 // raw data is sufficient. 231 // raw data is sufficient.
232 232
233 // We explicitly check fSegmentMask as a quick-reject. We could skip it, 233 // We explicitly check fSegmentMask as a quick-reject. We could skip it,
234 // since it is only a cache of info in the fVerbs, but its a fast way to 234 // since it is only a cache of info in the fVerbs, but its a fast way to
235 // notice a difference 235 // notice a difference
236 236
237 return &a == &b || 237 return &a == &b ||
238 (a.fFillType == b.fFillType && a.fSegmentMask == b.fSegmentMask && 238 (a.fFillType == b.fFillType && a.fSegmentMask == b.fSegmentMask &&
239 *a.fPathRef.get() == *b.fPathRef.get()); 239 *a.fPathRef.get() == *b.fPathRef.get());
240 } 240 }
241 241
242 void SkPath::swap(SkPath& that) { 242 void SkPath::swap(SkPath& that) {
243 SkASSERT(&that != NULL); 243 SkASSERT(&that != NULL);
244 244
245 if (this != &that) { 245 if (this != &that) {
246 fPathRef.swap(&that.fPathRef); 246 fPathRef.swap(&that.fPathRef);
247 SkTSwap<SkRect>(fBounds, that.fBounds); 247 SkTSwap<SkRect>(fBounds, that.fBounds);
248 SkTSwap<int>(fLastMoveToIndex, that.fLastMoveToIndex); 248 SkTSwap<int>(fLastMoveToIndex, that.fLastMoveToIndex);
249 SkTSwap<uint8_t>(fFillType, that.fFillType); 249 SkTSwap<uint8_t>(fFillType, that.fFillType);
250 SkTSwap<uint8_t>(fSegmentMask, that.fSegmentMask); 250 SkTSwap<uint8_t>(fSegmentMask, that.fSegmentMask);
251 SkTSwap<uint8_t>(fBoundsIsDirty, that.fBoundsIsDirty); 251 SkTSwap<uint8_t>(fBoundsIsDirty, that.fBoundsIsDirty);
252 SkTSwap<uint8_t>(fConvexity, that.fConvexity); 252 SkTSwap<uint8_t>(fConvexity, that.fConvexity);
253 SkTSwap<uint8_t>(fDirection, that.fDirection); 253 SkTSwap<uint8_t>(fDirection, that.fDirection);
254 SkTSwap<SkBool8>(fIsFinite, that.fIsFinite); 254 SkTSwap<SkBool8>(fIsFinite, that.fIsFinite);
255 SkTSwap<SkBool8>(fIsOval, that.fIsOval); 255 SkTSwap<SkBool8>(fIsOval, that.fIsOval);
256 #ifdef SK_BUILD_FOR_ANDROID
257 // It doesn't really make sense to swap the generation IDs here, because they might go
258 // backwards. To be safe we increment both to mark them both as changed .
256 GEN_ID_INC; 259 GEN_ID_INC;
257 GEN_ID_PTR_INC(&that); 260 GEN_ID_PTR_INC(&that);
261 SkTSwap<SkPath*>(fSourcePath, that.fSourcePath);
262 #endif
258 } 263 }
259 } 264 }
260 265
261 static inline bool check_edge_against_rect(const SkPoint& p0, 266 static inline bool check_edge_against_rect(const SkPoint& p0,
262 const SkPoint& p1, 267 const SkPoint& p1,
263 const SkRect& rect, 268 const SkRect& rect,
264 SkPath::Direction dir) { 269 SkPath::Direction dir) {
265 const SkPoint* edgeBegin; 270 const SkPoint* edgeBegin;
266 SkVector v; 271 SkVector v;
267 if (SkPath::kCW_Direction == dir) { 272 if (SkPath::kCW_Direction == dir) {
(...skipping 2727 matching lines...) Expand 10 before | Expand all | Expand 10 after
2995 switch (this->getFillType()) { 3000 switch (this->getFillType()) {
2996 case SkPath::kEvenOdd_FillType: 3001 case SkPath::kEvenOdd_FillType:
2997 case SkPath::kInverseEvenOdd_FillType: 3002 case SkPath::kInverseEvenOdd_FillType:
2998 w &= 1; 3003 w &= 1;
2999 break; 3004 break;
3000 default: 3005 default:
3001 break; 3006 break;
3002 } 3007 }
3003 return SkToBool(w); 3008 return SkToBool(w);
3004 } 3009 }
OLDNEW
« include/core/SkPath.h ('K') | « include/core/SkPath.h ('k') | tests/PathTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698