Chromium Code Reviews| Index: src/core/SkPath.cpp |
| diff --git a/src/core/SkPath.cpp b/src/core/SkPath.cpp |
| index 9df62850fd2eb5bc9cf442dc4675b7091cded8c1..b70fb4bf578f766a0cdfe1ebea8a9347e1717a3a 100644 |
| --- a/src/core/SkPath.cpp |
| +++ b/src/core/SkPath.cpp |
| @@ -147,7 +147,7 @@ private: |
| SkPath::SkPath() |
| : fPathRef(SkPathRef::CreateEmpty()) |
| #ifdef SK_BUILD_FOR_ANDROID |
| - , fGenerationID(0) |
| + , fSourcePath(NULL) |
|
mtklein
2013/10/29 20:38:36
Nice catch.
|
| #endif |
| { |
| this->resetFields(); |
| @@ -161,18 +161,15 @@ void SkPath::resetFields() { |
| fConvexity = kUnknown_Convexity; |
| fDirection = kUnknown_Direction; |
| fIsOval = false; |
| -#ifdef SK_BUILD_FOR_ANDROID |
| - GEN_ID_INC; |
| - // We don't touch fSourcePath. It's used to track texture garbage collection, so we don't |
| - // want to muck with it if it's been set to something non-NULL. |
| -#endif |
| + |
| + // We don't touch Android's fSourcePath. It's used to track texture garbage collection, so we |
| + // don't want to muck with it if it's been set to something non-NULL. |
| } |
| SkPath::SkPath(const SkPath& that) |
| : fPathRef(SkRef(that.fPathRef.get())) { |
| this->copyFields(that); |
| #ifdef SK_BUILD_FOR_ANDROID |
| - fGenerationID = that.fGenerationID; |
| fSourcePath = that.fSourcePath; |
| #endif |
| SkDEBUGCODE(that.validate();) |
| @@ -189,7 +186,6 @@ SkPath& SkPath::operator=(const SkPath& that) { |
| fPathRef.reset(SkRef(that.fPathRef.get())); |
| this->copyFields(that); |
| #ifdef SK_BUILD_FOR_ANDROID |
| - GEN_ID_INC; // Similar to swap, we can't just copy this or it could go back in time. |
| fSourcePath = that.fSourcePath; |
| #endif |
| } |
| @@ -232,10 +228,6 @@ void SkPath::swap(SkPath& that) { |
| SkTSwap<uint8_t>(fDirection, that.fDirection); |
| SkTSwap<SkBool8>(fIsOval, that.fIsOval); |
| #ifdef SK_BUILD_FOR_ANDROID |
| - // It doesn't really make sense to swap the generation IDs here, because they might go |
| - // backwards. To be safe we increment both to mark them both as changed. |
| - GEN_ID_INC; |
| - GEN_ID_PTR_INC(&that); |
| SkTSwap<const SkPath*>(fSourcePath, that.fSourcePath); |
| #endif |
| } |
| @@ -328,11 +320,16 @@ bool SkPath::conservativelyContainsRect(const SkRect& rect) const { |
| return check_edge_against_rect(prevPt, firstPt, rect, direction); |
| } |
| -#ifdef SK_BUILD_FOR_ANDROID |
| uint32_t SkPath::getGenerationID() const { |
| - return fGenerationID; |
| + uint32_t genID = fPathRef->genID(); |
| +#ifdef SK_BUILD_FOR_ANDROID |
| + SkASSERT((unsigned)fFillType < (32 - kPathRefGenIDBitCnt)); |
|
mtklein
2013/10/29 20:38:36
Comparing values vs bitcounts? I think we need 1<
bsalomon
2013/10/29 20:45:04
d'oh, yes.
|
| + genID |= static_cast<uint32_t>(fFillType) << kPathRefGenIDBitCnt; |
| +#endif |
| + return genID; |
| } |
| +#ifdef SK_BUILD_FOR_ANDROID |
| const SkPath* SkPath::getSourcePath() const { |
| return fSourcePath; |
| } |
| @@ -633,14 +630,12 @@ void SkPath::setLastPt(SkScalar x, SkScalar y) { |
| fIsOval = false; |
| SkPathRef::Editor ed(&fPathRef); |
| ed.atPoint(count-1)->set(x, y); |
| - GEN_ID_INC; |
| } |
| } |
| void SkPath::setConvexity(Convexity c) { |
| if (fConvexity != c) { |
| fConvexity = c; |
| - GEN_ID_INC; |
| } |
| } |
| @@ -669,8 +664,6 @@ void SkPath::moveTo(SkScalar x, SkScalar y) { |
| fLastMoveToIndex = ed.pathRef()->countPoints(); |
| ed.growForVerb(kMove_Verb)->set(x, y); |
| - |
| - GEN_ID_INC; |
| } |
| void SkPath::rMoveTo(SkScalar x, SkScalar y) { |
| @@ -702,7 +695,6 @@ void SkPath::lineTo(SkScalar x, SkScalar y) { |
| ed.growForVerb(kLine_Verb)->set(x, y); |
| fSegmentMask |= kLine_SegmentMask; |
| - GEN_ID_INC; |
| DIRTY_AFTER_EDIT; |
| } |
| @@ -724,7 +716,6 @@ void SkPath::quadTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2) { |
| pts[1].set(x2, y2); |
| fSegmentMask |= kQuad_SegmentMask; |
| - GEN_ID_INC; |
| DIRTY_AFTER_EDIT; |
| } |
| @@ -756,7 +747,6 @@ void SkPath::conicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, |
| pts[1].set(x2, y2); |
| fSegmentMask |= kConic_SegmentMask; |
| - GEN_ID_INC; |
| DIRTY_AFTER_EDIT; |
| } |
| } |
| @@ -782,7 +772,6 @@ void SkPath::cubicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, |
| pts[2].set(x3, y3); |
| fSegmentMask |= kCubic_SegmentMask; |
| - GEN_ID_INC; |
| DIRTY_AFTER_EDIT; |
| } |
| @@ -808,7 +797,6 @@ void SkPath::close() { |
| case kMove_Verb: { |
| SkPathRef::Editor ed(&fPathRef); |
| ed.growForVerb(kClose_Verb); |
| - GEN_ID_INC; |
| break; |
| } |
| case kClose_Verb: |
| @@ -894,7 +882,6 @@ void SkPath::addPoly(const SkPoint pts[], int count, bool close) { |
| vb[~count] = kClose_Verb; |
| } |
| - GEN_ID_INC; |
| DIRTY_AFTER_EDIT; |
| SkDEBUGCODE(this->validate();) |
| } |
| @@ -1720,12 +1707,6 @@ void SkPath::transform(const SkMatrix& matrix, SkPath* dst) const { |
| dst->fConvexity = fConvexity; |
| } |
| -#ifdef SK_BUILD_FOR_ANDROID |
| - if (!matrix.isIdentity() && !dst->hasComputedBounds()) { |
| - GEN_ID_PTR_INC(dst); |
| - } |
| -#endif |
| - |
| if (kUnknown_Direction == fDirection) { |
| dst->fDirection = kUnknown_Direction; |
| } else { |
| @@ -2134,8 +2115,6 @@ uint32_t SkPath::readFromMemory(const void* storage) { |
| buffer.skipToAlign4(); |
| - GEN_ID_INC; |
| - |
| SkDEBUGCODE(this->validate();) |
| return SkToU32(buffer.pos()); |
| } |