| 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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 rroots = (ri.*CurveRay[SkPathOpsVerbToPoints(rVerb)])(rh.fSegment->pts()
, ray); | 200 rroots = (ri.*CurveRay[SkPathOpsVerbToPoints(rVerb)])(rh.fSegment->pts()
, ray); |
| 201 } while ((roots == 0 || rroots == 0) && (flip ^= true)); | 201 } while ((roots == 0 || rroots == 0) && (flip ^= true)); |
| 202 if (roots == 0 || rroots == 0) { | 202 if (roots == 0 || rroots == 0) { |
| 203 // FIXME: we don't have a solution in this case. The interim solution | 203 // FIXME: we don't have a solution in this case. The interim solution |
| 204 // is to mark the edges as unsortable, exclude them from this and | 204 // is to mark the edges as unsortable, exclude them from this and |
| 205 // future computations, and allow the returned path to be fragmented | 205 // future computations, and allow the returned path to be fragmented |
| 206 fUnsortable = true; | 206 fUnsortable = true; |
| 207 return COMPARE_RESULT("roots == 0 || rroots == 0", this < &rh); | 207 return COMPARE_RESULT("roots == 0 || rroots == 0", this < &rh); |
| 208 } | 208 } |
| 209 SkASSERT(fSide != 0 && rh.fSide != 0); | 209 SkASSERT(fSide != 0 && rh.fSide != 0); |
| 210 SkASSERT(fSide * rh.fSide > 0); // both are the same sign | 210 if (fSide * rh.fSide < 0) { |
| 211 fUnsortable = true; |
| 212 return COMPARE_RESULT("14 fSide * rh.fSide < 0", this < &rh); |
| 213 } |
| 211 SkDPoint lLoc; | 214 SkDPoint lLoc; |
| 212 double best = SK_ScalarInfinity; | 215 double best = SK_ScalarInfinity; |
| 213 #if DEBUG_SORT | 216 #if DEBUG_SORT |
| 214 SkDebugf("lh=%d rh=%d use-lh=%d ray={{%1.9g,%1.9g}, {%1.9g,%1.9g}} %c\n", | 217 SkDebugf("lh=%d rh=%d use-lh=%d ray={{%1.9g,%1.9g}, {%1.9g,%1.9g}} %c\n", |
| 215 fSegment->debugID(), rh.fSegment->debugID(), useThis, ray[0].fX, ray
[0].fY, | 218 fSegment->debugID(), rh.fSegment->debugID(), useThis, ray[0].fX, ray
[0].fY, |
| 216 ray[1].fX, ray[1].fY, "-+"[fSide > 0]); | 219 ray[1].fX, ray[1].fY, "-+"[fSide > 0]); |
| 217 #endif | 220 #endif |
| 218 for (int index = 0; index < roots; ++index) { | 221 for (int index = 0; index < roots; ++index) { |
| 219 SkDPoint loc = i.pt(index); | 222 SkDPoint loc = i.pt(index); |
| 220 SkDVector dxy = loc - ray[0]; | 223 SkDVector dxy = loc - ray[0]; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 239 best, dist, "><"[fSide < 0], rLoc.fX, rLoc.fY, dxy.fX, dxy.fY); | 242 best, dist, "><"[fSide < 0], rLoc.fX, rLoc.fY, dxy.fX, dxy.fY); |
| 240 #endif | 243 #endif |
| 241 if (best > dist) { | 244 if (best > dist) { |
| 242 flip = true; | 245 flip = true; |
| 243 break; | 246 break; |
| 244 } | 247 } |
| 245 } | 248 } |
| 246 if (flip) { | 249 if (flip) { |
| 247 leftLessThanRight = !leftLessThanRight; | 250 leftLessThanRight = !leftLessThanRight; |
| 248 } | 251 } |
| 249 return COMPARE_RESULT("14 leftLessThanRight", leftLessThanRight); | 252 return COMPARE_RESULT("15 leftLessThanRight", leftLessThanRight); |
| 250 } | 253 } |
| 251 | 254 |
| 252 bool SkOpAngle::isHorizontal() const { | 255 bool SkOpAngle::isHorizontal() const { |
| 253 return dy() == 0 && fSegment->verb() == SkPath::kLine_Verb; | 256 return dy() == 0 && fSegment->verb() == SkPath::kLine_Verb; |
| 254 } | 257 } |
| 255 | 258 |
| 256 // lengthen cannot cross opposite angle | 259 // lengthen cannot cross opposite angle |
| 257 bool SkOpAngle::lengthen(const SkOpAngle& opp) { | 260 bool SkOpAngle::lengthen(const SkOpAngle& opp) { |
| 258 if (fSegment->other(fEnd) == opp.fSegment) { | 261 if (fSegment->other(fEnd) == opp.fSegment) { |
| 259 return false; | 262 return false; |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 const SkOpSpan& spanMin = fStart < fEnd ? spanStart : spanEnd; | 424 const SkOpSpan& spanMin = fStart < fEnd ? spanStart : spanEnd; |
| 422 SkDebugf("id=%d (%1.9g,%1.9g) start=%d (%1.9g) end=%d (%1.9g) sumWind=", | 425 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), | 426 fSegment->debugID(), fSegment->xAtT(fStart), fSegment->yAtT(fStart), |
| 424 fStart, spanStart.fT, fEnd, spanEnd.fT); | 427 fStart, spanStart.fT, fEnd, spanEnd.fT); |
| 425 SkPathOpsDebug::WindingPrintf(spanMin.fWindSum); | 428 SkPathOpsDebug::WindingPrintf(spanMin.fWindSum); |
| 426 SkDebugf(" oppWind="); | 429 SkDebugf(" oppWind="); |
| 427 SkPathOpsDebug::WindingPrintf(spanMin.fOppSum), | 430 SkPathOpsDebug::WindingPrintf(spanMin.fOppSum), |
| 428 SkDebugf(" done=%d\n", spanMin.fDone); | 431 SkDebugf(" done=%d\n", spanMin.fDone); |
| 429 } | 432 } |
| 430 #endif | 433 #endif |
| OLD | NEW |