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

Unified Diff: third_party/WebKit/Source/platform/transforms/TransformationMatrix.cpp

Issue 1530723004: Use clampTo instead of chaining std::max(std::min(...)) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More rebase Created 5 years 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 | « third_party/WebKit/Source/platform/speech/PlatformSpeechSynthesisUtterance.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/transforms/TransformationMatrix.cpp
diff --git a/third_party/WebKit/Source/platform/transforms/TransformationMatrix.cpp b/third_party/WebKit/Source/platform/transforms/TransformationMatrix.cpp
index ced3d37ab6ea9ee35cb8bf1a02a35632a15b79a2..f1c208806ca92c72e272bab65162cc86054abde4 100644
--- a/third_party/WebKit/Source/platform/transforms/TransformationMatrix.cpp
+++ b/third_party/WebKit/Source/platform/transforms/TransformationMatrix.cpp
@@ -37,6 +37,9 @@
#include "wtf/Assertions.h"
#include "wtf/MathExtras.h"
+#include <cmath>
+#include <cstdlib>
+
#if CPU(X86_64)
#include <emmintrin.h>
#endif
@@ -596,8 +599,7 @@ static void slerp(double qa[4], const double qb[4], double t)
product = ax * bx + ay * by + az * bz + aw * bw;
- // Clamp product to -1.0 <= product <= 1.0.
- product = std::min(std::max(product, -1.0), 1.0);
+ product = clampTo(product, -1.0, 1.0);
const double epsilon = 1e-5;
if (std::abs(product - 1.0) < epsilon) {
@@ -710,7 +712,7 @@ FloatQuad TransformationMatrix::projectQuad(const FloatQuad& q, bool* clamped) c
static float clampEdgeValue(float f)
{
ASSERT(!std::isnan(f));
- return std::min<float>(std::max<float>(f, (-LayoutUnit::max() / 2).toFloat()), (LayoutUnit::max() / 2).toFloat());
+ return clampTo(f, (-LayoutUnit::max() / 2).toFloat(), (LayoutUnit::max() / 2).toFloat());
}
LayoutRect TransformationMatrix::clampedBoundsOfProjectedQuad(const FloatQuad& q) const
« no previous file with comments | « third_party/WebKit/Source/platform/speech/PlatformSpeechSynthesisUtterance.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698