Chromium Code Reviews| Index: ui/gfx/color_transform.cc |
| diff --git a/ui/gfx/color_transform.cc b/ui/gfx/color_transform.cc |
| index e88f3a56b92cedc78ef39b696e39653d75a24f23..361a8ba4bb07727a193b9f0aed2ebe7101942ac0 100644 |
| --- a/ui/gfx/color_transform.cc |
| +++ b/ui/gfx/color_transform.cc |
| @@ -277,6 +277,11 @@ class ColorTransformInternal : public ColorTransform { |
| ColorTransform::Intent intent); |
| void Simplify(); |
| + // Retrieve the ICC profile from which |color_space| was created, only if that |
| + // is a more precise representation of the color space than the primaries and |
| + // transfer function in |color_space|. |
| + ScopedQcmsProfile GetQCMSProfileIfNecessary(const ColorSpace& color_space); |
| + |
| std::list<std::unique_ptr<ColorTransformStep>> steps_; |
| }; |
| @@ -540,6 +545,10 @@ void ColorTransformInternal::AppendColorSpaceToColorSpaceTransform( |
| ColorSpace from, |
| const ColorSpace& to, |
| ColorTransform::Intent intent) { |
| + // If the source was not specified, assume that it was sRGB. |
| + if (!from.IsValid()) |
|
hubbe
2017/02/16 08:33:02
Can we just remove this?
ccameron
2017/02/16 22:33:10
Oops, yes, that was dead code.
|
| + from = gfx::ColorSpace::CreateSRGB(); |
| + |
| if (intent == ColorTransform::Intent::INTENT_PERCEPTUAL) { |
| switch (from.transfer_) { |
| case ColorSpace::TransferID::BT709: |
| @@ -653,9 +662,10 @@ class QCMSColorTransform : public ColorTransformStep { |
| ScopedQcmsProfile to_; |
| }; |
| -ScopedQcmsProfile GetQCMSProfileIfAvailable(const ColorSpace& color_space) { |
| - ICCProfile icc_profile = ICCProfile::FromColorSpace(color_space); |
| - if (icc_profile.GetData().empty()) |
| +ScopedQcmsProfile ColorTransformInternal::GetQCMSProfileIfNecessary( |
| + const ColorSpace& color_space) { |
| + ICCProfile icc_profile; |
| + if (!ICCProfile::FromId(color_space.icc_profile_id_, true, &icc_profile)) |
| return nullptr; |
| return ScopedQcmsProfile(qcms_profile_from_memory( |
| icc_profile.GetData().data(), icc_profile.GetData().size())); |
| @@ -690,8 +700,8 @@ ColorTransformInternal::ColorTransformInternal(const ColorSpace& from, |
| if (!from.IsValid()) |
| return; |
| - ScopedQcmsProfile from_profile = GetQCMSProfileIfAvailable(from); |
| - ScopedQcmsProfile to_profile = GetQCMSProfileIfAvailable(to); |
| + ScopedQcmsProfile from_profile = GetQCMSProfileIfNecessary(from); |
| + ScopedQcmsProfile to_profile = GetQCMSProfileIfNecessary(to); |
| bool has_from_profile = !!from_profile; |
| bool has_to_profile = !!to_profile; |