Make numTextures() be non-virtual on GrCustomStage.

R=tomhudson@google.com,robertphillips@google.com,senorblanco@chromium.org
Review URL: https://codereview.appspot.com/6586081

git-svn-id: http://skia.googlecode.com/svn/trunk@5805 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/effects/gradients/SkGradientShader.cpp b/src/effects/gradients/SkGradientShader.cpp
index 9a965ff..cc7e13c 100644
--- a/src/effects/gradients/SkGradientShader.cpp
+++ b/src/effects/gradients/SkGradientShader.cpp
@@ -719,7 +719,7 @@
 GrGradientEffect::GrGradientEffect(GrContext* ctx,
                                    const SkGradientShaderBase& shader,
                                    SkShader::TileMode tileMode)
-    : fUseTexture (true) {
+    : INHERITED(1) {
     // TODO: check for simple cases where we don't need a texture:
     //GradientInfo info;
     //shader.asAGradient(&info);
@@ -765,12 +765,8 @@
     }
 }
 
-int GrGradientEffect::numTextures() const {
-    return fUseTexture ? 1 : 0;
-}
-
 const GrTextureAccess& GrGradientEffect::textureAccess(int index) const {
-    GrAssert(fUseTexture && 0 == index);
+    GrAssert(0 == index);
     return fTextureAccess;
 }
 
diff --git a/src/effects/gradients/SkGradientShaderPriv.h b/src/effects/gradients/SkGradientShaderPriv.h
index bdea900..61b9c35 100644
--- a/src/effects/gradients/SkGradientShaderPriv.h
+++ b/src/effects/gradients/SkGradientShaderPriv.h
@@ -232,12 +232,10 @@
 
     virtual ~GrGradientEffect();
 
-    virtual int numTextures() const SK_OVERRIDE;
     virtual const GrTextureAccess& textureAccess(int index) const SK_OVERRIDE;
 
-    bool useTexture() const { return fUseTexture; }
     bool useAtlas() const { return SkToBool(-1 != fRow); }
-    GrScalar getYCoord() const { GrAssert(fUseTexture); return fYCoord; };
+    GrScalar getYCoord() const { return fYCoord; };
 
     virtual bool isEqual(const GrCustomStage& stage) const SK_OVERRIDE {
         const GrGradientEffect& s = static_cast<const GrGradientEffect&>(stage);
@@ -262,7 +260,6 @@
 
 private:
     GrTextureAccess fTextureAccess;
-    bool fUseTexture;
     GrScalar fYCoord;
     GrTextureStripAtlas* fAtlas;
     int fRow;
diff --git a/src/gpu/GrCustomStage.cpp b/src/gpu/GrCustomStage.cpp
index b9ad4ea..0000278 100644
--- a/src/gpu/GrCustomStage.cpp
+++ b/src/gpu/GrCustomStage.cpp
@@ -38,8 +38,8 @@
 int32_t GrProgramStageFactory::fCurrStageClassID =
                                     GrProgramStageFactory::kIllegalStageClassID;
 
-GrCustomStage::GrCustomStage() {
-
+GrCustomStage::GrCustomStage(int numTextures)
+    : fNumTextures(numTextures) {
 }
 
 GrCustomStage::~GrCustomStage() {
@@ -62,10 +62,6 @@
     return true;
 }
 
-int GrCustomStage::numTextures() const {
-    return 0;
-}
-
 const GrTextureAccess& GrCustomStage::textureAccess(int index) const {
     GrCrash("We shouldn't be calling this function on the base class.");
     static GrTextureAccess kDummy;
diff --git a/src/gpu/effects/GrColorTableEffect.cpp b/src/gpu/effects/GrColorTableEffect.cpp
index 0edc00d..165cd60 100644
--- a/src/gpu/effects/GrColorTableEffect.cpp
+++ b/src/gpu/effects/GrColorTableEffect.cpp
@@ -91,7 +91,8 @@
 ///////////////////////////////////////////////////////////////////////////////
 
 GrColorTableEffect::GrColorTableEffect(GrTexture* texture)
-    : fTextureAccess(texture, "a") {
+    : INHERITED(1)
+    , fTextureAccess(texture, "a") {
 }
 
 GrColorTableEffect::~GrColorTableEffect() {
diff --git a/src/gpu/effects/GrColorTableEffect.h b/src/gpu/effects/GrColorTableEffect.h
index fe762fd..c064600 100644
--- a/src/gpu/effects/GrColorTableEffect.h
+++ b/src/gpu/effects/GrColorTableEffect.h
@@ -21,14 +21,13 @@
 class GrColorTableEffect : public GrCustomStage {
 public:
 
-    GrColorTableEffect(GrTexture* texture);
+    explicit GrColorTableEffect(GrTexture* texture);
     virtual ~GrColorTableEffect();
 
     static const char* Name() { return "ColorTable"; }
     virtual const GrProgramStageFactory& getFactory() const SK_OVERRIDE;
     virtual bool isEqual(const GrCustomStage&) const SK_OVERRIDE;
 
-    virtual int numTextures() const SK_OVERRIDE { return 1; }
     virtual const GrTextureAccess& textureAccess(int index) const SK_OVERRIDE;
 
     typedef GrGLColorTableEffect GLProgramStage;
diff --git a/src/gpu/effects/GrSingleTextureEffect.cpp b/src/gpu/effects/GrSingleTextureEffect.cpp
index e96eb47..f6f7b8c 100644
--- a/src/gpu/effects/GrSingleTextureEffect.cpp
+++ b/src/gpu/effects/GrSingleTextureEffect.cpp
@@ -38,24 +38,23 @@
 ///////////////////////////////////////////////////////////////////////////////
 
 GrSingleTextureEffect::GrSingleTextureEffect(GrTexture* texture)
-    : fTextureAccess(texture) {
+    : INHERITED(1)
+    , fTextureAccess(texture) {
 }
 
 GrSingleTextureEffect::GrSingleTextureEffect(GrTexture* texture, bool bilerp)
-    : fTextureAccess(texture, bilerp) {
+    : INHERITED(1)
+    , fTextureAccess(texture, bilerp) {
 }
 
 GrSingleTextureEffect::GrSingleTextureEffect(GrTexture* texture, const GrTextureParams& params)
-    : fTextureAccess(texture, params) {
+    : INHERITED(1)
+    , fTextureAccess(texture, params) {
 }
 
 GrSingleTextureEffect::~GrSingleTextureEffect() {
 }
 
-int GrSingleTextureEffect::numTextures() const {
-    return 1;
-}
-
 const GrTextureAccess& GrSingleTextureEffect::textureAccess(int index) const {
     GrAssert(0 == index);
     return fTextureAccess;
diff --git a/src/gpu/effects/GrSingleTextureEffect.h b/src/gpu/effects/GrSingleTextureEffect.h
index 4d0a40f..ad47eb7 100644
--- a/src/gpu/effects/GrSingleTextureEffect.h
+++ b/src/gpu/effects/GrSingleTextureEffect.h
@@ -28,7 +28,6 @@
 
     virtual ~GrSingleTextureEffect();
 
-    virtual int numTextures() const SK_OVERRIDE;
     virtual const GrTextureAccess& textureAccess(int index) const SK_OVERRIDE;
 
     static const char* Name() { return "Single Texture"; }