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 <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "cc/base/cc_export.h" | |
15 #include "ui/gfx/geometry/box_f.h" | 14 #include "ui/gfx/geometry/box_f.h" |
16 #include "ui/gfx/geometry/point3_f.h" | 15 #include "ui/gfx/geometry/point3_f.h" |
17 #include "ui/gfx/geometry/point_f.h" | 16 #include "ui/gfx/geometry/point_f.h" |
18 #include "ui/gfx/geometry/scroll_offset.h" | 17 #include "ui/gfx/geometry/scroll_offset.h" |
19 #include "ui/gfx/geometry/size.h" | 18 #include "ui/gfx/geometry/size.h" |
20 #include "ui/gfx/transform.h" | 19 #include "ui/gfx/transform.h" |
21 | 20 |
22 namespace base { | 21 namespace base { |
23 class Value; | 22 class Value; |
24 namespace trace_event { | 23 namespace trace_event { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 } | 69 } |
71 | 70 |
72 SkMScalar x() const { return vec[0]; } | 71 SkMScalar x() const { return vec[0]; } |
73 SkMScalar y() const { return vec[1]; } | 72 SkMScalar y() const { return vec[1]; } |
74 SkMScalar z() const { return vec[2]; } | 73 SkMScalar z() const { return vec[2]; } |
75 SkMScalar w() const { return vec[3]; } | 74 SkMScalar w() const { return vec[3]; } |
76 | 75 |
77 SkMScalar vec[4]; | 76 SkMScalar vec[4]; |
78 }; | 77 }; |
79 | 78 |
80 class CC_EXPORT MathUtil { | 79 class MathUtil { |
81 public: | 80 public: |
82 static const double kPiDouble; | 81 static const double kPiDouble; |
83 static const float kPiFloat; | 82 static const float kPiFloat; |
84 | 83 |
85 static double Deg2Rad(double deg) { return deg * kPiDouble / 180.0; } | 84 static double Deg2Rad(double deg) { return deg * kPiDouble / 180.0; } |
86 static double Rad2Deg(double rad) { return rad * 180.0 / kPiDouble; } | 85 static double Rad2Deg(double rad) { return rad * 180.0 / kPiDouble; } |
87 | 86 |
88 static float Deg2Rad(float deg) { return deg * kPiFloat / 180.0f; } | 87 static float Deg2Rad(float deg) { return deg * kPiFloat / 180.0f; } |
89 static float Rad2Deg(float rad) { return rad * 180.0f / kPiFloat; } | 88 static float Rad2Deg(float rad) { return rad * 180.0f / kPiFloat; } |
90 | 89 |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 | 237 |
239 // Returns a base::Value representation of the floating point value. | 238 // Returns a base::Value representation of the floating point value. |
240 // If the value is inf, returns max double/float representation. | 239 // If the value is inf, returns max double/float representation. |
241 static double AsDoubleSafely(double value); | 240 static double AsDoubleSafely(double value); |
242 static float AsFloatSafely(float value); | 241 static float AsFloatSafely(float value); |
243 }; | 242 }; |
244 | 243 |
245 } // namespace cc | 244 } // namespace cc |
246 | 245 |
247 #endif // CC_BASE_MATH_UTIL_H_ | 246 #endif // CC_BASE_MATH_UTIL_H_ |
OLD | NEW |