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

Unified Diff: cc/math_util.cc

Issue 10915313: cc: Apply the layer's initial CSS scale to the contentsScale to render text at the right resolution. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 2 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 | « cc/math_util.h ('k') | cc/occlusion_tracker_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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());
« no previous file with comments | « cc/math_util.h ('k') | cc/occlusion_tracker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698