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> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "cc/base/cc_export.h" | 14 #include "cc/base/base_export.h" |
15 #include "ui/gfx/geometry/box_f.h" | 15 #include "ui/gfx/geometry/box_f.h" |
16 #include "ui/gfx/geometry/point3_f.h" | 16 #include "ui/gfx/geometry/point3_f.h" |
17 #include "ui/gfx/geometry/point_f.h" | 17 #include "ui/gfx/geometry/point_f.h" |
18 #include "ui/gfx/geometry/scroll_offset.h" | 18 #include "ui/gfx/geometry/scroll_offset.h" |
19 #include "ui/gfx/geometry/size.h" | 19 #include "ui/gfx/geometry/size.h" |
20 #include "ui/gfx/transform.h" | 20 #include "ui/gfx/transform.h" |
21 | 21 |
22 namespace base { | 22 namespace base { |
23 class Value; | 23 class Value; |
24 namespace trace_event { | 24 namespace trace_event { |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 } | 72 } |
73 | 73 |
74 SkMScalar x() const { return vec[0]; } | 74 SkMScalar x() const { return vec[0]; } |
75 SkMScalar y() const { return vec[1]; } | 75 SkMScalar y() const { return vec[1]; } |
76 SkMScalar z() const { return vec[2]; } | 76 SkMScalar z() const { return vec[2]; } |
77 SkMScalar w() const { return vec[3]; } | 77 SkMScalar w() const { return vec[3]; } |
78 | 78 |
79 SkMScalar vec[4]; | 79 SkMScalar vec[4]; |
80 }; | 80 }; |
81 | 81 |
82 class CC_EXPORT MathUtil { | 82 class CC_BASE_EXPORT MathUtil { |
83 public: | 83 public: |
84 static const double kPiDouble; | 84 static const double kPiDouble; |
85 static const float kPiFloat; | 85 static const float kPiFloat; |
86 | 86 |
87 static double Deg2Rad(double deg) { return deg * kPiDouble / 180.0; } | 87 static double Deg2Rad(double deg) { return deg * kPiDouble / 180.0; } |
88 static double Rad2Deg(double rad) { return rad * 180.0 / kPiDouble; } | 88 static double Rad2Deg(double rad) { return rad * 180.0 / kPiDouble; } |
89 | 89 |
90 static float Deg2Rad(float deg) { return deg * kPiFloat / 180.0f; } | 90 static float Deg2Rad(float deg) { return deg * kPiFloat / 180.0f; } |
91 static float Rad2Deg(float rad) { return rad * 180.0f / kPiFloat; } | 91 static float Rad2Deg(float rad) { return rad * 180.0f / kPiFloat; } |
92 | 92 |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 return (n > 0) ? ((n + mul - 1) / mul) * mul : (n / mul) * mul; | 318 return (n > 0) ? ((n + mul - 1) / mul) * mul : (n / mul) * mul; |
319 } | 319 } |
320 | 320 |
321 template <typename T> | 321 template <typename T> |
322 static T RoundDownInternal(T n, T mul) { | 322 static T RoundDownInternal(T n, T mul) { |
323 return (n > 0) ? (n / mul) * mul : (n == 0) ? 0 | 323 return (n > 0) ? (n / mul) * mul : (n == 0) ? 0 |
324 : ((n - mul + 1) / mul) * mul; | 324 : ((n - mul + 1) / mul) * mul; |
325 } | 325 } |
326 }; | 326 }; |
327 | 327 |
328 class ScopedSubnormalFloatDisabler { | 328 class CC_BASE_EXPORT ScopedSubnormalFloatDisabler { |
329 public: | 329 public: |
330 ScopedSubnormalFloatDisabler(); | 330 ScopedSubnormalFloatDisabler(); |
331 ~ScopedSubnormalFloatDisabler(); | 331 ~ScopedSubnormalFloatDisabler(); |
332 | 332 |
333 private: | 333 private: |
334 #ifdef __SSE__ | 334 #ifdef __SSE__ |
335 unsigned int orig_state_; | 335 unsigned int orig_state_; |
336 #endif | 336 #endif |
337 DISALLOW_COPY_AND_ASSIGN(ScopedSubnormalFloatDisabler); | 337 DISALLOW_COPY_AND_ASSIGN(ScopedSubnormalFloatDisabler); |
338 }; | 338 }; |
339 | 339 |
340 } // namespace cc | 340 } // namespace cc |
341 | 341 |
342 #endif // CC_BASE_MATH_UTIL_H_ | 342 #endif // CC_BASE_MATH_UTIL_H_ |
OLD | NEW |