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