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

Unified Diff: cc/base/math_util.cc

Issue 1321503002: cc: Do not create separate tilings for almost equal scale factors. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nit. Created 5 years, 2 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
Index: cc/base/math_util.cc
diff --git a/cc/base/math_util.cc b/cc/base/math_util.cc
index 6e5ac0bd45db73b47d318a7d4b3aef0f42af0078..f4bc359059f9dfb57cc8aa103514048ca8d906e3 100644
--- a/cc/base/math_util.cc
+++ b/cc/base/math_util.cc
@@ -120,6 +120,18 @@ static inline void AddVertexToClippedQuad3d(const gfx::Point3F& new_vertex,
(*num_vertices_in_clipped_quad)++;
}
+float MathUtil::RoundToFixedPrecision(float value, int precision) {
+ // Return the same value, as higher precision is not possible with float.
+ if (precision < 1 || precision > (std::numeric_limits<float>::digits10 - 1))
ericrk 2015/10/19 16:40:50 drive-by-nit: Should we DCHECK that precision >= 1
vmpstr 2015/10/19 18:58:38 I agree, this should be a DCHECK instead of an ear
+ return value;
+
+ float factor = std::pow(10, precision);
+ float integral;
+ float fractional = std::modf(value, &integral);
+ fractional = std::round(fractional * factor) / factor;
+ return integral + fractional;
+}
+
gfx::Rect MathUtil::MapEnclosingClippedRect(const gfx::Transform& transform,
const gfx::Rect& src_rect) {
if (transform.IsIdentityOrIntegerTranslation()) {

Powered by Google App Engine
This is Rietveld 408576698