Chromium Code Reviews| Index: ui/gfx/color_space.h |
| diff --git a/ui/gfx/color_space.h b/ui/gfx/color_space.h |
| index 798b9305a19b28d5941eae06812167aa77fd23ae..c85ce67990ce24300c267e418afc204b0aab8a77 100644 |
| --- a/ui/gfx/color_space.h |
| +++ b/ui/gfx/color_space.h |
| @@ -28,26 +28,17 @@ class ICCProfile; |
| class GFX_EXPORT ColorSpace { |
| public: |
| enum class PrimaryID : uint16_t { |
|
hubbe
2017/02/15 23:30:43
uint8_t (ditto below)
|
| - // The first 0-255 values should match the H264 specification (see Table E-3 |
| - // Colour Primaries in https://www.itu.int/rec/T-REC-H.264/en). |
| - RESERVED0 = 0, |
| - BT709 = 1, |
| - UNSPECIFIED = 2, |
| - RESERVED = 3, |
| - BT470M = 4, |
| - BT470BG = 5, |
| - SMPTE170M = 6, |
| - SMPTE240M = 7, |
| - FILM = 8, |
| - BT2020 = 9, |
| - SMPTEST428_1 = 10, |
| - SMPTEST431_2 = 11, |
| - SMPTEST432_1 = 12, |
| - |
| - LAST_STANDARD_VALUE = SMPTEST432_1, |
| - |
| - // Chrome-specific values start at 1000. |
| - UNKNOWN = 1000, |
| + INVALID = 0, |
| + BT709, |
| + BT470M, |
| + BT470BG, |
| + SMPTE170M, |
| + SMPTE240M, |
| + FILM, |
| + BT2020, |
| + SMPTEST428_1, |
| + SMPTEST431_2, |
| + SMPTEST432_1, |
| XYZ_D50, |
| ADOBE_RGB, |
| CUSTOM, |
| @@ -55,33 +46,24 @@ class GFX_EXPORT ColorSpace { |
| }; |
| enum class TransferID : uint16_t { |
| - // The first 0-255 values should match the H264 specification (see Table E-4 |
| - // Transfer Characteristics in https://www.itu.int/rec/T-REC-H.264/en). |
| - RESERVED0 = 0, |
| - BT709 = 1, |
| - UNSPECIFIED = 2, |
| - RESERVED = 3, |
| - GAMMA22 = 4, |
| - GAMMA28 = 5, |
| - SMPTE170M = 6, |
| - SMPTE240M = 7, |
| - LINEAR = 8, |
| - LOG = 9, |
| - LOG_SQRT = 10, |
| - IEC61966_2_4 = 11, |
| - BT1361_ECG = 12, |
| - IEC61966_2_1 = 13, |
| - BT2020_10 = 14, |
| - BT2020_12 = 15, |
| - SMPTEST2084 = 16, |
| - SMPTEST428_1 = 17, |
| - ARIB_STD_B67 = 18, // AKA hybrid-log gamma, HLG. |
| - |
| - LAST_STANDARD_VALUE = SMPTEST428_1, |
| - |
| - // Chrome-specific values start at 1000. |
| - UNKNOWN = 1000, |
| + INVALID = 0, |
| + BT709, |
| + GAMMA22, |
| GAMMA24, |
| + GAMMA28, |
| + SMPTE170M, |
| + SMPTE240M, |
| + LINEAR, |
| + LOG, |
| + LOG_SQRT, |
| + IEC61966_2_4, |
| + BT1361_ECG, |
| + IEC61966_2_1, |
| + BT2020_10, |
| + BT2020_12, |
| + SMPTEST2084, |
| + SMPTEST428_1, |
| + ARIB_STD_B67, |
| // This is an ad-hoc transfer function that decodes SMPTE 2084 content |
| // into a 0-1 range more or less suitable for viewing on a non-hdr |
| @@ -90,51 +72,32 @@ class GFX_EXPORT ColorSpace { |
| // Like LINEAR, but intended for HDR. (can go outside of 0-1) |
| LINEAR_HDR, |
| - // TODO(hubbe): Need to store an approximation of the gamma function(s). |
| + |
| CUSTOM, |
| LAST = CUSTOM, |
| }; |
| enum class MatrixID : int16_t { |
| - // The first 0-255 values should match the H264 specification (see Table E-5 |
| - // Matrix Coefficients in https://www.itu.int/rec/T-REC-H.264/en). |
| RGB = 0, |
| - BT709 = 1, |
| - UNSPECIFIED = 2, |
| - RESERVED = 3, |
| - FCC = 4, |
| - BT470BG = 5, |
| - SMPTE170M = 6, |
| - SMPTE240M = 7, |
| - YCOCG = 8, |
| - BT2020_NCL = 9, |
| - BT2020_CL = 10, |
| - YDZDX = 11, |
| - |
| - LAST_STANDARD_VALUE = YDZDX, |
| - |
| - // Chrome-specific values start at 1000 |
| - UNKNOWN = 1000, |
| - LAST = UNKNOWN, |
| + BT709, |
| + FCC, |
| + BT470BG, |
| + SMPTE170M, |
| + SMPTE240M, |
| + YCOCG, |
| + BT2020_NCL, |
| + BT2020_CL, |
| + YDZDX, |
| + LAST = YDZDX, |
| }; |
| - // This corresponds to the WebM Range enum which is part of WebM color data |
| - // (see http://www.webmproject.org/docs/container/#Range). |
| - // H.264 only uses a bool, which corresponds to the LIMITED/FULL values. |
| - // Chrome-specific values start at 1000. |
| enum class RangeID : int8_t { |
| - // Range is not explicitly specified / unknown. |
| - UNSPECIFIED = 0, |
| - |
| - // Limited Rec. 709 color range with RGB values ranging from 16 to 235. |
| - LIMITED = 1, |
| - |
| // Full RGB color range with RGB valees from 0 to 255. |
| - FULL = 2, |
| - |
| + FULL = 0, |
| + // Limited Rec. 709 color range with RGB values ranging from 16 to 235. |
| + LIMITED, |
| // Range is defined by TransferID/MatrixID. |
| - DERIVED = 3, |
| - |
| + DERIVED, |
| LAST = DERIVED |
| }; |
| @@ -145,12 +108,19 @@ class GFX_EXPORT ColorSpace { |
| MatrixID matrix, |
| RangeID full_range); |
| ColorSpace(const ColorSpace& other); |
| - ColorSpace(int primaries, int transfer, int matrix, RangeID full_range); |
| ~ColorSpace(); |
| - static PrimaryID PrimaryIDFromInt(int primary_id); |
| - static TransferID TransferIDFromInt(int transfer_id); |
| - static MatrixID MatrixIDFromInt(int matrix_id); |
| + // Return the PrimaryID for values from the H264 specification (see Table E-3 |
| + // Colour Primaries in https://www.itu.int/rec/T-REC-H.264/en). |
| + static PrimaryID PrimaryIDFromH264(int primary_id); |
| + |
| + // Return the TransferID for value from the H264 specification (see Table E-4 |
| + // Transfer Characteristics in https://www.itu.int/rec/T-REC-H.264/en). |
| + static TransferID TransferIDFromH264(int transfer_id); |
| + |
| + // Return the MatrixID for values from the H264 specification (see Table E-5 |
| + // Matrix Coefficients in https://www.itu.int/rec/T-REC-H.264/en). |
| + static MatrixID MatrixIDFromH264(int matrix_id); |
| // Returns true if this is not the default-constructor object. |
| bool IsValid() const; |
| @@ -187,10 +157,10 @@ class GFX_EXPORT ColorSpace { |
| void GetRangeAdjustMatrix(SkMatrix44* matrix) const; |
| private: |
| - PrimaryID primaries_ = PrimaryID::UNSPECIFIED; |
| - TransferID transfer_ = TransferID::UNSPECIFIED; |
| - MatrixID matrix_ = MatrixID::UNSPECIFIED; |
| - RangeID range_ = RangeID::LIMITED; |
| + PrimaryID primaries_ = PrimaryID::INVALID; |
| + TransferID transfer_ = TransferID::INVALID; |
| + MatrixID matrix_ = MatrixID::RGB; |
|
hubbe
2017/02/15 23:30:43
I think we should default matrix_ & range_ to INVA
|
| + RangeID range_ = RangeID::FULL; |
| // Only used if primaries_ is PrimaryID::CUSTOM. |
| float custom_primary_matrix_[9] = {0, 0, 0, 0, 0, 0, 0, 0}; |