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

Unified Diff: third_party/WebKit/Source/platform/graphics/Color.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
Index: third_party/WebKit/Source/platform/graphics/Color.cpp
diff --git a/third_party/WebKit/Source/platform/graphics/Color.cpp b/third_party/WebKit/Source/platform/graphics/Color.cpp
index 5f2f51ab3015ec90aceb98df1b6a28cfbb6b9533..dc9364edbde2bea1f7c0a43392244b658f961551 100644
--- a/third_party/WebKit/Source/platform/graphics/Color.cpp
+++ b/third_party/WebKit/Source/platform/graphics/Color.cpp
@@ -50,17 +50,17 @@ static const RGBA32 darkenedWhite = 0xFFABABAB;
RGBA32 makeRGB(int r, int g, int b)
{
- return 0xFF000000 | std::max(0, std::min(r, 255)) << 16 | std::max(0, std::min(g, 255)) << 8 | std::max(0, std::min(b, 255));
+ return 0xFF000000 | clampTo(r, 0, 255) << 16 | clampTo(g, 0, 255) << 8 | clampTo(b, 0, 255);
}
RGBA32 makeRGBA(int r, int g, int b, int a)
{
- return std::max(0, std::min(a, 255)) << 24 | std::max(0, std::min(r, 255)) << 16 | std::max(0, std::min(g, 255)) << 8 | std::max(0, std::min(b, 255));
+ return clampTo(a, 0, 255) << 24 | clampTo(r, 0, 255) << 16 | clampTo(g, 0, 255) << 8 | clampTo(b, 0, 255);
}
static int colorFloatToRGBAByte(float f)
{
- return std::max(0, std::min(static_cast<int>(lroundf(255.0f * f)), 255));
+ return clampTo(static_cast<int>(lroundf(255.0f * f)), 0, 255);
}
RGBA32 makeRGBA32FromFloats(float r, float g, float b, float a)
« no previous file with comments | « third_party/WebKit/Source/platform/audio/VectorMath.cpp ('k') | third_party/WebKit/Source/platform/graphics/GraphicsLayer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698