From a12f795f4ab4b97d31acfd8bfbbbb6e06a70e999 Mon Sep 17 00:00:00 2001 From: Brian Osman Date: Tue, 19 Dec 2017 14:44:12 -0500 Subject: Fix Adobe RGB color space in Skia Our runtime definition of the XYZ matrix was fairly inaccurate. It also didn't round-trip through ICC fixed point correctly. Now, constructing the color space at runtime produces exactly the same matrix as constructing the space from the ICC profile. And the values can then be serialized back to ICC exactly. This eliminates the need for the snapping logic, too. Bug: skia: Change-Id: I69f4a9bfec3eeef153935e21ab3a0630794b1607 Reviewed-on: https://skia-review.googlesource.com/84840 Reviewed-by: Brian Osman Reviewed-by: Mike Klein Reviewed-by: Mike Klein Commit-Queue: Brian Osman --- tests/ICCTest.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'tests/ICCTest.cpp') diff --git a/tests/ICCTest.cpp b/tests/ICCTest.cpp index cfe4dc04a0..378a430dc0 100644 --- a/tests/ICCTest.cpp +++ b/tests/ICCTest.cpp @@ -98,6 +98,16 @@ DEF_TEST(ICC_IsNumericalTransferFn, r) { test_is_numerical_transfer_fn(r, upperRight.get(), false, referenceFn); } +DEF_TEST(ICC_Adobe, r) { + // Test that the color spaces produced by our procedural Adobe factory, and the official + // Adobe ICC profile match exactly. + sk_sp data = GetResourceAsData("icc_profiles/AdobeRGB1998.icc"); + sk_sp fromIcc = SkColorSpace::MakeICC(data->data(), data->size()); + sk_sp procedural = SkColorSpace::MakeRGB(g2Dot2_TransferFn, + SkColorSpace::kAdobeRGB_Gamut); + REPORTER_ASSERT(r, SkColorSpace::Equals(fromIcc.get(), procedural.get())); +} + static inline void test_write_icc(skiatest::Reporter* r, const SkColorSpaceTransferFn& fn, const SkMatrix44& toXYZD50, bool writeToFile) { sk_sp profile = SkICC::WriteToICC(fn, toXYZD50); @@ -124,7 +134,7 @@ DEF_TEST(ICC_WriteICC, r) { adobeMatrix.set3x3RowMajorf(gAdobeRGB_toXYZD50); // TODO: Restore this test once we fix our Adobe matrix to be based on the decoded ICC // fixed point values, and once we use a rounding conversion to fixed-point. -// test_write_icc(r, adobeFn, adobeMatrix, false); + test_write_icc(r, adobeFn, adobeMatrix, false); SkColorSpaceTransferFn srgbFn; srgbFn.fA = 1.0f / 1.055f; -- cgit v1.2.3