OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 | 7 |
8 #include "GrPathUtils.h" | 8 #include "GrPathUtils.h" |
9 | 9 |
10 #include "GrPoint.h" | 10 #include "GrPoint.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 SkASSERT(tol > 0); | 44 SkASSERT(tol > 0); |
45 | 45 |
46 SkScalar d = points[1].distanceToLineSegmentBetween(points[0], points[2]); | 46 SkScalar d = points[1].distanceToLineSegmentBetween(points[0], points[2]); |
47 if (d <= tol) { | 47 if (d <= tol) { |
48 return 1; | 48 return 1; |
49 } else { | 49 } else { |
50 // Each time we subdivide, d should be cut in 4. So we need to | 50 // Each time we subdivide, d should be cut in 4. So we need to |
51 // subdivide x = log4(d/tol) times. x subdivisions creates 2^(x) | 51 // subdivide x = log4(d/tol) times. x subdivisions creates 2^(x) |
52 // points. | 52 // points. |
53 // 2^(log4(x)) = sqrt(x); | 53 // 2^(log4(x)) = sqrt(x); |
54 int temp = SkScalarCeil(SkScalarSqrt(SkScalarDiv(d, tol))); | 54 int temp = SkScalarCeilToInt(SkScalarSqrt(SkScalarDiv(d, tol))); |
55 int pow2 = GrNextPow2(temp); | 55 int pow2 = GrNextPow2(temp); |
56 // Because of NaNs & INFs we can wind up with a degenerate temp | 56 // Because of NaNs & INFs we can wind up with a degenerate temp |
57 // such that pow2 comes out negative. Also, our point generator | 57 // such that pow2 comes out negative. Also, our point generator |
58 // will always output at least one pt. | 58 // will always output at least one pt. |
59 if (pow2 < 1) { | 59 if (pow2 < 1) { |
60 pow2 = 1; | 60 pow2 = 1; |
61 } | 61 } |
62 return GrMin(pow2, MAX_POINTS_PER_CURVE); | 62 return GrMin(pow2, MAX_POINTS_PER_CURVE); |
63 } | 63 } |
64 } | 64 } |
(...skipping 30 matching lines...) Expand all Loading... |
95 } | 95 } |
96 SkASSERT(tol > 0); | 96 SkASSERT(tol > 0); |
97 | 97 |
98 SkScalar d = GrMax( | 98 SkScalar d = GrMax( |
99 points[1].distanceToLineSegmentBetweenSqd(points[0], points[3]), | 99 points[1].distanceToLineSegmentBetweenSqd(points[0], points[3]), |
100 points[2].distanceToLineSegmentBetweenSqd(points[0], points[3])); | 100 points[2].distanceToLineSegmentBetweenSqd(points[0], points[3])); |
101 d = SkScalarSqrt(d); | 101 d = SkScalarSqrt(d); |
102 if (d <= tol) { | 102 if (d <= tol) { |
103 return 1; | 103 return 1; |
104 } else { | 104 } else { |
105 int temp = SkScalarCeil(SkScalarSqrt(SkScalarDiv(d, tol))); | 105 int temp = SkScalarCeilToInt(SkScalarSqrt(SkScalarDiv(d, tol))); |
106 int pow2 = GrNextPow2(temp); | 106 int pow2 = GrNextPow2(temp); |
107 // Because of NaNs & INFs we can wind up with a degenerate temp | 107 // Because of NaNs & INFs we can wind up with a degenerate temp |
108 // such that pow2 comes out negative. Also, our point generator | 108 // such that pow2 comes out negative. Also, our point generator |
109 // will always output at least one pt. | 109 // will always output at least one pt. |
110 if (pow2 < 1) { | 110 if (pow2 < 1) { |
111 pow2 = 1; | 111 pow2 = 1; |
112 } | 112 } |
113 return GrMin(pow2, MAX_POINTS_PER_CURVE); | 113 return GrMin(pow2, MAX_POINTS_PER_CURVE); |
114 } | 114 } |
115 } | 115 } |
(...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
859 set_loop_klm(d, controlK, controlL, controlM); | 859 set_loop_klm(d, controlK, controlL, controlM); |
860 } else if (kCusp_CubicType == cType) { | 860 } else if (kCusp_CubicType == cType) { |
861 SkASSERT(0.f == d[0]); | 861 SkASSERT(0.f == d[0]); |
862 set_cusp_klm(d, controlK, controlL, controlM); | 862 set_cusp_klm(d, controlK, controlL, controlM); |
863 } else if (kQuadratic_CubicType == cType) { | 863 } else if (kQuadratic_CubicType == cType) { |
864 set_quadratic_klm(d, controlK, controlL, controlM); | 864 set_quadratic_klm(d, controlK, controlL, controlM); |
865 } | 865 } |
866 | 866 |
867 calc_cubic_klm(p, controlK, controlL, controlM, klm, &klm[3], &klm[6]); | 867 calc_cubic_klm(p, controlK, controlL, controlM, klm, &klm[3], &klm[6]); |
868 } | 868 } |
OLD | NEW |