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

Unified Diff: ui/gfx/color_utils.cc

Issue 1448433004: [MD] update EV bubble icon and location bar https icons (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix build.gn Created 5 years, 1 month 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 | « ui/gfx/color_utils.h ('k') | ui/gfx/vector_icons/location_bar_https_invalid_invert.icon » ('j') | 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 97c3a84a08ea01d7e4bc878c15861b03bdd4c400..494f04b423582eb5c1bdededa09d49e60e6b82ad 100644
--- a/ui/gfx/color_utils.cc
+++ b/ui/gfx/color_utils.cc
@@ -291,12 +291,13 @@ SkColor AlphaBlend(SkColor foreground, SkColor background, SkAlpha alpha) {
static_cast<int>(b));
}
+bool IsDark(SkColor color) {
+ return GetLuminanceForColor(color) < 128;
+}
+
SkColor BlendTowardOppositeLuminance(SkColor color, SkAlpha alpha) {
- unsigned char background_luminance =
- color_utils::GetLuminanceForColor(color);
- const SkColor blend_color =
- (background_luminance < 128) ? SK_ColorWHITE : SK_ColorBLACK;
- return color_utils::AlphaBlend(blend_color, color, alpha);
+ return AlphaBlend(IsDark(color) ? SK_ColorWHITE : SK_ColorBLACK, color,
+ alpha);
}
SkColor GetReadableColor(SkColor foreground, SkColor background) {
@@ -334,8 +335,7 @@ bool IsInvertedColorScheme() {
SkColor DeriveDefaultIconColor(SkColor text_color) {
// This function works similarly to BlendTowardOppositeLuminance, but uses a
// different blend value for lightening and darkening.
- unsigned char luminance = color_utils::GetLuminanceForColor(text_color);
- if (luminance < 128) {
+ if (IsDark(text_color)) {
// For black text, this comes out to kChromeIconGrey.
return color_utils::AlphaBlend(SK_ColorWHITE, text_color,
SkColorGetR(gfx::kChromeIconGrey));
« no previous file with comments | « ui/gfx/color_utils.h ('k') | ui/gfx/vector_icons/location_bar_https_invalid_invert.icon » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698