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
3 // found in the LICENSE file.
6 #include "core/dom/DOMMatrix.h"
10 DOMMatrix* DOMMatrix::create()
12 return new DOMMatrix(TransformationMatrix());
15 DOMMatrix* DOMMatrix::create(DOMMatrixReadOnly* other)
17 return new DOMMatrix(other->matrix(), other->is2D());
20 DOMMatrix::DOMMatrix(const TransformationMatrix& matrix, bool is2D)
26 void DOMMatrix::setIs2D(bool value)
32 DOMMatrix* DOMMatrix::multiplySelf(DOMMatrix* other)
37 m_matrix = m_matrix * other->matrix();
42 DOMMatrix* DOMMatrix::preMultiplySelf(DOMMatrix* other)
47 m_matrix = other->matrix() * m_matrix;
52 DOMMatrix* DOMMatrix::translateSelf(double tx, double ty, double tz)
54 if (!tx && !ty && !tz)
61 m_matrix.translate(tx, ty);
63 m_matrix.translate3d(tx, ty, tz);
68 DOMMatrix* DOMMatrix::scaleSelf(double scale, double ox, double oy)
70 return scaleNonUniformSelf(scale, scale, 1, ox, oy);
73 DOMMatrix* DOMMatrix::scale3dSelf(double scale, double ox, double oy, double oz)
75 return scaleNonUniformSelf(scale, scale, scale, ox, oy, oz);
78 DOMMatrix* DOMMatrix::scaleNonUniformSelf(double sx, double sy, double sz,
79 double ox, double oy, double oz)
84 if (sx == 1 && sy == 1 && sz == 1)
87 bool hasTranslation = (ox || oy || oz);
90 translateSelf(ox, oy, oz);
93 m_matrix.scaleNonUniform(sx, sy);
95 m_matrix.scale3d(sx, sy, sz);
98 translateSelf(-ox, -oy, -oz);