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

Unified Diff: src/gpu/gl/builders/GrGLFragmentShaderBuilder.cpp

Issue 789343002: Revert of Create xfer processor backend. (Closed) Base URL: https://skia.googlesource.com/skia.git@xferBlendSolo
Patch Set: Created 6 years 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
Index: src/gpu/gl/builders/GrGLFragmentShaderBuilder.cpp
diff --git a/src/gpu/gl/builders/GrGLFragmentShaderBuilder.cpp b/src/gpu/gl/builders/GrGLFragmentShaderBuilder.cpp
index b6daca797865e7055561ebeb11a494a094682176..49be12d8badf82f2aa910b9fd00f1c449568c1fc 100644
--- a/src/gpu/gl/builders/GrGLFragmentShaderBuilder.cpp
+++ b/src/gpu/gl/builders/GrGLFragmentShaderBuilder.cpp
@@ -256,6 +256,55 @@
return dual_source_output_name();
}
+void GrGLFragmentShaderBuilder::enableSecondaryOutput(const GrGLSLExpr4& inputColor,
+ const GrGLSLExpr4& inputCoverage) {
+ this->enableSecondaryOutput();
+ const char* secondaryOutputName = this->getSecondaryColorOutputName();
+ GrGLSLExpr4 coeff(1);
+ switch (fProgramBuilder->header().fSecondaryOutputType) {
+ case GrProgramDesc::kCoverage_SecondaryOutputType:
+ break;
+ case GrProgramDesc::kCoverageISA_SecondaryOutputType:
+ // Get (1-A) into coeff
+ coeff = GrGLSLExpr4::VectorCast(GrGLSLExpr1(1) - inputColor.a());
+ break;
+ case GrProgramDesc::kCoverageISC_SecondaryOutputType:
+ // Get (1-RGBA) into coeff
+ coeff = GrGLSLExpr4(1) - inputColor;
+ break;
+ default:
+ SkFAIL("Unexpected Secondary Output");
+ }
+ // Get coeff * coverage into modulate and then write that to the dual source output.
+ this->codeAppendf("\t%s = %s;\n", secondaryOutputName, (coeff * inputCoverage).c_str());
+}
+
+void GrGLFragmentShaderBuilder::combineColorAndCoverage(const GrGLSLExpr4& inputColor,
+ const GrGLSLExpr4& inputCoverage) {
+ GrGLSLExpr4 fragColor = inputColor * inputCoverage;
+ switch (fProgramBuilder->header().fPrimaryOutputType) {
+ case GrProgramDesc::kModulate_PrimaryOutputType:
+ break;
+ case GrProgramDesc::kCombineWithDst_PrimaryOutputType:
+ {
+ // Tack on "+(1-coverage)dst onto the frag color.
+ GrGLSLExpr4 dstCoeff = GrGLSLExpr4(1) - inputCoverage;
+ GrGLSLExpr4 dstContribution = dstCoeff * GrGLSLExpr4(this->dstColor());
+ fragColor = fragColor + dstContribution;
+ }
+ break;
+ default:
+ SkFAIL("Unknown Primary Output");
+ }
+
+ // On any post 1.10 GLSL supporting GPU, we declare custom output
+ if (k110_GrGLSLGeneration != fProgramBuilder->gpu()->glslGeneration()) {
+ this->enableCustomOutput();
+ }
+
+ this->codeAppendf("\t%s = %s;\n", this->getPrimaryColorOutputName(), fragColor.c_str());
+}
+
bool GrGLFragmentShaderBuilder::compileAndAttachShaders(GrGLuint programId,
SkTDArray<GrGLuint>* shaderIds) const {
GrGpuGL* gpu = fProgramBuilder->gpu();
« no previous file with comments | « src/gpu/gl/builders/GrGLFragmentShaderBuilder.h ('k') | src/gpu/gl/builders/GrGLLegacyNvprProgramBuilder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698