void GrGLPathTexGenProgramEffects::emitEffect(GrGLFragmentOnlyShaderBuilder* builder, const GrEffectStage& stage, const GrEffectKey& key, const char* outColor, const char* inColor, int stageIndex) { GrDrawEffect drawEffect(stage, false); const GrEffect* effect = stage.getEffect(); SkSTArray<2, TransformedCoords> coords(effect->numTransforms()); SkSTArray<4, TextureSampler> samplers(effect->numTextures()); SkASSERT(0 == stage.getVertexAttribIndexCount()); this->setupPathTexGen(builder, drawEffect, &coords); this->emitSamplers(builder, effect, &samplers); GrGLEffect* glEffect = effect->getFactory().createGLInstance(drawEffect); fGLEffects.push_back(glEffect); // Enclose custom code in a block to avoid namespace conflicts SkString openBrace; openBrace.printf("\t{ // Stage %d: %s\n", stageIndex, glEffect->name()); builder->fsCodeAppend(openBrace.c_str()); SkASSERT(!glEffect->isVertexEffect()); glEffect->emitCode(builder, drawEffect, key, outColor, inColor, coords, samplers); builder->fsCodeAppend("\t}\n"); }
void GrGLVertexProgramEffects::emitAttributes(GrGLFullShaderBuilder* builder, const GrEffectStage& stage) { int numAttributes = stage.getVertexAttribIndexCount(); const int* attributeIndices = stage.getVertexAttribIndices(); for (int a = 0; a < numAttributes; ++a) { // TODO: Make addAttribute mangle the name. SkString attributeName("aAttr"); attributeName.appendS32(attributeIndices[a]); builder->addEffectAttribute(attributeIndices[a], stage.getEffect()->vertexAttribType(a), attributeName); } }