Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(297)

Unified Diff: src/gpu/batches/GrAAConvexPathRenderer.cpp

Issue 1457543003: Add ShaderBuilders to EmitArgs and remove gettings from ProgBuilder. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/GrPathProcessor.cpp ('k') | src/gpu/effects/GrBezierEffect.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/batches/GrAAConvexPathRenderer.cpp
diff --git a/src/gpu/batches/GrAAConvexPathRenderer.cpp b/src/gpu/batches/GrAAConvexPathRenderer.cpp
index d5522b1dc4a0971009e6ee5d15fd5b290c53d8e9..b78ecd80bcb5abd27761aac44e6b4ae3440ff9bd 100644
--- a/src/gpu/batches/GrAAConvexPathRenderer.cpp
+++ b/src/gpu/batches/GrAAConvexPathRenderer.cpp
@@ -549,50 +549,54 @@ public:
void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override {
const QuadEdgeEffect& qe = args.fGP.cast<QuadEdgeEffect>();
GrGLSLGPBuilder* pb = args.fPB;
- GrGLSLVertexBuilder* vsBuilder = pb->getVertexShaderBuilder();
+ GrGLSLVertexBuilder* vertBuilder = args.fVertBuilder;
// emit attributes
- vsBuilder->emitAttributes(qe);
+ vertBuilder->emitAttributes(qe);
GrGLSLVertToFrag v(kVec4f_GrSLType);
args.fPB->addVarying("QuadEdge", &v);
- vsBuilder->codeAppendf("%s = %s;", v.vsOut(), qe.inQuadEdge()->fName);
+ vertBuilder->codeAppendf("%s = %s;", v.vsOut(), qe.inQuadEdge()->fName);
+ GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
// Setup pass through color
if (!qe.colorIgnored()) {
- this->setupUniformColor(pb, args.fOutputColor, &fColorUniform);
+ this->setupUniformColor(pb, fragBuilder, args.fOutputColor, &fColorUniform);
}
// Setup position
- this->setupPosition(pb, gpArgs, qe.inPosition()->fName);
+ this->setupPosition(pb, vertBuilder, gpArgs, qe.inPosition()->fName);
// emit transforms
- this->emitTransforms(args.fPB, gpArgs->fPositionVar, qe.inPosition()->fName,
- qe.localMatrix(), args.fTransformsIn, args.fTransformsOut);
-
- GrGLSLFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
-
- SkAssertResult(fsBuilder->enableFeature(
+ this->emitTransforms(args.fPB,
+ vertBuilder,
+ gpArgs->fPositionVar,
+ qe.inPosition()->fName,
+ qe.localMatrix(),
+ args.fTransformsIn,
+ args.fTransformsOut);
+
+ SkAssertResult(fragBuilder->enableFeature(
GrGLSLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature));
- fsBuilder->codeAppendf("float edgeAlpha;");
+ fragBuilder->codeAppendf("float edgeAlpha;");
// keep the derivative instructions outside the conditional
- fsBuilder->codeAppendf("vec2 duvdx = dFdx(%s.xy);", v.fsIn());
- fsBuilder->codeAppendf("vec2 duvdy = dFdy(%s.xy);", v.fsIn());
- fsBuilder->codeAppendf("if (%s.z > 0.0 && %s.w > 0.0) {", v.fsIn(), v.fsIn());
+ fragBuilder->codeAppendf("vec2 duvdx = dFdx(%s.xy);", v.fsIn());
+ fragBuilder->codeAppendf("vec2 duvdy = dFdy(%s.xy);", v.fsIn());
+ fragBuilder->codeAppendf("if (%s.z > 0.0 && %s.w > 0.0) {", v.fsIn(), v.fsIn());
// today we know z and w are in device space. We could use derivatives
- fsBuilder->codeAppendf("edgeAlpha = min(min(%s.z, %s.w) + 0.5, 1.0);", v.fsIn(),
- v.fsIn());
- fsBuilder->codeAppendf ("} else {");
- fsBuilder->codeAppendf("vec2 gF = vec2(2.0*%s.x*duvdx.x - duvdx.y,"
- " 2.0*%s.x*duvdy.x - duvdy.y);",
- v.fsIn(), v.fsIn());
- fsBuilder->codeAppendf("edgeAlpha = (%s.x*%s.x - %s.y);", v.fsIn(), v.fsIn(),
- v.fsIn());
- fsBuilder->codeAppendf("edgeAlpha = "
- "clamp(0.5 - edgeAlpha / length(gF), 0.0, 1.0);}");
-
- fsBuilder->codeAppendf("%s = vec4(edgeAlpha);", args.fOutputCoverage);
+ fragBuilder->codeAppendf("edgeAlpha = min(min(%s.z, %s.w) + 0.5, 1.0);", v.fsIn(),
+ v.fsIn());
+ fragBuilder->codeAppendf ("} else {");
+ fragBuilder->codeAppendf("vec2 gF = vec2(2.0*%s.x*duvdx.x - duvdx.y,"
+ " 2.0*%s.x*duvdy.x - duvdy.y);",
+ v.fsIn(), v.fsIn());
+ fragBuilder->codeAppendf("edgeAlpha = (%s.x*%s.x - %s.y);", v.fsIn(), v.fsIn(),
+ v.fsIn());
+ fragBuilder->codeAppendf("edgeAlpha = "
+ "clamp(0.5 - edgeAlpha / length(gF), 0.0, 1.0);}");
+
+ fragBuilder->codeAppendf("%s = vec4(edgeAlpha);", args.fOutputCoverage);
}
static inline void GenKey(const GrGeometryProcessor& gp,
« no previous file with comments | « src/gpu/GrPathProcessor.cpp ('k') | src/gpu/effects/GrBezierEffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698