| Index: src/gpu/gl/builders/GrGLFragmentShaderBuilder.h
|
| diff --git a/src/gpu/gl/builders/GrGLFragmentShaderBuilder.h b/src/gpu/gl/builders/GrGLFragmentShaderBuilder.h
|
| index 2b3e18d763dcc946a784f714f7167a97e23ca308..8746fffb8b101f75cb3d637045b2fa736bfd6bfd 100644
|
| --- a/src/gpu/gl/builders/GrGLFragmentShaderBuilder.h
|
| +++ b/src/gpu/gl/builders/GrGLFragmentShaderBuilder.h
|
| @@ -17,7 +17,10 @@ class GrGLVarying;
|
| */
|
| class GrGLFragmentBuilder : public GrGLShaderBuilder {
|
| public:
|
| - GrGLFragmentBuilder(GrGLProgramBuilder* program) : INHERITED(program) {}
|
| + GrGLFragmentBuilder(GrGLProgramBuilder* program)
|
| + : INHERITED(program) {
|
| + fSubstageIndices.push_back(0);
|
| + }
|
| virtual ~GrGLFragmentBuilder() {}
|
| /**
|
| * Use of these features may require a GLSL extension to be enabled. Shaders may not compile
|
| @@ -47,7 +50,54 @@ public:
|
| is in device space (e.g. 0,0 is the top left and pixel centers are at half-integers). */
|
| virtual const char* fragmentPosition() = 0;
|
|
|
| + /**
|
| + * Fragment procs with child procs should call these functions before/after calling emitCode
|
| + * on a child proc.
|
| + */
|
| + void onBeforeChildProcEmitCode();
|
| + void onAfterChildProcEmitCode();
|
| +
|
| + int getChildNumberThisLevel() const {
|
| + if (fSubstageIndices.count() > 1) {
|
| + // second-to-last value in the fSubstageIndices stack is the index of the child proc
|
| + // at that level which is currently emitting code.
|
| + return fSubstageIndices[fSubstageIndices.count() - 2];
|
| + }
|
| + return -1;
|
| + }
|
| +
|
| + const SkString& getMangleString() const { return fMangleString; }
|
| +
|
| + SkString getMangleStringThisLevel() const {
|
| + SkString ret;
|
| + int childNumber = this->getChildNumberThisLevel();
|
| + if (childNumber >= 0) {
|
| + ret.printf("_c%d", childNumber);
|
| + }
|
| + return ret;
|
| + }
|
| +
|
| private:
|
| + /*
|
| + * State that tracks which child proc in the proc tree is currently emitting code. This is
|
| + * used to update the fMangleString, which is used to mangle the names of uniforms and functions
|
| + * emitted by the proc. fSubstageIndices is a stack: its count indicates how many levels deep
|
| + * we are in the tree, and its second-to-last value is the index of the child proc at that
|
| + * level which is currently emitting code. For example, if fSubstageIndices = [3, 1, 2, 0], that
|
| + * means we're currently emitting code for the base proc's 3rd child's 1st child's 2nd child.
|
| + */
|
| + SkTArray<int> fSubstageIndices;
|
| +
|
| + /*
|
| + * The mangle string is used to mangle the names of uniforms/functions emitted by the child
|
| + * procs so no duplicate uniforms/functions appear in the generated shader program. The mangle
|
| + * string is simply based on fSubstageIndices. For example, if fSubstageIndices = [3, 1, 2, 0],
|
| + * then the manglestring will be "_c3_c1_c2", and any uniform/function emitted by that proc will
|
| + * have "_c3_c1_c2" appended to its name, which can be interpreted as "base proc's 3rd child's
|
| + * 1st child's 2nd child".
|
| + */
|
| + SkString fMangleString;
|
| +
|
| friend class GrGLPathProcessor;
|
|
|
| typedef GrGLShaderBuilder INHERITED;
|
|
|