diff options
author | Mike Klein <mtklein@chromium.org> | 2017-07-18 18:15:13 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-07-20 19:50:32 +0000 |
commit | 45c16fa82cd2fec010d4cb7763b654a413cabd0c (patch) | |
tree | 2c6e4376e11dca4b4c3ae479b7835096124016f5 /tests | |
parent | 3f4671871fac8e5439440ce756d0666bc2a96f46 (diff) |
convert over to 2d-mode
[√] convert all stages to use SkJumper_MemoryCtx / be 2d-compatible
[√] convert compile to 2d also, remove 1d run/compile
[√] convert all call sites
[√] no diffs
Change-Id: I3b806eb8fe0c3ec043359616409f7cd1211a1e43
Reviewed-on: https://skia-review.googlesource.com/24263
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/F16StagesTest.cpp | 41 | ||||
-rw-r--r-- | tests/ParametricStageTest.cpp | 7 | ||||
-rw-r--r-- | tests/SRGBTest.cpp | 10 | ||||
-rw-r--r-- | tests/SkRasterPipelineTest.cpp | 49 |
4 files changed, 56 insertions, 51 deletions
diff --git a/tests/F16StagesTest.cpp b/tests/F16StagesTest.cpp index 51cb861c89..d07f6ba4a7 100644 --- a/tests/F16StagesTest.cpp +++ b/tests/F16StagesTest.cpp @@ -7,6 +7,7 @@ #include "SkRasterPipeline.h" #include "Test.h" +#include "../src/jumper/SkJumper.h" DEF_TEST(F16Stages, r) { // Make sure SkRasterPipeline::load_f16 and store_f16 can handle a range of @@ -18,36 +19,36 @@ DEF_TEST(F16Stages, r) { }; uint16_t halfs[16] = {0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0}; - float* f32 = floats; - uint16_t* f16 = halfs; + SkJumper_MemoryCtx f32 = { floats, 0 }, + f16 = { halfs, 0 }; { SkRasterPipeline_<256> p; p.append(SkRasterPipeline:: load_f32, &f32); p.append(SkRasterPipeline::store_f16, &f16); - p.run(0,0,16/4); + p.run(0,0,16/4,1); } - REPORTER_ASSERT(r, f16[0] == 0x0000); - REPORTER_ASSERT(r, f16[1] == 0x3400); - REPORTER_ASSERT(r, f16[2] == 0x3800); - REPORTER_ASSERT(r, f16[3] == 0x3c00); - REPORTER_ASSERT(r, f16[4] == 0xbd00); - REPORTER_ASSERT(r, f16[5] == 0xb800); - REPORTER_ASSERT(r, f16[6] == 0x3d00); - REPORTER_ASSERT(r, f16[7] == 0x4000); + REPORTER_ASSERT(r, halfs[0] == 0x0000); + REPORTER_ASSERT(r, halfs[1] == 0x3400); + REPORTER_ASSERT(r, halfs[2] == 0x3800); + REPORTER_ASSERT(r, halfs[3] == 0x3c00); + REPORTER_ASSERT(r, halfs[4] == 0xbd00); + REPORTER_ASSERT(r, halfs[5] == 0xb800); + REPORTER_ASSERT(r, halfs[6] == 0x3d00); + REPORTER_ASSERT(r, halfs[7] == 0x4000); { SkRasterPipeline_<256> p; p.append(SkRasterPipeline:: load_f16, &f16); p.append(SkRasterPipeline::store_f32, &f32); - p.run(0,0,16/4); + p.run(0,0,16/4,1); } - REPORTER_ASSERT(r, f32[0] == 0.00f); - REPORTER_ASSERT(r, f32[1] == 0.25f); - REPORTER_ASSERT(r, f32[2] == 0.50f); - REPORTER_ASSERT(r, f32[3] == 1.00f); - REPORTER_ASSERT(r, f32[4] == -1.25f); - REPORTER_ASSERT(r, f32[5] == -0.50f); - REPORTER_ASSERT(r, f32[6] == 1.25f); - REPORTER_ASSERT(r, f32[7] == 2.00f); + REPORTER_ASSERT(r, floats[0] == 0.00f); + REPORTER_ASSERT(r, floats[1] == 0.25f); + REPORTER_ASSERT(r, floats[2] == 0.50f); + REPORTER_ASSERT(r, floats[3] == 1.00f); + REPORTER_ASSERT(r, floats[4] == -1.25f); + REPORTER_ASSERT(r, floats[5] == -0.50f); + REPORTER_ASSERT(r, floats[6] == 1.25f); + REPORTER_ASSERT(r, floats[7] == 2.00f); } diff --git a/tests/ParametricStageTest.cpp b/tests/ParametricStageTest.cpp index 5b34e166c9..6d98ac451b 100644 --- a/tests/ParametricStageTest.cpp +++ b/tests/ParametricStageTest.cpp @@ -8,6 +8,7 @@ #include "SkColorSpace.h" #include "SkRasterPipeline.h" #include "Test.h" +#include "../src/jumper/SkJumper.h" static void check_error(skiatest::Reporter* r, float limit, SkColorSpaceTransferFn fn) { float in[256], out[256]; @@ -16,8 +17,8 @@ static void check_error(skiatest::Reporter* r, float limit, SkColorSpaceTransfer out[i] = 0.0f; // Not likely important. Just being tidy. } - const float* ip = in; - float* op = out; + SkJumper_MemoryCtx ip = { in, 0}, + op = {out, 0}; SkRasterPipeline_<256> p; p.append(SkRasterPipeline::load_f32, &ip); @@ -27,7 +28,7 @@ static void check_error(skiatest::Reporter* r, float limit, SkColorSpaceTransfer p.append(SkRasterPipeline::parametric_a, &fn); p.append(SkRasterPipeline::store_f32, &op); - p.run(0,0, 256/4); + p.run(0,0, 256/4,1); for (int i = 0; i < 256; i++) { diff --git a/tests/SRGBTest.cpp b/tests/SRGBTest.cpp index fc02f7d96c..1db9eb306f 100644 --- a/tests/SRGBTest.cpp +++ b/tests/SRGBTest.cpp @@ -11,6 +11,7 @@ #include "SkTypes.h" #include "Test.h" #include <math.h> +#include "../src/jumper/SkJumper.h" static uint8_t linear_to_srgb(float l) { return (uint8_t)sk_linear_to_srgb(Sk4f{l})[0]; @@ -46,7 +47,7 @@ DEF_TEST(sk_pipeline_srgb_roundtrip, r) { reds[i] = i; } - auto ptr = (void*)reds; + SkJumper_MemoryCtx ptr = { reds, 0 }; SkRasterPipeline_<256> p; p.append(SkRasterPipeline::load_8888, &ptr); @@ -54,7 +55,7 @@ DEF_TEST(sk_pipeline_srgb_roundtrip, r) { p.append(SkRasterPipeline::to_srgb); p.append(SkRasterPipeline::store_8888, &ptr); - p.run(0,0,256); + p.run(0,0,256,1); for (int i = 0; i < 256; i++) { if (reds[i] != (uint32_t)i) { @@ -67,13 +68,14 @@ DEF_TEST(sk_pipeline_srgb_edge_cases, r) { // We need to run at least 4 pixels to make sure we hit all specializations. SkPM4f colors[4] = { {{0,1,1,1}}, {{0,0,0,0}}, {{0,0,0,0}}, {{0,0,0,0}} }; auto& color = colors[0]; - void* dst = &color; + + SkJumper_MemoryCtx dst = { &color, 0 }; SkRasterPipeline_<256> p; p.append(SkRasterPipeline::uniform_color, &color); p.append(SkRasterPipeline::to_srgb); p.append(SkRasterPipeline::store_f32, &dst); - p.run(0,0,4); + p.run(0,0,4,1); if (color.r() != 0.0f) { ERRORF(r, "expected to_srgb() to map 0.0f to 0.0f, got %f", color.r()); diff --git a/tests/SkRasterPipelineTest.cpp b/tests/SkRasterPipelineTest.cpp index 8edff7e061..bab3d5b63b 100644 --- a/tests/SkRasterPipelineTest.cpp +++ b/tests/SkRasterPipelineTest.cpp @@ -17,16 +17,16 @@ DEF_TEST(SkRasterPipeline, r) { blue = 0x3800380000000000ull, result; - void* load_s_ctx = &blue; - void* load_d_ctx = &red; - void* store_ctx = &result; + SkJumper_MemoryCtx load_s_ctx = { &blue, 0 }, + load_d_ctx = { &red, 0 }, + store_ctx = { &result, 0 }; SkRasterPipeline_<256> p; p.append(SkRasterPipeline::load_f16, &load_s_ctx); p.append(SkRasterPipeline::load_f16_dst, &load_d_ctx); p.append(SkRasterPipeline::srcover); p.append(SkRasterPipeline::store_f16, &store_ctx); - p.run(0,0,1); + p.run(0,0,1,1); // We should see half-intensity magenta. REPORTER_ASSERT(r, ((result >> 0) & 0xffff) == 0x3800); @@ -38,7 +38,7 @@ DEF_TEST(SkRasterPipeline, r) { DEF_TEST(SkRasterPipeline_empty, r) { // No asserts... just a test that this is safe to run. SkRasterPipeline_<256> p; - p.run(0,0,20); + p.run(0,0,20,1); } DEF_TEST(SkRasterPipeline_nonsense, r) { @@ -46,7 +46,7 @@ DEF_TEST(SkRasterPipeline_nonsense, r) { // srcover() calls st->next(); this makes sure we've always got something there to call. SkRasterPipeline_<256> p; p.append(SkRasterPipeline::srcover); - p.run(0,0,20); + p.run(0,0,20,1); } DEF_TEST(SkRasterPipeline_JIT, r) { @@ -61,20 +61,20 @@ DEF_TEST(SkRasterPipeline_JIT, r) { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; - const uint32_t* src = buf + 0; - uint32_t* dst = buf + 36; + SkJumper_MemoryCtx src = { buf + 0, 0 }, + dst = { buf + 36, 0 }; // Copy buf[x] to buf[x+36] for x in [15,35). SkRasterPipeline_<256> p; p.append(SkRasterPipeline:: load_8888, &src); p.append(SkRasterPipeline::store_8888, &dst); - p.run(15,0, 20); + p.run(15,0, 20,1); for (int i = 0; i < 36; i++) { if (i < 15 || i == 35) { - REPORTER_ASSERT(r, dst[i] == 0); + REPORTER_ASSERT(r, buf[i+36] == 0); } else { - REPORTER_ASSERT(r, dst[i] == (uint32_t)(i - 11)); + REPORTER_ASSERT(r, buf[i+36] == (uint32_t)(i - 11)); } } } @@ -111,15 +111,16 @@ DEF_TEST(SkRasterPipeline_tail, r) { }; float buffer[4][4]; - float* src = &data[0][0]; - float* dst = &buffer[0][0]; + + SkJumper_MemoryCtx src = { &data[0][0], 0 }, + dst = { &buffer[0][0], 0 }; for (unsigned i = 1; i <= 4; i++) { memset(buffer, 0xff, sizeof(buffer)); SkRasterPipeline_<256> p; p.append(SkRasterPipeline::load_f32, &src); p.append(SkRasterPipeline::store_f32, &dst); - p.run(0,0, i); + p.run(0,0, i,1); for (unsigned j = 0; j < i; j++) { for (unsigned k = 0; k < 4; k++) { if (buffer[j][k] != data[j][k]) { @@ -143,15 +144,15 @@ DEF_TEST(SkRasterPipeline_tail, r) { {h(30), h(31), h(32), h(33)}, }; uint16_t buffer[4][4]; - uint16_t* src = &data[0][0]; - uint16_t* dst = &buffer[0][0]; + SkJumper_MemoryCtx src = { &data[0][0], 0 }, + dst = { &buffer[0][0], 0 }; for (unsigned i = 1; i <= 4; i++) { memset(buffer, 0xff, sizeof(buffer)); SkRasterPipeline_<256> p; p.append(SkRasterPipeline::load_f16, &src); p.append(SkRasterPipeline::store_f16, &dst); - p.run(0,0, i); + p.run(0,0, i,1); for (unsigned j = 0; j < i; j++) { REPORTER_ASSERT(r, !memcmp(&data[j][0], &buffer[j][0], sizeof(buffer[j]))); @@ -180,15 +181,15 @@ DEF_TEST(SkRasterPipeline_tail, r) { }; float buffer[4][4]; - uint16_t* src = &data[0][0]; - float* dst = &buffer[0][0]; + SkJumper_MemoryCtx src = { &data[0][0], 0 }, + dst = { &buffer[0][0], 0 }; for (unsigned i = 1; i <= 4; i++) { memset(buffer, 0xff, sizeof(buffer)); SkRasterPipeline_<256> p; p.append(SkRasterPipeline::load_rgb_u16_be, &src); p.append(SkRasterPipeline::store_f32, &dst); - p.run(0,0, i); + p.run(0,0, i,1); for (unsigned j = 0; j < i; j++) { for (unsigned k = 0; k < 4; k++) { if (buffer[j][k] != answer[j][k]) { @@ -214,12 +215,12 @@ DEF_TEST(SkRasterPipeline_lowp, r) { | (4*i+3) << 24; } - void* ptr = rgba; + SkJumper_MemoryCtx ptr = { rgba, 0 }; SkRasterPipeline_<256> p; p.append(SkRasterPipeline::load_bgra, &ptr); p.append(SkRasterPipeline::store_8888, &ptr); - p.run(0,0,64); + p.run(0,0,64,1); for (int i = 0; i < 64; i++) { uint32_t want = (4*i+0) << 16 @@ -247,9 +248,9 @@ DEF_TEST(SkRasterPipeline_2d, r) { // Write out to rgba, with row stride = 2 pixels. SkJumper_MemoryCtx ctx = { rgba, 2 }; - p.append(SkRasterPipeline::store_8888_2d, &ctx); + p.append(SkRasterPipeline::store_8888, &ctx); - p.run_2d(0,0, 2,2); + p.run(0,0, 2,2); REPORTER_ASSERT(r, ((rgba[0] >> 0) & 0xff) == 0); REPORTER_ASSERT(r, ((rgba[1] >> 0) & 0xff) == 128); |