Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(296)

Unified Diff: src/gpu/glsl/GrGLSLFragmentProcessor.cpp

Issue 2339203002: Stop flattening GrCoordTransforms in parent GrFragmentProcessors. (Closed)
Patch Set: Fix issue of taking ref to a temporary Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/glsl/GrGLSLFragmentProcessor.h ('k') | src/gpu/glsl/GrGLSLGeometryProcessor.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/glsl/GrGLSLFragmentProcessor.cpp
diff --git a/src/gpu/glsl/GrGLSLFragmentProcessor.cpp b/src/gpu/glsl/GrGLSLFragmentProcessor.cpp
index 9a58db77bd6cd1430f58bd8f7097b00fbbe36e6a..82a07ca39d819a88292f9ae1710f6a779b0dd1df 100644
--- a/src/gpu/glsl/GrGLSLFragmentProcessor.cpp
+++ b/src/gpu/glsl/GrGLSLFragmentProcessor.cpp
@@ -43,16 +43,16 @@ void GrGLSLFragmentProcessor::internalEmitChild(int childIndex, const char* inpu
const GrFragmentProcessor& childProc = args.fFp.childProcessor(childIndex);
/*
- * 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.
+ * 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.
*
* Explanation:
- * 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.
+ * 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.
*
* (A)
* [a1,b1,b2,c1,d1,e1,e2,e3,f1,f2]
@@ -66,28 +66,22 @@ void GrGLSLFragmentProcessor::internalEmitChild(int childIndex, const char* inpu
* [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' coords. The
- * EmitArgs given to A would contain the transforms [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' textures. The
+ * EmitArgs given to A would contain the textures [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 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.
+ * 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.
*/
- 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,13 +93,14 @@ void GrGLSLFragmentProcessor::internalEmitChild(int childIndex, const char* inpu
fragBuilder->codeAppend("{\n");
fragBuilder->codeAppendf("// Child Index %d (mangle: %s): %s\n", childIndex,
fragBuilder->getMangleString().c_str(), childProc.name());
+ TransformedCoordVars coordVars = args.fTransformedCoords.childTransforms(childIndex);
EmitArgs childArgs(fragBuilder,
args.fUniformHandler,
args.fGLSLCaps,
childProc,
outputColor,
inputColor,
- childCoords,
+ coordVars,
childTexSamplers,
childBufferSamplers,
args.fGpImplementsDistanceVector);
@@ -114,3 +109,19 @@ void GrGLSLFragmentProcessor::internalEmitChild(int childIndex, const char* inpu
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();
+ }
+}
« no previous file with comments | « src/gpu/glsl/GrGLSLFragmentProcessor.h ('k') | src/gpu/glsl/GrGLSLGeometryProcessor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698