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 #include "SkNx.h" | 10 #include "SkNx.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 | 55 |
56 if (numer < 0) { | 56 if (numer < 0) { |
57 numer = -numer; | 57 numer = -numer; |
58 denom = -denom; | 58 denom = -denom; |
59 } | 59 } |
60 | 60 |
61 if (denom == 0 || numer == 0 || numer >= denom) { | 61 if (denom == 0 || numer == 0 || numer >= denom) { |
62 return 0; | 62 return 0; |
63 } | 63 } |
64 | 64 |
65 SkScalar r = numer / denom; | 65 SkScalar r = SkScalarDiv(numer, denom); |
66 if (SkScalarIsNaN(r)) { | 66 if (SkScalarIsNaN(r)) { |
67 return 0; | 67 return 0; |
68 } | 68 } |
69 SkASSERTF(r >= 0 && r < SK_Scalar1, "numer %f, denom %f, r %f", numer, denom
, r); | 69 SkASSERTF(r >= 0 && r < SK_Scalar1, "numer %f, denom %f, r %f", numer, denom
, r); |
70 if (r == 0) { // catch underflow if numer <<<< denom | 70 if (r == 0) { // catch underflow if numer <<<< denom |
71 return 0; | 71 return 0; |
72 } | 72 } |
73 *ratio = r; | 73 *ratio = r; |
74 return 1; | 74 return 1; |
75 } | 75 } |
(...skipping 1066 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1142 SkScalar C = src[0]; | 1142 SkScalar C = src[0]; |
1143 SkScalar A = src[4] - 2 * src2w + C; | 1143 SkScalar A = src[4] - 2 * src2w + C; |
1144 SkScalar B = 2 * (src2w - C); | 1144 SkScalar B = 2 * (src2w - C); |
1145 SkScalar numer = SkScalarMulAdd(SkScalarMulAdd(A, t, B), t, C); | 1145 SkScalar numer = SkScalarMulAdd(SkScalarMulAdd(A, t, B), t, C); |
1146 | 1146 |
1147 B = 2 * (w - SK_Scalar1); | 1147 B = 2 * (w - SK_Scalar1); |
1148 C = SK_Scalar1; | 1148 C = SK_Scalar1; |
1149 A = -B; | 1149 A = -B; |
1150 SkScalar denom = SkScalarMulAdd(SkScalarMulAdd(A, t, B), t, C); | 1150 SkScalar denom = SkScalarMulAdd(SkScalarMulAdd(A, t, B), t, C); |
1151 | 1151 |
1152 return numer / denom; | 1152 return SkScalarDiv(numer, denom); |
1153 } | 1153 } |
1154 | 1154 |
1155 // F' = 2 (C t (1 + t (-1 + w)) - A (-1 + t) (t (-1 + w) - w) + B (1 - 2 t) w) | 1155 // F' = 2 (C t (1 + t (-1 + w)) - A (-1 + t) (t (-1 + w) - w) + B (1 - 2 t) w) |
1156 // | 1156 // |
1157 // t^2 : (2 P0 - 2 P2 - 2 P0 w + 2 P2 w) | 1157 // t^2 : (2 P0 - 2 P2 - 2 P0 w + 2 P2 w) |
1158 // t^1 : (-2 P0 + 2 P2 + 4 P0 w - 4 P1 w) | 1158 // t^1 : (-2 P0 + 2 P2 + 4 P0 w - 4 P1 w) |
1159 // t^0 : -2 P0 w + 2 P1 w | 1159 // t^0 : -2 P0 w + 2 P1 w |
1160 // | 1160 // |
1161 // We disregard magnitude, so we can freely ignore the denominator of F', and | 1161 // We disregard magnitude, so we can freely ignore the denominator of F', and |
1162 // divide the numerator by 2 | 1162 // divide the numerator by 2 |
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1577 matrix.preScale(SK_Scalar1, -SK_Scalar1); | 1577 matrix.preScale(SK_Scalar1, -SK_Scalar1); |
1578 } | 1578 } |
1579 if (userMatrix) { | 1579 if (userMatrix) { |
1580 matrix.postConcat(*userMatrix); | 1580 matrix.postConcat(*userMatrix); |
1581 } | 1581 } |
1582 for (int i = 0; i < conicCount; ++i) { | 1582 for (int i = 0; i < conicCount; ++i) { |
1583 matrix.mapPoints(dst[i].fPts, 3); | 1583 matrix.mapPoints(dst[i].fPts, 3); |
1584 } | 1584 } |
1585 return conicCount; | 1585 return conicCount; |
1586 } | 1586 } |
OLD | NEW |