| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef GrGLFragmentShaderBuilder_DEFINED | 8 #ifndef GrGLFragmentShaderBuilder_DEFINED |
| 9 #define GrGLFragmentShaderBuilder_DEFINED | 9 #define GrGLFragmentShaderBuilder_DEFINED |
| 10 | 10 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 is in device space (e.g. 0,0 is the top left and pixel centers are at ha
lf-integers). */ | 50 is in device space (e.g. 0,0 is the top left and pixel centers are at ha
lf-integers). */ |
| 51 virtual const char* fragmentPosition() = 0; | 51 virtual const char* fragmentPosition() = 0; |
| 52 | 52 |
| 53 /** | 53 /** |
| 54 * Fragment procs with child procs should call these functions before/after
calling emitCode | 54 * Fragment procs with child procs should call these functions before/after
calling emitCode |
| 55 * on a child proc. | 55 * on a child proc. |
| 56 */ | 56 */ |
| 57 void onBeforeChildProcEmitCode(); | 57 void onBeforeChildProcEmitCode(); |
| 58 void onAfterChildProcEmitCode(); | 58 void onAfterChildProcEmitCode(); |
| 59 | 59 |
| 60 int getChildNumberThisLevel() const { | |
| 61 if (fSubstageIndices.count() > 1) { | |
| 62 // second-to-last value in the fSubstageIndices stack is the index o
f the child proc | |
| 63 // at that level which is currently emitting code. | |
| 64 return fSubstageIndices[fSubstageIndices.count() - 2]; | |
| 65 } | |
| 66 return -1; | |
| 67 } | |
| 68 | |
| 69 const SkString& getMangleString() const { return fMangleString; } | 60 const SkString& getMangleString() const { return fMangleString; } |
| 70 | 61 |
| 71 SkString getMangleStringThisLevel() const { | |
| 72 SkString ret; | |
| 73 int childNumber = this->getChildNumberThisLevel(); | |
| 74 if (childNumber >= 0) { | |
| 75 ret.printf("_c%d", childNumber); | |
| 76 } | |
| 77 return ret; | |
| 78 } | |
| 79 | |
| 80 private: | 62 private: |
| 81 /* | 63 /* |
| 82 * State that tracks which child proc in the proc tree is currently emitting
code. This is | 64 * State that tracks which child proc in the proc tree is currently emitting
code. This is |
| 83 * used to update the fMangleString, which is used to mangle the names of un
iforms and functions | 65 * used to update the fMangleString, which is used to mangle the names of un
iforms and functions |
| 84 * emitted by the proc. fSubstageIndices is a stack: its count indicates ho
w many levels deep | 66 * emitted by the proc. fSubstageIndices is a stack: its count indicates ho
w many levels deep |
| 85 * we are in the tree, and its second-to-last value is the index of the chil
d proc at that | 67 * we are in the tree, and its second-to-last value is the index of the chil
d proc at that |
| 86 * level which is currently emitting code. For example, if fSubstageIndices
= [3, 1, 2, 0], that | 68 * level which is currently emitting code. For example, if fSubstageIndices
= [3, 1, 2, 0], that |
| 87 * means we're currently emitting code for the base proc's 3rd child's 1st c
hild's 2nd child. | 69 * means we're currently emitting code for the base proc's 3rd child's 1st c
hild's 2nd child. |
| 88 */ | 70 */ |
| 89 SkTArray<int> fSubstageIndices; | 71 SkTArray<int> fSubstageIndices; |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 // the program creator | 194 // the program creator |
| 213 bool fHasReadDstColor; | 195 bool fHasReadDstColor; |
| 214 bool fHasReadFragmentPosition; | 196 bool fHasReadFragmentPosition; |
| 215 | 197 |
| 216 friend class GrGLProgramBuilder; | 198 friend class GrGLProgramBuilder; |
| 217 | 199 |
| 218 typedef GrGLXPFragmentBuilder INHERITED; | 200 typedef GrGLXPFragmentBuilder INHERITED; |
| 219 }; | 201 }; |
| 220 | 202 |
| 221 #endif | 203 #endif |
| OLD | NEW |