Chromium Code Reviews| 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..899f6216ce05027251fe5ed9497ef79e7af6cf2d 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()) |
|
joshualitt
2015/08/13 18:33:53
braces
wangyix
2015/08/14 13:46:16
Done.
|
| + childCoords->push_back_n(childProc.numTransforms(), &coords[firstCoordAt]); |
| + if (!samplers.empty()) |
|
joshualitt
2015/08/13 18:33:53
braces
wangyix
2015/08/14 13:46:16
Done.
|
| + 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(); |
| +} |