When getGLInstance is called on a frag proc, the resulting GrGLFragmentProcessor will be the root of a tree of GrGLFragmentProcessors that mirrors the GrFragmentProcessor's tree. This allows setData() to be called recursively (removing the responsibility from compose shader) and allows gl instances direct access to their children gl instances so they can emit their code.
BUG=skia:4182
Review URL: https://codereview.chromium.org/1287023009
diff --git a/src/effects/SkDisplacementMapEffect.cpp b/src/effects/SkDisplacementMapEffect.cpp
index c303301..f360fe1 100644
--- a/src/effects/SkDisplacementMapEffect.cpp
+++ b/src/effects/SkDisplacementMapEffect.cpp
@@ -310,9 +310,11 @@
static inline void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuilder*);
- void setData(const GrGLProgramDataManager&, const GrProcessor&) override;
const GrTextureDomain::GLDomain& glDomain() const { return fGLDomain; }
+protected:
+ void onSetData(const GrGLProgramDataManager&, const GrProcessor&) override;
+
private:
SkDisplacementMapEffect::ChannelSelectorType fXChannelSelector;
SkDisplacementMapEffect::ChannelSelectorType fYChannelSelector;
@@ -344,10 +346,6 @@
virtual ~GrDisplacementMapEffect();
- GrGLFragmentProcessor* createGLInstance() const override {
- return SkNEW_ARGS(GrGLDisplacementMapEffect, (*this));
- }
-
SkDisplacementMapEffect::ChannelSelectorType xChannelSelector() const
{ return fXChannelSelector; }
SkDisplacementMapEffect::ChannelSelectorType yChannelSelector() const
@@ -358,6 +356,10 @@
const GrTextureDomain& domain() const { return fDomain; }
private:
+ GrGLFragmentProcessor* onCreateGLInstance() const override {
+ return SkNEW_ARGS(GrGLDisplacementMapEffect, (*this));
+ }
+
virtual void onGetGLProcessorKey(const GrGLSLCaps& caps,
GrProcessorKeyBuilder* b) const override {
GrGLDisplacementMapEffect::GenKey(*this, caps, b);
@@ -621,7 +623,7 @@
fsBuilder->codeAppend(";\n");
}
-void GrGLDisplacementMapEffect::setData(const GrGLProgramDataManager& pdman,
+void GrGLDisplacementMapEffect::onSetData(const GrGLProgramDataManager& pdman,
const GrProcessor& proc) {
const GrDisplacementMapEffect& displacementMap = proc.cast<GrDisplacementMapEffect>();
GrTexture* colorTex = displacementMap.texture(1);