diff options
author | Mike Klein <mtklein@chromium.org> | 2018-05-23 12:43:42 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-05-23 17:11:11 +0000 |
commit | 8fcfcc5686604ede4f2a6d5da1af6459d39c36ad (patch) | |
tree | ad4ed53407eb4bd5aebeb2db4588443ef1cba2fd | |
parent | ee43091c1b8ebf2f62918688494b0eb82ceedb38 (diff) |
update ColorSpaceTest.cpp to remove MakeICC
The upperLeft and upperRight profiles are A2B/B2A-only, and so cannot be
represented as SkColorSpace using SkColorSpace::Make(skcms_ICCProfile).
They do parse fine, of course.
Change-Id: Iaf51911c2b06b985037d3d5e74b043fb344e320e
Reviewed-on: https://skia-review.googlesource.com/129653
Commit-Queue: Mike Klein <mtklein@chromium.org>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: Mike Klein <mtklein@chromium.org>
Reviewed-by: Brian Osman <brianosman@google.com>
-rw-r--r-- | resources/icc_profiles/SM2333SW.icc | bin | 2404 -> 0 bytes | |||
-rw-r--r-- | resources/icc_profiles/invalid_color_lut.icc | bin | 688 -> 0 bytes | |||
-rw-r--r-- | tests/ColorSpaceTest.cpp | 93 |
3 files changed, 44 insertions, 49 deletions
diff --git a/resources/icc_profiles/SM2333SW.icc b/resources/icc_profiles/SM2333SW.icc Binary files differdeleted file mode 100644 index cf6e91fb68..0000000000 --- a/resources/icc_profiles/SM2333SW.icc +++ /dev/null diff --git a/resources/icc_profiles/invalid_color_lut.icc b/resources/icc_profiles/invalid_color_lut.icc Binary files differdeleted file mode 100644 index 33384cd220..0000000000 --- a/resources/icc_profiles/invalid_color_lut.icc +++ /dev/null diff --git a/tests/ColorSpaceTest.cpp b/tests/ColorSpaceTest.cpp index d1eb75efe4..9324e8cf04 100644 --- a/tests/ColorSpaceTest.cpp +++ b/tests/ColorSpaceTest.cpp @@ -185,7 +185,7 @@ DEF_TEST(ColorSpaceSRGBLinearCompare, r) { REPORTER_ASSERT(r, strangeColorSpace != namedColorSpace); } -static void test_serialize(skiatest::Reporter* r, SkColorSpace* space, bool isNamed) { +static void test_serialize(skiatest::Reporter* r, sk_sp<SkColorSpace> space, bool isNamed) { sk_sp<SkData> data1 = space->serialize(); size_t bytes = space->writeToMemory(nullptr); @@ -196,26 +196,33 @@ static void test_serialize(skiatest::Reporter* r, SkColorSpace* space, bool isNa sk_sp<SkColorSpace> newSpace2 = SkColorSpace::Deserialize(data2->data(), data2->size()); if (isNamed) { - REPORTER_ASSERT(r, space == newSpace1.get()); - REPORTER_ASSERT(r, space == newSpace2.get()); + REPORTER_ASSERT(r, space.get() == newSpace1.get()); + REPORTER_ASSERT(r, space.get() == newSpace2.get()); } else { - REPORTER_ASSERT(r, SkColorSpace::Equals(space, newSpace1.get())); - REPORTER_ASSERT(r, SkColorSpace::Equals(space, newSpace2.get())); + REPORTER_ASSERT(r, SkColorSpace::Equals(space.get(), newSpace1.get())); + REPORTER_ASSERT(r, SkColorSpace::Equals(space.get(), newSpace2.get())); } } DEF_TEST(ColorSpace_Serialize, r) { - test_serialize(r, SkColorSpace::MakeSRGB().get(), true); - test_serialize(r, SkColorSpace::MakeSRGBLinear().get(), true); - - sk_sp<SkData> monitorData = GetResourceAsData("icc_profiles/HP_ZR30w.icc"); - test_serialize(r, SkColorSpace::MakeICC(monitorData->data(), monitorData->size()).get(), false); - monitorData = GetResourceAsData("icc_profiles/HP_Z32x.icc"); - test_serialize(r, SkColorSpace::MakeICC(monitorData->data(), monitorData->size()).get(), false); - monitorData = GetResourceAsData("icc_profiles/upperLeft.icc"); - test_serialize(r, SkColorSpace::MakeICC(monitorData->data(), monitorData->size()).get(), false); - monitorData = GetResourceAsData("icc_profiles/upperRight.icc"); - test_serialize(r, SkColorSpace::MakeICC(monitorData->data(), monitorData->size()).get(), false); + test_serialize(r, SkColorSpace::MakeSRGB(), true); + test_serialize(r, SkColorSpace::MakeSRGBLinear(), true); + +#if defined(SK_USE_SKCMS) + auto test = [&](const char* path) { + sk_sp<SkData> data = GetResourceAsData(path); + + skcms_ICCProfile profile; + REPORTER_ASSERT(r, skcms_Parse(data->data(), data->size(), &profile)); + + sk_sp<SkColorSpace> space = SkColorSpace::Make(profile); + REPORTER_ASSERT(r, space); + + test_serialize(r, space, false); + }; + test("icc_profiles/HP_ZR30w.icc"); + test("icc_profiles/HP_Z32x.icc"); +#endif SkColorSpaceTransferFn fn; fn.fA = 1.0f; @@ -226,19 +233,27 @@ DEF_TEST(ColorSpace_Serialize, r) { fn.fF = 0.0f; fn.fG = 1.0f; SkMatrix44 toXYZ(SkMatrix44::kIdentity_Constructor); - test_serialize(r, SkColorSpace::MakeRGB(fn, toXYZ).get(), false); + test_serialize(r, SkColorSpace::MakeRGB(fn, toXYZ), false); } DEF_TEST(ColorSpace_Equals, r) { sk_sp<SkColorSpace> srgb = SkColorSpace::MakeSRGB(); - sk_sp<SkData> data = GetResourceAsData("icc_profiles/HP_ZR30w.icc"); - sk_sp<SkColorSpace> z30 = SkColorSpace::MakeICC(data->data(), data->size()); - data = GetResourceAsData("icc_profiles/HP_Z32x.icc"); - sk_sp<SkColorSpace> z32 = SkColorSpace::MakeICC(data->data(), data->size()); - data = GetResourceAsData("icc_profiles/upperLeft.icc"); - sk_sp<SkColorSpace> upperLeft = SkColorSpace::MakeICC(data->data(), data->size()); - data = GetResourceAsData("icc_profiles/upperRight.icc"); - sk_sp<SkColorSpace> upperRight = SkColorSpace::MakeICC(data->data(), data->size()); + +#if defined(SK_USE_SKCMS) + auto parse = [&](const char* path) { + sk_sp<SkData> data = GetResourceAsData(path); + + skcms_ICCProfile profile; + REPORTER_ASSERT(r, skcms_Parse(data->data(), data->size(), &profile)); + + sk_sp<SkColorSpace> space = SkColorSpace::Make(profile); + REPORTER_ASSERT(r, space); + + return space; + }; + sk_sp<SkColorSpace> z30 = parse("icc_profiles/HP_ZR30w.icc"); + sk_sp<SkColorSpace> z32 = parse("icc_profiles/HP_Z32x.icc"); +#endif SkColorSpaceTransferFn fn; fn.fA = 1.0f; @@ -253,20 +268,19 @@ DEF_TEST(ColorSpace_Equals, r) { REPORTER_ASSERT(r, SkColorSpace::Equals(nullptr, nullptr)); REPORTER_ASSERT(r, SkColorSpace::Equals(srgb.get(), srgb.get())); +#if defined(SK_USE_SKCMS) REPORTER_ASSERT(r, SkColorSpace::Equals(z30.get(), z30.get())); REPORTER_ASSERT(r, SkColorSpace::Equals(z32.get(), z32.get())); - REPORTER_ASSERT(r, SkColorSpace::Equals(upperLeft.get(), upperLeft.get())); - REPORTER_ASSERT(r, SkColorSpace::Equals(upperRight.get(), upperRight.get())); +#endif REPORTER_ASSERT(r, SkColorSpace::Equals(rgb4.get(), rgb4.get())); REPORTER_ASSERT(r, !SkColorSpace::Equals(nullptr, srgb.get())); REPORTER_ASSERT(r, !SkColorSpace::Equals(srgb.get(), nullptr)); +#if defined(SK_USE_SKCMS) REPORTER_ASSERT(r, !SkColorSpace::Equals(z30.get(), srgb.get())); REPORTER_ASSERT(r, !SkColorSpace::Equals(z32.get(), z30.get())); - REPORTER_ASSERT(r, !SkColorSpace::Equals(upperLeft.get(), srgb.get())); - REPORTER_ASSERT(r, !SkColorSpace::Equals(upperLeft.get(), upperRight.get())); - REPORTER_ASSERT(r, !SkColorSpace::Equals(z30.get(), upperRight.get())); REPORTER_ASSERT(r, !SkColorSpace::Equals(z30.get(), rgb4.get())); +#endif REPORTER_ASSERT(r, !SkColorSpace::Equals(srgb.get(), rgb4.get())); } @@ -380,25 +394,6 @@ DEF_TEST(ColorSpace_Primaries, r) { check_primaries(r, rec2020, reference); } -DEF_TEST(ColorSpace_InvalidICC, r) { - // This color space has a matrix that is not D50. - sk_sp<SkData> data = GetResourceAsData("icc_profiles/SM2333SW.icc"); - if (!data) { - return; - } - sk_sp<SkColorSpace> cs = SkColorSpace::MakeICC(data->data(), data->size()); - REPORTER_ASSERT(r, !cs); - - // The color space has a color lut with only one entry in each dimension. - data = GetResourceAsData("icc_profiles/invalid_color_lut.icc"); - if (!data) { - return; - } - - cs = SkColorSpace::MakeICC(data->data(), data->size()); - REPORTER_ASSERT(r, !cs); -} - DEF_TEST(ColorSpace_MatrixHash, r) { sk_sp<SkColorSpace> srgb = SkColorSpace::MakeSRGB(); |