kill off shader_adapter

I still plan to replace this more thoroughly with a different blitter,
but for now just implement it using callback.

This is the last stage not supported by SkJumper!  Will follow up by
removing all of SkRasterPipeline_opts.h and anything that indicates
SkJumper might not work.

Change-Id: I96ba2bb0a26266f3b658e5f3153ec7d5bbd46799
Reviewed-on: https://skia-review.googlesource.com/14037
Reviewed-by: Florin Malita <fmalita@chromium.org>
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Mike Klein <mtklein@chromium.org>
diff --git a/src/core/SkRasterPipeline.h b/src/core/SkRasterPipeline.h
index 66b4c3a..09632b0 100644
--- a/src/core/SkRasterPipeline.h
+++ b/src/core/SkRasterPipeline.h
@@ -99,7 +99,6 @@
     M(linear_gradient)                                           \
     M(linear_gradient_2stops)                                    \
     M(byte_tables) M(byte_tables_rgb)                            \
-    M(shader_adapter)                                            \
     M(rgb_to_hsl)                                                \
     M(hsl_to_rgb)
 
diff --git a/src/core/SkShader.cpp b/src/core/SkShader.cpp
index cfdd8b9..f6865d9 100644
--- a/src/core/SkShader.cpp
+++ b/src/core/SkShader.cpp
@@ -21,6 +21,7 @@
 #include "SkShader.h"
 #include "SkTLazy.h"
 #include "SkWriteBuffer.h"
+#include "../jumper/SkJumper.h"
 
 #if SK_SUPPORT_GPU
 #include "GrFragmentProcessor.h"
@@ -274,8 +275,20 @@
     }
 
     ContextRec rec(*opaquePaint, ctm, localM, ContextRec::kPM4f_DstType, cs);
-    if (auto* ctx = this->makeContext(rec, alloc)) {
-        p->append(SkRasterPipeline::shader_adapter, ctx);
+    if (Context* ctx = this->makeContext(rec, alloc)) {
+        struct CallbackCtx : SkJumper_CallbackCtx {
+            Context* ctx;
+        };
+
+        auto cb = alloc->make<CallbackCtx>();
+        cb->ctx = ctx;
+        cb->fn  = [](SkJumper_CallbackCtx* self, int active_pixels) {
+            auto c = (CallbackCtx*)self;
+            int x = (int)c->rgba[0],
+                y = (int)c->rgba[1];
+            c->ctx->shadeSpan4f(x,y, (SkPM4f*)c->rgba, active_pixels);
+        };
+        p->append(SkRasterPipeline::callback, cb);
 
         // Legacy shaders aren't aware of color spaces. We can pretty
         // safely assume they're in sRGB gamut.
diff --git a/src/opts/SkRasterPipeline_opts.h b/src/opts/SkRasterPipeline_opts.h
index 2b5b2e5..9f1828e 100644
--- a/src/opts/SkRasterPipeline_opts.h
+++ b/src/opts/SkRasterPipeline_opts.h
@@ -1067,13 +1067,6 @@
     b = SkNf_from_byte(gather(tail, tables->b, SkNf_round(scale, b)));
 }
 
-STAGE_CTX(shader_adapter, SkShader::Context*) {
-    SkPM4f buf[N];
-    static_assert(sizeof(buf) == sizeof(r) + sizeof(g) + sizeof(b) + sizeof(a), "");
-    ctx->shadeSpan4f(x, (int)g[0], buf, N);
-    SkNf::Load4(buf, &r, &g, &b, &a);
-}
-
 STAGE_CTX(callback, const void*) {
     auto c = (SkJumper_CallbackCtx*)ctx;
     SkNf::Store4(c->rgba, r,g,b,a);