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

Side by Side Diff: Source/wtf/MathExtras.h

Issue 303263008: [SVG2] Add support for the 'turn' unit in <angle>. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: fix nits Created 6 years, 6 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
« no previous file with comments | « Source/core/svg/SVGAngleTearOff.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 #endif // COMPILER(MSVC) 201 #endif // COMPILER(MSVC)
202 202
203 inline double deg2rad(double d) { return d * piDouble / 180.0; } 203 inline double deg2rad(double d) { return d * piDouble / 180.0; }
204 inline double rad2deg(double r) { return r * 180.0 / piDouble; } 204 inline double rad2deg(double r) { return r * 180.0 / piDouble; }
205 inline double deg2grad(double d) { return d * 400.0 / 360.0; } 205 inline double deg2grad(double d) { return d * 400.0 / 360.0; }
206 inline double grad2deg(double g) { return g * 360.0 / 400.0; } 206 inline double grad2deg(double g) { return g * 360.0 / 400.0; }
207 inline double turn2deg(double t) { return t * 360.0; } 207 inline double turn2deg(double t) { return t * 360.0; }
208 inline double deg2turn(double d) { return d / 360.0; } 208 inline double deg2turn(double d) { return d / 360.0; }
209 inline double rad2grad(double r) { return r * 200.0 / piDouble; } 209 inline double rad2grad(double r) { return r * 200.0 / piDouble; }
210 inline double grad2rad(double g) { return g * piDouble / 200.0; } 210 inline double grad2rad(double g) { return g * piDouble / 200.0; }
211 inline double turn2grad(double t) { return t * 400.0; }
tkent 2014/06/12 00:18:26 No need to add .0 http://dev.chromium.org/blink/co
212 inline double grad2turn(double g) { return g / 400.f; }
tkent 2014/06/12 00:18:26 No need to add .f
211 213
212 inline float deg2rad(float d) { return d * piFloat / 180.0f; } 214 inline float deg2rad(float d) { return d * piFloat / 180.0f; }
213 inline float rad2deg(float r) { return r * 180.0f / piFloat; } 215 inline float rad2deg(float r) { return r * 180.0f / piFloat; }
214 inline float deg2grad(float d) { return d * 400.0f / 360.0f; } 216 inline float deg2grad(float d) { return d * 400.0f / 360.0f; }
215 inline float grad2deg(float g) { return g * 360.0f / 400.0f; } 217 inline float grad2deg(float g) { return g * 360.0f / 400.0f; }
216 inline float turn2deg(float t) { return t * 360.0f; } 218 inline float turn2deg(float t) { return t * 360.0f; }
217 inline float deg2turn(float d) { return d / 360.0f; } 219 inline float deg2turn(float d) { return d / 360.0f; }
218 inline float rad2grad(float r) { return r * 200.0f / piFloat; } 220 inline float rad2grad(float r) { return r * 200.0f / piFloat; }
219 inline float grad2rad(float g) { return g * piFloat / 200.0f; } 221 inline float grad2rad(float g) { return g * piFloat / 200.0f; }
222 inline float turn2grad(float t) { return t * 400.0f; }
tkent 2014/06/12 00:18:26 No need to add .0f
223 inline float grad2turn(float g) { return g / 400.f; }
tkent 2014/06/12 00:18:26 No need to add .f
220 224
221 // std::numeric_limits<T>::min() returns the smallest positive value for floatin g point types 225 // std::numeric_limits<T>::min() returns the smallest positive value for floatin g point types
222 template<typename T> inline T defaultMinimumForClamp() { return std::numeric_lim its<T>::min(); } 226 template<typename T> inline T defaultMinimumForClamp() { return std::numeric_lim its<T>::min(); }
223 template<> inline float defaultMinimumForClamp() { return -std::numeric_limits<f loat>::max(); } 227 template<> inline float defaultMinimumForClamp() { return -std::numeric_limits<f loat>::max(); }
224 template<> inline double defaultMinimumForClamp() { return -std::numeric_limits< double>::max(); } 228 template<> inline double defaultMinimumForClamp() { return -std::numeric_limits< double>::max(); }
225 template<typename T> inline T defaultMaximumForClamp() { return std::numeric_lim its<T>::max(); } 229 template<typename T> inline T defaultMaximumForClamp() { return std::numeric_lim its<T>::max(); }
226 230
227 template<typename T> inline T clampTo(double value, T min = defaultMinimumForCla mp<T>(), T max = defaultMaximumForClamp<T>()) 231 template<typename T> inline T clampTo(double value, T min = defaultMinimumForCla mp<T>(), T max = defaultMaximumForClamp<T>())
228 { 232 {
229 if (value >= static_cast<double>(max)) 233 if (value >= static_cast<double>(max))
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 if (i >> 2) 334 if (i >> 2)
331 log2 += 2, i >>= 2; 335 log2 += 2, i >>= 2;
332 if (i >> 1) 336 if (i >> 1)
333 log2 += 1; 337 log2 += 1;
334 return log2; 338 return log2;
335 } 339 }
336 340
337 } // namespace WTF 341 } // namespace WTF
338 342
339 #endif // #ifndef WTF_MathExtras_h 343 #endif // #ifndef WTF_MathExtras_h
OLDNEW
« no previous file with comments | « Source/core/svg/SVGAngleTearOff.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698