OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 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 #ifndef SkPathRef_DEFINED | 9 #ifndef SkPathRef_DEFINED |
10 #define SkPathRef_DEFINED | 10 #define SkPathRef_DEFINED |
11 | 11 |
12 #include "SkDynamicAnnotations.h" | |
13 #include "SkMatrix.h" | 12 #include "SkMatrix.h" |
14 #include "SkPoint.h" | 13 #include "SkPoint.h" |
15 #include "SkRect.h" | 14 #include "SkRect.h" |
16 #include "SkRefCnt.h" | 15 #include "SkRefCnt.h" |
17 #include "SkTDArray.h" | 16 #include "SkTDArray.h" |
18 #include <stddef.h> // ptrdiff_t | 17 #include <stddef.h> // ptrdiff_t |
19 | 18 |
20 class SkRBuffer; | 19 class SkRBuffer; |
21 class SkWBuffer; | 20 class SkWBuffer; |
22 | 21 |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 } else { | 285 } else { |
287 return bounds->setBoundsCheck(ref.points(), count); | 286 return bounds->setBoundsCheck(ref.points(), count); |
288 } | 287 } |
289 } | 288 } |
290 | 289 |
291 // called, if dirty, by getBounds() | 290 // called, if dirty, by getBounds() |
292 void computeBounds() const { | 291 void computeBounds() const { |
293 SkDEBUGCODE(this->validate();) | 292 SkDEBUGCODE(this->validate();) |
294 // TODO(mtklein): remove fBoundsIsDirty and fIsFinite, | 293 // TODO(mtklein): remove fBoundsIsDirty and fIsFinite, |
295 // using an inverted rect instead of fBoundsIsDirty and always recalcula
ting fIsFinite. | 294 // using an inverted rect instead of fBoundsIsDirty and always recalcula
ting fIsFinite. |
296 //SkASSERT(fBoundsIsDirty); | 295 SkASSERT(fBoundsIsDirty); |
297 | 296 |
298 fIsFinite = ComputePtBounds(fBounds.get(), *this); | 297 fIsFinite = ComputePtBounds(&fBounds, *this); |
299 fBoundsIsDirty = false; | 298 fBoundsIsDirty = false; |
300 } | 299 } |
301 | 300 |
302 void setBounds(const SkRect& rect) { | 301 void setBounds(const SkRect& rect) { |
303 SkASSERT(rect.fLeft <= rect.fRight && rect.fTop <= rect.fBottom); | 302 SkASSERT(rect.fLeft <= rect.fRight && rect.fTop <= rect.fBottom); |
304 fBounds = rect; | 303 fBounds = rect; |
305 fBoundsIsDirty = false; | 304 fBoundsIsDirty = false; |
306 fIsFinite = fBounds->isFinite(); | 305 fIsFinite = fBounds.isFinite(); |
307 } | 306 } |
308 | 307 |
309 /** Makes additional room but does not change the counts or change the genID
*/ | 308 /** Makes additional room but does not change the counts or change the genID
*/ |
310 void incReserve(int additionalVerbs, int additionalPoints) { | 309 void incReserve(int additionalVerbs, int additionalPoints) { |
311 SkDEBUGCODE(this->validate();) | 310 SkDEBUGCODE(this->validate();) |
312 size_t space = additionalVerbs * sizeof(uint8_t) + additionalPoints * si
zeof (SkPoint); | 311 size_t space = additionalVerbs * sizeof(uint8_t) + additionalPoints * si
zeof (SkPoint); |
313 this->makeSpace(space); | 312 this->makeSpace(space); |
314 SkDEBUGCODE(this->validate();) | 313 SkDEBUGCODE(this->validate();) |
315 } | 314 } |
316 | 315 |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 SkPoint* getPoints() { | 427 SkPoint* getPoints() { |
429 SkDEBUGCODE(this->validate();) | 428 SkDEBUGCODE(this->validate();) |
430 fIsOval = false; | 429 fIsOval = false; |
431 return fPoints; | 430 return fPoints; |
432 } | 431 } |
433 | 432 |
434 enum { | 433 enum { |
435 kMinSize = 256, | 434 kMinSize = 256, |
436 }; | 435 }; |
437 | 436 |
438 mutable SkTRacyReffable<SkRect> fBounds; | 437 mutable SkRect fBounds; |
439 mutable SkTRacy<uint8_t> fBoundsIsDirty; | 438 mutable uint8_t fBoundsIsDirty; |
440 mutable SkTRacy<SkBool8> fIsFinite; // only meaningful if bounds a
re valid | 439 mutable SkBool8 fIsFinite; // only meaningful if bounds are valid |
441 | 440 |
442 SkBool8 fIsOval; | 441 SkBool8 fIsOval; |
443 uint8_t fSegmentMask; | 442 uint8_t fSegmentMask; |
444 | 443 |
445 SkPoint* fPoints; // points to begining of the allocation | 444 SkPoint* fPoints; // points to begining of the allocation |
446 uint8_t* fVerbs; // points just past the end of the allocation (v
erbs grow backwards) | 445 uint8_t* fVerbs; // points just past the end of the allocation (v
erbs grow backwards) |
447 int fVerbCnt; | 446 int fVerbCnt; |
448 int fPointCnt; | 447 int fPointCnt; |
449 size_t fFreeSpace; // redundant but saves computation | 448 size_t fFreeSpace; // redundant but saves computation |
450 SkTDArray<SkScalar> fConicWeights; | 449 SkTDArray<SkScalar> fConicWeights; |
451 | 450 |
452 enum { | 451 enum { |
453 kEmptyGenID = 1, // GenID reserved for path ref with zero points and zer
o verbs. | 452 kEmptyGenID = 1, // GenID reserved for path ref with zero points and zer
o verbs. |
454 }; | 453 }; |
455 mutable uint32_t fGenerationID; | 454 mutable uint32_t fGenerationID; |
456 SkDEBUGCODE(int32_t fEditorsAttached;) // assert that only one editor in use
at any time. | 455 SkDEBUGCODE(int32_t fEditorsAttached;) // assert that only one editor in use
at any time. |
457 | 456 |
458 friend class PathRefTest_Private; | 457 friend class PathRefTest_Private; |
459 typedef SkRefCnt INHERITED; | 458 typedef SkRefCnt INHERITED; |
460 }; | 459 }; |
461 | 460 |
462 #endif | 461 #endif |
OLD | NEW |