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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 // the result to |this|. | 82 // the result to |this|. |
83 void RotateAboutXAxis(double degrees); | 83 void RotateAboutXAxis(double degrees); |
84 void RotateAboutYAxis(double degrees); | 84 void RotateAboutYAxis(double degrees); |
85 void RotateAboutZAxis(double degrees); | 85 void RotateAboutZAxis(double degrees); |
86 void RotateAbout(const Vector3dF& axis, double degrees); | 86 void RotateAbout(const Vector3dF& axis, double degrees); |
87 | 87 |
88 // Applies the current transformation on a scaling and assigns the result | 88 // Applies the current transformation on a scaling and assigns the result |
89 // to |this|. | 89 // to |this|. |
90 void Scale(SkMScalar x, SkMScalar y); | 90 void Scale(SkMScalar x, SkMScalar y); |
91 void Scale3d(SkMScalar x, SkMScalar y, SkMScalar z); | 91 void Scale3d(SkMScalar x, SkMScalar y, SkMScalar z); |
| 92 gfx::Vector2dF Scale2d() const { |
| 93 return gfx::Vector2dF(matrix_.get(0, 0), matrix_.get(1, 1)); |
| 94 } |
92 | 95 |
93 // Applies the current transformation on a translation and assigns the result | 96 // Applies the current transformation on a translation and assigns the result |
94 // to |this|. | 97 // to |this|. |
95 void Translate(SkMScalar x, SkMScalar y); | 98 void Translate(SkMScalar x, SkMScalar y); |
96 void Translate3d(SkMScalar x, SkMScalar y, SkMScalar z); | 99 void Translate3d(SkMScalar x, SkMScalar y, SkMScalar z); |
97 | 100 |
98 // Applies the current transformation on a skew and assigns the result | 101 // Applies the current transformation on a skew and assigns the result |
99 // to |this|. | 102 // to |this|. |
100 void SkewX(double angle_x); | 103 void SkewX(double angle_x); |
101 void SkewY(double angle_y); | 104 void SkewY(double angle_y); |
(...skipping 27 matching lines...) Expand all Loading... |
129 if (!IsScaleOrTranslation()) | 132 if (!IsScaleOrTranslation()) |
130 return false; | 133 return false; |
131 return matrix_.get(0, 0) > 0.0 && matrix_.get(1, 1) > 0.0 && | 134 return matrix_.get(0, 0) > 0.0 && matrix_.get(1, 1) > 0.0 && |
132 matrix_.get(2, 2) > 0.0; | 135 matrix_.get(2, 2) > 0.0; |
133 } | 136 } |
134 | 137 |
135 // Returns true if the matrix is either identity or pure, non-fractional | 138 // Returns true if the matrix is either identity or pure, non-fractional |
136 // translation. | 139 // translation. |
137 bool IsIdentityOrIntegerTranslation() const; | 140 bool IsIdentityOrIntegerTranslation() const; |
138 | 141 |
| 142 // Returns true if the matrix had only scaling components. |
| 143 bool IsScale2d() const { |
| 144 return !(matrix_.getType() & ~SkMatrix44::kScale_Mask); |
| 145 } |
| 146 |
139 // Returns true if the matrix is has only scaling and translation components. | 147 // Returns true if the matrix is has only scaling and translation components. |
140 bool IsScaleOrTranslation() const { | 148 bool IsScaleOrTranslation() const { |
141 int mask = SkMatrix44::kScale_Mask | SkMatrix44::kTranslate_Mask; | 149 int mask = SkMatrix44::kScale_Mask | SkMatrix44::kTranslate_Mask; |
142 return (matrix_.getType() & ~mask) == 0; | 150 return (matrix_.getType() & ~mask) == 0; |
143 } | 151 } |
144 | 152 |
145 // Returns true if axis-aligned 2d rects will remain axis-aligned after being | 153 // Returns true if axis-aligned 2d rects will remain axis-aligned after being |
146 // transformed by this matrix. | 154 // transformed by this matrix. |
147 bool Preserves2dAxisAlignment() const; | 155 bool Preserves2dAxisAlignment() const; |
148 | 156 |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 Point3F* point) const; | 264 Point3F* point) const; |
257 | 265 |
258 SkMatrix44 matrix_; | 266 SkMatrix44 matrix_; |
259 | 267 |
260 // copy/assign are allowed. | 268 // copy/assign are allowed. |
261 }; | 269 }; |
262 | 270 |
263 } // namespace gfx | 271 } // namespace gfx |
264 | 272 |
265 #endif // UI_GFX_TRANSFORM_H_ | 273 #endif // UI_GFX_TRANSFORM_H_ |
OLD | NEW |