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

Side by Side Diff: third_party/WebKit/Source/core/dom/DOMMatrix.cpp

Issue 2309013002: [GeometryInterface] Add fromFloat32Array & fromFloat64Array function (Closed)
Patch Set: 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 #include "core/dom/DOMMatrix.h" 5 #include "core/dom/DOMMatrix.h"
6 6
7 namespace blink { 7 namespace blink {
8 8
9 DOMMatrix* DOMMatrix::create() 9 DOMMatrix* DOMMatrix::create()
10 { 10 {
11 return new DOMMatrix(TransformationMatrix()); 11 return new DOMMatrix(TransformationMatrix());
12 } 12 }
13 13
14 DOMMatrix* DOMMatrix::create(DOMMatrixReadOnly* other) 14 DOMMatrix* DOMMatrix::create(DOMMatrixReadOnly* other)
15 { 15 {
16 return new DOMMatrix(other->matrix(), other->is2D()); 16 return new DOMMatrix(other->matrix(), other->is2D());
17 } 17 }
18 18
19 DOMMatrix* DOMMatrix::create(const SkMatrix44& matrix) 19 DOMMatrix* DOMMatrix::create(const SkMatrix44& matrix)
20 { 20 {
21 TransformationMatrix transformationMatrix(matrix); 21 TransformationMatrix transformationMatrix(matrix);
22 return new DOMMatrix(transformationMatrix, transformationMatrix.isAffine()); 22 return new DOMMatrix(transformationMatrix, transformationMatrix.isAffine());
23 } 23 }
24 24
25 DOMMatrix* DOMMatrix::fromFloat32Array(DOMFloat32Array* float32Array, ExceptionS tate& exceptionState)
26 {
27 if (float32Array->length() != 6 && float32Array->length() != 16) {
28 exceptionState.throwTypeError("An invalid number sequence is specified. The sequence must contain 6 elements for 2D matrix and 16 elements for 3D matrix .");
29 return nullptr;
30 }
31 return new DOMMatrix(float32Array);
32 }
33
34 DOMMatrix* DOMMatrix::fromFloat64Array(DOMFloat64Array* float64Array, ExceptionS tate& exceptionState)
35 {
36 if (float64Array->length() != 6 && float64Array->length() != 16) {
37 exceptionState.throwTypeError("An invalid number sequence is specified. The sequence must contain 6 elements for 2D matrix and 16 elements for 3D matrix .");
38 return nullptr;
39 }
40 return new DOMMatrix(float64Array);
41 }
42
43 DOMMatrix::DOMMatrix(DOMFloat32Array* float32Array) : DOMMatrixReadOnly(float32A rray)
44 {
45 }
46
47 DOMMatrix::DOMMatrix(DOMFloat64Array* float64Array) : DOMMatrixReadOnly(float64A rray)
48 {
49 }
50
25 DOMMatrix::DOMMatrix(const TransformationMatrix& matrix, bool is2D) 51 DOMMatrix::DOMMatrix(const TransformationMatrix& matrix, bool is2D)
26 { 52 {
27 m_matrix = TransformationMatrix::create(matrix); 53 m_matrix = TransformationMatrix::create(matrix);
28 m_is2D = is2D; 54 m_is2D = is2D;
29 } 55 }
30 56
31 void DOMMatrix::setIs2D(bool value) 57 void DOMMatrix::setIs2D(bool value)
32 { 58 {
33 if (m_is2D) 59 if (m_is2D)
34 m_is2D = value; 60 m_is2D = value;
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 setM41(NAN); 164 setM41(NAN);
139 setM42(NAN); 165 setM42(NAN);
140 setM43(NAN); 166 setM43(NAN);
141 setM44(NAN); 167 setM44(NAN);
142 setIs2D(false); 168 setIs2D(false);
143 } 169 }
144 return this; 170 return this;
145 } 171 }
146 172
147 } // namespace blink 173 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698