Index: cc/math_util.cc |
diff --git a/cc/math_util.cc b/cc/math_util.cc |
index d90eb090abef6fbc004f87cedc0a3188419486cf..8cb7d2b70eeeccf42fbeae11fed6b5cd56e0018b 100644 |
--- a/cc/math_util.cc |
+++ b/cc/math_util.cc |
@@ -9,6 +9,7 @@ |
#include "FloatPoint.h" |
#include "FloatQuad.h" |
#include "IntRect.h" |
+#include <cmath> |
#include <public/WebTransformationMatrix.h> |
using WebKit::WebTransformationMatrix; |
@@ -361,6 +362,20 @@ void CCMathUtil::flattenTransformTo2d(WebTransformationMatrix& transform) |
transform.setM43(0); |
} |
+static inline float scaleOnAxis(double a, double b, double c) |
+{ |
+ return std::sqrt(a * a + b * b + c * c); |
+} |
+ |
+FloatPoint CCMathUtil::computeTransform2dScaleComponents(const WebTransformationMatrix& transform) |
+{ |
+ if (transform.hasPerspective()) |
+ return FloatPoint(1, 1); |
+ float xScale = scaleOnAxis(transform.m11(), transform.m12(), transform.m13()); |
+ float yScale = scaleOnAxis(transform.m21(), transform.m22(), transform.m23()); |
+ return FloatPoint(xScale, yScale); |
+} |
+ |
float CCMathUtil::smallestAngleBetweenVectors(const FloatSize& v1, const FloatSize& v2) |
{ |
float dotProduct = (v1.width() * v2.width() + v1.height() * v2.height()) / (v1.diagonalLength() * v2.diagonalLength()); |