rearrange to emphasize most salient params

Move (x,y) up front for shaders, Color for color filters.

I did think about wrapping the other params in a struct, but
for now I still find it less error prone (while admittedly
more tedious) to have all those params in my face when adding,
removing, or refactoring parameters or effects.

Change-Id: I5e124f1ecea3eff9366872d5e77ddfbadc0302e3
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/277111
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Mike Reed <reed@google.com>
This commit is contained in:
Mike Klein 2020-03-15 08:46:09 -05:00
parent 9a4ac6e865
commit 276a78573e
22 changed files with 102 additions and 116 deletions

View File

@ -63,8 +63,8 @@ public:
bool appendStages(const SkStageRec& rec, bool shaderIsOpaque) const;
skvm::Color program(skvm::Builder*, SkColorSpace* dstCS, skvm::Uniforms*,
SkArenaAlloc*, skvm::Color) const;
skvm::Color program(skvm::Builder*, skvm::Color,
SkColorSpace* dstCS, skvm::Uniforms*, SkArenaAlloc*) const;
enum Flags {
/** If set the filter methods will not change the alpha channel of the colors.
@ -148,8 +148,8 @@ private:
virtual bool onAppendStages(const SkStageRec& rec, bool shaderIsOpaque) const = 0;
virtual skvm::Color onProgram(skvm::Builder*, SkColorSpace* dstCS, skvm::Uniforms*,
SkArenaAlloc*, skvm::Color) const;
virtual skvm::Color onProgram(skvm::Builder*, skvm::Color,
SkColorSpace* dstCS, skvm::Uniforms*, SkArenaAlloc*) const;
friend class SkComposeColorFilter;

View File

@ -50,8 +50,8 @@ private:
SkLumaColorFilter();
bool onAppendStages(const SkStageRec& rec, bool shaderIsOpaque) const override;
skvm::Color onProgram(skvm::Builder*, SkColorSpace* dstCS, skvm::Uniforms*,
SkArenaAlloc*, skvm::Color) const override;
skvm::Color onProgram(skvm::Builder*, skvm::Color,
SkColorSpace* dstCS, skvm::Uniforms*, SkArenaAlloc*) const override;
typedef SkColorFilter INHERITED;
};

View File

@ -43,10 +43,11 @@ bool SkColorFilter::appendStages(const SkStageRec& rec, bool shaderIsOpaque) con
return this->onAppendStages(rec, shaderIsOpaque);
}
skvm::Color SkColorFilter::program(skvm::Builder* p, SkColorSpace* dstCS, skvm::Uniforms* uniforms,
SkArenaAlloc* alloc, skvm::Color c) const {
skvm::Color SkColorFilter::program(skvm::Builder* p, skvm::Color c,
SkColorSpace* dstCS,
skvm::Uniforms* uniforms, SkArenaAlloc* alloc) const {
skvm::F32 original = c.a;
if ((c = this->onProgram(p, dstCS, uniforms,alloc, c))) {
if ((c = this->onProgram(p,c, dstCS, uniforms,alloc))) {
if (this->getFlags() & kAlphaUnchanged_Flag) {
c.a = original;
}
@ -55,8 +56,8 @@ skvm::Color SkColorFilter::program(skvm::Builder* p, SkColorSpace* dstCS, skvm::
return {};
}
skvm::Color SkColorFilter::onProgram(skvm::Builder*, SkColorSpace*, skvm::Uniforms*,
SkArenaAlloc*, skvm::Color) const {
skvm::Color SkColorFilter::onProgram(skvm::Builder*, skvm::Color,
SkColorSpace*, skvm::Uniforms*, SkArenaAlloc*) const {
//SkDebugf("cannot onProgram %s\n", this->getTypeName());
return {};
}
@ -123,10 +124,11 @@ public:
fOuter->appendStages(rec, innerIsOpaque);
}
skvm::Color onProgram(skvm::Builder* p, SkColorSpace* dstCS, skvm::Uniforms* uniforms,
SkArenaAlloc* alloc, skvm::Color c) const override {
c = fInner->program(p, dstCS, uniforms, alloc, c);
return c ? fOuter->program(p, dstCS, uniforms, alloc, c) : skvm::Color{};
skvm::Color onProgram(skvm::Builder* p, skvm::Color c,
SkColorSpace* dstCS,
skvm::Uniforms* uniforms, SkArenaAlloc* alloc) const override {
c = fInner->program(p, c, dstCS, uniforms, alloc);
return c ? fOuter->program(p, c, dstCS, uniforms, alloc) : skvm::Color{};
}
#if SK_SUPPORT_GPU
@ -329,10 +331,11 @@ public:
return true;
}
skvm::Color onProgram(skvm::Builder* p, SkColorSpace* dstCS, skvm::Uniforms* uniforms,
SkArenaAlloc* alloc, skvm::Color c) const override {
skvm::Color c0 = fCF0->program(p, dstCS, uniforms, alloc, c);
skvm::Color c1 = fCF1 ? fCF1->program(p, dstCS, uniforms, alloc, c) : c;
skvm::Color onProgram(skvm::Builder* p, skvm::Color c,
SkColorSpace* dstCS,
skvm::Uniforms* uniforms, SkArenaAlloc* alloc) const override {
skvm::Color c0 = fCF0->program(p, c, dstCS, uniforms, alloc);
skvm::Color c1 = fCF1 ? fCF1->program(p, c, dstCS, uniforms, alloc) : c;
return (c0 && c1)
? p->lerp(c0, c1, p->uniformF(uniforms->pushF(fWeight)))
: skvm::Color{};

View File

@ -80,10 +80,9 @@ bool SkColorFilter_Matrix::onAppendStages(const SkStageRec& rec, bool shaderIsOp
return true;
}
skvm::Color SkColorFilter_Matrix::onProgram(skvm::Builder* p,
skvm::Color SkColorFilter_Matrix::onProgram(skvm::Builder* p, skvm::Color c,
SkColorSpace* /*dstCS*/,
skvm::Uniforms* uniforms, SkArenaAlloc*,
skvm::Color c) const {
skvm::Uniforms* uniforms, SkArenaAlloc*) const {
// TODO: specialize generated code on the 0/1 values of fMatrix?
if (fDomain == Domain::kRGBA) {
c = p->unpremul(c);

View File

@ -33,8 +33,9 @@ private:
SK_FLATTENABLE_HOOKS(SkColorFilter_Matrix)
bool onAppendStages(const SkStageRec& rec, bool shaderIsOpaque) const override;
skvm::Color onProgram(skvm::Builder*, SkColorSpace* dstCS,
skvm::Uniforms* uniforms, SkArenaAlloc*, skvm::Color) const override;
skvm::Color onProgram(skvm::Builder*, skvm::Color,
SkColorSpace* dstCS,
skvm::Uniforms* uniforms, SkArenaAlloc*) const override;
float fMatrix[20];
uint16_t fFlags;

View File

@ -125,10 +125,10 @@ namespace {
y = p.add(p.to_f32(dy), p.splat(0.5f));
uint64_t hash = 0;
if (auto c = sb->program(&p,
if (auto c = sb->program(&p, x,y,
params.ctm, /*localM=*/nullptr,
params.quality, params.colorSpace.get(),
uniforms,alloc, x, y)) {
uniforms,alloc)) {
hash = p.hash();
// p.hash() folds in all instructions to produce r,g,b,a but does not know
// precisely which value we'll treat as which channel. Imagine the shader
@ -198,10 +198,10 @@ namespace {
skvm::F32 x = add(to_f32(dx), splat(0.5f)),
y = add(to_f32(dy), splat(0.5f));
skvm::Color src = as_SB(params.shader)->program(this,
params.ctm, /*localM=*/nullptr,
params.quality, params.colorSpace.get(),
uniforms, alloc, x,y);
skvm::Color src = as_SB(params.shader)->program(this, x,y,
params.ctm, /*localM=*/nullptr,
params.quality, params.colorSpace.get(),
uniforms, alloc);
SkASSERT(src);
if (params.coverage == Coverage::Mask3D) {
skvm::F32 M = from_unorm(8, load8(varying<uint8_t>())),
@ -265,11 +265,11 @@ namespace {
}
if (params.clip) {
skvm::Color clip = as_SB(params.clip)->program(this,
skvm::Color clip = as_SB(params.clip)->program(this, x,y,
params.ctm, /*localM=*/nullptr,
params.quality,
params.colorSpace.get(),
uniforms, alloc, x,y);
uniforms, alloc);
SkAssertResult(clip);
cov->r = mul(cov->r, clip.a); // We use the alpha channel of clip for all four.
cov->g = mul(cov->g, clip.a);
@ -399,8 +399,8 @@ namespace {
};
struct NoopColorFilter : public SkColorFilter {
skvm::Color onProgram(skvm::Builder*, SkColorSpace*, skvm::Uniforms*,
SkArenaAlloc*, skvm::Color c) const override {
skvm::Color onProgram(skvm::Builder*, skvm::Color c,
SkColorSpace*, skvm::Uniforms*, SkArenaAlloc*) const override {
return c;
}
@ -424,14 +424,13 @@ namespace {
bool isOpaque() const override { return fShader->isOpaque(); }
skvm::Color onProgram(skvm::Builder* p,
skvm::Color onProgram(skvm::Builder* p, skvm::F32 x, skvm::F32 y,
const SkMatrix& ctm, const SkMatrix* localM,
SkFilterQuality quality, SkColorSpace* dstCS,
skvm::Uniforms* uniforms, SkArenaAlloc* alloc,
skvm::F32 x, skvm::F32 y) const override {
skvm::Uniforms* uniforms, SkArenaAlloc* alloc) const override {
// Run our wrapped shader.
skvm::Color c = as_SB(fShader)->program(p, ctm,localM, quality,dstCS,
uniforms,alloc, x,y);
skvm::Color c = as_SB(fShader)->program(p, x,y,
ctm,localM, quality,dstCS, uniforms,alloc);
if (!c) {
return {};
}

View File

@ -26,9 +26,9 @@ bool SkLumaColorFilter::onAppendStages(const SkStageRec& rec, bool shaderIsOpaqu
return true;
}
skvm::Color SkLumaColorFilter::onProgram(skvm::Builder* p, SkColorSpace* dstCS,
skvm::Uniforms* uniforms, SkArenaAlloc* alloc,
skvm::Color c) const {
skvm::Color SkLumaColorFilter::onProgram(skvm::Builder* p, skvm::Color c,
SkColorSpace* dstCS,
skvm::Uniforms* uniforms, SkArenaAlloc* alloc) const {
auto a = p->mad(c.r, p->splat(0.2126f),
p->mad(c.g, p->splat(0.7152f),
p->mul(c.b, p->splat(0.0722f))));

View File

@ -123,8 +123,9 @@ public:
return true;
}
skvm::Color onProgram(skvm::Builder* p, SkColorSpace* dstCS, skvm::Uniforms* uniforms,
SkArenaAlloc*, skvm::Color c) const override {
skvm::Color onProgram(skvm::Builder* p, skvm::Color c,
SkColorSpace* dstCS,
skvm::Uniforms* uniforms, SkArenaAlloc*) const override {
auto apply_table_to_component = [&](skvm::F32 c, const uint8_t* bytePtr) -> skvm::F32 {
c = p->clamp(c, p->splat(0.f), p->splat(1.0f));

View File

@ -61,13 +61,12 @@ bool SkColorFilterShader::onAppendStages(const SkStageRec& rec) const {
return true;
}
skvm::Color SkColorFilterShader::onProgram(skvm::Builder* p,
skvm::Color SkColorFilterShader::onProgram(skvm::Builder* p, skvm::F32 x, skvm::F32 y,
const SkMatrix& ctm, const SkMatrix* localM,
SkFilterQuality quality, SkColorSpace* dstCS,
skvm::Uniforms* uniforms, SkArenaAlloc* alloc,
skvm::F32 x, skvm::F32 y) const {
skvm::Uniforms* uniforms, SkArenaAlloc* alloc) const {
// Run the shader.
skvm::Color c = as_SB(fShader)->program(p, ctm,localM, quality,dstCS, uniforms,alloc, x,y);
skvm::Color c = as_SB(fShader)->program(p,x,y, ctm,localM, quality,dstCS, uniforms,alloc);
if (!c) {
return {};
}
@ -81,7 +80,7 @@ skvm::Color SkColorFilterShader::onProgram(skvm::Builder* p,
}
// Finally run that through the color filter.
return fFilter->program(p, dstCS, uniforms,alloc, c);
return fFilter->program(p,c, dstCS, uniforms,alloc);
}
#if SK_SUPPORT_GPU

View File

@ -26,11 +26,10 @@ private:
void flatten(SkWriteBuffer&) const override;
bool onAppendStages(const SkStageRec&) const override;
skvm::Color onProgram(skvm::Builder*,
skvm::Color onProgram(skvm::Builder*, skvm::F32 x, skvm::F32 y,
const SkMatrix& ctm, const SkMatrix* localM,
SkFilterQuality quality, SkColorSpace* dstCS,
skvm::Uniforms* uniforms, SkArenaAlloc*,
skvm::F32 x, skvm::F32 y) const override;
skvm::Uniforms* uniforms, SkArenaAlloc*) const override;
SK_FLATTENABLE_HOOKS(SkColorFilterShader)

View File

@ -106,18 +106,16 @@ static skvm::Color common_program(SkColor4f color, SkColorSpace* cs,
};
}
skvm::Color SkColorShader::onProgram(skvm::Builder* p,
skvm::Color SkColorShader::onProgram(skvm::Builder* p, skvm::F32 /*x*/, skvm::F32 /*y*/,
const SkMatrix& /*ctm*/, const SkMatrix* /*localM*/,
SkFilterQuality /*quality*/, SkColorSpace* dstCS,
skvm::Uniforms* uniforms, SkArenaAlloc*,
skvm::F32 /*x*/, skvm::F32 /*y*/) const {
skvm::Uniforms* uniforms, SkArenaAlloc*) const {
return common_program(SkColor4f::FromColor(fColor), sk_srgb_singleton(), p, dstCS, uniforms);
}
skvm::Color SkColor4Shader::onProgram(skvm::Builder* p,
skvm::Color SkColor4Shader::onProgram(skvm::Builder* p, skvm::F32 /*x*/, skvm::F32 /*y*/,
const SkMatrix& /*ctm*/, const SkMatrix* /*localM*/,
SkFilterQuality /*quality*/, SkColorSpace* dstCS,
skvm::Uniforms* uniforms, SkArenaAlloc*,
skvm::F32 /*x*/, skvm::F32 /*y*/) const {
skvm::Uniforms* uniforms, SkArenaAlloc*) const {
return common_program(fColor, fColorSpace.get(), p, dstCS, uniforms);
}

View File

@ -44,11 +44,10 @@ private:
bool onAppendStages(const SkStageRec&) const override;
skvm::Color onProgram(skvm::Builder*,
skvm::Color onProgram(skvm::Builder*, skvm::F32 x, skvm::F32 y,
const SkMatrix& ctm, const SkMatrix* localM,
SkFilterQuality quality, SkColorSpace* dstCS,
skvm::Uniforms* uniforms, SkArenaAlloc*,
skvm::F32 x, skvm::F32 y) const override;
skvm::Uniforms* uniforms, SkArenaAlloc*) const override;
SkColor fColor;
};
@ -70,11 +69,10 @@ private:
void flatten(SkWriteBuffer&) const override;
bool onAppendStages(const SkStageRec&) const override;
skvm::Color onProgram(skvm::Builder*,
skvm::Color onProgram(skvm::Builder*, skvm::F32 x, skvm::F32 y,
const SkMatrix& ctm, const SkMatrix* localM,
SkFilterQuality quality, SkColorSpace* dstCS,
skvm::Uniforms* uniforms, SkArenaAlloc*,
skvm::F32 x, skvm::F32 y) const override;
skvm::Uniforms* uniforms, SkArenaAlloc*) const override;
sk_sp<SkColorSpace> fColorSpace;
const SkColor4f fColor;

View File

@ -133,15 +133,14 @@ bool SkShader_Blend::onAppendStages(const SkStageRec& orig_rec) const {
return true;
}
skvm::Color SkShader_Blend::onProgram(skvm::Builder* p,
skvm::Color SkShader_Blend::onProgram(skvm::Builder* p, skvm::F32 x, skvm::F32 y,
const SkMatrix& ctm, const SkMatrix* localM,
SkFilterQuality q, SkColorSpace* cs,
skvm::Uniforms* uniforms, SkArenaAlloc* alloc,
skvm::F32 x, skvm::F32 y) const {
skvm::Uniforms* uniforms, SkArenaAlloc* alloc) const {
skvm::Color dst, src;
if (skvm::BlendModeSupported(fMode) &&
(dst = as_SB(fDst)->program(p, ctm,localM, q, cs, uniforms, alloc, x,y)) &&
(src = as_SB(fSrc)->program(p, ctm,localM, q, cs, uniforms, alloc, x,y)))
(dst = as_SB(fDst)->program(p, x,y, ctm,localM, q, cs, uniforms, alloc)) &&
(src = as_SB(fSrc)->program(p, x,y, ctm,localM, q, cs, uniforms, alloc)))
{
return skvm::BlendModeProgram(p, fMode, src, dst);
}
@ -175,14 +174,13 @@ bool SkShader_Lerp::onAppendStages(const SkStageRec& orig_rec) const {
return true;
}
skvm::Color SkShader_Lerp::onProgram(skvm::Builder* p,
skvm::Color SkShader_Lerp::onProgram(skvm::Builder* p, skvm::F32 x, skvm::F32 y,
const SkMatrix& ctm, const SkMatrix* localM,
SkFilterQuality q, SkColorSpace* cs,
skvm::Uniforms* uniforms, SkArenaAlloc* alloc,
skvm::F32 x, skvm::F32 y) const {
skvm::Uniforms* uniforms, SkArenaAlloc* alloc) const {
skvm::Color dst, src;
if ((dst = as_SB(fDst)->program(p, ctm,localM, q, cs, uniforms, alloc, x,y)) &&
(src = as_SB(fSrc)->program(p, ctm,localM, q, cs, uniforms, alloc, x,y)))
if ((dst = as_SB(fDst)->program(p, x,y, ctm,localM, q, cs, uniforms, alloc)) &&
(src = as_SB(fSrc)->program(p, x,y, ctm,localM, q, cs, uniforms, alloc)))
{
auto t = p->uniformF(uniforms->pushF(fWeight));
return {

View File

@ -28,9 +28,10 @@ protected:
SkShader_Blend(SkReadBuffer&);
void flatten(SkWriteBuffer&) const override;
bool onAppendStages(const SkStageRec&) const override;
skvm::Color onProgram(skvm::Builder*, const SkMatrix& ctm, const SkMatrix* localM,
SkFilterQuality, SkColorSpace* dstCS, skvm::Uniforms*, SkArenaAlloc*,
skvm::F32 x, skvm::F32 y) const override;
skvm::Color onProgram(skvm::Builder*, skvm::F32 x, skvm::F32 y,
const SkMatrix& ctm, const SkMatrix* localM,
SkFilterQuality, SkColorSpace* dstCS,
skvm::Uniforms*, SkArenaAlloc*) const override;
private:
SK_FLATTENABLE_HOOKS(SkShader_Blend)
@ -61,9 +62,10 @@ protected:
SkShader_Lerp(SkReadBuffer&);
void flatten(SkWriteBuffer&) const override;
bool onAppendStages(const SkStageRec&) const override;
skvm::Color onProgram(skvm::Builder*, const SkMatrix& ctm, const SkMatrix* localM,
SkFilterQuality, SkColorSpace* dstCS, skvm::Uniforms*, SkArenaAlloc*,
skvm::F32 x, skvm::F32 y) const override;
skvm::Color onProgram(skvm::Builder*, skvm::F32 x, skvm::F32 y,
const SkMatrix& ctm, const SkMatrix* localM,
SkFilterQuality, SkColorSpace* dstCS,
skvm::Uniforms*, SkArenaAlloc*) const override;
private:
SK_FLATTENABLE_HOOKS(SkShader_Lerp)

View File

@ -638,11 +638,10 @@ SkStageUpdater* SkImageShader::onAppendUpdatableStages(const SkStageRec& rec) co
return this->doStages(rec, updater) ? updater : nullptr;
}
skvm::Color SkImageShader::onProgram(skvm::Builder* p,
skvm::Color SkImageShader::onProgram(skvm::Builder* p, skvm::F32 x, skvm::F32 y,
const SkMatrix& ctm, const SkMatrix* localM,
SkFilterQuality quality, SkColorSpace* dstCS,
skvm::Uniforms* uniforms, SkArenaAlloc* alloc,
skvm::F32 x, skvm::F32 y) const {
skvm::Uniforms* uniforms, SkArenaAlloc* alloc) const {
SkMatrix inv;
if (!this->computeTotalInverse(ctm, localM, &inv)) {
return {};

View File

@ -47,11 +47,10 @@ private:
bool onAppendStages(const SkStageRec&) const override;
SkStageUpdater* onAppendUpdatableStages(const SkStageRec&) const override;
skvm::Color onProgram(skvm::Builder*,
skvm::Color onProgram(skvm::Builder*, skvm::F32 x, skvm::F32 y,
const SkMatrix& ctm, const SkMatrix* localM,
SkFilterQuality quality, SkColorSpace* dstCS,
skvm::Uniforms* uniforms, SkArenaAlloc*,
skvm::F32 x, skvm::F32 y) const override;
skvm::Uniforms* uniforms, SkArenaAlloc*) const override;
bool doStages(const SkStageRec&, SkImageStageUpdater* = nullptr) const;

View File

@ -75,16 +75,15 @@ 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,
const SkMatrix& ctm, const SkMatrix* localM,
SkFilterQuality quality, SkColorSpace* dstCS,
skvm::Uniforms* uniforms, SkArenaAlloc* alloc,
skvm::F32 x, skvm::F32 y) const {
skvm::Uniforms* uniforms, SkArenaAlloc* alloc) const {
SkTCopyOnFirstWrite<SkMatrix> lm(this->getLocalMatrix());
if (localM) {
lm.writable()->preConcat(*localM);
}
return as_SB(fProxyShader)->program(p, ctm,lm.get(), quality,dstCS, uniforms,alloc, x,y);
return as_SB(fProxyShader)->program(p, x,y, ctm,lm.get(), quality,dstCS, uniforms,alloc);
}
sk_sp<SkShader> SkShader::makeWithLocalMatrix(const SkMatrix& localMatrix) const {
@ -150,12 +149,11 @@ protected:
return as_SB(fProxyShader)->appendStages(newRec);
}
skvm::Color onProgram(skvm::Builder* p,
skvm::Color onProgram(skvm::Builder* p, skvm::F32 x, skvm::F32 y,
const SkMatrix& ctm, const SkMatrix* localM,
SkFilterQuality quality, SkColorSpace* dstCS,
skvm::Uniforms* uniforms, SkArenaAlloc* alloc,
skvm::F32 x, skvm::F32 y) const override {
return as_SB(fProxyShader)->program(p, fCTM,localM, quality,dstCS, uniforms,alloc, x,y);
skvm::Uniforms* uniforms, SkArenaAlloc* alloc) const override {
return as_SB(fProxyShader)->program(p, x,y, fCTM,localM, quality,dstCS, uniforms,alloc);
}
private:

View File

@ -48,11 +48,10 @@ protected:
bool onAppendStages(const SkStageRec&) const override;
skvm::Color onProgram(skvm::Builder*,
skvm::Color onProgram(skvm::Builder*, skvm::F32 x, skvm::F32 y,
const SkMatrix& ctm, const SkMatrix* localM,
SkFilterQuality quality, SkColorSpace* dstCS,
skvm::Uniforms* uniforms, SkArenaAlloc*,
skvm::F32 x, skvm::F32 y) const override;
skvm::Uniforms* uniforms, SkArenaAlloc*) const override;
private:
SK_FLATTENABLE_HOOKS(SkLocalMatrixShader)

View File

@ -193,11 +193,10 @@ bool SkShaderBase::onAppendStages(const SkStageRec& rec) const {
return false;
}
skvm::Color SkShaderBase::program(skvm::Builder* p,
skvm::Color SkShaderBase::program(skvm::Builder* p, skvm::F32 x, skvm::F32 y,
const SkMatrix& ctm, const SkMatrix* localM,
SkFilterQuality quality, SkColorSpace* dstCS,
skvm::Uniforms* uniforms, SkArenaAlloc* alloc,
skvm::F32 x, skvm::F32 y) const {
skvm::Uniforms* uniforms, SkArenaAlloc* alloc) const {
// Force opaque alpha for all opaque shaders.
//
// This is primarily nice in that we usually have a 1.0f constant splat
@ -210,7 +209,7 @@ skvm::Color SkShaderBase::program(skvm::Builder* p,
// 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
// SrcOver -> Src strength reduction.
if (auto color = this->onProgram(p, ctm,localM, quality,dstCS, uniforms,alloc, x,y)) {
if (auto color = this->onProgram(p, x,y, ctm,localM, quality,dstCS, uniforms,alloc)) {
if (this->isOpaque()) {
color.a = p->splat(1.0f);
}
@ -219,11 +218,10 @@ skvm::Color SkShaderBase::program(skvm::Builder* p,
return {};
}
skvm::Color SkShaderBase::onProgram(skvm::Builder*,
skvm::Color SkShaderBase::onProgram(skvm::Builder*, skvm::F32 x, skvm::F32 y,
const SkMatrix& ctm, const SkMatrix* localM,
SkFilterQuality quality, SkColorSpace* dstCS,
skvm::Uniforms* uniforms, SkArenaAlloc* alloc,
skvm::F32 x, skvm::F32 y) const {
skvm::Uniforms* uniforms, SkArenaAlloc* alloc) const {
//SkDebugf("cannot onProgram %s\n", this->getTypeName());
return {};
}

View File

@ -208,11 +208,10 @@ public:
return this->onAppendUpdatableStages(rec);
}
skvm::Color program(skvm::Builder*,
skvm::Color program(skvm::Builder*, skvm::F32 x, skvm::F32 y,
const SkMatrix& ctm, const SkMatrix* localM,
SkFilterQuality quality, SkColorSpace* dstCS,
skvm::Uniforms* uniforms, SkArenaAlloc* alloc,
skvm::F32 x, skvm::F32 y) const;
skvm::Uniforms* uniforms, SkArenaAlloc* alloc) const;
protected:
SkShaderBase(const SkMatrix* localMatrix = nullptr);
@ -245,11 +244,10 @@ private:
// This is essentially const, but not officially so it can be modified in constructors.
SkMatrix fLocalMatrix;
virtual skvm::Color onProgram(skvm::Builder*,
virtual skvm::Color onProgram(skvm::Builder*, skvm::F32 x, skvm::F32 y,
const SkMatrix& ctm, const SkMatrix* localM,
SkFilterQuality quality, SkColorSpace* dstCS,
skvm::Uniforms* uniforms, SkArenaAlloc* alloc,
skvm::F32 x, skvm::F32 y) const;
skvm::Uniforms* uniforms, SkArenaAlloc* alloc) const;
typedef SkShader INHERITED;
};

View File

@ -417,11 +417,10 @@ bool SkGradientShaderBase::onAppendStages(const SkStageRec& rec) const {
return true;
}
skvm::Color SkGradientShaderBase::onProgram(skvm::Builder* p,
skvm::Color SkGradientShaderBase::onProgram(skvm::Builder* p, skvm::F32 x, skvm::F32 y,
const SkMatrix& ctm, const SkMatrix* localM,
SkFilterQuality quality, SkColorSpace* dstCS,
skvm::Uniforms* uniforms, SkArenaAlloc* alloc,
skvm::F32 x, skvm::F32 y) const {
skvm::Uniforms* uniforms, SkArenaAlloc* alloc) const {
SkMatrix inv;
if (!this->computeTotalInverse(ctm, localM, &inv)) {
return {};

View File

@ -79,11 +79,10 @@ protected:
bool onAppendStages(const SkStageRec&) const override;
skvm::Color onProgram(skvm::Builder* p,
skvm::Color onProgram(skvm::Builder* p, skvm::F32 x, skvm::F32 y,
const SkMatrix& ctm, const SkMatrix* localM,
SkFilterQuality quality, SkColorSpace* dstCS,
skvm::Uniforms* uniforms, SkArenaAlloc* alloc,
skvm::F32 x, skvm::F32 y) const override;
skvm::Uniforms* uniforms, SkArenaAlloc* alloc) const override;
virtual void appendGradientStages(SkArenaAlloc* alloc, SkRasterPipeline* tPipeline,
SkRasterPipeline* postPipeline) const = 0;