OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2008 The Android Open Source Project | 3 * Copyright 2008 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #include "SkMathPriv.h" | 10 #include "SkMathPriv.h" |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 | 154 |
155 float scale; | 155 float scale; |
156 if (SkScalarIsFinite(mag2)) { | 156 if (SkScalarIsFinite(mag2)) { |
157 scale = length / sk_float_sqrt(mag2); | 157 scale = length / sk_float_sqrt(mag2); |
158 } else { | 158 } else { |
159 // our mag2 step overflowed to infinity, so use doubles instead. | 159 // our mag2 step overflowed to infinity, so use doubles instead. |
160 // much slower, but needed when x or y are very large, other wise we | 160 // much slower, but needed when x or y are very large, other wise we |
161 // divide by inf. and return (0,0) vector. | 161 // divide by inf. and return (0,0) vector. |
162 double xx = x; | 162 double xx = x; |
163 double yy = y; | 163 double yy = y; |
164 #ifdef SK_DISCARD_DENORMALIZED_FOR_SPEED | 164 #ifdef SK_CPU_FLUSH_TO_ZERO |
165 // The iOS ARM processor discards small denormalized numbers to go faste
r. | 165 // The iOS ARM processor discards small denormalized numbers to go faste
r. |
166 // Casting this to a float would cause the scale to go to zero. Keeping
it | 166 // Casting this to a float would cause the scale to go to zero. Keeping
it |
167 // as a double for the multiply keeps the scale non-zero. | 167 // as a double for the multiply keeps the scale non-zero. |
168 double dscale = length / sqrt(xx * xx + yy * yy); | 168 double dscale = length / sqrt(xx * xx + yy * yy); |
169 fX = x * dscale; | 169 fX = x * dscale; |
170 fY = y * dscale; | 170 fY = y * dscale; |
171 return true; | 171 return true; |
172 #else | 172 #else |
173 scale = (float)(length / sqrt(xx * xx + yy * yy)); | 173 scale = (float)(length / sqrt(xx * xx + yy * yy)); |
174 #endif | 174 #endif |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 return v.lengthSqd(); | 256 return v.lengthSqd(); |
257 } else if (uDotV > uLengthSqd) { | 257 } else if (uDotV > uLengthSqd) { |
258 return b.distanceToSqd(*this); | 258 return b.distanceToSqd(*this); |
259 } else { | 259 } else { |
260 SkScalar det = u.cross(v); | 260 SkScalar det = u.cross(v); |
261 SkScalar temp = det / uLengthSqd; | 261 SkScalar temp = det / uLengthSqd; |
262 temp *= det; | 262 temp *= det; |
263 return temp; | 263 return temp; |
264 } | 264 } |
265 } | 265 } |
OLD | NEW |