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

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

Issue 2770253003: Revert of Move geometry interface files to geometry directory. (Closed)
Patch Set: Created 3 years, 9 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
(Empty)
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 #ifndef DOMMatrixReadOnly_h
6 #define DOMMatrixReadOnly_h
7
8 #include "bindings/core/v8/ExceptionState.h"
9 #include "bindings/core/v8/ScriptWrappable.h"
10 #include "core/dom/DOMTypedArray.h"
11 #include "platform/heap/Handle.h"
12 #include "platform/transforms/TransformationMatrix.h"
13 #include <memory>
14
15 namespace blink {
16
17 class DOMMatrix;
18 class DOMMatrixInit;
19 class DOMPoint;
20 class DOMPointInit;
21
22 class CORE_EXPORT DOMMatrixReadOnly
23 : public GarbageCollectedFinalized<DOMMatrixReadOnly>,
24 public ScriptWrappable {
25 DEFINE_WRAPPERTYPEINFO();
26
27 public:
28 static DOMMatrixReadOnly* create(ExceptionState&);
29 static DOMMatrixReadOnly* create(const String&, ExceptionState&);
30 static DOMMatrixReadOnly* create(Vector<double>, ExceptionState&);
31 static DOMMatrixReadOnly* fromFloat32Array(DOMFloat32Array*, ExceptionState&);
32 static DOMMatrixReadOnly* fromFloat64Array(DOMFloat64Array*, ExceptionState&);
33 static DOMMatrixReadOnly* fromMatrix(DOMMatrixInit&, ExceptionState&);
34 virtual ~DOMMatrixReadOnly();
35
36 double a() const { return m_matrix->m11(); }
37 double b() const { return m_matrix->m12(); }
38 double c() const { return m_matrix->m21(); }
39 double d() const { return m_matrix->m22(); }
40 double e() const { return m_matrix->m41(); }
41 double f() const { return m_matrix->m42(); }
42
43 double m11() const { return m_matrix->m11(); }
44 double m12() const { return m_matrix->m12(); }
45 double m13() const { return m_matrix->m13(); }
46 double m14() const { return m_matrix->m14(); }
47 double m21() const { return m_matrix->m21(); }
48 double m22() const { return m_matrix->m22(); }
49 double m23() const { return m_matrix->m23(); }
50 double m24() const { return m_matrix->m24(); }
51 double m31() const { return m_matrix->m31(); }
52 double m32() const { return m_matrix->m32(); }
53 double m33() const { return m_matrix->m33(); }
54 double m34() const { return m_matrix->m34(); }
55 double m41() const { return m_matrix->m41(); }
56 double m42() const { return m_matrix->m42(); }
57 double m43() const { return m_matrix->m43(); }
58 double m44() const { return m_matrix->m44(); }
59
60 bool is2D() const;
61 bool isIdentity() const;
62
63 DOMMatrix* multiply(DOMMatrixInit&, ExceptionState&);
64 DOMMatrix* translate(double tx = 0, double ty = 0, double tz = 0);
65 DOMMatrix* scale(double sx = 1);
66 DOMMatrix* scale(double sx,
67 double sy,
68 double sz = 1,
69 double ox = 0,
70 double oy = 0,
71 double oz = 0);
72 DOMMatrix* scale3d(double scale = 1,
73 double ox = 0,
74 double oy = 0,
75 double oz = 0);
76 DOMMatrix* rotate(double rotX);
77 DOMMatrix* rotate(double rotX, double rotY);
78 DOMMatrix* rotate(double rotX, double rotY, double rotZ);
79 DOMMatrix* rotateFromVector(double x, double y);
80 DOMMatrix* rotateAxisAngle(double x = 0,
81 double y = 0,
82 double z = 0,
83 double angle = 0);
84 DOMMatrix* skewX(double sx);
85 DOMMatrix* skewY(double sy);
86 DOMMatrix* flipX();
87 DOMMatrix* flipY();
88 DOMMatrix* inverse();
89
90 DOMPoint* transformPoint(const DOMPointInit&);
91
92 DOMFloat32Array* toFloat32Array() const;
93 DOMFloat64Array* toFloat64Array() const;
94
95 const String toString() const;
96
97 ScriptValue toJSONForBinding(ScriptState*) const;
98
99 const TransformationMatrix& matrix() const { return *m_matrix; }
100
101 DEFINE_INLINE_TRACE() {}
102
103 protected:
104 DOMMatrixReadOnly() {}
105 DOMMatrixReadOnly(const String&, ExceptionState&);
106 DOMMatrixReadOnly(const TransformationMatrix&, bool is2D = true);
107
108 template <typename T>
109 DOMMatrixReadOnly(T sequence, int size) {
110 if (size == 6) {
111 m_matrix =
112 TransformationMatrix::create(sequence[0], sequence[1], sequence[2],
113 sequence[3], sequence[4], sequence[5]);
114 m_is2D = true;
115 } else if (size == 16) {
116 m_matrix = TransformationMatrix::create(
117 sequence[0], sequence[1], sequence[2], sequence[3], sequence[4],
118 sequence[5], sequence[6], sequence[7], sequence[8], sequence[9],
119 sequence[10], sequence[11], sequence[12], sequence[13], sequence[14],
120 sequence[15]);
121 m_is2D = false;
122 } else {
123 NOTREACHED();
124 }
125 }
126
127 void setMatrixValueFromString(const String&, ExceptionState&);
128
129 static bool validateAndFixup(DOMMatrixInit&, ExceptionState&);
130 // TransformationMatrix needs to be 16-byte aligned. PartitionAlloc
131 // supports 16-byte alignment but Oilpan doesn't. So we use an std::unique_ptr
132 // to allocate TransformationMatrix on PartitionAlloc.
133 // TODO(oilpan): Oilpan should support 16-byte aligned allocations.
134 std::unique_ptr<TransformationMatrix> m_matrix;
135 bool m_is2D;
136 };
137
138 } // namespace blink
139
140 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698