| 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 #include <sstream> | 8 #include <sstream> |
| 9 | 9 |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 transfer_ == TransferID::IEC61966_2_1_HDR; | 151 transfer_ == TransferID::IEC61966_2_1_HDR; |
| 152 } | 152 } |
| 153 | 153 |
| 154 bool ColorSpace::FullRangeEncodedValues() const { | 154 bool ColorSpace::FullRangeEncodedValues() const { |
| 155 return transfer_ == TransferID::LINEAR_HDR || | 155 return transfer_ == TransferID::LINEAR_HDR || |
| 156 transfer_ == TransferID::IEC61966_2_1_HDR || | 156 transfer_ == TransferID::IEC61966_2_1_HDR || |
| 157 transfer_ == TransferID::BT1361_ECG || | 157 transfer_ == TransferID::BT1361_ECG || |
| 158 transfer_ == TransferID::IEC61966_2_4; | 158 transfer_ == TransferID::IEC61966_2_4; |
| 159 } | 159 } |
| 160 | 160 |
| 161 bool ColorSpace::IsParametric() const { |
| 162 return primaries_ != PrimaryID::ICC_BASED && |
| 163 transfer_ != TransferID::ICC_BASED; |
| 164 } |
| 165 |
| 166 ColorSpace ColorSpace::GetParametricApproximation() const { |
| 167 // If this is parametric already, return it directly. |
| 168 if (IsParametric()) |
| 169 return *this; |
| 170 |
| 171 // Query the ICC profile, if available, for the parametric approximation. |
| 172 ICCProfile icc_profile; |
| 173 if (GetICCProfile(&icc_profile)) |
| 174 return icc_profile.GetParametricColorSpace(); |
| 175 |
| 176 // Fall back to sRGB if the ICC profile is no longer cached. |
| 177 return CreateSRGB(); |
| 178 } |
| 179 |
| 161 bool ColorSpace::operator!=(const ColorSpace& other) const { | 180 bool ColorSpace::operator!=(const ColorSpace& other) const { |
| 162 return !(*this == other); | 181 return !(*this == other); |
| 163 } | 182 } |
| 164 | 183 |
| 165 bool ColorSpace::operator<(const ColorSpace& other) const { | 184 bool ColorSpace::operator<(const ColorSpace& other) const { |
| 166 if (primaries_ < other.primaries_) | 185 if (primaries_ < other.primaries_) |
| 167 return true; | 186 return true; |
| 168 if (primaries_ > other.primaries_) | 187 if (primaries_ > other.primaries_) |
| 169 return false; | 188 return false; |
| 170 if (transfer_ < other.transfer_) | 189 if (transfer_ < other.transfer_) |
| (...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 758 matrix->postTranslate(-16.0f/219.0f, -15.5f/224.0f, -15.5f/224.0f); | 777 matrix->postTranslate(-16.0f/219.0f, -15.5f/224.0f, -15.5f/224.0f); |
| 759 break; | 778 break; |
| 760 } | 779 } |
| 761 } | 780 } |
| 762 | 781 |
| 763 std::ostream& operator<<(std::ostream& out, const ColorSpace& color_space) { | 782 std::ostream& operator<<(std::ostream& out, const ColorSpace& color_space) { |
| 764 return out << color_space.ToString(); | 783 return out << color_space.ToString(); |
| 765 } | 784 } |
| 766 | 785 |
| 767 } // namespace gfx | 786 } // namespace gfx |
| OLD | NEW |