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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 static bool FromValue(const base::Value*, gfx::Rect* out_rect); | 170 static bool FromValue(const base::Value*, gfx::Rect* out_rect); |
171 static scoped_ptr<base::Value> AsValue(gfx::PointF q); | 171 static scoped_ptr<base::Value> AsValue(gfx::PointF q); |
172 static scoped_ptr<base::Value> AsValue(const gfx::QuadF& q); | 172 static scoped_ptr<base::Value> AsValue(const gfx::QuadF& q); |
173 static scoped_ptr<base::Value> AsValue(const gfx::RectF& rect); | 173 static scoped_ptr<base::Value> AsValue(const gfx::RectF& rect); |
174 static scoped_ptr<base::Value> AsValue(const gfx::Transform& transform); | 174 static scoped_ptr<base::Value> AsValue(const gfx::Transform& transform); |
175 | 175 |
176 // Returns a base::Value representation of the floating point value. | 176 // Returns a base::Value representation of the floating point value. |
177 // If the value is inf, returns max double/float representation. | 177 // If the value is inf, returns max double/float representation. |
178 static scoped_ptr<base::Value> AsValueSafely(double value); | 178 static scoped_ptr<base::Value> AsValueSafely(double value); |
179 static scoped_ptr<base::Value> AsValueSafely(float value); | 179 static scoped_ptr<base::Value> AsValueSafely(float value); |
| 180 |
| 181 // Check if matrices are of a certain type using approximate math. Each |
| 182 // function gets a tolerance parameter to specify the maximum allowed |
| 183 // absolute difference to the exact values. |
| 184 static bool IsApproximatelyPureTranslation( |
| 185 const gfx::Transform& transform, SkMScalar tolerance); |
| 186 static bool IsMatrixApproximatelyPureTranslation( |
| 187 const SkMatrix44& matrix, SkMScalar tolerance); |
| 188 static bool IsApproximatelyIntegerTransform( |
| 189 const gfx::Transform& transform, SkMScalar tolerance); |
| 190 static bool IsMatrixApproximatelyIntegerTransform( |
| 191 const SkMatrix44& matrix, SkMScalar tolerance); |
180 }; | 192 }; |
181 | 193 |
182 } // namespace cc | 194 } // namespace cc |
183 | 195 |
184 #endif // CC_BASE_MATH_UTIL_H_ | 196 #endif // CC_BASE_MATH_UTIL_H_ |
OLD | NEW |