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

Unified Diff: src/gpu/gl/builders/GrGLFragmentOnlyProgramBuilder.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
Index: src/gpu/gl/builders/GrGLFragmentOnlyProgramBuilder.cpp
diff --git a/src/gpu/gl/builders/GrGLFragmentOnlyProgramBuilder.cpp b/src/gpu/gl/builders/GrGLFragmentOnlyProgramBuilder.cpp
index 3ad6b446c1523d76b7e45f5555bdd7ee5f5e4d30..16def638b5718e39abbb76c243e98d2115a82c9d 100644
--- a/src/gpu/gl/builders/GrGLFragmentOnlyProgramBuilder.cpp
+++ b/src/gpu/gl/builders/GrGLFragmentOnlyProgramBuilder.cpp
@@ -24,16 +24,85 @@ int GrGLFragmentOnlyProgramBuilder::addTexCoordSets(int count) {
return firstFreeCoordSet;
}
-GrGLProgramEffects* GrGLFragmentOnlyProgramBuilder::createAndEmitEffects(
+void
+GrGLFragmentOnlyProgramBuilder::createAndEmitEffects(const GrEffectStage* geometryProcessor,
+ const GrEffectStage* colorStages[],
+ const GrEffectStage* coverageStages[],
+ GrGLSLExpr4* inputColor,
+ GrGLSLExpr4* inputCoverage) {
+ ///////////////////////////////////////////////////////////////////////////
+ // emit the per-effect code for both color and coverage effects
+
+ EffectKeyProvider colorKeyProvider(&this->desc(), EffectKeyProvider::kColor_EffectType);
+ fColorEffects.reset(this->onCreateAndEmitEffects(colorStages,
+ this->desc().numColorEffects(),
+ colorKeyProvider,
+ inputColor));
+
+ EffectKeyProvider coverageKeyProvider(&this->desc(), EffectKeyProvider::kCoverage_EffectType);
+ fCoverageEffects.reset(this->onCreateAndEmitEffects(coverageStages,
+ this->desc().numCoverageEffects(),
+ coverageKeyProvider,
+ inputCoverage));
+}
+
+GrGLProgramEffects* GrGLFragmentOnlyProgramBuilder::onCreateAndEmitEffects(
const GrEffectStage* effectStages[], int effectCnt,
const GrGLProgramDesc::EffectKeyProvider& keyProvider, GrGLSLExpr4* inOutFSColor) {
- GrGLPathTexGenProgramEffectsBuilder pathTexGenEffectsBuilder(this,
- effectCnt);
- this->INHERITED::createAndEmitEffects(&pathTexGenEffectsBuilder,
- effectStages,
+ fProgramEffects.reset(SkNEW_ARGS(GrGLPathTexGenProgramEffects, (effectCnt)));
+ this->INHERITED::createAndEmitEffects(effectStages,
effectCnt,
keyProvider,
inOutFSColor);
- return pathTexGenEffectsBuilder.finish();
+ return fProgramEffects.detach();
+}
+
+void GrGLFragmentOnlyProgramBuilder::emitEffect(const GrEffectStage& stage,
+ const GrEffectKey& key,
+ const char* outColor,
+ const char* inColor,
+ int stageIndex) {
+ SkASSERT(fProgramEffects.get());
+ const GrEffect& effect = *stage.getEffect();
+ SkASSERT(0 == effect.getVertexAttribs().count());
+
+ SkSTArray<2, GrGLEffect::TransformedCoords> coords(effect.numTransforms());
+ SkSTArray<4, GrGLEffect::TextureSampler> samplers(effect.numTextures());
+
+ this->setupPathTexGen(stage, &coords);
+ this->emitSamplers(effect, &samplers);
+
+ GrGLEffect* glEffect = effect.getFactory().createGLInstance(effect);
+ SkASSERT(!glEffect->isVertexEffect());
+ fProgramEffects->addEffect(glEffect);
+
+ GrGLFragmentShaderBuilder* fsBuilder = this->getFragmentShaderBuilder();
+ // Enclose custom code in a block to avoid namespace conflicts
+ SkString openBrace;
+ openBrace.printf("\t{ // Stage %d: %s\n", stageIndex, glEffect->name());
+ fsBuilder->codeAppend(openBrace.c_str());
+
+ glEffect->emitCode(this, effect, key, outColor, inColor, coords, samplers);
+
+ fsBuilder->codeAppend("\t}\n");
+}
+
+void GrGLFragmentOnlyProgramBuilder::setupPathTexGen(const GrEffectStage& effectStage,
+ GrGLEffect::TransformedCoordsArray* outCoords) {
+ int numTransforms = effectStage.getEffect()->numTransforms();
+ int texCoordIndex = this->addTexCoordSets(numTransforms);
+
+ fProgramEffects->addTransforms(texCoordIndex);
+
+ SkString name;
+ for (int t = 0; t < numTransforms; ++t) {
+ GrSLType type =
+ effectStage.isPerspectiveCoordTransform(t, false) ?
+ kVec3f_GrSLType :
+ kVec2f_GrSLType;
+
+ name.printf("%s(gl_TexCoord[%i])", GrGLSLTypeString(type), texCoordIndex++);
+ SkNEW_APPEND_TO_TARRAY(outCoords, GrGLEffect::TransformedCoords, (name, type));
+ }
}
« no previous file with comments | « src/gpu/gl/builders/GrGLFragmentOnlyProgramBuilder.h ('k') | src/gpu/gl/builders/GrGLFragmentShaderBuilder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698