Chromium Code Reviews| Index: ui/gfx/color_transform.cc |
| diff --git a/ui/gfx/color_transform.cc b/ui/gfx/color_transform.cc |
| index 49a3026c895e13c33926b613c6724dc4e45d723c..cb751436ad4d82b657d0ef13ce752d3ab82943c3 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 01:28:29
It would be really cool if we could just do DCHECK
ccameron
2017/02/16 01:58:47
Maybe one day :D
I rebased this patch on top of t
|
| + from = gfx::ColorSpace::CreateSRGB(); |
| + |
| if (intent == ColorTransform::Intent::INTENT_PERCEPTUAL) { |
| switch (from.transfer_) { |
| case ColorSpace::TransferID::UNSPECIFIED: |
| @@ -654,9 +663,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())); |
| @@ -686,8 +696,8 @@ ScopedQcmsProfile GetXYZD50Profile() { |
| ColorTransformInternal::ColorTransformInternal(const ColorSpace& from, |
| const ColorSpace& to, |
| Intent intent) { |
| - 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; |