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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 SkPath::Verb rVerb = rh.fSegment->verb(); | 124 SkPath::Verb rVerb = rh.fSegment->verb(); |
125 if (y_ry != 0) { // if they aren't coincident, look for a stable cross produ
ct | 125 if (y_ry != 0) { // if they aren't coincident, look for a stable cross produ
ct |
126 // at this point, y's are the same sign, neither is zero | 126 // at this point, y's are the same sign, neither is zero |
127 // and x's are the same sign, or one (or both) is zero | 127 // and x's are the same sign, or one (or both) is zero |
128 double x_ry = x * ry; | 128 double x_ry = x * ry; |
129 double rx_y = rx * y; | 129 double rx_y = rx * y; |
130 if (!fComputed && !rh.fComputed) { | 130 if (!fComputed && !rh.fComputed) { |
131 if (!SkDLine::NearRay(x, y, rx, ry) && x_ry != rx_y) { | 131 if (!SkDLine::NearRay(x, y, rx, ry) && x_ry != rx_y) { |
132 return COMPARE_RESULT("7 !fComputed && !rh.fComputed", x_ry < rx
_y); | 132 return COMPARE_RESULT("7 !fComputed && !rh.fComputed", x_ry < rx
_y); |
133 } | 133 } |
| 134 if (fSide2 == 0 && rh.fSide2 == 0) { |
| 135 return COMPARE_RESULT("7a !fComputed && !rh.fComputed", x_ry < r
x_y); |
| 136 } |
134 } else { | 137 } else { |
135 // if the vector was a result of subdividing a curve, see if it is s
table | 138 // if the vector was a result of subdividing a curve, see if it is s
table |
136 bool sloppy1 = x_ry < rx_y; | 139 bool sloppy1 = x_ry < rx_y; |
137 bool sloppy2 = !sloppy1; | 140 bool sloppy2 = !sloppy1; |
138 if ((!fComputed || calcSlop(x, y, rx, ry, &sloppy1)) | 141 if ((!fComputed || calcSlop(x, y, rx, ry, &sloppy1)) |
139 && (!rh.fComputed || rh.calcSlop(rx, ry, x, y, &sloppy2)) | 142 && (!rh.fComputed || rh.calcSlop(rx, ry, x, y, &sloppy2)) |
140 && sloppy1 != sloppy2) { | 143 && sloppy1 != sloppy2) { |
141 return COMPARE_RESULT("8 CalcSlop(x, y ...", sloppy1); | 144 return COMPARE_RESULT("8 CalcSlop(x, y ...", sloppy1); |
142 } | 145 } |
143 } | 146 } |
144 } | 147 } |
145 if (fSide2 * rh.fSide2 == 0) { | 148 if (fSide2 * rh.fSide2 == 0) { // one is zero |
146 // SkASSERT(fSide2 + rh.fSide2 != 0); // hitting this assert means coinci
dence was undetected | 149 #if DEBUG_ANGLE |
| 150 if (fSide2 == rh.fSide2 && y_ry) { // both is zero; coincidence was und
etected |
| 151 SkDebugf("%s coincidence!\n", __FUNCTION__); |
| 152 } |
| 153 #endif |
147 return COMPARE_RESULT("9a fSide2 * rh.fSide2 == 0 ...", fSide2 < rh.fSid
e2); | 154 return COMPARE_RESULT("9a fSide2 * rh.fSide2 == 0 ...", fSide2 < rh.fSid
e2); |
148 } | 155 } |
149 // at this point, the initial tangent line is nearly coincident | 156 // at this point, the initial tangent line is nearly coincident |
150 // see if edges curl away from each other | 157 // see if edges curl away from each other |
151 if (fSide * rh.fSide < 0 && (!approximately_zero(fSide) || !approximately_ze
ro(rh.fSide))) { | 158 if (fSide * rh.fSide < 0 && (!approximately_zero(fSide) || !approximately_ze
ro(rh.fSide))) { |
152 return COMPARE_RESULT("9b fSide * rh.fSide < 0 ...", fSide < rh.fSide); | 159 return COMPARE_RESULT("9b fSide * rh.fSide < 0 ...", fSide < rh.fSide); |
153 } | 160 } |
154 if (fUnsortable || rh.fUnsortable) { | 161 if (fUnsortable || rh.fUnsortable) { |
155 // even with no solution, return a stable sort | 162 // even with no solution, return a stable sort |
156 return COMPARE_RESULT("11 fUnsortable || rh.fUnsortable", this < &rh); | 163 return COMPARE_RESULT("11 fUnsortable || rh.fUnsortable", this < &rh); |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 SkPoint ePt = fSegment->xyAtT(larger); | 409 SkPoint ePt = fSegment->xyAtT(larger); |
403 SkDebugf("%s unsortable [%d] (%1.9g,%1.9g) [%d] (%1.9g,%1.9g)\n", __FUNC
TION__, | 410 SkDebugf("%s unsortable [%d] (%1.9g,%1.9g) [%d] (%1.9g,%1.9g)\n", __FUNC
TION__, |
404 smaller, iPt.fX, iPt.fY, fEnd, ePt.fX, ePt.fY); | 411 smaller, iPt.fX, iPt.fY, fEnd, ePt.fX, ePt.fY); |
405 } | 412 } |
406 #endif | 413 #endif |
407 return; | 414 return; |
408 } | 415 } |
409 | 416 |
410 #ifdef SK_DEBUG | 417 #ifdef SK_DEBUG |
411 void SkOpAngle::dump() const { | 418 void SkOpAngle::dump() const { |
412 SkDebugf("id=%d (%1.9g,%1.9g) start=%d (%1.9g) end=%d (%1.9g)\n", fSegment->
debugID(), | 419 const SkOpSpan& spanStart = fSegment->span(fStart); |
413 fSegment->xAtT(fStart), fSegment->yAtT(fStart), fStart, fSegment->sp
an(fStart).fT, | 420 const SkOpSpan& spanEnd = fSegment->span(fEnd); |
414 fEnd, fSegment->span(fEnd).fT); | 421 const SkOpSpan& spanMin = fStart < fEnd ? spanStart : spanEnd; |
| 422 SkDebugf("id=%d (%1.9g,%1.9g) start=%d (%1.9g) end=%d (%1.9g) sumWind=", |
| 423 fSegment->debugID(), fSegment->xAtT(fStart), fSegment->yAtT(fStart), |
| 424 fStart, spanStart.fT, fEnd, spanEnd.fT); |
| 425 SkPathOpsDebug::WindingPrintf(spanMin.fWindSum); |
| 426 SkDebugf(" oppWind="); |
| 427 SkPathOpsDebug::WindingPrintf(spanMin.fOppSum), |
| 428 SkDebugf(" done=%d\n", spanMin.fDone); |
415 } | 429 } |
416 #endif | 430 #endif |
OLD | NEW |