| OLD | NEW |
| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 return (foreground_luminance > background_luminance) ? | 70 return (foreground_luminance > background_luminance) ? |
| 71 (foreground_luminance / background_luminance) : | 71 (foreground_luminance / background_luminance) : |
| 72 (background_luminance / foreground_luminance); | 72 (background_luminance / foreground_luminance); |
| 73 } | 73 } |
| 74 | 74 |
| 75 } // namespace | 75 } // namespace |
| 76 | 76 |
| 77 | 77 |
| 78 // ---------------------------------------------------------------------------- | 78 // ---------------------------------------------------------------------------- |
| 79 | 79 |
| 80 double GetContrastRatio(SkColor color_a, SkColor color_b) { |
| 81 return ContrastRatio(RelativeLuminance(color_a), RelativeLuminance(color_b)); |
| 82 } |
| 83 |
| 80 unsigned char GetLuminanceForColor(SkColor color) { | 84 unsigned char GetLuminanceForColor(SkColor color) { |
| 81 return base::saturated_cast<unsigned char>( | 85 return base::saturated_cast<unsigned char>( |
| 82 (0.3 * SkColorGetR(color)) + | 86 (0.3 * SkColorGetR(color)) + |
| 83 (0.59 * SkColorGetG(color)) + | 87 (0.59 * SkColorGetG(color)) + |
| 84 (0.11 * SkColorGetB(color))); | 88 (0.11 * SkColorGetB(color))); |
| 85 } | 89 } |
| 86 | 90 |
| 87 double RelativeLuminance(SkColor color) { | 91 double RelativeLuminance(SkColor color) { |
| 88 return (0.2126 * ConvertSRGB(SkColorGetR(color))) + | 92 return (0.2126 * ConvertSRGB(SkColorGetR(color))) + |
| 89 (0.7152 * ConvertSRGB(SkColorGetG(color))) + | 93 (0.7152 * ConvertSRGB(SkColorGetG(color))) + |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 } | 324 } |
| 321 | 325 |
| 322 // OS_WIN implementation lives in sys_color_change_listener.cc | 326 // OS_WIN implementation lives in sys_color_change_listener.cc |
| 323 #if !defined(OS_WIN) | 327 #if !defined(OS_WIN) |
| 324 bool IsInvertedColorScheme() { | 328 bool IsInvertedColorScheme() { |
| 325 return false; | 329 return false; |
| 326 } | 330 } |
| 327 #endif // !defined(OS_WIN) | 331 #endif // !defined(OS_WIN) |
| 328 | 332 |
| 329 } // namespace color_utils | 333 } // namespace color_utils |
| OLD | NEW |