Chromium Code Reviews| 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 "SkPoint.h" | 10 #include "SkPoint.h" |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 161 | 161 |
| 162 float scale; | 162 float scale; |
| 163 if (SkScalarIsFinite(mag2)) { | 163 if (SkScalarIsFinite(mag2)) { |
| 164 scale = length / sk_float_sqrt(mag2); | 164 scale = length / sk_float_sqrt(mag2); |
| 165 } else { | 165 } else { |
| 166 // our mag2 step overflowed to infinity, so use doubles instead. | 166 // our mag2 step overflowed to infinity, so use doubles instead. |
| 167 // much slower, but needed when x or y are very large, other wise we | 167 // much slower, but needed when x or y are very large, other wise we |
| 168 // divide by inf. and return (0,0) vector. | 168 // divide by inf. and return (0,0) vector. |
| 169 double xx = x; | 169 double xx = x; |
| 170 double yy = y; | 170 double yy = y; |
| 171 #ifdef SK_BUILD_FOR_IOS | |
| 172 double dscale = length / sqrt(xx * xx + yy * yy); | |
|
reed1
2014/07/10 18:39:39
Can we add a comment and/or bug/test ref to explai
caryclark
2014/07/10 21:07:03
Done.
| |
| 173 fX = x * dscale; | |
| 174 fY = y * dscale; | |
| 175 return true; | |
| 176 #else | |
| 171 scale = (float)(length / sqrt(xx * xx + yy * yy)); | 177 scale = (float)(length / sqrt(xx * xx + yy * yy)); |
| 178 #endif | |
| 172 } | 179 } |
| 173 fX = x * scale; | 180 fX = x * scale; |
| 174 fY = y * scale; | 181 fY = y * scale; |
| 175 return true; | 182 return true; |
| 176 } | 183 } |
| 177 | 184 |
| 178 bool SkPoint::setLengthFast(float length) { | 185 bool SkPoint::setLengthFast(float length) { |
| 179 return this->setLengthFast(fX, fY, length); | 186 return this->setLengthFast(fX, fY, length); |
| 180 } | 187 } |
| 181 | 188 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 248 | 255 |
| 249 if (uDotV <= 0) { | 256 if (uDotV <= 0) { |
| 250 return v.lengthSqd(); | 257 return v.lengthSqd(); |
| 251 } else if (uDotV > uLengthSqd) { | 258 } else if (uDotV > uLengthSqd) { |
| 252 return b.distanceToSqd(*this); | 259 return b.distanceToSqd(*this); |
| 253 } else { | 260 } else { |
| 254 SkScalar det = u.cross(v); | 261 SkScalar det = u.cross(v); |
| 255 return SkScalarMulDiv(det, det, uLengthSqd); | 262 return SkScalarMulDiv(det, det, uLengthSqd); |
| 256 } | 263 } |
| 257 } | 264 } |
| OLD | NEW |