diff options
author | brianosman <brianosman@google.com> | 2016-09-09 10:36:17 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-09-09 10:36:17 -0700 |
commit | de68d6c4616d86621373d88100002ddfdb9c08e3 (patch) | |
tree | c3020d0d2ab8a4157beeab02fc32efc1518bb1e6 /tests/ColorSpaceTest.cpp | |
parent | 81a478ca6c36aac3e53ce0373a281ac8940f4780 (diff) |
Fix storage of gamut transform matrices in SkColorSpace
We were effectively storing the transpose, which made all of our
operations on individual colors, and our concatenation of matrices
awkward and backwards.
I'm planning to push this further into Ganesh, where I had incorrectly
adjusted to the previous layout, treating colors as row vectors in the
shaders.
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2324843003
Review-Url: https://codereview.chromium.org/2324843003
Diffstat (limited to 'tests/ColorSpaceTest.cpp')
-rw-r--r-- | tests/ColorSpaceTest.cpp | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/tests/ColorSpaceTest.cpp b/tests/ColorSpaceTest.cpp index 969e0929a4..4a64460370 100644 --- a/tests/ColorSpaceTest.cpp +++ b/tests/ColorSpaceTest.cpp @@ -30,12 +30,13 @@ static void test_space(skiatest::Reporter* r, SkColorSpace* space, 0, 1, 0, 1, 0, 0, 1, 1, }; + const float* ref[3] = { red, green, blue }; float dst[4]; for (int i = 0; i < 3; ++i) { mat.mapScalars(&src[i*4], dst); - REPORTER_ASSERT(r, almost_equal(red[i], dst[0])); - REPORTER_ASSERT(r, almost_equal(green[i], dst[1])); - REPORTER_ASSERT(r, almost_equal(blue[i], dst[2])); + REPORTER_ASSERT(r, almost_equal(ref[i][0], dst[0])); + REPORTER_ASSERT(r, almost_equal(ref[i][1], dst[1])); + REPORTER_ASSERT(r, almost_equal(ref[i][2], dst[2])); } } @@ -63,20 +64,26 @@ static void test_path(skiatest::Reporter* r, const char* path, test_space(r, colorSpace, red, green, blue, expectedGamma); } -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 +static constexpr float g_sRGB_XYZ[]{ + 0.4358f, 0.3853f, 0.1430f, // Rx, Gx, Bx + 0.2224f, 0.7170f, 0.0606f, // Ry, Gy, Gz + 0.0139f, 0.0971f, 0.7139f, // Rz, Gz, Bz +}; + +static constexpr float g_sRGB_R[]{ 0.4358f, 0.2224f, 0.0139f }; +static constexpr float g_sRGB_G[]{ 0.3853f, 0.7170f, 0.0971f }; +static constexpr float g_sRGB_B[]{ 0.1430f, 0.0606f, 0.7139f }; 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], kSRGB_SkGammaNamed); + g_sRGB_R, g_sRGB_G, g_sRGB_B, kSRGB_SkGammaNamed); } 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], + test_path(r, "color_wheel_with_profile.png", g_sRGB_R, g_sRGB_G, g_sRGB_B, kSRGB_SkGammaNamed); #endif @@ -125,8 +132,7 @@ DEF_TEST(ColorSpaceWriteICC, r) { sk_sp<SkColorSpace> namedColorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named); sk_sp<SkData> namedData = ColorSpaceTest::WriteToICC(namedColorSpace.get()); sk_sp<SkColorSpace> iccColorSpace = SkColorSpace::NewICC(namedData->data(), namedData->size()); - test_space(r, iccColorSpace.get(), g_sRGB_XYZ, &g_sRGB_XYZ[3], &g_sRGB_XYZ[6], - k2Dot2Curve_SkGammaNamed); + test_space(r, iccColorSpace.get(), g_sRGB_R, g_sRGB_G, g_sRGB_B, k2Dot2Curve_SkGammaNamed); // FIXME (msarett): Test disabled. sRGB profiles are written approximately as 2.2f curves. // REPORTER_ASSERT(r, iccColorSpace == namedColorSpace); |