| 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 { |
| 11 return new DOMMatrix(TransformationMatrix()); | 11 return new DOMMatrix(TransformationMatrix()); |
| 12 } | 12 } |
| 13 | 13 |
| 14 DOMMatrix* DOMMatrix::create(DOMMatrixReadOnly* other) | 14 DOMMatrix* DOMMatrix::create(DOMMatrixReadOnly* other) |
| 15 { | 15 { |
| 16 return new DOMMatrix(other->matrix(), other->is2D()); | 16 return new DOMMatrix(other->matrix(), other->is2D()); |
| 17 } | 17 } |
| 18 | 18 |
| 19 DOMMatrix* DOMMatrix::create(const SkMatrix44& matrix) | 19 DOMMatrix* DOMMatrix::create(const SkMatrix44& matrix) |
| 20 { | 20 { |
| 21 TransformationMatrix transformationMatrix(matrix); | 21 TransformationMatrix transformationMatrix(matrix); |
| 22 return new DOMMatrix(transformationMatrix, transformationMatrix.isAffine()); | 22 return new DOMMatrix(transformationMatrix, transformationMatrix.isAffine()); |
| 23 } | 23 } |
| 24 | 24 |
| 25 DOMMatrix* DOMMatrix::fromFloat32Array(DOMFloat32Array* float32Array, ExceptionS
tate& exceptionState) |
| 26 { |
| 27 if (float32Array->length() != 6 && float32Array->length() != 16) { |
| 28 exceptionState.throwTypeError("An invalid number sequence is specified.
The sequence must contain 6 elements for 2D matrix and 16 elements for 3D matrix
."); |
| 29 return nullptr; |
| 30 } |
| 31 return new DOMMatrix(float32Array->data(), float32Array->length()); |
| 32 } |
| 33 |
| 34 DOMMatrix* DOMMatrix::fromFloat64Array(DOMFloat64Array* float64Array, ExceptionS
tate& exceptionState) |
| 35 { |
| 36 if (float64Array->length() != 6 && float64Array->length() != 16) { |
| 37 exceptionState.throwTypeError("An invalid number sequence is specified.
The sequence must contain 6 elements for 2D matrix and 16 elements for 3D matrix
."); |
| 38 return nullptr; |
| 39 } |
| 40 return new DOMMatrix(float64Array->data(), float64Array->length()); |
| 41 } |
| 42 |
| 43 template <typename T> |
| 44 DOMMatrix::DOMMatrix(T sequence, int size) : DOMMatrixReadOnly(sequence, size) |
| 45 { |
| 46 } |
| 47 |
| 25 DOMMatrix::DOMMatrix(const TransformationMatrix& matrix, bool is2D) | 48 DOMMatrix::DOMMatrix(const TransformationMatrix& matrix, bool is2D) |
| 26 { | 49 { |
| 27 m_matrix = TransformationMatrix::create(matrix); | 50 m_matrix = TransformationMatrix::create(matrix); |
| 28 m_is2D = is2D; | 51 m_is2D = is2D; |
| 29 } | 52 } |
| 30 | 53 |
| 31 void DOMMatrix::setIs2D(bool value) | 54 void DOMMatrix::setIs2D(bool value) |
| 32 { | 55 { |
| 33 if (m_is2D) | 56 if (m_is2D) |
| 34 m_is2D = value; | 57 m_is2D = value; |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 setM41(NAN); | 161 setM41(NAN); |
| 139 setM42(NAN); | 162 setM42(NAN); |
| 140 setM43(NAN); | 163 setM43(NAN); |
| 141 setM44(NAN); | 164 setM44(NAN); |
| 142 setIs2D(false); | 165 setIs2D(false); |
| 143 } | 166 } |
| 144 return this; | 167 return this; |
| 145 } | 168 } |
| 146 | 169 |
| 147 } // namespace blink | 170 } // namespace blink |
| OLD | NEW |