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