diff options
author | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-18 22:38:04 +0000 |
---|---|---|
committer | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-18 22:38:04 +0000 |
commit | ac49aaf6ba54d308c2dd73bcc7a830decf96aa44 (patch) | |
tree | 337ddca9b907b9144eeeda82a8495137565e943c /ui/gfx | |
parent | 2ecea3274277b17d6e50607f2474cd9adb296a2a (diff) | |
download | chromium_src-ac49aaf6ba54d308c2dd73bcc7a830decf96aa44.zip chromium_src-ac49aaf6ba54d308c2dd73bcc7a830decf96aa44.tar.gz chromium_src-ac49aaf6ba54d308c2dd73bcc7a830decf96aa44.tar.bz2 |
gfx: Transform is using its own custom function to round a float to an integer.
Use ToRoundedInt() from safe_integer_conversions.h which also has unittests,
so it's safer.
R=sky@chromium.org
Review URL: https://codereview.chromium.org/11183034
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@162816 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/gfx')
-rw-r--r-- | ui/gfx/transform.cc | 22 |
1 files changed, 4 insertions, 18 deletions
diff --git a/ui/gfx/transform.cc b/ui/gfx/transform.cc index d85d86f..b62dced 100644 --- a/ui/gfx/transform.cc +++ b/ui/gfx/transform.cc @@ -6,19 +6,9 @@ #include "ui/gfx/point3.h" #include "ui/gfx/rect.h" +#include "ui/gfx/safe_integer_conversions.h" #include "ui/gfx/skia_util.h" -namespace { - -static int SymmetricRound(float x) { - return static_cast<int>( - x > 0 - ? std::floor(x + 0.5f) - : std::ceil(x - 0.5f)); -} - -} // namespace - namespace gfx { Transform::Transform() { @@ -192,16 +182,12 @@ void Transform::TransformPointInternal(const SkMatrix44& xform, void Transform::TransformPointInternal(const SkMatrix44& xform, Point& point) const { - SkScalar p[4] = { - SkIntToScalar(point.x()), - SkIntToScalar(point.y()), - 0, - 1 }; + SkScalar p[4] = { SkIntToScalar(point.x()), SkIntToScalar(point.y()), + 0, 1 }; xform.map(p); - point.SetPoint(SymmetricRound(p[0]), - SymmetricRound(p[1])); + point.SetPoint(ToRoundedInt(p[0]), ToRoundedInt(p[1])); } } // namespace gfx |