aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/ColorSpaceXformTest.cpp
diff options
context:
space:
mode:
authorGravatar Mike Klein <mtklein@chromium.org>2017-04-17 14:43:59 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-04-17 19:59:11 +0000
commitc7d9c0b80886d24e74cd6e5a7118f44c06e0cd9b (patch)
tree5b95bee61e28c7ba5f0f1e31a90bd4f1eb96ffd4 /tests/ColorSpaceXformTest.cpp
parent6a2ccb2b34f5f3ba34efed2855dca4a46e82b630 (diff)
jumper, table_{r,g,b,a}
In testing, it didn't really seem like we're getting anything out of doing an interpolated lookup, so this just does a single rounded lookup. Change-Id: If85ba68675945b442076519dd7f1bf7540d1628d Reviewed-on: https://skia-review.googlesource.com/13646 Commit-Queue: Matt Sarett <msarett@google.com> Commit-Queue: Mike Klein <mtklein@chromium.org> Reviewed-by: Matt Sarett <msarett@google.com>
Diffstat (limited to 'tests/ColorSpaceXformTest.cpp')
-rw-r--r--tests/ColorSpaceXformTest.cpp24
1 files changed, 14 insertions, 10 deletions
diff --git a/tests/ColorSpaceXformTest.cpp b/tests/ColorSpaceXformTest.cpp
index f8a5c8fec4..81fdc37caf 100644
--- a/tests/ColorSpaceXformTest.cpp
+++ b/tests/ColorSpaceXformTest.cpp
@@ -67,8 +67,8 @@ public:
}
};
-static bool almost_equal(int x, int y) {
- return SkTAbs(x - y) <= 1;
+static bool almost_equal(int x, int y, int tol=1) {
+ return SkTAbs(x-y) <= tol;
}
static void test_identity_xform(skiatest::Reporter* r, const sk_sp<SkGammas>& gammas,
@@ -108,7 +108,7 @@ static void test_identity_xform(skiatest::Reporter* r, const sk_sp<SkGammas>& ga
}
static void test_identity_xform_A2B(skiatest::Reporter* r, SkGammaNamed gammaNamed,
- const sk_sp<SkGammas>& gammas) {
+ const sk_sp<SkGammas>& gammas, int tol=1) {
// Arbitrary set of 10 pixels
constexpr int width = 10;
constexpr uint32_t srcPixels[width] = {
@@ -124,16 +124,16 @@ static void test_identity_xform_A2B(skiatest::Reporter* r, SkGammaNamed gammaNam
REPORTER_ASSERT(r, result);
// Since the src->dst matrix is the identity, and the gamma curves match,
- // the pixels should be unchanged.
+ // the pixels should be ~unchanged.
for (int i = 0; i < width; i++) {
REPORTER_ASSERT(r, almost_equal(((srcPixels[i] >> 0) & 0xFF),
- SkGetPackedB32(dstPixels[i])));
+ SkGetPackedB32(dstPixels[i]), tol));
REPORTER_ASSERT(r, almost_equal(((srcPixels[i] >> 8) & 0xFF),
- SkGetPackedG32(dstPixels[i])));
+ SkGetPackedG32(dstPixels[i]), tol));
REPORTER_ASSERT(r, almost_equal(((srcPixels[i] >> 16) & 0xFF),
- SkGetPackedR32(dstPixels[i])));
+ SkGetPackedR32(dstPixels[i]), tol));
REPORTER_ASSERT(r, almost_equal(((srcPixels[i] >> 24) & 0xFF),
- SkGetPackedA32(dstPixels[i])));
+ SkGetPackedA32(dstPixels[i]), tol));
}
}
@@ -149,7 +149,6 @@ DEF_TEST(ColorSpaceXform_TableGamma, r) {
}
float* table = SkTAddOffset<float>(memory, sizeof(SkGammas));
-
table[0] = 0.00f;
table[1] = 0.05f;
table[2] = 0.10f;
@@ -160,8 +159,13 @@ DEF_TEST(ColorSpaceXform_TableGamma, r) {
table[7] = 0.60f;
table[8] = 0.75f;
table[9] = 1.00f;
+ // This table's pretty small compared to real ones in the wild (think 256),
+ // so we give test_identity_xform_A2B a wide tolerance.
+ // This lets us implement table transfer functions with a single lookup.
+ const int tolerance = 13;
+
test_identity_xform(r, gammas, true);
- test_identity_xform_A2B(r, kNonStandard_SkGammaNamed, gammas);
+ test_identity_xform_A2B(r, kNonStandard_SkGammaNamed, gammas, tolerance);
}
DEF_TEST(ColorSpaceXform_ParametricGamma, r) {