Index: src/gpu/glsl/GrGLSLFragmentProcessor.cpp |
diff --git a/src/gpu/glsl/GrGLSLFragmentProcessor.cpp b/src/gpu/glsl/GrGLSLFragmentProcessor.cpp |
index 25cc14abca3ff030e568475af0c5192c7520acf2..9a58db77bd6cd1430f58bd8f7097b00fbbe36e6a 100644 |
--- a/src/gpu/glsl/GrGLSLFragmentProcessor.cpp |
+++ b/src/gpu/glsl/GrGLSLFragmentProcessor.cpp |
@@ -43,16 +43,16 @@ |
const GrFragmentProcessor& childProc = args.fFp.childProcessor(childIndex); |
/* |
- * TODO: Move textures and buffers to the iterator model used by coords. |
- * We now want to find the subset of samplers that belong to the child and its descendants and |
- * put that into childSamplers. To do so, we'll do a forwards linear search. |
+ * We now want to find the subset of coords and samplers that belong to the child and its |
+ * descendants and put that into childCoords and childSamplers. To do so, we'll do a forwards |
+ * linear search. |
* |
* Explanation: |
- * Each GrFragmentProcessor has a copy of all the textures of itself and all procs in its |
- * subtree. For example, suppose we have frag proc A, who has two children B and D. B has a |
- * child C, and D has two children E and F. Each frag proc's textures array contains its own |
- * textures, followed by the textures of all its descendants (i.e. preorder traversal). Suppose |
- * procs A, B, C, D, E, F have 1, 2, 1, 1, 3, 2 textures respectively. |
+ * Each GrFragmentProcessor has a copy of all the transforms and textures of itself and |
+ * all procs in its subtree. For example, suppose we have frag proc A, who has two children B |
+ * and D. B has a child C, and D has two children E and F. Each frag proc's transforms array |
+ * contains its own transforms, followed by the transforms of all its descendants (i.e. preorder |
+ * traversal). Suppose procs A, B, C, D, E, F have 1, 2, 1, 1, 3, 2 transforms respectively. |
* |
* (A) |
* [a1,b1,b2,c1,d1,e1,e2,e3,f1,f2] |
@@ -66,22 +66,28 @@ |
* [c1] [e1,e2,e3] [f1,f2] |
* |
* So if we're inside proc A's emitCode, and A is about to call emitCode on proc D, we want the |
- * EmitArgs that's passed onto D to only contain its and its descendants' textures. The |
- * EmitArgs given to A would contain the textures [a1,b1,b2,c1,d1,e1,e2,e3,f1,f2], and we want |
+ * EmitArgs that's passed onto D to only contain its and its descendants' coords. The |
+ * EmitArgs given to A would contain the transforms [a1,b1,b2,c1,d1,e1,e2,e3,f1,f2], and we want |
* to extract the subset [d1,e1,e2,e3,f1,f2] to pass on to D. We can do this with a linear |
- * search since we know that A has 1 texture (using A.numTexturesExclChildren()), and B's |
- * subtree has 3 textures (using B.numTextures()), so we know the start of D's textures is |
- * 4 after the start of A's textures. |
- * Textures work the same way as textures. |
+ * search since we know that A has 1 transform (using A.numTransformsExclChildren()), and B's |
+ * subtree has 3 transforms (using B.numTransforms()), so we know the start of D's transforms is |
+ * 4 after the start of A's transforms. |
+ * Textures work the same way as transforms. |
*/ |
+ int firstCoordAt = args.fFp.numTransformsExclChildren(); |
int firstTextureAt = args.fFp.numTexturesExclChildren(); |
int firstBufferAt = args.fFp.numBuffersExclChildren(); |
for (int i = 0; i < childIndex; ++i) { |
+ firstCoordAt += args.fFp.childProcessor(i).numTransforms(); |
firstTextureAt += args.fFp.childProcessor(i).numTextures(); |
firstBufferAt += args.fFp.childProcessor(i).numBuffers(); |
} |
+ SkTArray<GrShaderVar> childCoords; |
const SamplerHandle* childTexSamplers = nullptr; |
const SamplerHandle* childBufferSamplers = nullptr; |
+ if (childProc.numTransforms() > 0) { |
+ childCoords.push_back_n(childProc.numTransforms(), &args.fTransformedCoords[firstCoordAt]); |
+ } |
if (childProc.numTextures() > 0) { |
childTexSamplers = &args.fTexSamplers[firstTextureAt]; |
} |
@@ -99,7 +105,7 @@ |
childProc, |
outputColor, |
inputColor, |
- args.fTransformedCoords.childTransforms(childIndex), |
+ childCoords, |
childTexSamplers, |
childBufferSamplers, |
args.fGpImplementsDistanceVector); |
@@ -108,19 +114,3 @@ |
fragBuilder->onAfterChildProcEmitCode(); |
} |
- |
-////////////////////////////////////////////////////////////////////////////// |
- |
-using TransformedCoordVars = GrGLSLFragmentProcessor::TransformedCoordVars; |
-TransformedCoordVars TransformedCoordVars::childTransforms(int childIdx) const { |
- const GrFragmentProcessor* child = &fFP->childProcessor(childIdx); |
- GrFragmentProcessor::Iter iter(fFP); |
- int numToSkip = 0; |
- while (true) { |
- const GrFragmentProcessor* fp = iter.next(); |
- if (fp == child) { |
- return TransformedCoordVars(child, fTransformedVars + numToSkip); |
- } |
- numToSkip += fp->numCoordTransforms(); |
- } |
-} |