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 "SkOpCoincidence.h" | 7 #include "SkOpCoincidence.h" |
8 #include "SkOpContour.h" | 8 #include "SkOpContour.h" |
9 #include "SkOpSegment.h" | 9 #include "SkOpSegment.h" |
10 #include "SkPathWriter.h" | 10 #include "SkPathWriter.h" |
(...skipping 1665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1676 // average t, find mid pt | 1676 // average t, find mid pt |
1677 double midT = (prior->t() + spanBase->t()) / 2; | 1677 double midT = (prior->t() + spanBase->t()) / 2; |
1678 SkPoint midPt = this->ptAtT(midT); | 1678 SkPoint midPt = this->ptAtT(midT); |
1679 bool coincident = true; | 1679 bool coincident = true; |
1680 // if the mid pt is not near either end pt, project perpendicular through op
p seg | 1680 // if the mid pt is not near either end pt, project perpendicular through op
p seg |
1681 if (!SkDPoint::ApproximatelyEqual(priorPtT->fPt, midPt) | 1681 if (!SkDPoint::ApproximatelyEqual(priorPtT->fPt, midPt) |
1682 && !SkDPoint::ApproximatelyEqual(ptT->fPt, midPt)) { | 1682 && !SkDPoint::ApproximatelyEqual(ptT->fPt, midPt)) { |
1683 coincident = false; | 1683 coincident = false; |
1684 SkIntersections i; | 1684 SkIntersections i; |
1685 SkVector dxdy = (*CurveSlopeAtT[fVerb])(this->pts(), this->weight(), mid
T); | 1685 SkVector dxdy = (*CurveSlopeAtT[fVerb])(this->pts(), this->weight(), mid
T); |
1686 SkDLine ray = {{{midPt.fX, midPt.fY}, {midPt.fX + dxdy.fY, midPt.fY - dx
dy.fX}}}; | 1686 SkDLine ray = {{{midPt.fX, midPt.fY}, |
| 1687 {(double) midPt.fX + dxdy.fY, (double) midPt.fY - dxdy.fX}}}; |
1687 (*CurveIntersectRay[opp->verb()])(opp->pts(), opp->weight(), ray, &i); | 1688 (*CurveIntersectRay[opp->verb()])(opp->pts(), opp->weight(), ray, &i); |
1688 // measure distance and see if it's small enough to denote coincidence | 1689 // measure distance and see if it's small enough to denote coincidence |
1689 for (int index = 0; index < i.used(); ++index) { | 1690 for (int index = 0; index < i.used(); ++index) { |
1690 SkDPoint oppPt = i.pt(index); | 1691 SkDPoint oppPt = i.pt(index); |
1691 if (oppPt.approximatelyEqual(midPt)) { | 1692 if (oppPt.approximatelyEqual(midPt)) { |
1692 SkVector oppDxdy = (*CurveSlopeAtT[opp->verb()])(opp->pts(), | 1693 SkVector oppDxdy = (*CurveSlopeAtT[opp->verb()])(opp->pts(), |
1693 opp->weight(), i[index][0]); | 1694 opp->weight(), i[index][0]); |
1694 oppDxdy.normalize(); | 1695 oppDxdy.normalize(); |
1695 dxdy.normalize(); | 1696 dxdy.normalize(); |
1696 SkScalar flatness = SkScalarAbs(dxdy.cross(oppDxdy) / FLT_EPSILO
N); | 1697 SkScalar flatness = SkScalarAbs(dxdy.cross(oppDxdy) / FLT_EPSILO
N); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1774 int absOut = SkTAbs(outerWinding); | 1775 int absOut = SkTAbs(outerWinding); |
1775 int absIn = SkTAbs(innerWinding); | 1776 int absIn = SkTAbs(innerWinding); |
1776 bool result = absOut == absIn ? outerWinding < 0 : absOut < absIn; | 1777 bool result = absOut == absIn ? outerWinding < 0 : absOut < absIn; |
1777 return result; | 1778 return result; |
1778 } | 1779 } |
1779 | 1780 |
1780 int SkOpSegment::windSum(const SkOpAngle* angle) const { | 1781 int SkOpSegment::windSum(const SkOpAngle* angle) const { |
1781 const SkOpSpan* minSpan = angle->start()->starter(angle->end()); | 1782 const SkOpSpan* minSpan = angle->start()->starter(angle->end()); |
1782 return minSpan->windSum(); | 1783 return minSpan->windSum(); |
1783 } | 1784 } |
OLD | NEW |