Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(143)

Side by Side Diff: src/core/SkPoint.cpp

Issue 373383003: ios fixes (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: give shell its own gyp file Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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_FAST_UNDERFLOW_BEHAVIOR
172 // The iOS ARM processor discards small denormalized numbers to go faste r.
reed1 2014/07/10 21:40:05 I think this comment belongs in SkMathPriv.h or wh
caryclark 2014/07/11 12:57:19 Done.
173 // Casting this to a float would cause the scale to go to zero. Keeping it
174 // as a double for the multipy keeps the scale non-zero.
175 double dscale = length / sqrt(xx * xx + yy * yy);
176 fX = x * dscale;
177 fY = y * dscale;
178 return true;
179 #else
171 scale = (float)(length / sqrt(xx * xx + yy * yy)); 180 scale = (float)(length / sqrt(xx * xx + yy * yy));
181 #endif
172 } 182 }
173 fX = x * scale; 183 fX = x * scale;
174 fY = y * scale; 184 fY = y * scale;
175 return true; 185 return true;
176 } 186 }
177 187
178 bool SkPoint::setLengthFast(float length) { 188 bool SkPoint::setLengthFast(float length) {
179 return this->setLengthFast(fX, fY, length); 189 return this->setLengthFast(fX, fY, length);
180 } 190 }
181 191
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 258
249 if (uDotV <= 0) { 259 if (uDotV <= 0) {
250 return v.lengthSqd(); 260 return v.lengthSqd();
251 } else if (uDotV > uLengthSqd) { 261 } else if (uDotV > uLengthSqd) {
252 return b.distanceToSqd(*this); 262 return b.distanceToSqd(*this);
253 } else { 263 } else {
254 SkScalar det = u.cross(v); 264 SkScalar det = u.cross(v);
255 return SkScalarMulDiv(det, det, uLengthSqd); 265 return SkScalarMulDiv(det, det, uLengthSqd);
256 } 266 }
257 } 267 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698