| 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 #include <ostream> | 9 #include <ostream> |
| 10 | 10 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 | 21 |
| 22 namespace gfx { | 22 namespace gfx { |
| 23 | 23 |
| 24 class ICCProfile; | 24 class ICCProfile; |
| 25 | 25 |
| 26 // Used to represet a color space for the purpose of color conversion. | 26 // Used to represet a color space for the purpose of color conversion. |
| 27 // This is designed to be safe and compact enough to send over IPC | 27 // This is designed to be safe and compact enough to send over IPC |
| 28 // between any processes. | 28 // between any processes. |
| 29 class GFX_EXPORT ColorSpace { | 29 class GFX_EXPORT ColorSpace { |
| 30 public: | 30 public: |
| 31 enum class PrimaryID : uint16_t { | 31 enum class PrimaryID : uint8_t { |
| 32 INVALID, | 32 INVALID, |
| 33 BT709, | 33 BT709, |
| 34 BT470M, | 34 BT470M, |
| 35 BT470BG, | 35 BT470BG, |
| 36 SMPTE170M, | 36 SMPTE170M, |
| 37 SMPTE240M, | 37 SMPTE240M, |
| 38 FILM, | 38 FILM, |
| 39 BT2020, | 39 BT2020, |
| 40 SMPTEST428_1, | 40 SMPTEST428_1, |
| 41 SMPTEST431_2, | 41 SMPTEST431_2, |
| 42 SMPTEST432_1, | 42 SMPTEST432_1, |
| 43 XYZ_D50, | 43 XYZ_D50, |
| 44 ADOBE_RGB, | 44 ADOBE_RGB, |
| 45 // Primaries defined by the primary matrix |custom_primary_matrix_|. | 45 // Primaries defined by the primary matrix |custom_primary_matrix_|. |
| 46 CUSTOM, | 46 CUSTOM, |
| 47 // For color spaces defined by an ICC profile which cannot be represented | 47 // For color spaces defined by an ICC profile which cannot be represented |
| 48 // parametrically. Any ColorTransform using this color space will use the | 48 // parametrically. Any ColorTransform using this color space will use the |
| 49 // ICC profile directly to compute a transform LUT. | 49 // ICC profile directly to compute a transform LUT. |
| 50 ICC_BASED, | 50 ICC_BASED, |
| 51 LAST = ICC_BASED, | 51 LAST = ICC_BASED, |
| 52 }; | 52 }; |
| 53 | 53 |
| 54 enum class TransferID : uint16_t { | 54 enum class TransferID : uint8_t { |
| 55 INVALID, | 55 INVALID, |
| 56 BT709, | 56 BT709, |
| 57 GAMMA22, | 57 GAMMA22, |
| 58 GAMMA24, | 58 GAMMA24, |
| 59 GAMMA28, | 59 GAMMA28, |
| 60 SMPTE170M, | 60 SMPTE170M, |
| 61 SMPTE240M, | 61 SMPTE240M, |
| 62 LINEAR, | 62 LINEAR, |
| 63 LOG, | 63 LOG, |
| 64 LOG_SQRT, | 64 LOG_SQRT, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 79 IEC61966_2_1_HDR, | 79 IEC61966_2_1_HDR, |
| 80 // The same as LINEAR but is defined for all real values. | 80 // The same as LINEAR but is defined for all real values. |
| 81 LINEAR_HDR, | 81 LINEAR_HDR, |
| 82 // A parametric transfer function defined by |custom_transfer_params_|. | 82 // A parametric transfer function defined by |custom_transfer_params_|. |
| 83 CUSTOM, | 83 CUSTOM, |
| 84 // See PrimaryID::ICC_BASED. | 84 // See PrimaryID::ICC_BASED. |
| 85 ICC_BASED, | 85 ICC_BASED, |
| 86 LAST = ICC_BASED, | 86 LAST = ICC_BASED, |
| 87 }; | 87 }; |
| 88 | 88 |
| 89 enum class MatrixID : int16_t { | 89 enum class MatrixID : uint8_t { |
| 90 INVALID, | 90 INVALID, |
| 91 RGB, | 91 RGB, |
| 92 BT709, | 92 BT709, |
| 93 FCC, | 93 FCC, |
| 94 BT470BG, | 94 BT470BG, |
| 95 SMPTE170M, | 95 SMPTE170M, |
| 96 SMPTE240M, | 96 SMPTE240M, |
| 97 YCOCG, | 97 YCOCG, |
| 98 BT2020_NCL, | 98 BT2020_NCL, |
| 99 BT2020_CL, | 99 BT2020_CL, |
| 100 YDZDX, | 100 YDZDX, |
| 101 LAST = YDZDX, | 101 LAST = YDZDX, |
| 102 }; | 102 }; |
| 103 | 103 |
| 104 enum class RangeID : int8_t { | 104 enum class RangeID : uint8_t { |
| 105 INVALID, | 105 INVALID, |
| 106 // Limited Rec. 709 color range with RGB values ranging from 16 to 235. | 106 // Limited Rec. 709 color range with RGB values ranging from 16 to 235. |
| 107 LIMITED, | 107 LIMITED, |
| 108 // Full RGB color range with RGB valees from 0 to 255. | 108 // Full RGB color range with RGB valees from 0 to 255. |
| 109 FULL, | 109 FULL, |
| 110 // Range is defined by TransferID/MatrixID. | 110 // Range is defined by TransferID/MatrixID. |
| 111 DERIVED, | 111 DERIVED, |
| 112 LAST = DERIVED, | 112 LAST = DERIVED, |
| 113 }; | 113 }; |
| 114 | 114 |
| 115 ColorSpace(); | 115 ColorSpace(); |
| 116 ColorSpace(PrimaryID primaries, TransferID transfer); | 116 ColorSpace(PrimaryID primaries, TransferID transfer); |
| 117 ColorSpace(PrimaryID primaries, | 117 ColorSpace(PrimaryID primaries, |
| 118 TransferID transfer, | 118 TransferID transfer, |
| 119 MatrixID matrix, | 119 MatrixID matrix, |
| 120 RangeID full_range); | 120 RangeID full_range); |
| 121 ColorSpace(const ColorSpace& other); | 121 ColorSpace(const ColorSpace& other); |
| 122 ColorSpace(ColorSpace&& other); |
| 123 ColorSpace& operator=(const ColorSpace& other); |
| 122 ~ColorSpace(); | 124 ~ColorSpace(); |
| 123 | 125 |
| 124 // Create a color space with primary, transfer and matrix values from the | 126 // Create a color space with primary, transfer and matrix values from the |
| 125 // H264 specification (Table E-3 Colour Primaries, E-4 Transfer | 127 // H264 specification (Table E-3 Colour Primaries, E-4 Transfer |
| 126 // Characteristics, and E-5 Matrix Coefficients in | 128 // Characteristics, and E-5 Matrix Coefficients in |
| 127 // https://www.itu.int/rec/T-REC-H.264/en). | 129 // https://www.itu.int/rec/T-REC-H.264/en). |
| 128 static ColorSpace CreateVideo(int h264_primary, | 130 static ColorSpace CreateVideo(int h264_primary, |
| 129 int h264_transfer, | 131 int h264_transfer, |
| 130 int h264_matrix, | 132 int h264_matrix, |
| 131 RangeID range_id); | 133 RangeID range_id); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 146 static ColorSpace CreateSCRGBLinear(); | 148 static ColorSpace CreateSCRGBLinear(); |
| 147 | 149 |
| 148 // TODO: Remove these, and replace with more generic constructors. | 150 // TODO: Remove these, and replace with more generic constructors. |
| 149 static ColorSpace CreateJpeg(); | 151 static ColorSpace CreateJpeg(); |
| 150 static ColorSpace CreateREC601(); | 152 static ColorSpace CreateREC601(); |
| 151 static ColorSpace CreateREC709(); | 153 static ColorSpace CreateREC709(); |
| 152 | 154 |
| 153 bool operator==(const ColorSpace& other) const; | 155 bool operator==(const ColorSpace& other) const; |
| 154 bool operator!=(const ColorSpace& other) const; | 156 bool operator!=(const ColorSpace& other) const; |
| 155 bool operator<(const ColorSpace& other) const; | 157 bool operator<(const ColorSpace& other) const; |
| 158 size_t GetHash() const; |
| 156 std::string ToString() const; | 159 std::string ToString() const; |
| 157 | 160 |
| 158 // Returns true if the decoded values can be outside of the 0.0-1.0 range. | 161 // Returns true if the decoded values can be outside of the 0.0-1.0 range. |
| 159 bool IsHDR() const; | 162 bool IsHDR() const; |
| 160 // Returns true if the encoded values can be outside of the 0.0-1.0 range. | 163 // Returns true if the encoded values can be outside of the 0.0-1.0 range. |
| 161 bool FullRangeEncodedValues() const; | 164 bool FullRangeEncodedValues() const; |
| 162 | 165 |
| 163 // Return this color space with any range adjust or YUV to RGB conversion | 166 // Return this color space with any range adjust or YUV to RGB conversion |
| 164 // stripped off. | 167 // stripped off. |
| 165 gfx::ColorSpace GetAsFullRangeRGB() const; | 168 gfx::ColorSpace GetAsFullRangeRGB() const; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 FRIEND_TEST_ALL_PREFIXES(SimpleColorSpace, GetColorSpace); | 214 FRIEND_TEST_ALL_PREFIXES(SimpleColorSpace, GetColorSpace); |
| 212 }; | 215 }; |
| 213 | 216 |
| 214 // Stream operator so ColorSpace can be used in assertion statements. | 217 // Stream operator so ColorSpace can be used in assertion statements. |
| 215 GFX_EXPORT std::ostream& operator<<(std::ostream& out, | 218 GFX_EXPORT std::ostream& operator<<(std::ostream& out, |
| 216 const ColorSpace& color_space); | 219 const ColorSpace& color_space); |
| 217 | 220 |
| 218 } // namespace gfx | 221 } // namespace gfx |
| 219 | 222 |
| 220 #endif // UI_GFX_COLOR_SPACE_H_ | 223 #endif // UI_GFX_COLOR_SPACE_H_ |
| OLD | NEW |