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 #include "core/dom/DOMMatrix.h" | 5 #include "core/dom/DOMMatrix.h" |
6 | 6 |
7 namespace blink { | 7 namespace blink { |
8 | 8 |
9 DOMMatrixReadOnly* DOMMatrixReadOnly::create(Vector<double> sequence, ExceptionS tate& exceptionState) | 9 DOMMatrixReadOnly* DOMMatrixReadOnly::create(Vector<double> sequence, ExceptionS tate& exceptionState) |
10 { | 10 { |
(...skipping 16 matching lines...) Expand all Loading... | |
27 sequence[0], sequence[1], sequence[2], sequence[3], | 27 sequence[0], sequence[1], sequence[2], sequence[3], |
28 sequence[4], sequence[5], sequence[6], sequence[7], | 28 sequence[4], sequence[5], sequence[6], sequence[7], |
29 sequence[8], sequence[9], sequence[10], sequence[11], | 29 sequence[8], sequence[9], sequence[10], sequence[11], |
30 sequence[12], sequence[13], sequence[14], sequence[15]); | 30 sequence[12], sequence[13], sequence[14], sequence[15]); |
31 m_is2D = false; | 31 m_is2D = false; |
32 } else { | 32 } else { |
33 NOTREACHED(); | 33 NOTREACHED(); |
34 } | 34 } |
35 } | 35 } |
36 | 36 |
37 DOMMatrixReadOnly* DOMMatrixReadOnly::fromFloat32Array(DOMFloat32Array* float32A rray, ExceptionState& exceptionState) | |
38 { | |
39 if (float32Array->length() != 6 && float32Array->length() != 16) { | |
40 exceptionState.throwTypeError("An invalid number sequence is specified. The sequence must contain 6 elements for 2D matrix and 16 elements for 3D matrix ."); | |
41 return nullptr; | |
42 } | |
43 return new DOMMatrixReadOnly(float32Array); | |
44 } | |
45 | |
46 DOMMatrixReadOnly::DOMMatrixReadOnly(DOMFloat32Array* float32Array) | |
47 { | |
48 float* array = float32Array->data(); | |
49 if (float32Array->length() == 6) { | |
zino
2016/09/04 23:11:53
This logic is duplicated with below constructor. (
Hwanseung Lee
2016/09/05 12:58:47
i did resolve it.
| |
50 m_matrix = TransformationMatrix::create( | |
51 array[0], array[1], array[2], array[3], | |
52 array[4], array[5]); | |
53 m_is2D = true; | |
54 } else if (float32Array->length() == 16) { | |
55 m_matrix = TransformationMatrix::create( | |
56 array[0], array[1], array[2], array[3], | |
57 array[4], array[5], array[6], array[7], | |
58 array[8], array[9], array[10], array[11], | |
59 array[12], array[13], array[14], array[15]); | |
60 m_is2D = false; | |
61 } else { | |
62 NOTREACHED(); | |
63 } | |
64 } | |
65 | |
66 DOMMatrixReadOnly* DOMMatrixReadOnly::fromFloat64Array(DOMFloat64Array* float64A rray, ExceptionState& exceptionState) | |
67 { | |
68 if (float64Array->length() != 6 && float64Array->length() != 16) { | |
69 exceptionState.throwTypeError("An invalid number sequence is specified. The sequence must contain 6 elements for 2D matrix and 16 elements for 3D matrix ."); | |
70 return nullptr; | |
71 } | |
72 return new DOMMatrixReadOnly(float64Array); | |
73 } | |
74 | |
75 DOMMatrixReadOnly::DOMMatrixReadOnly(DOMFloat64Array* float64Array) | |
76 { | |
77 double* array = float64Array->data(); | |
78 if (float64Array->length() == 6) { | |
79 m_matrix = TransformationMatrix::create( | |
80 array[0], array[1], array[2], array[3], | |
81 array[4], array[5]); | |
82 m_is2D = true; | |
83 } else if (float64Array->length() == 16) { | |
84 m_matrix = TransformationMatrix::create( | |
85 array[0], array[1], array[2], array[3], | |
86 array[4], array[5], array[6], array[7], | |
87 array[8], array[9], array[10], array[11], | |
88 array[12], array[13], array[14], array[15]); | |
89 m_is2D = false; | |
90 } else { | |
91 NOTREACHED(); | |
92 } | |
93 } | |
94 | |
37 DOMMatrixReadOnly::~DOMMatrixReadOnly() | 95 DOMMatrixReadOnly::~DOMMatrixReadOnly() |
38 { | 96 { |
39 } | 97 } |
40 | 98 |
41 bool DOMMatrixReadOnly::is2D() const | 99 bool DOMMatrixReadOnly::is2D() const |
42 { | 100 { |
43 return m_is2D; | 101 return m_is2D; |
44 } | 102 } |
45 | 103 |
46 bool DOMMatrixReadOnly::isIdentity() const | 104 bool DOMMatrixReadOnly::isIdentity() const |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
146 << m21() << ", " << m22() << ", " << m23() << ", " << m24() << ", " | 204 << m21() << ", " << m22() << ", " << m23() << ", " << m24() << ", " |
147 << m31() << ", " << m32() << ", " << m33() << ", " << m34() << ", " | 205 << m31() << ", " << m32() << ", " << m33() << ", " << m34() << ", " |
148 << m41() << ", " << m42() << ", " << m43() << ", " << m44(); | 206 << m41() << ", " << m42() << ", " << m43() << ", " << m44(); |
149 } | 207 } |
150 stream << ")"; | 208 stream << ")"; |
151 | 209 |
152 return String(stream.str().c_str()); | 210 return String(stream.str().c_str()); |
153 } | 211 } |
154 | 212 |
155 } // namespace blink | 213 } // namespace blink |
OLD | NEW |