Refactor various gradient effect classes

BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2221133002

Review-Url: https://codereview.chromium.org/2221133002
This commit is contained in:
fmenozzi 2016-08-09 08:05:57 -07:00 committed by Commit bot
parent 0c753e5c26
commit 55d318d35f
6 changed files with 201 additions and 159 deletions

View File

@ -911,12 +911,12 @@ SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
#include "glsl/GrGLSLUniformHandler.h"
#include "SkGr.h"
GrGLGradientEffect::GrGLGradientEffect()
GrGradientEffect::GLSLProcessor::GLSLProcessor()
: fCachedYCoord(SK_ScalarMax) {
}
void GrGLGradientEffect::emitUniforms(GrGLSLUniformHandler* uniformHandler,
const GrGradientEffect& ge) {
void GrGradientEffect::GLSLProcessor::emitUniforms(GrGLSLUniformHandler* uniformHandler,
const GrGradientEffect& ge) {
if (SkGradientShaderBase::kTwo_GpuColorType == ge.getColorType()) { // 2 Color case
fColorStartUni = uniformHandler->addUniform(kFragment_GrShaderFlag,
@ -966,8 +966,8 @@ static inline void set_mul_color_uni(const GrGLSLProgramDataManager& pdman,
a);
}
void GrGLGradientEffect::onSetData(const GrGLSLProgramDataManager& pdman,
const GrProcessor& processor) {
void GrGradientEffect::GLSLProcessor::onSetData(const GrGLSLProgramDataManager& pdman,
const GrProcessor& processor) {
const GrGradientEffect& e = processor.cast<GrGradientEffect>();
@ -1004,7 +1004,7 @@ void GrGLGradientEffect::onSetData(const GrGLSLProgramDataManager& pdman,
}
uint32_t GrGLGradientEffect::GenBaseGradientKey(const GrProcessor& processor) {
uint32_t GrGradientEffect::GLSLProcessor::GenBaseGradientKey(const GrProcessor& processor) {
const GrGradientEffect& e = processor.cast<GrGradientEffect>();
uint32_t key = 0;
@ -1022,14 +1022,14 @@ uint32_t GrGLGradientEffect::GenBaseGradientKey(const GrProcessor& processor) {
return key;
}
void GrGLGradientEffect::emitColor(GrGLSLFPFragmentBuilder* fragBuilder,
GrGLSLUniformHandler* uniformHandler,
const GrGLSLCaps* glslCaps,
const GrGradientEffect& ge,
const char* gradientTValue,
const char* outputColor,
const char* inputColor,
const SamplerHandle* texSamplers) {
void GrGradientEffect::GLSLProcessor::emitColor(GrGLSLFPFragmentBuilder* fragBuilder,
GrGLSLUniformHandler* uniformHandler,
const GrGLSLCaps* glslCaps,
const GrGradientEffect& ge,
const char* gradientTValue,
const char* outputColor,
const char* inputColor,
const SamplerHandle* texSamplers) {
if (SkGradientShaderBase::kTwo_GpuColorType == ge.getColorType()){
fragBuilder->codeAppendf("\tvec4 colorTemp = mix(%s, %s, clamp(%s, 0.0, 1.0));\n",
uniformHandler->getUniformVariable(fColorStartUni).c_str(),

View File

@ -326,6 +326,7 @@ class GrInvariantOutput;
// Base class for Gr gradient effects
class GrGradientEffect : public GrFragmentProcessor {
public:
class GLSLProcessor;
GrGradientEffect(GrContext* ctx,
const SkGradientShaderBase& shader,
@ -353,7 +354,6 @@ public:
}
protected:
/** Populates a pair of arrays with colors and stop info to construct a random gradient.
The function decides whether stop values should be used or not. The return value indicates
the number of colors, which will be capped by kMaxRandomGradientColors. colors should be
@ -392,10 +392,10 @@ private:
///////////////////////////////////////////////////////////////////////////////
// Base class for GL gradient effects
class GrGLGradientEffect : public GrGLSLFragmentProcessor {
// Base class for GLSL gradient effects
class GrGradientEffect::GLSLProcessor : public GrGLSLFragmentProcessor {
public:
GrGLGradientEffect();
GLSLProcessor();
protected:
void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;

View File

@ -347,28 +347,9 @@ SkShader::GradientType SkLinearGradient::asAGradient(GradientInfo* info) const {
/////////////////////////////////////////////////////////////////////
class GrGLLinearGradient : public GrGLGradientEffect {
public:
GrGLLinearGradient(const GrProcessor&) {}
virtual ~GrGLLinearGradient() { }
virtual void emitCode(EmitArgs&) override;
static void GenKey(const GrProcessor& processor, const GrGLSLCaps&, GrProcessorKeyBuilder* b) {
b->add32(GenBaseGradientKey(processor));
}
private:
typedef GrGLGradientEffect INHERITED;
};
/////////////////////////////////////////////////////////////////////
class GrLinearGradient : public GrGradientEffect {
public:
class GLSLLinearProcessor;
static sk_sp<GrFragmentProcessor> Make(GrContext* ctx,
const SkLinearGradient& shader,
@ -390,14 +371,10 @@ private:
this->initClassID<GrLinearGradient>();
}
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override {
return new GrGLLinearGradient(*this);
}
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
virtual void onGetGLSLProcessorKey(const GrGLSLCaps& caps,
GrProcessorKeyBuilder* b) const override {
GrGLLinearGradient::GenKey(*this, caps, b);
}
GrProcessorKeyBuilder* b) const override;
GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
@ -406,6 +383,35 @@ private:
/////////////////////////////////////////////////////////////////////
class GrLinearGradient::GLSLLinearProcessor : public GrGradientEffect::GLSLProcessor {
public:
GLSLLinearProcessor(const GrProcessor&) {}
virtual ~GLSLLinearProcessor() { }
virtual void emitCode(EmitArgs&) override;
static void GenKey(const GrProcessor& processor, const GrGLSLCaps&, GrProcessorKeyBuilder* b) {
b->add32(GenBaseGradientKey(processor));
}
private:
typedef GrGradientEffect::GLSLProcessor INHERITED;
};
/////////////////////////////////////////////////////////////////////
GrGLSLFragmentProcessor* GrLinearGradient::onCreateGLSLInstance() const {
return new GrLinearGradient::GLSLLinearProcessor(*this);
}
void GrLinearGradient::onGetGLSLProcessorKey(const GrGLSLCaps& caps,
GrProcessorKeyBuilder* b) const {
GrLinearGradient::GLSLLinearProcessor::GenKey(*this, caps, b);
}
/////////////////////////////////////////////////////////////////////
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrLinearGradient);
sk_sp<GrFragmentProcessor> GrLinearGradient::TestCreate(GrProcessorTestData* d) {
@ -428,7 +434,7 @@ sk_sp<GrFragmentProcessor> GrLinearGradient::TestCreate(GrProcessorTestData* d)
/////////////////////////////////////////////////////////////////////
void GrGLLinearGradient::emitCode(EmitArgs& args) {
void GrLinearGradient::GLSLLinearProcessor::emitCode(EmitArgs& args) {
const GrLinearGradient& ge = args.fFp.cast<GrLinearGradient>();
this->emitUniforms(args.fUniformHandler, ge);
SkString t = args.fFragBuilder->ensureFSCoords2D(args.fCoords, 0);
@ -436,7 +442,8 @@ void GrGLLinearGradient::emitCode(EmitArgs& args) {
this->emitColor(args.fFragBuilder,
args.fUniformHandler,
args.fGLSLCaps,
ge, t.c_str(),
ge,
t.c_str(),
args.fOutputColor,
args.fInputColor,
args.fTexSamplers);

View File

@ -242,28 +242,10 @@ void SkRadialGradient::RadialGradientContext::shadeSpan(int x, int y,
#include "glsl/GrGLSLCaps.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
class GrGLRadialGradient : public GrGLGradientEffect {
public:
GrGLRadialGradient(const GrProcessor&) {}
virtual ~GrGLRadialGradient() { }
virtual void emitCode(EmitArgs&) override;
static void GenKey(const GrProcessor& processor, const GrGLSLCaps&, GrProcessorKeyBuilder* b) {
b->add32(GenBaseGradientKey(processor));
}
private:
typedef GrGLGradientEffect INHERITED;
};
/////////////////////////////////////////////////////////////////////
class GrRadialGradient : public GrGradientEffect {
public:
class GLSLRadialProcessor;
static sk_sp<GrFragmentProcessor> Make(GrContext* ctx,
const SkRadialGradient& shader,
const SkMatrix& matrix,
@ -284,14 +266,10 @@ private:
this->initClassID<GrRadialGradient>();
}
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override {
return new GrGLRadialGradient(*this);
}
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
virtual void onGetGLSLProcessorKey(const GrGLSLCaps& caps,
GrProcessorKeyBuilder* b) const override {
GrGLRadialGradient::GenKey(*this, caps, b);
}
GrProcessorKeyBuilder* b) const override;
GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
@ -300,6 +278,35 @@ private:
/////////////////////////////////////////////////////////////////////
class GrRadialGradient::GLSLRadialProcessor : public GrGradientEffect::GLSLProcessor {
public:
GLSLRadialProcessor(const GrProcessor&) {}
virtual ~GLSLRadialProcessor() { }
virtual void emitCode(EmitArgs&) override;
static void GenKey(const GrProcessor& processor, const GrGLSLCaps&, GrProcessorKeyBuilder* b) {
b->add32(GenBaseGradientKey(processor));
}
private:
typedef GrGradientEffect::GLSLProcessor INHERITED;
};
/////////////////////////////////////////////////////////////////////
GrGLSLFragmentProcessor* GrRadialGradient::onCreateGLSLInstance() const {
return new GrRadialGradient::GLSLRadialProcessor(*this);
}
void GrRadialGradient::onGetGLSLProcessorKey(const GrGLSLCaps& caps,
GrProcessorKeyBuilder* b) const {
GrRadialGradient::GLSLRadialProcessor::GenKey(*this, caps, b);
}
/////////////////////////////////////////////////////////////////////
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrRadialGradient);
sk_sp<GrFragmentProcessor> GrRadialGradient::TestCreate(GrProcessorTestData* d) {
@ -322,7 +329,7 @@ sk_sp<GrFragmentProcessor> GrRadialGradient::TestCreate(GrProcessorTestData* d)
/////////////////////////////////////////////////////////////////////
void GrGLRadialGradient::emitCode(EmitArgs& args) {
void GrRadialGradient::GLSLRadialProcessor::emitCode(EmitArgs& args) {
const GrRadialGradient& ge = args.fFp.cast<GrRadialGradient>();
this->emitUniforms(args.fUniformHandler, ge);
SkString t("length(");

View File

@ -125,28 +125,10 @@ void SkSweepGradient::SweepGradientContext::shadeSpan(int x, int y, SkPMColor* S
#include "glsl/GrGLSLCaps.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
class GrGLSweepGradient : public GrGLGradientEffect {
public:
GrGLSweepGradient(const GrProcessor&) {}
virtual ~GrGLSweepGradient() { }
virtual void emitCode(EmitArgs&) override;
static void GenKey(const GrProcessor& processor, const GrGLSLCaps&, GrProcessorKeyBuilder* b) {
b->add32(GenBaseGradientKey(processor));
}
private:
typedef GrGLGradientEffect INHERITED;
};
/////////////////////////////////////////////////////////////////////
class GrSweepGradient : public GrGradientEffect {
public:
class GLSLSweepProcessor;
static sk_sp<GrFragmentProcessor> Make(GrContext* ctx, const SkSweepGradient& shader,
const SkMatrix& m) {
return sk_sp<GrFragmentProcessor>(new GrSweepGradient(ctx, shader, m));
@ -163,20 +145,46 @@ private:
this->initClassID<GrSweepGradient>();
}
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override {
return new GrGLSweepGradient(*this);
}
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
virtual void onGetGLSLProcessorKey(const GrGLSLCaps& caps,
GrProcessorKeyBuilder* b) const override {
GrGLSweepGradient::GenKey(*this, caps, b);
}
GrProcessorKeyBuilder* b) const override;
GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
typedef GrGradientEffect INHERITED;
};
/////////////////////////////////////////////////////////////////////
class GrSweepGradient::GLSLSweepProcessor : public GrGradientEffect::GLSLProcessor {
public:
GLSLSweepProcessor(const GrProcessor&) {}
virtual ~GLSLSweepProcessor() { }
virtual void emitCode(EmitArgs&) override;
static void GenKey(const GrProcessor& processor, const GrGLSLCaps&, GrProcessorKeyBuilder* b) {
b->add32(GenBaseGradientKey(processor));
}
private:
typedef GrGradientEffect::GLSLProcessor INHERITED;
};
/////////////////////////////////////////////////////////////////////
GrGLSLFragmentProcessor* GrSweepGradient::onCreateGLSLInstance() const {
return new GrSweepGradient::GLSLSweepProcessor(*this);
}
void GrSweepGradient::onGetGLSLProcessorKey(const GrGLSLCaps& caps,
GrProcessorKeyBuilder* b) const {
GrSweepGradient::GLSLSweepProcessor::GenKey(*this, caps, b);
}
/////////////////////////////////////////////////////////////////////
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrSweepGradient);
@ -201,7 +209,7 @@ sk_sp<GrFragmentProcessor> GrSweepGradient::TestCreate(GrProcessorTestData* d) {
/////////////////////////////////////////////////////////////////////
void GrGLSweepGradient::emitCode(EmitArgs& args) {
void GrSweepGradient::GLSLSweepProcessor::emitCode(EmitArgs& args) {
const GrSweepGradient& ge = args.fFp.cast<GrSweepGradient>();
this->emitUniforms(args.fUniformHandler, ge);
SkString coords2D = args.fFragBuilder->ensureFSCoords2D(args.fCoords, 0);

View File

@ -60,6 +60,7 @@ static void set_matrix_edge_conical(const SkTwoPointConicalGradient& shader,
class Edge2PtConicalEffect : public GrGradientEffect {
public:
class GLSLEdge2PtConicalProcessor;
static sk_sp<GrFragmentProcessor> Make(GrContext* ctx,
const SkTwoPointConicalGradient& shader,
@ -140,10 +141,10 @@ private:
typedef GrGradientEffect INHERITED;
};
class GLEdge2PtConicalEffect : public GrGLGradientEffect {
class Edge2PtConicalEffect::GLSLEdge2PtConicalProcessor : public GrGradientEffect::GLSLProcessor {
public:
GLEdge2PtConicalEffect(const GrProcessor&);
virtual ~GLEdge2PtConicalEffect() { }
GLSLEdge2PtConicalProcessor(const GrProcessor&);
virtual ~GLSLEdge2PtConicalProcessor() { }
virtual void emitCode(EmitArgs&) override;
@ -166,17 +167,17 @@ protected:
// @}
private:
typedef GrGLGradientEffect INHERITED;
typedef GrGradientEffect::GLSLProcessor INHERITED;
};
void Edge2PtConicalEffect::onGetGLSLProcessorKey(const GrGLSLCaps& caps,
GrProcessorKeyBuilder* b) const {
GLEdge2PtConicalEffect::GenKey(*this, caps, b);
Edge2PtConicalEffect::GLSLEdge2PtConicalProcessor::GenKey(*this, caps, b);
}
GrGLSLFragmentProcessor* Edge2PtConicalEffect::onCreateGLSLInstance() const {
return new GLEdge2PtConicalEffect(*this);
return new Edge2PtConicalEffect::GLSLEdge2PtConicalProcessor(*this);
}
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(Edge2PtConicalEffect);
@ -216,13 +217,13 @@ sk_sp<GrFragmentProcessor> Edge2PtConicalEffect::TestCreate(GrProcessorTestData*
return fp;
}
GLEdge2PtConicalEffect::GLEdge2PtConicalEffect(const GrProcessor&)
Edge2PtConicalEffect::GLSLEdge2PtConicalProcessor::GLSLEdge2PtConicalProcessor(const GrProcessor&)
: fVSVaryingName(nullptr)
, fFSVaryingName(nullptr)
, fCachedRadius(-SK_ScalarMax)
, fCachedDiffRadius(-SK_ScalarMax) {}
void GLEdge2PtConicalEffect::emitCode(EmitArgs& args) {
void Edge2PtConicalEffect::GLSLEdge2PtConicalProcessor::emitCode(EmitArgs& args) {
const Edge2PtConicalEffect& ge = args.fFp.cast<Edge2PtConicalEffect>();
GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
this->emitUniforms(uniformHandler, ge);
@ -284,8 +285,9 @@ void GLEdge2PtConicalEffect::emitCode(EmitArgs& args) {
fragBuilder->codeAppend("\t}\n");
}
void GLEdge2PtConicalEffect::onSetData(const GrGLSLProgramDataManager& pdman,
const GrProcessor& processor) {
void Edge2PtConicalEffect::GLSLEdge2PtConicalProcessor::onSetData(
const GrGLSLProgramDataManager& pdman,
const GrProcessor& processor) {
INHERITED::onSetData(pdman, processor);
const Edge2PtConicalEffect& data = processor.cast<Edge2PtConicalEffect>();
SkScalar radius0 = data.radius();
@ -301,7 +303,7 @@ void GLEdge2PtConicalEffect::onSetData(const GrGLSLProgramDataManager& pdman,
}
}
void GLEdge2PtConicalEffect::GenKey(const GrProcessor& processor,
void Edge2PtConicalEffect::GLSLEdge2PtConicalProcessor::GenKey(const GrProcessor& processor,
const GrGLSLCaps&, GrProcessorKeyBuilder* b) {
b->add32(GenBaseGradientKey(processor));
}
@ -370,6 +372,7 @@ static ConicalType set_matrix_focal_conical(const SkTwoPointConicalGradient& sha
class FocalOutside2PtConicalEffect : public GrGradientEffect {
public:
class GLSLFocalOutside2PtConicalProcessor;
static sk_sp<GrFragmentProcessor> Make(GrContext* ctx,
const SkTwoPointConicalGradient& shader,
@ -420,10 +423,11 @@ private:
typedef GrGradientEffect INHERITED;
};
class GLFocalOutside2PtConicalEffect : public GrGLGradientEffect {
class FocalOutside2PtConicalEffect::GLSLFocalOutside2PtConicalProcessor
: public GrGradientEffect::GLSLProcessor {
public:
GLFocalOutside2PtConicalEffect(const GrProcessor&);
virtual ~GLFocalOutside2PtConicalEffect() { }
GLSLFocalOutside2PtConicalProcessor(const GrProcessor&);
virtual ~GLSLFocalOutside2PtConicalProcessor() { }
virtual void emitCode(EmitArgs&) override;
@ -447,17 +451,17 @@ protected:
// @}
private:
typedef GrGLGradientEffect INHERITED;
typedef GrGradientEffect::GLSLProcessor INHERITED;
};
void FocalOutside2PtConicalEffect::onGetGLSLProcessorKey(const GrGLSLCaps& caps,
GrProcessorKeyBuilder* b) const {
GLFocalOutside2PtConicalEffect::GenKey(*this, caps, b);
FocalOutside2PtConicalEffect::GLSLFocalOutside2PtConicalProcessor::GenKey(*this, caps, b);
}
GrGLSLFragmentProcessor* FocalOutside2PtConicalEffect::onCreateGLSLInstance() const {
return new GLFocalOutside2PtConicalEffect(*this);
return new FocalOutside2PtConicalEffect::GLSLFocalOutside2PtConicalProcessor(*this);
}
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(FocalOutside2PtConicalEffect);
@ -494,7 +498,8 @@ sk_sp<GrFragmentProcessor> FocalOutside2PtConicalEffect::TestCreate(GrProcessorT
return fp;
}
GLFocalOutside2PtConicalEffect::GLFocalOutside2PtConicalEffect(const GrProcessor& processor)
FocalOutside2PtConicalEffect::GLSLFocalOutside2PtConicalProcessor
::GLSLFocalOutside2PtConicalProcessor(const GrProcessor& processor)
: fVSVaryingName(nullptr)
, fFSVaryingName(nullptr)
, fCachedFocal(SK_ScalarMax) {
@ -502,7 +507,7 @@ GLFocalOutside2PtConicalEffect::GLFocalOutside2PtConicalEffect(const GrProcessor
fIsFlipped = data.isFlipped();
}
void GLFocalOutside2PtConicalEffect::emitCode(EmitArgs& args) {
void FocalOutside2PtConicalEffect::GLSLFocalOutside2PtConicalProcessor::emitCode(EmitArgs& args) {
const FocalOutside2PtConicalEffect& ge = args.fFp.cast<FocalOutside2PtConicalEffect>();
GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
this->emitUniforms(uniformHandler, ge);
@ -554,8 +559,9 @@ void GLFocalOutside2PtConicalEffect::emitCode(EmitArgs& args) {
fragBuilder->codeAppend("\t}\n");
}
void GLFocalOutside2PtConicalEffect::onSetData(const GrGLSLProgramDataManager& pdman,
const GrProcessor& processor) {
void FocalOutside2PtConicalEffect::GLSLFocalOutside2PtConicalProcessor::onSetData(
const GrGLSLProgramDataManager& pdman,
const GrProcessor& processor) {
INHERITED::onSetData(pdman, processor);
const FocalOutside2PtConicalEffect& data = processor.cast<FocalOutside2PtConicalEffect>();
SkASSERT(data.isFlipped() == fIsFlipped);
@ -569,7 +575,8 @@ void GLFocalOutside2PtConicalEffect::onSetData(const GrGLSLProgramDataManager& p
}
}
void GLFocalOutside2PtConicalEffect::GenKey(const GrProcessor& processor,
void FocalOutside2PtConicalEffect::GLSLFocalOutside2PtConicalProcessor::GenKey(
const GrProcessor& processor,
const GrGLSLCaps&, GrProcessorKeyBuilder* b) {
uint32_t* key = b->add32n(2);
key[0] = GenBaseGradientKey(processor);
@ -578,10 +585,9 @@ void GLFocalOutside2PtConicalEffect::GenKey(const GrProcessor& processor,
//////////////////////////////////////////////////////////////////////////////
class GLFocalInside2PtConicalEffect;
class FocalInside2PtConicalEffect : public GrGradientEffect {
public:
class GLSLFocalInside2PtConicalProcessor;
static sk_sp<GrFragmentProcessor> Make(GrContext* ctx,
const SkTwoPointConicalGradient& shader,
@ -600,7 +606,7 @@ public:
SkScalar focal() const { return fFocalX; }
typedef GLFocalInside2PtConicalEffect GLSLProcessor;
typedef FocalInside2PtConicalEffect::GLSLFocalInside2PtConicalProcessor GLSLProcessor;
private:
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
@ -629,10 +635,11 @@ private:
typedef GrGradientEffect INHERITED;
};
class GLFocalInside2PtConicalEffect : public GrGLGradientEffect {
class FocalInside2PtConicalEffect::GLSLFocalInside2PtConicalProcessor
: public GrGradientEffect::GLSLProcessor {
public:
GLFocalInside2PtConicalEffect(const GrProcessor&);
virtual ~GLFocalInside2PtConicalEffect() {}
GLSLFocalInside2PtConicalProcessor(const GrProcessor&);
virtual ~GLSLFocalInside2PtConicalProcessor() {}
virtual void emitCode(EmitArgs&) override;
@ -654,17 +661,17 @@ protected:
// @}
private:
typedef GrGLGradientEffect INHERITED;
typedef GrGradientEffect::GLSLProcessor INHERITED;
};
void FocalInside2PtConicalEffect::onGetGLSLProcessorKey(const GrGLSLCaps& caps,
GrProcessorKeyBuilder* b) const {
GLFocalInside2PtConicalEffect::GenKey(*this, caps, b);
FocalInside2PtConicalEffect::GLSLFocalInside2PtConicalProcessor::GenKey(*this, caps, b);
}
GrGLSLFragmentProcessor* FocalInside2PtConicalEffect::onCreateGLSLInstance() const {
return new GLFocalInside2PtConicalEffect(*this);
return new FocalInside2PtConicalEffect::GLSLFocalInside2PtConicalProcessor(*this);
}
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(FocalInside2PtConicalEffect);
@ -703,12 +710,13 @@ sk_sp<GrFragmentProcessor> FocalInside2PtConicalEffect::TestCreate(GrProcessorTe
return fp;
}
GLFocalInside2PtConicalEffect::GLFocalInside2PtConicalEffect(const GrProcessor&)
FocalInside2PtConicalEffect::GLSLFocalInside2PtConicalProcessor
::GLSLFocalInside2PtConicalProcessor(const GrProcessor&)
: fVSVaryingName(nullptr)
, fFSVaryingName(nullptr)
, fCachedFocal(SK_ScalarMax) {}
void GLFocalInside2PtConicalEffect::emitCode(EmitArgs& args) {
void FocalInside2PtConicalEffect::GLSLFocalInside2PtConicalProcessor::emitCode(EmitArgs& args) {
const FocalInside2PtConicalEffect& ge = args.fFp.cast<FocalInside2PtConicalEffect>();
GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
this->emitUniforms(uniformHandler, ge);
@ -740,8 +748,9 @@ void GLFocalInside2PtConicalEffect::emitCode(EmitArgs& args) {
args.fTexSamplers);
}
void GLFocalInside2PtConicalEffect::onSetData(const GrGLSLProgramDataManager& pdman,
const GrProcessor& processor) {
void FocalInside2PtConicalEffect::GLSLFocalInside2PtConicalProcessor::onSetData(
const GrGLSLProgramDataManager& pdman,
const GrProcessor& processor) {
INHERITED::onSetData(pdman, processor);
const FocalInside2PtConicalEffect& data = processor.cast<FocalInside2PtConicalEffect>();
SkScalar focal = data.focal();
@ -752,8 +761,9 @@ void GLFocalInside2PtConicalEffect::onSetData(const GrGLSLProgramDataManager& pd
}
}
void GLFocalInside2PtConicalEffect::GenKey(const GrProcessor& processor,
const GrGLSLCaps&, GrProcessorKeyBuilder* b) {
void FocalInside2PtConicalEffect::GLSLFocalInside2PtConicalProcessor::GenKey(
const GrProcessor& processor,
const GrGLSLCaps&, GrProcessorKeyBuilder* b) {
b->add32(GenBaseGradientKey(processor));
}
@ -823,6 +833,7 @@ static ConicalType set_matrix_circle_conical(const SkTwoPointConicalGradient& sh
class CircleInside2PtConicalEffect : public GrGradientEffect {
public:
class GLSLCircleInside2PtConicalProcessor;
static sk_sp<GrFragmentProcessor> Make(GrContext* ctx,
const SkTwoPointConicalGradient& shader,
@ -874,10 +885,11 @@ private:
typedef GrGradientEffect INHERITED;
};
class GLCircleInside2PtConicalEffect : public GrGLGradientEffect {
class CircleInside2PtConicalEffect::GLSLCircleInside2PtConicalProcessor
: public GrGradientEffect::GLSLProcessor {
public:
GLCircleInside2PtConicalEffect(const GrProcessor&);
virtual ~GLCircleInside2PtConicalEffect() {}
GLSLCircleInside2PtConicalProcessor(const GrProcessor&);
virtual ~GLSLCircleInside2PtConicalProcessor() {}
virtual void emitCode(EmitArgs&) override;
@ -904,17 +916,17 @@ protected:
// @}
private:
typedef GrGLGradientEffect INHERITED;
typedef GrGradientEffect::GLSLProcessor INHERITED;
};
void CircleInside2PtConicalEffect::onGetGLSLProcessorKey(const GrGLSLCaps& caps,
GrProcessorKeyBuilder* b) const {
GLCircleInside2PtConicalEffect::GenKey(*this, caps, b);
CircleInside2PtConicalEffect::GLSLCircleInside2PtConicalProcessor::GenKey(*this, caps, b);
}
GrGLSLFragmentProcessor* CircleInside2PtConicalEffect::onCreateGLSLInstance() const {
return new GLCircleInside2PtConicalEffect(*this);
return new CircleInside2PtConicalEffect::GLSLCircleInside2PtConicalProcessor(*this);
}
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(CircleInside2PtConicalEffect);
@ -952,7 +964,8 @@ sk_sp<GrFragmentProcessor> CircleInside2PtConicalEffect::TestCreate(GrProcessorT
return fp;
}
GLCircleInside2PtConicalEffect::GLCircleInside2PtConicalEffect(const GrProcessor& processor)
CircleInside2PtConicalEffect::GLSLCircleInside2PtConicalProcessor
::GLSLCircleInside2PtConicalProcessor(const GrProcessor& processor)
: fVSVaryingName(nullptr)
, fFSVaryingName(nullptr)
, fCachedCenterX(SK_ScalarMax)
@ -961,7 +974,7 @@ GLCircleInside2PtConicalEffect::GLCircleInside2PtConicalEffect(const GrProcessor
, fCachedB(SK_ScalarMax)
, fCachedC(SK_ScalarMax) {}
void GLCircleInside2PtConicalEffect::emitCode(EmitArgs& args) {
void CircleInside2PtConicalEffect::GLSLCircleInside2PtConicalProcessor::emitCode(EmitArgs& args) {
const CircleInside2PtConicalEffect& ge = args.fFp.cast<CircleInside2PtConicalEffect>();
GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
this->emitUniforms(uniformHandler, ge);
@ -1008,8 +1021,9 @@ void GLCircleInside2PtConicalEffect::emitCode(EmitArgs& args) {
args.fTexSamplers);
}
void GLCircleInside2PtConicalEffect::onSetData(const GrGLSLProgramDataManager& pdman,
const GrProcessor& processor) {
void CircleInside2PtConicalEffect::GLSLCircleInside2PtConicalProcessor::onSetData(
const GrGLSLProgramDataManager& pdman,
const GrProcessor& processor) {
INHERITED::onSetData(pdman, processor);
const CircleInside2PtConicalEffect& data = processor.cast<CircleInside2PtConicalEffect>();
SkScalar centerX = data.centerX();
@ -1032,7 +1046,8 @@ void GLCircleInside2PtConicalEffect::onSetData(const GrGLSLProgramDataManager& p
}
}
void GLCircleInside2PtConicalEffect::GenKey(const GrProcessor& processor,
void CircleInside2PtConicalEffect::GLSLCircleInside2PtConicalProcessor::GenKey(
const GrProcessor& processor,
const GrGLSLCaps&, GrProcessorKeyBuilder* b) {
b->add32(GenBaseGradientKey(processor));
}
@ -1041,6 +1056,7 @@ void GLCircleInside2PtConicalEffect::GenKey(const GrProcessor& processor,
class CircleOutside2PtConicalEffect : public GrGradientEffect {
public:
class GLSLCircleOutside2PtConicalProcessor;
static sk_sp<GrFragmentProcessor> Make(GrContext* ctx,
const SkTwoPointConicalGradient& shader,
@ -1104,10 +1120,11 @@ private:
typedef GrGradientEffect INHERITED;
};
class GLCircleOutside2PtConicalEffect : public GrGLGradientEffect {
class CircleOutside2PtConicalEffect::GLSLCircleOutside2PtConicalProcessor
: public GrGradientEffect::GLSLProcessor {
public:
GLCircleOutside2PtConicalEffect(const GrProcessor&);
virtual ~GLCircleOutside2PtConicalEffect() {}
GLSLCircleOutside2PtConicalProcessor(const GrProcessor&);
virtual ~GLSLCircleOutside2PtConicalProcessor() {}
virtual void emitCode(EmitArgs&) override;
@ -1137,17 +1154,17 @@ protected:
// @}
private:
typedef GrGLGradientEffect INHERITED;
typedef GrGradientEffect::GLSLProcessor INHERITED;
};
void CircleOutside2PtConicalEffect::onGetGLSLProcessorKey(const GrGLSLCaps& caps,
GrProcessorKeyBuilder* b) const {
GLCircleOutside2PtConicalEffect::GenKey(*this, caps, b);
CircleOutside2PtConicalEffect::GLSLCircleOutside2PtConicalProcessor::GenKey(*this, caps, b);
}
GrGLSLFragmentProcessor* CircleOutside2PtConicalEffect::onCreateGLSLInstance() const {
return new GLCircleOutside2PtConicalEffect(*this);
return new CircleOutside2PtConicalEffect::GLSLCircleOutside2PtConicalProcessor(*this);
}
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(CircleOutside2PtConicalEffect);
@ -1186,7 +1203,8 @@ sk_sp<GrFragmentProcessor> CircleOutside2PtConicalEffect::TestCreate(GrProcessor
return fp;
}
GLCircleOutside2PtConicalEffect::GLCircleOutside2PtConicalEffect(const GrProcessor& processor)
CircleOutside2PtConicalEffect::GLSLCircleOutside2PtConicalProcessor
::GLSLCircleOutside2PtConicalProcessor(const GrProcessor& processor)
: fVSVaryingName(nullptr)
, fFSVaryingName(nullptr)
, fCachedCenterX(SK_ScalarMax)
@ -1199,7 +1217,7 @@ GLCircleOutside2PtConicalEffect::GLCircleOutside2PtConicalEffect(const GrProcess
fIsFlipped = data.isFlipped();
}
void GLCircleOutside2PtConicalEffect::emitCode(EmitArgs& args) {
void CircleOutside2PtConicalEffect::GLSLCircleOutside2PtConicalProcessor::emitCode(EmitArgs& args) {
const CircleOutside2PtConicalEffect& ge = args.fFp.cast<CircleOutside2PtConicalEffect>();
GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
this->emitUniforms(uniformHandler, ge);
@ -1263,7 +1281,8 @@ void GLCircleOutside2PtConicalEffect::emitCode(EmitArgs& args) {
fragBuilder->codeAppend("\t}\n");
}
void GLCircleOutside2PtConicalEffect::onSetData(const GrGLSLProgramDataManager& pdman,
void CircleOutside2PtConicalEffect::GLSLCircleOutside2PtConicalProcessor::onSetData(
const GrGLSLProgramDataManager& pdman,
const GrProcessor& processor) {
INHERITED::onSetData(pdman, processor);
const CircleOutside2PtConicalEffect& data = processor.cast<CircleOutside2PtConicalEffect>();
@ -1291,8 +1310,9 @@ void GLCircleOutside2PtConicalEffect::onSetData(const GrGLSLProgramDataManager&
}
}
void GLCircleOutside2PtConicalEffect::GenKey(const GrProcessor& processor,
const GrGLSLCaps&, GrProcessorKeyBuilder* b) {
void CircleOutside2PtConicalEffect::GLSLCircleOutside2PtConicalProcessor::GenKey(
const GrProcessor& processor,
const GrGLSLCaps&, GrProcessorKeyBuilder* b) {
uint32_t* key = b->add32n(2);
key[0] = GenBaseGradientKey(processor);
key[1] = processor.cast<CircleOutside2PtConicalEffect>().isFlipped();