OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 21 matching lines...) Expand all Loading... |
32 #include "wtf/text/WTFString.h" | 32 #include "wtf/text/WTFString.h" |
33 | 33 |
34 namespace blink { | 34 namespace blink { |
35 | 35 |
36 class ExceptionState; | 36 class ExceptionState; |
37 class ExecutionContext; | 37 class ExecutionContext; |
38 | 38 |
39 class CSSMatrix final : public GarbageCollectedFinalized<CSSMatrix>, public Scri
ptWrappable { | 39 class CSSMatrix final : public GarbageCollectedFinalized<CSSMatrix>, public Scri
ptWrappable { |
40 DEFINE_WRAPPERTYPEINFO(); | 40 DEFINE_WRAPPERTYPEINFO(); |
41 public: | 41 public: |
42 static RawPtr<CSSMatrix> create(const TransformationMatrix& m) | 42 static CSSMatrix* create(const TransformationMatrix& m) |
43 { | 43 { |
44 return new CSSMatrix(m); | 44 return new CSSMatrix(m); |
45 } | 45 } |
46 static RawPtr<CSSMatrix> create(ExecutionContext*, const String&, ExceptionS
tate&); | 46 static CSSMatrix* create(ExecutionContext*, const String&, ExceptionState&); |
47 | 47 |
48 double a() const { return m_matrix->a(); } | 48 double a() const { return m_matrix->a(); } |
49 double b() const { return m_matrix->b(); } | 49 double b() const { return m_matrix->b(); } |
50 double c() const { return m_matrix->c(); } | 50 double c() const { return m_matrix->c(); } |
51 double d() const { return m_matrix->d(); } | 51 double d() const { return m_matrix->d(); } |
52 double e() const { return m_matrix->e(); } | 52 double e() const { return m_matrix->e(); } |
53 double f() const { return m_matrix->f(); } | 53 double f() const { return m_matrix->f(); } |
54 | 54 |
55 void setA(double f) { m_matrix->setA(f); } | 55 void setA(double f) { m_matrix->setA(f); } |
56 void setB(double f) { m_matrix->setB(f); } | 56 void setB(double f) { m_matrix->setB(f); } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 void setM42(double f) { m_matrix->setM42(f); } | 92 void setM42(double f) { m_matrix->setM42(f); } |
93 void setM43(double f) { m_matrix->setM43(f); } | 93 void setM43(double f) { m_matrix->setM43(f); } |
94 void setM44(double f) { m_matrix->setM44(f); } | 94 void setM44(double f) { m_matrix->setM44(f); } |
95 | 95 |
96 void setMatrixValue(const String&, ExceptionState&); | 96 void setMatrixValue(const String&, ExceptionState&); |
97 | 97 |
98 // The following math function return a new matrix with the | 98 // The following math function return a new matrix with the |
99 // specified operation applied. The this value is not modified. | 99 // specified operation applied. The this value is not modified. |
100 | 100 |
101 // Multiply this matrix by secondMatrix, on the right (result = this * secon
dMatrix) | 101 // Multiply this matrix by secondMatrix, on the right (result = this * secon
dMatrix) |
102 RawPtr<CSSMatrix> multiply(CSSMatrix* secondMatrix) const; | 102 CSSMatrix* multiply(CSSMatrix* secondMatrix) const; |
103 | 103 |
104 // Return the inverse of this matrix. Throw an exception if the matrix is no
t invertible | 104 // Return the inverse of this matrix. Throw an exception if the matrix is no
t invertible |
105 RawPtr<CSSMatrix> inverse(ExceptionState&) const; | 105 CSSMatrix* inverse(ExceptionState&) const; |
106 | 106 |
107 // Return this matrix translated by the passed values. | 107 // Return this matrix translated by the passed values. |
108 // Passing a NaN will use a value of 0. This allows the 3D form to used for
2D operations | 108 // Passing a NaN will use a value of 0. This allows the 3D form to used for
2D operations |
109 // Operation is performed as though the this matrix is multiplied by a matri
x with | 109 // Operation is performed as though the this matrix is multiplied by a matri
x with |
110 // the translation values on the left (result = translation(x,y,z) * this) | 110 // the translation values on the left (result = translation(x,y,z) * this) |
111 RawPtr<CSSMatrix> translate(double x, double y, double z) const; | 111 CSSMatrix* translate(double x, double y, double z) const; |
112 | 112 |
113 // Returns this matrix scaled by the passed values. | 113 // Returns this matrix scaled by the passed values. |
114 // Passing scaleX or scaleZ as NaN uses a value of 1, but passing scaleY of
NaN | 114 // Passing scaleX or scaleZ as NaN uses a value of 1, but passing scaleY of
NaN |
115 // makes it the same as scaleX. This allows the 3D form to used for 2D opera
tions | 115 // makes it the same as scaleX. This allows the 3D form to used for 2D opera
tions |
116 // Operation is performed as though the this matrix is multiplied by a matri
x with | 116 // Operation is performed as though the this matrix is multiplied by a matri
x with |
117 // the scale values on the left (result = scale(x,y,z) * this) | 117 // the scale values on the left (result = scale(x,y,z) * this) |
118 RawPtr<CSSMatrix> scale(double scaleX, double scaleY, double scaleZ) const; | 118 CSSMatrix* scale(double scaleX, double scaleY, double scaleZ) const; |
119 | 119 |
120 // Returns this matrix rotated by the passed values. | 120 // Returns this matrix rotated by the passed values. |
121 // If rotY and rotZ are NaN, rotate about Z (rotX=0, rotateY=0, rotateZ=rotX
). | 121 // If rotY and rotZ are NaN, rotate about Z (rotX=0, rotateY=0, rotateZ=rotX
). |
122 // Otherwise use a rotation value of 0 for any passed NaN. | 122 // Otherwise use a rotation value of 0 for any passed NaN. |
123 // Operation is performed as though the this matrix is multiplied by a matri
x with | 123 // Operation is performed as though the this matrix is multiplied by a matri
x with |
124 // the rotation values on the left (result = rotation(x,y,z) * this) | 124 // the rotation values on the left (result = rotation(x,y,z) * this) |
125 RawPtr<CSSMatrix> rotate(double rotX, double rotY, double rotZ) const; | 125 CSSMatrix* rotate(double rotX, double rotY, double rotZ) const; |
126 | 126 |
127 // Returns this matrix rotated about the passed axis by the passed angle. | 127 // Returns this matrix rotated about the passed axis by the passed angle. |
128 // Passing a NaN will use a value of 0. If the axis is (0,0,0) use a value | 128 // Passing a NaN will use a value of 0. If the axis is (0,0,0) use a value |
129 // Operation is performed as though the this matrix is multiplied by a matri
x with | 129 // Operation is performed as though the this matrix is multiplied by a matri
x with |
130 // the rotation values on the left (result = rotation(x,y,z,angle) * this) | 130 // the rotation values on the left (result = rotation(x,y,z,angle) * this) |
131 RawPtr<CSSMatrix> rotateAxisAngle(double x, double y, double z, double angle
) const; | 131 CSSMatrix* rotateAxisAngle(double x, double y, double z, double angle) const
; |
132 | 132 |
133 // Return this matrix skewed along the X axis by the passed values. | 133 // Return this matrix skewed along the X axis by the passed values. |
134 // Passing a NaN will use a value of 0. | 134 // Passing a NaN will use a value of 0. |
135 // Operation is performed as though the this matrix is multiplied by a matri
x with | 135 // Operation is performed as though the this matrix is multiplied by a matri
x with |
136 // the skew values on the left (result = skewX(angle) * this) | 136 // the skew values on the left (result = skewX(angle) * this) |
137 RawPtr<CSSMatrix> skewX(double angle) const; | 137 CSSMatrix* skewX(double angle) const; |
138 | 138 |
139 // Return this matrix skewed along the Y axis by the passed values. | 139 // Return this matrix skewed along the Y axis by the passed values. |
140 // Passing a NaN will use a value of 0. | 140 // Passing a NaN will use a value of 0. |
141 // Operation is performed as though the this matrix is multiplied by a matri
x with | 141 // Operation is performed as though the this matrix is multiplied by a matri
x with |
142 // the skew values on the left (result = skewY(angle) * this) | 142 // the skew values on the left (result = skewY(angle) * this) |
143 RawPtr<CSSMatrix> skewY(double angle) const; | 143 CSSMatrix* skewY(double angle) const; |
144 | 144 |
145 const TransformationMatrix& transform() const { return *m_matrix; } | 145 const TransformationMatrix& transform() const { return *m_matrix; } |
146 | 146 |
147 String toString() const; | 147 String toString() const; |
148 | 148 |
149 DEFINE_INLINE_TRACE() { } | 149 DEFINE_INLINE_TRACE() { } |
150 | 150 |
151 protected: | 151 protected: |
152 CSSMatrix(const TransformationMatrix&); | 152 CSSMatrix(const TransformationMatrix&); |
153 CSSMatrix(const String&, ExceptionState&); | 153 CSSMatrix(const String&, ExceptionState&); |
154 | 154 |
155 // TransformationMatrix needs to be 16-byte aligned. PartitionAlloc | 155 // TransformationMatrix needs to be 16-byte aligned. PartitionAlloc |
156 // supports 16-byte alignment but Oilpan doesn't. So we use an OwnPtr | 156 // supports 16-byte alignment but Oilpan doesn't. So we use an OwnPtr |
157 // to allocate TransformationMatrix on PartitionAlloc. | 157 // to allocate TransformationMatrix on PartitionAlloc. |
158 // TODO(oilpan): Oilpan should support 16-byte aligned allocations. | 158 // TODO(oilpan): Oilpan should support 16-byte aligned allocations. |
159 OwnPtr<TransformationMatrix> m_matrix; | 159 OwnPtr<TransformationMatrix> m_matrix; |
160 }; | 160 }; |
161 | 161 |
162 } // namespace blink | 162 } // namespace blink |
163 | 163 |
164 #endif // CSSMatrix_h | 164 #endif // CSSMatrix_h |
OLD | NEW |