| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 #include "SkIntersections.h" | 7 #include "SkIntersections.h" |
| 8 #include "SkOpAngle.h" | 8 #include "SkOpAngle.h" |
| 9 #include "SkOpSegment.h" | 9 #include "SkOpSegment.h" |
| 10 #include "SkPathOpsCurve.h" | 10 #include "SkPathOpsCurve.h" |
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 SkDLine rays[] = {{{fCurvePart[0], rh.fCurvePart[rPts]}}, | 402 SkDLine rays[] = {{{fCurvePart[0], rh.fCurvePart[rPts]}}, |
| 403 {{fCurvePart[0], fCurvePart[lPts]}}}; | 403 {{fCurvePart[0], fCurvePart[lPts]}}}; |
| 404 if (rays[0][1] == rays[1][1]) { | 404 if (rays[0][1] == rays[1][1]) { |
| 405 return checkParallel(rh); | 405 return checkParallel(rh); |
| 406 } | 406 } |
| 407 double smallTs[2] = {-1, -1}; | 407 double smallTs[2] = {-1, -1}; |
| 408 bool limited[2] = {false, false}; | 408 bool limited[2] = {false, false}; |
| 409 for (int index = 0; index < 2; ++index) { | 409 for (int index = 0; index < 2; ++index) { |
| 410 const SkOpSegment& segment = index ? *rh.fSegment : *fSegment; | 410 const SkOpSegment& segment = index ? *rh.fSegment : *fSegment; |
| 411 SkIntersections i; | 411 SkIntersections i; |
| 412 (*CurveIntersectRay[index ? rPts : lPts])(segment.pts(), rays[index], &i
); | 412 int cPts = index ? rPts : lPts; |
| 413 (*CurveIntersectRay[cPts])(segment.pts(), rays[index], &i); |
| 414 // if the curve is a line, then the line and the ray intersect only at t
heir crossing |
| 415 if (cPts == 1) { // line |
| 416 continue; |
| 417 } |
| 413 // SkASSERT(i.used() >= 1); | 418 // SkASSERT(i.used() >= 1); |
| 414 // if (i.used() <= 1) { | 419 // if (i.used() <= 1) { |
| 415 // continue; | 420 // continue; |
| 416 // } | 421 // } |
| 417 double tStart = segment.t(index ? rh.fStart : fStart); | 422 double tStart = segment.t(index ? rh.fStart : fStart); |
| 418 double tEnd = segment.t(index ? rh.fComputedEnd : fComputedEnd); | 423 double tEnd = segment.t(index ? rh.fComputedEnd : fComputedEnd); |
| 419 bool testAscends = index ? rh.fStart < rh.fComputedEnd : fStart < fCompu
tedEnd; | 424 bool testAscends = index ? rh.fStart < rh.fComputedEnd : fStart < fCompu
tedEnd; |
| 420 double t = testAscends ? 0 : 1; | 425 double t = testAscends ? 0 : 1; |
| 421 for (int idx2 = 0; idx2 < i.used(); ++idx2) { | 426 for (int idx2 = 0; idx2 < i.used(); ++idx2) { |
| 422 double testT = i[0][idx2]; | 427 double testT = i[0][idx2]; |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 650 angle->insert(this); | 655 angle->insert(this); |
| 651 } | 656 } |
| 652 return; | 657 return; |
| 653 } | 658 } |
| 654 bool singleton = NULL == fNext; | 659 bool singleton = NULL == fNext; |
| 655 if (singleton) { | 660 if (singleton) { |
| 656 fNext = this; | 661 fNext = this; |
| 657 } | 662 } |
| 658 SkOpAngle* next = fNext; | 663 SkOpAngle* next = fNext; |
| 659 if (next->fNext == this) { | 664 if (next->fNext == this) { |
| 660 if (angle->overlap(*this)) { | 665 if (angle->overlap(*this)) { // angles are essentially coincident |
| 661 return; | 666 return; |
| 662 } | 667 } |
| 663 if (singleton || angle->after(this)) { | 668 if (singleton || angle->after(this)) { |
| 664 this->fNext = angle; | 669 this->fNext = angle; |
| 665 angle->fNext = next; | 670 angle->fNext = next; |
| 666 } else { | 671 } else { |
| 667 next->fNext = angle; | 672 next->fNext = angle; |
| 668 angle->fNext = this; | 673 angle->fNext = this; |
| 669 } | 674 } |
| 670 debugValidateNext(); | 675 debugValidateNext(); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 770 } | 775 } |
| 771 working = working->fNext; | 776 working = working->fNext; |
| 772 } while (working != angle); | 777 } while (working != angle); |
| 773 do { | 778 do { |
| 774 SkOpAngle* next = working->fNext; | 779 SkOpAngle* next = working->fNext; |
| 775 working->fNext = NULL; | 780 working->fNext = NULL; |
| 776 insert(working); | 781 insert(working); |
| 777 working = next; | 782 working = next; |
| 778 } while (working != angle); | 783 } while (working != angle); |
| 779 // it's likely that a pair of the angles are unorderable | 784 // it's likely that a pair of the angles are unorderable |
| 780 #if DEBUG_ANGLE | 785 #if 0 && DEBUG_ANGLE |
| 781 SkOpAngle* last = angle; | 786 SkOpAngle* last = angle; |
| 782 working = angle->fNext; | 787 working = angle->fNext; |
| 783 do { | 788 do { |
| 784 SkASSERT(last->fNext == working); | 789 SkASSERT(last->fNext == working); |
| 785 last->fNext = working->fNext; | 790 last->fNext = working->fNext; |
| 786 SkASSERT(working->after(last)); | 791 SkASSERT(working->after(last)); |
| 787 last->fNext = working; | 792 last->fNext = working; |
| 788 last = working; | 793 last = working; |
| 789 working = working->fNext; | 794 working = working->fNext; |
| 790 } while (last != angle); | 795 } while (last != angle); |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1121 angle->setID(++fCount); | 1126 angle->setID(++fCount); |
| 1122 #endif | 1127 #endif |
| 1123 return *angle; | 1128 return *angle; |
| 1124 } | 1129 } |
| 1125 | 1130 |
| 1126 void SkOpAngleSet::reset() { | 1131 void SkOpAngleSet::reset() { |
| 1127 if (fAngles) { | 1132 if (fAngles) { |
| 1128 fAngles->reset(); | 1133 fAngles->reset(); |
| 1129 } | 1134 } |
| 1130 } | 1135 } |
| OLD | NEW |