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

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

Issue 2660393002: Use gfx::ColorSpace instead of SkColorSpace in Blink (Closed)
Patch Set: 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 unified diff | Download patch
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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 BT2020 = 9, 43 BT2020 = 9,
44 SMPTEST428_1 = 10, 44 SMPTEST428_1 = 10,
45 SMPTEST431_2 = 11, 45 SMPTEST431_2 = 11,
46 SMPTEST432_1 = 12, 46 SMPTEST432_1 = 12,
47 47
48 LAST_STANDARD_VALUE = SMPTEST432_1, 48 LAST_STANDARD_VALUE = SMPTEST432_1,
49 49
50 // Chrome-specific values start at 1000. 50 // Chrome-specific values start at 1000.
51 UNKNOWN = 1000, 51 UNKNOWN = 1000,
52 XYZ_D50, 52 XYZ_D50,
53 ADOBE_RGB,
53 CUSTOM, 54 CUSTOM,
54 LAST = CUSTOM 55 LAST = CUSTOM
55 }; 56 };
56 57
57 enum class TransferID : uint16_t { 58 enum class TransferID : uint16_t {
58 // The first 0-255 values should match the H264 specification (see Table E-4 59 // The first 0-255 values should match the H264 specification (see Table E-4
59 // Transfer Characteristics in https://www.itu.int/rec/T-REC-H.264/en). 60 // Transfer Characteristics in https://www.itu.int/rec/T-REC-H.264/en).
60 RESERVED0 = 0, 61 RESERVED0 = 0,
61 BT709 = 1, 62 BT709 = 1,
62 UNSPECIFIED = 2, 63 UNSPECIFIED = 2,
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 FULL = 2, 134 FULL = 2,
134 135
135 // Range is defined by TransferID/MatrixID. 136 // Range is defined by TransferID/MatrixID.
136 DERIVED = 3, 137 DERIVED = 3,
137 138
138 LAST = DERIVED 139 LAST = DERIVED
139 }; 140 };
140 141
141 ColorSpace(); 142 ColorSpace();
142 ColorSpace(PrimaryID primaries, 143 ColorSpace(PrimaryID primaries,
144 TransferID transfer);
145 ColorSpace(PrimaryID primaries,
143 TransferID transfer, 146 TransferID transfer,
144 MatrixID matrix, 147 MatrixID matrix,
145 RangeID full_range); 148 RangeID full_range);
146 ColorSpace(const ColorSpace& other); 149 ColorSpace(const ColorSpace& other);
147 ColorSpace(int primaries, int transfer, int matrix, RangeID full_range); 150 ColorSpace(int primaries, int transfer, int matrix, RangeID full_range);
148 ~ColorSpace(); 151 ~ColorSpace();
149 152
150 static PrimaryID PrimaryIDFromInt(int primary_id); 153 static PrimaryID PrimaryIDFromInt(int primary_id);
151 static TransferID TransferIDFromInt(int transfer_id); 154 static TransferID TransferIDFromInt(int transfer_id);
152 static MatrixID MatrixIDFromInt(int matrix_id); 155 static MatrixID MatrixIDFromInt(int matrix_id);
153 156
157 // Returns true if this is not the default-constructor object.
158 bool IsValid() const;
159
154 static ColorSpace CreateSRGB(); 160 static ColorSpace CreateSRGB();
155 static ColorSpace CreateCustom(const SkMatrix44& to_XYZD50, 161 static ColorSpace CreateCustom(const SkMatrix44& to_XYZD50,
156 const SkColorSpaceTransferFn& fn); 162 const SkColorSpaceTransferFn& fn);
157 // scRGB is like RGB, but linear and values outside of 0-1 are allowed. 163 // scRGB is like RGB, but linear and values outside of 0-1 are allowed.
158 // scRGB is normally used with fp16 textures. 164 // scRGB is normally used with fp16 textures.
159 static ColorSpace CreateSCRGBLinear(); 165 static ColorSpace CreateSCRGBLinear();
160 static ColorSpace CreateXYZD50(); 166 static ColorSpace CreateXYZD50();
161 167
162 // TODO: Remove these, and replace with more generic constructors. 168 // TODO: Remove these, and replace with more generic constructors.
163 static ColorSpace CreateJpeg(); 169 static ColorSpace CreateJpeg();
164 static ColorSpace CreateREC601(); 170 static ColorSpace CreateREC601();
165 static ColorSpace CreateREC709(); 171 static ColorSpace CreateREC709();
166 172
167 bool operator==(const ColorSpace& other) const; 173 bool operator==(const ColorSpace& other) const;
168 bool operator!=(const ColorSpace& other) const; 174 bool operator!=(const ColorSpace& other) const;
169 bool operator<(const ColorSpace& other) const; 175 bool operator<(const ColorSpace& other) const;
170 176
171 bool IsHDR() const; 177 bool IsHDR() const;
172 178
173 // Note that this may return nullptr. 179 // This will return nullptr for non-RGB spaces, spaces with non-FULL
180 // range, and unspecified spaces.
174 sk_sp<SkColorSpace> ToSkColorSpace() const; 181 sk_sp<SkColorSpace> ToSkColorSpace() const;
175 static ColorSpace FromSkColorSpace(const sk_sp<SkColorSpace>& sk_color_space);
176 182
177 void GetPrimaryMatrix(SkMatrix44* to_XYZD50) const; 183 void GetPrimaryMatrix(SkMatrix44* to_XYZD50) const;
178 bool GetTransferFunction(SkColorSpaceTransferFn* fn) const; 184 bool GetTransferFunction(SkColorSpaceTransferFn* fn) const;
179 bool GetInverseTransferFunction(SkColorSpaceTransferFn* fn) const; 185 bool GetInverseTransferFunction(SkColorSpaceTransferFn* fn) const;
180 186
181 private: 187 private:
182 PrimaryID primaries_ = PrimaryID::UNSPECIFIED; 188 PrimaryID primaries_ = PrimaryID::UNSPECIFIED;
183 TransferID transfer_ = TransferID::UNSPECIFIED; 189 TransferID transfer_ = TransferID::UNSPECIFIED;
184 MatrixID matrix_ = MatrixID::UNSPECIFIED; 190 MatrixID matrix_ = MatrixID::UNSPECIFIED;
185 RangeID range_ = RangeID::LIMITED; 191 RangeID range_ = RangeID::LIMITED;
(...skipping 14 matching lines...) Expand all
200 friend class ICCProfile; 206 friend class ICCProfile;
201 friend class ColorSpaceToColorSpaceTransform; 207 friend class ColorSpaceToColorSpaceTransform;
202 friend class ColorSpaceWin; 208 friend class ColorSpaceWin;
203 friend struct IPC::ParamTraits<gfx::ColorSpace>; 209 friend struct IPC::ParamTraits<gfx::ColorSpace>;
204 FRIEND_TEST_ALL_PREFIXES(SimpleColorSpace, GetColorSpace); 210 FRIEND_TEST_ALL_PREFIXES(SimpleColorSpace, GetColorSpace);
205 }; 211 };
206 212
207 } // namespace gfx 213 } // namespace gfx
208 214
209 #endif // UI_GFX_COLOR_SPACE_H_ 215 #endif // UI_GFX_COLOR_SPACE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698