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

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

Issue 2423753002: [GeometryInterface] add transformPoint(point) function. (Closed)
Patch Set: update test msg. Created 4 years, 1 month 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
Index: third_party/WebKit/Source/core/dom/DOMMatrixReadOnly.cpp
diff --git a/third_party/WebKit/Source/core/dom/DOMMatrixReadOnly.cpp b/third_party/WebKit/Source/core/dom/DOMMatrixReadOnly.cpp
index b0a49af8abac3ee38fd3451ed6d6656ba891a2fe..0b34d8bf78ff3d29f3704b555fc54322095281db 100644
--- a/third_party/WebKit/Source/core/dom/DOMMatrixReadOnly.cpp
+++ b/third_party/WebKit/Source/core/dom/DOMMatrixReadOnly.cpp
@@ -7,6 +7,8 @@
#include "bindings/core/v8/V8ObjectBuilder.h"
#include "core/dom/DOMMatrix.h"
#include "core/dom/DOMMatrixInit.h"
+#include "core/dom/DOMPoint.h"
+#include "core/dom/DOMPointInit.h"
namespace blink {
namespace {
@@ -229,6 +231,24 @@ DOMMatrix* DOMMatrixReadOnly::inverse() {
return DOMMatrix::create(this)->invertSelf();
}
+DOMPoint* DOMMatrixReadOnly::transformPoint(const DOMPointInit& point) {
+ if (is2D() && point.z() == 0 && point.w() == 1) {
+ double x = point.x() * m11() + point.y() * m12() + m41();
+ double y = point.x() * m12() + point.y() * m22() + m42();
+ return DOMPoint::create(x, y, 0, 1);
+ }
+
+ double x = point.x() * m11() + point.y() * m21() + point.z() * m31() +
+ point.w() * m41();
+ double y = point.x() * m12() + point.y() * m22() + point.z() * m32() +
+ point.w() * m42();
+ double z = point.x() * m13() + point.y() * m23() + point.z() * m33() +
+ point.w() * m43();
+ double w = point.x() * m14() + point.y() * m24() + point.z() * m34() +
+ point.w() * m44();
+ return DOMPoint::create(x, y, z, w);
+}
+
DOMFloat32Array* DOMMatrixReadOnly::toFloat32Array() const {
float array[] = {
static_cast<float>(m_matrix->m11()), static_cast<float>(m_matrix->m12()),
« no previous file with comments | « third_party/WebKit/Source/core/dom/DOMMatrixReadOnly.h ('k') | third_party/WebKit/Source/core/dom/DOMMatrixReadOnly.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698