OLD | NEW |
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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 RangeID full_range); | 143 RangeID full_range); |
144 ColorSpace(const ColorSpace& other); | 144 ColorSpace(const ColorSpace& other); |
145 ColorSpace(int primaries, int transfer, int matrix, RangeID full_range); | 145 ColorSpace(int primaries, int transfer, int matrix, RangeID full_range); |
146 ~ColorSpace(); | 146 ~ColorSpace(); |
147 | 147 |
148 static PrimaryID PrimaryIDFromInt(int primary_id); | 148 static PrimaryID PrimaryIDFromInt(int primary_id); |
149 static TransferID TransferIDFromInt(int transfer_id); | 149 static TransferID TransferIDFromInt(int transfer_id); |
150 static MatrixID MatrixIDFromInt(int matrix_id); | 150 static MatrixID MatrixIDFromInt(int matrix_id); |
151 | 151 |
152 static ColorSpace CreateSRGB(); | 152 static ColorSpace CreateSRGB(); |
153 static ColorSpace CreateCustom(const SkMatrix44& to_XYZD50, | |
154 const SkColorSpaceTransferFn& fn); | |
155 // scRGB is like RGB, but linear and values outside of 0-1 are allowed. | 153 // scRGB is like RGB, but linear and values outside of 0-1 are allowed. |
156 // scRGB is normally used with fp16 textures. | 154 // scRGB is normally used with fp16 textures. |
157 static ColorSpace CreateSCRGBLinear(); | 155 static ColorSpace CreateSCRGBLinear(); |
158 static ColorSpace CreateXYZD50(); | 156 static ColorSpace CreateXYZD50(); |
159 | 157 |
160 // TODO: Remove these, and replace with more generic constructors. | 158 // TODO: Remove these, and replace with more generic constructors. |
161 static ColorSpace CreateJpeg(); | 159 static ColorSpace CreateJpeg(); |
162 static ColorSpace CreateREC601(); | 160 static ColorSpace CreateREC601(); |
163 static ColorSpace CreateREC709(); | 161 static ColorSpace CreateREC709(); |
164 | 162 |
165 bool operator==(const ColorSpace& other) const; | 163 bool operator==(const ColorSpace& other) const; |
166 bool operator!=(const ColorSpace& other) const; | 164 bool operator!=(const ColorSpace& other) const; |
167 bool operator<(const ColorSpace& other) const; | 165 bool operator<(const ColorSpace& other) const; |
168 | 166 |
169 bool IsHDR() const; | 167 bool IsHDR() const; |
170 | 168 |
171 // Note that this may return nullptr. | 169 // Note that this may return nullptr. |
172 const sk_sp<SkColorSpace>& ToSkColorSpace() const { return sk_color_space_; } | 170 const sk_sp<SkColorSpace>& ToSkColorSpace() const { return sk_color_space_; } |
173 static ColorSpace FromSkColorSpace(const sk_sp<SkColorSpace>& sk_color_space); | 171 static ColorSpace FromSkColorSpace(const sk_sp<SkColorSpace>& sk_color_space); |
174 | 172 |
175 void GetPrimaryMatrix(SkMatrix44* to_XYZD50) const; | |
176 bool GetTransferFunction(SkColorSpaceTransferFn* fn) const; | |
177 bool GetInverseTransferFunction(SkColorSpaceTransferFn* fn) const; | |
178 | |
179 private: | 173 private: |
180 PrimaryID primaries_ = PrimaryID::UNSPECIFIED; | 174 PrimaryID primaries_ = PrimaryID::UNSPECIFIED; |
181 TransferID transfer_ = TransferID::UNSPECIFIED; | 175 TransferID transfer_ = TransferID::UNSPECIFIED; |
182 MatrixID matrix_ = MatrixID::UNSPECIFIED; | 176 MatrixID matrix_ = MatrixID::UNSPECIFIED; |
183 RangeID range_ = RangeID::LIMITED; | 177 RangeID range_ = RangeID::LIMITED; |
184 | 178 |
185 // Only used if primaries_ is PrimaryID::CUSTOM. | 179 // Only used if primaries_ == PrimaryID::CUSTOM |
186 float custom_primary_matrix_[9]; | 180 float custom_primary_matrix_[12]; |
187 | |
188 // Only used if transfer_ is TransferID::CUSTOM. This array consists of the A | |
189 // through G entries of the SkColorSpaceTransferFn structure in alphabetical | |
190 // order. | |
191 float custom_transfer_params_[7]; | |
192 | 181 |
193 // This is used to look up the ICCProfile from which this ColorSpace was | 182 // This is used to look up the ICCProfile from which this ColorSpace was |
194 // created, if possible. | 183 // created, if possible. |
195 uint64_t icc_profile_id_ = 0; | 184 uint64_t icc_profile_id_ = 0; |
196 | 185 |
197 sk_sp<SkColorSpace> sk_color_space_; | 186 sk_sp<SkColorSpace> sk_color_space_; |
198 | 187 |
199 friend class ICCProfile; | 188 friend class ICCProfile; |
200 friend class ColorSpaceToColorSpaceTransform; | 189 friend class ColorSpaceToColorSpaceTransform; |
201 friend class ColorSpaceWin; | 190 friend class ColorSpaceWin; |
202 friend struct IPC::ParamTraits<gfx::ColorSpace>; | 191 friend struct IPC::ParamTraits<gfx::ColorSpace>; |
203 FRIEND_TEST_ALL_PREFIXES(SimpleColorSpace, GetColorSpace); | 192 FRIEND_TEST_ALL_PREFIXES(SimpleColorSpace, GetColorSpace); |
204 }; | 193 }; |
205 | 194 |
206 } // namespace gfx | 195 } // namespace gfx |
207 | 196 |
208 #endif // UI_GFX_COLOR_SPACE_H_ | 197 #endif // UI_GFX_COLOR_SPACE_H_ |
OLD | NEW |