Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(170)

Unified Diff: ui/gfx/color_space.h

Issue 2697863003: color: Clarify default behaviors (Closed)
Patch Set: Do less Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/gfx/color_space.h
diff --git a/ui/gfx/color_space.h b/ui/gfx/color_space.h
index 798b9305a19b28d5941eae06812167aa77fd23ae..c605a1aee9eff7c17f575d83392064bc594c6a8b 100644
--- a/ui/gfx/color_space.h
+++ b/ui/gfx/color_space.h
@@ -28,59 +28,52 @@ class ICCProfile;
class GFX_EXPORT ColorSpace {
public:
enum class PrimaryID : uint16_t {
- // 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,
+ RESERVED0 = 1000,
+ FIRST_VIDEO_VALUE = RESERVED0,
+ BT709 = 1001,
+ UNSPECIFIED = 1002,
+ RESERVED = 1003,
+ BT470M = 1004,
+ BT470BG = 1005,
+ SMPTE170M = 1006,
+ SMPTE240M = 1007,
+ FILM = 1008,
+ BT2020 = 1009,
+ SMPTEST428_1 = 1010,
+ SMPTEST431_2 = 1011,
+ SMPTEST432_1 = 1012,
+ LAST_VIDEO_VALUE = SMPTEST432_1,
+
XYZ_D50,
ADOBE_RGB,
CUSTOM,
- LAST = CUSTOM
+ INVALID,
+ LAST = INVALID
};
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,
+ RESERVED0 = 1000,
hubbe 2017/02/16 05:02:39 Actually, this is really weird to me. Either we em
+ FIRST_VIDEO_VALUE = RESERVED0,
+ BT709 = 1001,
+ UNSPECIFIED = 1002,
+ RESERVED = 1003,
+ GAMMA22 = 1004,
+ GAMMA28 = 1005,
+ SMPTE170M = 1006,
+ SMPTE240M = 1007,
+ LINEAR = 1008,
+ LOG = 1009,
+ LOG_SQRT = 1010,
+ IEC61966_2_4 = 1011,
+ BT1361_ECG = 1012,
+ IEC61966_2_1 = 1013,
+ BT2020_10 = 1014,
+ BT2020_12 = 1015,
+ SMPTEST2084 = 1016,
+ SMPTEST428_1 = 1017,
+ ARIB_STD_B67 = 1018, // AKA hybrid-log gamma, HLG.
+ LAST_VIDEO_VALUE = ARIB_STD_B67,
+
GAMMA24,
// This is an ad-hoc transfer function that decodes SMPTE 2084 content
@@ -90,38 +83,30 @@ 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,
+ INVALID,
+ LAST = INVALID,
};
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,
+ RGB = 1000,
+ FIRST_VIDEO_VALUE = RGB,
+ BT709 = 1001,
+ UNSPECIFIED = 1002,
+ RESERVED = 1003,
+ FCC = 1004,
+ BT470BG = 1005,
+ SMPTE170M = 1006,
+ SMPTE240M = 1007,
+ YCOCG = 1008,
+ BT2020_NCL = 1009,
+ BT2020_CL = 1010,
+ YDZDX = 1011,
+ LAST_VIDEO_VALUE = YDZDX,
+ INVALID,
+ LAST = INVALID,
};
- // 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,
@@ -135,7 +120,8 @@ class GFX_EXPORT ColorSpace {
// Range is defined by TransferID/MatrixID.
DERIVED = 3,
- LAST = DERIVED
+ INVALID,
+ LAST = INVALID
};
ColorSpace();
@@ -145,12 +131,21 @@ 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);
+ // Create a color space with primary, transfer and matrix values from the
+ // H264 specification (Table E-3 Colour Primaries, E-4 Transfer
+ // Characteristics, and E-5 Matrix Coefficients in
+ // https://www.itu.int/rec/T-REC-H.264/en).
+ static ColorSpace CreateVideo(int h264_primary,
+ int h264_transfer,
+ int h264_matrix,
+ RangeID range_id);
+ // Retrieve the H264 parameters.
+ void GetVideoParameters(int* h264_primary,
hubbe 2017/02/16 05:02:39 I'd rather have four individual accessors.
+ int* h264_transfer,
+ int* h264_matrix,
+ bool* full_range);
// Returns true if this is not the default-constructor object.
bool IsValid() const;
@@ -187,10 +182,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::INVALID;
+ RangeID range_ = RangeID::INVALID;
// Only used if primaries_ is PrimaryID::CUSTOM.
float custom_primary_matrix_[9] = {0, 0, 0, 0, 0, 0, 0, 0};

Powered by Google App Engine
This is Rietveld 408576698