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 "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "third_party/skia/include/utils/SkMatrix44.h" | 9 #include "third_party/skia/include/utils/SkMatrix44.h" |
10 #include "ui/base/ui_export.h" | 10 #include "ui/base/ui_export.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 public: | 22 public: |
23 Transform(); | 23 Transform(); |
24 ~Transform(); | 24 ~Transform(); |
25 | 25 |
26 bool operator==(const Transform& rhs) const; | 26 bool operator==(const Transform& rhs) const; |
27 bool operator!=(const Transform& rhs) const; | 27 bool operator!=(const Transform& rhs) const; |
28 | 28 |
29 // Resets this transform to the identity transform. | 29 // Resets this transform to the identity transform. |
30 void MakeIdentity(); | 30 void MakeIdentity(); |
31 | 31 |
32 // Applies the current transformation on a rotation and assigns the result | 32 // Applies the current transformation on a 2d rotation and assigns the result |
33 // to |this|. | 33 // to |this|. |
34 void Rotate(double degree); | 34 void Rotate(double degrees) { RotateAboutZAxis(degrees); } |
35 | 35 |
36 // Applies the current transformation on an axis-angle rotation and assigns | 36 // Applies the current transformation on an axis-angle rotation and assigns |
37 // the result to |this|. | 37 // the result to |this|. |
38 void RotateAbout(const Vector3dF& point, double degree); | 38 void RotateAboutXAxis(double degrees); |
| 39 void RotateAboutYAxis(double degrees); |
| 40 void RotateAboutZAxis(double degrees); |
| 41 void RotateAbout(const Vector3dF& axis, double degrees); |
39 | 42 |
40 // Applies the current transformation on a scaling and assigns the result | 43 // Applies the current transformation on a scaling and assigns the result |
41 // to |this|. | 44 // to |this|. |
42 void Scale(double x, double y); | 45 void Scale(double x, double y); |
43 void Scale3d(double x, double y, double z); | 46 void Scale3d(double x, double y, double z); |
44 | 47 |
45 // Applies the current transformation on a translation and assigns the result | 48 // Applies the current transformation on a translation and assigns the result |
46 // to |this|. | 49 // to |this|. |
47 void Translate(double x, double y); | 50 void Translate(double x, double y); |
48 void Translate3d(double x, double y, double z); | 51 void Translate3d(double x, double y, double z); |
(...skipping 11 matching lines...) Expand all Loading... |
60 // (i.e. 'this = this * transform;'). | 63 // (i.e. 'this = this * transform;'). |
61 void PreconcatTransform(const Transform& transform); | 64 void PreconcatTransform(const Transform& transform); |
62 | 65 |
63 // Applies a transformation on the current transformation | 66 // Applies a transformation on the current transformation |
64 // (i.e. 'this = transform * this;'). | 67 // (i.e. 'this = transform * this;'). |
65 void ConcatTransform(const Transform& transform); | 68 void ConcatTransform(const Transform& transform); |
66 | 69 |
67 // Returns true if this is the identity matrix. | 70 // Returns true if this is the identity matrix. |
68 bool IsIdentity() const; | 71 bool IsIdentity() const; |
69 | 72 |
| 73 // Returns true if the matrix is either identity or pure translation. |
| 74 bool IsIdentityOrTranslation() const; |
| 75 |
| 76 // Returns true if the matrix is has only scaling and translation components. |
| 77 bool IsScaleOrTranslation() const; |
| 78 |
| 79 // Returns true if the matrix has any perspective component that would |
| 80 // change the w-component of a homogeneous point. |
| 81 bool HasPerspective() const; |
| 82 |
70 // Returns true if this transform is non-singular. | 83 // Returns true if this transform is non-singular. |
71 bool IsInvertible() const; | 84 bool IsInvertible() const; |
72 | 85 |
| 86 // Returns true if a layer with a forward-facing normal of (0, 0, 1) would |
| 87 // have its back side facing frontwards after applying the transform. |
| 88 bool IsBackFaceVisible() const; |
| 89 |
73 // Inverts the transform which is passed in. Returns true if successful. | 90 // Inverts the transform which is passed in. Returns true if successful. |
74 bool GetInverse(Transform* transform) const WARN_UNUSED_RESULT; | 91 bool GetInverse(Transform* transform) const WARN_UNUSED_RESULT; |
75 | 92 |
76 // Transposes this transform in place. | 93 // Transposes this transform in place. |
77 void Transpose(); | 94 void Transpose(); |
78 | 95 |
79 // Applies the transformation on the point. Returns true if the point is | 96 // Applies the transformation on the point. Returns true if the point is |
80 // transformed successfully. | 97 // transformed successfully. |
81 void TransformPoint(Point3F& point) const; | 98 void TransformPoint(Point3F& point) const; |
82 | 99 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 Point3F& point) const; | 149 Point3F& point) const; |
133 | 150 |
134 SkMatrix44 matrix_; | 151 SkMatrix44 matrix_; |
135 | 152 |
136 // copy/assign are allowed. | 153 // copy/assign are allowed. |
137 }; | 154 }; |
138 | 155 |
139 } // namespace gfx | 156 } // namespace gfx |
140 | 157 |
141 #endif // UI_GFX_TRANSFORM_H_ | 158 #endif // UI_GFX_TRANSFORM_H_ |
OLD | NEW |