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 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 for (int cIndex = 0; cIndex < 4; cIndex += 3) { | 208 for (int cIndex = 0; cIndex < 4; cIndex += 3) { |
209 double lineT = fLine.exactPoint(fCubic[cIndex]); | 209 double lineT = fLine.exactPoint(fCubic[cIndex]); |
210 if (lineT < 0) { | 210 if (lineT < 0) { |
211 continue; | 211 continue; |
212 } | 212 } |
213 double cubicT = (double) (cIndex >> 1); | 213 double cubicT = (double) (cIndex >> 1); |
214 fIntersections->insert(cubicT, lineT, fCubic[cIndex]); | 214 fIntersections->insert(cubicT, lineT, fCubic[cIndex]); |
215 } | 215 } |
216 } | 216 } |
217 | 217 |
| 218 /* Note that this does not look for endpoints of the line that are near the
cubic. |
| 219 These points are found later when check ends looks for missing points */ |
218 void addNearEndPoints() { | 220 void addNearEndPoints() { |
219 for (int cIndex = 0; cIndex < 4; cIndex += 3) { | 221 for (int cIndex = 0; cIndex < 4; cIndex += 3) { |
220 double cubicT = (double) (cIndex >> 1); | 222 double cubicT = (double) (cIndex >> 1); |
221 if (fIntersections->hasT(cubicT)) { | 223 if (fIntersections->hasT(cubicT)) { |
222 continue; | 224 continue; |
223 } | 225 } |
224 double lineT = fLine.nearPoint(fCubic[cIndex]); | 226 double lineT = fLine.nearPoint(fCubic[cIndex]); |
225 if (lineT < 0) { | 227 if (lineT < 0) { |
226 continue; | 228 continue; |
227 } | 229 } |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 } | 349 } |
348 | 350 |
349 int SkIntersections::intersectRay(const SkDCubic& cubic, const SkDLine& line) { | 351 int SkIntersections::intersectRay(const SkDCubic& cubic, const SkDLine& line) { |
350 LineCubicIntersections c(cubic, line, this); | 352 LineCubicIntersections c(cubic, line, this); |
351 fUsed = c.intersectRay(fT[0]); | 353 fUsed = c.intersectRay(fT[0]); |
352 for (int index = 0; index < fUsed; ++index) { | 354 for (int index = 0; index < fUsed; ++index) { |
353 fPt[index] = cubic.ptAtT(fT[0][index]); | 355 fPt[index] = cubic.ptAtT(fT[0][index]); |
354 } | 356 } |
355 return fUsed; | 357 return fUsed; |
356 } | 358 } |
OLD | NEW |