start on raster pipeline 2d mode
- Add run_2d(x,y,w,h) and start_pipeline_2d().
- Add and test a 2d-compatible store_8888_2d stage.
Change-Id: Ib9c225d1b8cb40471ae4333df1d06eec4d506f8a
Reviewed-on: https://skia-review.googlesource.com/24401
Commit-Queue: Mike Klein <mtklein@chromium.org>
Reviewed-by: Florin Malita <fmalita@chromium.org>
diff --git a/tests/SkRasterPipelineTest.cpp b/tests/SkRasterPipelineTest.cpp
index 52b4152..db4d5a3 100644
--- a/tests/SkRasterPipelineTest.cpp
+++ b/tests/SkRasterPipelineTest.cpp
@@ -8,6 +8,7 @@
#include "Test.h"
#include "SkHalf.h"
#include "SkRasterPipeline.h"
+#include "../src/jumper/SkJumper.h"
DEF_TEST(SkRasterPipeline, r) {
// Build and run a simple pipeline to exercise SkRasterPipeline,
@@ -230,3 +231,33 @@
}
}
}
+
+DEF_TEST(SkRasterPipeline_2d, r) {
+ uint32_t rgba[2*2] = {0,0,0,0};
+
+ SkSTArenaAlloc<256> alloc;
+ SkRasterPipeline p(&alloc);
+
+ // Splat out the (2d) dst coordinates: (0.5,0.5), (1.5,0.5), (0.5,1.5), (1.5,1.5).
+ p.append(SkRasterPipeline::seed_shader);
+
+ // Scale down to [0,1] range to write out as bytes.
+ p.append_matrix(&alloc, SkMatrix::Concat(SkMatrix::MakeScale(0.5f),
+ SkMatrix::MakeTrans(-0.5f, -0.5f)));
+
+ // Write out to rgba, with row stride = 2 pixels.
+ SkJumper_PtrStride ctx = { rgba, 2 };
+ p.append(SkRasterPipeline::store_8888_2d, &ctx);
+
+ p.run_2d(0,0, 2,2);
+
+ REPORTER_ASSERT(r, ((rgba[0] >> 0) & 0xff) == 0);
+ REPORTER_ASSERT(r, ((rgba[1] >> 0) & 0xff) == 128);
+ REPORTER_ASSERT(r, ((rgba[2] >> 0) & 0xff) == 0);
+ REPORTER_ASSERT(r, ((rgba[3] >> 0) & 0xff) == 128);
+
+ REPORTER_ASSERT(r, ((rgba[0] >> 8) & 0xff) == 0);
+ REPORTER_ASSERT(r, ((rgba[1] >> 8) & 0xff) == 0);
+ REPORTER_ASSERT(r, ((rgba[2] >> 8) & 0xff) == 128);
+ REPORTER_ASSERT(r, ((rgba[3] >> 8) & 0xff) == 128);
+}