Index: tests/ColorSpaceTest.cpp |
diff --git a/tests/ColorSpaceTest.cpp b/tests/ColorSpaceTest.cpp |
index 393d75310b05a897bb0856fb439373de069b95a6..3eb145b2e8b0e104a18c325f03d9f39a857a0157 100644 |
--- a/tests/ColorSpaceTest.cpp |
+++ b/tests/ColorSpaceTest.cpp |
@@ -21,9 +21,9 @@ static void test_space(skiatest::Reporter* r, SkColorSpace* space, |
const float red[], const float green[], const float blue[], |
const SkColorSpace::GammaNamed expectedGamma) { |
+ REPORTER_ASSERT(r, nullptr != space); |
REPORTER_ASSERT(r, expectedGamma == space->gammaNamed()); |
- |
const SkMatrix44& mat = space->xyz(); |
const float src[] = { |
1, 0, 0, 1, |
@@ -39,23 +39,15 @@ static void test_space(skiatest::Reporter* r, SkColorSpace* space, |
} |
} |
-const float g_sRGB_XYZ[] = { 0.4358f, 0.2224f, 0.0139f, // R |
- 0.3853f, 0.7170f, 0.0971f, // G |
- 0.1430f, 0.0606f, 0.7139f }; // B |
- |
-DEF_TEST(ColorSpace_sRGB, r) { |
- test_space(r, SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named).get(), |
- g_sRGB_XYZ, &g_sRGB_XYZ[3], &g_sRGB_XYZ[6], SkColorSpace::kSRGB_GammaNamed); |
- |
-} |
- |
static SkStreamAsset* resource(const char path[]) { |
SkString fullPath = GetResourcePath(path); |
return SkStream::NewFromFile(fullPath.c_str()); |
} |
-DEF_TEST(ColorSpaceParsePngICCProfile, r) { |
- SkAutoTDelete<SkStream> stream(resource("color_wheel_with_profile.png")); |
+static void test_path(skiatest::Reporter* r, const char* path, |
+ const float red[], const float green[], const float blue[], |
+ const SkColorSpace::GammaNamed expectedGamma) { |
+ SkAutoTDelete<SkStream> stream(resource(path)); |
REPORTER_ASSERT(r, nullptr != stream); |
if (!stream) { |
return; |
@@ -63,36 +55,44 @@ DEF_TEST(ColorSpaceParsePngICCProfile, r) { |
SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.release())); |
REPORTER_ASSERT(r, nullptr != codec); |
+ if (!codec) { |
+ return; |
+ } |
-#if (PNG_LIBPNG_VER_MAJOR > 1) || (PNG_LIBPNG_VER_MAJOR == 1 && PNG_LIBPNG_VER_MINOR >= 6) |
SkColorSpace* colorSpace = codec->getInfo().colorSpace(); |
- REPORTER_ASSERT(r, nullptr != colorSpace); |
- |
- test_space(r, colorSpace, &g_sRGB_XYZ[0], &g_sRGB_XYZ[3], &g_sRGB_XYZ[6], |
- SkColorSpace::kSRGB_GammaNamed); |
-#endif |
+ test_space(r, colorSpace, red, green, blue, expectedGamma); |
} |
-DEF_TEST(ColorSpaceParseJpegICCProfile, r) { |
- SkAutoTDelete<SkStream> stream(resource("icc-v2-gbr.jpg")); |
- REPORTER_ASSERT(r, nullptr != stream); |
- if (!stream) { |
- return; |
- } |
+const float g_sRGB_XYZ[] = { 0.4358f, 0.2224f, 0.0139f, // R |
+ 0.3853f, 0.7170f, 0.0971f, // G |
+ 0.1430f, 0.0606f, 0.7139f }; // B |
- SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.release())); |
- REPORTER_ASSERT(r, nullptr != codec); |
- if (!codec) { |
- return; |
- } |
+DEF_TEST(ColorSpace_sRGB, r) { |
+ test_space(r, SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named).get(), |
+ g_sRGB_XYZ, &g_sRGB_XYZ[3], &g_sRGB_XYZ[6], SkColorSpace::kSRGB_GammaNamed); |
- SkColorSpace* colorSpace = codec->getInfo().colorSpace(); |
- REPORTER_ASSERT(r, nullptr != colorSpace); |
+} |
+ |
+DEF_TEST(ColorSpaceParseICCProfiles, r) { |
+ |
+#if (PNG_LIBPNG_VER_MAJOR > 1) || (PNG_LIBPNG_VER_MAJOR == 1 && PNG_LIBPNG_VER_MINOR >= 6) |
+ test_path(r, "color_wheel_with_profile.png", &g_sRGB_XYZ[0], &g_sRGB_XYZ[3], &g_sRGB_XYZ[6], |
+ SkColorSpace::kSRGB_GammaNamed); |
+#endif |
const float red[] = { 0.385117f, 0.716904f, 0.0970612f }; |
const float green[] = { 0.143051f, 0.0606079f, 0.713913f }; |
const float blue[] = { 0.436035f, 0.222488f, 0.013916f }; |
- test_space(r, colorSpace, red, green, blue, SkColorSpace::k2Dot2Curve_GammaNamed); |
+ test_path(r, "icc-v2-gbr.jpg", red, green, blue, SkColorSpace::k2Dot2Curve_GammaNamed); |
+ |
+ test_path(r, "webp-color-profile-crash.webp", |
+ red, green, blue, SkColorSpace::kNonStandard_GammaNamed); |
+ test_path(r, "webp-color-profile-lossless.webp", |
+ red, green, blue, SkColorSpace::kNonStandard_GammaNamed); |
+ test_path(r, "webp-color-profile-lossy.webp", |
+ red, green, blue, SkColorSpace::kNonStandard_GammaNamed); |
+ test_path(r, "webp-color-profile-lossy-alpha.webp", |
+ red, green, blue, SkColorSpace::kNonStandard_GammaNamed); |
} |
DEF_TEST(ColorSpaceSRGBCompare, r) { |