Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(664)

Side by Side Diff: third_party/WebKit/Source/core/dom/DOMMatrixReadOnly.h

Issue 2309013002: [GeometryInterface] Add fromFloat32Array & fromFloat64Array function (Closed)
Patch Set: [GeometryInterface] Add fromFloat32Array & fromFloat64Array function Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 18
19 class DOMMatrixReadOnly : public GarbageCollectedFinalized<DOMMatrixReadOnly>, p ublic ScriptWrappable { 19 class DOMMatrixReadOnly : public GarbageCollectedFinalized<DOMMatrixReadOnly>, p ublic ScriptWrappable {
20 DEFINE_WRAPPERTYPEINFO(); 20 DEFINE_WRAPPERTYPEINFO();
21 public: 21 public:
22 static DOMMatrixReadOnly* create(Vector<double>, ExceptionState&); 22 static DOMMatrixReadOnly* create(Vector<double>, ExceptionState&);
23 static DOMMatrixReadOnly* fromFloat32Array(DOMFloat32Array*, ExceptionState& );
24 static DOMMatrixReadOnly* fromFloat64Array(DOMFloat64Array*, ExceptionState& );
25
23 virtual ~DOMMatrixReadOnly(); 26 virtual ~DOMMatrixReadOnly();
24 27
25 double a() const { return m_matrix->m11(); } 28 double a() const { return m_matrix->m11(); }
26 double b() const { return m_matrix->m12(); } 29 double b() const { return m_matrix->m12(); }
27 double c() const { return m_matrix->m21(); } 30 double c() const { return m_matrix->m21(); }
28 double d() const { return m_matrix->m22(); } 31 double d() const { return m_matrix->m22(); }
29 double e() const { return m_matrix->m41(); } 32 double e() const { return m_matrix->m41(); }
30 double f() const { return m_matrix->m42(); } 33 double f() const { return m_matrix->m42(); }
31 34
32 double m11() const { return m_matrix->m11(); } 35 double m11() const { return m_matrix->m11(); }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 DOMFloat64Array* toFloat64Array() const; 68 DOMFloat64Array* toFloat64Array() const;
66 69
67 const String toString() const; 70 const String toString() const;
68 71
69 const TransformationMatrix& matrix() const { return *m_matrix; } 72 const TransformationMatrix& matrix() const { return *m_matrix; }
70 73
71 DEFINE_INLINE_TRACE() { } 74 DEFINE_INLINE_TRACE() { }
72 75
73 protected: 76 protected:
74 DOMMatrixReadOnly() {} 77 DOMMatrixReadOnly() {}
78
79 template <typename T>
80 DOMMatrixReadOnly(T sequence, int size)
81 {
82 if (size == 6) {
83 m_matrix = TransformationMatrix::create(
84 sequence[0], sequence[1], sequence[2], sequence[3],
85 sequence[4], sequence[5]);
86 m_is2D = true;
87 } else if (size == 16) {
88 m_matrix = TransformationMatrix::create(
89 sequence[0], sequence[1], sequence[2], sequence[3],
90 sequence[4], sequence[5], sequence[6], sequence[7],
91 sequence[8], sequence[9], sequence[10], sequence[11],
92 sequence[12], sequence[13], sequence[14], sequence[15]);
93 m_is2D = false;
94 } else {
95 NOTREACHED();
96 }
97 }
98
75 // TransformationMatrix needs to be 16-byte aligned. PartitionAlloc 99 // TransformationMatrix needs to be 16-byte aligned. PartitionAlloc
76 // supports 16-byte alignment but Oilpan doesn't. So we use an std::unique_p tr 100 // supports 16-byte alignment but Oilpan doesn't. So we use an std::unique_p tr
77 // to allocate TransformationMatrix on PartitionAlloc. 101 // to allocate TransformationMatrix on PartitionAlloc.
78 // TODO(oilpan): Oilpan should support 16-byte aligned allocations. 102 // TODO(oilpan): Oilpan should support 16-byte aligned allocations.
79 std::unique_ptr<TransformationMatrix> m_matrix; 103 std::unique_ptr<TransformationMatrix> m_matrix;
80 bool m_is2D; 104 bool m_is2D;
81
82 private:
83 DOMMatrixReadOnly(Vector<double> sequence);
84 }; 105 };
85 106
86 } // namespace blink 107 } // namespace blink
87 108
88 #endif 109 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/DOMMatrix.idl ('k') | third_party/WebKit/Source/core/dom/DOMMatrixReadOnly.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698