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