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 | 10 |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "cc/base/cc_export.h" | 13 #include "cc/base/cc_export.h" |
14 #include "ui/gfx/box_f.h" | 14 #include "ui/gfx/box_f.h" |
15 #include "ui/gfx/point3_f.h" | 15 #include "ui/gfx/point3_f.h" |
16 #include "ui/gfx/point_f.h" | 16 #include "ui/gfx/point_f.h" |
17 #include "ui/gfx/size.h" | 17 #include "ui/gfx/size.h" |
18 #include "ui/gfx/transform.h" | 18 #include "ui/gfx/transform.h" |
19 | 19 |
20 namespace base { class Value; } | 20 namespace base { |
| 21 class Value; |
| 22 namespace debug { |
| 23 class TracedValue; |
| 24 } |
| 25 } |
21 | 26 |
22 namespace gfx { | 27 namespace gfx { |
23 class QuadF; | 28 class QuadF; |
24 class Rect; | 29 class Rect; |
25 class RectF; | 30 class RectF; |
26 class Transform; | 31 class Transform; |
27 class Vector2dF; | 32 class Vector2dF; |
28 class Vector2d; | 33 class Vector2d; |
29 } | 34 } |
30 | 35 |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 static float SmallestAngleBetweenVectors(const gfx::Vector2dF& v1, | 172 static float SmallestAngleBetweenVectors(const gfx::Vector2dF& v1, |
168 const gfx::Vector2dF& v2); | 173 const gfx::Vector2dF& v2); |
169 | 174 |
170 // Projects the |source| vector onto |destination|. Neither vector is assumed | 175 // Projects the |source| vector onto |destination|. Neither vector is assumed |
171 // to be normalized. | 176 // to be normalized. |
172 static gfx::Vector2dF ProjectVector(const gfx::Vector2dF& source, | 177 static gfx::Vector2dF ProjectVector(const gfx::Vector2dF& source, |
173 const gfx::Vector2dF& destination); | 178 const gfx::Vector2dF& destination); |
174 | 179 |
175 // Conversion to value. | 180 // Conversion to value. |
176 static scoped_ptr<base::Value> AsValue(const gfx::Size& s); | 181 static scoped_ptr<base::Value> AsValue(const gfx::Size& s); |
177 static scoped_ptr<base::Value> AsValue(const gfx::SizeF& s); | |
178 static scoped_ptr<base::Value> AsValue(const gfx::Rect& r); | 182 static scoped_ptr<base::Value> AsValue(const gfx::Rect& r); |
179 static bool FromValue(const base::Value*, gfx::Rect* out_rect); | 183 static bool FromValue(const base::Value*, gfx::Rect* out_rect); |
180 static scoped_ptr<base::Value> AsValue(const gfx::PointF& q); | 184 static scoped_ptr<base::Value> AsValue(const gfx::PointF& q); |
181 static scoped_ptr<base::Value> AsValue(const gfx::Point3F&); | 185 |
182 static scoped_ptr<base::Value> AsValue(const gfx::Vector2d& v); | 186 static void AddToTracedValue(const gfx::Size& s, |
183 static scoped_ptr<base::Value> AsValue(const gfx::QuadF& q); | 187 base::debug::TracedValue* res); |
184 static scoped_ptr<base::Value> AsValue(const gfx::RectF& rect); | 188 static void AddToTracedValue(const gfx::SizeF& s, |
185 static scoped_ptr<base::Value> AsValue(const gfx::Transform& transform); | 189 base::debug::TracedValue* res); |
186 static scoped_ptr<base::Value> AsValue(const gfx::BoxF& box); | 190 static void AddToTracedValue(const gfx::Rect& r, |
| 191 base::debug::TracedValue* res); |
| 192 static void AddToTracedValue(const gfx::PointF& q, |
| 193 base::debug::TracedValue* res); |
| 194 static void AddToTracedValue(const gfx::Point3F&, |
| 195 base::debug::TracedValue* res); |
| 196 static void AddToTracedValue(const gfx::Vector2d& v, |
| 197 base::debug::TracedValue* res); |
| 198 static void AddToTracedValue(const gfx::QuadF& q, |
| 199 base::debug::TracedValue* res); |
| 200 static void AddToTracedValue(const gfx::RectF& rect, |
| 201 base::debug::TracedValue* res); |
| 202 static void AddToTracedValue(const gfx::Transform& transform, |
| 203 base::debug::TracedValue* res); |
| 204 static void AddToTracedValue(const gfx::BoxF& box, |
| 205 base::debug::TracedValue* res); |
187 | 206 |
188 // Returns a base::Value representation of the floating point value. | 207 // Returns a base::Value representation of the floating point value. |
189 // If the value is inf, returns max double/float representation. | 208 // If the value is inf, returns max double/float representation. |
190 static scoped_ptr<base::Value> AsValueSafely(double value); | 209 static double AsDoubleSafely(double value); |
191 static scoped_ptr<base::Value> AsValueSafely(float value); | 210 static float AsFloatSafely(float value); |
192 }; | 211 }; |
193 | 212 |
194 } // namespace cc | 213 } // namespace cc |
195 | 214 |
196 #endif // CC_BASE_MATH_UTIL_H_ | 215 #endif // CC_BASE_MATH_UTIL_H_ |
OLD | NEW |