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

Unified Diff: ui/gfx/color_utils.cc

Issue 1683913003: Round color values in AlphaBlend() as we already do in HSLShift(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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: ui/gfx/color_utils.cc
diff --git a/ui/gfx/color_utils.cc b/ui/gfx/color_utils.cc
index f30c266e1beee8ba5a47c7979832576c96b4e85d..978283d29ab7a326781548940c448c104a57201b 100644
--- a/ui/gfx/color_utils.cc
+++ b/ui/gfx/color_utils.cc
@@ -150,10 +150,9 @@ SkColor HSLToSkColor(const HSL& hsl, SkAlpha alpha) {
(lightness * (1.0 + saturation)) :
(lightness + saturation - (lightness * saturation));
double temp1 = 2.0 * lightness - temp2;
- return SkColorSetARGB(alpha,
- calcHue(temp1, temp2, hue + 1.0 / 3.0),
- calcHue(temp1, temp2, hue),
- calcHue(temp1, temp2, hue - 1.0 / 3.0));
+ return SkColorSetARGB(alpha, calcHue(temp1, temp2, hue + 1.0 / 3.0),
+ calcHue(temp1, temp2, hue),
+ calcHue(temp1, temp2, hue - 1.0 / 3.0));
}
bool IsWithinHSLRange(const HSL& hsl,
@@ -287,10 +286,10 @@ SkColor AlphaBlend(SkColor foreground, SkColor background, SkAlpha alpha) {
double b = (SkColorGetB(foreground) * f_weight +
SkColorGetB(background) * b_weight) / 255.0;
- return SkColorSetARGB(static_cast<int>(normalizer),
- static_cast<int>(r),
- static_cast<int>(g),
- static_cast<int>(b));
+ return SkColorSetARGB(static_cast<int>(std::round(normalizer)),
+ static_cast<int>(std::round(r)),
+ static_cast<int>(std::round(g)),
+ static_cast<int>(std::round(b)));
}
bool IsDark(SkColor color) {
@@ -311,11 +310,8 @@ SkColor GetReadableColor(SkColor foreground, SkColor background) {
}
SkColor InvertColor(SkColor color) {
- return SkColorSetARGB(
- SkColorGetA(color),
- 255 - SkColorGetR(color),
- 255 - SkColorGetG(color),
- 255 - SkColorGetB(color));
+ return SkColorSetARGB(SkColorGetA(color), 255 - SkColorGetR(color),
+ 255 - SkColorGetG(color), 255 - SkColorGetB(color));
}
SkColor GetSysSkColor(int which) {
« 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