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_SPACE_H_ | 5 #ifndef UI_GFX_COLOR_SPACE_H_ |
6 #define UI_GFX_COLOR_SPACE_H_ | 6 #define UI_GFX_COLOR_SPACE_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "build/build_config.h" | 11 #include "build/build_config.h" |
12 #include "ui/gfx/gfx_export.h" | 12 #include "ui/gfx/gfx_export.h" |
13 | 13 |
14 namespace IPC { | 14 namespace IPC { |
15 template <class P> | 15 template <class P> |
16 struct ParamTraits; | 16 struct ParamTraits; |
17 } // namespace IPC | 17 } // namespace IPC |
18 | 18 |
19 namespace gfx { | 19 namespace gfx { |
20 | 20 |
21 class ICCProfile; | 21 class ICCProfile; |
22 | 22 |
23 // Used to represet a color space for the purpose of color conversion. | 23 // Used to represet a color space for the purpose of color conversion. |
24 // This is designed to be safe and compact enough to send over IPC | 24 // This is designed to be safe and compact enough to send over IPC |
25 // between any processes. | 25 // between any processes. |
26 class GFX_EXPORT ColorSpace { | 26 class GFX_EXPORT ColorSpace { |
27 public: | 27 public: |
| 28 enum class PrimaryID : uint16_t { |
| 29 // The first 0-255 values should match the H264 specification. |
| 30 RESERVED0 = 0, |
| 31 BT709 = 1, |
| 32 UNSPECIFIED = 2, |
| 33 RESERVED = 3, |
| 34 BT470M = 4, |
| 35 BT470BG = 5, |
| 36 SMPTE170M = 6, |
| 37 SMPTE240M = 7, |
| 38 FILM = 8, |
| 39 BT2020 = 9, |
| 40 SMPTEST428_1 = 10, |
| 41 SMPTEST431_2 = 11, |
| 42 SMPTEST432_1 = 12, |
| 43 |
| 44 // Chrome-specific values start at 1000. |
| 45 XYZ_D50 = 1000, |
| 46 // TODO(hubbe): We need to store the primaries. |
| 47 CUSTOM = 1001, |
| 48 LAST = CUSTOM |
| 49 }; |
| 50 |
| 51 enum class TransferID : uint16_t { |
| 52 // The first 0-255 values should match the H264 specification. |
| 53 RESERVED0 = 0, |
| 54 BT709 = 1, |
| 55 UNSPECIFIED = 2, |
| 56 RESERVED = 3, |
| 57 GAMMA22 = 4, |
| 58 GAMMA28 = 5, |
| 59 SMPTE170M = 6, |
| 60 SMPTE240M = 7, |
| 61 LINEAR = 8, |
| 62 LOG = 9, |
| 63 LOG_SQRT = 10, |
| 64 IEC61966_2_4 = 11, |
| 65 BT1361_ECG = 12, |
| 66 IEC61966_2_1 = 13, |
| 67 BT2020_10 = 14, |
| 68 BT2020_12 = 15, |
| 69 SMPTEST2084 = 16, |
| 70 SMPTEST428_1 = 17, |
| 71 |
| 72 // Chrome-specific values start at 1000. |
| 73 GAMMA24 = 1000, |
| 74 |
| 75 // TODO(hubbe): Need to store an approximation of the gamma function(s). |
| 76 CUSTOM = 1001, |
| 77 LAST = CUSTOM, |
| 78 }; |
| 79 |
| 80 enum class MatrixID : int16_t { |
| 81 // The first 0-255 values should match the H264 specification. |
| 82 RGB = 0, |
| 83 BT709 = 1, |
| 84 UNSPECIFIED = 2, |
| 85 RESERVED = 3, |
| 86 FCC = 4, |
| 87 BT470BG = 5, |
| 88 SMPTE170M = 6, |
| 89 SMPTE240M = 7, |
| 90 YCOCG = 8, |
| 91 BT2020_NCL = 9, |
| 92 BT2020_CL = 10, |
| 93 YDZDX = 11, |
| 94 |
| 95 // Chrome-specific values start at 1000 |
| 96 LAST = YDZDX, |
| 97 }; |
| 98 |
| 99 // The h264 spec declares this as bool, so only the the first two values |
| 100 // correspond to the h264 spec. Chrome-specific values can start at 2. |
| 101 // We use an enum instead of a bool becuase different bit depths may have |
| 102 // different definitions of what "limited" means. |
| 103 enum class RangeID : int8_t { |
| 104 FULL = 0, |
| 105 LIMITED = 1, |
| 106 |
| 107 LAST = LIMITED |
| 108 }; |
| 109 |
28 ColorSpace(); | 110 ColorSpace(); |
| 111 ColorSpace(PrimaryID primaries, |
| 112 TransferID transfer, |
| 113 MatrixID matrix, |
| 114 RangeID full_range); |
| 115 |
29 static ColorSpace CreateSRGB(); | 116 static ColorSpace CreateSRGB(); |
30 | 117 |
31 // TODO: Remove these, and replace with more generic constructors. | 118 // TODO: Remove these, and replace with more generic constructors. |
32 static ColorSpace CreateJpeg(); | 119 static ColorSpace CreateJpeg(); |
33 static ColorSpace CreateREC601(); | 120 static ColorSpace CreateREC601(); |
34 static ColorSpace CreateREC709(); | 121 static ColorSpace CreateREC709(); |
35 | 122 |
36 bool operator==(const ColorSpace& other) const; | 123 bool operator==(const ColorSpace& other) const; |
37 | 124 |
38 private: | 125 private: |
39 bool valid_ = false; | 126 PrimaryID primaries_; |
| 127 TransferID transfer_; |
| 128 MatrixID matrix_; |
| 129 RangeID range_; |
| 130 |
40 // This is used to look up the ICCProfile from which this ColorSpace was | 131 // This is used to look up the ICCProfile from which this ColorSpace was |
41 // created, if possible. | 132 // created, if possible. |
42 uint64_t icc_profile_id_ = 0; | 133 uint64_t icc_profile_id_ = 0; |
43 | 134 |
44 friend class ICCProfile; | 135 friend class ICCProfile; |
45 friend struct IPC::ParamTraits<gfx::ColorSpace>; | 136 friend struct IPC::ParamTraits<gfx::ColorSpace>; |
46 }; | 137 }; |
47 | 138 |
48 } // namespace gfx | 139 } // namespace gfx |
49 | 140 |
50 #endif // UI_GFX_COLOR_SPACE_H_ | 141 #endif // UI_GFX_COLOR_SPACE_H_ |
OLD | NEW |