diff options
author | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-24 18:29:44 +0000 |
---|---|---|
committer | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-24 18:29:44 +0000 |
commit | 518ee58ff2ed4f72e313fce4f3c29d2688b3ade1 (patch) | |
tree | a021a76da13a66e64057d65d3420660687a54a5a /cc/math_util.cc | |
parent | 50b03123bf40bec1277f63a3720d6849d2e90fc8 (diff) | |
download | chromium_src-518ee58ff2ed4f72e313fce4f3c29d2688b3ade1.zip chromium_src-518ee58ff2ed4f72e313fce4f3c29d2688b3ade1.tar.gz chromium_src-518ee58ff2ed4f72e313fce4f3c29d2688b3ade1.tar.bz2 |
cc: Apply the layer's initial CSS scale to the contentsScale to render text at the right resolution.
Currently the transform does not affect the scale of a layer's contents. This
means that when a layer with a scale on it becomes composited, its text is
rendered at 1x and then scaled up during rendering, which makes for very fuzzy
text.
This change applies the scale from the layer's CSS transform to the
contentsScale so that text is rendered at the same pixel resolution
as it will be drawn on screen.
Tests:
cc_unittests:CCLayerTreeHostCommonTest.verifyContentsScale
cc_unittests:CCLayerTreeHostCommonTest.verifyContentsScaleForSurfaces
BUG=149943
R=enne
Review URL: https://codereview.chromium.org/11230033
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@163873 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/math_util.cc')
-rw-r--r-- | cc/math_util.cc | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/cc/math_util.cc b/cc/math_util.cc index 76b2f54..7e3cba6 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 MathUtil::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 MathUtil::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 MathUtil::smallestAngleBetweenVectors(const FloatSize& v1, const FloatSize& v2) { float dotProduct = (v1.width() * v2.width() + v1.height() * v2.height()) / (v1.diagonalLength() * v2.diagonalLength()); |