OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkPathOpsDebug.h" | 8 #include "SkPathOpsDebug.h" |
9 #include "SkPath.h" | 9 #include "SkPath.h" |
10 | 10 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 } | 97 } |
98 #endif | 98 #endif |
99 | 99 |
100 #endif // defined SK_DEBUG || !FORCE_RELEASE | 100 #endif // defined SK_DEBUG || !FORCE_RELEASE |
101 | 101 |
102 #include "SkOpAngle.h" | 102 #include "SkOpAngle.h" |
103 #include "SkOpSegment.h" | 103 #include "SkOpSegment.h" |
104 | 104 |
105 #if DEBUG_SORT | 105 #if DEBUG_SORT |
106 void SkOpAngle::debugLoop() const { | 106 void SkOpAngle::debugLoop() const { |
107 const SkOpAngle* first = this; | 107 dumpLoop(); |
108 const SkOpAngle* next = this; | |
109 do { | |
110 next->debugOne(true); | |
111 SkDebugf("\n"); | |
112 next = next->fNext; | |
113 } while (next && next != first); | |
114 } | |
115 | |
116 void SkOpAngle::debugOne(bool functionHeader) const { | |
117 // fSegment->debugValidate(); | |
118 const SkOpSpan& mSpan = fSegment->span(SkMin32(fStart, fEnd)); | |
119 if (functionHeader) { | |
120 SkDebugf("%s ", __FUNCTION__); | |
121 } | |
122 SkDebugf("[%d", fSegment->debugID()); | |
123 #if DEBUG_ANGLE | |
124 SkDebugf("/%d", fID); | |
125 #endif | |
126 SkDebugf("] next="); | |
127 if (fNext) { | |
128 SkDebugf("%d", fNext->fSegment->debugID()); | |
129 #if DEBUG_ANGLE | |
130 SkDebugf("/%d", fNext->fID); | |
131 #endif | |
132 } else { | |
133 SkDebugf("?"); | |
134 } | |
135 SkDebugf(" sect=%d/%d ", fSectorStart, fSectorEnd); | |
136 SkDebugf(" s=%1.9g [%d] e=%1.9g [%d]", fSegment->span(fStart).fT, fStart, | |
137 fSegment->span(fEnd).fT, fEnd); | |
138 SkDebugf(" sgn=%d windVal=%d", sign(), mSpan.fWindValue); | |
139 | |
140 #if DEBUG_WINDING | |
141 SkDebugf(" windSum="); | |
142 SkPathOpsDebug::WindingPrintf(mSpan.fWindSum); | |
143 #endif | |
144 if (mSpan.fOppValue != 0 || mSpan.fOppSum != SK_MinS32) { | |
145 SkDebugf(" oppVal=%d", mSpan.fOppValue); | |
146 #if DEBUG_WINDING | |
147 SkDebugf(" oppSum="); | |
148 SkPathOpsDebug::WindingPrintf(mSpan.fOppSum); | |
149 #endif | |
150 } | |
151 if (mSpan.fDone) { | |
152 SkDebugf(" done"); | |
153 } | |
154 if (unorderable()) { | |
155 SkDebugf(" unorderable"); | |
156 } | |
157 if (small()) { | |
158 SkDebugf(" small"); | |
159 } | |
160 if (mSpan.fTiny) { | |
161 SkDebugf(" tiny"); | |
162 } | |
163 if (fSegment->operand()) { | |
164 SkDebugf(" operand"); | |
165 } | |
166 if (fStop) { | |
167 SkDebugf(" stop"); | |
168 } | |
169 } | 108 } |
170 #endif | 109 #endif |
171 | 110 |
172 #if DEBUG_ANGLE | 111 #if DEBUG_ANGLE |
173 void SkOpAngle::debugSameAs(const SkOpAngle* compare) const { | 112 void SkOpAngle::debugSameAs(const SkOpAngle* compare) const { |
174 SK_ALWAYSBREAK(fSegment == compare->fSegment); | 113 SK_ALWAYSBREAK(fSegment == compare->fSegment); |
175 const SkOpSpan& startSpan = fSegment->span(fStart); | 114 const SkOpSpan& startSpan = fSegment->span(fStart); |
176 const SkOpSpan& oStartSpan = fSegment->span(compare->fStart); | 115 const SkOpSpan& oStartSpan = fSegment->span(compare->fStart); |
177 SK_ALWAYSBREAK(startSpan.fToAngleIndex == oStartSpan.fToAngleIndex); | 116 SK_ALWAYSBREAK(startSpan.fToAngle == oStartSpan.fToAngle); |
178 SK_ALWAYSBREAK(startSpan.fFromAngleIndex == oStartSpan.fFromAngleIndex); | 117 SK_ALWAYSBREAK(startSpan.fFromAngle == oStartSpan.fFromAngle); |
179 const SkOpSpan& endSpan = fSegment->span(fEnd); | 118 const SkOpSpan& endSpan = fSegment->span(fEnd); |
180 const SkOpSpan& oEndSpan = fSegment->span(compare->fEnd); | 119 const SkOpSpan& oEndSpan = fSegment->span(compare->fEnd); |
181 SK_ALWAYSBREAK(endSpan.fToAngleIndex == oEndSpan.fToAngleIndex); | 120 SK_ALWAYSBREAK(endSpan.fToAngle == oEndSpan.fToAngle); |
182 SK_ALWAYSBREAK(endSpan.fFromAngleIndex == oEndSpan.fFromAngleIndex); | 121 SK_ALWAYSBREAK(endSpan.fFromAngle == oEndSpan.fFromAngle); |
183 } | 122 } |
184 #endif | 123 #endif |
185 | 124 |
186 #if DEBUG_VALIDATE | 125 #if DEBUG_VALIDATE |
187 void SkOpAngle::debugValidateNext() const { | 126 void SkOpAngle::debugValidateNext() const { |
188 const SkOpAngle* first = this; | 127 const SkOpAngle* first = this; |
189 const SkOpAngle* next = first; | 128 const SkOpAngle* next = first; |
190 SkTDArray<const SkOpAngle*>(angles); | 129 SkTDArray<const SkOpAngle*>(angles); |
191 do { | 130 do { |
192 SK_ALWAYSBREAK(next->fSegment->debugContains(next)); | 131 // SK_ALWAYSBREAK(next->fSegment->debugContains(next)); |
193 angles.push(next); | 132 angles.push(next); |
194 next = next->next(); | 133 next = next->next(); |
195 if (next == first) { | 134 if (next == first) { |
196 break; | 135 break; |
197 } | 136 } |
198 SK_ALWAYSBREAK(!angles.contains(next)); | 137 SK_ALWAYSBREAK(!angles.contains(next)); |
199 if (!next) { | 138 if (!next) { |
200 return; | 139 return; |
201 } | 140 } |
202 } while (true); | 141 } while (true); |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 #if DEBUG_ANGLE | 309 #if DEBUG_ANGLE |
371 void SkOpSegment::debugCheckPointsEqualish(int tStart, int tEnd) const { | 310 void SkOpSegment::debugCheckPointsEqualish(int tStart, int tEnd) const { |
372 const SkPoint& basePt = fTs[tStart].fPt; | 311 const SkPoint& basePt = fTs[tStart].fPt; |
373 while (++tStart < tEnd) { | 312 while (++tStart < tEnd) { |
374 const SkPoint& cmpPt = fTs[tStart].fPt; | 313 const SkPoint& cmpPt = fTs[tStart].fPt; |
375 SK_ALWAYSBREAK(SkDPoint::ApproximatelyEqual(basePt, cmpPt)); | 314 SK_ALWAYSBREAK(SkDPoint::ApproximatelyEqual(basePt, cmpPt)); |
376 } | 315 } |
377 } | 316 } |
378 #endif | 317 #endif |
379 | 318 |
380 #if DEBUG_VALIDATE | |
381 bool SkOpSegment::debugContains(const SkOpAngle* angle) const { | |
382 for (int index = 0; index < fAngles.count(); ++index) { | |
383 if (&fAngles[index] == angle) { | |
384 return true; | |
385 } | |
386 } | |
387 for (int index = 0; index < fSingletonAngles.count(); ++index) { | |
388 if (&fSingletonAngles[index] == angle) { | |
389 return true; | |
390 } | |
391 } | |
392 return false; | |
393 } | |
394 #endif | |
395 | |
396 #if DEBUG_SWAP_TOP | 319 #if DEBUG_SWAP_TOP |
397 int SkOpSegment::debugInflections(int tStart, int tEnd) const { | 320 int SkOpSegment::debugInflections(int tStart, int tEnd) const { |
398 if (fVerb != SkPath::kCubic_Verb) { | 321 if (fVerb != SkPath::kCubic_Verb) { |
399 return false; | 322 return false; |
400 } | 323 } |
401 SkDCubic dst = SkDCubic::SubDivide(fPts, fTs[tStart].fT, fTs[tEnd].fT); | 324 SkDCubic dst = SkDCubic::SubDivide(fPts, fTs[tStart].fT, fTs[tEnd].fT); |
402 double inflections[2]; | 325 double inflections[2]; |
403 return dst.findInflections(inflections); | 326 return dst.findInflections(inflections); |
404 } | 327 } |
405 #endif | 328 #endif |
406 | 329 |
| 330 const SkOpAngle* SkOpSegment::debugLastAngle() const { |
| 331 const SkOpAngle* result = NULL; |
| 332 for (int index = 0; index < count(); ++index) { |
| 333 const SkOpSpan& span = this->span(index); |
| 334 if (span.fToAngle) { |
| 335 SkASSERT(!result); |
| 336 result = span.fToAngle; |
| 337 } |
| 338 } |
| 339 SkASSERT(result); |
| 340 return result; |
| 341 } |
| 342 |
407 void SkOpSegment::debugReset() { | 343 void SkOpSegment::debugReset() { |
408 fTs.reset(); | 344 fTs.reset(); |
409 fAngles.reset(); | 345 fAngles.reset(); |
410 } | 346 } |
411 | 347 |
412 #if DEBUG_CONCIDENT | 348 #if DEBUG_CONCIDENT |
413 void SkOpSegment::debugShowTs(const char* prefix) const { | 349 void SkOpSegment::debugShowTs(const char* prefix) const { |
414 SkDebugf("%s %s id=%d", __FUNCTION__, prefix, fID); | 350 SkDebugf("%s %s id=%d", __FUNCTION__, prefix, fID); |
415 int lastWind = -1; | 351 int lastWind = -1; |
416 int lastOpp = -1; | 352 int lastOpp = -1; |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
532 SkDebugf("?"); | 468 SkDebugf("?"); |
533 } else { | 469 } else { |
534 SkDebugf("%d", span.fOppSum); | 470 SkDebugf("%d", span.fOppSum); |
535 } | 471 } |
536 SkDebugf(" windSum="); | 472 SkDebugf(" windSum="); |
537 if (span.fWindSum == SK_MinS32) { | 473 if (span.fWindSum == SK_MinS32) { |
538 SkDebugf("?"); | 474 SkDebugf("?"); |
539 } else { | 475 } else { |
540 SkDebugf("%d", span.fWindSum); | 476 SkDebugf("%d", span.fWindSum); |
541 } | 477 } |
542 SkDebugf(" windValue=%d\n", span.fWindValue); | 478 SkDebugf(" windValue=%d oppValue=%d\n", span.fWindValue, span.fOppValue); |
543 } | 479 } |
544 #endif | 480 #endif |
545 | 481 |
546 #if DEBUG_SHOW_WINDING | 482 #if DEBUG_SHOW_WINDING |
547 int SkOpSegment::debugShowWindingValues(int slotCount, int ofInterest) const { | 483 int SkOpSegment::debugShowWindingValues(int slotCount, int ofInterest) const { |
548 if (!(1 << fID & ofInterest)) { | 484 if (!(1 << fID & ofInterest)) { |
549 return 0; | 485 return 0; |
550 } | 486 } |
551 int sum = 0; | 487 int sum = 0; |
552 SkTArray<char, true> slots(slotCount * 2); | 488 SkTArray<char, true> slots(slotCount * 2); |
(...skipping 30 matching lines...) Expand all Loading... |
583 t = span.fT; | 519 t = span.fT; |
584 int otherIndex = span.fOtherIndex; | 520 int otherIndex = span.fOtherIndex; |
585 const SkOpSegment* other = span.fOther; | 521 const SkOpSegment* other = span.fOther; |
586 SK_ALWAYSBREAK(other != this || fVerb == SkPath::kCubic_Verb); | 522 SK_ALWAYSBREAK(other != this || fVerb == SkPath::kCubic_Verb); |
587 const SkOpSpan& otherSpan = other->fTs[otherIndex]; | 523 const SkOpSpan& otherSpan = other->fTs[otherIndex]; |
588 SK_ALWAYSBREAK(otherSpan.fPt == span.fPt); | 524 SK_ALWAYSBREAK(otherSpan.fPt == span.fPt); |
589 SK_ALWAYSBREAK(otherSpan.fOtherT == t); | 525 SK_ALWAYSBREAK(otherSpan.fOtherT == t); |
590 SK_ALWAYSBREAK(&fTs[i] == &otherSpan.fOther->fTs[otherSpan.fOtherIndex])
; | 526 SK_ALWAYSBREAK(&fTs[i] == &otherSpan.fOther->fTs[otherSpan.fOtherIndex])
; |
591 done += span.fDone; | 527 done += span.fDone; |
592 if (last) { | 528 if (last) { |
| 529 SK_ALWAYSBREAK(last->fT != span.fT || last->fOther != span.fOther); |
593 bool tsEqual = last->fT == span.fT; | 530 bool tsEqual = last->fT == span.fT; |
594 bool tsPreciselyEqual = precisely_equal(last->fT, span.fT); | 531 bool tsPreciselyEqual = precisely_equal(last->fT, span.fT); |
595 SK_ALWAYSBREAK(!tsEqual || tsPreciselyEqual); | 532 SK_ALWAYSBREAK(!tsEqual || tsPreciselyEqual); |
596 bool pointsEqual = last->fPt == span.fPt; | 533 bool pointsEqual = last->fPt == span.fPt; |
597 bool pointsNearlyEqual = AlmostEqualUlps(last->fPt, span.fPt); | 534 bool pointsNearlyEqual = AlmostEqualUlps(last->fPt, span.fPt); |
598 #if 0 // bufferOverflow test triggers this | 535 #if 0 // bufferOverflow test triggers this |
599 SK_ALWAYSBREAK(!tsPreciselyEqual || pointsNearlyEqual); | 536 SK_ALWAYSBREAK(!tsPreciselyEqual || pointsNearlyEqual); |
600 #endif | 537 #endif |
601 // SK_ALWAYSBREAK(!last->fTiny || !tsPreciselyEqual || span.fTiny ||
tinyTFound); | 538 // SK_ALWAYSBREAK(!last->fTiny || !tsPreciselyEqual || span.fTiny ||
tinyTFound); |
602 SK_ALWAYSBREAK(last->fTiny || tsPreciselyEqual || !pointsEqual || ha
sLoop); | 539 SK_ALWAYSBREAK(last->fTiny || tsPreciselyEqual || !pointsEqual || ha
sLoop); |
603 SK_ALWAYSBREAK(!last->fTiny || pointsEqual); | 540 SK_ALWAYSBREAK(!last->fTiny || pointsEqual); |
604 SK_ALWAYSBREAK(!last->fTiny || last->fDone); | 541 SK_ALWAYSBREAK(!last->fTiny || last->fDone); |
605 SK_ALWAYSBREAK(!last->fSmall || pointsNearlyEqual); | 542 SK_ALWAYSBREAK(!last->fSmall || pointsNearlyEqual); |
606 SK_ALWAYSBREAK(!last->fSmall || last->fDone); | 543 SK_ALWAYSBREAK(!last->fSmall || last->fDone); |
607 // SK_ALWAYSBREAK(!last->fSmall || last->fTiny); | 544 // SK_ALWAYSBREAK(!last->fSmall || last->fTiny); |
608 // SK_ALWAYSBREAK(last->fTiny || !pointsEqual || last->fDone == span.
fDone); | 545 // SK_ALWAYSBREAK(last->fTiny || !pointsEqual || last->fDone == span.
fDone); |
609 if (last->fTiny) { | 546 if (last->fTiny) { |
610 tinyTFound |= !tsPreciselyEqual; | 547 tinyTFound |= !tsPreciselyEqual; |
611 } else { | 548 } else { |
612 tinyTFound = false; | 549 tinyTFound = false; |
613 } | 550 } |
614 } | 551 } |
615 last = &span; | 552 last = &span; |
616 hasLoop |= last->fLoop; | 553 hasLoop |= last->fLoop; |
617 } | 554 } |
618 SK_ALWAYSBREAK(done == fDoneSpans); | 555 SK_ALWAYSBREAK(done == fDoneSpans); |
619 if (fAngles.count() ) { | 556 // if (fAngles.count() ) { |
620 fAngles.begin()->debugValidateLoop(); | 557 // fAngles.begin()->debugValidateLoop(); |
621 } | 558 // } |
622 #endif | 559 #endif |
623 } | 560 } |
OLD | NEW |