| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 | 7 |
| 8 #include "third_party/skia/include/core/SkColor.h" | 8 #include "third_party/skia/include/core/SkColor.h" |
| 9 | 9 |
| 10 class SkBitmap; | 10 class SkBitmap; |
| 11 | 11 |
| 12 namespace color_utils { | 12 namespace color_utils { |
| 13 | 13 |
| 14 // Represents set of CIE XYZ tristimulus values. | |
| 15 struct CIE_XYZ { | |
| 16 double X; | |
| 17 double Y; // luminance | |
| 18 double Z; | |
| 19 }; | |
| 20 | |
| 21 // Represents a L*a*b* color value | |
| 22 struct LabColor { | |
| 23 int L; | |
| 24 int a; | |
| 25 int b; | |
| 26 }; | |
| 27 | |
| 28 // Note: these transformations assume sRGB as the source color space | |
| 29 | |
| 30 // Convert between different color spaces | |
| 31 void SkColorToCIEXYZ(SkColor c, CIE_XYZ* xyz); | |
| 32 SkColor CIEXYZToSkColor(SkAlpha alpha, const CIE_XYZ& xyz); | |
| 33 | |
| 34 void SkColorToLabColor(SkColor c, LabColor* lab); | |
| 35 SkColor LabColorToSkColor(const LabColor& lab, SkAlpha alpha); | |
| 36 | |
| 37 void CIEXYZToLabColor(const CIE_XYZ& xyz, LabColor* lab); | |
| 38 void LabColorToCIEXYZ(const LabColor& lab, CIE_XYZ* xyz); | |
| 39 | |
| 40 // Determine if a given alpha value is nearly completely transparent. | 14 // Determine if a given alpha value is nearly completely transparent. |
| 41 bool IsColorCloseToTransparent(SkAlpha alpha); | 15 bool IsColorCloseToTransparent(SkAlpha alpha); |
| 42 | 16 |
| 43 // Determine if a color is near grey. | 17 // Determine if a color is near grey. |
| 44 bool IsColorCloseToGrey(int r, int g, int b); | 18 bool IsColorCloseToGrey(int r, int g, int b); |
| 45 | 19 |
| 46 // Gets a color representing a bitmap. The definition of "representing" is the | 20 // Gets a color representing a bitmap. The definition of "representing" is the |
| 47 // average color in the bitmap. The color returned is modified to have the | 21 // average color in the bitmap. The color returned is modified to have the |
| 48 // specified alpha. | 22 // specified alpha. |
| 49 SkColor GetAverageColorOfFavicon(SkBitmap* bitmap, SkAlpha alpha); | 23 SkColor GetAverageColorOfFavicon(SkBitmap* bitmap, SkAlpha alpha); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 61 SkColor PickMoreReadableColor(SkColor foreground1, | 35 SkColor PickMoreReadableColor(SkColor foreground1, |
| 62 SkColor foreground2, | 36 SkColor foreground2, |
| 63 SkColor background); | 37 SkColor background); |
| 64 | 38 |
| 65 // Gets a Windows system color as a SkColor | 39 // Gets a Windows system color as a SkColor |
| 66 SkColor GetSysSkColor(int which); | 40 SkColor GetSysSkColor(int which); |
| 67 | 41 |
| 68 } // namespace color_utils | 42 } // namespace color_utils |
| 69 | 43 |
| 70 #endif // APP_GFX_COLOR_UTILS_H_ | 44 #endif // APP_GFX_COLOR_UTILS_H_ |
| OLD | NEW |