| 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 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 535 private: | 535 private: |
| 536 bool null_ = false; | 536 bool null_ = false; |
| 537 }; | 537 }; |
| 538 | 538 |
| 539 void ColorTransformInternal::AppendColorSpaceToColorSpaceTransform( | 539 void ColorTransformInternal::AppendColorSpaceToColorSpaceTransform( |
| 540 ColorSpace from, | 540 ColorSpace from, |
| 541 const ColorSpace& to, | 541 const ColorSpace& to, |
| 542 ColorTransform::Intent intent) { | 542 ColorTransform::Intent intent) { |
| 543 if (intent == ColorTransform::Intent::INTENT_PERCEPTUAL) { | 543 if (intent == ColorTransform::Intent::INTENT_PERCEPTUAL) { |
| 544 switch (from.transfer_) { | 544 switch (from.transfer_) { |
| 545 case ColorSpace::TransferID::UNSPECIFIED: | |
| 546 case ColorSpace::TransferID::BT709: | 545 case ColorSpace::TransferID::BT709: |
| 547 case ColorSpace::TransferID::SMPTE170M: | 546 case ColorSpace::TransferID::SMPTE170M: |
| 548 // SMPTE 1886 suggests that we should be using gamma 2.4 for BT709 | 547 // SMPTE 1886 suggests that we should be using gamma 2.4 for BT709 |
| 549 // content. However, most displays actually use a gamma of 2.2, and | 548 // content. However, most displays actually use a gamma of 2.2, and |
| 550 // user studies shows that users don't really care. Using the same | 549 // user studies shows that users don't really care. Using the same |
| 551 // gamma as the display will let us optimize a lot more, so lets stick | 550 // gamma as the display will let us optimize a lot more, so lets stick |
| 552 // with using the SRGB transfer function. | 551 // with using the SRGB transfer function. |
| 553 from.transfer_ = ColorSpace::TransferID::IEC61966_2_1; | 552 from.transfer_ = ColorSpace::TransferID::IEC61966_2_1; |
| 554 break; | 553 break; |
| 555 | 554 |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 679 xyz.blue.Y = 1.0f; | 678 xyz.blue.Y = 1.0f; |
| 680 w.x = 0.34567f; | 679 w.x = 0.34567f; |
| 681 w.y = 0.35850f; | 680 w.y = 0.35850f; |
| 682 w.Y = 1.0f; | 681 w.Y = 1.0f; |
| 683 return ScopedQcmsProfile(qcms_profile_create_rgb_with_gamma(w, xyz, 1.0f)); | 682 return ScopedQcmsProfile(qcms_profile_create_rgb_with_gamma(w, xyz, 1.0f)); |
| 684 } | 683 } |
| 685 | 684 |
| 686 ColorTransformInternal::ColorTransformInternal(const ColorSpace& from, | 685 ColorTransformInternal::ColorTransformInternal(const ColorSpace& from, |
| 687 const ColorSpace& to, | 686 const ColorSpace& to, |
| 688 Intent intent) { | 687 Intent intent) { |
| 688 // If no source color space is specified, do no transformation. |
| 689 // TODO(ccameron): We may want to assume sRGB at some point in the future. |
| 690 if (!from.IsValid()) |
| 691 return; |
| 692 |
| 689 ScopedQcmsProfile from_profile = GetQCMSProfileIfAvailable(from); | 693 ScopedQcmsProfile from_profile = GetQCMSProfileIfAvailable(from); |
| 690 ScopedQcmsProfile to_profile = GetQCMSProfileIfAvailable(to); | 694 ScopedQcmsProfile to_profile = GetQCMSProfileIfAvailable(to); |
| 691 bool has_from_profile = !!from_profile; | 695 bool has_from_profile = !!from_profile; |
| 692 bool has_to_profile = !!to_profile; | 696 bool has_to_profile = !!to_profile; |
| 693 | 697 |
| 694 if (from_profile) { | 698 if (from_profile) { |
| 695 steps_.push_back(base::MakeUnique<QCMSColorTransform>( | 699 steps_.push_back(base::MakeUnique<QCMSColorTransform>( |
| 696 std::move(from_profile), GetXYZD50Profile())); | 700 std::move(from_profile), GetXYZD50Profile())); |
| 697 } | 701 } |
| 698 | 702 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 748 const ColorSpace& to, | 752 const ColorSpace& to, |
| 749 Intent intent) { | 753 Intent intent) { |
| 750 return std::unique_ptr<ColorTransform>( | 754 return std::unique_ptr<ColorTransform>( |
| 751 new ColorTransformInternal(from, to, intent)); | 755 new ColorTransformInternal(from, to, intent)); |
| 752 } | 756 } |
| 753 | 757 |
| 754 ColorTransform::ColorTransform() {} | 758 ColorTransform::ColorTransform() {} |
| 755 ColorTransform::~ColorTransform() {} | 759 ColorTransform::~ColorTransform() {} |
| 756 | 760 |
| 757 } // namespace gfx | 761 } // namespace gfx |
| OLD | NEW |