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

Side by Side Diff: gfx/color_utils.h

Issue 6246027: Move src/gfx/ to src/ui/gfx... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « gfx/codec/png_codec_unittest.cc ('k') | gfx/color_utils.cc » ('j') | 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 APP_GFX_COLOR_UTILS_H_ 5 #ifndef APP_GFX_COLOR_UTILS_H_
6 #define APP_GFX_COLOR_UTILS_H_ 6 #define APP_GFX_COLOR_UTILS_H_
7 #pragma once 7 #pragma once
8 8
9 #include "third_party/skia/include/core/SkColor.h" 9 #include "ui/gfx/color_utils.h"
10 10 // TODO(sail): remove this file once all includes have been updated.
11 class SkBitmap;
12
13 namespace color_utils {
14
15 // Represents an HSL color.
16 struct HSL {
17 double h;
18 double s;
19 double l;
20 };
21
22 // Calculated according to http://www.w3.org/TR/WCAG20/#relativeluminancedef
23 double RelativeLuminance(SkColor color);
24
25 // Note: these transformations assume sRGB as the source color space
26 void SkColorToHSL(SkColor c, HSL* hsl);
27 SkColor HSLToSkColor(const HSL& hsl, SkAlpha alpha);
28
29 // HSL-Shift an SkColor. The shift values are in the range of 0-1, with the
30 // option to specify -1 for 'no change'. The shift values are defined as:
31 // hsl_shift[0] (hue): The absolute hue value - 0 and 1 map
32 // to 0 and 360 on the hue color wheel (red).
33 // hsl_shift[1] (saturation): A saturation shift, with the
34 // following key values:
35 // 0 = remove all color.
36 // 0.5 = leave unchanged.
37 // 1 = fully saturate the image.
38 // hsl_shift[2] (lightness): A lightness shift, with the
39 // following key values:
40 // 0 = remove all lightness (make all pixels black).
41 // 0.5 = leave unchanged.
42 // 1 = full lightness (make all pixels white).
43 SkColor HSLShift(SkColor color, const HSL& shift);
44
45 // Determine if a given alpha value is nearly completely transparent.
46 bool IsColorCloseToTransparent(SkAlpha alpha);
47
48 // Determine if a color is near grey.
49 bool IsColorCloseToGrey(int r, int g, int b);
50
51 // Gets a color representing a bitmap. The definition of "representing" is the
52 // average color in the bitmap. The color returned is modified to have the
53 // specified alpha.
54 SkColor GetAverageColorOfFavicon(SkBitmap* bitmap, SkAlpha alpha);
55
56 // Builds a histogram based on the Y' of the Y'UV representation of
57 // this image.
58 void BuildLumaHistogram(SkBitmap* bitmap, int histogram[256]);
59
60 // Returns a blend of the supplied colors, ranging from |background| (for
61 // |alpha| == 0) to |foreground| (for |alpha| == 255). The alpha channels of
62 // the supplied colors are also taken into account, so the returned color may
63 // be partially transparent.
64 SkColor AlphaBlend(SkColor foreground, SkColor background, SkAlpha alpha);
65
66 // Given a foreground and background color, try to return a foreground color
67 // that is "readable" over the background color by luma-inverting the foreground
68 // color and then picking whichever foreground color has higher contrast against
69 // the background color.
70 //
71 // NOTE: This won't do anything but waste time if the supplied foreground color
72 // has a luma value close to the midpoint (0.5 in the HSL representation).
73 SkColor GetReadableColor(SkColor foreground, SkColor background);
74
75 // Gets a Windows system color as a SkColor
76 SkColor GetSysSkColor(int which);
77
78 } // namespace color_utils
79 11
80 #endif // APP_GFX_COLOR_UTILS_H_ 12 #endif // APP_GFX_COLOR_UTILS_H_
OLDNEW
« no previous file with comments | « gfx/codec/png_codec_unittest.cc ('k') | gfx/color_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698