OLD | NEW |
---|---|
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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
212 | 212 |
213 // flag to require a moveTo if we begin with something else, like lineTo etc. | 213 // flag to require a moveTo if we begin with something else, like lineTo etc. |
214 #define INITIAL_LASTMOVETOINDEX_VALUE ~0 | 214 #define INITIAL_LASTMOVETOINDEX_VALUE ~0 |
215 | 215 |
216 SkPath::SkPath() | 216 SkPath::SkPath() |
217 #if SK_DEBUG_PATH_REF | 217 #if SK_DEBUG_PATH_REF |
218 : fPathRef(SkPathRef::CreateEmpty(), this) | 218 : fPathRef(SkPathRef::CreateEmpty(), this) |
219 #else | 219 #else |
220 : fPathRef(SkPathRef::CreateEmpty()) | 220 : fPathRef(SkPathRef::CreateEmpty()) |
221 #endif | 221 #endif |
222 , fLastMoveToIndex(INITIAL_LASTMOVETOINDEX_VALUE) | |
reed1
2013/06/19 17:36:49
why not have the constructor also call resetFields
bungeman-skia
2013/06/19 19:59:48
Done.
| |
222 , fFillType(kWinding_FillType) | 223 , fFillType(kWinding_FillType) |
223 , fBoundsIsDirty(true) { | 224 , fSegmentMask(0) |
225 , fBoundsIsDirty(true) | |
226 , fConvexity(kUnknown_Convexity) | |
227 , fDirection(kUnknown_Direction) | |
228 , fIsFinite(false) // gets computed when we know our bounds | |
229 , fIsOval(false) | |
230 #ifdef SK_BUILD_FOR_ANDROID | |
231 , fGenerationID(0) | |
232 , fSourcePath(NULL) | |
233 #endif | |
234 { } | |
235 | |
caryclark
2013/06/19 17:38:21
could this be
#ifdef SK_BUILD_FOR_ANDROID
, fG
bungeman-skia
2013/06/19 19:59:48
Done.
| |
236 void SkPath::resetFields() { | |
237 //fPathRef is assumed to have been emptied by the caller. | |
238 fLastMoveToIndex = INITIAL_LASTMOVETOINDEX_VALUE; | |
239 fFillType = kWinding_FillType; | |
240 fSegmentMask = 0; | |
241 fBoundsIsDirty = true; | |
224 fConvexity = kUnknown_Convexity; | 242 fConvexity = kUnknown_Convexity; |
225 fDirection = kUnknown_Direction; | 243 fDirection = kUnknown_Direction; |
226 fSegmentMask = 0; | 244 fIsFinite = false; |
227 fLastMoveToIndex = INITIAL_LASTMOVETOINDEX_VALUE; | |
228 fIsOval = false; | 245 fIsOval = false; |
229 fIsFinite = false; // gets computed when we know our bounds | |
230 #ifdef SK_BUILD_FOR_ANDROID | 246 #ifdef SK_BUILD_FOR_ANDROID |
231 fGenerationID = 0; | 247 GEN_ID_INC; |
232 fSourcePath = NULL; | 248 fSourcePath = NULL; |
233 #endif | 249 #endif |
234 } | 250 } |
235 | 251 |
236 SkPath::SkPath(const SkPath& src) | 252 SkPath::SkPath(const SkPath& src) |
237 #if SK_DEBUG_PATH_REF | 253 #if SK_DEBUG_PATH_REF |
238 : fPathRef(this) | 254 : fPathRef(this) |
255 #else | |
256 : fPathRef(SkRef(src.fPathRef.get())) | |
257 #endif | |
258 , fBounds(src.fBounds) | |
259 , fLastMoveToIndex(src.fLastMoveToIndex) | |
260 , fFillType(src.fFillType) | |
261 , fSegmentMask(src.fSegmentMask) | |
262 , fBoundsIsDirty(src.fBoundsIsDirty) | |
263 , fConvexity(src.fConvexity) | |
264 , fDirection(src.fDirection) | |
265 , fIsFinite(src.fIsFinite) | |
266 , fIsOval(src.fIsOval) | |
267 #ifdef SK_BUILD_FOR_ANDROID | |
268 , fGenerationID(src.fGenerationID) | |
269 , fSourcePath(NULL) | |
239 #endif | 270 #endif |
240 { | 271 { |
241 SkDEBUGCODE(src.validate();) | 272 SkDEBUGCODE(src.validate();) |
242 src.fPathRef.get()->ref(); | |
243 fPathRef.reset(src.fPathRef.get()); | |
244 fBounds = src.fBounds; | |
245 fFillType = src.fFillType; | |
246 fBoundsIsDirty = src.fBoundsIsDirty; | |
247 fConvexity = src.fConvexity; | |
248 fDirection = src.fDirection; | |
249 fIsFinite = src.fIsFinite; | |
250 fSegmentMask = src.fSegmentMask; | |
251 fLastMoveToIndex = src.fLastMoveToIndex; | |
252 fIsOval = src.fIsOval; | |
253 #ifdef SK_BUILD_FOR_ANDROID | |
254 fGenerationID = src.fGenerationID; | |
255 fSourcePath = NULL; | |
256 #endif | |
257 } | 273 } |
258 | 274 |
259 SkPath::~SkPath() { | 275 SkPath::~SkPath() { |
260 SkDEBUGCODE(this->validate();) | 276 SkDEBUGCODE(this->validate();) |
261 } | 277 } |
262 | 278 |
263 SkPath& SkPath::operator=(const SkPath& src) { | 279 SkPath& SkPath::operator=(const SkPath& src) { |
264 SkDEBUGCODE(src.validate();) | 280 SkDEBUGCODE(src.validate();) |
265 | 281 |
266 if (this != &src) { | 282 if (this != &src) { |
267 src.fPathRef.get()->ref(); | 283 fPathRef.reset(SkRef(src.fPathRef.get())); |
268 fPathRef.reset(src.fPathRef.get()); | 284 fBounds = src.fBounds; |
269 fBounds = src.fBounds; | |
270 fFillType = src.fFillType; | |
271 fBoundsIsDirty = src.fBoundsIsDirty; | |
272 fConvexity = src.fConvexity; | |
273 fDirection = src.fDirection; | |
274 fIsFinite = src.fIsFinite; | |
275 fSegmentMask = src.fSegmentMask; | |
276 fLastMoveToIndex = src.fLastMoveToIndex; | 285 fLastMoveToIndex = src.fLastMoveToIndex; |
277 fIsOval = src.fIsOval; | 286 fFillType = src.fFillType; |
287 fSegmentMask = src.fSegmentMask; | |
288 fBoundsIsDirty = src.fBoundsIsDirty; | |
289 fConvexity = src.fConvexity; | |
290 fDirection = src.fDirection; | |
291 fIsFinite = src.fIsFinite; | |
292 fIsOval = src.fIsOval; | |
293 #ifdef SK_BUILD_FOR_ANDROID | |
278 GEN_ID_INC; | 294 GEN_ID_INC; |
295 fSourcePath = NULL; | |
296 #endif | |
279 } | 297 } |
280 SkDEBUGCODE(this->validate();) | 298 SkDEBUGCODE(this->validate();) |
281 return *this; | 299 return *this; |
282 } | 300 } |
283 | 301 |
284 SK_API bool operator==(const SkPath& a, const SkPath& b) { | 302 SK_API bool operator==(const SkPath& a, const SkPath& b) { |
285 // note: don't need to look at isConvex or bounds, since just comparing the | 303 // note: don't need to look at isConvex or bounds, since just comparing the |
286 // raw data is sufficient. | 304 // raw data is sufficient. |
287 | 305 |
288 // We explicitly check fSegmentMask as a quick-reject. We could skip it, | 306 // We explicitly check fSegmentMask as a quick-reject. We could skip it, |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
404 | 422 |
405 void SkPath::setSourcePath(const SkPath* path) { | 423 void SkPath::setSourcePath(const SkPath* path) { |
406 fSourcePath = path; | 424 fSourcePath = path; |
407 } | 425 } |
408 #endif | 426 #endif |
409 | 427 |
410 void SkPath::reset() { | 428 void SkPath::reset() { |
411 SkDEBUGCODE(this->validate();) | 429 SkDEBUGCODE(this->validate();) |
412 | 430 |
413 fPathRef.reset(SkPathRef::CreateEmpty()); | 431 fPathRef.reset(SkPathRef::CreateEmpty()); |
414 GEN_ID_INC; | 432 this->resetFields(); |
415 fBoundsIsDirty = true; | |
416 fConvexity = kUnknown_Convexity; | |
417 fDirection = kUnknown_Direction; | |
418 fSegmentMask = 0; | |
419 fLastMoveToIndex = INITIAL_LASTMOVETOINDEX_VALUE; | |
420 fIsOval = false; | |
421 } | 433 } |
422 | 434 |
423 void SkPath::rewind() { | 435 void SkPath::rewind() { |
424 SkDEBUGCODE(this->validate();) | 436 SkDEBUGCODE(this->validate();) |
425 | 437 |
426 SkPathRef::Rewind(&fPathRef); | 438 SkPathRef::Rewind(&fPathRef); |
427 GEN_ID_INC; | 439 this->resetFields(); |
428 fConvexity = kUnknown_Convexity; | |
429 fBoundsIsDirty = true; | |
430 fSegmentMask = 0; | |
431 fLastMoveToIndex = INITIAL_LASTMOVETOINDEX_VALUE; | |
432 fIsOval = false; | |
433 } | 440 } |
434 | 441 |
435 bool SkPath::isEmpty() const { | 442 bool SkPath::isEmpty() const { |
436 SkDEBUGCODE(this->validate();) | 443 SkDEBUGCODE(this->validate();) |
437 return 0 == fPathRef->countVerbs(); | 444 return 0 == fPathRef->countVerbs(); |
438 } | 445 } |
439 | 446 |
440 bool SkPath::isLine(SkPoint line[2]) const { | 447 bool SkPath::isLine(SkPoint line[2]) const { |
441 int verbCount = fPathRef->countVerbs(); | 448 int verbCount = fPathRef->countVerbs(); |
442 int ptCount = fPathRef->countVerbs(); | 449 int ptCount = fPathRef->countVerbs(); |
(...skipping 2612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3055 switch (this->getFillType()) { | 3062 switch (this->getFillType()) { |
3056 case SkPath::kEvenOdd_FillType: | 3063 case SkPath::kEvenOdd_FillType: |
3057 case SkPath::kInverseEvenOdd_FillType: | 3064 case SkPath::kInverseEvenOdd_FillType: |
3058 w &= 1; | 3065 w &= 1; |
3059 break; | 3066 break; |
3060 default: | 3067 default: |
3061 break; | 3068 break; |
3062 } | 3069 } |
3063 return SkToBool(w); | 3070 return SkToBool(w); |
3064 } | 3071 } |
OLD | NEW |