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

Unified Diff: include/gpu/GrFragmentProcessor.h

Issue 1266633003: Added registerChild; transforms, textures, glKey automatically handled. (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: Created 5 years, 5 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 | « no previous file | src/gpu/GrProcessor.cpp » ('j') | src/gpu/gl/builders/GrGLProgramBuilder.cpp » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/gpu/GrFragmentProcessor.h
diff --git a/include/gpu/GrFragmentProcessor.h b/include/gpu/GrFragmentProcessor.h
index a8baa53b4a0c0ec8d73c10be1b6500cf61198c30..fb3b5c2f69ebe461ca8bf73d515db7fc7c1073a1 100644
--- a/include/gpu/GrFragmentProcessor.h
+++ b/include/gpu/GrFragmentProcessor.h
@@ -39,8 +39,22 @@ public:
in generated shader code. */
virtual const char* name() const = 0;
+ void getGLProcessorKeyIncludeChildProcs(const GrGLSLCaps& caps,
+ GrProcessorKeyBuilder* b) const {
+ this->getGLProcessorKey(caps, b);
+ for (int i = 0; i < fChildProcessors.count(); ++i)
joshualitt 2015/08/03 14:06:02 We put braces around single line for loops.
wangyix 2015/08/03 16:12:47 Done.
+ fChildProcessors[i]->getGLProcessorKeyIncludeChildProcs(caps, b);
+ }
+
int numTransforms() const { return fCoordTransforms.count(); }
+ int numTransformsIncludeChildProcs() const {
+ int numTransforms = fCoordTransforms.count();
+ for (int i = 0; i < fChildProcessors.count(); ++i)
joshualitt 2015/08/03 14:06:02 same
wangyix 2015/08/03 16:12:47 Done.
+ numTransforms += fChildProcessors[i]->numTransformsIncludeChildProcs();
+ return numTransforms;
+ }
+
/** Returns the coordinate transformation at index. index must be valid according to
numTransforms(). */
const GrCoordTransform& coordTransform(int index) const { return *fCoordTransforms[index]; }
@@ -49,6 +63,21 @@ public:
return fCoordTransforms;
}
+ int numChildProcessors() const { return fChildProcessors.count(); }
+
+ GrFragmentProcessor* childProcessor(int index) const { return fChildProcessors[index]; }
+
+ const SkTArray<GrFragmentProcessor*, false>& childProcessors() const {
+ return fChildProcessors;
+ }
+
+ int numTexturesIncludeChildProcs() const {
+ int numTextures = this->numTextures();
+ for (int i = 0; i < fChildProcessors.count(); ++i)
joshualitt 2015/08/03 14:06:02 same
wangyix 2015/08/03 16:12:47 Done.
+ numTextures += fChildProcessors[i]->numTexturesIncludeChildProcs();
+ return numTextures;
+ }
+
/** Do any of the coordtransforms for this processor require local coords? */
bool usesLocalCoords() const { return fUsesLocalCoords; }
@@ -98,6 +127,15 @@ protected:
void addCoordTransform(const GrCoordTransform*);
/**
+ * FragmentProcessor subclasses call this to register any child FragmentProcessors they have.
+ * This is for processors whose shader code will be composed of nested processors whose output
+ * colors will be combined somehow to produce its output color. Registering these child
+ * processors will allow the ProgramBuilder to automatically add their transformed coords and
+ * texture accesses and mangle their uniform and output color names and
+ */
+ void registerChildProcessor(GrFragmentProcessor* child);
+
+ /**
* Subclass implements this to support getConstantColorComponents(...).
*/
virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const = 0;
@@ -115,7 +153,8 @@ private:
SkSTArray<4, const GrCoordTransform*, true> fCoordTransforms;
bool fUsesLocalCoords;
-
+ SkTArray<GrFragmentProcessor*, false> fChildProcessors;
+
joshualitt 2015/08/03 14:06:02 delete tab
wangyix 2015/08/03 16:12:47 Done.
typedef GrProcessor INHERITED;
};
« no previous file with comments | « no previous file | src/gpu/GrProcessor.cpp » ('j') | src/gpu/gl/builders/GrGLProgramBuilder.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698