| 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" |
| 11 | 11 |
| 12 #define FAIL_IF(cond) do { if (cond) return false; } while (false) | |
| 13 | |
| 14 /* | 12 /* |
| 15 After computing raw intersections, post process all segments to: | 13 After computing raw intersections, post process all segments to: |
| 16 - find small collections of points that can be collapsed to a single point | 14 - find small collections of points that can be collapsed to a single point |
| 17 - find missing intersections to resolve differences caused by different algorith
ms | 15 - find missing intersections to resolve differences caused by different algorith
ms |
| 18 | 16 |
| 19 Consider segments containing tiny or small intervals. Consider coincident segmen
ts | 17 Consider segments containing tiny or small intervals. Consider coincident segmen
ts |
| 20 because coincidence finds intersections through distance measurement that non-co
incident | 18 because coincidence finds intersections through distance measurement that non-co
incident |
| 21 intersection tests cannot. | 19 intersection tests cannot. |
| 22 */ | 20 */ |
| 23 | 21 |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 int maxWinding; | 154 int maxWinding; |
| 157 setUpWinding(start, end, &maxWinding, sumWinding); | 155 setUpWinding(start, end, &maxWinding, sumWinding); |
| 158 bool from = maxWinding != 0; | 156 bool from = maxWinding != 0; |
| 159 bool to = *sumWinding != 0; | 157 bool to = *sumWinding != 0; |
| 160 bool result = gUnaryActiveEdge[from][to]; | 158 bool result = gUnaryActiveEdge[from][to]; |
| 161 return result; | 159 return result; |
| 162 } | 160 } |
| 163 | 161 |
| 164 bool SkOpSegment::addCurveTo(const SkOpSpanBase* start, const SkOpSpanBase* end, | 162 bool SkOpSegment::addCurveTo(const SkOpSpanBase* start, const SkOpSpanBase* end, |
| 165 SkPathWriter* path) const { | 163 SkPathWriter* path) const { |
| 166 if (start->starter(end)->alreadyAdded()) { | 164 FAIL_IF(start->starter(end)->alreadyAdded()); |
| 167 SkDEBUGF(("same curve added twice aborted pathops\n")); | |
| 168 return false; | |
| 169 } | |
| 170 SkOpCurve edge; | 165 SkOpCurve edge; |
| 171 const SkPoint* ePtr; | 166 const SkPoint* ePtr; |
| 172 SkScalar eWeight; | 167 SkScalar eWeight; |
| 173 if ((start == &fHead && end == &fTail) || (start == &fTail && end == &fHead)
) { | 168 if ((start == &fHead && end == &fTail) || (start == &fTail && end == &fHead)
) { |
| 174 ePtr = fPts; | 169 ePtr = fPts; |
| 175 eWeight = fWeight; | 170 eWeight = fWeight; |
| 176 } else { | 171 } else { |
| 177 // OPTIMIZE? if not active, skip remainder and return xyAtT(end) | 172 // OPTIMIZE? if not active, skip remainder and return xyAtT(end) |
| 178 subDivide(start, end, &edge); | 173 subDivide(start, end, &edge); |
| 179 ePtr = edge.fPts; | 174 ePtr = edge.fPts; |
| (...skipping 1610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1790 int absOut = SkTAbs(outerWinding); | 1785 int absOut = SkTAbs(outerWinding); |
| 1791 int absIn = SkTAbs(innerWinding); | 1786 int absIn = SkTAbs(innerWinding); |
| 1792 bool result = absOut == absIn ? outerWinding < 0 : absOut < absIn; | 1787 bool result = absOut == absIn ? outerWinding < 0 : absOut < absIn; |
| 1793 return result; | 1788 return result; |
| 1794 } | 1789 } |
| 1795 | 1790 |
| 1796 int SkOpSegment::windSum(const SkOpAngle* angle) const { | 1791 int SkOpSegment::windSum(const SkOpAngle* angle) const { |
| 1797 const SkOpSpan* minSpan = angle->start()->starter(angle->end()); | 1792 const SkOpSpan* minSpan = angle->start()->starter(angle->end()); |
| 1798 return minSpan->windSum(); | 1793 return minSpan->windSum(); |
| 1799 } | 1794 } |
| OLD | NEW |