| 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(ExceptionState&); |
| 29 static DOMMatrixReadOnly* create(const String&, ExceptionState&); |
| 29 static DOMMatrixReadOnly* create(Vector<double>, ExceptionState&); | 30 static DOMMatrixReadOnly* create(Vector<double>, ExceptionState&); |
| 30 static DOMMatrixReadOnly* fromFloat32Array(DOMFloat32Array*, ExceptionState&); | 31 static DOMMatrixReadOnly* fromFloat32Array(DOMFloat32Array*, ExceptionState&); |
| 31 static DOMMatrixReadOnly* fromFloat64Array(DOMFloat64Array*, ExceptionState&); | 32 static DOMMatrixReadOnly* fromFloat64Array(DOMFloat64Array*, ExceptionState&); |
| 32 static DOMMatrixReadOnly* fromMatrix(DOMMatrixInit&, ExceptionState&); | 33 static DOMMatrixReadOnly* fromMatrix(DOMMatrixInit&, ExceptionState&); |
| 33 virtual ~DOMMatrixReadOnly(); | 34 virtual ~DOMMatrixReadOnly(); |
| 34 | 35 |
| 35 double a() const { return m_matrix->m11(); } | 36 double a() const { return m_matrix->m11(); } |
| 36 double b() const { return m_matrix->m12(); } | 37 double b() const { return m_matrix->m12(); } |
| 37 double c() const { return m_matrix->m21(); } | 38 double c() const { return m_matrix->m21(); } |
| 38 double d() const { return m_matrix->m22(); } | 39 double d() const { return m_matrix->m22(); } |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 const String toString() const; | 95 const String toString() const; |
| 95 | 96 |
| 96 ScriptValue toJSONForBinding(ScriptState*) const; | 97 ScriptValue toJSONForBinding(ScriptState*) const; |
| 97 | 98 |
| 98 const TransformationMatrix& matrix() const { return *m_matrix; } | 99 const TransformationMatrix& matrix() const { return *m_matrix; } |
| 99 | 100 |
| 100 DEFINE_INLINE_TRACE() {} | 101 DEFINE_INLINE_TRACE() {} |
| 101 | 102 |
| 102 protected: | 103 protected: |
| 103 DOMMatrixReadOnly() {} | 104 DOMMatrixReadOnly() {} |
| 105 DOMMatrixReadOnly(const String&, ExceptionState&); |
| 104 DOMMatrixReadOnly(const TransformationMatrix&, bool is2D = true); | 106 DOMMatrixReadOnly(const TransformationMatrix&, bool is2D = true); |
| 105 | 107 |
| 106 template <typename T> | 108 template <typename T> |
| 107 DOMMatrixReadOnly(T sequence, int size) { | 109 DOMMatrixReadOnly(T sequence, int size) { |
| 108 if (size == 6) { | 110 if (size == 6) { |
| 109 m_matrix = | 111 m_matrix = |
| 110 TransformationMatrix::create(sequence[0], sequence[1], sequence[2], | 112 TransformationMatrix::create(sequence[0], sequence[1], sequence[2], |
| 111 sequence[3], sequence[4], sequence[5]); | 113 sequence[3], sequence[4], sequence[5]); |
| 112 m_is2D = true; | 114 m_is2D = true; |
| 113 } else if (size == 16) { | 115 } else if (size == 16) { |
| 114 m_matrix = TransformationMatrix::create( | 116 m_matrix = TransformationMatrix::create( |
| 115 sequence[0], sequence[1], sequence[2], sequence[3], sequence[4], | 117 sequence[0], sequence[1], sequence[2], sequence[3], sequence[4], |
| 116 sequence[5], sequence[6], sequence[7], sequence[8], sequence[9], | 118 sequence[5], sequence[6], sequence[7], sequence[8], sequence[9], |
| 117 sequence[10], sequence[11], sequence[12], sequence[13], sequence[14], | 119 sequence[10], sequence[11], sequence[12], sequence[13], sequence[14], |
| 118 sequence[15]); | 120 sequence[15]); |
| 119 m_is2D = false; | 121 m_is2D = false; |
| 120 } else { | 122 } else { |
| 121 NOTREACHED(); | 123 NOTREACHED(); |
| 122 } | 124 } |
| 123 } | 125 } |
| 124 | 126 |
| 127 void setMatrixValueFromString(const String&, ExceptionState&); |
| 128 |
| 125 static bool validateAndFixup(DOMMatrixInit&, ExceptionState&); | 129 static bool validateAndFixup(DOMMatrixInit&, ExceptionState&); |
| 126 // TransformationMatrix needs to be 16-byte aligned. PartitionAlloc | 130 // TransformationMatrix needs to be 16-byte aligned. PartitionAlloc |
| 127 // supports 16-byte alignment but Oilpan doesn't. So we use an std::unique_ptr | 131 // supports 16-byte alignment but Oilpan doesn't. So we use an std::unique_ptr |
| 128 // to allocate TransformationMatrix on PartitionAlloc. | 132 // to allocate TransformationMatrix on PartitionAlloc. |
| 129 // TODO(oilpan): Oilpan should support 16-byte aligned allocations. | 133 // TODO(oilpan): Oilpan should support 16-byte aligned allocations. |
| 130 std::unique_ptr<TransformationMatrix> m_matrix; | 134 std::unique_ptr<TransformationMatrix> m_matrix; |
| 131 bool m_is2D; | 135 bool m_is2D; |
| 132 }; | 136 }; |
| 133 | 137 |
| 134 } // namespace blink | 138 } // namespace blink |
| 135 | 139 |
| 136 #endif | 140 #endif |
| OLD | NEW |