| 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 "third_party/skia/include/core/SkColor.h" | 8 #include "third_party/skia/include/core/SkColor.h" |
| 9 #include "ui/gfx/gfx_export.h" | 9 #include "ui/gfx/gfx_export.h" |
| 10 | 10 |
| 11 class SkBitmap; | 11 class SkBitmap; |
| 12 | 12 |
| 13 namespace color_utils { | 13 namespace color_utils { |
| 14 | 14 |
| 15 // Tristimulus value, RGB, XYZ,, HSV, YUV, etc. |
| 16 struct GFX_EXPORT TriStim { |
| 17 TriStim() { |
| 18 values[0] = 0.0f; |
| 19 values[1] = 0.0f; |
| 20 values[2] = 0.0f; |
| 21 } |
| 22 TriStim(float a, float b, float c) { |
| 23 values[0] = a; |
| 24 values[1] = b; |
| 25 values[2] = c; |
| 26 } |
| 27 float values[3]; |
| 28 }; |
| 29 |
| 30 // The fourth row is always 0,0,0,1 |
| 31 struct GFX_EXPORT Matrix4x3 { |
| 32 // Defaults to unity matrix. |
| 33 Matrix4x3(); |
| 34 |
| 35 // Matrix multiplication. |
| 36 Matrix4x3 operator*(const Matrix4x3& other) const; |
| 37 |
| 38 // Color mapping. |
| 39 TriStim operator*(const TriStim& color) const; |
| 40 |
| 41 // Invert matrix. |
| 42 Matrix4x3 Invert() const; |
| 43 |
| 44 // Lookup, makes it look like the fourth row is there. |
| 45 float lookup(int row, int col) const; |
| 46 |
| 47 typedef float Quad[4]; |
| 48 Quad rows[3]; |
| 49 }; |
| 50 |
| 15 // Represents an HSL color. | 51 // Represents an HSL color. |
| 16 struct HSL { | 52 struct HSL { |
| 17 double h; | 53 double h; |
| 18 double s; | 54 double s; |
| 19 double l; | 55 double l; |
| 20 }; | 56 }; |
| 21 | 57 |
| 22 // The minimum contrast between text and background that is still readable. | 58 // The minimum contrast between text and background that is still readable. |
| 23 // This value is taken from w3c accessibility guidelines. | 59 // This value is taken from w3c accessibility guidelines. |
| 24 const double kMinimumReadableContrastRatio = 4.5f; | 60 const double kMinimumReadableContrastRatio = 4.5f; |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 // light-on-dark color scheme. | 165 // light-on-dark color scheme. |
| 130 GFX_EXPORT bool IsInvertedColorScheme(); | 166 GFX_EXPORT bool IsInvertedColorScheme(); |
| 131 | 167 |
| 132 // Derives a color for icons on a UI surface based on the text color on the same | 168 // Derives a color for icons on a UI surface based on the text color on the same |
| 133 // surface. | 169 // surface. |
| 134 GFX_EXPORT SkColor DeriveDefaultIconColor(SkColor text_color); | 170 GFX_EXPORT SkColor DeriveDefaultIconColor(SkColor text_color); |
| 135 | 171 |
| 136 } // namespace color_utils | 172 } // namespace color_utils |
| 137 | 173 |
| 138 #endif // UI_GFX_COLOR_UTILS_H_ | 174 #endif // UI_GFX_COLOR_UTILS_H_ |
| OLD | NEW |