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

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

Issue 450533006: Implement scale*() methods in DOMMatrix. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: use TransformationMatrix 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
« no previous file with comments | « Source/core/dom/DOMMatrix.h ('k') | Source/core/dom/DOMMatrix.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/DOMMatrix.cpp
diff --git a/Source/core/dom/DOMMatrix.cpp b/Source/core/dom/DOMMatrix.cpp
index 38e20ac40d0582b01f05ec5f3edcdcdaca1adf4d..75cefcb63fe9bf945653424bb609bba356e300b0 100644
--- a/Source/core/dom/DOMMatrix.cpp
+++ b/Source/core/dom/DOMMatrix.cpp
@@ -45,4 +45,39 @@ DOMMatrix* DOMMatrix::translateSelf(double tx, double ty, double tz)
return this;
}
+DOMMatrix* DOMMatrix::scaleSelf(double scale, double ox, double oy)
+{
+ return scaleNonUniformSelf(scale, scale, 1, ox, oy);
+}
+
+DOMMatrix* DOMMatrix::scale3dSelf(double scale, double ox, double oy, double oz)
+{
+ return scaleNonUniformSelf(scale, scale, scale, ox, oy, oz);
+}
+
+DOMMatrix* DOMMatrix::scaleNonUniformSelf(double sx, double sy, double sz,
+ double ox, double oy, double oz)
+{
+ if (sz != 1 || oz)
+ m_is2D = false;
+
+ if (sx == 1 && sy == 1 && sz == 1)
+ return this;
+
+ bool hasTranslation = (ox || oy || oz);
+
+ if (hasTranslation)
+ translateSelf(ox, oy, oz);
+
+ if (m_is2D)
+ m_matrix.scaleNonUniform(sx, sy);
+ else
+ m_matrix.scale3d(sx, sy, sz);
+
+ if (hasTranslation)
+ translateSelf(-ox, -oy, -oz);
+
+ return this;
+}
+
} // namespace blink
« no previous file with comments | « Source/core/dom/DOMMatrix.h ('k') | Source/core/dom/DOMMatrix.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698