Make GrEffect::textureAccess non-virtual. Require subclasses to append their GrTAs.
Review URL: https://codereview.appspot.com/7062063

git-svn-id: http://skia.googlecode.com/svn/trunk@7129 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/effects/SkBlendImageFilter.cpp b/src/effects/SkBlendImageFilter.cpp
index 4e5e018..6dd5eab 100644
--- a/src/effects/SkBlendImageFilter.cpp
+++ b/src/effects/SkBlendImageFilter.cpp
@@ -153,8 +153,6 @@
     typedef GrGLBlendEffect GLEffect;
     static const char* Name() { return "Blend"; }
 
-    virtual const GrTextureAccess& textureAccess(int index) const SK_OVERRIDE;
-
 private:
     GrTextureAccess             fForegroundAccess;
     GrTextureAccess             fBackgroundAccess;
@@ -228,10 +226,11 @@
 GrBlendEffect::GrBlendEffect(SkBlendImageFilter::Mode mode,
                              GrTexture* foreground,
                              GrTexture* background)
-    : INHERITED(2)
-    , fForegroundAccess(foreground)
+    : fForegroundAccess(foreground)
     , fBackgroundAccess(background)
     , fMode(mode) {
+    this->addTextureAccess(&fForegroundAccess);
+    this->addTextureAccess(&fBackgroundAccess);
 }
 
 GrBlendEffect::~GrBlendEffect() {
@@ -246,11 +245,6 @@
     return GrTBackendEffectFactory<GrBlendEffect>::getInstance();
 }
 
-const GrTextureAccess& GrBlendEffect::textureAccess(int index) const {
-    SkASSERT(index >= 0 && index < 2);
-    return (0 == index) ? fForegroundAccess : fBackgroundAccess;
-}
-
 ///////////////////////////////////////////////////////////////////////////////
 
 GrGLBlendEffect::GrGLBlendEffect(const GrBackendEffectFactory& factory, const GrEffect& effect)
diff --git a/src/effects/SkColorMatrixFilter.cpp b/src/effects/SkColorMatrixFilter.cpp
index e460325..ed34f64 100644
--- a/src/effects/SkColorMatrixFilter.cpp
+++ b/src/effects/SkColorMatrixFilter.cpp
@@ -327,7 +327,7 @@
 public:
     static const char* Name() { return "Color Matrix"; }
 
-    ColorMatrixEffect(const SkColorMatrix& matrix) : GrEffect(0), fMatrix(matrix) {}
+    ColorMatrixEffect(const SkColorMatrix& matrix) : fMatrix(matrix) {}
 
     virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE {
         return GrTBackendEffectFactory<ColorMatrixEffect>::getInstance();
diff --git a/src/effects/SkTableColorFilter.cpp b/src/effects/SkTableColorFilter.cpp
index ff30636..eb59425 100644
--- a/src/effects/SkTableColorFilter.cpp
+++ b/src/effects/SkTableColorFilter.cpp
@@ -233,8 +233,6 @@
     virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE;
     virtual bool isEqual(const GrEffect&) const SK_OVERRIDE;
 
-    virtual const GrTextureAccess& textureAccess(int index) const SK_OVERRIDE;
-
     typedef GLColorTableEffect GLEffect;
 
 private:
@@ -324,8 +322,8 @@
 ///////////////////////////////////////////////////////////////////////////////
 
 ColorTableEffect::ColorTableEffect(GrTexture* texture)
-    : INHERITED(1)
-    , fTextureAccess(texture, "a") {
+    : fTextureAccess(texture, "a") {
+    this->addTextureAccess(&fTextureAccess);
 }
 
 ColorTableEffect::~ColorTableEffect() {
@@ -339,11 +337,6 @@
     return INHERITED::isEqual(sBase);
 }
 
-const GrTextureAccess& ColorTableEffect::textureAccess(int index) const {
-    GrAssert(0 == index);
-    return fTextureAccess;
-}
-
 ///////////////////////////////////////////////////////////////////////////////
 
 GR_DEFINE_EFFECT_TEST(ColorTableEffect);
diff --git a/src/effects/gradients/SkGradientShader.cpp b/src/effects/gradients/SkGradientShader.cpp
index 5b2a60e..8521bdb 100644
--- a/src/effects/gradients/SkGradientShader.cpp
+++ b/src/effects/gradients/SkGradientShader.cpp
@@ -742,8 +742,7 @@
 GrGradientEffect::GrGradientEffect(GrContext* ctx,
                                    const SkGradientShaderBase& shader,
                                    const SkMatrix& matrix,
-                                   SkShader::TileMode tileMode)
-    : INHERITED(1) {
+                                   SkShader::TileMode tileMode) {
     // TODO: check for simple cases where we don't need a texture:
     //GradientInfo info;
     //shader.asAGradient(&info);
@@ -783,6 +782,7 @@
         // the cache, but it'll still be ref'd until it's no longer being used.
         GrUnlockCachedBitmapTexture(texture);
     }
+    this->addTextureAccess(&fTextureAccess);
 }
 
 GrGradientEffect::~GrGradientEffect() {
@@ -791,11 +791,6 @@
     }
 }
 
-const GrTextureAccess& GrGradientEffect::textureAccess(int index) const {
-    GrAssert(0 == index);
-    return fTextureAccess;
-}
-
 int GrGradientEffect::RandomGradientParams(SkRandom* random,
                                            SkColor colors[],
                                            SkScalar** stops,
diff --git a/src/effects/gradients/SkGradientShaderPriv.h b/src/effects/gradients/SkGradientShaderPriv.h
index 1662188..552013e 100644
--- a/src/effects/gradients/SkGradientShaderPriv.h
+++ b/src/effects/gradients/SkGradientShaderPriv.h
@@ -233,8 +233,6 @@
 
     virtual ~GrGradientEffect();
 
-    virtual const GrTextureAccess& textureAccess(int index) const SK_OVERRIDE;
-
     bool useAtlas() const { return SkToBool(-1 != fRow); }
     SkScalar getYCoord() const { return fYCoord; };
     const SkMatrix& getMatrix() const { return fMatrix;}