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 #ifndef UI_GFX_COLOR_UTILS_H_ | 5 #ifndef UI_GFX_COLOR_UTILS_H_ |
6 #define UI_GFX_COLOR_UTILS_H_ | 6 #define UI_GFX_COLOR_UTILS_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "third_party/skia/include/core/SkColor.h" | 9 #include "third_party/skia/include/core/SkColor.h" |
10 #include "ui/base/ui_export.h" | 10 #include "ui/base/ui_export.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 // 0.5 = leave unchanged. | 44 // 0.5 = leave unchanged. |
45 // 1 = full lightness (make all pixels white). | 45 // 1 = full lightness (make all pixels white). |
46 UI_EXPORT SkColor HSLShift(SkColor color, const HSL& shift); | 46 UI_EXPORT SkColor HSLShift(SkColor color, const HSL& shift); |
47 | 47 |
48 // Determine if a given alpha value is nearly completely transparent. | 48 // Determine if a given alpha value is nearly completely transparent. |
49 bool IsColorCloseToTransparent(SkAlpha alpha); | 49 bool IsColorCloseToTransparent(SkAlpha alpha); |
50 | 50 |
51 // Determine if a color is near grey. | 51 // Determine if a color is near grey. |
52 bool IsColorCloseToGrey(int r, int g, int b); | 52 bool IsColorCloseToGrey(int r, int g, int b); |
53 | 53 |
54 // Gets a color representing a bitmap. The definition of "representing" is the | |
55 // average color in the bitmap. The color returned is modified to have the | |
56 // specified alpha. | |
57 SkColor GetAverageColorOfFavicon(SkBitmap* bitmap, SkAlpha alpha); | |
58 | |
59 // Builds a histogram based on the Y' of the Y'UV representation of | 54 // Builds a histogram based on the Y' of the Y'UV representation of |
60 // this image. | 55 // this image. |
61 UI_EXPORT void BuildLumaHistogram(const SkBitmap& bitmap, int histogram[256]); | 56 UI_EXPORT void BuildLumaHistogram(const SkBitmap& bitmap, int histogram[256]); |
62 | 57 |
63 // Returns a blend of the supplied colors, ranging from |background| (for | 58 // Returns a blend of the supplied colors, ranging from |background| (for |
64 // |alpha| == 0) to |foreground| (for |alpha| == 255). The alpha channels of | 59 // |alpha| == 0) to |foreground| (for |alpha| == 255). The alpha channels of |
65 // the supplied colors are also taken into account, so the returned color may | 60 // the supplied colors are also taken into account, so the returned color may |
66 // be partially transparent. | 61 // be partially transparent. |
67 UI_EXPORT SkColor AlphaBlend(SkColor foreground, SkColor background, | 62 UI_EXPORT SkColor AlphaBlend(SkColor foreground, SkColor background, |
68 SkAlpha alpha); | 63 SkAlpha alpha); |
69 | 64 |
70 // Given a foreground and background color, try to return a foreground color | 65 // Given a foreground and background color, try to return a foreground color |
71 // that is "readable" over the background color by luma-inverting the foreground | 66 // that is "readable" over the background color by luma-inverting the foreground |
72 // color and then picking whichever foreground color has higher contrast against | 67 // color and then picking whichever foreground color has higher contrast against |
73 // the background color. | 68 // the background color. |
74 // | 69 // |
75 // NOTE: This won't do anything but waste time if the supplied foreground color | 70 // NOTE: This won't do anything but waste time if the supplied foreground color |
76 // has a luma value close to the midpoint (0.5 in the HSL representation). | 71 // has a luma value close to the midpoint (0.5 in the HSL representation). |
77 UI_EXPORT SkColor GetReadableColor(SkColor foreground, SkColor background); | 72 UI_EXPORT SkColor GetReadableColor(SkColor foreground, SkColor background); |
78 | 73 |
79 // Invert a color. | 74 // Invert a color. |
80 UI_EXPORT SkColor InvertColor(SkColor color); | 75 UI_EXPORT SkColor InvertColor(SkColor color); |
81 | 76 |
82 // Gets a Windows system color as a SkColor | 77 // Gets a Windows system color as a SkColor |
83 UI_EXPORT SkColor GetSysSkColor(int which); | 78 UI_EXPORT SkColor GetSysSkColor(int which); |
84 | 79 |
85 } // namespace color_utils | 80 } // namespace color_utils |
86 | 81 |
87 #endif // UI_GFX_COLOR_UTILS_H_ | 82 #endif // UI_GFX_COLOR_UTILS_H_ |
OLD | NEW |