Index: include/gpu/GrFragmentProcessor.h |
diff --git a/include/gpu/GrFragmentProcessor.h b/include/gpu/GrFragmentProcessor.h |
index a8baa53b4a0c0ec8d73c10be1b6500cf61198c30..8fc3ec1d4b3fe9aed42f228a37065dfa8c99ccdd 100644 |
--- a/include/gpu/GrFragmentProcessor.h |
+++ b/include/gpu/GrFragmentProcessor.h |
@@ -26,10 +26,6 @@ public: |
: INHERITED() |
, fUsesLocalCoords(false) {} |
- /** Implemented using GLFragmentProcessor::GenKey as described in this class's comment. */ |
- virtual void getGLProcessorKey(const GrGLSLCaps& caps, |
- GrProcessorKeyBuilder* b) const = 0; |
- |
/** Returns a new instance of the appropriate *GL* implementation class |
for the given GrFragmentProcessor; caller is responsible for deleting |
the object. */ |
@@ -39,8 +35,23 @@ public: |
in generated shader code. */ |
virtual const char* name() const = 0; |
+ void getGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const { |
+ this->onGetGLProcessorKey(caps, b); |
+ for (int i = 0; i < fChildProcessors.count(); ++i) { |
+ fChildProcessors[i]->getGLProcessorKey(caps, b); |
+ } |
+ } |
+ |
int numTransforms() const { return fCoordTransforms.count(); } |
+ int numTransformsIncludeChildProcs() const { |
+ int numTransforms = fCoordTransforms.count(); |
+ for (int i = 0; i < fChildProcessors.count(); ++i) { |
+ 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 +60,22 @@ 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) { |
+ numTextures += fChildProcessors[i]->numTexturesIncludeChildProcs(); |
+ } |
+ return numTextures; |
+ } |
+ |
/** Do any of the coordtransforms for this processor require local coords? */ |
bool usesLocalCoords() const { return fUsesLocalCoords; } |
@@ -98,11 +125,24 @@ 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; |
private: |
+ /** Implemented using GLFragmentProcessor::GenKey as described in this class's comment. */ |
+ virtual void onGetGLProcessorKey(const GrGLSLCaps& caps, |
+ GrProcessorKeyBuilder* b) const = 0; |
+ |
/** |
* Subclass implements this to support isEqual(). It will only be called if it is known that |
* the two processors are of the same subclass (i.e. they return the same object from |
@@ -115,6 +155,7 @@ private: |
SkSTArray<4, const GrCoordTransform*, true> fCoordTransforms; |
bool fUsesLocalCoords; |
+ SkTArray<GrFragmentProcessor*, false> fChildProcessors; |
typedef GrProcessor INHERITED; |
}; |