GrCustomStage Renaming Part 5

Stuff found by searching for "stage".

R=robertphillips@google.com
Review URL: https://codereview.appspot.com/6772043

git-svn-id: http://skia.googlecode.com/svn/trunk@6089 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index e6d5b4c..858242b 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -1317,16 +1317,16 @@
         ast.set(this, desc, match);
         GrTexture* texture = ast.texture();
         if (texture) {
-            SkAutoTUnref<GrEffect> stage;
+            SkAutoTUnref<GrEffect> effect;
             if (unpremul) {
-                stage.reset(this->createPMToUPMEffect(src, swapRAndB));
+                effect.reset(this->createPMToUPMEffect(src, swapRAndB));
             }
             // If we failed to create a PM->UPM effect and have no other conversions to perform then
             // there is no longer any point to using the scratch.
-            if (NULL != stage || flipY || swapRAndB) {
-                if (NULL == stage) {
-                    stage.reset(GrConfigConversionEffect::Create(src, swapRAndB));
-                    GrAssert(NULL != stage);
+            if (NULL != effect || flipY || swapRAndB) {
+                if (NULL == effect) {
+                    effect.reset(GrConfigConversionEffect::Create(src, swapRAndB));
+                    GrAssert(NULL != effect);
                 } else {
                     unpremul = false; // we will handle the UPM conversion in the draw
                 }
@@ -1345,7 +1345,7 @@
                     matrix.setTranslate(SK_Scalar1 *left, SK_Scalar1 *top);
                 }
                 matrix.postIDiv(src->width(), src->height());
-                drawState->sampler(0)->setEffect(stage, matrix);
+                drawState->sampler(0)->setEffect(effect, matrix);
                 GrRect rect = GrRect::MakeWH(GrIntToScalar(width), GrIntToScalar(height));
                 fGpu->drawSimpleRect(rect, NULL);
                 // we want to read back from the scratch's origin
@@ -1490,7 +1490,7 @@
         return;
     }
 #endif
-    SkAutoTUnref<GrEffect> stage;
+    SkAutoTUnref<GrEffect> effect;
     bool swapRAndB = (fGpu->preferredReadPixelsConfig(config) == GrPixelConfigSwapRAndB(config));
 
     GrPixelConfig textureConfig;
@@ -1516,8 +1516,8 @@
         if (kRGBA_8888_GrPixelConfig != config && kBGRA_8888_GrPixelConfig != config) {
             return;
         }
-        stage.reset(this->createUPMToPMEffect(texture, swapRAndB));
-        if (NULL == stage) {
+        effect.reset(this->createUPMToPMEffect(texture, swapRAndB));
+        if (NULL == effect) {
             SkCanvas::Config8888 srcConfig8888, dstConfig8888;
             GR_DEBUGCODE(bool success = )
             grconfig_to_config8888(config, true, &srcConfig8888);
@@ -1534,9 +1534,9 @@
             rowBytes = 4 * width;
         }
     }
-    if (NULL == stage) {
-        stage.reset(GrConfigConversionEffect::Create(texture, swapRAndB));
-        GrAssert(NULL != stage);
+    if (NULL == effect) {
+        effect.reset(GrConfigConversionEffect::Create(texture, swapRAndB));
+        GrAssert(NULL != effect);
     }
 
     this->writeTexturePixels(texture,
@@ -1553,7 +1553,7 @@
     drawState->setRenderTarget(target);
 
     matrix.setIDiv(texture->width(), texture->height());
-    drawState->sampler(0)->setEffect(stage, matrix);
+    drawState->sampler(0)->setEffect(effect, matrix);
 
     fGpu->drawSimpleRect(GrRect::MakeWH(SkIntToScalar(width), SkIntToScalar(height)), NULL);
 }
diff --git a/src/gpu/GrDrawState.h b/src/gpu/GrDrawState.h
index 330ae66..54f2179 100644
--- a/src/gpu/GrDrawState.h
+++ b/src/gpu/GrDrawState.h
@@ -26,7 +26,7 @@
     SK_DECLARE_INST_COUNT(GrDrawState)
 
     /**
-     * Number of texture stages. Each stage takes as input a color and
+     * Number of effect stages. Each stage takes as input a color and
      * 2D texture coordinates. The color input to the first enabled stage is the
      * per-vertex color or the constant color (setColor/setAlpha) if there are
      * no per-vertex colors. For subsequent stages the input color is the output
@@ -190,8 +190,7 @@
      */
     void createTextureEffect(int stage, GrTexture* texture) {
         GrAssert(!this->getSampler(stage).getEffect());
-        this->sampler(stage)->setEffect(
-            SkNEW_ARGS(GrSingleTextureEffect, (texture)))->unref();
+        this->sampler(stage)->setEffect(SkNEW_ARGS(GrSingleTextureEffect, (texture)))->unref();
     }
     void createTextureEffect(int stage, GrTexture* texture, const GrMatrix& matrix) {
         GrAssert(!this->getSampler(stage).getEffect());
diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp
index d365a89..dbb04a6 100644
--- a/src/gpu/GrDrawTarget.cpp
+++ b/src/gpu/GrDrawTarget.cpp
@@ -748,10 +748,10 @@
     GrAssert(NULL != drawState.getRenderTarget());
     for (int s = 0; s < GrDrawState::kNumStages; ++s) {
         if (drawState.isStageEnabled(s)) {
-            const GrEffect* stage = drawState.getSampler(s).getEffect();
-            int numTextures = stage->numTextures();
+            const GrEffect* effect = drawState.getSampler(s).getEffect();
+            int numTextures = effect->numTextures();
             for (int t = 0; t < numTextures; ++t) {
-                GrTexture* texture = stage->texture(t);
+                GrTexture* texture = effect->texture(t);
                 GrAssert(texture->asRenderTarget() != drawState.getRenderTarget());
             }
         }
@@ -831,11 +831,11 @@
     // Check if a color stage could create a partial alpha
     for (int s = 0; s < drawState.getFirstCoverageStage(); ++s) {
         if (this->isStageEnabled(s)) {
-            const GrEffect* stage = drawState.getSampler(s).getEffect();
-            // FIXME: The param indicates whether the texture is opaque or not. However, the stage
+            const GrEffect* effect = drawState.getSampler(s).getEffect();
+            // FIXME: The param indicates whether the texture is opaque or not. However, the effect
             // already controls its textures. It really needs to know whether the incoming color
             // (from a uni, per-vertex colors, or previous stage) is opaque or not.
-            if (!stage->isOpaque(true)) {
+            if (!effect->isOpaque(true)) {
                 return false;
             }
         }
@@ -913,7 +913,7 @@
     }
 
     // check for coverage due to constant coverage, per-vertex coverage,
-    // edge aa or coverage texture stage
+    // edge aa or coverage stage
     bool hasCoverage = forceCoverage ||
                        0xffffffff != drawState.getCoverage() ||
                        (layout & kCoverage_VertexLayoutBit) ||
diff --git a/src/gpu/GrEffect.cpp b/src/gpu/GrEffect.cpp
index 352d43c..396f5d1 100644
--- a/src/gpu/GrEffect.cpp
+++ b/src/gpu/GrEffect.cpp
@@ -35,8 +35,7 @@
     }
 };
 
-int32_t GrProgramStageFactory::fCurrStageClassID =
-                                    GrProgramStageFactory::kIllegalStageClassID;
+int32_t GrProgramStageFactory::fCurrEffectClassID = GrProgramStageFactory::kIllegalEffectClassID;
 
 GrEffect::GrEffect(int numTextures)
     : fNumTextures(numTextures) {
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 5cdecdb..b7de9ad 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -512,9 +512,9 @@
             SkColor filtered = colorFilter->filterColor(skPaint.getColor());
             grPaint->setColor(SkColor2GrColor(filtered));
         } else {
-            SkAutoTUnref<GrEffect> stage(colorFilter->asNewEffect(dev->context()));
-            if (NULL != stage.get()) {
-                grPaint->colorSampler(kColorFilterTextureIdx)->setEffect(stage);
+            SkAutoTUnref<GrEffect> effect(colorFilter->asNewEffect(dev->context()));
+            if (NULL != effect.get()) {
+                grPaint->colorSampler(kColorFilterTextureIdx)->setEffect(effect);
             } else {
                 // TODO: rewrite this using asNewEffect()
                 SkColor color;
@@ -1415,7 +1415,7 @@
     }
 
     GrRect textureDomain = GrRect::MakeEmpty();
-    SkAutoTUnref<GrEffect> stage;
+    SkAutoTUnref<GrEffect> effect;
     if (needsTextureDomain) {
         // Use a constrained texture domain to avoid color bleeding
         GrScalar left, top, right, bottom;
@@ -1434,11 +1434,11 @@
             top = bottom = GrScalarHalf(paintRect.top() + paintRect.bottom());
         }
         textureDomain.setLTRB(left, top, right, bottom);
-        stage.reset(SkNEW_ARGS(GrTextureDomainEffect, (texture, textureDomain, params)));
+        effect.reset(SkNEW_ARGS(GrTextureDomainEffect, (texture, textureDomain, params)));
     } else {
-        stage.reset(SkNEW_ARGS(GrSingleTextureEffect, (texture, params)));
+        effect.reset(SkNEW_ARGS(GrSingleTextureEffect, (texture, params)));
     }
-    grPaint->colorSampler(kBitmapTextureIdx)->setEffect(stage);
+    grPaint->colorSampler(kBitmapTextureIdx)->setEffect(effect);
     fContext->drawRectToRect(*grPaint, dstRect, paintRect, &m);
 }
 
@@ -1475,18 +1475,18 @@
     desc.fWidth = SkScalarCeilToInt(rect.width());
     desc.fHeight = SkScalarCeilToInt(rect.height());
     desc.fConfig = kRGBA_8888_GrPixelConfig;
-    GrEffect* stage;
+    GrEffect* effect;
 
     if (filter->canFilterImageGPU()) {
         // Save the render target and set it to NULL, so we don't accidentally draw to it in the
         // filter.  Also set the clip wide open and the matrix to identity.
         GrContext::AutoWideOpenIdentityDraw awo(context, NULL);
         texture = filter->onFilterImageGPU(&proxy, texture, rect);
-    } else if (filter->asNewEffect(&stage, texture)) {
+    } else if (filter->asNewEffect(&effect, texture)) {
         GrAutoScratchTexture dst(context, desc);
-        apply_effect(context, texture, dst.texture(), rect, stage);
+        apply_effect(context, texture, dst.texture(), rect, effect);
         texture = dst.detach();
-        stage->unref();
+        effect->unref();
     }
     return texture;
 }
diff --git a/src/gpu/effects/GrConfigConversionEffect.cpp b/src/gpu/effects/GrConfigConversionEffect.cpp
index beb6107..7bc203b 100644
--- a/src/gpu/effects/GrConfigConversionEffect.cpp
+++ b/src/gpu/effects/GrConfigConversionEffect.cpp
@@ -12,9 +12,9 @@
 public:
     GrGLConfigConversionEffect(const GrProgramStageFactory& factory,
                                const GrEffect& s) : INHERITED (factory) {
-        const GrConfigConversionEffect& stage = static_cast<const GrConfigConversionEffect&>(s);
-        fSwapRedAndBlue = stage.swapsRedAndBlue();
-        fPMConversion = stage.pmConversion();
+        const GrConfigConversionEffect& effect = static_cast<const GrConfigConversionEffect&>(s);
+        fSwapRedAndBlue = effect.swapsRedAndBlue();
+        fPMConversion = effect.pmConversion();
     }
 
     virtual void emitVS(GrGLShaderBuilder* builder,
@@ -59,8 +59,8 @@
     }
 
     static inline StageKey GenKey(const GrEffect& s, const GrGLCaps&) {
-        const GrConfigConversionEffect& stage = static_cast<const GrConfigConversionEffect&>(s);
-        return static_cast<int>(stage.swapsRedAndBlue()) | (stage.pmConversion() << 1);
+        const GrConfigConversionEffect& effect = static_cast<const GrConfigConversionEffect&>(s);
+        return static_cast<int>(effect.swapsRedAndBlue()) | (effect.pmConversion() << 1);
     }
 
 private:
@@ -177,24 +177,24 @@
 
         GrPaint paint;
 
-        SkAutoTUnref<GrEffect> pmToUPMStage1(SkNEW_ARGS(GrConfigConversionEffect,
+        SkAutoTUnref<GrEffect> pmToUPMEffect1(SkNEW_ARGS(GrConfigConversionEffect,
                                                         (dataTex, false, *pmToUPMRule)));
-        SkAutoTUnref<GrEffect> upmToPMStage(SkNEW_ARGS(GrConfigConversionEffect,
+        SkAutoTUnref<GrEffect> upmToPMEffect(SkNEW_ARGS(GrConfigConversionEffect,
                                                        (readTex, false, *upmToPMRule)));
-        SkAutoTUnref<GrEffect> pmToUPMStage2(SkNEW_ARGS(GrConfigConversionEffect,
+        SkAutoTUnref<GrEffect> pmToUPMEffect2(SkNEW_ARGS(GrConfigConversionEffect,
                                                         (tempTex, false, *pmToUPMRule)));
 
         context->setRenderTarget(readTex->asRenderTarget());
-        paint.colorSampler(0)->setEffect(pmToUPMStage1);
+        paint.colorSampler(0)->setEffect(pmToUPMEffect1);
         context->drawRectToRect(paint, kDstRect, kSrcRect);
 
         readTex->readPixels(0, 0, 256, 256, kRGBA_8888_GrPixelConfig, firstRead);
 
         context->setRenderTarget(tempTex->asRenderTarget());
-        paint.colorSampler(0)->setEffect(upmToPMStage);
+        paint.colorSampler(0)->setEffect(upmToPMEffect);
         context->drawRectToRect(paint, kDstRect, kSrcRect);
         context->setRenderTarget(readTex->asRenderTarget());
-        paint.colorSampler(0)->setEffect(pmToUPMStage2);
+        paint.colorSampler(0)->setEffect(pmToUPMEffect2);
         context->drawRectToRect(paint, kDstRect, kSrcRect);
 
         readTex->readPixels(0, 0, 256, 256, kRGBA_8888_GrPixelConfig, secondRead);
diff --git a/src/gpu/effects/GrConvolutionEffect.cpp b/src/gpu/effects/GrConvolutionEffect.cpp
index 32086ca..e49302e 100644
--- a/src/gpu/effects/GrConvolutionEffect.cpp
+++ b/src/gpu/effects/GrConvolutionEffect.cpp
@@ -17,8 +17,7 @@
 
 class GrGLConvolutionEffect : public GrGLLegacyProgramStage {
 public:
-    GrGLConvolutionEffect(const GrProgramStageFactory& factory,
-                          const GrEffect& stage);
+    GrGLConvolutionEffect(const GrProgramStageFactory&, const GrEffect&);
 
     virtual void setupVariables(GrGLShaderBuilder* builder) SK_OVERRIDE;
     virtual void emitVS(GrGLShaderBuilder* builder,
@@ -43,12 +42,12 @@
 };
 
 GrGLConvolutionEffect::GrGLConvolutionEffect(const GrProgramStageFactory& factory,
-                                             const GrEffect& stage)
+                                             const GrEffect& effect)
     : INHERITED(factory)
     , fKernelUni(kInvalidUniformHandle)
     , fImageIncrementUni(kInvalidUniformHandle) {
     const GrConvolutionEffect& c =
-        static_cast<const GrConvolutionEffect&>(stage);
+        static_cast<const GrConvolutionEffect&>(effect);
     fRadius = c.radius();
 }
 
diff --git a/src/gpu/effects/GrSingleTextureEffect.cpp b/src/gpu/effects/GrSingleTextureEffect.cpp
index 7717f6a..47e26e5 100644
--- a/src/gpu/effects/GrSingleTextureEffect.cpp
+++ b/src/gpu/effects/GrSingleTextureEffect.cpp
@@ -14,8 +14,9 @@
 
 class GrGLSingleTextureEffect : public GrGLLegacyProgramStage {
 public:
-    GrGLSingleTextureEffect(const GrProgramStageFactory& factory,
-                            const GrEffect& stage) : INHERITED (factory) { }
+    GrGLSingleTextureEffect(const GrProgramStageFactory& factory, const GrEffect&)
+    : INHERITED (factory) {
+    }
 
     virtual void emitVS(GrGLShaderBuilder* builder,
                         const char* vertexCoords) SK_OVERRIDE { }
diff --git a/src/gpu/effects/GrTextureDomainEffect.cpp b/src/gpu/effects/GrTextureDomainEffect.cpp
index fb0bcff..1203392 100644
--- a/src/gpu/effects/GrTextureDomainEffect.cpp
+++ b/src/gpu/effects/GrTextureDomainEffect.cpp
@@ -11,8 +11,7 @@
 
 class GrGLTextureDomainEffect : public GrGLLegacyProgramStage {
 public:
-    GrGLTextureDomainEffect(const GrProgramStageFactory& factory,
-                            const GrEffect& stage);
+    GrGLTextureDomainEffect(const GrProgramStageFactory&, const GrEffect&);
 
     virtual void setupVariables(GrGLShaderBuilder* builder) SK_OVERRIDE;
     virtual void emitVS(GrGLShaderBuilder* builder,
@@ -33,7 +32,7 @@
 };
 
 GrGLTextureDomainEffect::GrGLTextureDomainEffect(const GrProgramStageFactory& factory,
-                                                 const GrEffect& stage)
+                                                 const GrEffect&)
     : INHERITED(factory)
     , fNameUni(GrGLUniformManager::kInvalidUniformHandle) {
 }
diff --git a/src/gpu/gl/GrGLProgram.cpp b/src/gpu/gl/GrGLProgram.cpp
index 5549e58..ae957e9 100644
--- a/src/gpu/gl/GrGLProgram.cpp
+++ b/src/gpu/gl/GrGLProgram.cpp
@@ -896,7 +896,7 @@
 // Stage code generation
 
 // TODO: Move this function to GrGLShaderBuilder
-GrGLProgramStage* GrGLProgram::GenStageCode(const GrEffect* stage,
+GrGLProgramStage* GrGLProgram::GenStageCode(const GrEffect* effect,
                                             const StageDesc& desc,
                                             StageUniforms* uniforms,
                                             const char* fsInColor, // NULL means no incoming color
@@ -904,7 +904,7 @@
                                             const char* vsInCoord,
                                             GrGLShaderBuilder* builder) {
 
-    GrGLProgramStage* glStage = stage->getFactory().createGLInstance(*stage);
+    GrGLProgramStage* glStage = effect->getFactory().createGLInstance(*effect);
 
     /// Vertex Shader Stuff
 
@@ -932,13 +932,13 @@
                         &varyingFSName);
     builder->setupTextureAccess(varyingFSName, texCoordVaryingType);
 
-    int numTextures = stage->numTextures();
+    int numTextures = effect->numTextures();
     SkSTArray<8, GrGLShaderBuilder::TextureSampler> textureSamplers;
 
     textureSamplers.push_back_n(numTextures);
 
     for (int i = 0; i < numTextures; ++i) {
-        textureSamplers[i].init(builder, &stage->textureAccess(i));
+        textureSamplers[i].init(builder, &effect->textureAccess(i));
         uniforms->fSamplerUniforms.push_back(textureSamplers[i].fSamplerUniform);
     }
 
@@ -956,7 +956,7 @@
     builder->fVSCode.appendf("\t{ // %s\n", glStage->name());
     builder->fFSCode.appendf("\t{ // %s \n", glStage->name());
     glStage->emitCode(builder,
-                      *stage,
+                      *effect,
                       desc.fCustomStageKey,
                       varyingVSName,
                       fsOutColor,
diff --git a/src/gpu/gl/GrGLProgram.h b/src/gpu/gl/GrGLProgram.h
index f6760a9..056b7ed 100644
--- a/src/gpu/gl/GrGLProgram.h
+++ b/src/gpu/gl/GrGLProgram.h
@@ -175,7 +175,7 @@
 
     void genInputColor(GrGLShaderBuilder* builder, SkString* inColor);
 
-    static GrGLProgramStage* GenStageCode(const GrEffect* stage,
+    static GrGLProgramStage* GenStageCode(const GrEffect* effect,
                                           const StageDesc& desc, // TODO: Eliminate this
                                           StageUniforms* stageUniforms, // TODO: Eliminate this
                                           const char* fsInColor, // NULL means no incoming color
diff --git a/src/gpu/gl/GrGLProgramStage.cpp b/src/gpu/gl/GrGLProgramStage.cpp
index 8cbb7c3..cc4cc91 100644
--- a/src/gpu/gl/GrGLProgramStage.cpp
+++ b/src/gpu/gl/GrGLProgramStage.cpp
@@ -20,11 +20,11 @@
 void GrGLProgramStage::setData(const GrGLUniformManager&, const GrEffect&) {
 }
 
-GrGLProgramStage::StageKey GrGLProgramStage::GenTextureKey(const GrEffect& stage,
+GrGLProgramStage::StageKey GrGLProgramStage::GenTextureKey(const GrEffect& effect,
                                                            const GrGLCaps& caps) {
     StageKey key = 0;
-    for (int index = 0; index < stage.numTextures(); ++index) {
-        const GrTextureAccess& access = stage.textureAccess(index);
+    for (int index = 0; index < effect.numTextures(); ++index) {
+        const GrTextureAccess& access = effect.textureAccess(index);
         StageKey value = GrGLShaderBuilder::KeyForTextureAccess(access, caps) << index;
         GrAssert(0 == (value & key)); // keys for each access ought not to overlap
         key |= value;
diff --git a/src/gpu/gl/GrGLProgramStage.h b/src/gpu/gl/GrGLProgramStage.h
index 300e6f1..190ea8a6 100644
--- a/src/gpu/gl/GrGLProgramStage.h
+++ b/src/gpu/gl/GrGLProgramStage.h
@@ -77,7 +77,7 @@
     /** A GrGLProgramStage instance can be reused with any GrEffect that produces the same stage
         key; this function reads data from a stage and uploads any uniform variables required
         by the shaders created in emitCode(). */
-    virtual void setData(const GrGLUniformManager&, const GrEffect& stage);
+    virtual void setData(const GrGLUniformManager&, const GrEffect&);
 
     const char* name() const { return fFactory.name(); }
 
diff --git a/src/gpu/gl/GrGpuGL_program.cpp b/src/gpu/gl/GrGpuGL_program.cpp
index 9f78aa4..5bc84f8 100644
--- a/src/gpu/gl/GrGpuGL_program.cpp
+++ b/src/gpu/gl/GrGpuGL_program.cpp
@@ -199,11 +199,11 @@
     const GrDrawState& drawState = this->getDrawState();
 
     // FIXME: Still assuming only a single texture per effect
-    const GrEffect* stage = drawState.getSampler(s).getEffect();
-    if (0 == stage->numTextures()) {
+    const GrEffect* effect = drawState.getSampler(s).getEffect();
+    if (0 == effect->numTextures()) {
         return;
     }
-    const GrGLTexture* texture = static_cast<const GrGLTexture*>(stage->texture(0));
+    const GrGLTexture* texture = static_cast<const GrGLTexture*>(effect->texture(0));
     if (NULL != texture) {
 
         bool orientationChange = fCurrentProgram->fTextureOrientation[s] !=