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 <string> | 8 #include <string> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 void ConcatTransform(const Transform& transform); | 113 void ConcatTransform(const Transform& transform); |
114 | 114 |
115 // Returns true if this is the identity matrix. | 115 // Returns true if this is the identity matrix. |
116 bool IsIdentity() const { return matrix_.isIdentity(); } | 116 bool IsIdentity() const { return matrix_.isIdentity(); } |
117 | 117 |
118 // Returns true if the matrix is either identity or pure translation. | 118 // Returns true if the matrix is either identity or pure translation. |
119 bool IsIdentityOrTranslation() const { | 119 bool IsIdentityOrTranslation() const { |
120 return !(matrix_.getType() & ~SkMatrix44::kTranslate_Mask); | 120 return !(matrix_.getType() & ~SkMatrix44::kTranslate_Mask); |
121 } | 121 } |
122 | 122 |
| 123 // Returns true if the matrix is either identity or pure translation, |
| 124 // allowing for an amount of inaccuracy as specified by the parameter. |
| 125 bool IsApproximatelyIdentityOrTranslation(SkMScalar tolerance) const; |
| 126 |
123 // Returns true if the matrix is either a positive scale and/or a translation. | 127 // Returns true if the matrix is either a positive scale and/or a translation. |
124 bool IsPositiveScaleOrTranslation() const { | 128 bool IsPositiveScaleOrTranslation() const { |
125 if (!IsScaleOrTranslation()) | 129 if (!IsScaleOrTranslation()) |
126 return false; | 130 return false; |
127 return matrix_.get(0, 0) > 0.0 && matrix_.get(1, 1) > 0.0 && | 131 return matrix_.get(0, 0) > 0.0 && matrix_.get(1, 1) > 0.0 && |
128 matrix_.get(2, 2) > 0.0; | 132 matrix_.get(2, 2) > 0.0; |
129 } | 133 } |
130 | 134 |
131 // Returns true if the matrix is either identity or pure, non-fractional | 135 // Returns true if the matrix is either identity or pure, non-fractional |
132 // translation. | 136 // translation. |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 Point3F* point) const; | 257 Point3F* point) const; |
254 | 258 |
255 SkMatrix44 matrix_; | 259 SkMatrix44 matrix_; |
256 | 260 |
257 // copy/assign are allowed. | 261 // copy/assign are allowed. |
258 }; | 262 }; |
259 | 263 |
260 } // namespace gfx | 264 } // namespace gfx |
261 | 265 |
262 #endif // UI_GFX_TRANSFORM_H_ | 266 #endif // UI_GFX_TRANSFORM_H_ |
OLD | NEW |