Wrap all GrCustomStage textures in GrTextureAccess, remove StageDesc::fInConfigFlags

Review URL: https://codereview.appspot.com/6494114



git-svn-id: http://skia.googlecode.com/svn/trunk@5485 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/effects/GrColorTableEffect.cpp b/src/gpu/effects/GrColorTableEffect.cpp
index d662398..0edc00d 100644
--- a/src/gpu/effects/GrColorTableEffect.cpp
+++ b/src/gpu/effects/GrColorTableEffect.cpp
@@ -91,8 +91,7 @@
 ///////////////////////////////////////////////////////////////////////////////
 
 GrColorTableEffect::GrColorTableEffect(GrTexture* texture)
-    : INHERITED(texture)
-    , fTextureAccess(texture, SkString("a")) {
+    : fTextureAccess(texture, "a") {
 }
 
 GrColorTableEffect::~GrColorTableEffect() {
@@ -106,11 +105,9 @@
     return INHERITED::isEqual(sBase);
 }
 
-const GrTextureAccess* GrColorTableEffect::textureAccess(unsigned int index) const {
-    if (0 == index)
-        return &fTextureAccess;
-
-    return NULL;
+const GrTextureAccess& GrColorTableEffect::textureAccess(int index) const {
+    GrAssert(0 == index);
+    return fTextureAccess;
 }
 
 ///////////////////////////////////////////////////////////////////////////////
diff --git a/src/gpu/effects/GrColorTableEffect.h b/src/gpu/effects/GrColorTableEffect.h
index f79e586..fe762fd 100644
--- a/src/gpu/effects/GrColorTableEffect.h
+++ b/src/gpu/effects/GrColorTableEffect.h
@@ -18,8 +18,7 @@
  * counterpart to the SkTable_ColorFilter effect. A 256 * 4 (single-channel)
  * LUT is used to transform the input colors of the image.
  */
-class GrColorTableEffect : public GrSingleTextureEffect {
-
+class GrColorTableEffect : public GrCustomStage {
 public:
 
     GrColorTableEffect(GrTexture* texture);
@@ -29,7 +28,8 @@
     virtual const GrProgramStageFactory& getFactory() const SK_OVERRIDE;
     virtual bool isEqual(const GrCustomStage&) const SK_OVERRIDE;
 
-    virtual const GrTextureAccess* textureAccess(unsigned int index) const SK_OVERRIDE;
+    virtual int numTextures() const SK_OVERRIDE { return 1; }
+    virtual const GrTextureAccess& textureAccess(int index) const SK_OVERRIDE;
 
     typedef GrGLColorTableEffect GLProgramStage;
 
@@ -38,6 +38,6 @@
 
     GrTextureAccess fTextureAccess;
 
-    typedef GrSingleTextureEffect INHERITED;
+    typedef GrCustomStage INHERITED;
 };
 #endif
diff --git a/src/gpu/effects/GrSingleTextureEffect.cpp b/src/gpu/effects/GrSingleTextureEffect.cpp
index b2fe0cc..b2e9205 100644
--- a/src/gpu/effects/GrSingleTextureEffect.cpp
+++ b/src/gpu/effects/GrSingleTextureEffect.cpp
@@ -38,21 +38,19 @@
 ///////////////////////////////////////////////////////////////////////////////
 
 GrSingleTextureEffect::GrSingleTextureEffect(GrTexture* texture)
-    : fTexture (texture) {
-    SkSafeRef(fTexture);
+    : fTextureAccess(texture) {
 }
 
 GrSingleTextureEffect::~GrSingleTextureEffect() {
-    SkSafeUnref(fTexture);
 }
 
-unsigned int GrSingleTextureEffect::numTextures() const {
+int GrSingleTextureEffect::numTextures() const {
     return 1;
 }
 
-GrTexture* GrSingleTextureEffect::texture(unsigned int index) const {
+const GrTextureAccess& GrSingleTextureEffect::textureAccess(int index) const {
     GrAssert(0 == index);
-    return fTexture;
+    return fTextureAccess;
 }
 
 const GrProgramStageFactory& GrSingleTextureEffect::getFactory() const {
diff --git a/src/gpu/effects/GrSingleTextureEffect.h b/src/gpu/effects/GrSingleTextureEffect.h
index 211319c..2090196 100644
--- a/src/gpu/effects/GrSingleTextureEffect.h
+++ b/src/gpu/effects/GrSingleTextureEffect.h
@@ -21,8 +21,8 @@
     GrSingleTextureEffect(GrTexture* texture);
     virtual ~GrSingleTextureEffect();
 
-    virtual unsigned int numTextures() const SK_OVERRIDE;
-    virtual GrTexture* texture(unsigned int index) const SK_OVERRIDE;
+    virtual int numTextures() const SK_OVERRIDE;
+    virtual const GrTextureAccess& textureAccess(int index) const SK_OVERRIDE;
 
     static const char* Name() { return "Single Texture"; }
 
@@ -33,7 +33,7 @@
 private:
     GR_DECLARE_CUSTOM_STAGE_TEST;
 
-    GrTexture* fTexture;
+    GrTextureAccess fTextureAccess;
 
     typedef GrCustomStage INHERITED;
 };