OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CC_BASE_MATH_UTIL_H_ | 5 #ifndef CC_BASE_MATH_UTIL_H_ |
6 #define CC_BASE_MATH_UTIL_H_ | 6 #define CC_BASE_MATH_UTIL_H_ |
7 | 7 |
8 #include <algorithm> | 8 #include <algorithm> |
9 #include <cmath> | 9 #include <cmath> |
10 #include <memory> | 10 #include <memory> |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 // If the value is inf, returns max double/float representation. | 303 // If the value is inf, returns max double/float representation. |
304 static double AsDoubleSafely(double value); | 304 static double AsDoubleSafely(double value); |
305 static float AsFloatSafely(float value); | 305 static float AsFloatSafely(float value); |
306 | 306 |
307 // Returns vector that x axis (1,0,0) transforms to under given transform. | 307 // Returns vector that x axis (1,0,0) transforms to under given transform. |
308 static gfx::Vector3dF GetXAxis(const gfx::Transform& transform); | 308 static gfx::Vector3dF GetXAxis(const gfx::Transform& transform); |
309 | 309 |
310 // Returns vector that y axis (0,1,0) transforms to under given transform. | 310 // Returns vector that y axis (0,1,0) transforms to under given transform. |
311 static gfx::Vector3dF GetYAxis(const gfx::Transform& transform); | 311 static gfx::Vector3dF GetYAxis(const gfx::Transform& transform); |
312 | 312 |
| 313 static bool IsNearlyTheSameForTesting(float left, float right); |
| 314 static bool IsNearlyTheSameForTesting(const gfx::PointF& l, |
| 315 const gfx::PointF& r); |
| 316 static bool IsNearlyTheSameForTesting(const gfx::Point3F& l, |
| 317 const gfx::Point3F& r); |
| 318 |
313 private: | 319 private: |
314 template <typename T> | 320 template <typename T> |
315 static T RoundUpInternal(T n, T mul) { | 321 static T RoundUpInternal(T n, T mul) { |
316 return (n > 0) ? ((n + mul - 1) / mul) * mul : (n / mul) * mul; | 322 return (n > 0) ? ((n + mul - 1) / mul) * mul : (n / mul) * mul; |
317 } | 323 } |
318 | 324 |
319 template <typename T> | 325 template <typename T> |
320 static T RoundDownInternal(T n, T mul) { | 326 static T RoundDownInternal(T n, T mul) { |
321 return (n > 0) ? (n / mul) * mul : (n == 0) ? 0 | 327 return (n > 0) ? (n / mul) * mul : (n == 0) ? 0 |
322 : ((n - mul + 1) / mul) * mul; | 328 : ((n - mul + 1) / mul) * mul; |
323 } | 329 } |
324 }; | 330 }; |
325 | 331 |
326 class ScopedSubnormalFloatDisabler { | 332 class ScopedSubnormalFloatDisabler { |
327 public: | 333 public: |
328 ScopedSubnormalFloatDisabler(); | 334 ScopedSubnormalFloatDisabler(); |
329 ~ScopedSubnormalFloatDisabler(); | 335 ~ScopedSubnormalFloatDisabler(); |
330 | 336 |
331 private: | 337 private: |
332 #ifdef __SSE__ | 338 #ifdef __SSE__ |
333 unsigned int orig_state_; | 339 unsigned int orig_state_; |
334 #endif | 340 #endif |
335 DISALLOW_COPY_AND_ASSIGN(ScopedSubnormalFloatDisabler); | 341 DISALLOW_COPY_AND_ASSIGN(ScopedSubnormalFloatDisabler); |
336 }; | 342 }; |
337 | 343 |
338 } // namespace cc | 344 } // namespace cc |
339 | 345 |
340 #endif // CC_BASE_MATH_UTIL_H_ | 346 #endif // CC_BASE_MATH_UTIL_H_ |
OLD | NEW |