| Index: src/gpu/gl/builders/GrGLFragmentShaderBuilder.cpp
|
| diff --git a/src/gpu/gl/builders/GrGLFragmentShaderBuilder.cpp b/src/gpu/gl/builders/GrGLFragmentShaderBuilder.cpp
|
| index 20bb3a389341a5bf1f614587d042a8ca3e0d91cf..a82b6b7f44dd2dfb734c8db78e6bcca0798a8be6 100644
|
| --- a/src/gpu/gl/builders/GrGLFragmentShaderBuilder.cpp
|
| +++ b/src/gpu/gl/builders/GrGLFragmentShaderBuilder.cpp
|
| @@ -312,3 +312,52 @@ void GrGLFragmentBuilder::onAfterChildProcEmitCode() {
|
| int removeAt = fMangleString.findLastOf('_');
|
| fMangleString.remove(removeAt, fMangleString.size() - removeAt);
|
| }
|
| +
|
| +GrGLFragmentBuilder::AutoFragmentChildProcAdvance::AutoFragmentChildProcAdvance(
|
| + int childProcIndex,
|
| + GrGLFPBuilder* builder,
|
| + const GrFragmentProcessor& fp,
|
| + const char* outputColor,
|
| + const TransformedCoordsArray& coords,
|
| + const TextureSamplerArray& samplers,
|
| + const GrFragmentProcessor** childFp,
|
| + SkString* childOutputColor,
|
| + TransformedCoordsArray* childCoords,
|
| + TextureSamplerArray* childSamplers
|
| + ) {
|
| + fFsb = builder->getFragmentShaderBuilder();
|
| + fFsb->onBeforeChildProcEmitCode(); // call first so mangleString is updated
|
| +
|
| + const GrFragmentProcessor& childProc = fp.childProcessor(childProcIndex);
|
| + *childFp = &childProc;
|
| +
|
| + // Mangle the name of the outputColor
|
| + childOutputColor->set(outputColor);
|
| + childOutputColor->append(fFsb->getMangleStringThisLevel());
|
| +
|
| + // Find the subset of the transforms and textures that belongs to this child proc.
|
| + // Since we don't know how many transforms/textures at the head of the arrays
|
| + // belong to this proc and not one of its children, we have to do a backwards linear search
|
| + // from the ends of the arrays.
|
| + SkASSERT(childCoords->empty());
|
| + SkASSERT(childSamplers->empty());
|
| + int firstCoordAt = fp.numTransforms();
|
| + int firstSamplerAt = fp.numTextures();
|
| + for (int i = fp.numChildProcessors() - 1; i >= childProcIndex; --i) {
|
| + firstCoordAt -= fp.childProcessor(i).numTransforms();
|
| + firstSamplerAt -= fp.childProcessor(i).numTextures();
|
| + }
|
| + if (!coords.empty())
|
| + childCoords->push_back_n(childProc.numTransforms(), &coords[firstCoordAt]);
|
| + if (!samplers.empty())
|
| + childSamplers->push_back_n(childProc.numTextures(), &samplers[firstSamplerAt]);
|
| +
|
| + fFsb->codeAppendf("vec4 %s;\n", childOutputColor->c_str());
|
| + fFsb->codeAppend("{\n");
|
| + fFsb->codeAppendf("// Child %d: %s\n", fFsb->getChildNumberThisLevel(), childProc.name());
|
| +}
|
| +
|
| +GrGLFragmentBuilder::AutoFragmentChildProcAdvance::~AutoFragmentChildProcAdvance() {
|
| + fFsb->codeAppend("}\n");
|
| + fFsb->onAfterChildProcEmitCode();
|
| +}
|
|
|