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

Unified Diff: components/favicon_base/fallback_icon_style.cc

Issue 1761183002: color_utils cleanup: (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rename functions 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 | « chrome/browser/ui/views/download/download_item_view.cc ('k') | mash/wm/frame/default_header_painter.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/favicon_base/fallback_icon_style.cc
diff --git a/components/favicon_base/fallback_icon_style.cc b/components/favicon_base/fallback_icon_style.cc
index 83305f71e12a48fd4b69ceffc93607f43b5961df..66ee5997e51ba43c91db55df0ff4cdef031f440a 100644
--- a/components/favicon_base/fallback_icon_style.cc
+++ b/components/favicon_base/fallback_icon_style.cc
@@ -13,14 +13,14 @@ namespace favicon_base {
namespace {
-// Luminance threshold for background color determine whether to use dark or
-// light text color.
-const int kDarkTextLuminanceThreshold = 190;
+// Luma threshold for background color determine whether to use dark or light
+// text color.
+const uint8_t kDarkTextLumaThreshold = 190;
-// The maximum luminance of the background color to ensure light text is
+// The maximum lightness of the background color to ensure light text is
// readable.
-const double kMaxBackgroundColorLuminance = 0.67;
-const double kMinBackgroundColorLuminance = 0.15;
+const double kMaxBackgroundColorLightness = 0.67;
+const double kMinBackgroundColorLightness = 0.15;
// Default values for FallbackIconStyle.
const SkColor kDefaultBackgroundColor = SkColorSetRGB(0x78, 0x78, 0x78);
@@ -51,9 +51,9 @@ bool FallbackIconStyle::operator==(const FallbackIconStyle& other) const {
void MatchFallbackIconTextColorAgainstBackgroundColor(
FallbackIconStyle* style) {
- int luminance = color_utils::GetLuminanceForColor(style->background_color);
- style->text_color = (luminance >= kDarkTextLuminanceThreshold ?
- kDefaultTextColorDark : kDefaultTextColorLight);
+ const uint8_t luma = color_utils::GetLuma(style->background_color);
+ style->text_color = (luma >= kDarkTextLumaThreshold) ?
+ kDefaultTextColorDark : kDefaultTextColorLight;
}
bool ValidateFallbackIconStyle(const FallbackIconStyle& style) {
@@ -64,20 +64,20 @@ bool ValidateFallbackIconStyle(const FallbackIconStyle& style) {
void SetDominantColorAsBackground(
const scoped_refptr<base::RefCountedMemory>& bitmap_data,
FallbackIconStyle* style) {
- // Try to ensure color's luminance isn't too large so that light text is
+ // Try to ensure color's lightness isn't too large so that light text is
// visible. Set an upper bound for the dominant color.
- const color_utils::HSL lower_bound{-1.0, -1.0, kMinBackgroundColorLuminance};
- const color_utils::HSL upper_bound{-1.0, -1.0, kMaxBackgroundColorLuminance};
+ const color_utils::HSL lower_bound{-1.0, -1.0, kMinBackgroundColorLightness};
+ const color_utils::HSL upper_bound{-1.0, -1.0, kMaxBackgroundColorLightness};
color_utils::GridSampler sampler;
SkColor dominant_color = color_utils::CalculateKMeanColorOfPNG(
bitmap_data, lower_bound, upper_bound, &sampler);
// |CalculateKMeanColorOfPNG| will try to return a color that lies within the
// specified bounds if one exists in the image. If there's no such color, it
// will return the dominant color which may be lighter than our upper bound.
- // Clamp luminance down to a reasonable maximum value so text is readable.
+ // Clamp lightness down to a reasonable maximum value so text is readable.
color_utils::HSL color_hsl;
color_utils::SkColorToHSL(dominant_color, &color_hsl);
- color_hsl.l = std::min(color_hsl.l, kMaxBackgroundColorLuminance);
+ color_hsl.l = std::min(color_hsl.l, kMaxBackgroundColorLightness);
style->background_color =
color_utils::HSLToSkColor(color_hsl, SK_AlphaOPAQUE);
}
« no previous file with comments | « chrome/browser/ui/views/download/download_item_view.cc ('k') | mash/wm/frame/default_header_painter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698