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

Side by Side Diff: ui/gfx/color_space.h

Issue 2338213009: Always use valid enum values in gfx::ColorSpace (Closed)
Patch Set: merge Created 4 years, 3 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 unified diff | Download patch
« no previous file with comments | « media/filters/ffmpeg_video_decoder.cc ('k') | ui/gfx/color_space.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/gtest_prod_util.h" 10 #include "base/gtest_prod_util.h"
(...skipping 25 matching lines...) Expand all
36 BT470M = 4, 36 BT470M = 4,
37 BT470BG = 5, 37 BT470BG = 5,
38 SMPTE170M = 6, 38 SMPTE170M = 6,
39 SMPTE240M = 7, 39 SMPTE240M = 7,
40 FILM = 8, 40 FILM = 8,
41 BT2020 = 9, 41 BT2020 = 9,
42 SMPTEST428_1 = 10, 42 SMPTEST428_1 = 10,
43 SMPTEST431_2 = 11, 43 SMPTEST431_2 = 11,
44 SMPTEST432_1 = 12, 44 SMPTEST432_1 = 12,
45 45
46 LAST_STANDARD_VALUE = SMPTEST432_1,
47
46 // Chrome-specific values start at 1000. 48 // Chrome-specific values start at 1000.
47 XYZ_D50 = 1000, 49 UNKNOWN = 1000,
48 // TODO(hubbe): We need to store the primaries. 50 XYZ_D50,
49 CUSTOM = 1001, 51 CUSTOM,
50 LAST = CUSTOM 52 LAST = CUSTOM
51 }; 53 };
52 54
53 enum class TransferID : uint16_t { 55 enum class TransferID : uint16_t {
54 // The first 0-255 values should match the H264 specification. 56 // The first 0-255 values should match the H264 specification.
55 RESERVED0 = 0, 57 RESERVED0 = 0,
56 BT709 = 1, 58 BT709 = 1,
57 UNSPECIFIED = 2, 59 UNSPECIFIED = 2,
58 RESERVED = 3, 60 RESERVED = 3,
59 GAMMA22 = 4, 61 GAMMA22 = 4,
60 GAMMA28 = 5, 62 GAMMA28 = 5,
61 SMPTE170M = 6, 63 SMPTE170M = 6,
62 SMPTE240M = 7, 64 SMPTE240M = 7,
63 LINEAR = 8, 65 LINEAR = 8,
64 LOG = 9, 66 LOG = 9,
65 LOG_SQRT = 10, 67 LOG_SQRT = 10,
66 IEC61966_2_4 = 11, 68 IEC61966_2_4 = 11,
67 BT1361_ECG = 12, 69 BT1361_ECG = 12,
68 IEC61966_2_1 = 13, 70 IEC61966_2_1 = 13,
69 BT2020_10 = 14, 71 BT2020_10 = 14,
70 BT2020_12 = 15, 72 BT2020_12 = 15,
71 SMPTEST2084 = 16, 73 SMPTEST2084 = 16,
72 SMPTEST428_1 = 17, 74 SMPTEST428_1 = 17,
73 ARIB_STD_B67 = 18, // AKA hybrid-log gamma, HLG. 75 ARIB_STD_B67 = 18, // AKA hybrid-log gamma, HLG.
74 76
77 LAST_STANDARD_VALUE = SMPTEST428_1,
78
75 // Chrome-specific values start at 1000. 79 // Chrome-specific values start at 1000.
76 GAMMA24 = 1000, 80 UNKNOWN = 1000,
81 GAMMA24,
77 82
78 // This is an ad-hoc transfer function that decodes SMPTE 2084 content 83 // This is an ad-hoc transfer function that decodes SMPTE 2084 content
79 // into a 0-1 range more or less suitable for viewing on a non-hdr 84 // into a 0-1 range more or less suitable for viewing on a non-hdr
80 // display. 85 // display.
81 SMPTEST2084_NON_HDR, 86 SMPTEST2084_NON_HDR,
82 87
83 // TODO(hubbe): Need to store an approximation of the gamma function(s). 88 // TODO(hubbe): Need to store an approximation of the gamma function(s).
84 CUSTOM, 89 CUSTOM,
85 LAST = CUSTOM, 90 LAST = CUSTOM,
86 }; 91 };
87 92
88 enum class MatrixID : int16_t { 93 enum class MatrixID : int16_t {
89 // The first 0-255 values should match the H264 specification. 94 // The first 0-255 values should match the H264 specification.
90 RGB = 0, 95 RGB = 0,
91 BT709 = 1, 96 BT709 = 1,
92 UNSPECIFIED = 2, 97 UNSPECIFIED = 2,
93 RESERVED = 3, 98 RESERVED = 3,
94 FCC = 4, 99 FCC = 4,
95 BT470BG = 5, 100 BT470BG = 5,
96 SMPTE170M = 6, 101 SMPTE170M = 6,
97 SMPTE240M = 7, 102 SMPTE240M = 7,
98 YCOCG = 8, 103 YCOCG = 8,
99 BT2020_NCL = 9, 104 BT2020_NCL = 9,
100 BT2020_CL = 10, 105 BT2020_CL = 10,
101 YDZDX = 11, 106 YDZDX = 11,
102 107
108 LAST_STANDARD_VALUE = YDZDX,
109
103 // Chrome-specific values start at 1000 110 // Chrome-specific values start at 1000
104 LAST = YDZDX, 111 UNKNOWN = 1000,
112 LAST = UNKNOWN,
105 }; 113 };
106 114
107 // The h264 spec declares this as bool, so only the the first two values 115 // The h264 spec declares this as bool, so only the the first two values
108 // correspond to the h264 spec. Chrome-specific values can start at 2. 116 // correspond to the h264 spec. Chrome-specific values can start at 2.
109 // We use an enum instead of a bool becuase different bit depths may have 117 // We use an enum instead of a bool becuase different bit depths may have
110 // different definitions of what "limited" means. 118 // different definitions of what "limited" means.
111 enum class RangeID : int8_t { 119 enum class RangeID : int8_t {
112 FULL = 0, 120 FULL = 0,
113 LIMITED = 1, 121 LIMITED = 1,
114 122
115 LAST = LIMITED 123 LAST = LIMITED
116 }; 124 };
117 125
118 ColorSpace(); 126 ColorSpace();
119 ColorSpace(PrimaryID primaries, 127 ColorSpace(PrimaryID primaries,
120 TransferID transfer, 128 TransferID transfer,
121 MatrixID matrix, 129 MatrixID matrix,
122 RangeID full_range); 130 RangeID full_range);
131 ColorSpace(int primaries, int transfer, int matrix, RangeID full_range);
132
133 static PrimaryID PrimaryIDFromInt(int primary_id);
134 static TransferID TransferIDFromInt(int transfer_id);
135 static MatrixID MatrixIDFromInt(int matrix_id);
123 136
124 static ColorSpace CreateSRGB(); 137 static ColorSpace CreateSRGB();
125 static ColorSpace CreateXYZD50(); 138 static ColorSpace CreateXYZD50();
126 139
127 // TODO: Remove these, and replace with more generic constructors. 140 // TODO: Remove these, and replace with more generic constructors.
128 static ColorSpace CreateJpeg(); 141 static ColorSpace CreateJpeg();
129 static ColorSpace CreateREC601(); 142 static ColorSpace CreateREC601();
130 static ColorSpace CreateREC709(); 143 static ColorSpace CreateREC709();
131 144
132 bool operator==(const ColorSpace& other) const; 145 bool operator==(const ColorSpace& other) const;
(...skipping 15 matching lines...) Expand all
148 161
149 friend class ICCProfile; 162 friend class ICCProfile;
150 friend class ColorSpaceToColorSpaceTransform; 163 friend class ColorSpaceToColorSpaceTransform;
151 friend struct IPC::ParamTraits<gfx::ColorSpace>; 164 friend struct IPC::ParamTraits<gfx::ColorSpace>;
152 FRIEND_TEST_ALL_PREFIXES(SimpleColorSpace, GetColorSpace); 165 FRIEND_TEST_ALL_PREFIXES(SimpleColorSpace, GetColorSpace);
153 }; 166 };
154 167
155 } // namespace gfx 168 } // namespace gfx
156 169
157 #endif // UI_GFX_COLOR_SPACE_H_ 170 #endif // UI_GFX_COLOR_SPACE_H_
OLDNEW
« no previous file with comments | « media/filters/ffmpeg_video_decoder.cc ('k') | ui/gfx/color_space.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698