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

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

Issue 2309013002: [GeometryInterface] Add fromFloat32Array & fromFloat64Array function (Closed)
Patch Set: [GeometryInterface] Add fromFloat32Array & fromFloat64Array function 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/dom/DOMMatrix.h ('k') | third_party/WebKit/Source/core/dom/DOMMatrix.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..726e316b21d69bd9b89a7926164d24ebfbd15fc7 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("The sequence must contain 6 elements for a 2D matrix or 16 elements for a 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("The sequence must contain 6 elements for a 2D matrix or 16 elements for a 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);
« no previous file with comments | « third_party/WebKit/Source/core/dom/DOMMatrix.h ('k') | third_party/WebKit/Source/core/dom/DOMMatrix.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698