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

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

Issue 2742613002: color: Always use parametric color spaces for raster (Closed)
Patch Set: Incorporate review feedback Created 3 years, 9 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/icc_profile.cc ('k') | ui/gfx/skia_color_space_util.h » ('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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 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 "base/logging.h" 5 #include "base/logging.h"
6 #include "testing/gtest/include/gtest/gtest.h" 6 #include "testing/gtest/include/gtest/gtest.h"
7 #include "ui/gfx/color_space.h" 7 #include "ui/gfx/color_space.h"
8 #include "ui/gfx/icc_profile.h" 8 #include "ui/gfx/icc_profile.h"
9 #include "ui/gfx/test/icc_profiles.h" 9 #include "ui/gfx/test/icc_profiles.h"
10 10
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 EXPECT_FALSE(spin_profile == temp); 57 EXPECT_FALSE(spin_profile == temp);
58 EXPECT_TRUE(spin_profile != temp); 58 EXPECT_TRUE(spin_profile != temp);
59 59
60 EXPECT_TRUE(!!spin_space.ToSkColorSpace()); 60 EXPECT_TRUE(!!spin_space.ToSkColorSpace());
61 EXPECT_TRUE(!!adobe_space.ToSkColorSpace()); 61 EXPECT_TRUE(!!adobe_space.ToSkColorSpace());
62 EXPECT_FALSE(SkColorSpace::Equals( 62 EXPECT_FALSE(SkColorSpace::Equals(
63 spin_space.ToSkColorSpace().get(), 63 spin_space.ToSkColorSpace().get(),
64 adobe_space.ToSkColorSpace().get())); 64 adobe_space.ToSkColorSpace().get()));
65 } 65 }
66 66
67 TEST(ICCProfile, ParametricVersusExact) {
68 // This ICC profile has three transfer functions that differ enough that the
69 // parametric color space is considered inaccurate.
70 ICCProfile inaccurate = ICCProfileForTestingNoAnalyticTrFn();
71 EXPECT_NE(inaccurate.GetColorSpace(), inaccurate.GetParametricColorSpace());
72
73 ICCProfile inaccurate_color_space;
74 EXPECT_TRUE(
75 inaccurate.GetColorSpace().GetICCProfile(&inaccurate_color_space));
76 EXPECT_EQ(inaccurate_color_space, inaccurate);
77
78 ICCProfile inaccurate_parametric_color_space;
79 EXPECT_TRUE(inaccurate.GetParametricColorSpace().GetICCProfile(
80 &inaccurate_parametric_color_space));
81 EXPECT_NE(inaccurate_parametric_color_space, inaccurate);
82
83 // This ICC profile is precisely represented by the parametric color space.
84 ICCProfile accurate = ICCProfileForTestingAdobeRGB();
85 EXPECT_EQ(accurate.GetColorSpace(), accurate.GetParametricColorSpace());
86
87 ICCProfile accurate_color_space;
88 EXPECT_TRUE(accurate.GetColorSpace().GetICCProfile(&accurate_color_space));
89 EXPECT_EQ(accurate_color_space, accurate);
90
91 ICCProfile accurate_parametric_color_space;
92 EXPECT_TRUE(accurate.GetParametricColorSpace().GetICCProfile(
93 &accurate_parametric_color_space));
94 EXPECT_EQ(accurate_parametric_color_space, accurate);
95
96 // This ICC profile has only an A2B representation. For now, this means that
97 // the parametric representation will be sRGB. We will eventually want to get
98 // some sense of the gamut.
99 ICCProfile a2b = ICCProfileForTestingA2BOnly();
100 EXPECT_TRUE(a2b.GetColorSpace().IsValid());
101 EXPECT_NE(a2b.GetColorSpace(), a2b.GetParametricColorSpace());
102 EXPECT_EQ(ColorSpace::CreateSRGB(), a2b.GetParametricColorSpace());
103 }
104
105 TEST(ICCProfile, GarbageData) {
106 std::vector<char> bad_data(10 * 1024);
107 const char* bad_data_string = "deadbeef";
108 for (size_t i = 0; i < bad_data.size(); ++i)
109 bad_data[i] = bad_data_string[i % 8];
110 ICCProfile garbage_profile =
111 ICCProfile::FromData(bad_data.data(), bad_data.size());
112 EXPECT_FALSE(garbage_profile.IsValid());
113 EXPECT_FALSE(garbage_profile.GetColorSpace().IsValid());
114 EXPECT_FALSE(garbage_profile.GetParametricColorSpace().IsValid());
115
116 ICCProfile default_ctor_profile;
117 EXPECT_FALSE(default_ctor_profile.IsValid());
118 EXPECT_FALSE(default_ctor_profile.GetColorSpace().IsValid());
119 EXPECT_FALSE(default_ctor_profile.GetParametricColorSpace().IsValid());
120 }
121
67 } // namespace gfx 122 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/icc_profile.cc ('k') | ui/gfx/skia_color_space_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698