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/point3_f.h" | 14 #include "ui/gfx/point3_f.h" |
15 #include "ui/gfx/point_f.h" | 15 #include "ui/gfx/point_f.h" |
16 #include "ui/gfx/size.h" | 16 #include "ui/gfx/size.h" |
17 #include "ui/gfx/transform.h" | 17 #include "ui/gfx/transform.h" |
18 | 18 |
19 namespace base { class Value; } | 19 namespace base { class Value; } |
20 | 20 |
21 namespace gfx { | 21 namespace gfx { |
22 class QuadF; | 22 class QuadF; |
23 class Rect; | 23 class Rect; |
24 class RectF; | 24 class RectF; |
25 class Transform; | 25 class Transform; |
26 class Vector2dF; | 26 class Vector2dF; |
| 27 class Vector2d; |
27 } | 28 } |
28 | 29 |
29 namespace cc { | 30 namespace cc { |
30 | 31 |
31 struct HomogeneousCoordinate { | 32 struct HomogeneousCoordinate { |
32 HomogeneousCoordinate(SkMScalar x, SkMScalar y, SkMScalar z, SkMScalar w) { | 33 HomogeneousCoordinate(SkMScalar x, SkMScalar y, SkMScalar z, SkMScalar w) { |
33 vec[0] = x; | 34 vec[0] = x; |
34 vec[1] = y; | 35 vec[1] = y; |
35 vec[2] = z; | 36 vec[2] = z; |
36 vec[3] = w; | 37 vec[3] = w; |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 gfx::Vector2dF v2); | 151 gfx::Vector2dF v2); |
151 | 152 |
152 // Projects the |source| vector onto |destination|. Neither vector is assumed | 153 // Projects the |source| vector onto |destination|. Neither vector is assumed |
153 // to be normalized. | 154 // to be normalized. |
154 static gfx::Vector2dF ProjectVector(gfx::Vector2dF source, | 155 static gfx::Vector2dF ProjectVector(gfx::Vector2dF source, |
155 gfx::Vector2dF destination); | 156 gfx::Vector2dF destination); |
156 | 157 |
157 // Conversion to value. | 158 // Conversion to value. |
158 static scoped_ptr<base::Value> AsValue(gfx::Size s); | 159 static scoped_ptr<base::Value> AsValue(gfx::Size s); |
159 static scoped_ptr<base::Value> AsValue(gfx::Rect r); | 160 static scoped_ptr<base::Value> AsValue(gfx::Rect r); |
| 161 static scoped_ptr<base::Value> AsValue(gfx::Vector2d vec); |
| 162 static scoped_ptr<base::Value> AsValue(gfx::Vector2dF vec); |
160 static bool FromValue(const base::Value*, gfx::Rect* out_rect); | 163 static bool FromValue(const base::Value*, gfx::Rect* out_rect); |
161 static scoped_ptr<base::Value> AsValue(gfx::PointF q); | 164 static scoped_ptr<base::Value> AsValue(gfx::PointF q); |
162 static scoped_ptr<base::Value> AsValue(const gfx::QuadF& q); | 165 static scoped_ptr<base::Value> AsValue(const gfx::QuadF& q); |
163 static scoped_ptr<base::Value> AsValue(const gfx::RectF& rect); | 166 static scoped_ptr<base::Value> AsValue(const gfx::RectF& rect); |
164 | 167 |
165 // Returns a base::Value representation of the floating point value. | 168 // Returns a base::Value representation of the floating point value. |
166 // If the value is inf, returns max double/float representation. | 169 // If the value is inf, returns max double/float representation. |
167 static scoped_ptr<base::Value> AsValueSafely(double value); | 170 static scoped_ptr<base::Value> AsValueSafely(double value); |
168 static scoped_ptr<base::Value> AsValueSafely(float value); | 171 static scoped_ptr<base::Value> AsValueSafely(float value); |
169 }; | 172 }; |
170 | 173 |
171 } // namespace cc | 174 } // namespace cc |
172 | 175 |
173 #endif // CC_BASE_MATH_UTIL_H_ | 176 #endif // CC_BASE_MATH_UTIL_H_ |
OLD | NEW |