OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 UI_GFX_TRANSFORM_H_ | 5 #ifndef UI_GFX_TRANSFORM_H_ |
6 #define UI_GFX_TRANSFORM_H_ | 6 #define UI_GFX_TRANSFORM_H_ |
7 | 7 |
8 #include <iosfwd> | 8 #include <iosfwd> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 // Applies a transformation on the current transformation | 115 // Applies a transformation on the current transformation |
116 // (i.e. 'this = transform * this;'). | 116 // (i.e. 'this = transform * this;'). |
117 void ConcatTransform(const Transform& transform); | 117 void ConcatTransform(const Transform& transform); |
118 | 118 |
119 // Returns true if this is the identity matrix. | 119 // Returns true if this is the identity matrix. |
120 bool IsIdentity() const { return matrix_.isIdentity(); } | 120 bool IsIdentity() const { return matrix_.isIdentity(); } |
121 | 121 |
122 // Returns true if the matrix is either identity or pure translation. | 122 // Returns true if the matrix is either identity or pure translation. |
123 bool IsIdentityOrTranslation() const { return matrix_.isTranslate(); } | 123 bool IsIdentityOrTranslation() const { return matrix_.isTranslate(); } |
124 | 124 |
| 125 // Returns true if the matrix is either the identity or a 2d translation. |
| 126 bool IsIdentityOr2DTranslation() const { |
| 127 return matrix_.isTranslate() && matrix_.get(2, 3) == 0; |
| 128 } |
| 129 |
125 // Returns true if the matrix is either identity or pure translation, | 130 // Returns true if the matrix is either identity or pure translation, |
126 // allowing for an amount of inaccuracy as specified by the parameter. | 131 // allowing for an amount of inaccuracy as specified by the parameter. |
127 bool IsApproximatelyIdentityOrTranslation(SkMScalar tolerance) const; | 132 bool IsApproximatelyIdentityOrTranslation(SkMScalar tolerance) const; |
128 | 133 |
129 // Returns true if the matrix is either a positive scale and/or a translation. | 134 // Returns true if the matrix is either a positive scale and/or a translation. |
130 bool IsPositiveScaleOrTranslation() const { | 135 bool IsPositiveScaleOrTranslation() const { |
131 if (!IsScaleOrTranslation()) | 136 if (!IsScaleOrTranslation()) |
132 return false; | 137 return false; |
133 return matrix_.get(0, 0) > 0.0 && matrix_.get(1, 1) > 0.0 && | 138 return matrix_.get(0, 0) > 0.0 && matrix_.get(1, 1) > 0.0 && |
134 matrix_.get(2, 2) > 0.0; | 139 matrix_.get(2, 2) > 0.0; |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 }; | 268 }; |
264 | 269 |
265 // This is declared here for use in gtest-based unit tests but is defined in | 270 // This is declared here for use in gtest-based unit tests but is defined in |
266 // the gfx_test_support target. Depend on that to use this in your unit test. | 271 // the gfx_test_support target. Depend on that to use this in your unit test. |
267 // This should not be used in production code - call ToString() instead. | 272 // This should not be used in production code - call ToString() instead. |
268 void PrintTo(const Transform& transform, ::std::ostream* os); | 273 void PrintTo(const Transform& transform, ::std::ostream* os); |
269 | 274 |
270 } // namespace gfx | 275 } // namespace gfx |
271 | 276 |
272 #endif // UI_GFX_TRANSFORM_H_ | 277 #endif // UI_GFX_TRANSFORM_H_ |
OLD | NEW |