OLD | NEW |
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2016 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_transform.h" | 5 #include "ui/gfx/color_transform.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <list> | 9 #include <list> |
10 #include <memory> | 10 #include <memory> |
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
611 // TODO(hubbe): shrink gamuts here (never stretch gamuts) | 611 // TODO(hubbe): shrink gamuts here (never stretch gamuts) |
612 } | 612 } |
613 | 613 |
614 steps_.push_back( | 614 steps_.push_back( |
615 base::MakeUnique<ColorTransformMatrix>(GetRangeAdjustMatrix(from))); | 615 base::MakeUnique<ColorTransformMatrix>(GetRangeAdjustMatrix(from))); |
616 | 616 |
617 steps_.push_back( | 617 steps_.push_back( |
618 base::MakeUnique<ColorTransformMatrix>(Invert(GetTransferMatrix(from)))); | 618 base::MakeUnique<ColorTransformMatrix>(Invert(GetTransferMatrix(from)))); |
619 | 619 |
620 // If the target color space is not defined, just apply the adjust and | 620 // If the target color space is not defined, just apply the adjust and |
621 // tranfer matrices. | 621 // tranfer matrices. This path is used by YUV to RGB color conversion |
| 622 // when full color conversion is not enabled. |
622 if (!to.IsValid()) | 623 if (!to.IsValid()) |
623 return; | 624 return; |
624 | 625 |
625 SkColorSpaceTransferFn to_linear_fn; | 626 SkColorSpaceTransferFn to_linear_fn; |
626 bool to_linear_fn_valid = from.GetTransferFunction(&to_linear_fn); | 627 bool to_linear_fn_valid = from.GetTransferFunction(&to_linear_fn); |
627 steps_.push_back(base::MakeUnique<ColorTransformToLinear>( | 628 steps_.push_back(base::MakeUnique<ColorTransformToLinear>( |
628 from.transfer_, to_linear_fn, to_linear_fn_valid)); | 629 from.transfer_, to_linear_fn, to_linear_fn_valid)); |
629 | 630 |
630 if (from.matrix_ == ColorSpace::MatrixID::BT2020_CL) { | 631 if (from.matrix_ == ColorSpace::MatrixID::BT2020_CL) { |
631 // BT2020 CL is a special case. | 632 // BT2020 CL is a special case. |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
725 | 726 |
726 ColorTransformInternal::ColorTransformInternal(const ColorSpace& src, | 727 ColorTransformInternal::ColorTransformInternal(const ColorSpace& src, |
727 const ColorSpace& dst, | 728 const ColorSpace& dst, |
728 Intent intent) | 729 Intent intent) |
729 : src_(src), dst_(dst) { | 730 : src_(src), dst_(dst) { |
730 // If no source color space is specified, do no transformation. | 731 // If no source color space is specified, do no transformation. |
731 // TODO(ccameron): We may want dst assume sRGB at some point in the future. | 732 // TODO(ccameron): We may want dst assume sRGB at some point in the future. |
732 if (!src_.IsValid()) | 733 if (!src_.IsValid()) |
733 return; | 734 return; |
734 | 735 |
735 ScopedQcmsProfile src_profile = GetQCMSProfileIfNecessary(src_); | 736 // If the target color space is not defined, just apply the adjust and |
736 ScopedQcmsProfile dst_profile = GetQCMSProfileIfNecessary(dst_); | 737 // tranfer matrices. This path is used by YUV to RGB color conversion |
| 738 // when full color conversion is not enabled. |
| 739 ScopedQcmsProfile src_profile; |
| 740 ScopedQcmsProfile dst_profile; |
| 741 if (dst.IsValid()) { |
| 742 src_profile = GetQCMSProfileIfNecessary(src_); |
| 743 dst_profile = GetQCMSProfileIfNecessary(dst_); |
| 744 } |
737 bool has_src_profile = !!src_profile; | 745 bool has_src_profile = !!src_profile; |
738 bool has_dst_profile = !!dst_profile; | 746 bool has_dst_profile = !!dst_profile; |
739 | 747 |
740 if (src_profile) { | 748 if (src_profile) { |
741 steps_.push_back(base::MakeUnique<QCMSColorTransform>( | 749 steps_.push_back(base::MakeUnique<QCMSColorTransform>( |
742 std::move(src_profile), GetXYZD50Profile())); | 750 std::move(src_profile), GetXYZD50Profile())); |
743 } | 751 } |
744 | 752 |
745 AppendColorSpaceToColorSpaceTransform( | 753 AppendColorSpaceToColorSpaceTransform( |
746 has_src_profile ? ColorSpace::CreateXYZD50() : src_, | 754 has_src_profile ? ColorSpace::CreateXYZD50() : src_, |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
812 const ColorSpace& to, | 820 const ColorSpace& to, |
813 Intent intent) { | 821 Intent intent) { |
814 return std::unique_ptr<ColorTransform>( | 822 return std::unique_ptr<ColorTransform>( |
815 new ColorTransformInternal(from, to, intent)); | 823 new ColorTransformInternal(from, to, intent)); |
816 } | 824 } |
817 | 825 |
818 ColorTransform::ColorTransform() {} | 826 ColorTransform::ColorTransform() {} |
819 ColorTransform::~ColorTransform() {} | 827 ColorTransform::~ColorTransform() {} |
820 | 828 |
821 } // namespace gfx | 829 } // namespace gfx |
OLD | NEW |