tweaks to make gather_* easier in SkJumper
This moves all the values that gather_8888, gather_a8, etc. need to
the front of SkImageShaderContext, and dereferences the color table.
This should be a no-op, but will make these stages easier to write
in SkJumper.
Change-Id: I0dff97d5113d14e941e7b717cd85f0036764eb88
Reviewed-on: https://skia-review.googlesource.com/11492
Reviewed-by: Herb Derby <herb@google.com>
Reviewed-by: Mike Klein <mtklein@chromium.org>
Commit-Queue: Mike Klein <mtklein@chromium.org>
diff --git a/src/image/SkImageShader.cpp b/src/image/SkImageShader.cpp
index c8d6a8c..cbba65e 100644
--- a/src/image/SkImageShader.cpp
+++ b/src/image/SkImageShader.cpp
@@ -258,13 +258,13 @@
}
auto ctx = scratch->make<SkImageShaderContext>();
- ctx->state = std::move(state); // Extend lifetime to match the pipeline's.
ctx->pixels = pm.addr();
- ctx->ctable = pm.ctable();
- ctx->color4f = SkColor4f_from_SkColor(paint.getColor(), dst);
+ ctx->ctable = pm.ctable() ? pm.ctable()->readColors() : nullptr;
ctx->stride = pm.rowBytesAsPixels();
+ ctx->color4f = SkColor4f_from_SkColor(paint.getColor(), dst);
ctx->width = (float)pm.width();
ctx->height = (float)pm.height();
+ ctx->state = std::move(state); // Extend lifetime to match the pipeline's.
if (matrix.asAffine(ctx->matrix)) {
p->append(SkRasterPipeline::matrix_2x3, ctx->matrix);
} else {
diff --git a/src/image/SkImageShaderContext.h b/src/image/SkImageShaderContext.h
index 24f17db..7a8ba63 100644
--- a/src/image/SkImageShaderContext.h
+++ b/src/image/SkImageShaderContext.h
@@ -17,21 +17,21 @@
// Otherwise, completely uninteresting.
struct SkImageShaderContext {
- std::unique_ptr<SkBitmapController::State> state;
+ const void* pixels;
+ const uint32_t* ctable;
+ int stride;
+ SkColor4f color4f;
+ float width;
+ float height;
+ float matrix[9];
+ float x[8];
+ float y[8];
+ float fx[8];
+ float fy[8];
+ float scalex[8];
+ float scaley[8];
- const void* pixels;
- SkColorTable* ctable;
- SkColor4f color4f;
- int stride;
- float width;
- float height;
- float matrix[9];
- float x[8];
- float y[8];
- float fx[8];
- float fy[8];
- float scalex[8];
- float scaley[8];
+ std::unique_ptr<SkBitmapController::State> state;
};
#endif//SkImageShaderContext_DEFINED
diff --git a/src/opts/SkRasterPipeline_opts.h b/src/opts/SkRasterPipeline_opts.h
index 2da04ae..3310990 100644
--- a/src/opts/SkRasterPipeline_opts.h
+++ b/src/opts/SkRasterPipeline_opts.h
@@ -1065,7 +1065,7 @@
SkNi offset = offset_and_ptr(&p, ctx, r, g);
SkNi ix = SkNx_cast<int>(gather(tail, p, offset));
- from_8888(gather(tail, ctx->ctable->readColors(), ix), &r, &g, &b, &a);
+ from_8888(gather(tail, ctx->ctable, ix), &r, &g, &b, &a);
}
STAGE_CTX(gather_g8, const SkImageShaderContext*) {
const uint8_t* p;