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>
This commit is contained in:
Mike Klein 2017-04-17 14:43:59 -04:00 committed by Skia Commit-Bot
parent 6a2ccb2b34
commit c7d9c0b808
6 changed files with 1635 additions and 433 deletions

View File

@ -93,6 +93,7 @@ static K kConstants = {
M(load_tables_rgb_u16_be) \ M(load_tables_rgb_u16_be) \
M(byte_tables) \ M(byte_tables) \
M(byte_tables_rgb) \ M(byte_tables_rgb) \
M(table_r) M(table_g) M(table_b) M(table_a) \
M(load_a8) \ M(load_a8) \
M(gather_a8) \ M(gather_a8) \
M(store_a8) \ M(store_a8) \

View File

@ -91,4 +91,9 @@ struct SkJumper_LoadTablesCtx {
const float *r, *g, *b; const float *r, *g, *b;
}; };
struct SkJumper_TableCtx {
const float* table;
int size;
};
#endif//SkJumper_DEFINED #endif//SkJumper_DEFINED

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -663,6 +663,14 @@ STAGE(byte_tables_rgb) {
b = from_byte(gather(tables->b, round(b, scale))); b = from_byte(gather(tables->b, round(b, scale)));
} }
SI F table(F v, const SkJumper_TableCtx* ctx) {
return gather(ctx->table, round(v, ctx->size - 1));
}
STAGE(table_r) { r = table(r, ctx); }
STAGE(table_g) { g = table(g, ctx); }
STAGE(table_b) { b = table(b, ctx); }
STAGE(table_a) { a = table(a, ctx); }
STAGE(load_a8) { STAGE(load_a8) {
auto ptr = *(const uint8_t**)ctx + x; auto ptr = *(const uint8_t**)ctx + x;

View File

@ -67,8 +67,8 @@ public:
} }
}; };
static bool almost_equal(int x, int y) { static bool almost_equal(int x, int y, int tol=1) {
return SkTAbs(x - y) <= 1; return SkTAbs(x-y) <= tol;
} }
static void test_identity_xform(skiatest::Reporter* r, const sk_sp<SkGammas>& gammas, 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, 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 // Arbitrary set of 10 pixels
constexpr int width = 10; constexpr int width = 10;
constexpr uint32_t srcPixels[width] = { constexpr uint32_t srcPixels[width] = {
@ -124,16 +124,16 @@ static void test_identity_xform_A2B(skiatest::Reporter* r, SkGammaNamed gammaNam
REPORTER_ASSERT(r, result); REPORTER_ASSERT(r, result);
// Since the src->dst matrix is the identity, and the gamma curves match, // 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++) { for (int i = 0; i < width; i++) {
REPORTER_ASSERT(r, almost_equal(((srcPixels[i] >> 0) & 0xFF), 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), 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), 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), 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)); float* table = SkTAddOffset<float>(memory, sizeof(SkGammas));
table[0] = 0.00f; table[0] = 0.00f;
table[1] = 0.05f; table[1] = 0.05f;
table[2] = 0.10f; table[2] = 0.10f;
@ -160,8 +159,13 @@ DEF_TEST(ColorSpaceXform_TableGamma, r) {
table[7] = 0.60f; table[7] = 0.60f;
table[8] = 0.75f; table[8] = 0.75f;
table[9] = 1.00f; 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(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) { DEF_TEST(ColorSpaceXform_ParametricGamma, r) {