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.
4
5#include "config.h"
6#include "core/dom/DOMMatrix.h"
7
8namespace blink {
9
10bool DOMMatrixReadOnly::is2D() const
11{
12    return m_is2D;
13}
14
15bool DOMMatrixReadOnly::isIdentity() const
16{
17    return m_matrix.isIdentity();
18}
19
20DOMMatrix* DOMMatrixReadOnly::multiply(DOMMatrix* other)
21{
22    return DOMMatrix::create(this)->multiplySelf(other);
23}
24
25DOMMatrix* DOMMatrixReadOnly::translate(double tx, double ty, double tz)
26{
27    return DOMMatrix::create(this)->translateSelf(tx, ty, tz);
28}
29
30DOMMatrix* DOMMatrixReadOnly::scale(double scale, double ox, double oy)
31{
32    return DOMMatrix::create(this)->scaleSelf(scale, ox, oy);
33}
34
35DOMMatrix* DOMMatrixReadOnly::scale3d(double scale, double ox, double oy, double oz)
36{
37    return DOMMatrix::create(this)->scale3dSelf(scale, ox, oy, oz);
38}
39
40DOMMatrix* DOMMatrixReadOnly::scaleNonUniform(double sx, double sy, double sz,
41    double ox, double oy, double oz)
42{
43    return DOMMatrix::create(this)->scaleNonUniformSelf(sx, sy, sz, ox, oy, oz);
44}
45
46PassRefPtr<Float32Array> DOMMatrixReadOnly::toFloat32Array() const
47{
48    float array[] = {
49        m_matrix.m11(), m_matrix.m12(), m_matrix.m13(), m_matrix.m14(),
50        m_matrix.m21(), m_matrix.m22(), m_matrix.m23(), m_matrix.m24(),
51        m_matrix.m31(), m_matrix.m32(), m_matrix.m33(), m_matrix.m34(),
52        m_matrix.m41(), m_matrix.m42(), m_matrix.m43(), m_matrix.m44()
53    };
54
55    return Float32Array::create(array, 16);
56}
57
58PassRefPtr<Float64Array> DOMMatrixReadOnly::toFloat64Array() const
59{
60    double array[] = {
61        m_matrix.m11(), m_matrix.m12(), m_matrix.m13(), m_matrix.m14(),
62        m_matrix.m21(), m_matrix.m22(), m_matrix.m23(), m_matrix.m24(),
63        m_matrix.m31(), m_matrix.m32(), m_matrix.m33(), m_matrix.m34(),
64        m_matrix.m41(), m_matrix.m42(), m_matrix.m43(), m_matrix.m44()
65    };
66
67    return Float64Array::create(array, 16);
68}
69
70} // namespace blink
71