Chromium Code Reviews| 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..a058e9f7cc5d766a6eba59c3ded712e3f33ac67c 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,40 @@ 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) |
|
joshualitt
2015/08/12 17:14:53
Braces
wangyix
2015/08/12 18:00:33
Done.
|
| + return fSubstageIndices[fSubstageIndices.count() - 2]; |
|
joshualitt
2015/08/12 17:14:53
Could you put a comment here for the '- 2'?
ie, th
wangyix
2015/08/12 18:00:33
Done.
|
| + return -1; |
| + } |
| + |
| + const SkString& getMangleString() const { return fMangleString; } |
| + |
| + SkString getMangleStringThisLevel() const { |
| + SkString ret; |
| + int childNumber = getChildNumberThisLevel(); |
|
joshualitt
2015/08/12 17:14:53
this->
wangyix
2015/08/12 18:00:33
Done.
|
| + if (childNumber >= 0) |
|
joshualitt
2015/08/12 17:14:53
braces
wangyix
2015/08/12 18:00:33
Done.
|
| + 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 manglestring, 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. |
| + */ |
| + SkTArray<int> fSubstageIndices; |
| + SkString fMangleString; |
|
joshualitt
2015/08/12 17:14:53
Please put an explanation of the what the mangle s
wangyix
2015/08/12 18:00:33
Done.
|
| + |
| friend class GrGLPathProcessor; |
| typedef GrGLShaderBuilder INHERITED; |