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

Unified Diff: cc/math_util.h

Issue 12407002: Align physical pixels of scrolled layers (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix win break again Created 7 years, 9 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/layer_tree_host_common_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/math_util.h
diff --git a/cc/math_util.h b/cc/math_util.h
index 8c1ca88675dbde5e7aee2e77ab6ad0d1684beee0..24a155d74422c31ea8a3cd8f1a7c54bfc8e85e88 100644
--- a/cc/math_util.h
+++ b/cc/math_util.h
@@ -5,6 +5,8 @@
#ifndef CC_MATH_UTIL_H_
#define CC_MATH_UTIL_H_
+#include <cmath>
+
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "cc/cc_export.h"
@@ -81,6 +83,9 @@ public:
static float Deg2Rad(float deg) { return deg * PI_FLOAT / 180; }
static float Rad2Deg(float rad) { return rad * 180 / PI_FLOAT; }
+ static float Round(float f) { return (f > 0.f) ? std::floor(f + 0.5f) : std::ceil(f - 0.5f); }
+ static double Round(double d) { return (d > 0.0) ? std::floor(d + 0.5) : std::ceil(d - 0.5); }
+
// Background: Existing transform code does not do the right thing in
// mapRect / mapQuad / projectQuad when there is a perspective projection that causes
// one of the transformed vertices to go to w < 0. In those cases, it is necessary to
« no previous file with comments | « cc/layer_tree_host_common_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698