| Index: src/gpu/gl/GrGLShaderBuilder.cpp
|
| diff --git a/src/gpu/gl/GrGLShaderBuilder.cpp b/src/gpu/gl/GrGLShaderBuilder.cpp
|
| index f73520c363f268a7666689d2a4b26404afbcaea0..d11394a7b39371608b1ce113cbc7b8d1a49a4e78 100644
|
| --- a/src/gpu/gl/GrGLShaderBuilder.cpp
|
| +++ b/src/gpu/gl/GrGLShaderBuilder.cpp
|
| @@ -94,7 +94,7 @@ static const char kDstCopyColorName[] = "_dstColor";
|
| GrGLShaderBuilder::GrGLShaderBuilder(const GrGLContextInfo& ctxInfo,
|
| GrGLUniformManager& uniformManager,
|
| const GrGLProgramDesc& desc,
|
| - bool hasVertexShaderEffects)
|
| + bool needsVertexShader)
|
| : fUniforms(kVarsPerBlock)
|
| , fCtxInfo(ctxInfo)
|
| , fUniformManager(uniformManager)
|
| @@ -106,8 +106,9 @@ GrGLShaderBuilder::GrGLShaderBuilder(const GrGLContextInfo& ctxInfo,
|
|
|
| const GrGLProgramDesc::KeyHeader& header = desc.getHeader();
|
|
|
| - // TODO: go vertexless when possible.
|
| - fVertexBuilder.reset(SkNEW_ARGS(VertexBuilder, (this, desc)));
|
| + if (needsVertexShader) {
|
| + fVertexBuilder.reset(SkNEW_ARGS(VertexBuilder, (this, desc)));
|
| + }
|
|
|
| // Emit code to read the dst copy textue if necessary.
|
| if (kNoDstRead_DstReadKey != header.fDstReadKey &&
|
| @@ -216,7 +217,7 @@ void GrGLShaderBuilder::nameVariable(SkString* out, char prefix, const char* nam
|
|
|
| const char* GrGLShaderBuilder::dstColor() {
|
| if (fCodeStage.inStageCode()) {
|
| - const GrEffectRef& effect = *fCodeStage.effect();
|
| + const GrEffectRef& effect = *fCodeStage.effectStage()->getEffect();
|
| if (!effect->willReadDstColor()) {
|
| GrDebugCrash("GrGLEffect asked for dst color but its generating GrEffect "
|
| "did not request access.");
|
| @@ -362,7 +363,7 @@ GrGLUniformManager::UniformHandle GrGLShaderBuilder::addUniformArray(uint32_t vi
|
|
|
| const char* GrGLShaderBuilder::fragmentPosition() {
|
| if (fCodeStage.inStageCode()) {
|
| - const GrEffectRef& effect = *fCodeStage.effect();
|
| + const GrEffectRef& effect = *fCodeStage.effectStage()->getEffect();
|
| if (!effect->willReadFragmentPosition()) {
|
| GrDebugCrash("GrGLEffect asked for frag position but its generating GrEffect "
|
| "did not request access.");
|
| @@ -499,23 +500,24 @@ void GrGLShaderBuilder::finished(GrGLuint programID) {
|
| }
|
|
|
| void GrGLShaderBuilder::emitEffects(
|
| - GrGLEffect* const glEffects[],
|
| - const GrDrawEffect drawEffects[],
|
| + const GrEffectStage* effectStages[],
|
| const GrBackendEffectFactory::EffectKey effectKeys[],
|
| int effectCnt,
|
| SkString* fsInOutColor,
|
| GrSLConstantVec* fsInOutColorKnownValue,
|
| - SkTArray<GrGLUniformManager::UniformHandle, true>* effectSamplerHandles[]) {
|
| + SkTArray<GrGLUniformManager::UniformHandle, true>* effectSamplerHandles[],
|
| + GrGLEffect* glEffects[]) {
|
| bool effectEmitted = false;
|
|
|
| SkString inColor = *fsInOutColor;
|
| SkString outColor;
|
|
|
| for (int e = 0; e < effectCnt; ++e) {
|
| - const GrDrawEffect& drawEffect = drawEffects[e];
|
| - const GrEffectRef& effect = *drawEffect.effect();
|
| + SkASSERT(NULL != effectStages[e] && NULL != effectStages[e]->getEffect());
|
| + const GrEffectStage& stage = *effectStages[e];
|
| + const GrEffectRef& effect = *stage.getEffect();
|
|
|
| - CodeStage::AutoStageRestore csar(&fCodeStage, &effect);
|
| + CodeStage::AutoStageRestore csar(&fCodeStage, &stage);
|
|
|
| int numTextures = effect->numTextures();
|
| SkSTArray<8, GrGLShaderBuilder::TextureSampler> textureSamplers;
|
| @@ -524,9 +526,11 @@ void GrGLShaderBuilder::emitEffects(
|
| textureSamplers[t].init(this, &effect->textureAccess(t), t);
|
| effectSamplerHandles[e]->push_back(textureSamplers[t].fSamplerUniform);
|
| }
|
| + GrDrawEffect drawEffect(stage, fVertexBuilder.get()
|
| + && fVertexBuilder->hasExplicitLocalCoords());
|
|
|
| - int numAttributes = drawEffect.getVertexAttribIndexCount();
|
| - const int* attributeIndices = drawEffect.getVertexAttribIndices();
|
| + int numAttributes = stage.getVertexAttribIndexCount();
|
| + const int* attributeIndices = stage.getVertexAttribIndices();
|
| SkSTArray<GrEffect::kMaxVertexAttribs, SkString> attributeNames;
|
| for (int a = 0; a < numAttributes; ++a) {
|
| // TODO: Make addAttribute mangle the name.
|
| @@ -538,6 +542,8 @@ void GrGLShaderBuilder::emitEffects(
|
| attributeName);
|
| }
|
|
|
| + glEffects[e] = effect->getFactory().createGLInstance(drawEffect);
|
| +
|
| if (kZeros_GrSLConstantVec == *fsInOutColorKnownValue) {
|
| // Effects have no way to communicate zeros, they treat an empty string as ones.
|
| this->nameVariable(&inColor, '\0', "input");
|
|
|