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

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

Issue 2283363003: GeometryInterface: Add DOMMatrixInit and fromMatrix(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed comments 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 class DOMMatrixInit;
18 19
19 class DOMMatrixReadOnly : public GarbageCollectedFinalized<DOMMatrixReadOnly>, p ublic ScriptWrappable { 20 class CORE_EXPORT DOMMatrixReadOnly : public GarbageCollectedFinalized<DOMMatrix ReadOnly>, public ScriptWrappable {
20 DEFINE_WRAPPERTYPEINFO(); 21 DEFINE_WRAPPERTYPEINFO();
21 public: 22 public:
22 static DOMMatrixReadOnly* create(Vector<double>, ExceptionState&); 23 static DOMMatrixReadOnly* create(Vector<double>, ExceptionState&);
24 static DOMMatrixReadOnly* fromMatrix(DOMMatrixInit&, ExceptionState&);
23 virtual ~DOMMatrixReadOnly(); 25 virtual ~DOMMatrixReadOnly();
24 26
25 double a() const { return m_matrix->m11(); } 27 double a() const { return m_matrix->m11(); }
26 double b() const { return m_matrix->m12(); } 28 double b() const { return m_matrix->m12(); }
27 double c() const { return m_matrix->m21(); } 29 double c() const { return m_matrix->m21(); }
28 double d() const { return m_matrix->m22(); } 30 double d() const { return m_matrix->m22(); }
29 double e() const { return m_matrix->m41(); } 31 double e() const { return m_matrix->m41(); }
30 double f() const { return m_matrix->m42(); } 32 double f() const { return m_matrix->m42(); }
31 33
32 double m11() const { return m_matrix->m11(); } 34 double m11() const { return m_matrix->m11(); }
33 double m12() const { return m_matrix->m12(); } 35 double m12() const { return m_matrix->m12(); }
34 double m13() const { return m_matrix->m13(); } 36 double m13() const { return m_matrix->m13(); }
35 double m14() const { return m_matrix->m14(); } 37 double m14() const { return m_matrix->m14(); }
36 double m21() const { return m_matrix->m21(); } 38 double m21() const { return m_matrix->m21(); }
37 double m22() const { return m_matrix->m22(); } 39 double m22() const { return m_matrix->m22(); }
38 double m23() const { return m_matrix->m23(); } 40 double m23() const { return m_matrix->m23(); }
39 double m24() const { return m_matrix->m24(); } 41 double m24() const { return m_matrix->m24(); }
40 double m31() const { return m_matrix->m31(); } 42 double m31() const { return m_matrix->m31(); }
41 double m32() const { return m_matrix->m32(); } 43 double m32() const { return m_matrix->m32(); }
42 double m33() const { return m_matrix->m33(); } 44 double m33() const { return m_matrix->m33(); }
43 double m34() const { return m_matrix->m34(); } 45 double m34() const { return m_matrix->m34(); }
44 double m41() const { return m_matrix->m41(); } 46 double m41() const { return m_matrix->m41(); }
45 double m42() const { return m_matrix->m42(); } 47 double m42() const { return m_matrix->m42(); }
46 double m43() const { return m_matrix->m43(); } 48 double m43() const { return m_matrix->m43(); }
47 double m44() const { return m_matrix->m44(); } 49 double m44() const { return m_matrix->m44(); }
48 50
49 bool is2D() const; 51 bool is2D() const;
50 bool isIdentity() const; 52 bool isIdentity() const;
51 53
52 DOMMatrix* multiply(DOMMatrix*); 54 DOMMatrix* multiply(DOMMatrixInit&, ExceptionState&);
53 DOMMatrix* translate(double tx, double ty, double tz = 0); 55 DOMMatrix* translate(double tx, double ty, double tz = 0);
54 DOMMatrix* scale(double scale, double ox = 0, double oy = 0); 56 DOMMatrix* scale(double scale, double ox = 0, double oy = 0);
55 DOMMatrix* scale3d(double scale, double ox = 0, double oy = 0, double oz = 0 ); 57 DOMMatrix* scale3d(double scale, double ox = 0, double oy = 0, double oz = 0 );
56 DOMMatrix* scaleNonUniform(double sx, double sy = 1, double sz = 1, 58 DOMMatrix* scaleNonUniform(double sx, double sy = 1, double sz = 1,
57 double ox = 0, double oy = 0, double oz = 0); 59 double ox = 0, double oy = 0, double oz = 0);
58 DOMMatrix* skewX(double sx); 60 DOMMatrix* skewX(double sx);
59 DOMMatrix* skewY(double sy); 61 DOMMatrix* skewY(double sy);
60 DOMMatrix* flipX(); 62 DOMMatrix* flipX();
61 DOMMatrix* flipY(); 63 DOMMatrix* flipY();
62 DOMMatrix* inverse(); 64 DOMMatrix* inverse();
63 65
64 DOMFloat32Array* toFloat32Array() const; 66 DOMFloat32Array* toFloat32Array() const;
65 DOMFloat64Array* toFloat64Array() const; 67 DOMFloat64Array* toFloat64Array() const;
66 68
67 const String toString() const; 69 const String toString() const;
68 70
69 const TransformationMatrix& matrix() const { return *m_matrix; } 71 const TransformationMatrix& matrix() const { return *m_matrix; }
70 72
71 DEFINE_INLINE_TRACE() { } 73 DEFINE_INLINE_TRACE() { }
72 74
73 protected: 75 protected:
74 DOMMatrixReadOnly() {} 76 DOMMatrixReadOnly() {}
77 static bool validateAndFixup(DOMMatrixInit&, ExceptionState&);
75 // TransformationMatrix needs to be 16-byte aligned. PartitionAlloc 78 // 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 79 // supports 16-byte alignment but Oilpan doesn't. So we use an std::unique_p tr
77 // to allocate TransformationMatrix on PartitionAlloc. 80 // to allocate TransformationMatrix on PartitionAlloc.
78 // TODO(oilpan): Oilpan should support 16-byte aligned allocations. 81 // TODO(oilpan): Oilpan should support 16-byte aligned allocations.
79 std::unique_ptr<TransformationMatrix> m_matrix; 82 std::unique_ptr<TransformationMatrix> m_matrix;
80 bool m_is2D; 83 bool m_is2D;
81 84
82 private: 85 private:
83 DOMMatrixReadOnly(Vector<double> sequence); 86 DOMMatrixReadOnly(Vector<double> sequence);
84 }; 87 };
85 88
86 } // namespace blink 89 } // namespace blink
87 90
88 #endif 91 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698