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
diff --git a/src/gpu/effects/GrBezierEffect.cpp b/src/gpu/effects/GrBezierEffect.cpp
index 2f378c3..ae1a8d3 100644
--- a/src/gpu/effects/GrBezierEffect.cpp
+++ b/src/gpu/effects/GrBezierEffect.cpp
@@ -87,7 +87,7 @@
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 @@
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 @@
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);
diff --git a/src/gpu/effects/GrBicubicEffect.cpp b/src/gpu/effects/GrBicubicEffect.cpp
index 567c38c..a74b2d4 100644
--- a/src/gpu/effects/GrBicubicEffect.cpp
+++ b/src/gpu/effects/GrBicubicEffect.cpp
@@ -68,7 +68,7 @@
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",
diff --git a/src/gpu/effects/GrBitmapTextGeoProc.cpp b/src/gpu/effects/GrBitmapTextGeoProc.cpp
index 6fd3538..263676d 100644
--- a/src/gpu/effects/GrBitmapTextGeoProc.cpp
+++ b/src/gpu/effects/GrBitmapTextGeoProc.cpp
@@ -43,7 +43,7 @@
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()) {
diff --git a/src/gpu/effects/GrConfigConversionEffect.cpp b/src/gpu/effects/GrConfigConversionEffect.cpp
index ace736c..4e168cd 100644
--- a/src/gpu/effects/GrConfigConversionEffect.cpp
+++ b/src/gpu/effects/GrConfigConversionEffect.cpp
@@ -26,7 +26,7 @@
SkString tmpDecl;
tmpVar.appendDecl(args.fGLSLCaps, &tmpDecl);
- GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
+ GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
fragBuilder->codeAppendf("%s;", tmpDecl.c_str());
diff --git a/src/gpu/effects/GrConstColorProcessor.cpp b/src/gpu/effects/GrConstColorProcessor.cpp
index 52108e5..62a1ecc 100644
--- a/src/gpu/effects/GrConstColorProcessor.cpp
+++ b/src/gpu/effects/GrConstColorProcessor.cpp
@@ -17,7 +17,7 @@
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,
diff --git a/src/gpu/effects/GrConvexPolyEffect.cpp b/src/gpu/effects/GrConvexPolyEffect.cpp
index 31ace60..cf874cf 100644
--- a/src/gpu/effects/GrConvexPolyEffect.cpp
+++ b/src/gpu/effects/GrConvexPolyEffect.cpp
@@ -110,7 +110,7 @@
"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 @@
"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();
diff --git a/src/gpu/effects/GrConvolutionEffect.cpp b/src/gpu/effects/GrConvolutionEffect.cpp
index 0b2adac..1fb2e95 100644
--- a/src/gpu/effects/GrConvolutionEffect.cpp
+++ b/src/gpu/effects/GrConvolutionEffect.cpp
@@ -50,7 +50,7 @@
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);
diff --git a/src/gpu/effects/GrDashingEffect.cpp b/src/gpu/effects/GrDashingEffect.cpp
index 09dc90a..17a2d8d 100644
--- a/src/gpu/effects/GrDashingEffect.cpp
+++ b/src/gpu/effects/GrDashingEffect.cpp
@@ -879,7 +879,7 @@
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 @@
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);
diff --git a/src/gpu/effects/GrDistanceFieldGeoProc.cpp b/src/gpu/effects/GrDistanceFieldGeoProc.cpp
index 395de32..50e78cc 100644
--- a/src/gpu/effects/GrDistanceFieldGeoProc.cpp
+++ b/src/gpu/effects/GrDistanceFieldGeoProc.cpp
@@ -34,7 +34,7 @@
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 @@
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 @@
// emit attributes
varyingHandler->emitAttributes(dfTexEffect);
- GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
+ GrGLSLPPFragmentBuilder* fragBuilder = args.fFragBuilder;
// setup pass through color
if (!dfTexEffect.colorIgnored()) {
diff --git a/src/gpu/effects/GrDitherEffect.cpp b/src/gpu/effects/GrDitherEffect.cpp
index 43fe937..39d4063 100644
--- a/src/gpu/effects/GrDitherEffect.cpp
+++ b/src/gpu/effects/GrDitherEffect.cpp
@@ -67,7 +67,7 @@
};
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
diff --git a/src/gpu/effects/GrMatrixConvolutionEffect.cpp b/src/gpu/effects/GrMatrixConvolutionEffect.cpp
index ac7889d..ae8b9bf 100644
--- a/src/gpu/effects/GrMatrixConvolutionEffect.cpp
+++ b/src/gpu/effects/GrMatrixConvolutionEffect.cpp
@@ -61,7 +61,7 @@
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);
diff --git a/src/gpu/effects/GrOvalEffect.cpp b/src/gpu/effects/GrOvalEffect.cpp
index aea73e1..3e6287b 100644
--- a/src/gpu/effects/GrOvalEffect.cpp
+++ b/src/gpu/effects/GrOvalEffect.cpp
@@ -120,7 +120,7 @@
"circle",
&circleName);
- GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
+ GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
const char* fragmentPos = fragBuilder->fragmentPosition();
SkASSERT(kHairlineAA_GrProcessorEdgeType != ce.getEdgeType());
@@ -301,7 +301,7 @@
"scale", &scaleName);
}
- GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
+ GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
const char* fragmentPos = fragBuilder->fragmentPosition();
// d is the offset to the ellipse center
diff --git a/src/gpu/effects/GrRRectEffect.cpp b/src/gpu/effects/GrRRectEffect.cpp
index a91b8f1..d1d811d 100644
--- a/src/gpu/effects/GrRRectEffect.cpp
+++ b/src/gpu/effects/GrRRectEffect.cpp
@@ -175,7 +175,7 @@
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 @@
"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
diff --git a/src/gpu/effects/GrSimpleTextureEffect.cpp b/src/gpu/effects/GrSimpleTextureEffect.cpp
index 96a53f5..904b898 100644
--- a/src/gpu/effects/GrSimpleTextureEffect.cpp
+++ b/src/gpu/effects/GrSimpleTextureEffect.cpp
@@ -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],
diff --git a/src/gpu/effects/GrTextureDomain.cpp b/src/gpu/effects/GrTextureDomain.cpp
index 16bca7c..77ce39e 100644
--- a/src/gpu/effects/GrTextureDomain.cpp
+++ b/src/gpu/effects/GrTextureDomain.cpp
@@ -192,7 +192,7 @@
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,
diff --git a/src/gpu/effects/GrXfermodeFragmentProcessor.cpp b/src/gpu/effects/GrXfermodeFragmentProcessor.cpp
index 7a358d6..a881999 100644
--- a/src/gpu/effects/GrXfermodeFragmentProcessor.cpp
+++ b/src/gpu/effects/GrXfermodeFragmentProcessor.cpp
@@ -87,7 +87,7 @@
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 @@
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();
diff --git a/src/gpu/effects/GrYUVEffect.cpp b/src/gpu/effects/GrYUVEffect.cpp
index 9fd643b..ef1bf1b 100644
--- a/src/gpu/effects/GrYUVEffect.cpp
+++ b/src/gpu/effects/GrYUVEffect.cpp
@@ -99,7 +99,7 @@
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 @@
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");