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

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

Issue 446803002: Implement translate() and translateSelf() in DOMMatrix. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 4 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
Index: Source/core/dom/DOMMatrix.cpp
diff --git a/Source/core/dom/DOMMatrix.cpp b/Source/core/dom/DOMMatrix.cpp
index 59b27ccf9fcece18644f4a4e4be5a3b4d25115a4..e1fe9ae0ba05ee0838cccfd49e1ce0319bafdd8b 100644
--- a/Source/core/dom/DOMMatrix.cpp
+++ b/Source/core/dom/DOMMatrix.cpp
@@ -52,4 +52,31 @@ void DOMMatrix::setIs2D(bool value)
m_is2D = value;
}
+DOMMatrix* DOMMatrix::translateSelf(double tx, double ty, double tz)
+{
+ if (!tx && !ty && !tz)
+ return this;
+
+ if (tz)
+ m_is2D = false;
+
+ if (isIdentity()) {
krit 2014/08/08 06:24:15 Why don't you use TransformationMatrix here?
zino 2014/08/16 03:23:32 Done.
+ m_matrix[3][0] = tx;
+ m_matrix[3][1] = ty;
+ m_matrix[3][2] = tz;
+ } else {
+ m_matrix[3][0] += tx * m11() + ty * m21();
+ m_matrix[3][1] += tx * m12() + ty * m22();
+
+ if (!m_is2D) {
+ m_matrix[3][0] += tz * m31();
+ m_matrix[3][1] += tz * m32();
+ m_matrix[3][2] += tx * m13() + ty * m23() + tz * m33();
+ m_matrix[3][3] += tx * m14() + ty * m24() + tz * m34();
+ }
+ }
+
+ return this;
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698