| 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 void ConcatTransform(const Transform& transform); | 84 void ConcatTransform(const Transform& transform); |
| 85 | 85 |
| 86 // Returns true if this is the identity matrix. | 86 // Returns true if this is the identity matrix. |
| 87 bool IsIdentity() const { return matrix_.isIdentity(); } | 87 bool IsIdentity() const { return matrix_.isIdentity(); } |
| 88 | 88 |
| 89 // Returns true if the matrix is either identity or pure translation. | 89 // Returns true if the matrix is either identity or pure translation. |
| 90 bool IsIdentityOrTranslation() const { | 90 bool IsIdentityOrTranslation() const { |
| 91 return !(matrix_.getType() & ~SkMatrix44::kTranslate_Mask); | 91 return !(matrix_.getType() & ~SkMatrix44::kTranslate_Mask); |
| 92 } | 92 } |
| 93 | 93 |
| 94 // Returns true if the matrix is either a positive scale and/or a translation. |
| 95 bool IsPositiveScaleOrTranslation() const { |
| 96 if (!IsScaleOrTranslation()) |
| 97 return false; |
| 98 return matrix_.getDouble(0, 0) > 0.0 && |
| 99 matrix_.getDouble(1, 1) > 0.0 && |
| 100 matrix_.getDouble(2, 2) > 0.0; |
| 101 } |
| 102 |
| 94 // Returns true if the matrix is either identity or pure, non-fractional | 103 // Returns true if the matrix is either identity or pure, non-fractional |
| 95 // translation. | 104 // translation. |
| 96 bool IsIdentityOrIntegerTranslation() const; | 105 bool IsIdentityOrIntegerTranslation() const; |
| 97 | 106 |
| 98 // Returns true if the matrix is has only scaling and translation components. | 107 // Returns true if the matrix is has only scaling and translation components. |
| 99 bool IsScaleOrTranslation() const { | 108 bool IsScaleOrTranslation() const { |
| 100 int mask = SkMatrix44::kScale_Mask | SkMatrix44::kTranslate_Mask; | 109 int mask = SkMatrix44::kScale_Mask | SkMatrix44::kTranslate_Mask; |
| 101 return (matrix_.getType() & ~mask) == 0; | 110 return (matrix_.getType() & ~mask) == 0; |
| 102 } | 111 } |
| 103 | 112 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 Point3F& point) const; | 192 Point3F& point) const; |
| 184 | 193 |
| 185 SkMatrix44 matrix_; | 194 SkMatrix44 matrix_; |
| 186 | 195 |
| 187 // copy/assign are allowed. | 196 // copy/assign are allowed. |
| 188 }; | 197 }; |
| 189 | 198 |
| 190 } // namespace gfx | 199 } // namespace gfx |
| 191 | 200 |
| 192 #endif // UI_GFX_TRANSFORM_H_ | 201 #endif // UI_GFX_TRANSFORM_H_ |
| OLD | NEW |