GP Emit Code takes a struct

BUG=skia:

Review URL: https://codereview.chromium.org/666693012
This commit is contained in:
joshualitt 2014-10-22 10:56:26 -07:00 committed by Commit bot
parent 46c248da26
commit c369e7c999
9 changed files with 165 additions and 281 deletions

View File

@ -528,17 +528,11 @@ public:
GLProcessor(const GrBackendProcessorFactory& factory, const GrProcessor&)
: INHERITED (factory) {}
virtual void emitCode(GrGLGPBuilder* builder,
const GrGeometryProcessor& geometryProcessor,
const GrProcessorKey& key,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray&,
const TextureSamplerArray& samplers) SK_OVERRIDE {
virtual void emitCode(const EmitArgs& args) SK_OVERRIDE {
const char *vsName, *fsName;
builder->addVarying(kVec4f_GrSLType, "QuadEdge", &vsName, &fsName);
args.fPB->addVarying(kVec4f_GrSLType, "QuadEdge", &vsName, &fsName);
GrGLGPFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder();
GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
SkAssertResult(fsBuilder->enableFeature(
GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature));
@ -561,11 +555,11 @@ public:
"clamp(0.5 - edgeAlpha / length(gF), 0.0, 1.0);\n\t\t}\n");
fsBuilder->codeAppendf("\t%s = %s;\n", outputColor,
(GrGLSLExpr4(inputColor) * GrGLSLExpr1("edgeAlpha")).c_str());
fsBuilder->codeAppendf("\t%s = %s;\n", args.fOutput,
(GrGLSLExpr4(args.fInput) * GrGLSLExpr1("edgeAlpha")).c_str());
const GrShaderVar& inQuadEdge = geometryProcessor.cast<QuadEdgeEffect>().inQuadEdge();
GrGLVertexBuilder* vsBuilder = builder->getVertexShaderBuilder();
const GrShaderVar& inQuadEdge = args.fGP.cast<QuadEdgeEffect>().inQuadEdge();
GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder();
vsBuilder->codeAppendf("\t%s = %s;\n", vsName, inQuadEdge.c_str());
}

View File

@ -41,24 +41,18 @@ public:
GLProcessor(const GrBackendProcessorFactory& factory, const GrProcessor&)
: INHERITED (factory) {}
virtual void emitCode(GrGLGPBuilder* builder,
const GrGeometryProcessor& geometryProcessor,
const GrProcessorKey& key,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray&,
const TextureSamplerArray& samplers) SK_OVERRIDE {
virtual void emitCode(const EmitArgs& args) SK_OVERRIDE {
// setup the varying for the Axis aligned rect effect
// xy -> interpolated offset
// zw -> w/2+0.5, h/2+0.5
const char *vsRectName, *fsRectName;
builder->addVarying(kVec4f_GrSLType, "Rect", &vsRectName, &fsRectName);
args.fPB->addVarying(kVec4f_GrSLType, "Rect", &vsRectName, &fsRectName);
const GrShaderVar& inRect = geometryProcessor.cast<GrAlignedRectEffect>().inRect();
GrGLVertexBuilder* vsBuilder = builder->getVertexShaderBuilder();
const GrShaderVar& inRect = args.fGP.cast<GrAlignedRectEffect>().inRect();
GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder();
vsBuilder->codeAppendf("\t%s = %s;\n", vsRectName, inRect.c_str());
GrGLGPFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder();
GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
// TODO: compute all these offsets, spans, and scales in the VS
fsBuilder->codeAppendf("\tfloat insetW = min(1.0, %s.z) - 0.5;\n", fsRectName);
fsBuilder->codeAppendf("\tfloat insetH = min(1.0, %s.w) - 0.5;\n", fsRectName);
@ -83,8 +77,8 @@ public:
fsRectName, fsRectName);
fsBuilder->codeAppendf("\t%s = %s;\n", outputColor,
(GrGLSLExpr4(inputColor) * GrGLSLExpr1("coverage")).c_str());
fsBuilder->codeAppendf("\t%s = %s;\n", args.fOutput,
(GrGLSLExpr4(args.fInput) * GrGLSLExpr1("coverage")).c_str());
}
static void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKeyBuilder*) {}
@ -166,32 +160,26 @@ public:
GLProcessor(const GrBackendProcessorFactory& factory, const GrProcessor&)
: INHERITED (factory) {}
virtual void emitCode(GrGLGPBuilder* builder,
const GrGeometryProcessor& geometryProcessor,
const GrProcessorKey& key,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray&,
const TextureSamplerArray& samplers) SK_OVERRIDE {
virtual void emitCode(const EmitArgs& args) SK_OVERRIDE {
// setup the varying for the center point and the unit vector
// that points down the height of the rect
const char *vsRectEdgeName, *fsRectEdgeName;
builder->addVarying(kVec4f_GrSLType, "RectEdge",
args.fPB->addVarying(kVec4f_GrSLType, "RectEdge",
&vsRectEdgeName, &fsRectEdgeName);
const GrRectEffect& rectEffect = geometryProcessor.cast<GrRectEffect>();
GrGLVertexBuilder* vsBuilder = builder->getVertexShaderBuilder();
const GrRectEffect& rectEffect = args.fGP.cast<GrRectEffect>();
GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder();
vsBuilder->codeAppendf("%s = %s;", vsRectEdgeName, rectEffect.inRectEdge().c_str());
// setup the varying for width/2+.5 and height/2+.5
const char *vsWidthHeightName, *fsWidthHeightName;
builder->addVarying(kVec2f_GrSLType, "WidthHeight",
args.fPB->addVarying(kVec2f_GrSLType, "WidthHeight",
&vsWidthHeightName, &fsWidthHeightName);
vsBuilder->codeAppendf("%s = %s;",
vsWidthHeightName,
rectEffect.inWidthHeight().c_str());
GrGLGPFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder();
GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
// TODO: compute all these offsets, spans, and scales in the VS
fsBuilder->codeAppendf("\tfloat insetW = min(1.0, %s.x) - 0.5;\n", fsWidthHeightName);
fsBuilder->codeAppendf("\tfloat insetH = min(1.0, %s.y) - 0.5;\n", fsWidthHeightName);
@ -223,8 +211,8 @@ public:
fsWidthHeightName);
fsBuilder->codeAppendf("\t%s = %s;\n", outputColor,
(GrGLSLExpr4(inputColor) * GrGLSLExpr1("coverage")).c_str());
fsBuilder->codeAppendf("\t%s = %s;\n", args.fOutput,
(GrGLSLExpr4(args.fInput) * GrGLSLExpr1("coverage")).c_str());
}
static void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKeyBuilder*) {}

View File

@ -92,21 +92,15 @@ public:
GLProcessor(const GrBackendProcessorFactory& factory, const GrProcessor&)
: INHERITED (factory) {}
virtual void emitCode(GrGLGPBuilder* builder,
const GrGeometryProcessor& geometryProcessor,
const GrProcessorKey& key,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray&,
const TextureSamplerArray& samplers) SK_OVERRIDE {
const CircleEdgeEffect& circleEffect = geometryProcessor.cast<CircleEdgeEffect>();
virtual void emitCode(const EmitArgs& args) SK_OVERRIDE {
const CircleEdgeEffect& circleEffect = args.fGP.cast<CircleEdgeEffect>();
const char *vsName, *fsName;
builder->addVarying(kVec4f_GrSLType, "CircleEdge", &vsName, &fsName);
args.fPB->addVarying(kVec4f_GrSLType, "CircleEdge", &vsName, &fsName);
GrGLVertexBuilder* vsBuilder = builder->getVertexShaderBuilder();;
GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder();;
vsBuilder->codeAppendf("\t%s = %s;\n", vsName, circleEffect.inCircleEdge().c_str());
GrGLGPFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder();
GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
fsBuilder->codeAppendf("\tfloat d = length(%s.xy);\n", fsName);
fsBuilder->codeAppendf("\tfloat edgeAlpha = clamp(%s.z - d, 0.0, 1.0);\n", fsName);
if (circleEffect.isStroked()) {
@ -114,8 +108,8 @@ public:
fsBuilder->codeAppend("\tedgeAlpha *= innerAlpha;\n");
}
fsBuilder->codeAppendf("\t%s = %s;\n", outputColor,
(GrGLSLExpr4(inputColor) * GrGLSLExpr1("edgeAlpha")).c_str());
fsBuilder->codeAppendf("\t%s = %s;\n", args.fOutput,
(GrGLSLExpr4(args.fInput) * GrGLSLExpr1("edgeAlpha")).c_str());
}
static void GenKey(const GrProcessor& processor, const GrGLCaps&,
@ -209,29 +203,23 @@ public:
GLProcessor(const GrBackendProcessorFactory& factory, const GrProcessor&)
: INHERITED (factory) {}
virtual void emitCode(GrGLGPBuilder* builder,
const GrGeometryProcessor& geometryProcessor,
const GrProcessorKey& key,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray&,
const TextureSamplerArray& samplers) SK_OVERRIDE {
const EllipseEdgeEffect& ellipseEffect = geometryProcessor.cast<EllipseEdgeEffect>();
virtual void emitCode(const EmitArgs& args) SK_OVERRIDE {
const EllipseEdgeEffect& ellipseEffect = args.fGP.cast<EllipseEdgeEffect>();
const char *vsOffsetName, *fsOffsetName;
const char *vsRadiiName, *fsRadiiName;
builder->addVarying(kVec2f_GrSLType, "EllipseOffsets", &vsOffsetName, &fsOffsetName);
args.fPB->addVarying(kVec2f_GrSLType, "EllipseOffsets", &vsOffsetName, &fsOffsetName);
GrGLVertexBuilder* vsBuilder = builder->getVertexShaderBuilder();
GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder();
vsBuilder->codeAppendf("%s = %s;", vsOffsetName,
ellipseEffect.inEllipseOffset().c_str());
builder->addVarying(kVec4f_GrSLType, "EllipseRadii", &vsRadiiName, &fsRadiiName);
args.fPB->addVarying(kVec4f_GrSLType, "EllipseRadii", &vsRadiiName, &fsRadiiName);
vsBuilder->codeAppendf("%s = %s;", vsRadiiName, ellipseEffect.inEllipseRadii().c_str());
// for outer curve
GrGLGPFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder();
GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
fsBuilder->codeAppendf("\tvec2 scaledOffset = %s*%s.xy;\n", fsOffsetName, fsRadiiName);
fsBuilder->codeAppend("\tfloat test = dot(scaledOffset, scaledOffset) - 1.0;\n");
fsBuilder->codeAppendf("\tvec2 grad = 2.0*scaledOffset*%s.xy;\n", fsRadiiName);
@ -250,8 +238,8 @@ public:
fsBuilder->codeAppend("\tedgeAlpha *= clamp(0.5+test*invlen, 0.0, 1.0);\n");
}
fsBuilder->codeAppendf("\t%s = %s;\n", outputColor,
(GrGLSLExpr4(inputColor) * GrGLSLExpr1("edgeAlpha")).c_str());
fsBuilder->codeAppendf("\t%s = %s;\n", args.fOutput,
(GrGLSLExpr4(args.fInput) * GrGLSLExpr1("edgeAlpha")).c_str());
}
static void GenKey(const GrProcessor& processor, const GrGLCaps&,
@ -357,30 +345,23 @@ public:
GLProcessor(const GrBackendProcessorFactory& factory, const GrProcessor&)
: INHERITED (factory) {}
virtual void emitCode(GrGLGPBuilder* builder,
const GrGeometryProcessor& geometryProcessor,
const GrProcessorKey& key,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray&,
const TextureSamplerArray& samplers) SK_OVERRIDE {
const DIEllipseEdgeEffect& ellipseEffect =
geometryProcessor.cast<DIEllipseEdgeEffect>();
virtual void emitCode(const EmitArgs& args) SK_OVERRIDE {
const DIEllipseEdgeEffect& ellipseEffect = args.fGP.cast<DIEllipseEdgeEffect>();
const char *vsOffsetName0, *fsOffsetName0;
builder->addVarying(kVec2f_GrSLType, "EllipseOffsets0",
args.fPB->addVarying(kVec2f_GrSLType, "EllipseOffsets0",
&vsOffsetName0, &fsOffsetName0);
GrGLVertexBuilder* vsBuilder = builder->getVertexShaderBuilder();
GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder();
vsBuilder->codeAppendf("%s = %s;", vsOffsetName0,
ellipseEffect.inEllipseOffsets0().c_str());
const char *vsOffsetName1, *fsOffsetName1;
builder->addVarying(kVec2f_GrSLType, "EllipseOffsets1",
args.fPB->addVarying(kVec2f_GrSLType, "EllipseOffsets1",
&vsOffsetName1, &fsOffsetName1);
vsBuilder->codeAppendf("\t%s = %s;\n", vsOffsetName1,
ellipseEffect.inEllipseOffsets1().c_str());
GrGLGPFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder();
GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
SkAssertResult(fsBuilder->enableFeature(
GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature));
// for outer curve
@ -417,8 +398,8 @@ public:
fsBuilder->codeAppend("\tedgeAlpha *= clamp(0.5+test*invlen, 0.0, 1.0);\n");
}
fsBuilder->codeAppendf("\t%s = %s;\n", outputColor,
(GrGLSLExpr4(inputColor) * GrGLSLExpr1("edgeAlpha")).c_str());
fsBuilder->codeAppendf("\t%s = %s;\n", args.fOutput,
(GrGLSLExpr4(args.fInput) * GrGLSLExpr1("edgeAlpha")).c_str());
}
static void GenKey(const GrProcessor& processor, const GrGLCaps&,

View File

@ -17,13 +17,7 @@ class GrGLConicEffect : public GrGLGeometryProcessor {
public:
GrGLConicEffect(const GrBackendProcessorFactory&, const GrProcessor&);
virtual void emitCode(GrGLGPBuilder* builder,
const GrGeometryProcessor& geometryProcessor,
const GrProcessorKey& key,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray&,
const TextureSamplerArray&) SK_OVERRIDE;
virtual void emitCode(const EmitArgs&) SK_OVERRIDE;
static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKeyBuilder*);
@ -42,23 +36,16 @@ GrGLConicEffect::GrGLConicEffect(const GrBackendProcessorFactory& factory,
fEdgeType = ce.getEdgeType();
}
void GrGLConicEffect::emitCode(GrGLGPBuilder* builder,
const GrGeometryProcessor& geometryProcessor,
const GrProcessorKey& key,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray&,
const TextureSamplerArray& samplers) {
void GrGLConicEffect::emitCode(const EmitArgs& args) {
const char *vsName, *fsName;
builder->addVarying(kVec4f_GrSLType, "ConicCoeffs",
&vsName, &fsName);
args.fPB->addVarying(kVec4f_GrSLType, "ConicCoeffs", &vsName, &fsName);
const GrShaderVar& inConicCoeffs = geometryProcessor.cast<GrConicEffect>().inConicCoeffs();
GrGLVertexBuilder* vsBuilder = builder->getVertexShaderBuilder();
const GrShaderVar& inConicCoeffs = args.fGP.cast<GrConicEffect>().inConicCoeffs();
GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder();
vsBuilder->codeAppendf("%s = %s;", vsName, inConicCoeffs.c_str());
GrGLGPFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder();
GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
fsBuilder->codeAppend("float edgeAlpha;");
switch (fEdgeType) {
@ -115,8 +102,8 @@ void GrGLConicEffect::emitCode(GrGLGPBuilder* builder,
SkFAIL("Shouldn't get here");
}
fsBuilder->codeAppendf("%s = %s;", outputColor,
(GrGLSLExpr4(inputColor) * GrGLSLExpr1("edgeAlpha")).c_str());
fsBuilder->codeAppendf("%s = %s;", args.fOutput,
(GrGLSLExpr4(args.fInput) * GrGLSLExpr1("edgeAlpha")).c_str());
}
void GrGLConicEffect::GenKey(const GrProcessor& processor, const GrGLCaps&,
@ -171,13 +158,7 @@ class GrGLQuadEffect : public GrGLGeometryProcessor {
public:
GrGLQuadEffect(const GrBackendProcessorFactory&, const GrProcessor&);
virtual void emitCode(GrGLGPBuilder* builder,
const GrGeometryProcessor& geometryProcessor,
const GrProcessorKey& key,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray&,
const TextureSamplerArray&) SK_OVERRIDE;
virtual void emitCode(const EmitArgs&) SK_OVERRIDE;
static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKeyBuilder*);
@ -196,21 +177,15 @@ GrGLQuadEffect::GrGLQuadEffect(const GrBackendProcessorFactory& factory,
fEdgeType = ce.getEdgeType();
}
void GrGLQuadEffect::emitCode(GrGLGPBuilder* builder,
const GrGeometryProcessor& geometryProcessor,
const GrProcessorKey& key,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray&,
const TextureSamplerArray& samplers) {
void GrGLQuadEffect::emitCode(const EmitArgs& args) {
const char *vsName, *fsName;
builder->addVarying(kVec4f_GrSLType, "HairQuadEdge", &vsName, &fsName);
args.fPB->addVarying(kVec4f_GrSLType, "HairQuadEdge", &vsName, &fsName);
GrGLVertexBuilder* vsBuilder = builder->getVertexShaderBuilder();
const GrShaderVar& inHairQuadEdge = geometryProcessor.cast<GrQuadEffect>().inHairQuadEdge();
GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder();
const GrShaderVar& inHairQuadEdge = args.fGP.cast<GrQuadEffect>().inHairQuadEdge();
vsBuilder->codeAppendf("%s = %s;", vsName, inHairQuadEdge.c_str());
GrGLGPFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder();
GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
fsBuilder->codeAppendf("float edgeAlpha;");
switch (fEdgeType) {
@ -253,8 +228,8 @@ void GrGLQuadEffect::emitCode(GrGLGPBuilder* builder,
SkFAIL("Shouldn't get here");
}
fsBuilder->codeAppendf("%s = %s;", outputColor,
(GrGLSLExpr4(inputColor) * GrGLSLExpr1("edgeAlpha")).c_str());
fsBuilder->codeAppendf("%s = %s;", args.fOutput,
(GrGLSLExpr4(args.fInput) * GrGLSLExpr1("edgeAlpha")).c_str());
}
void GrGLQuadEffect::GenKey(const GrProcessor& processor, const GrGLCaps&,
@ -309,13 +284,7 @@ class GrGLCubicEffect : public GrGLGeometryProcessor {
public:
GrGLCubicEffect(const GrBackendProcessorFactory&, const GrProcessor&);
virtual void emitCode(GrGLGPBuilder* builder,
const GrGeometryProcessor& geometryProcessor,
const GrProcessorKey& key,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray&,
const TextureSamplerArray&) SK_OVERRIDE;
virtual void emitCode(const EmitArgs&) SK_OVERRIDE;
static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKeyBuilder*);
@ -334,23 +303,17 @@ GrGLCubicEffect::GrGLCubicEffect(const GrBackendProcessorFactory& factory,
fEdgeType = ce.getEdgeType();
}
void GrGLCubicEffect::emitCode(GrGLGPBuilder* builder,
const GrGeometryProcessor& geometryProcessor,
const GrProcessorKey& key,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray&,
const TextureSamplerArray& samplers) {
void GrGLCubicEffect::emitCode(const EmitArgs& args) {
const char *vsName, *fsName;
builder->addVarying(kVec4f_GrSLType, "CubicCoeffs",
&vsName, &fsName, GrGLShaderVar::kHigh_Precision);
args.fPB->addVarying(kVec4f_GrSLType, "CubicCoeffs",
&vsName, &fsName, GrGLShaderVar::kHigh_Precision);
GrGLVertexBuilder* vsBuilder = builder->getVertexShaderBuilder();
const GrShaderVar& inCubicCoeffs = geometryProcessor.cast<GrCubicEffect>().inCubicCoeffs();
GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder();
const GrShaderVar& inCubicCoeffs = args.fGP.cast<GrCubicEffect>().inCubicCoeffs();
vsBuilder->codeAppendf("%s = %s;", vsName, inCubicCoeffs.c_str());
GrGLGPFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder();
GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
GrGLShaderVar edgeAlpha("edgeAlpha", kFloat_GrSLType, 0, GrGLShaderVar::kHigh_Precision);
GrGLShaderVar dklmdx("dklmdx", kVec3f_GrSLType, 0, GrGLShaderVar::kHigh_Precision);
@ -433,8 +396,8 @@ void GrGLCubicEffect::emitCode(GrGLGPBuilder* builder,
SkFAIL("Shouldn't get here");
}
fsBuilder->codeAppendf("%s = %s;", outputColor,
(GrGLSLExpr4(inputColor) * GrGLSLExpr1(edgeAlpha.c_str())).c_str());
fsBuilder->codeAppendf("%s = %s;", args.fOutput,
(GrGLSLExpr4(args.fInput) * GrGLSLExpr1(edgeAlpha.c_str())).c_str());
}
void GrGLCubicEffect::GenKey(const GrProcessor& processor, const GrGLCaps&,

View File

@ -19,31 +19,25 @@ public:
GrGLCustomCoordsTextureEffect(const GrBackendProcessorFactory& factory, const GrProcessor&)
: INHERITED (factory) {}
virtual void emitCode(GrGLGPBuilder* builder,
const GrGeometryProcessor& geometryProcessor,
const GrProcessorKey& key,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray&,
const TextureSamplerArray& samplers) SK_OVERRIDE {
virtual void emitCode(const EmitArgs& args) SK_OVERRIDE {
const GrCustomCoordsTextureEffect& customCoordsTextureEffect =
geometryProcessor.cast<GrCustomCoordsTextureEffect>();
args.fGP.cast<GrCustomCoordsTextureEffect>();
SkASSERT(1 == customCoordsTextureEffect.getVertexAttribs().count());
SkString fsCoordName;
const char* vsVaryingName;
const char* fsVaryingNamePtr;
builder->addVarying(kVec2f_GrSLType, "textureCoords", &vsVaryingName, &fsVaryingNamePtr);
args.fPB->addVarying(kVec2f_GrSLType, "textureCoords", &vsVaryingName, &fsVaryingNamePtr);
fsCoordName = fsVaryingNamePtr;
GrGLVertexBuilder* vsBuilder = builder->getVertexShaderBuilder();
GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder();
const GrShaderVar& inTextureCoords = customCoordsTextureEffect.inTextureCoords();
vsBuilder->codeAppendf("\t%s = %s;\n", vsVaryingName, inTextureCoords.c_str());
GrGLGPFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder();
fsBuilder->codeAppendf("\t%s = ", outputColor);
fsBuilder->appendTextureLookupAndModulate(inputColor,
samplers[0],
GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
fsBuilder->codeAppendf("\t%s = ", args.fOutput);
fsBuilder->appendTextureLookupAndModulate(args.fInput,
args.fSamplers[0],
fsCoordName.c_str(),
kVec2f_GrSLType);
fsBuilder->codeAppend(";\n");

View File

@ -482,13 +482,7 @@ class GLDashingCircleEffect : public GrGLGeometryProcessor {
public:
GLDashingCircleEffect(const GrBackendProcessorFactory&, const GrProcessor&);
virtual void emitCode(GrGLGPBuilder* builder,
const GrGeometryProcessor& geometryProcessor,
const GrProcessorKey& key,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray&,
const TextureSamplerArray&) SK_OVERRIDE;
virtual void emitCode(const EmitArgs&) SK_OVERRIDE;
static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKeyBuilder*);
@ -510,30 +504,24 @@ GLDashingCircleEffect::GLDashingCircleEffect(const GrBackendProcessorFactory& fa
fPrevIntervalLength = SK_ScalarMax;
}
void GLDashingCircleEffect::emitCode(GrGLGPBuilder* builder,
const GrGeometryProcessor& geometryProcessor,
const GrProcessorKey& key,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray&,
const TextureSamplerArray& samplers) {
const DashingCircleEffect& dce = geometryProcessor.cast<DashingCircleEffect>();
void GLDashingCircleEffect::emitCode(const EmitArgs& args) {
const DashingCircleEffect& dce = args.fGP.cast<DashingCircleEffect>();
const char *paramName;
// The param uniforms, xyz, refer to circle radius - 0.5, cicles center x coord, and
// the total interval length of the dash.
fParamUniform = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
kVec3f_GrSLType,
"params",
&paramName);
fParamUniform = args.fPB->addUniform(GrGLProgramBuilder::kFragment_Visibility,
kVec3f_GrSLType,
"params",
&paramName);
const char *vsCoordName, *fsCoordName;
builder->addVarying(kVec2f_GrSLType, "Coord", &vsCoordName, &fsCoordName);
args.fPB->addVarying(kVec2f_GrSLType, "Coord", &vsCoordName, &fsCoordName);
GrGLVertexBuilder* vsBuilder = builder->getVertexShaderBuilder();
GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder();
vsBuilder->codeAppendf("\t%s = %s;\n", vsCoordName, dce.inCoord().c_str());
// transforms all points so that we can compare them to our test circle
GrGLGPFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder();
GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
fsBuilder->codeAppendf("\t\tfloat xShifted = %s.x - floor(%s.x / %s.z) * %s.z;\n",
fsCoordName, fsCoordName, paramName, paramName);
fsBuilder->codeAppendf("\t\tvec2 fragPosShifted = vec2(xShifted, %s.y);\n", fsCoordName);
@ -547,8 +535,8 @@ void GLDashingCircleEffect::emitCode(GrGLGPBuilder* builder,
fsBuilder->codeAppendf("\t\tfloat alpha = 1.0;\n");
fsBuilder->codeAppendf("\t\talpha *= dist < %s.x + 0.5 ? 1.0 : 0.0;\n", paramName);
}
fsBuilder->codeAppendf("\t\t%s = %s;\n", outputColor,
(GrGLSLExpr4(inputColor) * GrGLSLExpr1("alpha")).c_str());
fsBuilder->codeAppendf("\t\t%s = %s;\n", args.fOutput,
(GrGLSLExpr4(args.fInput) * GrGLSLExpr1("alpha")).c_str());
}
void GLDashingCircleEffect::setData(const GrGLProgramDataManager& pdman
@ -693,13 +681,7 @@ class GLDashingLineEffect : public GrGLGeometryProcessor {
public:
GLDashingLineEffect(const GrBackendProcessorFactory&, const GrProcessor&);
virtual void emitCode(GrGLGPBuilder* builder,
const GrGeometryProcessor& geometryProcessor,
const GrProcessorKey& key,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray&,
const TextureSamplerArray&) SK_OVERRIDE;
virtual void emitCode(const EmitArgs&) SK_OVERRIDE;
static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKeyBuilder*);
@ -720,35 +702,29 @@ GLDashingLineEffect::GLDashingLineEffect(const GrBackendProcessorFactory& factor
fPrevIntervalLength = SK_ScalarMax;
}
void GLDashingLineEffect::emitCode(GrGLGPBuilder* builder,
const GrGeometryProcessor& geometryProcessor,
const GrProcessorKey& key,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray&,
const TextureSamplerArray& samplers) {
const DashingLineEffect& de = geometryProcessor.cast<DashingLineEffect>();
void GLDashingLineEffect::emitCode(const EmitArgs& args) {
const DashingLineEffect& de = args.fGP.cast<DashingLineEffect>();
const char *rectName;
// The rect uniform's xyzw refer to (left + 0.5, top + 0.5, right - 0.5, bottom - 0.5),
// respectively.
fRectUniform = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
fRectUniform = args.fPB->addUniform(GrGLProgramBuilder::kFragment_Visibility,
kVec4f_GrSLType,
"rect",
&rectName);
const char *intervalName;
// The interval uniform's refers to the total length of the interval (on + off)
fIntervalUniform = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
kFloat_GrSLType,
"interval",
&intervalName);
fIntervalUniform = args.fPB->addUniform(GrGLProgramBuilder::kFragment_Visibility,
kFloat_GrSLType,
"interval",
&intervalName);
const char *vsCoordName, *fsCoordName;
builder->addVarying(kVec2f_GrSLType, "Coord", &vsCoordName, &fsCoordName);
GrGLVertexBuilder* vsBuilder = builder->getVertexShaderBuilder();
args.fPB->addVarying(kVec2f_GrSLType, "Coord", &vsCoordName, &fsCoordName);
GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder();
vsBuilder->codeAppendf("\t%s = %s;\n", vsCoordName, de.inCoord().c_str());
// transforms all points so that we can compare them to our test rect
GrGLGPFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder();
GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
fsBuilder->codeAppendf("\t\tfloat xShifted = %s.x - floor(%s.x / %s) * %s;\n",
fsCoordName, fsCoordName, intervalName, intervalName);
fsBuilder->codeAppendf("\t\tvec2 fragPosShifted = vec2(xShifted, %s.y);\n", fsCoordName);
@ -769,8 +745,8 @@ void GLDashingLineEffect::emitCode(GrGLGPBuilder* builder,
fsBuilder->codeAppendf("\t\talpha *= (fragPosShifted.x - %s.x) > -0.5 ? 1.0 : 0.0;\n", rectName);
fsBuilder->codeAppendf("\t\talpha *= (%s.z - fragPosShifted.x) >= -0.5 ? 1.0 : 0.0;\n", rectName);
}
fsBuilder->codeAppendf("\t\t%s = %s;\n", outputColor,
(GrGLSLExpr4(inputColor) * GrGLSLExpr1("alpha")).c_str());
fsBuilder->codeAppendf("\t\t%s = %s;\n", args.fOutput,
(GrGLSLExpr4(args.fInput) * GrGLSLExpr1("alpha")).c_str());
}
void GLDashingLineEffect::setData(const GrGLProgramDataManager& pdman,

View File

@ -40,37 +40,31 @@ public:
#endif
{}
virtual void emitCode(GrGLGPBuilder* builder,
const GrGeometryProcessor& geometryProcessor,
const GrProcessorKey& key,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray&,
const TextureSamplerArray& samplers) SK_OVERRIDE {
virtual void emitCode(const EmitArgs& args) SK_OVERRIDE {
const GrDistanceFieldTextureEffect& dfTexEffect =
geometryProcessor.cast<GrDistanceFieldTextureEffect>();
args.fGP.cast<GrDistanceFieldTextureEffect>();
SkASSERT(1 == dfTexEffect.getVertexAttribs().count());
GrGLGPFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder();
GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
SkAssertResult(fsBuilder->enableFeature(
GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature));
SkString fsCoordName;
const char* vsCoordName;
const char* fsCoordNamePtr;
builder->addVarying(kVec2f_GrSLType, "textureCoords", &vsCoordName, &fsCoordNamePtr);
args.fPB->addVarying(kVec2f_GrSLType, "textureCoords", &vsCoordName, &fsCoordNamePtr);
fsCoordName = fsCoordNamePtr;
GrGLVertexBuilder* vsBuilder = builder->getVertexShaderBuilder();
GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder();
vsBuilder->codeAppendf("\t%s = %s;\n", vsCoordName, dfTexEffect.inTextureCoords().c_str());
const char* textureSizeUniName = NULL;
fTextureSizeUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
kVec2f_GrSLType, "TextureSize",
&textureSizeUniName);
fTextureSizeUni = args.fPB->addUniform(GrGLProgramBuilder::kFragment_Visibility,
kVec2f_GrSLType, "TextureSize",
&textureSizeUniName);
fsBuilder->codeAppend("\tvec4 texColor = ");
fsBuilder->appendTextureLookup(samplers[0],
fsBuilder->appendTextureLookup(args.fSamplers[0],
fsCoordName.c_str(),
kVec2f_GrSLType);
fsBuilder->codeAppend(";\n");
@ -92,7 +86,7 @@ public:
fsBuilder->codeAppend("\tvec2 Jdy = dFdy(st);\n");
fsBuilder->codeAppend("\tvec2 uv_grad;\n");
if (builder->ctxInfo().caps()->dropsTileOnZeroDivide()) {
if (args.fPB->ctxInfo().caps()->dropsTileOnZeroDivide()) {
// this is to compensate for the Adreno, which likes to drop tiles on division by 0
fsBuilder->codeAppend("\tfloat uv_len2 = dot(uv, uv);\n");
fsBuilder->codeAppend("\tif (uv_len2 < 0.0001) {\n");
@ -115,19 +109,19 @@ public:
// adjust based on gamma
const char* luminanceUniName = NULL;
// width, height, 1/(3*width)
fLuminanceUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
kFloat_GrSLType, "Luminance",
&luminanceUniName);
fLuminanceUni = args.fPB->addUniform(GrGLProgramBuilder::kFragment_Visibility,
kFloat_GrSLType, "Luminance",
&luminanceUniName);
fsBuilder->codeAppendf("\tuv = vec2(val, %s);\n", luminanceUniName);
fsBuilder->codeAppend("\tvec4 gammaColor = ");
fsBuilder->appendTextureLookup(samplers[1], "uv", kVec2f_GrSLType);
fsBuilder->appendTextureLookup(args.fSamplers[1], "uv", kVec2f_GrSLType);
fsBuilder->codeAppend(";\n");
fsBuilder->codeAppend("\tval = gammaColor.r;\n");
#endif
fsBuilder->codeAppendf("\t%s = %s;\n", outputColor,
(GrGLSLExpr4(inputColor) * GrGLSLExpr1("val")).c_str());
fsBuilder->codeAppendf("\t%s = %s;\n", args.fOutput,
(GrGLSLExpr4(args.fInput) * GrGLSLExpr1("val")).c_str());
}
virtual void setData(const GrGLProgramDataManager& pdman,
@ -261,37 +255,31 @@ public:
: INHERITED(factory)
, fTextureSize(SkISize::Make(-1, -1)) {}
virtual void emitCode(GrGLGPBuilder* builder,
const GrGeometryProcessor& effect,
const GrProcessorKey& key,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray&,
const TextureSamplerArray& samplers) SK_OVERRIDE {
virtual void emitCode(const EmitArgs& args) SK_OVERRIDE {
const GrDistanceFieldNoGammaTextureEffect& dfTexEffect =
effect.cast<GrDistanceFieldNoGammaTextureEffect>();
args.fGP.cast<GrDistanceFieldNoGammaTextureEffect>();
SkASSERT(1 == dfTexEffect.getVertexAttribs().count());
GrGLGPFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder();
GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
SkAssertResult(fsBuilder->enableFeature(
GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature));
SkString fsCoordName;
const char* vsCoordName;
const char* fsCoordNamePtr;
builder->addVarying(kVec2f_GrSLType, "textureCoords", &vsCoordName, &fsCoordNamePtr);
args.fPB->addVarying(kVec2f_GrSLType, "textureCoords", &vsCoordName, &fsCoordNamePtr);
fsCoordName = fsCoordNamePtr;
GrGLVertexBuilder* vsBuilder = builder->getVertexShaderBuilder();
GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder();
vsBuilder->codeAppendf("%s = %s;", vsCoordName, dfTexEffect.inTextureCoords().c_str());
const char* textureSizeUniName = NULL;
fTextureSizeUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
fTextureSizeUni = args.fPB->addUniform(GrGLProgramBuilder::kFragment_Visibility,
kVec2f_GrSLType, "TextureSize",
&textureSizeUniName);
fsBuilder->codeAppend("vec4 texColor = ");
fsBuilder->appendTextureLookup(samplers[0],
fsBuilder->appendTextureLookup(args.fSamplers[0],
fsCoordName.c_str(),
kVec2f_GrSLType);
fsBuilder->codeAppend(";");
@ -312,7 +300,7 @@ public:
fsBuilder->codeAppend("vec2 Jdy = dFdy(st);");
fsBuilder->codeAppend("vec2 uv_grad;");
if (builder->ctxInfo().caps()->dropsTileOnZeroDivide()) {
if (args.fPB->ctxInfo().caps()->dropsTileOnZeroDivide()) {
// this is to compensate for the Adreno, which likes to drop tiles on division by 0
fsBuilder->codeAppend("float uv_len2 = dot(uv, uv);");
fsBuilder->codeAppend("if (uv_len2 < 0.0001) {");
@ -331,8 +319,8 @@ public:
}
fsBuilder->codeAppend("float val = smoothstep(-afwidth, afwidth, distance);");
fsBuilder->codeAppendf("%s = %s;", outputColor,
(GrGLSLExpr4(inputColor) * GrGLSLExpr1("val")).c_str());
fsBuilder->codeAppendf("%s = %s;", args.fOutput,
(GrGLSLExpr4(args.fInput) * GrGLSLExpr1("val")).c_str());
}
virtual void setData(const GrGLProgramDataManager& pdman,
@ -428,33 +416,27 @@ public:
, fTextureSize(SkISize::Make(-1,-1))
, fTextColor(GrColor_ILLEGAL) {}
virtual void emitCode(GrGLGPBuilder* builder,
const GrGeometryProcessor& geometryProcessor,
const GrProcessorKey& key,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray&,
const TextureSamplerArray& samplers) SK_OVERRIDE {
virtual void emitCode(const EmitArgs& args) SK_OVERRIDE {
const GrDistanceFieldLCDTextureEffect& dfTexEffect =
geometryProcessor.cast<GrDistanceFieldLCDTextureEffect>();
args.fGP.cast<GrDistanceFieldLCDTextureEffect>();
SkASSERT(1 == dfTexEffect.getVertexAttribs().count());
SkString fsCoordName;
const char* vsCoordName;
const char* fsCoordNamePtr;
builder->addVarying(kVec2f_GrSLType, "textureCoords", &vsCoordName, &fsCoordNamePtr);
args.fPB->addVarying(kVec2f_GrSLType, "textureCoords", &vsCoordName, &fsCoordNamePtr);
fsCoordName = fsCoordNamePtr;
GrGLVertexBuilder* vsBuilder = builder->getVertexShaderBuilder();
GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder();
vsBuilder->codeAppendf("\t%s = %s;\n", vsCoordName, dfTexEffect.inTextureCoords().c_str());
const char* textureSizeUniName = NULL;
// width, height, 1/(3*width)
fTextureSizeUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
fTextureSizeUni = args.fPB->addUniform(GrGLProgramBuilder::kFragment_Visibility,
kVec3f_GrSLType, "TextureSize",
&textureSizeUniName);
GrGLGPFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder();
GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
SkAssertResult(fsBuilder->enableFeature(
GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature));
@ -474,20 +456,20 @@ public:
// green is distance to uv center
fsBuilder->codeAppend("\tvec4 texColor = ");
fsBuilder->appendTextureLookup(samplers[0], "uv", kVec2f_GrSLType);
fsBuilder->appendTextureLookup(args.fSamplers[0], "uv", kVec2f_GrSLType);
fsBuilder->codeAppend(";\n");
fsBuilder->codeAppend("\tvec3 distance;\n");
fsBuilder->codeAppend("\tdistance.y = texColor.r;\n");
// red is distance to left offset
fsBuilder->codeAppend("\tvec2 uv_adjusted = uv - offset;\n");
fsBuilder->codeAppend("\ttexColor = ");
fsBuilder->appendTextureLookup(samplers[0], "uv_adjusted", kVec2f_GrSLType);
fsBuilder->appendTextureLookup(args.fSamplers[0], "uv_adjusted", kVec2f_GrSLType);
fsBuilder->codeAppend(";\n");
fsBuilder->codeAppend("\tdistance.x = texColor.r;\n");
// blue is distance to right offset
fsBuilder->codeAppend("\tuv_adjusted = uv + offset;\n");
fsBuilder->codeAppend("\ttexColor = ");
fsBuilder->appendTextureLookup(samplers[0], "uv_adjusted", kVec2f_GrSLType);
fsBuilder->appendTextureLookup(args.fSamplers[0], "uv_adjusted", kVec2f_GrSLType);
fsBuilder->codeAppend(";\n");
fsBuilder->codeAppend("\tdistance.z = texColor.r;\n");
@ -509,7 +491,7 @@ public:
fsBuilder->codeAppend("\tafwidth = abs(" SK_DistanceFieldAAFactor "*dx);\n");
} else {
fsBuilder->codeAppend("\tvec2 uv_grad;\n");
if (builder->ctxInfo().caps()->dropsTileOnZeroDivide()) {
if (args.fPB->ctxInfo().caps()->dropsTileOnZeroDivide()) {
// this is to compensate for the Adreno, which likes to drop tiles on division by 0
fsBuilder->codeAppend("\tfloat uv_len2 = dot(uv, uv);\n");
fsBuilder->codeAppend("\tif (uv_len2 < 0.0001) {\n");
@ -532,30 +514,30 @@ public:
// adjust based on gamma
const char* textColorUniName = NULL;
// width, height, 1/(3*width)
fTextColorUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
kVec3f_GrSLType, "TextColor",
&textColorUniName);
fTextColorUni = args.fPB->addUniform(GrGLProgramBuilder::kFragment_Visibility,
kVec3f_GrSLType, "TextColor",
&textColorUniName);
fsBuilder->codeAppendf("\tuv = vec2(val.x, %s.x);\n", textColorUniName);
fsBuilder->codeAppend("\tvec4 gammaColor = ");
fsBuilder->appendTextureLookup(samplers[1], "uv", kVec2f_GrSLType);
fsBuilder->appendTextureLookup(args.fSamplers[1], "uv", kVec2f_GrSLType);
fsBuilder->codeAppend(";\n");
fsBuilder->codeAppend("\tval.x = gammaColor.r;\n");
fsBuilder->codeAppendf("\tuv = vec2(val.y, %s.y);\n", textColorUniName);
fsBuilder->codeAppend("\tgammaColor = ");
fsBuilder->appendTextureLookup(samplers[1], "uv", kVec2f_GrSLType);
fsBuilder->appendTextureLookup(args.fSamplers[1], "uv", kVec2f_GrSLType);
fsBuilder->codeAppend(";\n");
fsBuilder->codeAppend("\tval.y = gammaColor.r;\n");
fsBuilder->codeAppendf("\tuv = vec2(val.z, %s.z);\n", textColorUniName);
fsBuilder->codeAppend("\tgammaColor = ");
fsBuilder->appendTextureLookup(samplers[1], "uv", kVec2f_GrSLType);
fsBuilder->appendTextureLookup(args.fSamplers[1], "uv", kVec2f_GrSLType);
fsBuilder->codeAppend(";\n");
fsBuilder->codeAppend("\tval.z = gammaColor.r;\n");
fsBuilder->codeAppendf("\t%s = %s;\n", outputColor,
(GrGLSLExpr4(inputColor) * GrGLSLExpr4("val")).c_str());
fsBuilder->codeAppendf("\t%s = %s;\n", args.fOutput,
(GrGLSLExpr4(args.fInput) * GrGLSLExpr4("val")).c_str());
}
virtual void setData(const GrGLProgramDataManager& pdman,

View File

@ -22,17 +22,26 @@ public:
GrGLGeometryProcessor(const GrBackendProcessorFactory& factory)
: INHERITED(factory) {}
struct EmitArgs {
EmitArgs(GrGLGPBuilder* pb,
const GrGeometryProcessor& gp,
const GrProcessorKey& key,
const char* output,
const char* input,
const TextureSamplerArray& samplers)
: fPB(pb), fGP(gp), fKey(key), fOutput(output), fInput(input), fSamplers(samplers) {}
GrGLGPBuilder* fPB;
const GrGeometryProcessor& fGP;
const GrProcessorKey& fKey;
const char* fOutput;
const char* fInput;
const TextureSamplerArray& fSamplers;
};
/**
* This is similar to emitCode() in the base class, except it takes a full shader builder.
* This allows the effect subclass to emit vertex code.
*/
virtual void emitCode(GrGLGPBuilder* builder,
const GrGeometryProcessor& geometryProcessor,
const GrProcessorKey& key,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray& coords,
const TextureSamplerArray& samplers) = 0;
virtual void emitCode(const EmitArgs&) = 0;
private:
typedef GrGLProcessor INHERITED;

View File

@ -313,11 +313,8 @@ void GrGLProgramBuilder::emitAndInstallProc(const GrGeometryProcessor& gp,
SkSTArray<4, GrGLProcessor::TextureSampler> samplers(gp.numTextures());
this->emitSamplers(gp, &samplers, fGeometryProcessor);
SkSTArray<2, GrGLProcessor::TransformedCoords> coords;
// TODO remove coords from emit code signature, probably best to use a struct here so these
// updates are less painful
fGeometryProcessor->fGLProc->emitCode(this, gp, key, outColor, inColor, coords, samplers);
GrGLGeometryProcessor::EmitArgs args(this, gp, key, outColor, inColor, samplers);
fGeometryProcessor->fGLProc->emitCode(args);
// We have to check that effects and the code they emit are consistent, ie if an effect
// asks for dst color, then the emit code needs to follow suit