plumb matrix provider through skvm shaders

Trickiest bit is probably the override provider in kSampleExplicit?

Change-Id: Ib0ada157825c844ff4b7b43efac9f27f3552f3d1
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/297775
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
This commit is contained in:
Mike Klein 2020-06-19 11:29:13 -05:00 committed by Skia Commit-Bot
parent 2a4871b80c
commit e81b10834e
21 changed files with 84 additions and 73 deletions

View File

@ -736,9 +736,8 @@ SkBlitter* SkBlitter::Choose(const SkPixmap& device,
paint.writable()->setDither(false); paint.writable()->setDither(false);
} }
SkMatrix ctm = matrixProvider.localToDevice();
if (gUseSkVMBlitter) { if (gUseSkVMBlitter) {
if (auto blitter = SkCreateSkVMBlitter(device, *paint, ctm, if (auto blitter = SkCreateSkVMBlitter(device, *paint, matrixProvider,
alloc, clipShader)) { alloc, clipShader)) {
return blitter; return blitter;
} }
@ -751,13 +750,14 @@ SkBlitter* SkBlitter::Choose(const SkPixmap& device,
alloc, clipShader)) { alloc, clipShader)) {
return blitter; return blitter;
} }
if (auto blitter = SkCreateSkVMBlitter(device, *paint, ctm, if (auto blitter = SkCreateSkVMBlitter(device, *paint, matrixProvider,
alloc, clipShader)) { alloc, clipShader)) {
return blitter; return blitter;
} }
return alloc->make<SkNullBlitter>(); return alloc->make<SkNullBlitter>();
}; };
SkMatrix ctm = matrixProvider.localToDevice();
// We'll end here for many interesting cases: color spaces, color filters, most color types. // We'll end here for many interesting cases: color spaces, color filters, most color types.
if (UseRasterPipelineBlitter(device, *paint, ctm) || clipShader) { if (UseRasterPipelineBlitter(device, *paint, ctm) || clipShader) {
return create_SkRP_or_SkVMBlitter(); return create_SkRP_or_SkVMBlitter();

View File

@ -177,7 +177,7 @@ SkBlitter* SkCreateRasterPipelineBlitter(const SkPixmap&, const SkPaint&,
SkBlitter* SkCreateSkVMBlitter(const SkPixmap&, SkBlitter* SkCreateSkVMBlitter(const SkPixmap&,
const SkPaint&, const SkPaint&,
const SkMatrix& ctm, const SkMatrixProvider&,
SkArenaAlloc*, SkArenaAlloc*,
sk_sp<SkShader> clipShader); sk_sp<SkShader> clipShader);

View File

@ -411,6 +411,7 @@ SkRuntimeEffect::ByteCodeResult SkRuntimeEffect::toByteCode(const void* inputs)
static std::vector<skvm::F32> program_fn(skvm::Builder* p, static std::vector<skvm::F32> program_fn(skvm::Builder* p,
const SkSL::ByteCodeFunction& fn, const SkSL::ByteCodeFunction& fn,
const std::vector<skvm::F32>& uniform, const std::vector<skvm::F32>& uniform,
const SkMatrixProvider& matrices,
std::vector<skvm::F32> stack, std::vector<skvm::F32> stack,
/*these parameters are used to call program() on children*/ /*these parameters are used to call program() on children*/
const std::vector<sk_sp<SkShader>>& children, const std::vector<sk_sp<SkShader>>& children,
@ -481,8 +482,9 @@ static std::vector<skvm::F32> program_fn(skvm::Builder* p,
skvm::F32 y = pop(), skvm::F32 y = pop(),
x = pop(); x = pop();
SkOverrideDeviceMatrixProvider mats{matrices, SkMatrix::I()};
skvm::Color c = as_SB(children[ix])->program(p, x,y,paint, skvm::Color c = as_SB(children[ix])->program(p, x,y,paint,
SkMatrix::I(), nullptr, mats, nullptr,
quality, dst, quality, dst,
uniforms, alloc); uniforms, alloc);
if (!c) { if (!c) {
@ -798,7 +800,7 @@ public:
} }
std::vector<skvm::F32> stack = std::vector<skvm::F32> stack =
program_fn(p, *fn, uniform, {c.r, c.g, c.b, c.a}, program_fn(p, *fn, uniform, SkSimpleMatrixProvider{SkMatrix::I()}, {c.r, c.g, c.b, c.a},
/* the remaining parameters are for shaders only and won't be used here */ /* the remaining parameters are for shaders only and won't be used here */
{},{},{},{},{},{},{},{}); {},{},{},{},{},{},{},{});
@ -990,7 +992,7 @@ public:
} }
skvm::Color onProgram(skvm::Builder* p, skvm::F32 x, skvm::F32 y, skvm::Color paint, skvm::Color onProgram(skvm::Builder* p, skvm::F32 x, skvm::F32 y, skvm::Color paint,
const SkMatrix& ctm, const SkMatrix* localM, const SkMatrixProvider& matrices, const SkMatrix* localM,
SkFilterQuality quality, const SkColorInfo& dst, SkFilterQuality quality, const SkColorInfo& dst,
skvm::Uniforms* uniforms, SkArenaAlloc* alloc) const override { skvm::Uniforms* uniforms, SkArenaAlloc* alloc) const override {
const SkSL::ByteCode* bc = this->byteCode(); const SkSL::ByteCode* bc = this->byteCode();
@ -1003,11 +1005,7 @@ public:
return {}; return {};
} }
// TODO: Eventually, plumb SkMatrixProvider here (instead of just ctm). For now, we will sk_sp<SkData> inputs = this->getUniforms(matrices, dst.colorSpace());
// simply fail if our effect requires any marked matrices (SkSimpleMatrixProvider always
// returns false in getLocalToMarker).
SkSimpleMatrixProvider matrixProvider(SkMatrix::I());
sk_sp<SkData> inputs = this->getUniforms(matrixProvider, dst.colorSpace());
if (!inputs) { if (!inputs) {
return {}; return {};
} }
@ -1020,13 +1018,13 @@ public:
} }
SkMatrix inv; SkMatrix inv;
if (!this->computeTotalInverse(ctm, localM, &inv)) { if (!this->computeTotalInverse(matrices.localToDevice(), localM, &inv)) {
return {}; return {};
} }
SkShaderBase::ApplyMatrix(p,inv, &x,&y,uniforms); SkShaderBase::ApplyMatrix(p,inv, &x,&y,uniforms);
std::vector<skvm::F32> stack = std::vector<skvm::F32> stack =
program_fn(p, *fn, uniform, {x,y, paint.r, paint.g, paint.b, paint.a}, program_fn(p, *fn, uniform, matrices, {x,y, paint.r, paint.g, paint.b, paint.a},
/*parameters for calling program() on children*/ /*parameters for calling program() on children*/
fChildren, x,y,paint, quality,dst, uniforms,alloc); fChildren, x,y,paint, quality,dst, uniforms,alloc);

View File

@ -40,7 +40,7 @@ namespace {
SkBlendMode blendMode; SkBlendMode blendMode;
Coverage coverage; Coverage coverage;
SkFilterQuality quality; SkFilterQuality quality;
SkMatrix ctm; const SkMatrixProvider& matrices;
Params withCoverage(Coverage c) const { Params withCoverage(Coverage c) const {
Params p = *this; Params p = *this;
@ -59,7 +59,7 @@ namespace {
blendMode, blendMode,
coverage; coverage;
uint32_t padding{0}; uint32_t padding{0};
// Params::quality and Params::ctm are only passed to {shader,clip}->program(), // Params::quality and Params::matrices are only passed to {shader,clip}->program(),
// not used here by the blitter itself. No need to include them in the key; // not used here by the blitter itself. No need to include them in the key;
// they'll be folded into the shader key if used. // they'll be folded into the shader key if used.
@ -130,7 +130,7 @@ namespace {
uint64_t hash = 0; uint64_t hash = 0;
if (auto c = sb->program(&p, if (auto c = sb->program(&p,
x,y, paint, x,y, paint,
params.ctm, /*localM=*/nullptr, params.matrices, /*localM=*/nullptr,
params.quality, params.dst, params.quality, params.dst,
uniforms,alloc)) { uniforms,alloc)) {
hash = p.hash(); hash = p.hash();
@ -208,7 +208,7 @@ namespace {
}; };
skvm::Color src = as_SB(params.shader)->program(p, x,y, paint, skvm::Color src = as_SB(params.shader)->program(p, x,y, paint,
params.ctm, /*localM=*/nullptr, params.matrices, /*localM=*/nullptr,
params.quality, params.dst, params.quality, params.dst,
uniforms, alloc); uniforms, alloc);
SkASSERT(src); SkASSERT(src);
@ -275,7 +275,7 @@ namespace {
if (params.clip) { if (params.clip) {
skvm::Color clip = as_SB(params.clip)->program(p, x,y, paint, skvm::Color clip = as_SB(params.clip)->program(p, x,y, paint,
params.ctm, /*localM=*/nullptr, params.matrices, /*localM=*/nullptr,
params.quality, params.dst, params.quality, params.dst,
uniforms, alloc); uniforms, alloc);
SkAssertResult(clip); SkAssertResult(clip);
@ -429,12 +429,12 @@ namespace {
bool isOpaque() const override { return fShader->isOpaque(); } bool isOpaque() const override { return fShader->isOpaque(); }
skvm::Color onProgram(skvm::Builder* p, skvm::F32 x, skvm::F32 y, skvm::Color paint, skvm::Color onProgram(skvm::Builder* p, skvm::F32 x, skvm::F32 y, skvm::Color paint,
const SkMatrix& ctm, const SkMatrix* localM, const SkMatrixProvider& matrices, const SkMatrix* localM,
SkFilterQuality quality, const SkColorInfo& dst, SkFilterQuality quality, const SkColorInfo& dst,
skvm::Uniforms* uniforms, SkArenaAlloc* alloc) const override { skvm::Uniforms* uniforms, SkArenaAlloc* alloc) const override {
// Run our wrapped shader. // Run our wrapped shader.
skvm::Color c = as_SB(fShader)->program(p, x,y, paint, skvm::Color c = as_SB(fShader)->program(p, x,y, paint,
ctm,localM, quality,dst, uniforms,alloc); matrices,localM, quality,dst, uniforms,alloc);
if (!c) { if (!c) {
return {}; return {};
} }
@ -501,7 +501,7 @@ namespace {
static Params effective_params(const SkPixmap& device, static Params effective_params(const SkPixmap& device,
const SkPaint& paint, const SkPaint& paint,
const SkMatrix& ctm, const SkMatrixProvider& matrices,
sk_sp<SkShader> clip) { sk_sp<SkShader> clip) {
// Color filters have been handled for us by SkBlitter::Choose(). // Color filters have been handled for us by SkBlitter::Choose().
SkASSERT(!paint.getColorFilter()); SkASSERT(!paint.getColorFilter());
@ -547,7 +547,7 @@ namespace {
blendMode, blendMode,
Coverage::Full, // Placeholder... withCoverage() will change as needed. Coverage::Full, // Placeholder... withCoverage() will change as needed.
paint.getFilterQuality(), paint.getFilterQuality(),
ctm, matrices,
}; };
} }
@ -555,12 +555,12 @@ namespace {
public: public:
Blitter(const SkPixmap& device, Blitter(const SkPixmap& device,
const SkPaint& paint, const SkPaint& paint,
const SkMatrix& ctm, const SkMatrixProvider& matrices,
sk_sp<SkShader> clip, sk_sp<SkShader> clip,
bool* ok) bool* ok)
: fDevice(device) : fDevice(device)
, fUniforms(kBlitterUniformsCount) , fUniforms(kBlitterUniformsCount)
, fParams(effective_params(device, paint, ctm, std::move(clip))) , fParams(effective_params(device, paint, matrices, std::move(clip)))
, fKey(cache_key(fParams, &fUniforms, &fAlloc, ok)) , fKey(cache_key(fParams, &fUniforms, &fAlloc, ok))
, fPaint([&]{ , fPaint([&]{
SkColor4f color = paint.getColor4f(); SkColor4f color = paint.getColor4f();
@ -737,10 +737,10 @@ namespace {
SkBlitter* SkCreateSkVMBlitter(const SkPixmap& device, SkBlitter* SkCreateSkVMBlitter(const SkPixmap& device,
const SkPaint& paint, const SkPaint& paint,
const SkMatrix& ctm, const SkMatrixProvider& matrices,
SkArenaAlloc* alloc, SkArenaAlloc* alloc,
sk_sp<SkShader> clip) { sk_sp<SkShader> clip) {
bool ok = true; bool ok = true;
auto blitter = alloc->make<Blitter>(device, paint, ctm, std::move(clip), &ok); auto blitter = alloc->make<Blitter>(device, paint, matrices, std::move(clip), &ok);
return ok ? blitter : nullptr; return ok ? blitter : nullptr;
} }

View File

@ -63,11 +63,14 @@ bool SkColorFilterShader::onAppendStages(const SkStageRec& rec) const {
skvm::Color SkColorFilterShader::onProgram(skvm::Builder* p, skvm::Color SkColorFilterShader::onProgram(skvm::Builder* p,
skvm::F32 x, skvm::F32 y, skvm::Color paint, skvm::F32 x, skvm::F32 y, skvm::Color paint,
const SkMatrix& ctm, const SkMatrix* localM, const SkMatrixProvider& matrices, const SkMatrix* localM,
SkFilterQuality quality, const SkColorInfo& dst, SkFilterQuality quality, const SkColorInfo& dst,
skvm::Uniforms* uniforms, SkArenaAlloc* alloc) const { skvm::Uniforms* uniforms, SkArenaAlloc* alloc) const {
// Run the shader. // Run the shader.
skvm::Color c = as_SB(fShader)->program(p, x,y, paint, ctm,localM, quality,dst, uniforms,alloc); skvm::Color c = as_SB(fShader)->program(p, x,y, paint,
matrices,localM,
quality,dst,
uniforms,alloc);
if (!c) { if (!c) {
return {}; return {};
} }

View File

@ -27,7 +27,7 @@ private:
bool onAppendStages(const SkStageRec&) const override; bool onAppendStages(const SkStageRec&) const override;
skvm::Color onProgram(skvm::Builder*, skvm::F32 x, skvm::F32 y, skvm::Color paint, skvm::Color onProgram(skvm::Builder*, skvm::F32 x, skvm::F32 y, skvm::Color paint,
const SkMatrix& ctm, const SkMatrix* localM, const SkMatrixProvider&, const SkMatrix* localM,
SkFilterQuality quality, const SkColorInfo& dst, SkFilterQuality quality, const SkColorInfo& dst,
skvm::Uniforms* uniforms, SkArenaAlloc*) const override; skvm::Uniforms* uniforms, SkArenaAlloc*) const override;

View File

@ -93,7 +93,7 @@ bool SkColor4Shader::onAppendStages(const SkStageRec& rec) const {
skvm::Color SkColorShader::onProgram(skvm::Builder* p, skvm::Color SkColorShader::onProgram(skvm::Builder* p,
skvm::F32 /*x*/, skvm::F32 /*y*/, skvm::Color /*paint*/, skvm::F32 /*x*/, skvm::F32 /*y*/, skvm::Color /*paint*/,
const SkMatrix& /*ctm*/, const SkMatrix* /*localM*/, const SkMatrixProvider&, const SkMatrix* /*localM*/,
SkFilterQuality /*quality*/, const SkColorInfo& dst, SkFilterQuality /*quality*/, const SkColorInfo& dst,
skvm::Uniforms* uniforms, SkArenaAlloc*) const { skvm::Uniforms* uniforms, SkArenaAlloc*) const {
return p->uniformPremul(SkColor4f::FromColor(fColor), sk_srgb_singleton(), return p->uniformPremul(SkColor4f::FromColor(fColor), sk_srgb_singleton(),
@ -101,7 +101,7 @@ skvm::Color SkColorShader::onProgram(skvm::Builder* p,
} }
skvm::Color SkColor4Shader::onProgram(skvm::Builder* p, skvm::Color SkColor4Shader::onProgram(skvm::Builder* p,
skvm::F32 /*x*/, skvm::F32 /*y*/, skvm::Color /*paint*/, skvm::F32 /*x*/, skvm::F32 /*y*/, skvm::Color /*paint*/,
const SkMatrix& /*ctm*/, const SkMatrix* /*localM*/, const SkMatrixProvider&, const SkMatrix* /*localM*/,
SkFilterQuality /*quality*/, const SkColorInfo& dst, SkFilterQuality /*quality*/, const SkColorInfo& dst,
skvm::Uniforms* uniforms, SkArenaAlloc*) const { skvm::Uniforms* uniforms, SkArenaAlloc*) const {
return p->uniformPremul(fColor, fColorSpace.get(), return p->uniformPremul(fColor, fColorSpace.get(),

View File

@ -45,7 +45,7 @@ private:
bool onAppendStages(const SkStageRec&) const override; bool onAppendStages(const SkStageRec&) const override;
skvm::Color onProgram(skvm::Builder*, skvm::F32 x, skvm::F32 y, skvm::Color paint, skvm::Color onProgram(skvm::Builder*, skvm::F32 x, skvm::F32 y, skvm::Color paint,
const SkMatrix& ctm, const SkMatrix* localM, const SkMatrixProvider&, const SkMatrix* localM,
SkFilterQuality quality, const SkColorInfo& dst, SkFilterQuality quality, const SkColorInfo& dst,
skvm::Uniforms* uniforms, SkArenaAlloc*) const override; skvm::Uniforms* uniforms, SkArenaAlloc*) const override;
@ -70,7 +70,7 @@ private:
bool onAppendStages(const SkStageRec&) const override; bool onAppendStages(const SkStageRec&) const override;
skvm::Color onProgram(skvm::Builder*, skvm::F32 x, skvm::F32 y, skvm::Color paint, skvm::Color onProgram(skvm::Builder*, skvm::F32 x, skvm::F32 y, skvm::Color paint,
const SkMatrix& ctm, const SkMatrix* localM, const SkMatrixProvider&, const SkMatrix* localM,
SkFilterQuality quality, const SkColorInfo& dst, SkFilterQuality quality, const SkColorInfo& dst,
skvm::Uniforms* uniforms, SkArenaAlloc*) const override; skvm::Uniforms* uniforms, SkArenaAlloc*) const override;

View File

@ -128,12 +128,12 @@ bool SkShader_Blend::onAppendStages(const SkStageRec& orig_rec) const {
} }
skvm::Color SkShader_Blend::onProgram(skvm::Builder* p, skvm::F32 x, skvm::F32 y, skvm::Color paint, skvm::Color SkShader_Blend::onProgram(skvm::Builder* p, skvm::F32 x, skvm::F32 y, skvm::Color paint,
const SkMatrix& ctm, const SkMatrix* localM, const SkMatrixProvider& matrices, const SkMatrix* localM,
SkFilterQuality q, const SkColorInfo& dst, SkFilterQuality q, const SkColorInfo& dst,
skvm::Uniforms* uniforms, SkArenaAlloc* alloc) const { skvm::Uniforms* uniforms, SkArenaAlloc* alloc) const {
skvm::Color d,s; skvm::Color d,s;
if ((d = as_SB(fDst)->program(p, x,y, paint, ctm,localM, q, dst, uniforms, alloc)) && if ((d = as_SB(fDst)->program(p, x,y, paint, matrices,localM, q, dst, uniforms, alloc)) &&
(s = as_SB(fSrc)->program(p, x,y, paint, ctm,localM, q, dst, uniforms, alloc))) (s = as_SB(fSrc)->program(p, x,y, paint, matrices,localM, q, dst, uniforms, alloc)))
{ {
return p->blend(fMode, s,d); return p->blend(fMode, s,d);
} }
@ -168,12 +168,12 @@ bool SkShader_Lerp::onAppendStages(const SkStageRec& orig_rec) const {
} }
skvm::Color SkShader_Lerp::onProgram(skvm::Builder* p, skvm::F32 x, skvm::F32 y, skvm::Color paint, skvm::Color SkShader_Lerp::onProgram(skvm::Builder* p, skvm::F32 x, skvm::F32 y, skvm::Color paint,
const SkMatrix& ctm, const SkMatrix* localM, const SkMatrixProvider& matrices, const SkMatrix* localM,
SkFilterQuality q, const SkColorInfo& dst, SkFilterQuality q, const SkColorInfo& dst,
skvm::Uniforms* uniforms, SkArenaAlloc* alloc) const { skvm::Uniforms* uniforms, SkArenaAlloc* alloc) const {
skvm::Color d,s; skvm::Color d,s;
if ((d = as_SB(fDst)->program(p, x,y, paint, ctm,localM, q, dst, uniforms, alloc)) && if ((d = as_SB(fDst)->program(p, x,y, paint, matrices,localM, q, dst, uniforms, alloc)) &&
(s = as_SB(fSrc)->program(p, x,y, paint, ctm,localM, q, dst, uniforms, alloc))) (s = as_SB(fSrc)->program(p, x,y, paint, matrices,localM, q, dst, uniforms, alloc)))
{ {
auto t = p->uniformF(uniforms->pushF(fWeight)); auto t = p->uniformF(uniforms->pushF(fWeight));
return { return {

View File

@ -28,7 +28,7 @@ protected:
void flatten(SkWriteBuffer&) const override; void flatten(SkWriteBuffer&) const override;
bool onAppendStages(const SkStageRec&) const override; bool onAppendStages(const SkStageRec&) const override;
skvm::Color onProgram(skvm::Builder*, skvm::F32 x, skvm::F32 y, skvm::Color paint, skvm::Color onProgram(skvm::Builder*, skvm::F32 x, skvm::F32 y, skvm::Color paint,
const SkMatrix& ctm, const SkMatrix* localM, const SkMatrixProvider&, const SkMatrix* localM,
SkFilterQuality, const SkColorInfo& dst, SkFilterQuality, const SkColorInfo& dst,
skvm::Uniforms*, SkArenaAlloc*) const override; skvm::Uniforms*, SkArenaAlloc*) const override;
@ -61,7 +61,7 @@ protected:
void flatten(SkWriteBuffer&) const override; void flatten(SkWriteBuffer&) const override;
bool onAppendStages(const SkStageRec&) const override; bool onAppendStages(const SkStageRec&) const override;
skvm::Color onProgram(skvm::Builder*, skvm::F32 x, skvm::F32 y, skvm::Color paint, skvm::Color onProgram(skvm::Builder*, skvm::F32 x, skvm::F32 y, skvm::Color paint,
const SkMatrix& ctm, const SkMatrix* localM, const SkMatrixProvider&, const SkMatrix* localM,
SkFilterQuality, const SkColorInfo& dst, SkFilterQuality, const SkColorInfo& dst,
skvm::Uniforms*, SkArenaAlloc*) const override; skvm::Uniforms*, SkArenaAlloc*) const override;

View File

@ -37,9 +37,10 @@ protected:
return false; return false;
} }
skvm::Color onProgram(skvm::Builder*, skvm::F32, skvm::F32, skvm::Color, const SkMatrix&, skvm::Color onProgram(skvm::Builder*, skvm::F32, skvm::F32, skvm::Color,
const SkMatrix*, SkFilterQuality, const SkColorInfo&, skvm::Uniforms*, const SkMatrixProvider&, const SkMatrix*,
SkArenaAlloc*) const override; SkFilterQuality, const SkColorInfo&,
skvm::Uniforms*, SkArenaAlloc*) const override;
private: private:
SK_FLATTENABLE_HOOKS(SkEmptyShader) SK_FLATTENABLE_HOOKS(SkEmptyShader)

View File

@ -640,13 +640,13 @@ SkStageUpdater* SkImageShader::onAppendUpdatableStages(const SkStageRec& rec) co
} }
skvm::Color SkImageShader::onProgram(skvm::Builder* p, skvm::F32 x, skvm::F32 y, skvm::Color paint, skvm::Color SkImageShader::onProgram(skvm::Builder* p, skvm::F32 x, skvm::F32 y, skvm::Color paint,
const SkMatrix& ctm, const SkMatrix* localM, const SkMatrixProvider& matrices, const SkMatrix* localM,
SkFilterQuality quality, const SkColorInfo& dst, SkFilterQuality quality, const SkColorInfo& dst,
skvm::Uniforms* uniforms, SkArenaAlloc* alloc) const { skvm::Uniforms* uniforms, SkArenaAlloc* alloc) const {
quality = this->resolveFiltering(quality); quality = this->resolveFiltering(quality);
SkMatrix inv; SkMatrix inv;
if (!this->computeTotalInverse(ctm, localM, &inv)) { if (!this->computeTotalInverse(matrices.localToDevice(), localM, &inv)) {
return {}; return {};
} }

View File

@ -59,7 +59,7 @@ private:
SkStageUpdater* onAppendUpdatableStages(const SkStageRec&) const override; SkStageUpdater* onAppendUpdatableStages(const SkStageRec&) const override;
skvm::Color onProgram(skvm::Builder*, skvm::F32 x, skvm::F32 y, skvm::Color paint, skvm::Color onProgram(skvm::Builder*, skvm::F32 x, skvm::F32 y, skvm::Color paint,
const SkMatrix& ctm, const SkMatrix* localM, const SkMatrixProvider&, const SkMatrix* localM,
SkFilterQuality quality, const SkColorInfo& dst, SkFilterQuality quality, const SkColorInfo& dst,
skvm::Uniforms* uniforms, SkArenaAlloc*) const override; skvm::Uniforms* uniforms, SkArenaAlloc*) const override;

View File

@ -79,14 +79,17 @@ bool SkLocalMatrixShader::onAppendStages(const SkStageRec& rec) const {
skvm::Color SkLocalMatrixShader::onProgram(skvm::Builder* p, skvm::Color SkLocalMatrixShader::onProgram(skvm::Builder* p,
skvm::F32 x, skvm::F32 y, skvm::Color paint, skvm::F32 x, skvm::F32 y, skvm::Color paint,
const SkMatrix& ctm, const SkMatrix* localM, const SkMatrixProvider& matrices, const SkMatrix* localM,
SkFilterQuality quality, const SkColorInfo& dst, SkFilterQuality quality, const SkColorInfo& dst,
skvm::Uniforms* uniforms, SkArenaAlloc* alloc) const { skvm::Uniforms* uniforms, SkArenaAlloc* alloc) const {
SkTCopyOnFirstWrite<SkMatrix> lm(this->getLocalMatrix()); SkTCopyOnFirstWrite<SkMatrix> lm(this->getLocalMatrix());
if (localM) { if (localM) {
lm.writable()->preConcat(*localM); lm.writable()->preConcat(*localM);
} }
return as_SB(fProxyShader)->program(p, x,y, paint, ctm,lm.get(), quality,dst, uniforms,alloc); return as_SB(fProxyShader)->program(p, x,y, paint,
matrices,lm.get(),
quality,dst,
uniforms,alloc);
} }
sk_sp<SkShader> SkShader::makeWithLocalMatrix(const SkMatrix& localMatrix) const { sk_sp<SkShader> SkShader::makeWithLocalMatrix(const SkMatrix& localMatrix) const {
@ -154,10 +157,14 @@ protected:
} }
skvm::Color onProgram(skvm::Builder* p, skvm::F32 x, skvm::F32 y, skvm::Color paint, skvm::Color onProgram(skvm::Builder* p, skvm::F32 x, skvm::F32 y, skvm::Color paint,
const SkMatrix& ctm, const SkMatrix* localM, const SkMatrixProvider& matrices, const SkMatrix* localM,
SkFilterQuality quality, const SkColorInfo& dst, SkFilterQuality quality, const SkColorInfo& dst,
skvm::Uniforms* uniforms, SkArenaAlloc* alloc) const override { skvm::Uniforms* uniforms, SkArenaAlloc* alloc) const override {
return as_SB(fProxyShader)->program(p, x,y,paint, fCTM,localM, quality,dst, uniforms,alloc); SkOverrideDeviceMatrixProvider matrixProvider(matrices, fCTM);
return as_SB(fProxyShader)->program(p, x,y,paint,
matrixProvider,localM,
quality,dst,
uniforms,alloc);
} }
private: private:

View File

@ -49,7 +49,7 @@ protected:
bool onAppendStages(const SkStageRec&) const override; bool onAppendStages(const SkStageRec&) const override;
skvm::Color onProgram(skvm::Builder*, skvm::F32 x, skvm::F32 y, skvm::Color paint, skvm::Color onProgram(skvm::Builder*, skvm::F32 x, skvm::F32 y, skvm::Color paint,
const SkMatrix& ctm, const SkMatrix* localM, const SkMatrixProvider&, const SkMatrix* localM,
SkFilterQuality quality, const SkColorInfo& dst, SkFilterQuality quality, const SkColorInfo& dst,
skvm::Uniforms* uniforms, SkArenaAlloc*) const override; skvm::Uniforms* uniforms, SkArenaAlloc*) const override;

View File

@ -276,19 +276,20 @@ bool SkPictureShader::onAppendStages(const SkStageRec& rec) const {
skvm::Color SkPictureShader::onProgram(skvm::Builder* p, skvm::Color SkPictureShader::onProgram(skvm::Builder* p,
skvm::F32 x, skvm::F32 y, skvm::Color paint, skvm::F32 x, skvm::F32 y, skvm::Color paint,
const SkMatrix& ctm, const SkMatrix* localM, const SkMatrixProvider& matrices, const SkMatrix* localM,
SkFilterQuality quality, const SkColorInfo& dst, SkFilterQuality quality, const SkColorInfo& dst,
skvm::Uniforms* uniforms, SkArenaAlloc* alloc) const { skvm::Uniforms* uniforms, SkArenaAlloc* alloc) const {
auto lm = this->totalLocalMatrix(localM); auto lm = this->totalLocalMatrix(localM);
// Keep bitmapShader alive by using alloc instead of stack memory // Keep bitmapShader alive by using alloc instead of stack memory
auto& bitmapShader = *alloc->make<sk_sp<SkShader>>(); auto& bitmapShader = *alloc->make<sk_sp<SkShader>>();
bitmapShader = this->refBitmapShader(ctm, &lm, dst.colorType(), dst.colorSpace()); bitmapShader = this->refBitmapShader(matrices.localToDevice(), &lm,
dst.colorType(), dst.colorSpace());
if (!bitmapShader) { if (!bitmapShader) {
return {}; return {};
} }
return as_SB(bitmapShader)->program(p, x,y, paint, ctm, lm, quality, dst, uniforms, alloc); return as_SB(bitmapShader)->program(p, x,y, paint, matrices, lm, quality, dst, uniforms, alloc);
} }
///////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////

View File

@ -38,7 +38,7 @@ protected:
void flatten(SkWriteBuffer&) const override; void flatten(SkWriteBuffer&) const override;
bool onAppendStages(const SkStageRec&) const override; bool onAppendStages(const SkStageRec&) const override;
skvm::Color onProgram(skvm::Builder*, skvm::F32 x, skvm::F32 y, skvm::Color paint, skvm::Color onProgram(skvm::Builder*, skvm::F32 x, skvm::F32 y, skvm::Color paint,
const SkMatrix& ctm, const SkMatrix* localM, const SkMatrixProvider&, const SkMatrix* localM,
SkFilterQuality quality, const SkColorInfo& dst, SkFilterQuality quality, const SkColorInfo& dst,
skvm::Uniforms* uniforms, SkArenaAlloc* alloc) const override; skvm::Uniforms* uniforms, SkArenaAlloc* alloc) const override;

View File

@ -196,7 +196,7 @@ bool SkShaderBase::onAppendStages(const SkStageRec& rec) const {
} }
skvm::Color SkShaderBase::program(skvm::Builder* p, skvm::F32 x, skvm::F32 y, skvm::Color paint, skvm::Color SkShaderBase::program(skvm::Builder* p, skvm::F32 x, skvm::F32 y, skvm::Color paint,
const SkMatrix& ctm, const SkMatrix* localM, const SkMatrixProvider& matrices, const SkMatrix* localM,
SkFilterQuality quality, const SkColorInfo& dst, SkFilterQuality quality, const SkColorInfo& dst,
skvm::Uniforms* uniforms, SkArenaAlloc* alloc) const { skvm::Uniforms* uniforms, SkArenaAlloc* alloc) const {
// Force opaque alpha for all opaque shaders. // Force opaque alpha for all opaque shaders.
@ -211,7 +211,7 @@ skvm::Color SkShaderBase::program(skvm::Builder* p, skvm::F32 x, skvm::F32 y, sk
// shader program hash and blitter Key. This makes it safe for us to use // shader program hash and blitter Key. This makes it safe for us to use
// that bit to make decisions when constructing an SkVMBlitter, like doing // that bit to make decisions when constructing an SkVMBlitter, like doing
// SrcOver -> Src strength reduction. // SrcOver -> Src strength reduction.
if (auto color = this->onProgram(p, x,y, paint, ctm,localM, quality,dst, uniforms,alloc)) { if (auto color = this->onProgram(p, x,y, paint, matrices,localM, quality,dst, uniforms,alloc)) {
if (this->isOpaque()) { if (this->isOpaque()) {
color.a = p->splat(1.0f); color.a = p->splat(1.0f);
} }
@ -221,7 +221,7 @@ skvm::Color SkShaderBase::program(skvm::Builder* p, skvm::F32 x, skvm::F32 y, sk
} }
skvm::Color SkShaderBase::onProgram(skvm::Builder*, skvm::F32 x, skvm::F32 y, skvm::Color paint, skvm::Color SkShaderBase::onProgram(skvm::Builder*, skvm::F32 x, skvm::F32 y, skvm::Color paint,
const SkMatrix& ctm, const SkMatrix* localM, const SkMatrixProvider&, const SkMatrix* localM,
SkFilterQuality quality, const SkColorInfo& dst, SkFilterQuality quality, const SkColorInfo& dst,
skvm::Uniforms* uniforms, SkArenaAlloc* alloc) const { skvm::Uniforms* uniforms, SkArenaAlloc* alloc) const {
//SkDebugf("cannot onProgram %s\n", this->getTypeName()); //SkDebugf("cannot onProgram %s\n", this->getTypeName());
@ -262,8 +262,9 @@ void SkShaderBase::ApplyMatrix(skvm::Builder* p, const SkMatrix& m,
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
skvm::Color SkEmptyShader::onProgram(skvm::Builder*, skvm::F32, skvm::F32, skvm::Color, skvm::Color SkEmptyShader::onProgram(skvm::Builder*, skvm::F32, skvm::F32, skvm::Color,
const SkMatrix&, const SkMatrix*, SkFilterQuality, const SkMatrixProvider&, const SkMatrix*,
const SkColorInfo&, skvm::Uniforms*, SkArenaAlloc*) const { SkFilterQuality, const SkColorInfo&,
skvm::Uniforms*, SkArenaAlloc*) const {
return {}; // signal failure return {}; // signal failure
} }

View File

@ -212,7 +212,7 @@ public:
} }
skvm::Color program(skvm::Builder*, skvm::F32 x, skvm::F32 y, skvm::Color paint, skvm::Color program(skvm::Builder*, skvm::F32 x, skvm::F32 y, skvm::Color paint,
const SkMatrix& ctm, const SkMatrix* localM, const SkMatrixProvider&, const SkMatrix* localM,
SkFilterQuality quality, const SkColorInfo& dst, SkFilterQuality quality, const SkColorInfo& dst,
skvm::Uniforms* uniforms, SkArenaAlloc* alloc) const; skvm::Uniforms* uniforms, SkArenaAlloc* alloc) const;
@ -248,7 +248,7 @@ private:
SkMatrix fLocalMatrix; SkMatrix fLocalMatrix;
virtual skvm::Color onProgram(skvm::Builder*, skvm::F32 x, skvm::F32 y, skvm::Color paint, virtual skvm::Color onProgram(skvm::Builder*, skvm::F32 x, skvm::F32 y, skvm::Color paint,
const SkMatrix& ctm, const SkMatrix* localM, const SkMatrixProvider&, const SkMatrix* localM,
SkFilterQuality quality, const SkColorInfo& dst, SkFilterQuality quality, const SkColorInfo& dst,
skvm::Uniforms* uniforms, SkArenaAlloc* alloc) const; skvm::Uniforms* uniforms, SkArenaAlloc* alloc) const;

View File

@ -421,11 +421,11 @@ bool SkGradientShaderBase::onAppendStages(const SkStageRec& rec) const {
skvm::Color SkGradientShaderBase::onProgram(skvm::Builder* p, skvm::Color SkGradientShaderBase::onProgram(skvm::Builder* p,
skvm::F32 x, skvm::F32 y, skvm::Color /*paint*/, skvm::F32 x, skvm::F32 y, skvm::Color /*paint*/,
const SkMatrix& ctm, const SkMatrix* localM, const SkMatrixProvider& mats, const SkMatrix* localM,
SkFilterQuality quality, const SkColorInfo& dstInfo, SkFilterQuality quality, const SkColorInfo& dstInfo,
skvm::Uniforms* uniforms, SkArenaAlloc* alloc) const { skvm::Uniforms* uniforms, SkArenaAlloc* alloc) const {
SkMatrix inv; SkMatrix inv;
if (!this->computeTotalInverse(ctm, localM, &inv)) { if (!this->computeTotalInverse(mats.localToDevice(), localM, &inv)) {
return {}; return {};
} }
inv.postConcat(fPtsToUnit); inv.postConcat(fPtsToUnit);

View File

@ -80,7 +80,7 @@ protected:
bool onAppendStages(const SkStageRec&) const override; bool onAppendStages(const SkStageRec&) const override;
skvm::Color onProgram(skvm::Builder* p, skvm::F32 x, skvm::F32 y, skvm::Color paint, skvm::Color onProgram(skvm::Builder* p, skvm::F32 x, skvm::F32 y, skvm::Color paint,
const SkMatrix& ctm, const SkMatrix* localM, const SkMatrixProvider&, const SkMatrix* localM,
SkFilterQuality quality, const SkColorInfo& dstCS, SkFilterQuality quality, const SkColorInfo& dstCS,
skvm::Uniforms* uniforms, SkArenaAlloc* alloc) const override; skvm::Uniforms* uniforms, SkArenaAlloc* alloc) const override;