OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "core/dom/DOMMatrix.h" | 5 #include "core/dom/DOMMatrix.h" |
6 | 6 |
7 namespace blink { | 7 namespace blink { |
8 | 8 |
9 DOMMatrix* DOMMatrix::create() | 9 DOMMatrix* DOMMatrix::create() |
10 { | 10 { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 DOMMatrix::DOMMatrix(T sequence, int size) : DOMMatrixReadOnly(sequence, size) | 44 DOMMatrix::DOMMatrix(T sequence, int size) : DOMMatrixReadOnly(sequence, size) |
45 { | 45 { |
46 } | 46 } |
47 | 47 |
48 DOMMatrix::DOMMatrix(const TransformationMatrix& matrix, bool is2D) | 48 DOMMatrix::DOMMatrix(const TransformationMatrix& matrix, bool is2D) |
49 { | 49 { |
50 m_matrix = TransformationMatrix::create(matrix); | 50 m_matrix = TransformationMatrix::create(matrix); |
51 m_is2D = is2D; | 51 m_is2D = is2D; |
52 } | 52 } |
53 | 53 |
| 54 DOMMatrix* DOMMatrix::fromMatrix(DOMMatrixInit& other, ExceptionState& exception
State) |
| 55 { |
| 56 validateAndFixup(other, exceptionState); |
| 57 if (exceptionState.hadException()) |
| 58 return nullptr; |
| 59 |
| 60 if (other.is2D()) { |
| 61 return new DOMMatrix({ |
| 62 other.m11(), other.m12(), other.m21(), |
| 63 other.m22(), other.m41(), other.m42()}, other.is2D()); |
| 64 } |
| 65 |
| 66 return new DOMMatrix({ |
| 67 other.m11(), other.m12(), other.m13(), other.m14(), |
| 68 other.m21(), other.m22(), other.m23(), other.m24(), |
| 69 other.m31(), other.m32(), other.m33(), other.m34(), |
| 70 other.m41(), other.m42(), other.m43(), other.m44()}, other.is2D()); |
| 71 } |
| 72 |
54 void DOMMatrix::setIs2D(bool value) | 73 void DOMMatrix::setIs2D(bool value) |
55 { | 74 { |
56 if (m_is2D) | 75 if (m_is2D) |
57 m_is2D = value; | 76 m_is2D = value; |
58 } | 77 } |
59 | 78 |
60 DOMMatrix* DOMMatrix::multiplySelf(DOMMatrix* other) | 79 DOMMatrix* DOMMatrix::multiplySelf(DOMMatrixInit& other, ExceptionState& excepti
onState) |
61 { | 80 { |
62 if (!other->is2D()) | 81 DOMMatrix* otherMatrix = DOMMatrix::fromMatrix(other, exceptionState); |
| 82 if (!otherMatrix->is2D()) |
63 m_is2D = false; | 83 m_is2D = false; |
64 | 84 |
65 *m_matrix *= other->matrix(); | 85 *m_matrix *= otherMatrix->matrix(); |
66 | 86 |
67 return this; | 87 return this; |
68 } | 88 } |
69 | 89 |
70 DOMMatrix* DOMMatrix::preMultiplySelf(DOMMatrix* other) | 90 DOMMatrix* DOMMatrix::preMultiplySelf(DOMMatrixInit& other, ExceptionState& exce
ptionState) |
71 { | 91 { |
72 if (!other->is2D()) | 92 DOMMatrix* otherMatrix = DOMMatrix::fromMatrix(other, exceptionState); |
| 93 if (!otherMatrix->is2D()) |
73 m_is2D = false; | 94 m_is2D = false; |
74 | 95 |
75 TransformationMatrix& matrix = *m_matrix; | 96 TransformationMatrix& matrix = *m_matrix; |
76 *m_matrix = other->matrix() * matrix; | 97 *m_matrix = otherMatrix->matrix() * matrix; |
77 | 98 |
78 return this; | 99 return this; |
79 } | 100 } |
80 | 101 |
81 DOMMatrix* DOMMatrix::translateSelf(double tx, double ty, double tz) | 102 DOMMatrix* DOMMatrix::translateSelf(double tx, double ty, double tz) |
82 { | 103 { |
83 if (!tx && !ty && !tz) | 104 if (!tx && !ty && !tz) |
84 return this; | 105 return this; |
85 | 106 |
86 if (tz) | 107 if (tz) |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 setM41(NAN); | 182 setM41(NAN); |
162 setM42(NAN); | 183 setM42(NAN); |
163 setM43(NAN); | 184 setM43(NAN); |
164 setM44(NAN); | 185 setM44(NAN); |
165 setIs2D(false); | 186 setIs2D(false); |
166 } | 187 } |
167 return this; | 188 return this; |
168 } | 189 } |
169 | 190 |
170 } // namespace blink | 191 } // namespace blink |
OLD | NEW |