Chromium Code Reviews

Unified Diff: third_party/WebKit/Source/core/dom/DOMMatrix.cpp

Issue 2309013002: [GeometryInterface] Add fromFloat32Array & fromFloat64Array function (Closed)
Patch Set: Implement fromFloat32Array & fromFloat64Array function in DOMMatrix & DOMMatrixReadOnly. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Index: third_party/WebKit/Source/core/dom/DOMMatrix.cpp
diff --git a/third_party/WebKit/Source/core/dom/DOMMatrix.cpp b/third_party/WebKit/Source/core/dom/DOMMatrix.cpp
index a76c25e6d41b6c2feb80e4c458a53bc8b4dcc44a..9b6378a8549f4cc706cc50aa52458c83d0ed9079 100644
--- a/third_party/WebKit/Source/core/dom/DOMMatrix.cpp
+++ b/third_party/WebKit/Source/core/dom/DOMMatrix.cpp
@@ -22,6 +22,29 @@ DOMMatrix* DOMMatrix::create(const SkMatrix44& matrix)
return new DOMMatrix(transformationMatrix, transformationMatrix.isAffine());
}
+DOMMatrix* DOMMatrix::fromFloat32Array(DOMFloat32Array* float32Array, ExceptionState& exceptionState)
+{
+ if (float32Array->length() != 6 && float32Array->length() != 16) {
+ exceptionState.throwTypeError("An invalid number sequence is specified. The sequence must contain 6 elements for 2D matrix and 16 elements for 3D matrix.");
+ return nullptr;
+ }
+ return new DOMMatrix(float32Array->data(), float32Array->length());
+}
+
+DOMMatrix* DOMMatrix::fromFloat64Array(DOMFloat64Array* float64Array, ExceptionState& exceptionState)
+{
+ if (float64Array->length() != 6 && float64Array->length() != 16) {
+ exceptionState.throwTypeError("An invalid number sequence is specified. The sequence must contain 6 elements for 2D matrix and 16 elements for 3D matrix.");
+ return nullptr;
+ }
+ return new DOMMatrix(float64Array->data(), float64Array->length());
+}
+
+template <typename T>
+DOMMatrix::DOMMatrix(T sequence, int size) : DOMMatrixReadOnly(sequence, size)
+{
+}
+
DOMMatrix::DOMMatrix(const TransformationMatrix& matrix, bool is2D)
{
m_matrix = TransformationMatrix::create(matrix);

Powered by Google App Engine