aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/ICCTest.cpp
diff options
context:
space:
mode:
authorGravatar Brian Osman <brianosman@google.com>2017-12-19 14:44:12 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-12-20 14:09:34 +0000
commita12f795f4ab4b97d31acfd8bfbbbb6e06a70e999 (patch)
treef3c132ed909a214ac67e3352f1f2d965d1a10dc9 /tests/ICCTest.cpp
parentb5086961f335d6757a88ce7507c445485aaba2e6 (diff)
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 <brianosman@google.com> Reviewed-by: Mike Klein <mtklein@google.com> Reviewed-by: Mike Klein <mtklein@chromium.org> Commit-Queue: Brian Osman <brianosman@google.com>
Diffstat (limited to 'tests/ICCTest.cpp')
-rw-r--r--tests/ICCTest.cpp12
1 files changed, 11 insertions, 1 deletions
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<SkData> data = GetResourceAsData("icc_profiles/AdobeRGB1998.icc");
+ sk_sp<SkColorSpace> fromIcc = SkColorSpace::MakeICC(data->data(), data->size());
+ sk_sp<SkColorSpace> 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<SkData> 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;