Chromium Code Reviews| Index: src/pathops/SkOpSegment.cpp |
| diff --git a/src/pathops/SkOpSegment.cpp b/src/pathops/SkOpSegment.cpp |
| index 5b2074995734ecccc454b77f6ecb9bb09fb486fa..6b7003e3e4c29587e6f6061509fb38845a3a0a75 100644 |
| --- a/src/pathops/SkOpSegment.cpp |
| +++ b/src/pathops/SkOpSegment.cpp |
| @@ -1082,9 +1082,10 @@ bool SkOpSegment::bumpSpan(SkOpSpan* span, int windDelta, int oppDelta) { |
| // look to see if the curve end intersects an intermediary that intersects the other |
| void SkOpSegment::checkEnds() { |
| -#if 1 |
| +#if 0 |
| return; // FIXME: suspect we will need the code below to make intersections consistent |
| #else |
| + debugValidate(); |
| SkTDArray<SkOpSpan> missingSpans; |
| int count = fTs.count(); |
| for (int index = 0; index < count; ++index) { |
| @@ -1150,13 +1151,20 @@ nextPeeker: |
| ; |
| } |
| int missingCount = missingSpans.count(); |
| + if (missingCount == 0) { |
| + return; |
| + } |
| + debugValidate(); |
| for (int index = 0; index < missingCount; ++index) { |
| const SkOpSpan& missing = missingSpans[index]; |
| addTPair(missing.fT, missing.fOther, missing.fOtherT, false, missing.fPt); |
| } |
| - if (missingCount > 0) { |
| - fixOtherTIndex(); |
| + fixOtherTIndex(); |
| + for (int index = 0; index < missingCount; ++index) { |
| + const SkOpSpan& missing = missingSpans[index]; |
| + missing.fOther->fixOtherTIndex(); |
| } |
| + debugValidate(); |
| #endif |
| } |
| @@ -1792,13 +1800,16 @@ void SkOpSegment::fixOtherTIndex() { |
| double oT = iSpan.fOtherT; |
| SkOpSegment* other = iSpan.fOther; |
| int oCount = other->fTs.count(); |
| + SkDEBUGCODE(iSpan.fOtherIndex = -1); |
| for (int o = 0; o < oCount; ++o) { |
| SkOpSpan& oSpan = other->fTs[o]; |
| if (oT == oSpan.fT && this == oSpan.fOther && oSpan.fOtherT == iSpan.fT) { |
| iSpan.fOtherIndex = o; |
| + oSpan.fOtherIndex = i; |
| break; |
| } |
| } |
| + SkASSERT(iSpan.fOtherIndex >= 0); |
| } |
| } |
| @@ -2755,6 +2766,7 @@ void SkOpSegment::debugShowTs() const { |
| #if DEBUG_ACTIVE_SPANS || DEBUG_ACTIVE_SPANS_FIRST_ONLY |
| void SkOpSegment::debugShowActiveSpans() const { |
| + debugValidate(); |
| if (done()) { |
| return; |
| } |
| @@ -2763,8 +2775,6 @@ void SkOpSegment::debugShowActiveSpans() const { |
| double lastT = -1; |
| #endif |
| for (int i = 0; i < fTs.count(); ++i) { |
| - SkASSERT(&fTs[i] == &fTs[i].fOther->fTs[fTs[i].fOtherIndex].fOther-> |
| - fTs[fTs[i].fOther->fTs[fTs[i].fOtherIndex].fOtherIndex]); |
| if (fTs[i].fDone) { |
| continue; |
| } |
| @@ -2995,3 +3005,27 @@ int SkOpSegment::debugShowWindingValues(int slotCount, int ofInterest) const { |
| return sum; |
| } |
| #endif |
| + |
| +void SkOpSegment::debugValidate() const { |
| +#if SK_DEBUG |
|
fmalita_google_do_not_use
2013/07/18 18:31:28
When building Chrome, I had to change this to #ifd
|
| + int count = fTs.count(); |
| + SkASSERT(count >= 2); |
| + SkASSERT(fTs[0].fT == 0); |
| + SkASSERT(fTs[count - 1].fT == 1); |
| + int done = 0; |
| + double t = -1; |
| + for (int i = 0; i < count; ++i) { |
| + const SkOpSpan& span = fTs[i]; |
| + SkASSERT(t <= span.fT); |
| + t = span.fT; |
| + int otherIndex = span.fOtherIndex; |
| + const SkOpSegment* other = span.fOther; |
| + const SkOpSpan& otherSpan = other->fTs[otherIndex]; |
| + SkASSERT(otherSpan.fPt == span.fPt); |
| + SkASSERT(otherSpan.fOtherT == t); |
| + SkASSERT(&fTs[i] == &otherSpan.fOther->fTs[otherSpan.fOtherIndex]); |
| + done += span.fDone; |
| + } |
| + SkASSERT(done == fDoneSpans); |
| +#endif |
| +} |