| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 LINEAR, | 56 LINEAR, |
| 57 LOG, | 57 LOG, |
| 58 LOG_SQRT, | 58 LOG_SQRT, |
| 59 IEC61966_2_4, | 59 IEC61966_2_4, |
| 60 BT1361_ECG, | 60 BT1361_ECG, |
| 61 IEC61966_2_1, | 61 IEC61966_2_1, |
| 62 BT2020_10, | 62 BT2020_10, |
| 63 BT2020_12, | 63 BT2020_12, |
| 64 SMPTEST2084, | 64 SMPTEST2084, |
| 65 SMPTEST428_1, | 65 SMPTEST428_1, |
| 66 ARIB_STD_B67, // // AKA hybrid-log gamma, HLG. | 66 ARIB_STD_B67, // AKA hybrid-log gamma, HLG. |
| 67 // This is an ad-hoc transfer function that decodes SMPTE 2084 content | 67 // This is an ad-hoc transfer function that decodes SMPTE 2084 content |
| 68 // into a 0-1 range more or less suitable for viewing on a non-hdr | 68 // into a [0, 1] range more or less suitable for viewing on a non-hdr |
| 69 // display. | 69 // display. |
| 70 SMPTEST2084_NON_HDR, | 70 SMPTEST2084_NON_HDR, |
| 71 // Like LINEAR, but intended for HDR. (can go outside of 0-1) | 71 // The same as IEC61966_2_1 on the interval [0, 1], with the nonlinear |
| 72 // segment continuing beyond 1 and point symmetry defining values below 0. |
| 73 IEC61966_2_1_HDR, |
| 74 // The same as LINEAR but is defined for all real values. |
| 72 LINEAR_HDR, | 75 LINEAR_HDR, |
| 73 CUSTOM, | 76 CUSTOM, |
| 74 LAST = CUSTOM, | 77 LAST = CUSTOM, |
| 75 }; | 78 }; |
| 76 | 79 |
| 77 enum class MatrixID : int16_t { | 80 enum class MatrixID : int16_t { |
| 78 INVALID, | 81 INVALID, |
| 79 RGB, | 82 RGB, |
| 80 BT709, | 83 BT709, |
| 81 FCC, | 84 FCC, |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 int h264_transfer, | 120 int h264_transfer, |
| 118 int h264_matrix, | 121 int h264_matrix, |
| 119 RangeID range_id); | 122 RangeID range_id); |
| 120 | 123 |
| 121 // Returns true if this is not the default-constructor object. | 124 // Returns true if this is not the default-constructor object. |
| 122 bool IsValid() const; | 125 bool IsValid() const; |
| 123 | 126 |
| 124 static ColorSpace CreateSRGB(); | 127 static ColorSpace CreateSRGB(); |
| 125 static ColorSpace CreateCustom(const SkMatrix44& to_XYZD50, | 128 static ColorSpace CreateCustom(const SkMatrix44& to_XYZD50, |
| 126 const SkColorSpaceTransferFn& fn); | 129 const SkColorSpaceTransferFn& fn); |
| 127 // scRGB is like RGB, but linear and values outside of 0-1 are allowed. | 130 static ColorSpace CreateXYZD50(); |
| 128 // scRGB is normally used with fp16 textures. | 131 |
| 132 // Extended sRGB matches sRGB for values in [0, 1], and extends the transfer |
| 133 // function to all real values. |
| 134 static ColorSpace CreateExtendedSRGB(); |
| 135 // scRGB uses the same primaries as sRGB but has a linear transfer function |
| 136 // for all real values. |
| 129 static ColorSpace CreateSCRGBLinear(); | 137 static ColorSpace CreateSCRGBLinear(); |
| 130 static ColorSpace CreateXYZD50(); | |
| 131 | 138 |
| 132 // TODO: Remove these, and replace with more generic constructors. | 139 // TODO: Remove these, and replace with more generic constructors. |
| 133 static ColorSpace CreateJpeg(); | 140 static ColorSpace CreateJpeg(); |
| 134 static ColorSpace CreateREC601(); | 141 static ColorSpace CreateREC601(); |
| 135 static ColorSpace CreateREC709(); | 142 static ColorSpace CreateREC709(); |
| 136 | 143 |
| 137 bool operator==(const ColorSpace& other) const; | 144 bool operator==(const ColorSpace& other) const; |
| 138 bool operator!=(const ColorSpace& other) const; | 145 bool operator!=(const ColorSpace& other) const; |
| 139 bool operator<(const ColorSpace& other) const; | 146 bool operator<(const ColorSpace& other) const; |
| 140 | 147 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 158 | 165 |
| 159 void GetPrimaryMatrix(SkMatrix44* to_XYZD50) const; | 166 void GetPrimaryMatrix(SkMatrix44* to_XYZD50) const; |
| 160 bool GetTransferFunction(SkColorSpaceTransferFn* fn) const; | 167 bool GetTransferFunction(SkColorSpaceTransferFn* fn) const; |
| 161 bool GetInverseTransferFunction(SkColorSpaceTransferFn* fn) const; | 168 bool GetInverseTransferFunction(SkColorSpaceTransferFn* fn) const; |
| 162 | 169 |
| 163 // For most formats, this is the RGB to YUV matrix. | 170 // For most formats, this is the RGB to YUV matrix. |
| 164 void GetTransferMatrix(SkMatrix44* matrix) const; | 171 void GetTransferMatrix(SkMatrix44* matrix) const; |
| 165 void GetRangeAdjustMatrix(SkMatrix44* matrix) const; | 172 void GetRangeAdjustMatrix(SkMatrix44* matrix) const; |
| 166 | 173 |
| 167 private: | 174 private: |
| 175 // Returns true if the transfer function is defined by an |
| 176 // SkColorSpaceTransferFn which is extended to all real values. |
| 177 bool HasExtendedSkTransferFn() const; |
| 178 |
| 168 PrimaryID primaries_ = PrimaryID::INVALID; | 179 PrimaryID primaries_ = PrimaryID::INVALID; |
| 169 TransferID transfer_ = TransferID::INVALID; | 180 TransferID transfer_ = TransferID::INVALID; |
| 170 MatrixID matrix_ = MatrixID::INVALID; | 181 MatrixID matrix_ = MatrixID::INVALID; |
| 171 RangeID range_ = RangeID::INVALID; | 182 RangeID range_ = RangeID::INVALID; |
| 172 | 183 |
| 173 // Only used if primaries_ is PrimaryID::CUSTOM. | 184 // Only used if primaries_ is PrimaryID::CUSTOM. |
| 174 float custom_primary_matrix_[9] = {0, 0, 0, 0, 0, 0, 0, 0}; | 185 float custom_primary_matrix_[9] = {0, 0, 0, 0, 0, 0, 0, 0}; |
| 175 | 186 |
| 176 // Only used if transfer_ is TransferID::CUSTOM. This array consists of the A | 187 // Only used if transfer_ is TransferID::CUSTOM. This array consists of the A |
| 177 // through G entries of the SkColorSpaceTransferFn structure in alphabetical | 188 // through G entries of the SkColorSpaceTransferFn structure in alphabetical |
| 178 // order. | 189 // order. |
| 179 float custom_transfer_params_[7] = {0, 0, 0, 0, 0, 0, 0}; | 190 float custom_transfer_params_[7] = {0, 0, 0, 0, 0, 0, 0}; |
| 180 | 191 |
| 181 // 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 |
| 182 // created, if possible. | 193 // created, if possible. |
| 183 uint64_t icc_profile_id_ = 0; | 194 uint64_t icc_profile_id_ = 0; |
| 184 sk_sp<SkColorSpace> icc_profile_sk_color_space_; | 195 sk_sp<SkColorSpace> icc_profile_sk_color_space_; |
| 185 | 196 |
| 186 friend class ICCProfile; | 197 friend class ICCProfile; |
| 187 friend class ColorTransform; | 198 friend class ColorTransform; |
| 188 friend class ColorTransformInternal; | 199 friend class ColorTransformInternal; |
| 189 friend class ColorSpaceWin; | 200 friend class ColorSpaceWin; |
| 190 friend struct IPC::ParamTraits<gfx::ColorSpace>; | 201 friend struct IPC::ParamTraits<gfx::ColorSpace>; |
| 191 FRIEND_TEST_ALL_PREFIXES(SimpleColorSpace, GetColorSpace); | 202 FRIEND_TEST_ALL_PREFIXES(SimpleColorSpace, GetColorSpace); |
| 192 }; | 203 }; |
| 193 | 204 |
| 194 } // namespace gfx | 205 } // namespace gfx |
| 195 | 206 |
| 196 #endif // UI_GFX_COLOR_SPACE_H_ | 207 #endif // UI_GFX_COLOR_SPACE_H_ |
| OLD | NEW |