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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/icc_profile_unittest.cc
diff --git a/ui/gfx/icc_profile_unittest.cc b/ui/gfx/icc_profile_unittest.cc
index c4e3db8026b9ca8bfa0faf54bb0392589784562a..35d8edcffac2ae072a35b50fb008d811f967867f 100644
--- a/ui/gfx/icc_profile_unittest.cc
+++ b/ui/gfx/icc_profile_unittest.cc
@@ -64,4 +64,59 @@ TEST(ICCProfile, Equality) {
adobe_space.ToSkColorSpace().get()));
}
+TEST(ICCProfile, ParametricVersusExact) {
+ // This ICC profile has three transfer functions that differ enough that the
+ // parametric color space is considered inaccurate.
+ ICCProfile inaccurate = ICCProfileForTestingNoAnalyticTrFn();
+ EXPECT_NE(inaccurate.GetColorSpace(), inaccurate.GetParametricColorSpace());
+
+ ICCProfile inaccurate_color_space;
+ EXPECT_TRUE(
+ inaccurate.GetColorSpace().GetICCProfile(&inaccurate_color_space));
+ EXPECT_EQ(inaccurate_color_space, inaccurate);
+
+ ICCProfile inaccurate_parametric_color_space;
+ EXPECT_TRUE(inaccurate.GetParametricColorSpace().GetICCProfile(
+ &inaccurate_parametric_color_space));
+ EXPECT_NE(inaccurate_parametric_color_space, inaccurate);
+
+ // This ICC profile is precisely represented by the parametric color space.
+ ICCProfile accurate = ICCProfileForTestingAdobeRGB();
+ EXPECT_EQ(accurate.GetColorSpace(), accurate.GetParametricColorSpace());
+
+ ICCProfile accurate_color_space;
+ EXPECT_TRUE(accurate.GetColorSpace().GetICCProfile(&accurate_color_space));
+ EXPECT_EQ(accurate_color_space, accurate);
+
+ ICCProfile accurate_parametric_color_space;
+ EXPECT_TRUE(accurate.GetParametricColorSpace().GetICCProfile(
+ &accurate_parametric_color_space));
+ EXPECT_EQ(accurate_parametric_color_space, accurate);
+
+ // This ICC profile has only an A2B representation. For now, this means that
+ // the parametric representation will be sRGB. We will eventually want to get
+ // some sense of the gamut.
+ ICCProfile a2b = ICCProfileForTestingA2BOnly();
+ EXPECT_TRUE(a2b.GetColorSpace().IsValid());
+ EXPECT_NE(a2b.GetColorSpace(), a2b.GetParametricColorSpace());
+ EXPECT_EQ(ColorSpace::CreateSRGB(), a2b.GetParametricColorSpace());
+}
+
+TEST(ICCProfile, GarbageData) {
+ std::vector<char> bad_data(10 * 1024);
+ const char* bad_data_string = "deadbeef";
+ for (size_t i = 0; i < bad_data.size(); ++i)
+ bad_data[i] = bad_data_string[i % 8];
+ ICCProfile garbage_profile =
+ ICCProfile::FromData(bad_data.data(), bad_data.size());
+ EXPECT_FALSE(garbage_profile.IsValid());
+ EXPECT_FALSE(garbage_profile.GetColorSpace().IsValid());
+ EXPECT_FALSE(garbage_profile.GetParametricColorSpace().IsValid());
+
+ ICCProfile default_ctor_profile;
+ EXPECT_FALSE(default_ctor_profile.IsValid());
+ EXPECT_FALSE(default_ctor_profile.GetColorSpace().IsValid());
+ EXPECT_FALSE(default_ctor_profile.GetParametricColorSpace().IsValid());
+}
+
} // namespace gfx
« 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