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

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

Issue 551253004: Changes to remove program effects builder (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 6 years, 3 months 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/gl/builders/GrGLProgramBuilder.h ('k') | src/gpu/gl/builders/GrGLShaderBuilder.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/gl/builders/GrGLProgramBuilder.cpp
diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.cpp b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
index d3067764418949818a0b69b81676176cd6274257..a0dd555587f7a466f98bbfa48769443c1e6b8843 100644
--- a/src/gpu/gl/builders/GrGLProgramBuilder.cpp
+++ b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
@@ -67,28 +67,9 @@ bool GrGLProgramBuilder::genProgram(const GrEffectStage* geometryProcessor,
inputCoverage = GrGLSLExpr4(1);
}
- this->emitCodeBeforeEffects(&inputColor, &inputCoverage);
-
- ///////////////////////////////////////////////////////////////////////////
- // emit the per-effect code for both color and coverage effects
-
- GrGLProgramDesc::EffectKeyProvider colorKeyProvider(
- &this->desc(), GrGLProgramDesc::EffectKeyProvider::kColor_EffectType);
- fColorEffects.reset(this->createAndEmitEffects(colorStages,
- this->desc().numColorEffects(),
- colorKeyProvider,
- &inputColor));
-
- this->emitGeometryProcessor(geometryProcessor, &inputCoverage);
-
- GrGLProgramDesc::EffectKeyProvider coverageKeyProvider(
- &this->desc(), GrGLProgramDesc::EffectKeyProvider::kCoverage_EffectType);
- fCoverageEffects.reset(this->createAndEmitEffects(coverageStages,
- this->desc().numCoverageEffects(),
- coverageKeyProvider,
- &inputCoverage));
-
- this->emitCodeAfterEffects();
+ // Subclasses drive effect emitting
+ this->createAndEmitEffects(geometryProcessor, colorStages, coverageStages, &inputColor,
+ &inputCoverage);
fFS.emitCodeAfterEffects(inputColor, inputCoverage);
@@ -178,8 +159,7 @@ void GrGLProgramBuilder::appendUniformDecls(ShaderVisibility visibility,
}
}
-void GrGLProgramBuilder::createAndEmitEffects(GrGLProgramEffectsBuilder* programEffectsBuilder,
- const GrEffectStage* effectStages[],
+void GrGLProgramBuilder::createAndEmitEffects(const GrEffectStage* effectStages[],
int effectCnt,
const GrGLProgramDesc::EffectKeyProvider& keyProvider,
GrGLSLExpr4* fsInOutColor) {
@@ -189,39 +169,59 @@ void GrGLProgramBuilder::createAndEmitEffects(GrGLProgramEffectsBuilder* program
GrGLSLExpr4 outColor;
for (int e = 0; e < effectCnt; ++e) {
- SkASSERT(effectStages[e] && effectStages[e]->getEffect());
- const GrEffectStage& stage = *effectStages[e];
-
- CodeStage::AutoStageRestore csar(&fCodeStage, &stage);
-
- if (inColor.isZeros()) {
- SkString inColorName;
+ // calls into the subclass to emit the actual effect into the program effect object
+ this->emitEffect(*effectStages[e], e, keyProvider, &inColor, &outColor);
+ effectEmitted = true;
+ }
- // Effects have no way to communicate zeros, they treat an empty string as ones.
- this->nameVariable(&inColorName, '\0', "input");
- fFS.codeAppendf("\tvec4 %s = %s;\n", inColorName.c_str(), inColor.c_str());
- inColor = inColorName;
- }
+ if (effectEmitted) {
+ *fsInOutColor = outColor;
+ }
+}
- // create var to hold stage result
- SkString outColorName;
- this->nameVariable(&outColorName, '\0', "output");
- fFS.codeAppendf("\tvec4 %s;\n", outColorName.c_str());
- outColor = outColorName;
+void GrGLProgramBuilder::emitEffect(const GrEffectStage& effectStage,
+ int effectIndex,
+ const GrGLProgramDesc::EffectKeyProvider& keyProvider,
+ GrGLSLExpr4* inColor,
+ GrGLSLExpr4* outColor) {
+ SkASSERT(effectStage.getEffect());
+ CodeStage::AutoStageRestore csar(&fCodeStage, &effectStage);
+
+ if (inColor->isZeros()) {
+ SkString inColorName;
+
+ // Effects have no way to communicate zeros, they treat an empty string as ones.
+ this->nameVariable(&inColorName, '\0', "input");
+ fFS.codeAppendf("\tvec4 %s = %s;\n", inColorName.c_str(), inColor->c_str());
+ *inColor = inColorName;
+ }
+ // create var to hold stage result
+ SkString outColorName;
+ this->nameVariable(&outColorName, '\0', "output");
+ fFS.codeAppendf("\tvec4 %s;\n", outColorName.c_str());
+ *outColor = outColorName;
- programEffectsBuilder->emitEffect(stage,
- keyProvider.get(e),
- outColor.c_str(),
- inColor.isOnes() ? NULL : inColor.c_str(),
- fCodeStage.stageIndex());
+ this->emitEffect(effectStage, keyProvider.get(effectIndex), outColor->c_str(),
+ inColor->isOnes() ? NULL : inColor->c_str(), fCodeStage.stageIndex());
- inColor = outColor;
- effectEmitted = true;
- }
+ *inColor = *outColor;
+}
- if (effectEmitted) {
- *fsInOutColor = outColor;
+void GrGLProgramBuilder::emitSamplers(const GrEffect& effect,
+ GrGLEffect::TextureSamplerArray* outSamplers) {
+ SkTArray<GrGLProgramEffects::Sampler, true>& samplers =
+ this->getProgramEffects()->addSamplers();
+ int numTextures = effect.numTextures();
+ samplers.push_back_n(numTextures);
+ SkString name;
+ for (int t = 0; t < numTextures; ++t) {
+ name.printf("Sampler%d", t);
+ samplers[t].fUniform = this->addUniform(GrGLProgramBuilder::kFragment_Visibility,
+ kSampler2D_GrSLType,
+ name.c_str());
+ SkNEW_APPEND_TO_TARRAY(outSamplers, GrGLEffect::TextureSampler,
+ (samplers[t].fUniform, effect.textureAccess(t)));
}
}
« no previous file with comments | « src/gpu/gl/builders/GrGLProgramBuilder.h ('k') | src/gpu/gl/builders/GrGLShaderBuilder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698