Chromium Code Reviews| 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 10 matching lines...) Expand all Loading... | |
| 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(const TransformationMatrix& matrix, bool is2D) | 25 DOMMatrix::DOMMatrix(const TransformationMatrix& matrix, bool is2D) |
| 26 { | 26 { |
| 27 m_matrix = TransformationMatrix::create(matrix); | 27 m_matrix = TransformationMatrix::create(matrix); |
| 28 m_is2D = is2D; | 28 m_is2D = is2D; |
| 29 } | 29 } |
| 30 | 30 |
| 31 DOMMatrix* DOMMatrix::fromMatrix(DOMMatrixInit& other, ExceptionState& exception State) | |
| 32 { | |
| 33 validateAndFixup(other, exceptionState); | |
| 34 if (exceptionState.hadException()) | |
| 35 return nullptr; | |
| 36 | |
| 37 if (other.is2D()) { | |
| 38 return new DOMMatrix({ | |
| 39 other.m11(), other.m12(), other.m21(), | |
| 40 other.m22(), other.m41(), other.m42()}, other.is2D()); | |
| 41 } | |
| 42 | |
| 43 return new DOMMatrix({ | |
| 44 other.m11(), other.m12(), other.m13(), other.m14(), | |
| 45 other.m21(), other.m22(), other.m23(), other.m24(), | |
| 46 other.m31(), other.m32(), other.m33(), other.m34(), | |
| 47 other.m41(), other.m42(), other.m43(), other.m44()}, other.is2D()); | |
| 48 } | |
| 49 | |
| 31 void DOMMatrix::setIs2D(bool value) | 50 void DOMMatrix::setIs2D(bool value) |
| 32 { | 51 { |
| 33 if (m_is2D) | 52 if (m_is2D) |
| 34 m_is2D = value; | 53 m_is2D = value; |
| 35 } | 54 } |
| 36 | 55 |
| 37 DOMMatrix* DOMMatrix::multiplySelf(DOMMatrix* other) | 56 DOMMatrix* DOMMatrix::multiplySelf(DOMMatrixInit& other, ExceptionState& excepti onState) |
| 38 { | 57 { |
| 39 if (!other->is2D()) | 58 DOMMatrix* otherMatrix = DOMMatrix::fromMatrix(other, exceptionState); |
| 59 if (!otherMatrix->is2D()) | |
|
dominicc (has gone to gerrit)
2016/08/30 02:13:43
Seems a shame to allocate the whole intermediate D
zino
2016/09/10 10:18:15
I'll try to file a bug.
| |
| 40 m_is2D = false; | 60 m_is2D = false; |
| 41 | 61 |
| 42 *m_matrix *= other->matrix(); | 62 *m_matrix *= otherMatrix->matrix(); |
| 43 | 63 |
| 44 return this; | 64 return this; |
| 45 } | 65 } |
| 46 | 66 |
| 47 DOMMatrix* DOMMatrix::preMultiplySelf(DOMMatrix* other) | 67 DOMMatrix* DOMMatrix::preMultiplySelf(DOMMatrixInit& other, ExceptionState& exce ptionState) |
| 48 { | 68 { |
| 49 if (!other->is2D()) | 69 DOMMatrix* otherMatrix = DOMMatrix::fromMatrix(other, exceptionState); |
| 70 if (!otherMatrix->is2D()) | |
| 50 m_is2D = false; | 71 m_is2D = false; |
| 51 | 72 |
| 52 TransformationMatrix& matrix = *m_matrix; | 73 TransformationMatrix& matrix = *m_matrix; |
| 53 *m_matrix = other->matrix() * matrix; | 74 *m_matrix = otherMatrix->matrix() * matrix; |
| 54 | 75 |
| 55 return this; | 76 return this; |
| 56 } | 77 } |
| 57 | 78 |
| 58 DOMMatrix* DOMMatrix::translateSelf(double tx, double ty, double tz) | 79 DOMMatrix* DOMMatrix::translateSelf(double tx, double ty, double tz) |
| 59 { | 80 { |
| 60 if (!tx && !ty && !tz) | 81 if (!tx && !ty && !tz) |
| 61 return this; | 82 return this; |
| 62 | 83 |
| 63 if (tz) | 84 if (tz) |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 112 return this; | 133 return this; |
| 113 } | 134 } |
| 114 | 135 |
| 115 DOMMatrix* DOMMatrix::skewYSelf(double sy) | 136 DOMMatrix* DOMMatrix::skewYSelf(double sy) |
| 116 { | 137 { |
| 117 m_matrix->skewY(sy); | 138 m_matrix->skewY(sy); |
| 118 return this; | 139 return this; |
| 119 } | 140 } |
| 120 | 141 |
| 121 } // namespace blink | 142 } // namespace blink |
| OLD | NEW |