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

Unified Diff: src/gpu/glsl/GrGLSLXferProcessor.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/glsl/GrGLSLXferProcessor.h ('k') | tests/GLProgramsTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/glsl/GrGLSLXferProcessor.cpp
diff --git a/src/gpu/glsl/GrGLSLXferProcessor.cpp b/src/gpu/glsl/GrGLSLXferProcessor.cpp
index 38f2e6a131d9acffec2e8d84b3e72626d3ee75d1..4d2ec1074b381b800721a7ffb995cc67b72c21a9 100644
--- a/src/gpu/glsl/GrGLSLXferProcessor.cpp
+++ b/src/gpu/glsl/GrGLSLXferProcessor.cpp
@@ -18,8 +18,8 @@ void GrGLSLXferProcessor::emitCode(const EmitArgs& args) {
return;
}
- GrGLSLXPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
- const char* dstColor = fsBuilder->dstColor();
+ GrGLSLXPFragmentBuilder* fragBuilder = args.fXPFragBuilder;
+ const char* dstColor = fragBuilder->dstColor();
if (args.fXP.getDstTexture()) {
bool topDown = kTopLeft_GrSurfaceOrigin == args.fXP.getDstTexture()->origin();
@@ -27,9 +27,9 @@ void GrGLSLXferProcessor::emitCode(const EmitArgs& args) {
if (args.fXP.readsCoverage()) {
// We don't think any shaders actually output negative coverage, but just as a safety
// check for floating point precision errors we compare with <= here
- fsBuilder->codeAppendf("if (all(lessThanEqual(%s, vec4(0)))) {"
- " discard;"
- "}", args.fInputCoverage);
+ fragBuilder->codeAppendf("if (all(lessThanEqual(%s, vec4(0)))) {"
+ " discard;"
+ "}", args.fInputCoverage);
}
const char* dstTopLeftName;
@@ -45,36 +45,40 @@ void GrGLSLXferProcessor::emitCode(const EmitArgs& args) {
kDefault_GrSLPrecision,
"DstTextureCoordScale",
&dstCoordScaleName);
- const char* fragPos = fsBuilder->fragmentPosition();
+ const char* fragPos = fragBuilder->fragmentPosition();
- fsBuilder->codeAppend("// Read color from copy of the destination.\n");
- fsBuilder->codeAppendf("vec2 _dstTexCoord = (%s.xy - %s) * %s;",
- fragPos, dstTopLeftName, dstCoordScaleName);
+ fragBuilder->codeAppend("// Read color from copy of the destination.\n");
+ fragBuilder->codeAppendf("vec2 _dstTexCoord = (%s.xy - %s) * %s;",
+ fragPos, dstTopLeftName, dstCoordScaleName);
if (!topDown) {
- fsBuilder->codeAppend("_dstTexCoord.y = 1.0 - _dstTexCoord.y;");
+ fragBuilder->codeAppend("_dstTexCoord.y = 1.0 - _dstTexCoord.y;");
}
- fsBuilder->codeAppendf("vec4 %s = ", dstColor);
- fsBuilder->appendTextureLookup(args.fSamplers[0], "_dstTexCoord", kVec2f_GrSLType);
- fsBuilder->codeAppend(";");
+ fragBuilder->codeAppendf("vec4 %s = ", dstColor);
+ fragBuilder->appendTextureLookup(args.fSamplers[0], "_dstTexCoord", kVec2f_GrSLType);
+ fragBuilder->codeAppend(";");
}
- this->emitBlendCodeForDstRead(args.fPB, args.fInputColor, dstColor, args.fOutputPrimary,
+ this->emitBlendCodeForDstRead(args.fPB,
+ fragBuilder,
+ args.fInputColor,
+ dstColor,
+ args.fOutputPrimary,
args.fXP);
// Apply coverage.
if (args.fXP.dstReadUsesMixedSamples()) {
if (args.fXP.readsCoverage()) {
- fsBuilder->codeAppendf("%s *= %s;", args.fOutputPrimary, args.fInputCoverage);
- fsBuilder->codeAppendf("%s = %s;", args.fOutputSecondary, args.fInputCoverage);
+ fragBuilder->codeAppendf("%s *= %s;", args.fOutputPrimary, args.fInputCoverage);
+ fragBuilder->codeAppendf("%s = %s;", args.fOutputSecondary, args.fInputCoverage);
} else {
- fsBuilder->codeAppendf("%s = vec4(1.0);", args.fOutputSecondary);
+ fragBuilder->codeAppendf("%s = vec4(1.0);", args.fOutputSecondary);
}
} else if (args.fXP.readsCoverage()) {
- fsBuilder->codeAppendf("%s = %s * %s + (vec4(1.0) - %s) * %s;",
- args.fOutputPrimary, args.fInputCoverage,
- args.fOutputPrimary, args.fInputCoverage, dstColor);
+ fragBuilder->codeAppendf("%s = %s * %s + (vec4(1.0) - %s) * %s;",
+ args.fOutputPrimary, args.fInputCoverage,
+ args.fOutputPrimary, args.fInputCoverage, dstColor);
}
}
« no previous file with comments | « src/gpu/glsl/GrGLSLXferProcessor.h ('k') | tests/GLProgramsTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698