| 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 |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 // scale_inner_rect has to scale_outer_rect. scale_inner_rect should be | 149 // scale_inner_rect has to scale_outer_rect. scale_inner_rect should be |
| 150 // contained within scale_outer_rect, and likewise the rectangle that is | 150 // contained within scale_outer_rect, and likewise the rectangle that is |
| 151 // returned will be within input_outer_rect at a similar relative, scaled | 151 // returned will be within input_outer_rect at a similar relative, scaled |
| 152 // position. | 152 // position. |
| 153 static gfx::RectF ScaleRectProportional(const gfx::RectF& input_outer_rect, | 153 static gfx::RectF ScaleRectProportional(const gfx::RectF& input_outer_rect, |
| 154 const gfx::RectF& scale_outer_rect, | 154 const gfx::RectF& scale_outer_rect, |
| 155 const gfx::RectF& scale_inner_rect); | 155 const gfx::RectF& scale_inner_rect); |
| 156 | 156 |
| 157 // Returns the smallest angle between the given two vectors in degrees. | 157 // Returns the smallest angle between the given two vectors in degrees. |
| 158 // Neither vector is assumed to be normalized. | 158 // Neither vector is assumed to be normalized. |
| 159 static float SmallestAngleBetweenVectors(gfx::Vector2dF v1, | 159 static float SmallestAngleBetweenVectors(const gfx::Vector2dF& v1, |
| 160 gfx::Vector2dF v2); | 160 const gfx::Vector2dF& v2); |
| 161 | 161 |
| 162 // Projects the |source| vector onto |destination|. Neither vector is assumed | 162 // Projects the |source| vector onto |destination|. Neither vector is assumed |
| 163 // to be normalized. | 163 // to be normalized. |
| 164 static gfx::Vector2dF ProjectVector(gfx::Vector2dF source, | 164 static gfx::Vector2dF ProjectVector(const gfx::Vector2dF& source, |
| 165 gfx::Vector2dF destination); | 165 const gfx::Vector2dF& destination); |
| 166 | 166 |
| 167 // Conversion to value. | 167 // Conversion to value. |
| 168 static scoped_ptr<base::Value> AsValue(gfx::Size s); | 168 static scoped_ptr<base::Value> AsValue(gfx::Size s); |
| 169 static scoped_ptr<base::Value> AsValue(const gfx::SizeF& s); | 169 static scoped_ptr<base::Value> AsValue(const gfx::SizeF& s); |
| 170 static scoped_ptr<base::Value> AsValue(const gfx::Rect& r); | 170 static scoped_ptr<base::Value> AsValue(const gfx::Rect& r); |
| 171 static bool FromValue(const base::Value*, gfx::Rect* out_rect); | 171 static bool FromValue(const base::Value*, gfx::Rect* out_rect); |
| 172 static scoped_ptr<base::Value> AsValue(const gfx::PointF& q); | 172 static scoped_ptr<base::Value> AsValue(const gfx::PointF& q); |
| 173 static scoped_ptr<base::Value> AsValue(const gfx::QuadF& q); | 173 static scoped_ptr<base::Value> AsValue(const gfx::QuadF& q); |
| 174 static scoped_ptr<base::Value> AsValue(const gfx::RectF& rect); | 174 static scoped_ptr<base::Value> AsValue(const gfx::RectF& rect); |
| 175 static scoped_ptr<base::Value> AsValue(const gfx::Transform& transform); | 175 static scoped_ptr<base::Value> AsValue(const gfx::Transform& transform); |
| 176 static scoped_ptr<base::Value> AsValue(const gfx::BoxF& box); | 176 static scoped_ptr<base::Value> AsValue(const gfx::BoxF& box); |
| 177 | 177 |
| 178 // Returns a base::Value representation of the floating point value. | 178 // Returns a base::Value representation of the floating point value. |
| 179 // If the value is inf, returns max double/float representation. | 179 // If the value is inf, returns max double/float representation. |
| 180 static scoped_ptr<base::Value> AsValueSafely(double value); | 180 static scoped_ptr<base::Value> AsValueSafely(double value); |
| 181 static scoped_ptr<base::Value> AsValueSafely(float value); | 181 static scoped_ptr<base::Value> AsValueSafely(float value); |
| 182 }; | 182 }; |
| 183 | 183 |
| 184 } // namespace cc | 184 } // namespace cc |
| 185 | 185 |
| 186 #endif // CC_BASE_MATH_UTIL_H_ | 186 #endif // CC_BASE_MATH_UTIL_H_ |
| OLD | NEW |