| 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 #include "ui/gfx/color_space.h" | 5 #include "ui/gfx/color_space.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 | 8 |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/synchronization/lock.h" | 10 #include "base/synchronization/lock.h" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 ColorSpace::~ColorSpace() = default; | 79 ColorSpace::~ColorSpace() = default; |
| 80 | 80 |
| 81 // static | 81 // static |
| 82 ColorSpace ColorSpace::CreateSRGB() { | 82 ColorSpace ColorSpace::CreateSRGB() { |
| 83 ColorSpace result(PrimaryID::BT709, TransferID::IEC61966_2_1, MatrixID::RGB, | 83 ColorSpace result(PrimaryID::BT709, TransferID::IEC61966_2_1, MatrixID::RGB, |
| 84 RangeID::FULL); | 84 RangeID::FULL); |
| 85 result.sk_color_space_ = SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named); | 85 result.sk_color_space_ = SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named); |
| 86 return result; | 86 return result; |
| 87 } | 87 } |
| 88 | 88 |
| 89 // static |
| 90 ColorSpace ColorSpace::CreateSCRGBLinear() { |
| 91 return ColorSpace(PrimaryID::BT709, TransferID::LINEAR, MatrixID::RGB, |
| 92 RangeID::FULL); |
| 93 } |
| 94 |
| 89 // Static | 95 // Static |
| 90 ColorSpace ColorSpace::CreateXYZD50() { | 96 ColorSpace ColorSpace::CreateXYZD50() { |
| 91 return ColorSpace(PrimaryID::XYZ_D50, TransferID::LINEAR, MatrixID::RGB, | 97 return ColorSpace(PrimaryID::XYZ_D50, TransferID::LINEAR, MatrixID::RGB, |
| 92 RangeID::FULL); | 98 RangeID::FULL); |
| 93 } | 99 } |
| 94 | 100 |
| 95 // static | 101 // static |
| 96 ColorSpace ColorSpace::CreateJpeg() { | 102 ColorSpace ColorSpace::CreateJpeg() { |
| 97 return ColorSpace(PrimaryID::BT709, TransferID::IEC61966_2_1, MatrixID::BT709, | 103 return ColorSpace(PrimaryID::BT709, TransferID::IEC61966_2_1, MatrixID::BT709, |
| 98 RangeID::FULL); | 104 RangeID::FULL); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 114 if (primaries_ != other.primaries_ || transfer_ != other.transfer_ || | 120 if (primaries_ != other.primaries_ || transfer_ != other.transfer_ || |
| 115 matrix_ != other.matrix_ || range_ != other.range_) | 121 matrix_ != other.matrix_ || range_ != other.range_) |
| 116 return false; | 122 return false; |
| 117 if (primaries_ == PrimaryID::CUSTOM && | 123 if (primaries_ == PrimaryID::CUSTOM && |
| 118 memcmp(custom_primary_matrix_, other.custom_primary_matrix_, | 124 memcmp(custom_primary_matrix_, other.custom_primary_matrix_, |
| 119 sizeof(custom_primary_matrix_))) | 125 sizeof(custom_primary_matrix_))) |
| 120 return false; | 126 return false; |
| 121 return true; | 127 return true; |
| 122 } | 128 } |
| 123 | 129 |
| 130 bool ColorSpace::IsHDR() const { |
| 131 return transfer_ == TransferID::SMPTEST2084 || |
| 132 transfer_ == TransferID::ARIB_STD_B67; |
| 133 } |
| 134 |
| 124 bool ColorSpace::operator!=(const ColorSpace& other) const { | 135 bool ColorSpace::operator!=(const ColorSpace& other) const { |
| 125 return !(*this == other); | 136 return !(*this == other); |
| 126 } | 137 } |
| 127 | 138 |
| 128 bool ColorSpace::operator<(const ColorSpace& other) const { | 139 bool ColorSpace::operator<(const ColorSpace& other) const { |
| 129 if (primaries_ < other.primaries_) | 140 if (primaries_ < other.primaries_) |
| 130 return true; | 141 return true; |
| 131 if (primaries_ > other.primaries_) | 142 if (primaries_ > other.primaries_) |
| 132 return false; | 143 return false; |
| 133 if (transfer_ < other.transfer_) | 144 if (transfer_ < other.transfer_) |
| (...skipping 29 matching lines...) Expand all Loading... |
| 163 SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named).get())) | 174 SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named).get())) |
| 164 return gfx::ColorSpace::CreateSRGB(); | 175 return gfx::ColorSpace::CreateSRGB(); |
| 165 | 176 |
| 166 // TODO(crbug.com/634102): Add conversion to gfx::ColorSpace for | 177 // TODO(crbug.com/634102): Add conversion to gfx::ColorSpace for |
| 167 // non-ICC-profile based color spaces. | 178 // non-ICC-profile based color spaces. |
| 168 ICCProfile icc_profile = ICCProfile::FromSkColorSpace(sk_color_space); | 179 ICCProfile icc_profile = ICCProfile::FromSkColorSpace(sk_color_space); |
| 169 return icc_profile.GetColorSpace(); | 180 return icc_profile.GetColorSpace(); |
| 170 } | 181 } |
| 171 | 182 |
| 172 } // namespace gfx | 183 } // namespace gfx |
| OLD | NEW |