| 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 "SkPathOpsCubic.h" | 8 #include "SkPathOpsCubic.h" | 
| 9 #include "SkPathOpsLine.h" | 9 #include "SkPathOpsLine.h" | 
| 10 | 10 | 
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 128         SkDCubic::Coefficients(&c[0].fX, &A, &B, &C, &D); | 128         SkDCubic::Coefficients(&c[0].fX, &A, &B, &C, &D); | 
| 129         int count = SkDCubic::RootsValidT(A, B, C, D, roots); | 129         int count = SkDCubic::RootsValidT(A, B, C, D, roots); | 
| 130         for (int index = 0; index < count; ++index) { | 130         for (int index = 0; index < count; ++index) { | 
| 131             SkDPoint calcPt = c.ptAtT(roots[index]); | 131             SkDPoint calcPt = c.ptAtT(roots[index]); | 
| 132             if (!approximately_zero(calcPt.fX)) { | 132             if (!approximately_zero(calcPt.fX)) { | 
| 133                 for (int n = 0; n < 4; ++n) { | 133                 for (int n = 0; n < 4; ++n) { | 
| 134                     c[n].fY = (fCubic[n].fY - fLine[0].fY) * opp | 134                     c[n].fY = (fCubic[n].fY - fLine[0].fY) * opp | 
| 135                             + (fCubic[n].fX - fLine[0].fX) * adj; | 135                             + (fCubic[n].fX - fLine[0].fX) * adj; | 
| 136                 } | 136                 } | 
| 137                 double extremeTs[6]; | 137                 double extremeTs[6]; | 
| 138                 int extrema = SkDCubic::FindExtrema(c[0].fX, c[1].fX, c[2].fX, c
     [3].fX, extremeTs); | 138                 int extrema = SkDCubic::FindExtrema(&c[0].fX, extremeTs); | 
| 139                 count = c.searchRoots(extremeTs, extrema, 0, SkDCubic::kXAxis, r
     oots); | 139                 count = c.searchRoots(extremeTs, extrema, 0, SkDCubic::kXAxis, r
     oots); | 
| 140                 break; | 140                 break; | 
| 141             } | 141             } | 
| 142         } | 142         } | 
| 143         return count; | 143         return count; | 
| 144     } | 144     } | 
| 145 | 145 | 
| 146     int intersect() { | 146     int intersect() { | 
| 147         addExactEndPoints(); | 147         addExactEndPoints(); | 
| 148         if (fAllowNear) { | 148         if (fAllowNear) { | 
| (...skipping 15 matching lines...) Expand all  Loading... | 
| 164 | 164 | 
| 165     static int HorizontalIntersect(const SkDCubic& c, double axisIntercept, doub
     le roots[3]) { | 165     static int HorizontalIntersect(const SkDCubic& c, double axisIntercept, doub
     le roots[3]) { | 
| 166         double A, B, C, D; | 166         double A, B, C, D; | 
| 167         SkDCubic::Coefficients(&c[0].fY, &A, &B, &C, &D); | 167         SkDCubic::Coefficients(&c[0].fY, &A, &B, &C, &D); | 
| 168         D -= axisIntercept; | 168         D -= axisIntercept; | 
| 169         int count = SkDCubic::RootsValidT(A, B, C, D, roots); | 169         int count = SkDCubic::RootsValidT(A, B, C, D, roots); | 
| 170         for (int index = 0; index < count; ++index) { | 170         for (int index = 0; index < count; ++index) { | 
| 171             SkDPoint calcPt = c.ptAtT(roots[index]); | 171             SkDPoint calcPt = c.ptAtT(roots[index]); | 
| 172             if (!approximately_equal(calcPt.fY, axisIntercept)) { | 172             if (!approximately_equal(calcPt.fY, axisIntercept)) { | 
| 173                 double extremeTs[6]; | 173                 double extremeTs[6]; | 
| 174                 int extrema = SkDCubic::FindExtrema(c[0].fY, c[1].fY, c[2].fY, c
     [3].fY, extremeTs); | 174                 int extrema = SkDCubic::FindExtrema(&c[0].fY, extremeTs); | 
| 175                 count = c.searchRoots(extremeTs, extrema, axisIntercept, SkDCubi
     c::kYAxis, roots); | 175                 count = c.searchRoots(extremeTs, extrema, axisIntercept, SkDCubi
     c::kYAxis, roots); | 
| 176                 break; | 176                 break; | 
| 177             } | 177             } | 
| 178         } | 178         } | 
| 179         return count; | 179         return count; | 
| 180     } | 180     } | 
| 181 | 181 | 
| 182     int horizontalIntersect(double axisIntercept, double left, double right, boo
     l flipped) { | 182     int horizontalIntersect(double axisIntercept, double left, double right, boo
     l flipped) { | 
| 183         addExactHorizontalEndPoints(left, right, axisIntercept); | 183         addExactHorizontalEndPoints(left, right, axisIntercept); | 
| 184         if (fAllowNear) { | 184         if (fAllowNear) { | 
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 227 | 227 | 
| 228     static int VerticalIntersect(const SkDCubic& c, double axisIntercept, double
      roots[3]) { | 228     static int VerticalIntersect(const SkDCubic& c, double axisIntercept, double
      roots[3]) { | 
| 229         double A, B, C, D; | 229         double A, B, C, D; | 
| 230         SkDCubic::Coefficients(&c[0].fX, &A, &B, &C, &D); | 230         SkDCubic::Coefficients(&c[0].fX, &A, &B, &C, &D); | 
| 231         D -= axisIntercept; | 231         D -= axisIntercept; | 
| 232         int count = SkDCubic::RootsValidT(A, B, C, D, roots); | 232         int count = SkDCubic::RootsValidT(A, B, C, D, roots); | 
| 233         for (int index = 0; index < count; ++index) { | 233         for (int index = 0; index < count; ++index) { | 
| 234             SkDPoint calcPt = c.ptAtT(roots[index]); | 234             SkDPoint calcPt = c.ptAtT(roots[index]); | 
| 235             if (!approximately_equal(calcPt.fX, axisIntercept)) { | 235             if (!approximately_equal(calcPt.fX, axisIntercept)) { | 
| 236                 double extremeTs[6]; | 236                 double extremeTs[6]; | 
| 237                 int extrema = SkDCubic::FindExtrema(c[0].fX, c[1].fX, c[2].fX, c
     [3].fX, extremeTs); | 237                 int extrema = SkDCubic::FindExtrema(&c[0].fX, extremeTs); | 
| 238                 count = c.searchRoots(extremeTs, extrema, axisIntercept, SkDCubi
     c::kXAxis, roots); | 238                 count = c.searchRoots(extremeTs, extrema, axisIntercept, SkDCubi
     c::kXAxis, roots); | 
| 239                 break; | 239                 break; | 
| 240             } | 240             } | 
| 241         } | 241         } | 
| 242         return count; | 242         return count; | 
| 243     } | 243     } | 
| 244 | 244 | 
| 245     int verticalIntersect(double axisIntercept, double top, double bottom, bool 
     flipped) { | 245     int verticalIntersect(double axisIntercept, double top, double bottom, bool 
     flipped) { | 
| 246         addExactVerticalEndPoints(top, bottom, axisIntercept); | 246         addExactVerticalEndPoints(top, bottom, axisIntercept); | 
| 247         if (fAllowNear) { | 247         if (fAllowNear) { | 
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 418 } | 418 } | 
| 419 | 419 | 
| 420 int SkIntersections::intersectRay(const SkDCubic& cubic, const SkDLine& line) { | 420 int SkIntersections::intersectRay(const SkDCubic& cubic, const SkDLine& line) { | 
| 421     LineCubicIntersections c(cubic, line, this); | 421     LineCubicIntersections c(cubic, line, this); | 
| 422     fUsed = c.intersectRay(fT[0]); | 422     fUsed = c.intersectRay(fT[0]); | 
| 423     for (int index = 0; index < fUsed; ++index) { | 423     for (int index = 0; index < fUsed; ++index) { | 
| 424         fPt[index] = cubic.ptAtT(fT[0][index]); | 424         fPt[index] = cubic.ptAtT(fT[0][index]); | 
| 425     } | 425     } | 
| 426     return fUsed; | 426     return fUsed; | 
| 427 } | 427 } | 
| OLD | NEW | 
|---|