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

Unified Diff: cc/base/math_util.cc

Issue 47403002: Avoid unnecessary sqrt calls in ComputeTransform2dScaleComponents. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/base/math_util.cc
diff --git a/cc/base/math_util.cc b/cc/base/math_util.cc
index eeb1523db46a080aff9850caaf126c1c3f8b0509..76b2bb93cc325f0dd77fa35090ba5230c9dbbd6a 100644
--- a/cc/base/math_util.cc
+++ b/cc/base/math_util.cc
@@ -466,6 +466,13 @@ gfx::RectF MathUtil::ScaleRectProportional(const gfx::RectF& input_outer_rect,
}
static inline float ScaleOnAxis(double a, double b, double c) {
+ if (!b && !c)
+ return a;
+ if (!a && !c)
+ return b;
+ if (!a && !b)
+ return c;
+
// Do the sqrt as a double to not lose precision.
return static_cast<float>(std::sqrt(a * a + b * b + c * c));
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698