| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
| 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 | 7 |
| 8 #include "SkGeometry.h" | 8 #include "SkGeometry.h" |
| 9 #include "SkMatrix.h" | 9 #include "SkMatrix.h" |
| 10 | 10 |
| (...skipping 986 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 997 if (SkXRayCrossesMonotonicCubic(pt, | 997 if (SkXRayCrossesMonotonicCubic(pt, |
| 998 &monotonic_cubics[6], | 998 &monotonic_cubics[6], |
| 999 &locally_ambiguous)) | 999 &locally_ambiguous)) |
| 1000 ++num_crossings; | 1000 ++num_crossings; |
| 1001 if (ambiguous) { | 1001 if (ambiguous) { |
| 1002 *ambiguous |= locally_ambiguous; | 1002 *ambiguous |= locally_ambiguous; |
| 1003 } | 1003 } |
| 1004 return num_crossings; | 1004 return num_crossings; |
| 1005 } | 1005 } |
| 1006 | 1006 |
| 1007 /** |
| 1008 * Calculate the approximate arc length given a bezier curve's control points. |
| 1009 */ |
| 1010 SkScalar approx_arc_length(SkPoint* points, int count) { |
| 1011 if (count < 2) { |
| 1012 return 0; |
| 1013 } |
| 1014 SkScalar arcLength = 0; |
| 1015 for (int i = 0; i < count - 1; i++) { |
| 1016 arcLength += SkPoint::Distance(points[i], points[i + 1]); |
| 1017 } |
| 1018 return arcLength; |
| 1019 } |
| 1020 |
| 1007 /////////////////////////////////////////////////////////////////////////////// | 1021 /////////////////////////////////////////////////////////////////////////////// |
| 1008 | 1022 |
| 1009 /* Find t value for quadratic [a, b, c] = d. | 1023 /* Find t value for quadratic [a, b, c] = d. |
| 1010 Return 0 if there is no solution within [0, 1) | 1024 Return 0 if there is no solution within [0, 1) |
| 1011 */ | 1025 */ |
| 1012 static SkScalar quad_solve(SkScalar a, SkScalar b, SkScalar c, SkScalar d) { | 1026 static SkScalar quad_solve(SkScalar a, SkScalar b, SkScalar c, SkScalar d) { |
| 1013 // At^2 + Bt + C = d | 1027 // At^2 + Bt + C = d |
| 1014 SkScalar A = a - 2 * b + c; | 1028 SkScalar A = a - 2 * b + c; |
| 1015 SkScalar B = 2 * (b - a); | 1029 SkScalar B = 2 * (b - a); |
| 1016 SkScalar C = a - d; | 1030 SkScalar C = a - d; |
| (...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1459 } | 1473 } |
| 1460 | 1474 |
| 1461 void SkConic::computeFastBounds(SkRect* bounds) const { | 1475 void SkConic::computeFastBounds(SkRect* bounds) const { |
| 1462 bounds->set(fPts, 3); | 1476 bounds->set(fPts, 3); |
| 1463 } | 1477 } |
| 1464 | 1478 |
| 1465 bool SkConic::findMaxCurvature(SkScalar* t) const { | 1479 bool SkConic::findMaxCurvature(SkScalar* t) const { |
| 1466 // TODO: Implement me | 1480 // TODO: Implement me |
| 1467 return false; | 1481 return false; |
| 1468 } | 1482 } |
| OLD | NEW |