| 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 DOMMatrixReadOnly* DOMMatrixReadOnly::create(Vector<double> sequence) { |
| 10 if (sequence.size() == 16) { |
| 11 return new DOMMatrixReadOnly(sequence); |
| 12 } |
| 13 return nullptr; |
| 14 } |
| 15 |
| 16 DOMMatrixReadOnly* DOMMatrixReadOnly::create(DOMMatrixReadOnly* other) { |
| 17 return new DOMMatrixReadOnly(other->matrix(), other->is2D()); |
| 18 } |
| 19 |
| 20 DOMMatrixReadOnly::DOMMatrixReadOnly(Vector<double> sequence) |
| 21 { |
| 22 if (sequence.size() == 16) { |
| 23 m_matrix = TransformationMatrix::create( |
| 24 sequence[0], sequence[1], sequence[2], sequence[3], |
| 25 sequence[4], sequence[5], sequence[6], sequence[7], |
| 26 sequence[8], sequence[9], sequence[10], sequence[11], |
| 27 sequence[12], sequence[13], sequence[14], sequence[15]); |
| 28 m_is2D = false; |
| 29 } |
| 30 } |
| 31 |
| 32 DOMMatrixReadOnly::DOMMatrixReadOnly(const TransformationMatrix& matrix, bool is
2D) |
| 33 { |
| 34 m_matrix = TransformationMatrix::create(matrix); |
| 35 m_is2D = is2D; |
| 36 } |
| 37 |
| 9 DOMMatrixReadOnly::~DOMMatrixReadOnly() | 38 DOMMatrixReadOnly::~DOMMatrixReadOnly() |
| 10 { | 39 { |
| 11 } | 40 } |
| 12 | 41 |
| 13 bool DOMMatrixReadOnly::is2D() const | 42 bool DOMMatrixReadOnly::is2D() const |
| 14 { | 43 { |
| 15 return m_is2D; | 44 return m_is2D; |
| 16 } | 45 } |
| 17 | 46 |
| 18 bool DOMMatrixReadOnly::isIdentity() const | 47 bool DOMMatrixReadOnly::isIdentity() const |
| 19 { | 48 { |
| 20 return m_matrix->isIdentity(); | 49 return m_matrix->isIdentity(); |
| 21 } | 50 } |
| 22 | 51 |
| 23 DOMMatrix* DOMMatrixReadOnly::multiply(DOMMatrix* other) | 52 DOMMatrixReadOnly* DOMMatrixReadOnly::multiply(DOMMatrixReadOnly* other) |
| 24 { | 53 { |
| 25 return DOMMatrix::create(this)->multiplySelf(other); | 54 TransformationMatrix m = this->matrix(); |
| 55 m.multiply(other->matrix()); |
| 56 return new DOMMatrixReadOnly(m, other->is2D()); |
| 26 } | 57 } |
| 27 | 58 |
| 28 DOMMatrix* DOMMatrixReadOnly::translate(double tx, double ty, double tz) | 59 DOMMatrix* DOMMatrixReadOnly::translate(double tx, double ty, double tz) |
| 29 { | 60 { |
| 30 return DOMMatrix::create(this)->translateSelf(tx, ty, tz); | 61 return DOMMatrix::create(this)->translateSelf(tx, ty, tz); |
| 31 } | 62 } |
| 32 | 63 |
| 33 DOMMatrix* DOMMatrixReadOnly::scale(double scale, double ox, double oy) | 64 DOMMatrix* DOMMatrixReadOnly::scale(double scale, double ox, double oy) |
| 34 { | 65 { |
| 35 return DOMMatrix::create(this)->scaleSelf(scale, ox, oy); | 66 return DOMMatrix::create(this)->scaleSelf(scale, ox, oy); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 64 m_matrix->m11(), m_matrix->m12(), m_matrix->m13(), m_matrix->m14(), | 95 m_matrix->m11(), m_matrix->m12(), m_matrix->m13(), m_matrix->m14(), |
| 65 m_matrix->m21(), m_matrix->m22(), m_matrix->m23(), m_matrix->m24(), | 96 m_matrix->m21(), m_matrix->m22(), m_matrix->m23(), m_matrix->m24(), |
| 66 m_matrix->m31(), m_matrix->m32(), m_matrix->m33(), m_matrix->m34(), | 97 m_matrix->m31(), m_matrix->m32(), m_matrix->m33(), m_matrix->m34(), |
| 67 m_matrix->m41(), m_matrix->m42(), m_matrix->m43(), m_matrix->m44() | 98 m_matrix->m41(), m_matrix->m42(), m_matrix->m43(), m_matrix->m44() |
| 68 }; | 99 }; |
| 69 | 100 |
| 70 return DOMFloat64Array::create(array, 16); | 101 return DOMFloat64Array::create(array, 16); |
| 71 } | 102 } |
| 72 | 103 |
| 73 } // namespace blink | 104 } // namespace blink |
| OLD | NEW |