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/geometry/DOMMatrix.h" | 5 #include "core/geometry/DOMMatrix.h" |
6 | 6 |
7 namespace blink { | 7 namespace blink { |
8 | 8 |
9 DOMMatrix* DOMMatrix::Create(ExecutionContext* execution_context, | 9 DOMMatrix* DOMMatrix::Create(ExecutionContext* execution_context, |
10 ExceptionState& exception_state) { | 10 ExceptionState& exception_state) { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 ExceptionState& exception_state) { | 45 ExceptionState& exception_state) { |
46 return new DOMMatrix(other->Matrix(), other->is2D()); | 46 return new DOMMatrix(other->Matrix(), other->is2D()); |
47 } | 47 } |
48 | 48 |
49 DOMMatrix* DOMMatrix::Create(const SkMatrix44& matrix, | 49 DOMMatrix* DOMMatrix::Create(const SkMatrix44& matrix, |
50 ExceptionState& exception_state) { | 50 ExceptionState& exception_state) { |
51 TransformationMatrix transformation_matrix(matrix); | 51 TransformationMatrix transformation_matrix(matrix); |
52 return new DOMMatrix(transformation_matrix, transformation_matrix.IsAffine()); | 52 return new DOMMatrix(transformation_matrix, transformation_matrix.IsAffine()); |
53 } | 53 } |
54 | 54 |
| 55 DOMMatrix* DOMMatrix::CreateForSerialization(double sequence[], int size) { |
| 56 return new DOMMatrix(sequence, size); |
| 57 } |
| 58 |
55 DOMMatrix* DOMMatrix::fromFloat32Array(NotShared<DOMFloat32Array> float32_array, | 59 DOMMatrix* DOMMatrix::fromFloat32Array(NotShared<DOMFloat32Array> float32_array, |
56 ExceptionState& exception_state) { | 60 ExceptionState& exception_state) { |
57 if (float32_array.View()->length() != 6 && | 61 if (float32_array.View()->length() != 6 && |
58 float32_array.View()->length() != 16) { | 62 float32_array.View()->length() != 16) { |
59 exception_state.ThrowTypeError( | 63 exception_state.ThrowTypeError( |
60 "The sequence must contain 6 elements for a 2D matrix or 16 elements " | 64 "The sequence must contain 6 elements for a 2D matrix or 16 elements " |
61 "for a 3D matrix."); | 65 "for a 3D matrix."); |
62 return nullptr; | 66 return nullptr; |
63 } | 67 } |
64 return new DOMMatrix(float32_array.View()->Data(), | 68 return new DOMMatrix(float32_array.View()->Data(), |
(...skipping 20 matching lines...) Expand all Loading... |
85 DOMMatrix::DOMMatrix(const TransformationMatrix& matrix, bool is2d) | 89 DOMMatrix::DOMMatrix(const TransformationMatrix& matrix, bool is2d) |
86 : DOMMatrixReadOnly(matrix, is2d) {} | 90 : DOMMatrixReadOnly(matrix, is2d) {} |
87 | 91 |
88 DOMMatrix* DOMMatrix::fromMatrix(DOMMatrixInit& other, | 92 DOMMatrix* DOMMatrix::fromMatrix(DOMMatrixInit& other, |
89 ExceptionState& exception_state) { | 93 ExceptionState& exception_state) { |
90 if (!ValidateAndFixup(other, exception_state)) { | 94 if (!ValidateAndFixup(other, exception_state)) { |
91 DCHECK(exception_state.HadException()); | 95 DCHECK(exception_state.HadException()); |
92 return nullptr; | 96 return nullptr; |
93 } | 97 } |
94 if (other.is2D()) { | 98 if (other.is2D()) { |
95 return new DOMMatrix({other.m11(), other.m12(), other.m21(), other.m22(), | 99 return new DOMMatrix( |
96 other.m41(), other.m42()}, | 100 {other.a(), other.b(), other.c(), other.d(), other.e(), other.f()}, |
97 other.is2D()); | 101 other.is2D()); |
98 } | 102 } |
99 | 103 |
100 return new DOMMatrix({other.m11(), other.m12(), other.m13(), other.m14(), | 104 return new DOMMatrix({other.m11(), other.m12(), other.m13(), other.m14(), |
101 other.m21(), other.m22(), other.m23(), other.m24(), | 105 other.m21(), other.m22(), other.m23(), other.m24(), |
102 other.m31(), other.m32(), other.m33(), other.m34(), | 106 other.m31(), other.m32(), other.m33(), other.m34(), |
103 other.m41(), other.m42(), other.m43(), other.m44()}, | 107 other.m41(), other.m42(), other.m43(), other.m44()}, |
104 other.is2D()); | 108 other.is2D()); |
105 } | 109 } |
106 | 110 |
107 void DOMMatrix::SetIs2D(bool value) { | 111 void DOMMatrix::SetIs2D(bool value) { |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 return this; | 279 return this; |
276 } | 280 } |
277 | 281 |
278 DOMMatrix* DOMMatrix::setMatrixValue(const String& input_string, | 282 DOMMatrix* DOMMatrix::setMatrixValue(const String& input_string, |
279 ExceptionState& exception_state) { | 283 ExceptionState& exception_state) { |
280 SetMatrixValueFromString(input_string, exception_state); | 284 SetMatrixValueFromString(input_string, exception_state); |
281 return this; | 285 return this; |
282 } | 286 } |
283 | 287 |
284 } // namespace blink | 288 } // namespace blink |
OLD | NEW |