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

Unified Diff: ui/gfx/transform.cc

Issue 7066010: Fixes rounding bug in transform. This is needed to avoid rounding (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 7 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 | « no previous file | views/view_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/transform.cc
diff --git a/ui/gfx/transform.cc b/ui/gfx/transform.cc
index d335166779f4b2bac3e9fe3104a97669640403af..55edb4c3f47a782ec1adef0bfcf4cb4187780ef4 100644
--- a/ui/gfx/transform.cc
+++ b/ui/gfx/transform.cc
@@ -4,6 +4,8 @@
#include "ui/gfx/transform.h"
+#include <cmath>
+
#include "ui/gfx/point.h"
#include "ui/gfx/rect.h"
#include "ui/gfx/skia_util.h"
@@ -71,7 +73,8 @@ bool Transform::HasChange() const {
bool Transform::TransformPoint(gfx::Point* point) {
SkPoint skp;
matrix_.mapXY(SkIntToScalar(point->x()), SkIntToScalar(point->y()), &skp);
- point->SetPoint(static_cast<int>(skp.fX), static_cast<int>(skp.fY));
+ point->SetPoint(static_cast<int>(std::floor(skp.fX)),
+ static_cast<int>(std::floor(skp.fY)));
wjmaclean 2011/05/24 12:11:40 Just curious ... for positive values, wouldn't thi
sky 2011/05/24 15:51:49 I'm sure we'll have rounding problems until we use
return true;
}
@@ -81,7 +84,8 @@ bool Transform::TransformPointReverse(gfx::Point* point) {
if (matrix_.invert(&inverse)) {
SkPoint skp;
inverse.mapXY(SkIntToScalar(point->x()), SkIntToScalar(point->y()), &skp);
- point->SetPoint(static_cast<int>(skp.fX), static_cast<int>(skp.fY));
+ point->SetPoint(static_cast<int>(std::floor(skp.fX)),
+ static_cast<int>(std::floor(skp.fY)));
return true;
}
return false;
« no previous file with comments | « no previous file | views/view_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698