Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1178)

Side by Side Diff: ui/gfx/color_transform.cc

Issue 2652503002: Use SkICC in gfx::ICCProfile and gfx::ColorSpace (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/gfx/color_space.cc ('k') | ui/gfx/color_transform_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <vector> 7 #include <vector>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 SkMatrix44 matrix; 158 SkMatrix44 matrix;
159 primaries.toXYZD50(&matrix); 159 primaries.toXYZD50(&matrix);
160 return Transform(matrix); 160 return Transform(matrix);
161 } 161 }
162 162
163 GFX_EXPORT float FromLinear(ColorSpace::TransferID id, float v) { 163 GFX_EXPORT float FromLinear(ColorSpace::TransferID id, float v) {
164 switch (id) { 164 switch (id) {
165 case ColorSpace::TransferID::SMPTEST2084_NON_HDR: 165 case ColorSpace::TransferID::SMPTEST2084_NON_HDR:
166 // Should already be handled. 166 // Should already be handled.
167 NOTREACHED(); 167 NOTREACHED();
168 case ColorSpace::TransferID::CUSTOM: 168 case ColorSpace::TransferID::CUSTOM:
hubbe 2017/01/22 04:30:30 Maybe implement this? (And also in ToLinear?)
ccameron 2017/01/23 18:58:58 Good point. I started trying to put this in this
ccameron 2017/01/25 07:09:44 Went ahead and did this.
169 // TODO(hubbe): Actually implement custom transfer functions. 169 // TODO(hubbe): Actually implement custom transfer functions.
170 case ColorSpace::TransferID::RESERVED0: 170 case ColorSpace::TransferID::RESERVED0:
171 case ColorSpace::TransferID::RESERVED: 171 case ColorSpace::TransferID::RESERVED:
172 case ColorSpace::TransferID::UNSPECIFIED: 172 case ColorSpace::TransferID::UNSPECIFIED:
173 case ColorSpace::TransferID::UNKNOWN: 173 case ColorSpace::TransferID::UNKNOWN:
174 // All unknown values default to BT709 174 // All unknown values default to BT709
175 175
176 case ColorSpace::TransferID::BT709: 176 case ColorSpace::TransferID::BT709:
177 case ColorSpace::TransferID::SMPTE170M: 177 case ColorSpace::TransferID::SMPTE170M:
178 case ColorSpace::TransferID::BT2020_10: 178 case ColorSpace::TransferID::BT2020_10:
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after
852 852
853 private: 853 private:
854 bool disable_optimizations_ = false; 854 bool disable_optimizations_ = false;
855 std::vector<std::unique_ptr<ColorTransformInternal>> transforms_; 855 std::vector<std::unique_ptr<ColorTransformInternal>> transforms_;
856 }; 856 };
857 857
858 class ColorSpaceToColorSpaceTransform { 858 class ColorSpaceToColorSpaceTransform {
859 public: 859 public:
860 static Transform GetPrimaryTransform(const ColorSpace& c) { 860 static Transform GetPrimaryTransform(const ColorSpace& c) {
861 if (c.primaries_ == ColorSpace::PrimaryID::CUSTOM) { 861 if (c.primaries_ == ColorSpace::PrimaryID::CUSTOM) {
862 return Transform(c.custom_primary_matrix_[0], c.custom_primary_matrix_[1], 862 SkMatrix44 sk_matrix;
863 c.custom_primary_matrix_[2], c.custom_primary_matrix_[3], 863 c.GetPrimaryMatrix(&sk_matrix);
864 c.custom_primary_matrix_[4], c.custom_primary_matrix_[5], 864 return Transform(sk_matrix);
865 c.custom_primary_matrix_[6], c.custom_primary_matrix_[7],
866 c.custom_primary_matrix_[8], c.custom_primary_matrix_[9],
867 c.custom_primary_matrix_[10],
868 c.custom_primary_matrix_[11], 0.0f, 0.0f, 0.0f, 1.0f);
869 } else { 865 } else {
870 return GetPrimaryMatrix(c.primaries_); 866 return GetPrimaryMatrix(c.primaries_);
871 } 867 }
872 } 868 }
873 869
874 static void ColorSpaceToColorSpace(ColorSpace from, 870 static void ColorSpaceToColorSpace(ColorSpace from,
875 ColorSpace to, 871 ColorSpace to,
876 ColorTransform::Intent intent, 872 ColorTransform::Intent intent,
877 TransformBuilder* builder) { 873 TransformBuilder* builder) {
878 if (intent == ColorTransform::Intent::INTENT_PERCEPTUAL) { 874 if (intent == ColorTransform::Intent::INTENT_PERCEPTUAL) {
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
1022 to_profile ? ColorSpace::CreateXYZD50() : to, intent, &builder); 1018 to_profile ? ColorSpace::CreateXYZD50() : to, intent, &builder);
1023 if (to_profile) { 1019 if (to_profile) {
1024 builder.Append(std::unique_ptr<ColorTransformInternal>( 1020 builder.Append(std::unique_ptr<ColorTransformInternal>(
1025 new QCMSColorTransform(GetXYZD50Profile(), to_profile))); 1021 new QCMSColorTransform(GetXYZD50Profile(), to_profile)));
1026 } 1022 }
1027 1023
1028 return builder.GetTransform(); 1024 return builder.GetTransform();
1029 } 1025 }
1030 1026
1031 } // namespace gfx 1027 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/color_space.cc ('k') | ui/gfx/color_transform_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698