diff options
-rw-r--r-- | include/core/SkPath.h | 3 | ||||
-rw-r--r-- | src/core/SkPath.cpp | 17 |
2 files changed, 20 insertions, 0 deletions
diff --git a/include/core/SkPath.h b/include/core/SkPath.h index 3afea09..eb5ff6d 100644 --- a/include/core/SkPath.h +++ b/include/core/SkPath.h @@ -571,6 +571,8 @@ public: */ void subdivide(SkScalar dist, bool bendLines, SkPath* dst = NULL) const; + uint32_t getGenerationID() const; + SkDEBUGCODE(void validate() const;) private: @@ -580,6 +582,7 @@ private: mutable uint8_t fBoundsIsDirty; uint8_t fFillType; uint8_t fIsConvex; + uint32_t fGenerationID; // called, if dirty, by getBounds() void computeBounds() const; diff --git a/src/core/SkPath.cpp b/src/core/SkPath.cpp index 9c0b8af..eb72a5c 100644 --- a/src/core/SkPath.cpp +++ b/src/core/SkPath.cpp @@ -97,6 +97,7 @@ static void compute_pt_bounds(SkRect* bounds, const SkTDArray<SkPoint>& pts) { SkPath::SkPath() : fBoundsIsDirty(true), fFillType(kWinding_FillType) { fIsConvex = false; + fGenerationID = 0; } SkPath::SkPath(const SkPath& src) { @@ -118,6 +119,7 @@ SkPath& SkPath::operator=(const SkPath& src) { fFillType = src.fFillType; fBoundsIsDirty = src.fBoundsIsDirty; fIsConvex = src.fIsConvex; + fGenerationID++; } SkDEBUGCODE(this->validate();) return *this; @@ -140,14 +142,20 @@ void SkPath::swap(SkPath& other) { SkTSwap<uint8_t>(fFillType, other.fFillType); SkTSwap<uint8_t>(fBoundsIsDirty, other.fBoundsIsDirty); SkTSwap<uint8_t>(fIsConvex, other.fIsConvex); + fGenerationID++; } } +uint32_t SkPath::getGenerationID() const { + return fGenerationID; +} + void SkPath::reset() { SkDEBUGCODE(this->validate();) fPts.reset(); fVerbs.reset(); + fGenerationID = 0; fBoundsIsDirty = true; } @@ -156,6 +164,7 @@ void SkPath::rewind() { fPts.rewind(); fVerbs.rewind(); + fGenerationID = 0; fBoundsIsDirty = true; } @@ -212,6 +221,7 @@ void SkPath::setLastPt(SkScalar x, SkScalar y) { this->moveTo(x, y); } else { fPts[count - 1].set(x, y); + fGenerationID++; } } @@ -249,6 +259,7 @@ void SkPath::moveTo(SkScalar x, SkScalar y) { } pt->set(x, y); + fGenerationID++; fBoundsIsDirty = true; } @@ -268,6 +279,7 @@ void SkPath::lineTo(SkScalar x, SkScalar y) { fPts.append()->set(x, y); *fVerbs.append() = kLine_Verb; + fGenerationID++; fBoundsIsDirty = true; } @@ -290,6 +302,7 @@ void SkPath::quadTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2) { pts[1].set(x2, y2); *fVerbs.append() = kQuad_Verb; + fGenerationID++; fBoundsIsDirty = true; } @@ -313,6 +326,7 @@ void SkPath::cubicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, pts[2].set(x3, y3); *fVerbs.append() = kCubic_Verb; + fGenerationID++; fBoundsIsDirty = true; } @@ -334,6 +348,7 @@ void SkPath::close() { case kQuad_Verb: case kCubic_Verb: *fVerbs.append() = kClose_Verb; + fGenerationID++; break; default: // don't add a close if the prev wasn't a primitive @@ -936,6 +951,7 @@ void SkPath::transform(const SkMatrix& matrix, SkPath* dst) const { matrix.mapRect(&dst->fBounds, fBounds); dst->fBoundsIsDirty = false; } else { + dst->fGenerationID++; dst->fBoundsIsDirty = true; } @@ -1243,6 +1259,7 @@ void SkPath::unflatten(SkFlattenableReadBuffer& buffer) { buffer.read(fPts.begin(), sizeof(SkPoint) * fPts.count()); buffer.read(fVerbs.begin(), fVerbs.count()); + fGenerationID++; fBoundsIsDirty = true; SkDEBUGCODE(this->validate();) |