Add more specialized fragment builders

Adds specialized fragment builders for primitive and fragment
processors. Removes fragment-specific functionality from the Xfer
fragment builder.

BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1709153002

Review URL: https://codereview.chromium.org/1709153002
This commit is contained in:
cdalton 2016-02-18 12:37:07 -08:00 committed by Commit bot
parent d689bf8748
commit 8528541dd7
47 changed files with 170 additions and 151 deletions

View File

@ -46,7 +46,7 @@ void GrGLCircleBlurFragmentProcessor::emitCode(EmitArgs& args) {
"data",
&dataName);
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
const char *fragmentPos = fragBuilder->fragmentPosition();
if (args.fInputColor) {

View File

@ -164,7 +164,7 @@ void GrGLAlphaThresholdEffect::emitCode(EmitArgs& args) {
kFloat_GrSLType, kDefault_GrSLPrecision,
"outer_threshold");
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
SkString coords2D = fragBuilder->ensureFSCoords2D(args.fCoords, 0);
SkString maskCoords2D = fragBuilder->ensureFSCoords2D(args.fCoords, 1);

View File

@ -58,7 +58,7 @@ public:
void emitCode(EmitArgs& args) override {
const GrArithmeticFP& arith = args.fFp.cast<GrArithmeticFP>();
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
SkString dstColor("dstColor");
this->emitChild(0, nullptr, &dstColor, args);

View File

@ -272,7 +272,7 @@ public:
void emitCode(EmitArgs& args) override {
const AvoidFP& avoid = args.fFp.cast<AvoidFP>();
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
SkString dstColor("dstColor");
this->emitChild(0, nullptr, &dstColor, args);

View File

@ -690,7 +690,7 @@ private:
typedef GrGLSLFragmentProcessor INHERITED;
};
void OutputRectBlurProfileLookup(GrGLSLFragmentBuilder* fragBuilder,
void OutputRectBlurProfileLookup(GrGLSLFPFragmentBuilder* fragBuilder,
const GrGLSLTextureSampler& sampler,
const char *output,
const char *profileSize, const char *loc,
@ -735,7 +735,7 @@ void GrGLRectBlurEffect::emitCode(EmitArgs& args) {
"profileSize",
&profileSizeName);
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
const char *fragmentPos = fragBuilder->fragmentPosition();
if (args.fInputColor) {
@ -1082,7 +1082,7 @@ void GrGLRRectBlurEffect::emitCode(EmitArgs& args) {
"blurRadius",
&blurRadiusName);
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
const char* fragmentPos = fragBuilder->fragmentPosition();
// warp the fragment position to the appropriate part of the 9patch blur texture

View File

@ -256,7 +256,7 @@ void GrColorCubeEffect::GLSLProcessor::emitCode(EmitArgs& args) {
// Note: if implemented using texture3D in OpenGL ES older than OpenGL ES 3.0,
// the shader might need "#extension GL_OES_texture_3D : enable".
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
// Unpremultiply color
fragBuilder->codeAppendf("\tfloat %s = max(%s.a, 0.00001);\n", nonZeroAlpha, args.fInputColor);

View File

@ -553,7 +553,7 @@ void GrGLDisplacementMapEffect::emitCode(EmitArgs& args) {
// a number smaller than that to approximate 0, but
// leave room for 32-bit float GPU rounding errors.
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
fragBuilder->codeAppendf("\t\tvec4 %s = ", dColor);
fragBuilder->appendTextureLookup(args.fSamplers[0], args.fCoords[0].c_str(),
args.fCoords[0].getType());

View File

@ -660,10 +660,10 @@ public:
* and so this function only needs to be overridden if the light color varies spatially.
*/
virtual void emitSurfaceToLight(GrGLSLUniformHandler*,
GrGLSLFragmentBuilder*,
GrGLSLFPFragmentBuilder*,
const char* z) = 0;
virtual void emitLightColor(GrGLSLUniformHandler*,
GrGLSLFragmentBuilder*,
GrGLSLFPFragmentBuilder*,
const char *surfaceToLight);
// This is called from GrGLLightingEffect's setData(). Subclasses of GrGLLight must call
@ -689,7 +689,7 @@ class GrGLDistantLight : public GrGLLight {
public:
virtual ~GrGLDistantLight() {}
void setData(const GrGLSLProgramDataManager&, const SkImageFilterLight* light) const override;
void emitSurfaceToLight(GrGLSLUniformHandler*, GrGLSLFragmentBuilder*, const char* z) override;
void emitSurfaceToLight(GrGLSLUniformHandler*, GrGLSLFPFragmentBuilder*, const char* z) override;
private:
typedef GrGLLight INHERITED;
@ -702,7 +702,7 @@ class GrGLPointLight : public GrGLLight {
public:
virtual ~GrGLPointLight() {}
void setData(const GrGLSLProgramDataManager&, const SkImageFilterLight* light) const override;
void emitSurfaceToLight(GrGLSLUniformHandler*, GrGLSLFragmentBuilder*, const char* z) override;
void emitSurfaceToLight(GrGLSLUniformHandler*, GrGLSLFPFragmentBuilder*, const char* z) override;
private:
typedef GrGLLight INHERITED;
@ -715,9 +715,9 @@ class GrGLSpotLight : public GrGLLight {
public:
virtual ~GrGLSpotLight() {}
void setData(const GrGLSLProgramDataManager&, const SkImageFilterLight* light) const override;
void emitSurfaceToLight(GrGLSLUniformHandler*, GrGLSLFragmentBuilder*, const char* z) override;
void emitSurfaceToLight(GrGLSLUniformHandler*, GrGLSLFPFragmentBuilder*, const char* z) override;
void emitLightColor(GrGLSLUniformHandler*,
GrGLSLFragmentBuilder*,
GrGLSLFPFragmentBuilder*,
const char *surfaceToLight) override;
private:
@ -1584,7 +1584,7 @@ protected:
void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
virtual void emitLightFunc(GrGLSLUniformHandler*,
GrGLSLFragmentBuilder*,
GrGLSLFPFragmentBuilder*,
SkString* funcName) = 0;
private:
@ -1600,7 +1600,7 @@ private:
class GrGLDiffuseLightingEffect : public GrGLLightingEffect {
public:
void emitLightFunc(GrGLSLUniformHandler*, GrGLSLFragmentBuilder*, SkString* funcName) override;
void emitLightFunc(GrGLSLUniformHandler*, GrGLSLFPFragmentBuilder*, SkString* funcName) override;
protected:
void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
@ -1615,7 +1615,7 @@ private:
class GrGLSpecularLightingEffect : public GrGLLightingEffect {
public:
void emitLightFunc(GrGLSLUniformHandler*, GrGLSLFragmentBuilder*, SkString* funcName) override;
void emitLightFunc(GrGLSLUniformHandler*, GrGLSLFPFragmentBuilder*, SkString* funcName) override;
protected:
void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
@ -1737,7 +1737,7 @@ void GrGLLightingEffect::emitCode(EmitArgs& args) {
kFloat_GrSLType, kDefault_GrSLPrecision,
"SurfaceScale");
fLight->emitLightColorUniform(uniformHandler);
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
SkString lightFunc;
this->emitLightFunc(uniformHandler, fragBuilder, &lightFunc);
static const GrGLSLShaderVar gSobelArgs[] = {
@ -1854,7 +1854,7 @@ void GrGLLightingEffect::onSetData(const GrGLSLProgramDataManager& pdman,
///////////////////////////////////////////////////////////////////////////////
void GrGLDiffuseLightingEffect::emitLightFunc(GrGLSLUniformHandler* uniformHandler,
GrGLSLFragmentBuilder* fragBuilder,
GrGLSLFPFragmentBuilder* fragBuilder,
SkString* funcName) {
const char* kd;
fKDUni = uniformHandler->addUniform(kFragment_GrShaderFlag,
@ -1943,7 +1943,7 @@ const GrFragmentProcessor* GrSpecularLightingEffect::TestCreate(GrProcessorTestD
///////////////////////////////////////////////////////////////////////////////
void GrGLSpecularLightingEffect::emitLightFunc(GrGLSLUniformHandler* uniformHandler,
GrGLSLFragmentBuilder* fragBuilder,
GrGLSLFPFragmentBuilder* fragBuilder,
SkString* funcName) {
const char* ks;
const char* shininess;
@ -1990,7 +1990,7 @@ void GrGLLight::emitLightColorUniform(GrGLSLUniformHandler* uniformHandler) {
}
void GrGLLight::emitLightColor(GrGLSLUniformHandler* uniformHandler,
GrGLSLFragmentBuilder* fragBuilder,
GrGLSLFPFragmentBuilder* fragBuilder,
const char *surfaceToLight) {
fragBuilder->codeAppend(uniformHandler->getUniformCStr(this->lightColorUni()));
}
@ -2012,7 +2012,7 @@ void GrGLDistantLight::setData(const GrGLSLProgramDataManager& pdman,
}
void GrGLDistantLight::emitSurfaceToLight(GrGLSLUniformHandler* uniformHandler,
GrGLSLFragmentBuilder* fragBuilder,
GrGLSLFPFragmentBuilder* fragBuilder,
const char* z) {
const char* dir;
fDirectionUni = uniformHandler->addUniform(kFragment_GrShaderFlag,
@ -2032,7 +2032,7 @@ void GrGLPointLight::setData(const GrGLSLProgramDataManager& pdman,
}
void GrGLPointLight::emitSurfaceToLight(GrGLSLUniformHandler* uniformHandler,
GrGLSLFragmentBuilder* fragBuilder,
GrGLSLFPFragmentBuilder* fragBuilder,
const char* z) {
const char* loc;
fLocationUni = uniformHandler->addUniform(kFragment_GrShaderFlag,
@ -2058,7 +2058,7 @@ void GrGLSpotLight::setData(const GrGLSLProgramDataManager& pdman,
}
void GrGLSpotLight::emitSurfaceToLight(GrGLSLUniformHandler* uniformHandler,
GrGLSLFragmentBuilder* fragBuilder,
GrGLSLFPFragmentBuilder* fragBuilder,
const char* z) {
const char* location;
fLocationUni = uniformHandler->addUniform(kFragment_GrShaderFlag,
@ -2070,7 +2070,7 @@ void GrGLSpotLight::emitSurfaceToLight(GrGLSLUniformHandler* uniformHandler,
}
void GrGLSpotLight::emitLightColor(GrGLSLUniformHandler* uniformHandler,
GrGLSLFragmentBuilder* fragBuilder,
GrGLSLFPFragmentBuilder* fragBuilder,
const char *surfaceToLight) {
const char* color = uniformHandler->getUniformCStr(this->lightColorUni()); // created by parent class.

View File

@ -69,7 +69,7 @@ public:
args.fInputColor = "vec4(1)";
}
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
fragBuilder->codeAppendf("\tfloat luma = dot(vec3(%f, %f, %f), %s.rgb);\n",
SK_ITU_BT709_LUM_COEFF_R,
SK_ITU_BT709_LUM_COEFF_G,

View File

@ -129,7 +129,7 @@ void GrGLMagnifierEffect::emitCode(EmitArgs& args) {
kVec4f_GrSLType, kDefault_GrSLPrecision,
"Bounds");
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
SkString coords2D = fragBuilder->ensureFSCoords2D(args.fCoords, 0);
fragBuilder->codeAppendf("\t\tvec2 coord = %s;\n", coords2D.c_str());
fragBuilder->codeAppendf("\t\tvec2 zoom_coord = %s + %s * %s;\n",

View File

@ -281,7 +281,7 @@ void GrGLMorphologyEffect::emitCode(EmitArgs& args) {
"Range");
const char* range = uniformHandler->getUniformCStr(fRangeUni);
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
SkString coords2D = fragBuilder->ensureFSCoords2D(args.fCoords, 0);
const char* func;
switch (me.type()) {

View File

@ -594,7 +594,7 @@ const GrFragmentProcessor* GrPerlinNoiseEffect::TestCreate(GrProcessorTestData*
void GrGLPerlinNoise::emitCode(EmitArgs& args) {
const GrPerlinNoiseEffect& pne = args.fFp.cast<GrPerlinNoiseEffect>();
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
SkString vCoords = fragBuilder->ensureFSCoords2D(args.fCoords, 0);

View File

@ -172,7 +172,7 @@ private:
class GLPixelXorFP : public GrGLSLFragmentProcessor {
public:
void emitCode(EmitArgs& args) override {
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
SkString dstColor("dstColor");
this->emitChild(0, nullptr, &dstColor, args);

View File

@ -415,7 +415,7 @@ void GLColorTableEffect::emitCode(EmitArgs& args) {
"yoffsets", &yoffsets);
static const float kColorScaleFactor = 255.0f / 256.0f;
static const float kColorOffsetFactor = 1.0f / 512.0f;
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
if (nullptr == args.fInputColor) {
// the input color is solid white (all ones).
static const float kMaxValue = kColorScaleFactor + kColorOffsetFactor;

View File

@ -1020,7 +1020,7 @@ uint32_t GrGLGradientEffect::GenBaseGradientKey(const GrProcessor& processor) {
return key;
}
void GrGLGradientEffect::emitColor(GrGLSLFragmentBuilder* fragBuilder,
void GrGLGradientEffect::emitColor(GrGLSLFPFragmentBuilder* fragBuilder,
GrGLSLUniformHandler* uniformHandler,
const GrGLSLCaps* glslCaps,
const GrGradientEffect& ge,

View File

@ -424,7 +424,7 @@ protected:
// emit code that gets a fragment's color from an expression for t; Has branches for 3 separate
// control flows inside -- 2 color gradients, 3 color symmetric gradients (both using
// native GLSL mix), and 4+ color gradients that use the traditional texture lookup.
void emitColor(GrGLSLFragmentBuilder* fragBuilder,
void emitColor(GrGLSLFPFragmentBuilder* fragBuilder,
GrGLSLUniformHandler* uniformHandler,
const GrGLSLCaps* caps,
const GrGradientEffect&,

View File

@ -245,7 +245,7 @@ void GLEdge2PtConicalEffect::emitCode(EmitArgs& args) {
SkASSERT(args.fCoords[0].getType() == args.fCoords[1].getType());
const char* coords2D;
SkString bVar;
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
if (kVec3f_GrSLType == args.fCoords[0].getType()) {
fragBuilder->codeAppendf("\tvec3 interpolants = vec3(%s.xy / %s.z, %s.x / %s.z);\n",
args.fCoords[0].c_str(), args.fCoords[0].c_str(),
@ -521,7 +521,7 @@ void GLFocalOutside2PtConicalEffect::emitCode(EmitArgs& args) {
uniformHandler->getUniformVariable(fParamUni).appendArrayAccess(1, &p1);
// if we have a vec3 from being in perspective, convert it to a vec2 first
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
SkString coords2DString = fragBuilder->ensureFSCoords2D(args.fCoords, 0);
const char* coords2D = coords2DString.c_str();
@ -730,7 +730,7 @@ void GLFocalInside2PtConicalEffect::emitCode(EmitArgs& args) {
GrGLSLShaderVar focal = uniformHandler->getUniformVariable(fFocalUni);
// if we have a vec3 from being in perspective, convert it to a vec2 first
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
SkString coords2DString = fragBuilder->ensureFSCoords2D(args.fCoords, 0);
const char* coords2D = coords2DString.c_str();
@ -987,7 +987,7 @@ void GLCircleInside2PtConicalEffect::emitCode(EmitArgs& args) {
GrGLSLShaderVar params = uniformHandler->getUniformVariable(fParamUni);
// if we have a vec3 from being in perspective, convert it to a vec2 first
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
SkString coords2DString = fragBuilder->ensureFSCoords2D(args.fCoords, 0);
const char* coords2D = coords2DString.c_str();
@ -1224,7 +1224,7 @@ void GLCircleOutside2PtConicalEffect::emitCode(EmitArgs& args) {
GrGLSLShaderVar params = uniformHandler->getUniformVariable(fParamUni);
// if we have a vec3 from being in perspective, convert it to a vec2 first
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
SkString coords2DString = fragBuilder->ensureFSCoords2D(args.fCoords, 0);
const char* coords2D = coords2DString.c_str();

View File

@ -65,7 +65,7 @@ public:
void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override {
const DefaultGeoProc& gp = args.fGP.cast<DefaultGeoProc>();
GrGLSLVertexBuilder* vertBuilder = args.fVertBuilder;
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
GrGLSLPPFragmentBuilder* fragBuilder = args.fFragBuilder;
GrGLSLVaryingHandler* varyingHandler = args.fVaryingHandler;
GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;

View File

@ -153,7 +153,7 @@ const GrFragmentProcessor* GrFragmentProcessor::MulOutputByInputUnpremulColor(
class GLFP : public GrGLSLFragmentProcessor {
public:
void emitCode(EmitArgs& args) override {
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
this->emitChild(0, nullptr, args);
fragBuilder->codeAppendf("%s.rgb *= %s.rgb;", args.fOutputColor,
args.fInputColor);

View File

@ -113,7 +113,7 @@ public:
varyingHandler->addVarying("CircleEdge", &v);
vertBuilder->codeAppendf("%s = %s;", v.vsOut(), ce.inCircleEdge()->fName);
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
GrGLSLPPFragmentBuilder* fragBuilder = args.fFragBuilder;
// setup pass through color
if (!ce.colorIgnored()) {
varyingHandler->addPassThroughAttribute(ce.inColor(), args.fOutputColor);
@ -268,7 +268,7 @@ public:
vertBuilder->codeAppendf("%s = %s;", ellipseRadii.vsOut(),
ee.inEllipseRadii()->fName);
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
GrGLSLPPFragmentBuilder* fragBuilder = args.fFragBuilder;
// setup pass through color
if (!ee.colorIgnored()) {
varyingHandler->addPassThroughAttribute(ee.inColor(), args.fOutputColor);
@ -443,7 +443,7 @@ public:
vertBuilder->codeAppendf("%s = %s;", offsets1.vsOut(),
ee.inEllipseOffsets1()->fName);
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
GrGLSLPPFragmentBuilder* fragBuilder = args.fFragBuilder;
// setup pass through color
if (!ee.colorIgnored()) {
varyingHandler->addPassThroughAttribute(ee.inColor(), args.fOutputColor);

View File

@ -27,7 +27,7 @@ public:
}
void emitCode(EmitArgs& args) override {
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
GrGLSLPPFragmentBuilder* fragBuilder = args.fFragBuilder;
const GrPathProcessor& pathProc = args.fGP.cast<GrPathProcessor>();
if (!pathProc.viewMatrix().hasPerspective()) {

View File

@ -562,7 +562,7 @@ public:
varyingHandler->addVarying("QuadEdge", &v);
vertBuilder->codeAppendf("%s = %s;", v.vsOut(), qe.inQuadEdge()->fName);
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
GrGLSLPPFragmentBuilder* fragBuilder = args.fFragBuilder;
// Setup pass through color
if (!qe.colorIgnored()) {
this->setupUniformColor(fragBuilder, uniformHandler, args.fOutputColor,

View File

@ -336,7 +336,7 @@ public:
te.inPosition()->fName, te.localMatrix(), args.fTransformsIn,
args.fTransformsOut);
GrGLSLFragmentBuilder* fsBuilder = args.fFragBuilder;
GrGLSLPPFragmentBuilder* fsBuilder = args.fFragBuilder;
SkAssertResult(fsBuilder->enableFeature(
GrGLSLFragmentShaderBuilder::kPixelLocalStorage_GLSLFeature));
SkAssertResult(fsBuilder->enableFeature(
@ -524,7 +524,7 @@ public:
qe.inPosition()->fName, qe.localMatrix(), args.fTransformsIn,
args.fTransformsOut);
GrGLSLFragmentBuilder* fsBuilder = args.fFragBuilder;
GrGLSLPPFragmentBuilder* fsBuilder = args.fFragBuilder;
SkAssertResult(fsBuilder->enableFeature(
GrGLSLFragmentShaderBuilder::kPixelLocalStorage_GLSLFeature));
SkAssertResult(fsBuilder->enableFeature(
@ -682,7 +682,7 @@ public:
fe.inPosition()->fName, fe.localMatrix(), args.fTransformsIn,
args.fTransformsOut);
GrGLSLFragmentBuilder* fsBuilder = args.fFragBuilder;
GrGLSLPPFragmentBuilder* fsBuilder = args.fFragBuilder;
SkAssertResult(fsBuilder->enableFeature(
GrGLSLFragmentShaderBuilder::kPixelLocalStorage_GLSLFeature));
fsBuilder->declAppendf(GR_GL_PLS_PATH_DATA_DECL);

View File

@ -87,7 +87,7 @@ void GrGLConicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
varyingHandler->addVarying("ConicCoeffs", &v, kHigh_GrSLPrecision);
vertBuilder->codeAppendf("%s = %s;", v.vsOut(), gp.inConicCoeffs()->fName);
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
GrGLSLPPFragmentBuilder* fragBuilder = args.fFragBuilder;
// Setup pass through color
if (!gp.colorIgnored()) {
this->setupUniformColor(fragBuilder, uniformHandler, args.fOutputColor, &fColorUniform);
@ -361,7 +361,7 @@ void GrGLQuadEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
varyingHandler->addVarying("HairQuadEdge", &v);
vertBuilder->codeAppendf("%s = %s;", v.vsOut(), gp.inHairQuadEdge()->fName);
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
GrGLSLPPFragmentBuilder* fragBuilder = args.fFragBuilder;
// Setup pass through color
if (!gp.colorIgnored()) {
this->setupUniformColor(fragBuilder, uniformHandler, args.fOutputColor, &fColorUniform);
@ -564,7 +564,7 @@ void GrGLCubicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
varyingHandler->addVarying("CubicCoeffs", &v, kHigh_GrSLPrecision);
vertBuilder->codeAppendf("%s = %s;", v.vsOut(), gp.inCubicCoeffs()->fName);
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
GrGLSLPPFragmentBuilder* fragBuilder = args.fFragBuilder;
// Setup pass through color
if (!gp.colorIgnored()) {
this->setupUniformColor(fragBuilder, uniformHandler, args.fOutputColor, &fColorUniform);

View File

@ -68,7 +68,7 @@ void GrGLBicubicEffect::emitCode(EmitArgs& args) {
GrGLSLShaderVar("c2", kVec4f_GrSLType),
GrGLSLShaderVar("c3", kVec4f_GrSLType),
};
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
SkString coords2D = fragBuilder->ensureFSCoords2D(args.fCoords, 0);
fragBuilder->emitFunction(kVec4f_GrSLType,
"cubicBlend",

View File

@ -43,7 +43,7 @@ public:
GR_SIGNIFICANT_POW2_DECIMAL_DIG, recipHeight,
cte.inTextureCoords()->fName);
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
GrGLSLPPFragmentBuilder* fragBuilder = args.fFragBuilder;
// Setup pass through color
if (!cte.colorIgnored()) {
if (cte.hasVertexColor()) {

View File

@ -26,7 +26,7 @@ public:
SkString tmpDecl;
tmpVar.appendDecl(args.fGLSLCaps, &tmpDecl);
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
fragBuilder->codeAppendf("%s;", tmpDecl.c_str());

View File

@ -17,7 +17,7 @@ public:
GLConstColorProcessor() : fPrevColor(GrColor_ILLEGAL) {}
void emitCode(EmitArgs& args) override {
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
const char* colorUni;
fColorUniform = args.fUniformHandler->addUniform(kFragment_GrShaderFlag,
kVec4f_GrSLType, kMedium_GrSLPrecision,

View File

@ -110,7 +110,7 @@ void GLAARectEffect::emitCode(EmitArgs& args) {
"rect",
&rectName);
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
const char* fragmentPos = fragBuilder->fragmentPosition();
if (GrProcessorEdgeTypeIsAA(aare.getEdgeType())) {
// The amount of coverage removed in x and y by the edges is computed as a pair of negative
@ -194,7 +194,7 @@ void GrGLConvexPolyEffect::emitCode(EmitArgs& args) {
"edges",
cpe.getEdgeCount(),
&edgeArrayName);
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
fragBuilder->codeAppend("\t\tfloat alpha = 1.0;\n");
fragBuilder->codeAppend("\t\tfloat edge;\n");
const char* fragmentPos = fragBuilder->fragmentPosition();

View File

@ -50,7 +50,7 @@ void GrGLConvolutionEffect::emitCode(EmitArgs& args) {
kFloat_GrSLType, kDefault_GrSLPrecision,
"Kernel", width);
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
SkString coords2D = fragBuilder->ensureFSCoords2D(args.fCoords, 0);
fragBuilder->codeAppendf("%s = vec4(0, 0, 0, 0);", args.fOutputColor);

View File

@ -879,7 +879,7 @@ void GLDashingCircleEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
varyingHandler->addVarying("CircleParams", &circleParams);
vertBuilder->codeAppendf("%s = %s;", circleParams.vsOut(), dce.inCircleParams()->fName);
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
GrGLSLPPFragmentBuilder* fragBuilder = args.fFragBuilder;
// Setup pass through color
if (!dce.colorIgnored()) {
this->setupUniformColor(fragBuilder, uniformHandler, args.fOutputColor, &fColorUniform);
@ -1093,7 +1093,7 @@ void GLDashingLineEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
varyingHandler->addVarying("RectParams", &inRectParams, GrSLPrecision::kHigh_GrSLPrecision);
vertBuilder->codeAppendf("%s = %s;", inRectParams.vsOut(), de.inRectParams()->fName);
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
GrGLSLPPFragmentBuilder* fragBuilder = args.fFragBuilder;
// Setup pass through color
if (!de.colorIgnored()) {
this->setupUniformColor(fragBuilder, uniformHandler, args.fOutputColor, &fColorUniform);

View File

@ -34,7 +34,7 @@ public:
void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override{
const GrDistanceFieldA8TextGeoProc& dfTexEffect =
args.fGP.cast<GrDistanceFieldA8TextGeoProc>();
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
GrGLSLPPFragmentBuilder* fragBuilder = args.fFragBuilder;
SkAssertResult(fragBuilder->enableFeature(
GrGLSLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature));
@ -278,7 +278,7 @@ public:
void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override{
const GrDistanceFieldPathGeoProc& dfTexEffect = args.fGP.cast<GrDistanceFieldPathGeoProc>();
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
GrGLSLPPFragmentBuilder* fragBuilder = args.fFragBuilder;
SkAssertResult(fragBuilder->enableFeature(
GrGLSLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature));
@ -495,7 +495,7 @@ public:
// emit attributes
varyingHandler->emitAttributes(dfTexEffect);
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
GrGLSLPPFragmentBuilder* fragBuilder = args.fFragBuilder;
// setup pass through color
if (!dfTexEffect.colorIgnored()) {

View File

@ -67,7 +67,7 @@ private:
};
void GLDitherEffect::emitCode(EmitArgs& args) {
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
// Generate a random number based on the fragment position. For this
// random number generator, we use the "GLSL rand" function
// that seems to be floating around on the internet. It works under

View File

@ -61,7 +61,7 @@ void GrGLMatrixConvolutionEffect::emitCode(EmitArgs& args) {
const char* gain = uniformHandler->getUniformCStr(fGainUni);
const char* bias = uniformHandler->getUniformCStr(fBiasUni);
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
SkString coords2D = fragBuilder->ensureFSCoords2D(args.fCoords, 0);
fragBuilder->codeAppend("vec4 sum = vec4(0, 0, 0, 0);");
fragBuilder->codeAppendf("vec2 coord = %s - %s * %s;", coords2D.c_str(), kernelOffset, imgInc);

View File

@ -120,7 +120,7 @@ void GLCircleEffect::emitCode(EmitArgs& args) {
"circle",
&circleName);
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
const char* fragmentPos = fragBuilder->fragmentPosition();
SkASSERT(kHairlineAA_GrProcessorEdgeType != ce.getEdgeType());
@ -301,7 +301,7 @@ void GLEllipseEffect::emitCode(EmitArgs& args) {
"scale", &scaleName);
}
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
const char* fragmentPos = fragBuilder->fragmentPosition();
// d is the offset to the ellipse center

View File

@ -175,7 +175,7 @@ void GLCircularRRectEffect::emitCode(EmitArgs& args) {
clampedCircleDistance.printf("clamp(%s.x - length(dxy), 0.0, 1.0);", radiusPlusHalfName);
}
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
const char* fragmentPos = fragBuilder->fragmentPosition();
// At each quarter-circle corner we compute a vector that is the offset of the fragment position
// from the circle center. The vector is pinned in x and y to be in the quarter-plane relevant
@ -513,7 +513,7 @@ void GLEllipticalRRectEffect::emitCode(EmitArgs& args) {
"innerRect",
&rectName);
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
const char* fragmentPos = fragBuilder->fragmentPosition();
// At each quarter-ellipse corner we compute a vector that is the offset of the fragment pos
// to the ellipse center. The vector is pinned in x and y to be in the quarter-plane relevant

View File

@ -14,7 +14,7 @@
class GrGLSimpleTextureEffect : public GrGLSLFragmentProcessor {
public:
void emitCode(EmitArgs& args) override {
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
fragBuilder->codeAppendf("%s = ", args.fOutputColor);
fragBuilder->appendTextureLookupAndModulate(args.fInputColor,
args.fSamplers[0],

View File

@ -192,7 +192,7 @@ void GrGLTextureDomainEffect::emitCode(EmitArgs& args) {
const GrTextureDomainEffect& textureDomainEffect = args.fFp.cast<GrTextureDomainEffect>();
const GrTextureDomain& domain = textureDomainEffect.textureDomain();
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
SkString coords2D = fragBuilder->ensureFSCoords2D(args.fCoords, 0);
fGLDomain.sampleTexture(fragBuilder,
args.fUniformHandler,

View File

@ -87,7 +87,7 @@ GrGLSLFragmentProcessor* ComposeTwoFragmentProcessor::onCreateGLSLInstance() con
void GLComposeTwoFragmentProcessor::emitCode(EmitArgs& args) {
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
const ComposeTwoFragmentProcessor& cs = args.fFp.cast<ComposeTwoFragmentProcessor>();
const char* inputColor = nullptr;
@ -228,7 +228,7 @@ private:
class GLComposeOneFragmentProcessor : public GrGLSLFragmentProcessor {
public:
void emitCode(EmitArgs& args) override {
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
SkXfermode::Mode mode = args.fFp.cast<ComposeOneFragmentProcessor>().mode();
ComposeOneFragmentProcessor::Child child =
args.fFp.cast<ComposeOneFragmentProcessor>().child();

View File

@ -99,7 +99,7 @@ public:
static void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuilder*) {}
void emitCode(EmitArgs& args) override {
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
const char* colorSpaceMatrix = nullptr;
fMatrixUni = args.fUniformHandler->addUniform(kFragment_GrShaderFlag,
@ -225,7 +225,7 @@ public:
GLSLProcessor() : fLastColorSpace(-1), fLastOutputChannels(-1) {}
void emitCode(EmitArgs& args) override {
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
OutputChannels oc = args.fFp.cast<RGBToYUVEffect>().outputChannels();
SkString outputColor("rgbColor");

View File

@ -28,7 +28,7 @@ void GrGLSLFragmentProcessor::emitChild(int childIndex, const char* inputColor,
SkString* outputColor, EmitArgs& args) {
SkASSERT(outputColor);
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
outputColor->append(fragBuilder->getMangleString());
fragBuilder->codeAppendf("vec4 %s;", outputColor->c_str());
this->internalEmitChild(childIndex, inputColor, outputColor->c_str(), args);
@ -36,7 +36,7 @@ void GrGLSLFragmentProcessor::emitChild(int childIndex, const char* inputColor,
void GrGLSLFragmentProcessor::internalEmitChild(int childIndex, const char* inputColor,
const char* outputColor, EmitArgs& args) {
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
fragBuilder->onBeforeChildProcEmitCode(); // call first so mangleString is updated

View File

@ -16,7 +16,7 @@ class GrProcessor;
class GrProcessorKeyBuilder;
class GrGLSLCaps;
class GrGLSLFPBuilder;
class GrGLSLFragmentBuilder;
class GrGLSLFPFragmentBuilder;
class GrGLSLUniformHandler;
class GrGLSLFragmentProcessor {
@ -52,7 +52,7 @@ public:
*/
struct EmitArgs {
EmitArgs(GrGLSLFragmentBuilder* fragBuilder,
EmitArgs(GrGLSLFPFragmentBuilder* fragBuilder,
GrGLSLUniformHandler* uniformHandler,
const GrGLSLCaps* caps,
const GrFragmentProcessor& fp,
@ -68,7 +68,7 @@ public:
, fInputColor(inputColor)
, fCoords(coords)
, fSamplers(samplers) {}
GrGLSLFragmentBuilder* fFragBuilder;
GrGLSLFPFragmentBuilder* fFragBuilder;
GrGLSLUniformHandler* fUniformHandler;
const GrGLSLCaps* fGLSLCaps;
const GrFragmentProcessor& fFp;

View File

@ -68,12 +68,15 @@ GrGLSLFragmentShaderBuilder::KeyForFragmentPosition(const GrRenderTarget* dst) {
GrGLSLFragmentShaderBuilder::GrGLSLFragmentShaderBuilder(GrGLSLProgramBuilder* program,
uint8_t fragPosKey)
: INHERITED(program)
: GrGLSLFragmentBuilder(program)
, fSetupFragPosition(false)
, fTopLeftFragPosRead(kTopLeftFragPosRead_FragPosKey == fragPosKey)
, fHasCustomColorOutput(false)
, fCustomColorOutputIndex(-1)
, fHasSecondaryOutput(false)
, fHasReadDstColor(false)
, fHasReadFragmentPosition(false) {
fSubstageIndices.push_back(0);
}
bool GrGLSLFragmentShaderBuilder::enableFeature(GLSLFeature feature) {
@ -263,7 +266,7 @@ void GrGLSLFragmentShaderBuilder::onFinalize() {
&this->precisionQualifier());
}
void GrGLSLFragmentBuilder::onBeforeChildProcEmitCode() {
void GrGLSLFragmentShaderBuilder::onBeforeChildProcEmitCode() {
SkASSERT(fSubstageIndices.count() >= 1);
fSubstageIndices.push_back(0);
// second-to-last value in the fSubstageIndices stack is the index of the child proc
@ -271,7 +274,7 @@ void GrGLSLFragmentBuilder::onBeforeChildProcEmitCode() {
fMangleString.appendf("_c%d", fSubstageIndices[fSubstageIndices.count() - 2]);
}
void GrGLSLFragmentBuilder::onAfterChildProcEmitCode() {
void GrGLSLFragmentShaderBuilder::onAfterChildProcEmitCode() {
SkASSERT(fSubstageIndices.count() >= 2);
fSubstageIndices.pop_back();
fSubstageIndices.back()++;

View File

@ -16,17 +16,14 @@ class GrRenderTarget;
class GrGLSLVarying;
/*
* This base class encapsulates the functionality which the GP uses to build fragment shaders
* This base class encapsulates the common functionality which all processors use to build fragment
* shaders.
*/
class GrGLSLFragmentBuilder : public GrGLSLShaderBuilder {
public:
GrGLSLFragmentBuilder(GrGLSLProgramBuilder* program)
: INHERITED(program)
, fHasCustomColorOutput(false)
, fHasSecondaryOutput(false) {
fSubstageIndices.push_back(0);
}
GrGLSLFragmentBuilder(GrGLSLProgramBuilder* program) : INHERITED(program) {}
virtual ~GrGLSLFragmentBuilder() {}
/**
* Use of these features may require a GLSL extension to be enabled. Shaders may not compile
* if code is added that uses one of these features without calling enableFeature()
@ -54,74 +51,65 @@ public:
is in device space (e.g. 0,0 is the top left and pixel centers are at half-integers). */
virtual const char* fragmentPosition() = 0;
/**
* Fragment procs with child procs should call these functions before/after calling emitCode
* on a child proc.
*/
void onBeforeChildProcEmitCode();
void onAfterChildProcEmitCode();
const SkString& getMangleString() const { return fMangleString; }
bool hasCustomColorOutput() const { return fHasCustomColorOutput; }
bool hasSecondaryOutput() const { return fHasSecondaryOutput; }
// TODO: remove this method.
void declAppendf(const char* fmt, ...);
protected:
bool fHasCustomColorOutput;
bool fHasSecondaryOutput;
private:
/*
* State that tracks which child proc in the proc tree is currently emitting code. This is
* used to update the fMangleString, which is used to mangle the names of uniforms and functions
* emitted by the proc. fSubstageIndices is a stack: its count indicates how many levels deep
* we are in the tree, and its second-to-last value is the index of the child proc at that
* level which is currently emitting code. For example, if fSubstageIndices = [3, 1, 2, 0], that
* means we're currently emitting code for the base proc's 3rd child's 1st child's 2nd child.
*/
SkTArray<int> fSubstageIndices;
/*
* The mangle string is used to mangle the names of uniforms/functions emitted by the child
* procs so no duplicate uniforms/functions appear in the generated shader program. The mangle
* string is simply based on fSubstageIndices. For example, if fSubstageIndices = [3, 1, 2, 0],
* then the manglestring will be "_c3_c1_c2", and any uniform/function emitted by that proc will
* have "_c3_c1_c2" appended to its name, which can be interpreted as "base proc's 3rd child's
* 1st child's 2nd child".
*/
SkString fMangleString;
friend class GrGLPathProcessor;
typedef GrGLSLShaderBuilder INHERITED;
};
/*
* Fragment processor's, in addition to all of the above, may need to use dst color so they use
* this builder to create their shader. Because this is the only shader builder the FP sees, we
* just call it FPShaderBuilder
* This class is used by fragment processors to build their fragment code.
*/
class GrGLSLXPFragmentBuilder : public GrGLSLFragmentBuilder {
class GrGLSLFPFragmentBuilder : virtual public GrGLSLFragmentBuilder {
public:
GrGLSLXPFragmentBuilder(GrGLSLProgramBuilder* program) : INHERITED(program) {}
/** Appease the compiler; the derived class initializes GrGLSLFragmentBuilder. */
GrGLSLFPFragmentBuilder() : GrGLSLFragmentBuilder(nullptr) {}
/** Returns the variable name that holds the color of the destination pixel. This may be nullptr if
no effect advertised that it will read the destination. */
/**
* Fragment procs with child procs should call these functions before/after calling emitCode
* on a child proc.
*/
virtual void onBeforeChildProcEmitCode() = 0;
virtual void onAfterChildProcEmitCode() = 0;
virtual const SkString& getMangleString() const = 0;
};
/*
* This class is used by primitive processors to build their fragment code.
*/
class GrGLSLPPFragmentBuilder : public GrGLSLFPFragmentBuilder {
public:
/** Appease the compiler; the derived class initializes GrGLSLFragmentBuilder. */
GrGLSLPPFragmentBuilder() : GrGLSLFragmentBuilder(nullptr) {}
};
/*
* This class is used by Xfer processors to build their fragment code.
*/
class GrGLSLXPFragmentBuilder : virtual public GrGLSLFragmentBuilder {
public:
/** Appease the compiler; the derived class initializes GrGLSLFragmentBuilder. */
GrGLSLXPFragmentBuilder() : GrGLSLFragmentBuilder(nullptr) {}
virtual bool hasCustomColorOutput() const = 0;
virtual bool hasSecondaryOutput() const = 0;
/** Returns the variable name that holds the color of the destination pixel. This may be nullptr
* if no effect advertised that it will read the destination. */
virtual const char* dstColor() = 0;
/** Adds any necessary layout qualifiers in order to legalize the supplied blend equation with
this shader. It is only legal to call this method with an advanced blend equation, and only
if these equations are supported. */
virtual void enableAdvancedBlendEquationIfNeeded(GrBlendEquation) = 0;
private:
typedef GrGLSLFragmentBuilder INHERITED;
};
// TODO rename to Fragment Builder
class GrGLSLFragmentShaderBuilder : public GrGLSLXPFragmentBuilder {
/*
* This class implements the various fragment builder interfaces.
*/
class GrGLSLFragmentShaderBuilder : public GrGLSLPPFragmentBuilder, public GrGLSLXPFragmentBuilder {
public:
typedef uint8_t FragPosKey;
@ -132,13 +120,21 @@ public:
GrGLSLFragmentShaderBuilder(GrGLSLProgramBuilder* program, uint8_t fragPosKey);
// true public interface, defined explicitly in the abstract interfaces above
// Shared GrGLSLFragmentBuilder interface.
bool enableFeature(GLSLFeature) override;
virtual SkString ensureFSCoords2D(const GrGLSLTransformedCoordsArray& coords,
int index) override;
const char* fragmentPosition() override;
const char* dstColor() override;
// GrGLSLFPFragmentBuilder interface.
const SkString& getMangleString() const override { return fMangleString; }
void onBeforeChildProcEmitCode() override;
void onAfterChildProcEmitCode() override;
// GrGLSLXPFragmentBuilder interface.
bool hasCustomColorOutput() const override { return fHasCustomColorOutput; }
bool hasSecondaryOutput() const override { return fHasSecondaryOutput; }
const char* dstColor() override;
void enableAdvancedBlendEquationIfNeeded(GrBlendEquation) override;
private:
@ -176,9 +172,31 @@ private:
static const char* kDstTextureColorName;
/*
* State that tracks which child proc in the proc tree is currently emitting code. This is
* used to update the fMangleString, which is used to mangle the names of uniforms and functions
* emitted by the proc. fSubstageIndices is a stack: its count indicates how many levels deep
* we are in the tree, and its second-to-last value is the index of the child proc at that
* level which is currently emitting code. For example, if fSubstageIndices = [3, 1, 2, 0], that
* means we're currently emitting code for the base proc's 3rd child's 1st child's 2nd child.
*/
SkTArray<int> fSubstageIndices;
/*
* The mangle string is used to mangle the names of uniforms/functions emitted by the child
* procs so no duplicate uniforms/functions appear in the generated shader program. The mangle
* string is simply based on fSubstageIndices. For example, if fSubstageIndices = [3, 1, 2, 0],
* then the manglestring will be "_c3_c1_c2", and any uniform/function emitted by that proc will
* have "_c3_c1_c2" appended to its name, which can be interpreted as "base proc's 3rd child's
* 1st child's 2nd child".
*/
SkString fMangleString;
bool fSetupFragPosition;
bool fTopLeftFragPosRead;
bool fHasCustomColorOutput;
int fCustomColorOutputIndex;
bool fHasSecondaryOutput;
// some state to verify shaders and effects are consistent, this is reset between effects by
// the program creator
@ -187,8 +205,6 @@ private:
friend class GrGLSLProgramBuilder;
friend class GrGLProgramBuilder;
typedef GrGLSLXPFragmentBuilder INHERITED;
};
#endif

View File

@ -34,7 +34,7 @@ SkMatrix GrGLSLPrimitiveProcessor::GetTransformMatrix(const SkMatrix& localMatri
return combined;
}
void GrGLSLPrimitiveProcessor::setupUniformColor(GrGLSLFragmentBuilder* fragBuilder,
void GrGLSLPrimitiveProcessor::setupUniformColor(GrGLSLPPFragmentBuilder* fragBuilder,
GrGLSLUniformHandler* uniformHandler,
const char* outputName,
UniformHandle* colorUniform) {

View File

@ -16,7 +16,7 @@
class GrBatchTracker;
class GrPrimitiveProcessor;
class GrGLSLCaps;
class GrGLSLFragmentBuilder;
class GrGLSLPPFragmentBuilder;
class GrGLSLGPBuilder;
class GrGLSLUniformHandler;
class GrGLSLVaryingHandler;
@ -35,7 +35,7 @@ public:
struct EmitArgs {
EmitArgs(GrGLSLVertexBuilder* vertBuilder,
GrGLSLFragmentBuilder* fragBuilder,
GrGLSLPPFragmentBuilder* fragBuilder,
GrGLSLVaryingHandler* varyingHandler,
GrGLSLUniformHandler* uniformHandler,
const GrGLSLCaps* caps,
@ -57,7 +57,7 @@ public:
, fTransformsIn(transformsIn)
, fTransformsOut(transformsOut) {}
GrGLSLVertexBuilder* fVertBuilder;
GrGLSLFragmentBuilder* fFragBuilder;
GrGLSLPPFragmentBuilder* fFragBuilder;
GrGLSLVaryingHandler* fVaryingHandler;
GrGLSLUniformHandler* fUniformHandler;
const GrGLSLCaps* fGLSLCaps;
@ -92,7 +92,7 @@ public:
const SkTArray<const GrCoordTransform*, true>& transforms) = 0;
protected:
void setupUniformColor(GrGLSLFragmentBuilder* fragBuilder,
void setupUniformColor(GrGLSLPPFragmentBuilder* fragBuilder,
GrGLSLUniformHandler* uniformHandler,
const char* outputName,
UniformHandle* colorUniform);

View File

@ -96,7 +96,7 @@ void GrGLSLVaryingHandler::setNoPerspective() {
return;
}
if (const char* extension = caps.noperspectiveInterpolationExtensionString()) {
int bit = 1 << GrGLSLFragmentShaderBuilder::kNoPerspectiveInterpolation_GLSLPrivateFeature;
int bit = 1 << GrGLSLFragmentBuilder::kNoPerspectiveInterpolation_GLSLPrivateFeature;
fProgramBuilder->fVS.addFeature(bit, extension);
if (fProgramBuilder->primitiveProcessor().willUseGeoShader()) {
fProgramBuilder->fGS.addFeature(bit, extension);