| 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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 return false; | 109 return false; |
| 110 return matrix_.getDouble(0, 0) > 0.0 && | 110 return matrix_.getDouble(0, 0) > 0.0 && |
| 111 matrix_.getDouble(1, 1) > 0.0 && | 111 matrix_.getDouble(1, 1) > 0.0 && |
| 112 matrix_.getDouble(2, 2) > 0.0; | 112 matrix_.getDouble(2, 2) > 0.0; |
| 113 } | 113 } |
| 114 | 114 |
| 115 // Returns true if the matrix is either identity or pure, non-fractional | 115 // Returns true if the matrix is either identity or pure, non-fractional |
| 116 // translation. | 116 // translation. |
| 117 bool IsIdentityOrIntegerTranslation() const; | 117 bool IsIdentityOrIntegerTranslation() const; |
| 118 | 118 |
| 119 // These "Almost" methods check if the transform is very near to meet the |
| 120 // conditions. Useful when the transform has been computed many steps and |
| 121 // contains tiny errors but can still be treated as meeting the conditions |
| 122 // approximately. |
| 123 bool IsAlmostIdentity() const; |
| 124 bool IsAlmostIdentityOrTranslation() const; |
| 125 bool IsAlmostIdentityOrIntegerTranslation() const; |
| 126 |
| 119 // Returns true if the matrix is has only scaling and translation components. | 127 // Returns true if the matrix is has only scaling and translation components. |
| 120 bool IsScaleOrTranslation() const { | 128 bool IsScaleOrTranslation() const { |
| 121 int mask = SkMatrix44::kScale_Mask | SkMatrix44::kTranslate_Mask; | 129 int mask = SkMatrix44::kScale_Mask | SkMatrix44::kTranslate_Mask; |
| 122 return (matrix_.getType() & ~mask) == 0; | 130 return (matrix_.getType() & ~mask) == 0; |
| 123 } | 131 } |
| 124 | 132 |
| 125 // Returns true if the matrix has any perspective component that would | 133 // Returns true if the matrix has any perspective component that would |
| 126 // change the w-component of a homogeneous point. | 134 // change the w-component of a homogeneous point. |
| 127 bool HasPerspective() const { | 135 bool HasPerspective() const { |
| 128 return (matrix_.getType() & SkMatrix44::kPerspective_Mask) != 0; | 136 return (matrix_.getType() & SkMatrix44::kPerspective_Mask) != 0; |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 Point3F& point) const; | 228 Point3F& point) const; |
| 221 | 229 |
| 222 SkMatrix44 matrix_; | 230 SkMatrix44 matrix_; |
| 223 | 231 |
| 224 // copy/assign are allowed. | 232 // copy/assign are allowed. |
| 225 }; | 233 }; |
| 226 | 234 |
| 227 } // namespace gfx | 235 } // namespace gfx |
| 228 | 236 |
| 229 #endif // UI_GFX_TRANSFORM_H_ | 237 #endif // UI_GFX_TRANSFORM_H_ |
| OLD | NEW |