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

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

Issue 2660393002: Use gfx::ColorSpace instead of SkColorSpace in Blink (Closed)
Patch Set: Rebase (again) 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 // Full RGB color range with RGB valees from 0 to 255. 133 // Full RGB color range with RGB valees from 0 to 255.
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();
143 ColorSpace(PrimaryID primaries, TransferID transfer);
142 ColorSpace(PrimaryID primaries, 144 ColorSpace(PrimaryID primaries,
143 TransferID transfer, 145 TransferID transfer,
144 MatrixID matrix, 146 MatrixID matrix,
145 RangeID full_range); 147 RangeID full_range);
146 ColorSpace(const ColorSpace& other); 148 ColorSpace(const ColorSpace& other);
147 ColorSpace(int primaries, int transfer, int matrix, RangeID full_range); 149 ColorSpace(int primaries, int transfer, int matrix, RangeID full_range);
148 ~ColorSpace(); 150 ~ColorSpace();
149 151
150 static PrimaryID PrimaryIDFromInt(int primary_id); 152 static PrimaryID PrimaryIDFromInt(int primary_id);
151 static TransferID TransferIDFromInt(int transfer_id); 153 static TransferID TransferIDFromInt(int transfer_id);
152 static MatrixID MatrixIDFromInt(int matrix_id); 154 static MatrixID MatrixIDFromInt(int matrix_id);
153 155
156 // Returns true if this is not the default-constructor object.
157 bool IsValid() const;
158
154 static ColorSpace CreateSRGB(); 159 static ColorSpace CreateSRGB();
155 static ColorSpace CreateCustom(const SkMatrix44& to_XYZD50, 160 static ColorSpace CreateCustom(const SkMatrix44& to_XYZD50,
156 const SkColorSpaceTransferFn& fn); 161 const SkColorSpaceTransferFn& fn);
157 // scRGB is like RGB, but linear and values outside of 0-1 are allowed. 162 // scRGB is like RGB, but linear and values outside of 0-1 are allowed.
158 // scRGB is normally used with fp16 textures. 163 // scRGB is normally used with fp16 textures.
159 static ColorSpace CreateSCRGBLinear(); 164 static ColorSpace CreateSCRGBLinear();
160 static ColorSpace CreateXYZD50(); 165 static ColorSpace CreateXYZD50();
161 166
162 // TODO: Remove these, and replace with more generic constructors. 167 // TODO: Remove these, and replace with more generic constructors.
163 static ColorSpace CreateJpeg(); 168 static ColorSpace CreateJpeg();
164 static ColorSpace CreateREC601(); 169 static ColorSpace CreateREC601();
165 static ColorSpace CreateREC709(); 170 static ColorSpace CreateREC709();
166 171
167 bool operator==(const ColorSpace& other) const; 172 bool operator==(const ColorSpace& other) const;
168 bool operator!=(const ColorSpace& other) const; 173 bool operator!=(const ColorSpace& other) const;
169 bool operator<(const ColorSpace& other) const; 174 bool operator<(const ColorSpace& other) const;
170 175
171 bool IsHDR() const; 176 bool IsHDR() const;
172 177
173 // Note that this may return nullptr. 178 // This will return nullptr for non-RGB spaces, spaces with non-FULL
179 // range, and unspecified spaces.
174 sk_sp<SkColorSpace> ToSkColorSpace() const; 180 sk_sp<SkColorSpace> ToSkColorSpace() const;
175 static ColorSpace FromSkColorSpace(const sk_sp<SkColorSpace>& sk_color_space);
176 181
177 void GetPrimaryMatrix(SkMatrix44* to_XYZD50) const; 182 void GetPrimaryMatrix(SkMatrix44* to_XYZD50) const;
178 bool GetTransferFunction(SkColorSpaceTransferFn* fn) const; 183 bool GetTransferFunction(SkColorSpaceTransferFn* fn) const;
179 bool GetInverseTransferFunction(SkColorSpaceTransferFn* fn) const; 184 bool GetInverseTransferFunction(SkColorSpaceTransferFn* fn) const;
180 185
181 // For most formats, this is the RGB to YUV matrix. 186 // For most formats, this is the RGB to YUV matrix.
182 void GetTransferMatrix(SkMatrix44* matrix) const; 187 void GetTransferMatrix(SkMatrix44* matrix) const;
183 void GetRangeAdjustMatrix(SkMatrix44* matrix) const; 188 void GetRangeAdjustMatrix(SkMatrix44* matrix) const;
184 189
185 private: 190 private:
(...skipping 18 matching lines...) Expand all
204 friend class ICCProfile; 209 friend class ICCProfile;
205 friend class ColorSpaceToColorSpaceTransform; 210 friend class ColorSpaceToColorSpaceTransform;
206 friend class ColorSpaceWin; 211 friend class ColorSpaceWin;
207 friend struct IPC::ParamTraits<gfx::ColorSpace>; 212 friend struct IPC::ParamTraits<gfx::ColorSpace>;
208 FRIEND_TEST_ALL_PREFIXES(SimpleColorSpace, GetColorSpace); 213 FRIEND_TEST_ALL_PREFIXES(SimpleColorSpace, GetColorSpace);
209 }; 214 };
210 215
211 } // namespace gfx 216 } // namespace gfx
212 217
213 #endif // UI_GFX_COLOR_SPACE_H_ 218 #endif // UI_GFX_COLOR_SPACE_H_
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/image-decoders/ImageDecoder.cpp ('k') | ui/gfx/color_space.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698