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 #ifndef DOMMatrixReadOnly_h | 5 #ifndef DOMMatrixReadOnly_h |
6 #define DOMMatrixReadOnly_h | 6 #define DOMMatrixReadOnly_h |
7 | 7 |
8 #include "bindings/core/v8/ExceptionState.h" | 8 #include "bindings/core/v8/ExceptionState.h" |
9 #include "bindings/core/v8/ScriptWrappable.h" | 9 #include "bindings/core/v8/ScriptWrappable.h" |
10 #include "core/dom/DOMTypedArray.h" | 10 #include "core/dom/DOMTypedArray.h" |
11 #include "platform/heap/Handle.h" | 11 #include "platform/heap/Handle.h" |
12 #include "platform/transforms/TransformationMatrix.h" | 12 #include "platform/transforms/TransformationMatrix.h" |
13 #include <memory> | 13 #include <memory> |
14 | 14 |
15 namespace blink { | 15 namespace blink { |
16 | 16 |
17 class DOMMatrix; | 17 class DOMMatrix; |
18 class DOMMatrixInit; | 18 class DOMMatrixInit; |
19 class DOMPoint; | 19 class DOMPoint; |
20 class DOMPointInit; | 20 class DOMPointInit; |
21 | 21 |
22 class CORE_EXPORT DOMMatrixReadOnly | 22 class CORE_EXPORT DOMMatrixReadOnly |
23 : public GarbageCollectedFinalized<DOMMatrixReadOnly>, | 23 : public GarbageCollectedFinalized<DOMMatrixReadOnly>, |
24 public ScriptWrappable { | 24 public ScriptWrappable { |
25 DEFINE_WRAPPERTYPEINFO(); | 25 DEFINE_WRAPPERTYPEINFO(); |
26 | 26 |
27 public: | 27 public: |
| 28 static DOMMatrixReadOnly* create(ExceptionState&); |
28 static DOMMatrixReadOnly* create(Vector<double>, ExceptionState&); | 29 static DOMMatrixReadOnly* create(Vector<double>, ExceptionState&); |
29 static DOMMatrixReadOnly* fromFloat32Array(DOMFloat32Array*, ExceptionState&); | 30 static DOMMatrixReadOnly* fromFloat32Array(DOMFloat32Array*, ExceptionState&); |
30 static DOMMatrixReadOnly* fromFloat64Array(DOMFloat64Array*, ExceptionState&); | 31 static DOMMatrixReadOnly* fromFloat64Array(DOMFloat64Array*, ExceptionState&); |
31 static DOMMatrixReadOnly* fromMatrix(DOMMatrixInit&, ExceptionState&); | 32 static DOMMatrixReadOnly* fromMatrix(DOMMatrixInit&, ExceptionState&); |
32 virtual ~DOMMatrixReadOnly(); | 33 virtual ~DOMMatrixReadOnly(); |
33 | 34 |
34 double a() const { return m_matrix->m11(); } | 35 double a() const { return m_matrix->m11(); } |
35 double b() const { return m_matrix->m12(); } | 36 double b() const { return m_matrix->m12(); } |
36 double c() const { return m_matrix->m21(); } | 37 double c() const { return m_matrix->m21(); } |
37 double d() const { return m_matrix->m22(); } | 38 double d() const { return m_matrix->m22(); } |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 const String toString() const; | 94 const String toString() const; |
94 | 95 |
95 ScriptValue toJSONForBinding(ScriptState*) const; | 96 ScriptValue toJSONForBinding(ScriptState*) const; |
96 | 97 |
97 const TransformationMatrix& matrix() const { return *m_matrix; } | 98 const TransformationMatrix& matrix() const { return *m_matrix; } |
98 | 99 |
99 DEFINE_INLINE_TRACE() {} | 100 DEFINE_INLINE_TRACE() {} |
100 | 101 |
101 protected: | 102 protected: |
102 DOMMatrixReadOnly() {} | 103 DOMMatrixReadOnly() {} |
| 104 DOMMatrixReadOnly(const TransformationMatrix&, bool is2D = true); |
103 | 105 |
104 template <typename T> | 106 template <typename T> |
105 DOMMatrixReadOnly(T sequence, int size) { | 107 DOMMatrixReadOnly(T sequence, int size) { |
106 if (size == 6) { | 108 if (size == 6) { |
107 m_matrix = | 109 m_matrix = |
108 TransformationMatrix::create(sequence[0], sequence[1], sequence[2], | 110 TransformationMatrix::create(sequence[0], sequence[1], sequence[2], |
109 sequence[3], sequence[4], sequence[5]); | 111 sequence[3], sequence[4], sequence[5]); |
110 m_is2D = true; | 112 m_is2D = true; |
111 } else if (size == 16) { | 113 } else if (size == 16) { |
112 m_matrix = TransformationMatrix::create( | 114 m_matrix = TransformationMatrix::create( |
(...skipping 12 matching lines...) Expand all Loading... |
125 // supports 16-byte alignment but Oilpan doesn't. So we use an std::unique_ptr | 127 // supports 16-byte alignment but Oilpan doesn't. So we use an std::unique_ptr |
126 // to allocate TransformationMatrix on PartitionAlloc. | 128 // to allocate TransformationMatrix on PartitionAlloc. |
127 // TODO(oilpan): Oilpan should support 16-byte aligned allocations. | 129 // TODO(oilpan): Oilpan should support 16-byte aligned allocations. |
128 std::unique_ptr<TransformationMatrix> m_matrix; | 130 std::unique_ptr<TransformationMatrix> m_matrix; |
129 bool m_is2D; | 131 bool m_is2D; |
130 }; | 132 }; |
131 | 133 |
132 } // namespace blink | 134 } // namespace blink |
133 | 135 |
134 #endif | 136 #endif |
OLD | NEW |