Remove gradient onGetGLSLProcessorKey() overrides
None of the gradient processor subclassess contributes anything to the base class key. Relocate the key logic to GrGradientEffect, and remove unneeded builerplate. Change-Id: I6b33ad359212579adedf95c0c3d481373c83d4c4 Reviewed-on: https://skia-review.googlesource.com/67721 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Florin Malita <fmalita@chromium.org>
This commit is contained in:
parent
9539a8c5e6
commit
e657dc8ce6
@ -1040,6 +1040,10 @@ void GrGradientEffect::GLSLProcessor::onSetData(const GrGLSLProgramDataManager&
|
||||
}
|
||||
}
|
||||
|
||||
void GrGradientEffect::onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder* b) const {
|
||||
b->add32(GLSLProcessor::GenBaseGradientKey(*this));
|
||||
}
|
||||
|
||||
uint32_t GrGradientEffect::GLSLProcessor::GenBaseGradientKey(const GrProcessor& processor) {
|
||||
const GrGradientEffect& e = processor.cast<GrGradientEffect>();
|
||||
|
||||
|
@ -274,6 +274,8 @@ protected:
|
||||
GrGradientEffect(ClassID classID, const CreateArgs&, bool isOpaque);
|
||||
explicit GrGradientEffect(const GrGradientEffect&); // facilitates clone() implementations
|
||||
|
||||
void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const final;
|
||||
|
||||
// Helper function used by derived class factories to handle color space transformation and
|
||||
// modulation by input alpha.
|
||||
static std::unique_ptr<GrFragmentProcessor> AdjustFP(
|
||||
@ -362,16 +364,10 @@ public:
|
||||
fCachedYCoord = SK_ScalarMax;
|
||||
}
|
||||
|
||||
protected:
|
||||
void onSetData(const GrGLSLProgramDataManager&, const GrFragmentProcessor&) override;
|
||||
static uint32_t GenBaseGradientKey(const GrProcessor&);
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Subclasses must call this. It will return a key for the part of the shader code controlled
|
||||
* by the base class. The subclasses must stick it in their key and then pass it to the below
|
||||
* emit* functions from their emitCode function.
|
||||
*/
|
||||
static uint32_t GenBaseGradientKey(const GrProcessor&);
|
||||
void onSetData(const GrGLSLProgramDataManager&, const GrFragmentProcessor&) override;
|
||||
|
||||
// Emits the uniform used as the y-coord to texture samples in derived classes. Subclasses
|
||||
// should call this method from their emitCode().
|
||||
|
@ -120,9 +120,6 @@ private:
|
||||
|
||||
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
|
||||
|
||||
virtual void onGetGLSLProcessorKey(const GrShaderCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const override;
|
||||
|
||||
GR_DECLARE_FRAGMENT_PROCESSOR_TEST
|
||||
|
||||
typedef GrGradientEffect INHERITED;
|
||||
@ -136,10 +133,6 @@ public:
|
||||
|
||||
virtual void emitCode(EmitArgs&) override;
|
||||
|
||||
static void GenKey(const GrProcessor& processor, const GrShaderCaps&, GrProcessorKeyBuilder* b) {
|
||||
b->add32(GenBaseGradientKey(processor));
|
||||
}
|
||||
|
||||
private:
|
||||
typedef GrGradientEffect::GLSLProcessor INHERITED;
|
||||
};
|
||||
@ -150,11 +143,6 @@ GrGLSLFragmentProcessor* GrLinearGradient::onCreateGLSLInstance() const {
|
||||
return new GrLinearGradient::GLSLLinearProcessor(*this);
|
||||
}
|
||||
|
||||
void GrLinearGradient::onGetGLSLProcessorKey(const GrShaderCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const {
|
||||
GrLinearGradient::GLSLLinearProcessor::GenKey(*this, caps, b);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrLinearGradient);
|
||||
|
@ -91,9 +91,6 @@ private:
|
||||
|
||||
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
|
||||
|
||||
virtual void onGetGLSLProcessorKey(const GrShaderCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const override;
|
||||
|
||||
GR_DECLARE_FRAGMENT_PROCESSOR_TEST
|
||||
|
||||
typedef GrGradientEffect INHERITED;
|
||||
@ -107,10 +104,6 @@ public:
|
||||
|
||||
virtual void emitCode(EmitArgs&) override;
|
||||
|
||||
static void GenKey(const GrProcessor& processor, const GrShaderCaps&, GrProcessorKeyBuilder* b) {
|
||||
b->add32(GenBaseGradientKey(processor));
|
||||
}
|
||||
|
||||
private:
|
||||
typedef GrGradientEffect::GLSLProcessor INHERITED;
|
||||
|
||||
@ -122,11 +115,6 @@ GrGLSLFragmentProcessor* GrRadialGradient::onCreateGLSLInstance() const {
|
||||
return new GrRadialGradient::GLSLRadialProcessor(*this);
|
||||
}
|
||||
|
||||
void GrRadialGradient::onGetGLSLProcessorKey(const GrShaderCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const {
|
||||
GrRadialGradient::GLSLRadialProcessor::GenKey(*this, caps, b);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrRadialGradient);
|
||||
|
@ -101,15 +101,12 @@ private:
|
||||
|
||||
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
|
||||
|
||||
virtual void onGetGLSLProcessorKey(const GrShaderCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const override;
|
||||
|
||||
bool onIsEqual(const GrFragmentProcessor& base) const override {
|
||||
const GrSweepGradient& fp = base.cast<GrSweepGradient>();
|
||||
return INHERITED::onIsEqual(base)
|
||||
&& fTBias == fp.fTBias
|
||||
&& fTScale == fp.fTScale;
|
||||
}
|
||||
bool onIsEqual(const GrFragmentProcessor& base) const override {
|
||||
const GrSweepGradient& fp = base.cast<GrSweepGradient>();
|
||||
return INHERITED::onIsEqual(base)
|
||||
&& fTBias == fp.fTBias
|
||||
&& fTScale == fp.fTScale;
|
||||
}
|
||||
|
||||
GR_DECLARE_FRAGMENT_PROCESSOR_TEST
|
||||
|
||||
@ -129,11 +126,6 @@ public:
|
||||
|
||||
void emitCode(EmitArgs&) override;
|
||||
|
||||
static void GenKey(const GrProcessor& processor, const GrShaderCaps&,
|
||||
GrProcessorKeyBuilder* b) {
|
||||
b->add32(GenBaseGradientKey(processor));
|
||||
}
|
||||
|
||||
protected:
|
||||
void onSetData(const GrGLSLProgramDataManager& pdman,
|
||||
const GrFragmentProcessor& processor) override {
|
||||
@ -163,12 +155,6 @@ GrGLSLFragmentProcessor* GrSweepGradient::onCreateGLSLInstance() const {
|
||||
return new GrSweepGradient::GLSLSweepProcessor(*this);
|
||||
}
|
||||
|
||||
void GrSweepGradient::onGetGLSLProcessorKey(const GrShaderCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const {
|
||||
GrSweepGradient::GLSLSweepProcessor::GenKey(*this, caps, b);
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrSweepGradient);
|
||||
|
@ -85,8 +85,6 @@ public:
|
||||
private:
|
||||
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
|
||||
|
||||
void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
|
||||
|
||||
bool onIsEqual(const GrFragmentProcessor& sBase) const override {
|
||||
const Edge2PtConicalEffect& s = sBase.cast<Edge2PtConicalEffect>();
|
||||
return (INHERITED::onIsEqual(sBase) &&
|
||||
@ -157,8 +155,6 @@ public:
|
||||
|
||||
virtual void emitCode(EmitArgs&) override;
|
||||
|
||||
static void GenKey(const GrProcessor&, const GrShaderCaps& caps, GrProcessorKeyBuilder* b);
|
||||
|
||||
protected:
|
||||
void onSetData(const GrGLSLProgramDataManager&, const GrFragmentProcessor&) override;
|
||||
|
||||
@ -180,11 +176,6 @@ private:
|
||||
|
||||
};
|
||||
|
||||
void Edge2PtConicalEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const {
|
||||
Edge2PtConicalEffect::GLSLEdge2PtConicalProcessor::GenKey(*this, caps, b);
|
||||
}
|
||||
|
||||
GrGLSLFragmentProcessor* Edge2PtConicalEffect::onCreateGLSLInstance() const {
|
||||
return new Edge2PtConicalEffect::GLSLEdge2PtConicalProcessor(*this);
|
||||
}
|
||||
@ -312,11 +303,6 @@ void Edge2PtConicalEffect::GLSLEdge2PtConicalProcessor::onSetData(
|
||||
}
|
||||
}
|
||||
|
||||
void Edge2PtConicalEffect::GLSLEdge2PtConicalProcessor::GenKey(const GrProcessor& processor,
|
||||
const GrShaderCaps&, GrProcessorKeyBuilder* b) {
|
||||
b->add32(GenBaseGradientKey(processor));
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// Focal Conical Gradients
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
@ -403,8 +389,6 @@ public:
|
||||
private:
|
||||
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
|
||||
|
||||
void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
|
||||
|
||||
bool onIsEqual(const GrFragmentProcessor& sBase) const override {
|
||||
const FocalOutside2PtConicalEffect& s = sBase.cast<FocalOutside2PtConicalEffect>();
|
||||
return (INHERITED::onIsEqual(sBase) &&
|
||||
@ -437,8 +421,6 @@ public:
|
||||
|
||||
virtual void emitCode(EmitArgs&) override;
|
||||
|
||||
static void GenKey(const GrProcessor&, const GrShaderCaps& caps, GrProcessorKeyBuilder* b);
|
||||
|
||||
protected:
|
||||
void onSetData(const GrGLSLProgramDataManager&, const GrFragmentProcessor&) override;
|
||||
|
||||
@ -460,11 +442,6 @@ private:
|
||||
|
||||
};
|
||||
|
||||
void FocalOutside2PtConicalEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const {
|
||||
FocalOutside2PtConicalEffect::GLSLFocalOutside2PtConicalProcessor::GenKey(*this, caps, b);
|
||||
}
|
||||
|
||||
GrGLSLFragmentProcessor* FocalOutside2PtConicalEffect::onCreateGLSLInstance() const {
|
||||
return new FocalOutside2PtConicalEffect::GLSLFocalOutside2PtConicalProcessor(*this);
|
||||
}
|
||||
@ -578,12 +555,6 @@ void FocalOutside2PtConicalEffect::GLSLFocalOutside2PtConicalProcessor::onSetDat
|
||||
}
|
||||
}
|
||||
|
||||
void FocalOutside2PtConicalEffect::GLSLFocalOutside2PtConicalProcessor::GenKey(
|
||||
const GrProcessor& processor,
|
||||
const GrShaderCaps&, GrProcessorKeyBuilder* b) {
|
||||
b->add32(GenBaseGradientKey(processor));
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class FocalInside2PtConicalEffect : public GrGradientEffect {
|
||||
@ -611,8 +582,6 @@ public:
|
||||
private:
|
||||
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
|
||||
|
||||
void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
|
||||
|
||||
bool onIsEqual(const GrFragmentProcessor& sBase) const override {
|
||||
const FocalInside2PtConicalEffect& s = sBase.cast<FocalInside2PtConicalEffect>();
|
||||
return (INHERITED::onIsEqual(sBase) &&
|
||||
@ -640,8 +609,6 @@ public:
|
||||
|
||||
virtual void emitCode(EmitArgs&) override;
|
||||
|
||||
static void GenKey(const GrProcessor&, const GrShaderCaps& caps, GrProcessorKeyBuilder* b);
|
||||
|
||||
protected:
|
||||
void onSetData(const GrGLSLProgramDataManager&, const GrFragmentProcessor&) override;
|
||||
|
||||
@ -662,11 +629,6 @@ private:
|
||||
|
||||
};
|
||||
|
||||
void FocalInside2PtConicalEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const {
|
||||
FocalInside2PtConicalEffect::GLSLFocalInside2PtConicalProcessor::GenKey(*this, caps, b);
|
||||
}
|
||||
|
||||
GrGLSLFragmentProcessor* FocalInside2PtConicalEffect::onCreateGLSLInstance() const {
|
||||
return new FocalInside2PtConicalEffect::GLSLFocalInside2PtConicalProcessor(*this);
|
||||
}
|
||||
@ -758,12 +720,6 @@ void FocalInside2PtConicalEffect::GLSLFocalInside2PtConicalProcessor::onSetData(
|
||||
}
|
||||
}
|
||||
|
||||
void FocalInside2PtConicalEffect::GLSLFocalInside2PtConicalProcessor::GenKey(
|
||||
const GrProcessor& processor,
|
||||
const GrShaderCaps&, GrProcessorKeyBuilder* b) {
|
||||
b->add32(GenBaseGradientKey(processor));
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// Circle Conical Gradients
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
@ -870,9 +826,6 @@ public:
|
||||
private:
|
||||
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
|
||||
|
||||
virtual void onGetGLSLProcessorKey(const GrShaderCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const override;
|
||||
|
||||
bool onIsEqual(const GrFragmentProcessor& sBase) const override {
|
||||
const CircleInside2PtConicalEffect& s = sBase.cast<CircleInside2PtConicalEffect>();
|
||||
return INHERITED::onIsEqual(sBase) && fInfo == s.fInfo;
|
||||
@ -899,8 +852,6 @@ public:
|
||||
|
||||
virtual void emitCode(EmitArgs&) override;
|
||||
|
||||
static void GenKey(const GrProcessor&, const GrShaderCaps& caps, GrProcessorKeyBuilder* b);
|
||||
|
||||
protected:
|
||||
void onSetData(const GrGLSLProgramDataManager&, const GrFragmentProcessor&) override;
|
||||
|
||||
@ -927,11 +878,6 @@ private:
|
||||
|
||||
};
|
||||
|
||||
void CircleInside2PtConicalEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const {
|
||||
CircleInside2PtConicalEffect::GLSLCircleInside2PtConicalProcessor::GenKey(*this, caps, b);
|
||||
}
|
||||
|
||||
GrGLSLFragmentProcessor* CircleInside2PtConicalEffect::onCreateGLSLInstance() const {
|
||||
return new CircleInside2PtConicalEffect::GLSLCircleInside2PtConicalProcessor(*this);
|
||||
}
|
||||
@ -1056,12 +1002,6 @@ void CircleInside2PtConicalEffect::GLSLCircleInside2PtConicalProcessor::onSetDat
|
||||
}
|
||||
}
|
||||
|
||||
void CircleInside2PtConicalEffect::GLSLCircleInside2PtConicalProcessor::GenKey(
|
||||
const GrProcessor& processor,
|
||||
const GrShaderCaps&, GrProcessorKeyBuilder* b) {
|
||||
b->add32(GenBaseGradientKey(processor));
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class CircleOutside2PtConicalEffect : public GrGradientEffect {
|
||||
@ -1092,8 +1032,6 @@ public:
|
||||
private:
|
||||
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
|
||||
|
||||
void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
|
||||
|
||||
bool onIsEqual(const GrFragmentProcessor& sBase) const override {
|
||||
const CircleOutside2PtConicalEffect& s = sBase.cast<CircleOutside2PtConicalEffect>();
|
||||
return INHERITED::onIsEqual(sBase) && fInfo == s.fInfo && fTLimit == s.fTLimit;
|
||||
@ -1132,8 +1070,6 @@ public:
|
||||
|
||||
virtual void emitCode(EmitArgs&) override;
|
||||
|
||||
static void GenKey(const GrProcessor&, const GrShaderCaps& caps, GrProcessorKeyBuilder* b);
|
||||
|
||||
protected:
|
||||
void onSetData(const GrGLSLProgramDataManager&, const GrFragmentProcessor&) override;
|
||||
|
||||
@ -1162,11 +1098,6 @@ private:
|
||||
|
||||
};
|
||||
|
||||
void CircleOutside2PtConicalEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const {
|
||||
CircleOutside2PtConicalEffect::GLSLCircleOutside2PtConicalProcessor::GenKey(*this, caps, b);
|
||||
}
|
||||
|
||||
GrGLSLFragmentProcessor* CircleOutside2PtConicalEffect::onCreateGLSLInstance() const {
|
||||
return new CircleOutside2PtConicalEffect::GLSLCircleOutside2PtConicalProcessor(*this);
|
||||
}
|
||||
@ -1312,12 +1243,6 @@ void CircleOutside2PtConicalEffect::GLSLCircleOutside2PtConicalProcessor::onSetD
|
||||
}
|
||||
}
|
||||
|
||||
void CircleOutside2PtConicalEffect::GLSLCircleOutside2PtConicalProcessor::GenKey(
|
||||
const GrProcessor& processor,
|
||||
const GrShaderCaps&, GrProcessorKeyBuilder* b) {
|
||||
b->add32(GenBaseGradientKey(processor));
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
std::unique_ptr<GrFragmentProcessor> Gr2PtConicalGradientEffect::Make(
|
||||
|
Loading…
Reference in New Issue
Block a user