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

Side by Side Diff: ui/gfx/color_utils.cc

Issue 1408273002: Make some updates to BM bar for MD. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: eschew redundancy 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 unified diff | Download patch
« no previous file with comments | « ui/gfx/color_utils.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/gfx/color_utils.h" 5 #include "ui/gfx/color_utils.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 #if defined(OS_WIN) 8 #if defined(OS_WIN)
9 #include <windows.h> 9 #include <windows.h>
10 #endif 10 #endif
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 return (foreground_luminance > background_luminance) ? 71 return (foreground_luminance > background_luminance) ?
72 (foreground_luminance / background_luminance) : 72 (foreground_luminance / background_luminance) :
73 (background_luminance / foreground_luminance); 73 (background_luminance / foreground_luminance);
74 } 74 }
75 75
76 } // namespace 76 } // namespace
77 77
78 78
79 // ---------------------------------------------------------------------------- 79 // ----------------------------------------------------------------------------
80 80
81 double GetContrastRatio(SkColor color_a, SkColor color_b) {
82 return ContrastRatio(RelativeLuminance(color_a), RelativeLuminance(color_b));
83 }
84
81 unsigned char GetLuminanceForColor(SkColor color) { 85 unsigned char GetLuminanceForColor(SkColor color) {
82 return base::saturated_cast<unsigned char>( 86 return base::saturated_cast<unsigned char>(
83 (0.3 * SkColorGetR(color)) + 87 (0.3 * SkColorGetR(color)) +
84 (0.59 * SkColorGetG(color)) + 88 (0.59 * SkColorGetG(color)) +
85 (0.11 * SkColorGetB(color))); 89 (0.11 * SkColorGetB(color)));
86 } 90 }
87 91
88 double RelativeLuminance(SkColor color) { 92 double RelativeLuminance(SkColor color) {
89 return (0.2126 * ConvertSRGB(SkColorGetR(color))) + 93 return (0.2126 * ConvertSRGB(SkColorGetR(color))) +
90 (0.7152 * ConvertSRGB(SkColorGetG(color))) + 94 (0.7152 * ConvertSRGB(SkColorGetG(color))) +
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 #endif // !defined(OS_WIN) 332 #endif // !defined(OS_WIN)
329 333
330 SkColor DeriveDefaultIconColor(SkColor text_color) { 334 SkColor DeriveDefaultIconColor(SkColor text_color) {
331 // For black text, this comes out to gfx::kChromeIconGrey. 335 // For black text, this comes out to gfx::kChromeIconGrey.
332 SkColor color = BlendTowardOppositeLuminance( 336 SkColor color = BlendTowardOppositeLuminance(
333 text_color, SkColorGetR(gfx::kChromeIconGrey)); 337 text_color, SkColorGetR(gfx::kChromeIconGrey));
334 return color; 338 return color;
335 } 339 }
336 340
337 } // namespace color_utils 341 } // namespace color_utils
OLDNEW
« no previous file with comments | « ui/gfx/color_utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698