diff options
author | enne@chromium.org <enne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-12 00:51:26 +0000 |
---|---|---|
committer | enne@chromium.org <enne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-12 00:51:26 +0000 |
commit | 803f6b54878c02a34499262aa9a6f9cd8813d1b1 (patch) | |
tree | 382613dcc17866aebd627d8e67b06625f9b88305 /cc/base/math_util.cc | |
parent | 5939b835c80fd4bfaf8b077375ba29cc8eb0cd4e (diff) | |
download | chromium_src-803f6b54878c02a34499262aa9a6f9cd8813d1b1.zip chromium_src-803f6b54878c02a34499262aa9a6f9cd8813d1b1.tar.gz chromium_src-803f6b54878c02a34499262aa9a6f9cd8813d1b1.tar.bz2 |
cc: Use SkMScalar instead of doubles for transforms in cc
BUG=269819
Review URL: https://chromiumcodereview.appspot.com/23043011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@222683 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/base/math_util.cc')
-rw-r--r-- | cc/base/math_util.cc | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/cc/base/math_util.cc b/cc/base/math_util.cc index 919a172f..40b8d11 100644 --- a/cc/base/math_util.cc +++ b/cc/base/math_util.cc @@ -108,15 +108,15 @@ gfx::Rect MathUtil::MapClippedRect(const gfx::Transform& transform, gfx::RectF MathUtil::MapClippedRect(const gfx::Transform& transform, const gfx::RectF& src_rect) { - if (transform.IsIdentityOrTranslation()) + if (transform.IsIdentityOrTranslation()) { return src_rect + - gfx::Vector2dF( - static_cast<float>(transform.matrix().getDouble(0, 3)), - static_cast<float>(transform.matrix().getDouble(1, 3))); + gfx::Vector2dF(SkMScalarToFloat(transform.matrix().get(0, 3)), + SkMScalarToFloat(transform.matrix().get(1, 3))); + } // Apply the transform, but retain the result in homogeneous coordinates. - double quad[4 * 2]; // input: 4 x 2D points + SkMScalar quad[4 * 2]; // input: 4 x 2D points quad[0] = src_rect.x(); quad[1] = src_rect.y(); quad[2] = src_rect.right(); @@ -126,7 +126,7 @@ gfx::RectF MathUtil::MapClippedRect(const gfx::Transform& transform, quad[6] = src_rect.x(); quad[7] = src_rect.bottom(); - double result[4 * 4]; // output: 4 x 4D homogeneous points + SkMScalar result[4 * 4]; // output: 4 x 4D homogeneous points transform.matrix().map2(quad, 4, result); HomogeneousCoordinate hc0(result[0], result[1], result[2], result[3]); @@ -140,9 +140,8 @@ gfx::RectF MathUtil::ProjectClippedRect(const gfx::Transform& transform, const gfx::RectF& src_rect) { if (transform.IsIdentityOrTranslation()) { return src_rect + - gfx::Vector2dF( - static_cast<float>(transform.matrix().getDouble(0, 3)), - static_cast<float>(transform.matrix().getDouble(1, 3))); + gfx::Vector2dF(SkMScalarToFloat(transform.matrix().get(0, 3)), + SkMScalarToFloat(transform.matrix().get(1, 3))); } // Perform the projection, but retain the result in homogeneous coordinates. @@ -330,8 +329,8 @@ gfx::QuadF MathUtil::MapQuad(const gfx::Transform& transform, if (transform.IsIdentityOrTranslation()) { gfx::QuadF mapped_quad(q); mapped_quad += - gfx::Vector2dF(static_cast<float>(transform.matrix().getDouble(0, 3)), - static_cast<float>(transform.matrix().getDouble(1, 3))); + gfx::Vector2dF(SkMScalarToFloat(transform.matrix().get(0, 3)), + SkMScalarToFloat(transform.matrix().get(1, 3))); *clipped = false; return mapped_quad; } @@ -467,7 +466,8 @@ gfx::RectF MathUtil::ScaleRectProportional(const gfx::RectF& input_outer_rect, } static inline float ScaleOnAxis(double a, double b, double c) { - return std::sqrt(a * a + b * b + c * c); + // Do the sqrt as a double to not lose precision. + return static_cast<float>(std::sqrt(a * a + b * b + c * c)); } gfx::Vector2dF MathUtil::ComputeTransform2dScaleComponents( |