Chromium Code Reviews| 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/macros.h" | 10 #include "base/macros.h" |
| 11 #include "build/build_config.h" | 11 #include "build/build_config.h" |
| 12 #include "ui/gfx/gfx_export.h" | 12 #include "ui/gfx/gfx_export.h" |
| 13 | 13 |
| 14 namespace IPC { | 14 namespace IPC { |
| 15 template <class P> | 15 template <class P> |
| 16 struct ParamTraits; | 16 struct ParamTraits; |
| 17 } // namespace IPC | 17 } // namespace IPC |
| 18 | 18 |
| 19 namespace gfx { | 19 namespace gfx { |
| 20 | 20 |
| 21 class ICCProfile; | 21 class ICCProfile; |
| 22 | 22 |
| 23 // Used to represet a color space for the purpose of color conversion. | 23 // Used to represet a color space for the purpose of color conversion. |
| 24 // This is designed to be safe and compact enough to send over IPC | 24 // This is designed to be safe and compact enough to send over IPC |
| 25 // between any processes. | 25 // between any processes. |
| 26 class GFX_EXPORT ColorSpace { | 26 class GFX_EXPORT ColorSpace { |
| 27 public: | 27 public: |
| 28 enum PrimaryID : int16_t { | |
|
ccameron
2016/07/27 17:10:30
nit: Please change this to
enum class Primary {
hubbe
2016/07/27 17:44:04
Done.
Although I'm still calling it PrimaryID, as
| |
| 29 // The first 0-255 values should match the H264 specification. | |
| 30 PRI_RESERVED0 = 0, | |
| 31 PRI_BT709 = 1, | |
| 32 PRI_UNSPECIFIED = 2, | |
| 33 PRI_RESERVED = 3, | |
| 34 PRI_BT470M = 4, | |
| 35 PRI_BT470BG = 5, | |
| 36 PRI_SMPTE170M = 6, | |
| 37 PRI_SMPTE240M = 7, | |
| 38 PRI_FILM = 8, | |
| 39 PRI_BT2020 = 9, | |
| 40 PRI_SMPTEST428_1 = 10, | |
| 41 PRI_SMPTEST431_2 = 11, | |
| 42 PRI_SMPTEST432_1 = 12, | |
| 43 | |
| 44 // Chrome-specific values start at 1000. | |
| 45 PRI_XYZ_D50 = 1000, | |
| 46 // TODO(hubbe): We need to store the primaries. | |
| 47 PRI_CUSTOM = 1001, | |
| 48 PRI_LAST = PRI_XYZ_D50 | |
| 49 }; | |
| 50 | |
| 51 enum TransferID : uint16_t { | |
|
ccameron
2016/07/27 17:10:30
(same thing, "enum class TransferFunction", and no
hubbe
2016/07/27 17:44:04
Done, but still calling it TransferID
| |
| 52 // The first 0-255 values should match the H264 specification. | |
| 53 TRC_RESERVED0 = 0, | |
| 54 TRC_BT709 = 1, | |
| 55 TRC_UNSPECIFIED = 2, | |
| 56 TRC_RESERVED = 3, | |
| 57 TRC_GAMMA22 = 4, | |
| 58 TRC_GAMMA28 = 5, | |
| 59 TRC_SMPTE170M = 6, | |
| 60 TRC_SMPTE240M = 7, | |
| 61 TRC_LINEAR = 8, | |
| 62 TRC_LOG = 9, | |
| 63 TRC_LOG_SQRT = 10, | |
| 64 TRC_IEC61966_2_4 = 11, | |
| 65 TRC_BT1361_ECG = 12, | |
| 66 TRC_IEC61966_2_1 = 13, | |
| 67 TRC_BT2020_10 = 14, | |
| 68 TRC_BT2020_12 = 15, | |
| 69 TRC_SMPTEST2084 = 16, | |
| 70 TRC_SMPTEST428_1 = 17, | |
| 71 | |
| 72 // Chrome-specific values start at 1000. | |
| 73 TRC_GAMMA24 = 1000, | |
| 74 | |
| 75 // TODO(hubbe): Need to store an approximation of the gamma function(s). | |
| 76 TRC_CUSTOM = 1001, | |
| 77 TRC_LAST = TRC_GAMMA24, | |
| 78 }; | |
| 79 | |
| 80 enum MatrixID : int16_t { | |
| 81 // The first 0-255 values should match the H264 specification. | |
|
ccameron
2016/07/27 17:10:29
(& again)
hubbe
2016/07/27 17:44:04
Done.
| |
| 82 SPC_RGB = 0, | |
| 83 SPC_BT709 = 1, | |
| 84 SPC_UNSPECIFIED = 2, | |
| 85 SPC_RESERVED = 3, | |
| 86 SPC_FCC = 4, | |
| 87 SPC_BT470BG = 5, | |
| 88 SPC_SMPTE170M = 6, | |
| 89 SPC_SMPTE240M = 7, | |
| 90 SPC_YCOCG = 8, | |
| 91 SPC_BT2020_NCL = 9, | |
| 92 SPC_BT2020_CL = 10, | |
| 93 SPC_YDZDX = 11, | |
| 94 | |
| 95 // Chrome-specific values start at 1000 | |
| 96 SPC_LAST = SPC_BT2020_CL | |
| 97 }; | |
| 98 | |
| 28 ColorSpace(); | 99 ColorSpace(); |
| 100 ColorSpace(PrimaryID primaries, | |
| 101 TransferID transfer, | |
| 102 MatrixID matrix, | |
| 103 bool full_range); | |
| 104 | |
| 105 bool isValid() const; | |
|
ccameron
2016/07/27 17:10:30
Remove isValid cause it has no callers now (with t
hubbe
2016/07/27 17:44:04
Done.
| |
| 106 | |
| 29 static ColorSpace CreateSRGB(); | 107 static ColorSpace CreateSRGB(); |
| 30 | 108 |
| 31 // TODO: Remove these, and replace with more generic constructors. | 109 // TODO: Remove these, and replace with more generic constructors. |
| 32 static ColorSpace CreateJpeg(); | 110 static ColorSpace CreateJpeg(); |
| 33 static ColorSpace CreateREC601(); | 111 static ColorSpace CreateREC601(); |
| 34 static ColorSpace CreateREC709(); | 112 static ColorSpace CreateREC709(); |
| 35 | 113 |
| 36 bool operator==(const ColorSpace& other) const; | 114 bool operator==(const ColorSpace& other) const; |
| 37 | 115 |
| 38 private: | 116 private: |
| 39 bool valid_ = false; | 117 PrimaryID primaries_; |
| 118 TransferID transfer_; | |
| 119 MatrixID matrix_; | |
| 120 | |
| 121 // TODO(hubbe): Range might be different depending on bit depth, if so, | |
|
ccameron
2016/07/27 17:10:30
I'd go for putting this in an enum from the get-go
hubbe
2016/07/27 17:44:04
Done.
| |
| 122 // convert this to an enum. | |
| 123 bool full_range_; | |
| 124 | |
| 40 // This is used to look up the ICCProfile from which this ColorSpace was | 125 // This is used to look up the ICCProfile from which this ColorSpace was |
| 41 // created, if possible. | 126 // created, if possible. |
| 42 uint64_t icc_profile_id_ = 0; | 127 uint64_t icc_profile_id_ = 0; |
| 43 | 128 |
| 44 friend class ICCProfile; | 129 friend class ICCProfile; |
| 45 friend struct IPC::ParamTraits<gfx::ColorSpace>; | 130 friend struct IPC::ParamTraits<gfx::ColorSpace>; |
| 46 }; | 131 }; |
| 47 | 132 |
| 48 } // namespace gfx | 133 } // namespace gfx |
| 49 | 134 |
| 50 #endif // UI_GFX_COLOR_SPACE_H_ | 135 #endif // UI_GFX_COLOR_SPACE_H_ |
| OLD | NEW |