| 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 "SkOpAngle.h" | 7 #include "SkOpAngle.h" |
| 8 #include "SkOpSegment.h" | 8 #include "SkOpSegment.h" |
| 9 #include "SkPathOpsCurve.h" | 9 #include "SkPathOpsCurve.h" |
| 10 #include "SkTSort.h" | 10 #include "SkTSort.h" |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 } | 342 } |
| 343 if (oSpan == checkEnd) { | 343 if (oSpan == checkEnd) { |
| 344 continue; | 344 continue; |
| 345 } | 345 } |
| 346 if (!approximately_equal(oSpan->t(), checkEnd->t())) { | 346 if (!approximately_equal(oSpan->t(), checkEnd->t())) { |
| 347 continue; | 347 continue; |
| 348 } | 348 } |
| 349 goto recomputeSector; | 349 goto recomputeSector; |
| 350 } while (!oSpan->final() && (oSpan = oSpan->upCast()->next())); | 350 } while (!oSpan->final() && (oSpan = oSpan->upCast()->next())); |
| 351 checkEnd = stepUp ? !checkEnd->final() | 351 checkEnd = stepUp ? !checkEnd->final() |
| 352 ? checkEnd->upCast()->next() : NULL | 352 ? checkEnd->upCast()->next() : nullptr |
| 353 : checkEnd->prev(); | 353 : checkEnd->prev(); |
| 354 } while (checkEnd); | 354 } while (checkEnd); |
| 355 recomputeSector: | 355 recomputeSector: |
| 356 SkOpSpanBase* computedEnd = stepUp ? checkEnd ? checkEnd->prev() : fEnd->seg
ment()->head() | 356 SkOpSpanBase* computedEnd = stepUp ? checkEnd ? checkEnd->prev() : fEnd->seg
ment()->head() |
| 357 : checkEnd ? checkEnd->upCast()->next() : fEnd->segment()->tail(); | 357 : checkEnd ? checkEnd->upCast()->next() : fEnd->segment()->tail(); |
| 358 if (checkEnd == fEnd || computedEnd == fEnd || computedEnd == fStart) { | 358 if (checkEnd == fEnd || computedEnd == fEnd || computedEnd == fStart) { |
| 359 fUnorderable = true; | 359 fUnorderable = true; |
| 360 return false; | 360 return false; |
| 361 } | 361 } |
| 362 if (stepUp != (fStart->t() < computedEnd->t())) { | 362 if (stepUp != (fStart->t() < computedEnd->t())) { |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 652 } | 652 } |
| 653 } else if (fNext) { | 653 } else if (fNext) { |
| 654 if (!angle->merge(this)) { | 654 if (!angle->merge(this)) { |
| 655 return; | 655 return; |
| 656 } | 656 } |
| 657 } else { | 657 } else { |
| 658 angle->insert(this); | 658 angle->insert(this); |
| 659 } | 659 } |
| 660 return; | 660 return; |
| 661 } | 661 } |
| 662 bool singleton = NULL == fNext; | 662 bool singleton = nullptr == fNext; |
| 663 if (singleton) { | 663 if (singleton) { |
| 664 fNext = this; | 664 fNext = this; |
| 665 } | 665 } |
| 666 SkOpAngle* next = fNext; | 666 SkOpAngle* next = fNext; |
| 667 if (next->fNext == this) { | 667 if (next->fNext == this) { |
| 668 if (singleton || angle->after(this)) { | 668 if (singleton || angle->after(this)) { |
| 669 this->fNext = angle; | 669 this->fNext = angle; |
| 670 angle->fNext = next; | 670 angle->fNext = next; |
| 671 } else { | 671 } else { |
| 672 next->fNext = angle; | 672 next->fNext = angle; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 696 angle->fCheckCoincidence = true; | 696 angle->fCheckCoincidence = true; |
| 697 } | 697 } |
| 698 return; | 698 return; |
| 699 } | 699 } |
| 700 } while (true); | 700 } while (true); |
| 701 } | 701 } |
| 702 | 702 |
| 703 SkOpSpanBase* SkOpAngle::lastMarked() const { | 703 SkOpSpanBase* SkOpAngle::lastMarked() const { |
| 704 if (fLastMarked) { | 704 if (fLastMarked) { |
| 705 if (fLastMarked->chased()) { | 705 if (fLastMarked->chased()) { |
| 706 return NULL; | 706 return nullptr; |
| 707 } | 707 } |
| 708 fLastMarked->setChased(true); | 708 fLastMarked->setChased(true); |
| 709 } | 709 } |
| 710 return fLastMarked; | 710 return fLastMarked; |
| 711 } | 711 } |
| 712 | 712 |
| 713 bool SkOpAngle::loopContains(const SkOpAngle* angle) const { | 713 bool SkOpAngle::loopContains(const SkOpAngle* angle) const { |
| 714 if (!fNext) { | 714 if (!fNext) { |
| 715 return false; | 715 return false; |
| 716 } | 716 } |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 752 SkASSERT(angle->fNext); | 752 SkASSERT(angle->fNext); |
| 753 SkOpAngle* working = angle; | 753 SkOpAngle* working = angle; |
| 754 do { | 754 do { |
| 755 if (this == working) { | 755 if (this == working) { |
| 756 return false; | 756 return false; |
| 757 } | 757 } |
| 758 working = working->fNext; | 758 working = working->fNext; |
| 759 } while (working != angle); | 759 } while (working != angle); |
| 760 do { | 760 do { |
| 761 SkOpAngle* next = working->fNext; | 761 SkOpAngle* next = working->fNext; |
| 762 working->fNext = NULL; | 762 working->fNext = nullptr; |
| 763 insert(working); | 763 insert(working); |
| 764 working = next; | 764 working = next; |
| 765 } while (working != angle); | 765 } while (working != angle); |
| 766 // it's likely that a pair of the angles are unorderable | 766 // it's likely that a pair of the angles are unorderable |
| 767 debugValidateNext(); | 767 debugValidateNext(); |
| 768 return true; | 768 return true; |
| 769 } | 769 } |
| 770 | 770 |
| 771 double SkOpAngle::midT() const { | 771 double SkOpAngle::midT() const { |
| 772 return (fStart->t() + fEnd->t()) / 2; | 772 return (fStart->t() + fEnd->t()) / 2; |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 870 } | 870 } |
| 871 | 871 |
| 872 SkOpSegment* SkOpAngle::segment() const { | 872 SkOpSegment* SkOpAngle::segment() const { |
| 873 return fStart->segment(); | 873 return fStart->segment(); |
| 874 } | 874 } |
| 875 | 875 |
| 876 void SkOpAngle::set(SkOpSpanBase* start, SkOpSpanBase* end) { | 876 void SkOpAngle::set(SkOpSpanBase* start, SkOpSpanBase* end) { |
| 877 fStart = start; | 877 fStart = start; |
| 878 fComputedEnd = fEnd = end; | 878 fComputedEnd = fEnd = end; |
| 879 SkASSERT(start != end); | 879 SkASSERT(start != end); |
| 880 fNext = NULL; | 880 fNext = nullptr; |
| 881 fComputeSector = fComputedSector = fCheckCoincidence = false; | 881 fComputeSector = fComputedSector = fCheckCoincidence = false; |
| 882 setSpans(); | 882 setSpans(); |
| 883 setSector(); | 883 setSector(); |
| 884 SkDEBUGCODE(fID = start ? start->globalState()->nextAngleID() : -1); | 884 SkDEBUGCODE(fID = start ? start->globalState()->nextAngleID() : -1); |
| 885 } | 885 } |
| 886 | 886 |
| 887 void SkOpAngle::setCurveHullSweep() { | 887 void SkOpAngle::setCurveHullSweep() { |
| 888 fUnorderedSweep = false; | 888 fUnorderedSweep = false; |
| 889 fSweep[0] = fCurvePart[1] - fCurvePart[0]; | 889 fSweep[0] = fCurvePart[1] - fCurvePart[0]; |
| 890 const SkOpSegment* segment = fStart->segment(); | 890 const SkOpSegment* segment = fStart->segment(); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 922 if (s3x2 * s2x1 < 0) { | 922 if (s3x2 * s2x1 < 0) { |
| 923 SkASSERT(s2x1 * s1x3 > 0); | 923 SkASSERT(s2x1 * s1x3 > 0); |
| 924 fSweep[0] = fSweep[1]; | 924 fSweep[0] = fSweep[1]; |
| 925 fUnorderedSweep = true; | 925 fUnorderedSweep = true; |
| 926 } | 926 } |
| 927 fSweep[1] = thirdSweep; | 927 fSweep[1] = thirdSweep; |
| 928 } | 928 } |
| 929 | 929 |
| 930 void SkOpAngle::setSpans() { | 930 void SkOpAngle::setSpans() { |
| 931 fUnorderable = false; | 931 fUnorderable = false; |
| 932 fLastMarked = NULL; | 932 fLastMarked = nullptr; |
| 933 if (!fStart) { | 933 if (!fStart) { |
| 934 fUnorderable = true; | 934 fUnorderable = true; |
| 935 return; | 935 return; |
| 936 } | 936 } |
| 937 const SkOpSegment* segment = fStart->segment(); | 937 const SkOpSegment* segment = fStart->segment(); |
| 938 const SkPoint* pts = segment->pts(); | 938 const SkPoint* pts = segment->pts(); |
| 939 SkDEBUGCODE(fCurvePart.fVerb = SkPath::kCubic_Verb); | 939 SkDEBUGCODE(fCurvePart.fVerb = SkPath::kCubic_Verb); |
| 940 SkDEBUGCODE(fCurvePart[2].fX = fCurvePart[2].fY = fCurvePart[3].fX = fCurveP
art[3].fY | 940 SkDEBUGCODE(fCurvePart[2].fX = fCurvePart[2].fY = fCurvePart[3].fX = fCurveP
art[3].fY |
| 941 = SK_ScalarNaN); | 941 = SK_ScalarNaN); |
| 942 SkDEBUGCODE(fCurvePart.fVerb = segment->verb()); | 942 SkDEBUGCODE(fCurvePart.fVerb = segment->verb()); |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1091 return true; | 1091 return true; |
| 1092 } | 1092 } |
| 1093 SkASSERT(s0dt0 != 0); | 1093 SkASSERT(s0dt0 != 0); |
| 1094 double m = s0xt0 / s0dt0; | 1094 double m = s0xt0 / s0dt0; |
| 1095 double sDist = sweep[0].length() * m; | 1095 double sDist = sweep[0].length() * m; |
| 1096 double tDist = tweep[0].length() * m; | 1096 double tDist = tweep[0].length() * m; |
| 1097 bool useS = fabs(sDist) < fabs(tDist); | 1097 bool useS = fabs(sDist) < fabs(tDist); |
| 1098 double mFactor = fabs(useS ? this->distEndRatio(sDist) : rh->distEndRatio(tD
ist)); | 1098 double mFactor = fabs(useS ? this->distEndRatio(sDist) : rh->distEndRatio(tD
ist)); |
| 1099 return mFactor < 2400; // empirically found limit | 1099 return mFactor < 2400; // empirically found limit |
| 1100 } | 1100 } |
| OLD | NEW |