Rename GrSamplerState to GrEffectStage.
authorbsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Fri, 26 Oct 2012 13:01:20 +0000 (13:01 +0000)
committerbsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Fri, 26 Oct 2012 13:01:20 +0000 (13:01 +0000)
R=robertphillips@google.com
Review URL: https://codereview.appspot.com/6777053

git-svn-id: http://skia.googlecode.com/svn/trunk@6135 2bbb7eff-a529-9590-31e7-b0007b416f81

39 files changed:
gm/texdata.cpp
gyp/gpu.gypi
include/core/SkShader.h
include/gpu/GrEffectStage.h [new file with mode: 0644]
include/gpu/GrPaint.h
include/gpu/GrSamplerState.h [deleted file]
src/core/SkShader.cpp
src/effects/SkBlendImageFilter.cpp
src/effects/SkMagnifierImageFilter.cpp
src/effects/SkMorphologyImageFilter.cpp
src/effects/gradients/SkGradientShaderPriv.h
src/effects/gradients/SkLinearGradient.cpp
src/effects/gradients/SkLinearGradient.h
src/effects/gradients/SkRadialGradient.cpp
src/effects/gradients/SkRadialGradient.h
src/effects/gradients/SkSweepGradient.cpp
src/effects/gradients/SkSweepGradient.h
src/effects/gradients/SkTwoPointConicalGradient.cpp
src/effects/gradients/SkTwoPointConicalGradient.h
src/effects/gradients/SkTwoPointRadialGradient.cpp
src/effects/gradients/SkTwoPointRadialGradient.h
src/gpu/GrClipMaskManager.cpp
src/gpu/GrContext.cpp
src/gpu/GrDrawState.cpp
src/gpu/GrDrawState.h
src/gpu/GrDrawTarget.cpp
src/gpu/GrDrawTarget.h
src/gpu/GrInOrderDrawBuffer.cpp
src/gpu/GrSWMaskHelper.cpp
src/gpu/GrTextContext.cpp
src/gpu/SkGpuDevice.cpp
src/gpu/effects/GrConfigConversionEffect.cpp
src/gpu/gl/GrGLProgram.cpp
src/gpu/gl/GrGLShaderBuilder.cpp
src/gpu/gl/GrGLShaderBuilder.h
src/gpu/gl/GrGpuGL.cpp
src/gpu/gl/GrGpuGL.h
src/gpu/gl/GrGpuGL_program.cpp
tests/GLProgramsTest.cpp

index bbc5efa1eb6b798fa8de527bac3f05b4a561f83b..cc3476d1f69b354831944d602e25f2862ffcf442 100644 (file)
@@ -113,8 +113,8 @@ protected:
                 GrMatrix tm;
                 tm = vm;
                 tm.postIDiv(2*S, 2*S);
-                paint.colorSampler(0)->setEffect(SkNEW_ARGS(GrSingleTextureEffect,
-                                                            (texture)), tm)->unref();
+                paint.colorStage(0)->setEffect(SkNEW_ARGS(GrSingleTextureEffect,
+                                                          (texture)), tm)->unref();
 
                 ctx->drawRect(paint, GrRect::MakeWH(2*S, 2*S));
 
index 5733c469cf1ce854ec604dee0fdf1a47fd5e97b9..8650f3cd3fcd457539eb0a9be00fbca79cdcf2b5 100644 (file)
@@ -17,6 +17,7 @@
       '<(skia_include_path)/gpu/GrContext.h',
       '<(skia_include_path)/gpu/GrContextFactory.h',
       '<(skia_include_path)/gpu/GrEffect.h',
+      '<(skia_include_path)/gpu/GrEffectStage.h',
       '<(skia_include_path)/gpu/GrEffectUnitTest.h',
       '<(skia_include_path)/gpu/GrFontScaler.h',
       '<(skia_include_path)/gpu/GrGlyph.h',
@@ -30,7 +31,6 @@
       '<(skia_include_path)/gpu/GrRefCnt.h',
       '<(skia_include_path)/gpu/GrRenderTarget.h',
       '<(skia_include_path)/gpu/GrResource.h',
-      '<(skia_include_path)/gpu/GrSamplerState.h',
       '<(skia_include_path)/gpu/GrScalar.h',
       '<(skia_include_path)/gpu/GrSurface.h',
       '<(skia_include_path)/gpu/GrTextContext.h',
index 7329c1bf4c829cee085e13324bb1aae3bc5e6ed5..90d831710cc58dcfa1e253c25f9621848ddd98d0 100644 (file)
@@ -19,7 +19,7 @@
 class SkPath;
 class GrContext;
 class GrEffect;
-class GrSamplerState;
+class GrEffectStage;
 
 /** \class SkShader
  *
@@ -306,13 +306,12 @@ public:
     virtual GradientType asAGradient(GradientInfo* info) const;
 
     /**
-     *  If the shader subclass has a GrEffect implementation, this installs
-     *  an effect on the sampler. A GrContext pointer is required since custom
-     *  stages may need to create textures. The sampler parameter is necessary to set a
-     *  texture matrix. It will eventually be removed and this function will operate as a
-     *  GrEffect factory.
+     *  If the shader subclass has a GrEffect implementation, this installs an effect on the stage.
+     *  A GrContext pointer is required since effects may need to create textures. The stage
+     *  parameter is necessary to set a texture matrix. It will eventually be removed and this
+     *  function will operate as a GrEffect factory.
      */
-    virtual bool asNewEffect(GrContext* context, GrSamplerState* sampler) const;
+    virtual bool asNewEffect(GrContext* context, GrEffectStage* stage) const;
 
     //////////////////////////////////////////////////////////////////////////
     //  Factory methods for stock shaders
diff --git a/include/gpu/GrEffectStage.h b/include/gpu/GrEffectStage.h
new file mode 100644 (file)
index 0000000..6f8b23f
--- /dev/null
@@ -0,0 +1,147 @@
+
+/*
+ * Copyright 2010 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+
+
+#ifndef GrSamplerState_DEFINED
+#define GrSamplerState_DEFINED
+
+#include "GrEffect.h"
+#include "GrMatrix.h"
+#include "GrTypes.h"
+
+#include "SkShader.h"
+
+class GrEffectStage {
+public:
+
+    GrEffectStage()
+    : fEffect (NULL) {
+        GR_DEBUGCODE(fSavedCoordChangeCnt = 0;)
+    }
+
+    ~GrEffectStage() {
+        GrSafeUnref(fEffect);
+        GrAssert(0 == fSavedCoordChangeCnt);
+    }
+
+    bool operator ==(const GrEffectStage& other) const {
+        // first handle cases where one or the other has no effect
+        if (NULL == fEffect) {
+            return NULL == other.fEffect;
+        } else if (NULL == other.fEffect) {
+            return false;
+        }
+
+        if (fEffect->getFactory() != other.fEffect->getFactory()) {
+            return false;
+        }
+
+        if (!fEffect->isEqual(*other.fEffect)) {
+            return false;
+        }
+
+        return fMatrix == other.fMatrix && fCoordChangeMatrix == other.fCoordChangeMatrix;
+    }
+
+    bool operator !=(const GrEffectStage& s) const { return !(*this == s); }
+
+    GrEffectStage& operator =(const GrEffectStage& other) {
+        GrSafeAssign(fEffect, other.fEffect);
+        if (NULL != fEffect) {
+            fMatrix = other.fMatrix;
+            fCoordChangeMatrix = other.fCoordChangeMatrix;
+        }
+        return *this;
+    }
+
+    /**
+     * This is called when the coordinate system in which the geometry is specified will change.
+     *
+     * @param matrix    The transformation from the old coord system to the new one.
+     */
+    void preConcatCoordChange(const GrMatrix& matrix) { fCoordChangeMatrix.preConcat(matrix); }
+
+    class SavedCoordChange {
+    private:
+        GrMatrix fCoordChangeMatrix;
+        GR_DEBUGCODE(mutable SkAutoTUnref<GrEffect> fEffect;)
+
+        friend class GrEffectStage;
+    };
+
+    /**
+     * This gets the current coordinate system change. It is the accumulation of
+     * preConcatCoordChange calls since the effect was installed. It is used when then caller
+     * wants to temporarily change the source geometry coord system, draw something, and then
+     * restore the previous coord system (e.g. temporarily draw in device coords).s
+     */
+    void saveCoordChange(SavedCoordChange* savedCoordChange) const {
+        savedCoordChange->fCoordChangeMatrix = fCoordChangeMatrix;
+        GrAssert(NULL == savedCoordChange->fEffect.get());
+        GR_DEBUGCODE(GrSafeRef(fEffect);)
+        GR_DEBUGCODE(savedCoordChange->fEffect.reset(fEffect);)
+        GR_DEBUGCODE(++fSavedCoordChangeCnt);
+    }
+
+    /**
+     * This balances the saveCoordChange call.
+     */
+    void restoreCoordChange(const SavedCoordChange& savedCoordChange) {
+        fCoordChangeMatrix = savedCoordChange.fCoordChangeMatrix;
+        GrAssert(savedCoordChange.fEffect.get() == fEffect);
+        GR_DEBUGCODE(--fSavedCoordChangeCnt);
+        GR_DEBUGCODE(savedCoordChange.fEffect.reset(NULL);)
+    }
+
+    /**
+     * Gets the texture matrix. This is will be removed soon and be managed by GrEffect.
+     */
+    const GrMatrix& getMatrix() const { return fMatrix; }
+
+    /**
+     * Gets the matrix to apply at draw time. This is the original texture matrix combined with
+     * any coord system changes.
+     */
+    void getTotalMatrix(GrMatrix* matrix) const {
+        *matrix = fMatrix;
+        matrix->preConcat(fCoordChangeMatrix);
+    }
+
+    void reset() {
+        GrSafeSetNull(fEffect);
+    }
+
+    GrEffect* setEffect(GrEffect* effect) {
+        GrAssert(0 == fSavedCoordChangeCnt);
+        GrSafeAssign(fEffect, effect);
+        fMatrix.reset();
+        fCoordChangeMatrix.reset();
+        return effect;
+    }
+
+    GrEffect* setEffect(GrEffect* effect, const GrMatrix& matrix) {
+        GrAssert(0 == fSavedCoordChangeCnt);
+        GrSafeAssign(fEffect, effect);
+        fMatrix = matrix;
+        fCoordChangeMatrix.reset();
+        return effect;
+    }
+
+    const GrEffect* getEffect() const { return fEffect; }
+
+private:
+    GrMatrix            fCoordChangeMatrix;
+    GrMatrix            fMatrix; // TODO: remove this, store in GrEffect
+    GrEffect*           fEffect;
+
+    GR_DEBUGCODE(mutable int fSavedCoordChangeCnt;)
+};
+
+#endif
+
index 4b2d3cda0d4d2c9139da9dd3f9cd601573cbdd1b..efafd7f1ab740579e3e16d26987cbee2d440c788 100644 (file)
@@ -11,7 +11,7 @@
 #define GrPaint_DEFINED
 
 #include "GrColor.h"
-#include "GrSamplerState.h"
+#include "GrEffectStage.h"
 
 #include "SkXfermode.h"
 
@@ -113,40 +113,40 @@ public:
     /**
      * Specifies a stage of the color pipeline. Usually the texture matrices of color stages apply
      * to the primitive's positions. Some GrContext calls take explicit coords as an array or a
-     * rect. In this case these are the pre-matrix coords to colorSampler(0).
+     * rect. In this case these are the pre-matrix coords to colorStage(0).
      */
-    GrSamplerState* colorSampler(int i) {
+    GrEffectStage* colorStage(int i) {
         GrAssert((unsigned)i < kMaxColorStages);
-        return fColorSamplers + i;
+        return fColorStages + i;
     }
 
-    const GrSamplerState& getColorSampler(int i) const {
+    const GrEffectStage& getColorStage(int i) const {
         GrAssert((unsigned)i < kMaxColorStages);
-        return fColorSamplers[i];
+        return fColorStages[i];
     }
 
     bool isColorStageEnabled(int i) const {
         GrAssert((unsigned)i < kMaxColorStages);
-        return (NULL != fColorSamplers[i].getEffect());
+        return (NULL != fColorStages[i].getEffect());
     }
 
     /**
      * Specifies a stage of the coverage pipeline. Coverage stages' texture matrices are always
      * applied to the primitive's position, never to explicit texture coords.
      */
-    GrSamplerState* coverageSampler(int i) {
+    GrEffectStage* coverageStage(int i) {
         GrAssert((unsigned)i < kMaxCoverageStages);
-        return fCoverageSamplers + i;
+        return fCoverageStages + i;
     }
 
-    const GrSamplerState& getCoverageSampler(int i) const {
+    const GrEffectStage& getCoverageStage(int i) const {
         GrAssert((unsigned)i < kMaxCoverageStages);
-        return fCoverageSamplers[i];
+        return fCoverageStages[i];
     }
 
     bool isCoverageStageEnabled(int i) const {
         GrAssert((unsigned)i < kMaxCoverageStages);
-        return (NULL != fCoverageSamplers[i].getEffect());
+        return (NULL != fCoverageStages[i].getEffect());
     }
 
     bool hasCoverageStage() const {
@@ -184,7 +184,7 @@ public:
                 } else {
                     computed = true;
                 }
-                fColorSamplers[i].preConcatCoordChange(inv);
+                fColorStages[i].preConcatCoordChange(inv);
             }
         }
         for (int i = 0; i < kMaxCoverageStages; ++i) {
@@ -194,7 +194,7 @@ public:
                 } else {
                     computed = true;
                 }
-                fCoverageSamplers[i].preConcatCoordChange(inv);
+                fCoverageStages[i].preConcatCoordChange(inv);
             }
         }
         return true;
@@ -207,12 +207,12 @@ public:
     void sourceCoordChange(const GrMatrix& preConcat) {
         for (int i = 0; i < kMaxColorStages; ++i) {
             if (this->isColorStageEnabled(i)) {
-                fColorSamplers[i].preConcatCoordChange(preConcat);
+                fColorStages[i].preConcatCoordChange(preConcat);
             }
         }
         for (int i = 0; i < kMaxCoverageStages; ++i) {
             if (this->isCoverageStageEnabled(i)) {
-                fCoverageSamplers[i].preConcatCoordChange(preConcat);
+                fCoverageStages[i].preConcatCoordChange(preConcat);
             }
         }
     }
@@ -231,12 +231,12 @@ public:
 
         for (int i = 0; i < kMaxColorStages; ++i) {
             if (paint.isColorStageEnabled(i)) {
-                fColorSamplers[i] = paint.fColorSamplers[i];
+                fColorStages[i] = paint.fColorStages[i];
             }
         }
         for (int i = 0; i < kMaxCoverageStages; ++i) {
             if (paint.isCoverageStageEnabled(i)) {
-                fCoverageSamplers[i] = paint.fCoverageSamplers[i];
+                fCoverageStages[i] = paint.fCoverageStages[i];
             }
         }
         return *this;
@@ -250,9 +250,8 @@ public:
         this->resetOptions();
         this->resetColor();
         this->resetCoverage();
-        this->resetTextures();
+        this->resetStages();
         this->resetColorFilter();
-        this->resetMasks();
     }
 
     // internal use
@@ -266,8 +265,8 @@ public:
 
 private:
 
-    GrSamplerState              fColorSamplers[kMaxColorStages];
-    GrSamplerState              fCoverageSamplers[kMaxCoverageStages];
+    GrEffectStage               fColorStages[kMaxColorStages];
+    GrEffectStage               fCoverageStages[kMaxCoverageStages];
 
     GrBlendCoeff                fSrcBlendCoeff;
     GrBlendCoeff                fDstBlendCoeff;
@@ -298,15 +297,12 @@ private:
         fCoverage = 0xff;
     }
 
-    void resetTextures() {
+    void resetStages() {
         for (int i = 0; i < kMaxColorStages; ++i) {
-            fColorSamplers[i].reset();
+            fColorStages[i].reset();
         }
-    }
-
-    void resetMasks() {
         for (int i = 0; i < kMaxCoverageStages; ++i) {
-            fCoverageSamplers[i].reset();
+            fCoverageStages[i].reset();
         }
     }
 };
diff --git a/include/gpu/GrSamplerState.h b/include/gpu/GrSamplerState.h
deleted file mode 100644 (file)
index a70b383..0000000
+++ /dev/null
@@ -1,147 +0,0 @@
-
-/*
- * Copyright 2010 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-
-
-#ifndef GrSamplerState_DEFINED
-#define GrSamplerState_DEFINED
-
-#include "GrEffect.h"
-#include "GrMatrix.h"
-#include "GrTypes.h"
-
-#include "SkShader.h"
-
-class GrSamplerState {
-public:
-
-    GrSamplerState()
-    : fEffect (NULL) {
-        GR_DEBUGCODE(fSavedCoordChangeCnt = 0;)
-    }
-
-    ~GrSamplerState() {
-        GrSafeUnref(fEffect);
-        GrAssert(0 == fSavedCoordChangeCnt);
-    }
-
-    bool operator ==(const GrSamplerState& other) const {
-        // first handle cases where one or the other has no effect
-        if (NULL == fEffect) {
-            return NULL == other.fEffect;
-        } else if (NULL == other.fEffect) {
-            return false;
-        }
-
-        if (fEffect->getFactory() != other.fEffect->getFactory()) {
-            return false;
-        }
-
-        if (!fEffect->isEqual(*other.fEffect)) {
-            return false;
-        }
-
-        return fMatrix == other.fMatrix && fCoordChangeMatrix == other.fCoordChangeMatrix;
-    }
-
-    bool operator !=(const GrSamplerState& s) const { return !(*this == s); }
-
-    GrSamplerState& operator =(const GrSamplerState& other) {
-        GrSafeAssign(fEffect, other.fEffect);
-        if (NULL != fEffect) {
-            fMatrix = other.fMatrix;
-            fCoordChangeMatrix = other.fCoordChangeMatrix;
-        }
-        return *this;
-    }
-
-    /**
-     * This is called when the coordinate system in which the geometry is specified will change.
-     *
-     * @param matrix    The transformation from the old coord system to the new one.
-     */
-    void preConcatCoordChange(const GrMatrix& matrix) { fCoordChangeMatrix.preConcat(matrix); }
-
-    class SavedCoordChange {
-    private:
-        GrMatrix fCoordChangeMatrix;
-        GR_DEBUGCODE(mutable SkAutoTUnref<GrEffect> fEffect;)
-
-        friend class GrSamplerState;
-    };
-
-    /**
-     * This gets the current coordinate system change. It is the accumulation of
-     * preConcatCoordChange calls since the effect was installed. It is used when then caller
-     * wants to temporarily change the source geometry coord system, draw something, and then
-     * restore the previous coord system (e.g. temporarily draw in device coords).s
-     */
-    void saveCoordChange(SavedCoordChange* savedCoordChange) const {
-        savedCoordChange->fCoordChangeMatrix = fCoordChangeMatrix;
-        GrAssert(NULL == savedCoordChange->fEffect.get());
-        GR_DEBUGCODE(GrSafeRef(fEffect);)
-        GR_DEBUGCODE(savedCoordChange->fEffect.reset(fEffect);)
-        GR_DEBUGCODE(++fSavedCoordChangeCnt);
-    }
-
-    /**
-     * This balances the saveCoordChange call.
-     */
-    void restoreCoordChange(const SavedCoordChange& savedCoordChange) {
-        fCoordChangeMatrix = savedCoordChange.fCoordChangeMatrix;
-        GrAssert(savedCoordChange.fEffect.get() == fEffect);
-        GR_DEBUGCODE(--fSavedCoordChangeCnt);
-        GR_DEBUGCODE(savedCoordChange.fEffect.reset(NULL);)
-    }
-
-    /**
-     * Gets the texture matrix. This is will be removed soon and be managed by GrEffect.
-     */
-    const GrMatrix& getMatrix() const { return fMatrix; }
-
-    /**
-     * Gets the matrix to apply at draw time. This is the original texture matrix combined with
-     * any coord system changes.
-     */
-    void getTotalMatrix(GrMatrix* matrix) const {
-        *matrix = fMatrix;
-        matrix->preConcat(fCoordChangeMatrix);
-    }
-
-    void reset() {
-        GrSafeSetNull(fEffect);
-    }
-
-    GrEffect* setEffect(GrEffect* effect) {
-        GrAssert(0 == fSavedCoordChangeCnt);
-        GrSafeAssign(fEffect, effect);
-        fMatrix.reset();
-        fCoordChangeMatrix.reset();
-        return effect;
-    }
-
-    GrEffect* setEffect(GrEffect* effect, const GrMatrix& matrix) {
-        GrAssert(0 == fSavedCoordChangeCnt);
-        GrSafeAssign(fEffect, effect);
-        fMatrix = matrix;
-        fCoordChangeMatrix.reset();
-        return effect;
-    }
-
-    const GrEffect* getEffect() const { return fEffect; }
-
-private:
-    GrMatrix            fCoordChangeMatrix;
-    GrMatrix            fMatrix; // TODO: remove this, store in GrEffect
-    GrEffect*           fEffect;
-
-    GR_DEBUGCODE(mutable int fSavedCoordChangeCnt;)
-};
-
-#endif
-
index 50546ffcc3ba24d4a21843993d3c1cf773184734..9c9366b93aa1ed1cec6c82033074a1737cd0f143 100644 (file)
@@ -205,7 +205,7 @@ SkShader::GradientType SkShader::asAGradient(GradientInfo* info) const {
     return kNone_GradientType;
 }
 
-bool SkShader::asNewEffect(GrContext*, GrSamplerState*) const {
+bool SkShader::asNewEffect(GrContext*, GrEffectStage*) const {
     return false;
 }
 
index c87c5d35bd2df591c6ed5823cc2bd714159d5a17..fdbf0705607e464f66801aa096c43bb554f1931e 100644 (file)
@@ -207,9 +207,9 @@ GrTexture* SkBlendImageFilter::onFilterImageGPU(Proxy* proxy, GrTexture* src, co
     backgroundTexMatrix.setIDiv(background->width(), background->height());
     foregroundTexMatrix.setIDiv(foreground->width(), foreground->height());
     GrPaint paint;
-    paint.colorSampler(0)->setEffect(
+    paint.colorStage(0)->setEffect(
         SkNEW_ARGS(GrSingleTextureEffect, (background.get())), backgroundTexMatrix)->unref();
-    paint.colorSampler(1)->setEffect(
+    paint.colorStage(1)->setEffect(
         SkNEW_ARGS(GrBlendEffect, (fMode, foreground.get())), foregroundTexMatrix)->unref();
     context->drawRect(paint, rect);
     return dst;
index 3b306c17d5a6c0379dcb6921464835ba721cae6d..ea64e530e3ad315fa0e2f64f3129d4a147486443 100644 (file)
@@ -200,7 +200,6 @@ GrEffect* GrMagnifierEffect::TestCreate(SkRandom* random,
                 SkRect::MakeXYWH(SkIntToScalar(x), SkIntToScalar(y),
                                  SkIntToScalar(width), SkIntToScalar(height)),
                 inset));
-    GrSamplerState sampler;
     GrEffect* effect;
     filter->asNewEffect(&effect, textures[0]);
     GrAssert(NULL != effect);
index 1d243b9d36f6c80073cf541c46dcab2b448be858..3273798b9d263485f2348399c1c58bc81335f551 100644 (file)
@@ -425,7 +425,7 @@ void apply_morphology_pass(GrContext* context,
     GrMatrix sampleM;
     sampleM.setIDiv(texture->width(), texture->height());
     GrPaint paint;
-    paint.colorSampler(0)->setEffect(SkNEW_ARGS(GrMorphologyEffect, (texture, direction, radius, morphType)), sampleM)->unref();
+    paint.colorStage(0)->setEffect(SkNEW_ARGS(GrMorphologyEffect, (texture, direction, radius, morphType)), sampleM)->unref();
     context->drawRect(paint, rect);
 }
 
index 6bb0a60e1c97cce945d636b6e8db82e50295c6dc..194ff8c6d895f4c252a4579de92c6b8a7c242433 100644 (file)
@@ -194,7 +194,7 @@ private:
 
 #include "gl/GrGLEffect.h"
 
-class GrSamplerState;
+class GrEffectStage;
 class GrBackendEffectFactory;
 
 /*
index 71003cfd2045264e216e235379f086da32a5d973..61824a042e41dd2462af04e5a9449d2d64d3083b 100644 (file)
@@ -538,12 +538,12 @@ GrEffect* GrLinearGradient::TestCreate(SkRandom* random,
     SkAutoTUnref<SkShader> shader(SkGradientShader::CreateLinear(points,
                                                                  colors, stops, colorCount,
                                                                  tm));
-    GrSamplerState sampler;
-    shader->asNewEffect(context, &sampler);
-    GrAssert(NULL != sampler.getEffect());
+    GrEffectStage stage;
+    shader->asNewEffect(context, &stage);
+    GrAssert(NULL != stage.getEffect());
     // const_cast and ref is a hack! Will remove when asNewEffect returns GrEffect*
-    sampler.getEffect()->ref();
-    return const_cast<GrEffect*>(sampler.getEffect());
+    stage.getEffect()->ref();
+    return const_cast<GrEffect*>(stage.getEffect());
 }
 
 /////////////////////////////////////////////////////////////////////
@@ -559,8 +559,8 @@ void GrGLLinearGradient::emitFS(GrGLShaderBuilder* builder,
 
 /////////////////////////////////////////////////////////////////////
 
-bool SkLinearGradient::asNewEffect(GrContext* context, GrSamplerState* sampler) const {
-    SkASSERT(NULL != context && NULL != sampler);
+bool SkLinearGradient::asNewEffect(GrContext* context, GrEffectStage* stage) const {
+    SkASSERT(NULL != context && NULL != stage);
 
     SkAutoTUnref<GrEffect> effect(SkNEW_ARGS(GrLinearGradient, (context, *this, fTileMode)));
 
@@ -570,9 +570,9 @@ bool SkLinearGradient::asNewEffect(GrContext* context, GrSamplerState* sampler)
             return false;
         }
         matrix.postConcat(fPtsToUnit);
-        sampler->setEffect(effect, matrix);
+        stage->setEffect(effect, matrix);
     } else {
-        sampler->setEffect(effect, fPtsToUnit);
+        stage->setEffect(effect, fPtsToUnit);
     }
 
     return true;
@@ -580,7 +580,7 @@ bool SkLinearGradient::asNewEffect(GrContext* context, GrSamplerState* sampler)
 
 #else
 
-bool SkLinearGradient::asNewEffect(GrContext*, GrSamplerState*) const {
+bool SkLinearGradient::asNewEffect(GrContext*, GrEffectStage*) const {
     SkDEBUGFAIL("Should not call in GPU-less build");
     return false;
 }
index e0e75b4b6cd67461c705e6444e5c24a4c4e94733..7d879266b1dd7ce21d7bf2059f4cfaa219928482 100644 (file)
@@ -22,7 +22,7 @@ public:
     virtual void shadeSpan16(int x, int y, uint16_t dstC[], int count) SK_OVERRIDE;
     virtual BitmapType asABitmap(SkBitmap*, SkMatrix*, TileMode*) const SK_OVERRIDE;
     virtual GradientType asAGradient(GradientInfo* info) const SK_OVERRIDE;
-    virtual bool asNewEffect(GrContext* context, GrSamplerState* sampler) const SK_OVERRIDE;
+    virtual bool asNewEffect(GrContext* context, GrEffectStage* stage) const SK_OVERRIDE;
 
     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLinearGradient)
 
index fa36fccbd69bba81f6557b8a14b2d105ceb5cded..6b9a678df713650231328a058803e1c5ce9507cd 100644 (file)
@@ -537,12 +537,12 @@ GrEffect* GrRadialGradient::TestCreate(SkRandom* random,
     SkAutoTUnref<SkShader> shader(SkGradientShader::CreateRadial(center, radius,
                                                                  colors, stops, colorCount,
                                                                  tm));
-    GrSamplerState sampler;
-    shader->asNewEffect(context, &sampler);
-    GrAssert(NULL != sampler.getEffect());
+    GrEffectStage stage;
+    shader->asNewEffect(context, &stage);
+    GrAssert(NULL != stage.getEffect());
     // const_cast and ref is a hack! Will remove when asNewEffect returns GrEffect*
-    sampler.getEffect()->ref();
-    return const_cast<GrEffect*>(sampler.getEffect());
+    stage.getEffect()->ref();
+    return const_cast<GrEffect*>(stage.getEffect());
 }
 
 /////////////////////////////////////////////////////////////////////
@@ -558,8 +558,8 @@ void GrGLRadialGradient::emitFS(GrGLShaderBuilder* builder,
 
 /////////////////////////////////////////////////////////////////////
 
-bool SkRadialGradient::asNewEffect(GrContext* context, GrSamplerState* sampler) const {
-    SkASSERT(NULL != context && NULL != sampler);
+bool SkRadialGradient::asNewEffect(GrContext* context, GrEffectStage* stage) const {
+    SkASSERT(NULL != context && NULL != stage);
     SkAutoTUnref<GrEffect> effect(SkNEW_ARGS(GrRadialGradient, (context, *this, fTileMode)));
 
     SkMatrix matrix;
@@ -568,9 +568,9 @@ bool SkRadialGradient::asNewEffect(GrContext* context, GrSamplerState* sampler)
             return false;
         }
         matrix.postConcat(fPtsToUnit);
-        sampler->setEffect(effect, matrix);
+        stage->setEffect(effect, matrix);
     } else {
-        sampler->setEffect(effect, fPtsToUnit);
+        stage->setEffect(effect, fPtsToUnit);
     }
 
     return true;
@@ -578,7 +578,7 @@ bool SkRadialGradient::asNewEffect(GrContext* context, GrSamplerState* sampler)
 
 #else
 
-bool SkRadialGradient::asNewEffect(GrContext*, GrSamplerState*) const {
+bool SkRadialGradient::asNewEffect(GrContext*, GrEffectStage*) const {
     SkDEBUGFAIL("Should not call in GPU-less build");
     return false;
 }
index 9384793d2790cf1b9aa771629e73b705b9aba3c0..cf0d43d3b9bb4f69c9110fccca40fb96397331a2 100644 (file)
@@ -24,7 +24,7 @@ public:
                                  SkMatrix* matrix,
                                  TileMode* xy) const SK_OVERRIDE;
     virtual GradientType asAGradient(GradientInfo* info) const SK_OVERRIDE;
-    virtual bool asNewEffect(GrContext* context, GrSamplerState* sampler) const SK_OVERRIDE;
+    virtual bool asNewEffect(GrContext* context, GrEffectStage* stage) const SK_OVERRIDE;
 
     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkRadialGradient)
 
index 190da5973cb175e2e3af1477293ea6e7ef59dea4..c606bbaca6ecc0f147cc7233d58b5835ec7fdfe2 100644 (file)
@@ -443,12 +443,12 @@ GrEffect* GrSweepGradient::TestCreate(SkRandom* random,
     int colorCount = RandomGradientParams(random, colors, &stops, &tmIgnored);
     SkAutoTUnref<SkShader> shader(SkGradientShader::CreateSweep(center.fX, center.fY,
                                                                 colors, stops, colorCount));
-    GrSamplerState sampler;
-    shader->asNewEffect(context, &sampler);
-    GrAssert(NULL != sampler.getEffect());
+    GrEffectStage stage;
+    shader->asNewEffect(context, &stage);
+    GrAssert(NULL != stage.getEffect());
     // const_cast and ref is a hack! Will remove when asNewEffect returns GrEffect*
-    sampler.getEffect()->ref();
-    return const_cast<GrEffect*>(sampler.getEffect());
+    stage.getEffect()->ref();
+    return const_cast<GrEffect*>(stage.getEffect());
 }
 
 /////////////////////////////////////////////////////////////////////
@@ -465,7 +465,7 @@ void GrGLSweepGradient::emitFS(GrGLShaderBuilder* builder,
 
 /////////////////////////////////////////////////////////////////////
 
-bool SkSweepGradient::asNewEffect(GrContext* context, GrSamplerState* sampler) const {
+bool SkSweepGradient::asNewEffect(GrContext* context, GrEffectStage* stage) const {
     SkAutoTUnref<GrEffect> effect(SkNEW_ARGS(GrSweepGradient, (context, *this)));
 
     SkMatrix matrix;
@@ -474,9 +474,9 @@ bool SkSweepGradient::asNewEffect(GrContext* context, GrSamplerState* sampler) c
             return false;
         }
         matrix.postConcat(fPtsToUnit);
-        sampler->setEffect(effect, matrix);
+        stage->setEffect(effect, matrix);
     } else {
-        sampler->setEffect(effect, fPtsToUnit);
+        stage->setEffect(effect, fPtsToUnit);
     }
 
     return true;
@@ -484,7 +484,7 @@ bool SkSweepGradient::asNewEffect(GrContext* context, GrSamplerState* sampler) c
 
 #else
 
-bool SkSweepGradient::asNewEffect(GrContext*, GrSamplerState*) const {
+bool SkSweepGradient::asNewEffect(GrContext*, GrEffectStage*) const {
     SkDEBUGFAIL("Should not call in GPU-less build");
     return false;
 }
index c685cd924e8dfcfb8a69dfb9d4edb0a786f52dec..a44b4c15f16a0aa7ae4708e95e23fe1bf14a6319 100644 (file)
@@ -24,7 +24,7 @@ public:
 
     virtual GradientType asAGradient(GradientInfo* info) const SK_OVERRIDE;
 
-    virtual bool asNewEffect(GrContext* context, GrSamplerState* sampler) const SK_OVERRIDE;
+    virtual bool asNewEffect(GrContext* context, GrEffectStage* stage) const SK_OVERRIDE;
 
     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkSweepGradient)
 
index 84ad0874512cd6d6984779386d3871c7408c32b0..3c4560c909b7646ded29d3394167423d372693e1 100644 (file)
@@ -437,12 +437,12 @@ GrEffect* GrConical2Gradient::TestCreate(SkRandom* random,
                                                                           center2, radius2,
                                                                           colors, stops, colorCount,
                                                                           tm));
-    GrSamplerState sampler;
-    shader->asNewEffect(context, &sampler);
-    GrAssert(NULL != sampler.getEffect());
+    GrEffectStage stage;
+    shader->asNewEffect(context, &stage);
+    GrAssert(NULL != stage.getEffect());
     // const_cast and ref is a hack! Will remove when asNewEffect returns GrEffect*
-    sampler.getEffect()->ref();
-    return const_cast<GrEffect*>(sampler.getEffect());
+    stage.getEffect()->ref();
+    return const_cast<GrEffect*>(stage.getEffect());
 }
 
 
@@ -670,8 +670,8 @@ GrEffect::EffectKey GrGLConical2Gradient::GenKey(const GrEffect& s, const GrGLCa
 /////////////////////////////////////////////////////////////////////
 
 bool SkTwoPointConicalGradient::asNewEffect(GrContext* context,
-                                            GrSamplerState* sampler) const {
-    SkASSERT(NULL != context && NULL != sampler);
+                                            GrEffectStage* stage) const {
+    SkASSERT(NULL != context && NULL != stage);
 
     SkMatrix matrix;
     SkPoint diff = fCenter2 - fCenter1;
@@ -693,14 +693,14 @@ bool SkTwoPointConicalGradient::asNewEffect(GrContext* context,
         matrix.preConcat(localM);
     }
 
-    sampler->setEffect(SkNEW_ARGS(GrConical2Gradient, (context, *this, fTileMode)), matrix)->unref();
+    stage->setEffect(SkNEW_ARGS(GrConical2Gradient, (context, *this, fTileMode)), matrix)->unref();
 
     return true;
 }
 
 #else
 
-bool SkTwoPointConicalGradient::asNewEffect(GrContext*, GrSamplerState*) const {
+bool SkTwoPointConicalGradient::asNewEffect(GrContext*, GrEffectStage*) const {
     SkDEBUGFAIL("Should not call in GPU-less build");
     return false;
 }
index 398735ddb1806067a5eb680955d7d890f8ff7318..d199650414c6c7db08fb493897643ad2de0f3fe9 100644 (file)
@@ -61,7 +61,7 @@ public:
                                  SkMatrix* matrix,
                                  TileMode* xy) const;
     virtual SkShader::GradientType asAGradient(GradientInfo* info) const  SK_OVERRIDE;
-    virtual bool asNewEffect(GrContext* context, GrSamplerState* sampler) const SK_OVERRIDE;
+    virtual bool asNewEffect(GrContext* context, GrEffectStage* stage) const SK_OVERRIDE;
 
     SkScalar getCenterX1() const { return SkPoint::Distance(fCenter1, fCenter2); }
     SkScalar getStartRadius() const { return fRadius1; }
index 9d2245c9d467cf977ad35f1f52c8ff0b5b680eda..b37b568ad736ace98062d9db36ad74ffcd8cf8d6 100644 (file)
@@ -471,12 +471,12 @@ GrEffect* GrRadial2Gradient::TestCreate(SkRandom* random,
                                                                          center2, radius2,
                                                                          colors, stops, colorCount,
                                                                          tm));
-    GrSamplerState sampler;
-    shader->asNewEffect(context, &sampler);
-    GrAssert(NULL != sampler.getEffect());
+    GrEffectStage stage;
+    shader->asNewEffect(context, &stage);
+    GrAssert(NULL != stage.getEffect());
     // const_cast and ref is a hack! Will remove when asNewEffect returns GrEffect*
-    sampler.getEffect()->ref();
-    return const_cast<GrEffect*>(sampler.getEffect());
+    stage.getEffect()->ref();
+    return const_cast<GrEffect*>(stage.getEffect());
 }
 
 /////////////////////////////////////////////////////////////////////
@@ -643,8 +643,8 @@ GrEffect::EffectKey GrGLRadial2Gradient::GenKey(const GrEffect& s, const GrGLCap
 /////////////////////////////////////////////////////////////////////
 
 bool SkTwoPointRadialGradient::asNewEffect(GrContext* context,
-                                           GrSamplerState* sampler) const {
-    SkASSERT(NULL != context && NULL != sampler);
+                                           GrEffectStage* stage) const {
+    SkASSERT(NULL != context && NULL != stage);
     SkScalar diffLen = fDiff.length();
     SkMatrix matrix;
     if (0 != diffLen) {
@@ -665,13 +665,13 @@ bool SkTwoPointRadialGradient::asNewEffect(GrContext* context,
         matrix.preConcat(localM);
     }
 
-    sampler->setEffect(SkNEW_ARGS(GrRadial2Gradient, (context, *this, fTileMode)), matrix)->unref();
+    stage->setEffect(SkNEW_ARGS(GrRadial2Gradient, (context, *this, fTileMode)), matrix)->unref();
     return true;
 }
 
 #else
 
-bool SkTwoPointRadialGradient::asNewEffect(GrContext*, GrSamplerState*) const {
+bool SkTwoPointRadialGradient::asNewEffect(GrContext*, GrEffectStage*) const {
     SkDEBUGFAIL("Should not call in GPU-less build");
     return false;
 }
index 2810f43f331627aa4360a52fd5a0a4418b1b97ab..e7e451afe9b526aba3915c554e4c8c8d48681b4b 100644 (file)
@@ -23,7 +23,7 @@ public:
                                  SkMatrix* matrix,
                                  TileMode* xy) const SK_OVERRIDE;
     virtual GradientType asAGradient(GradientInfo* info) const SK_OVERRIDE;
-    virtual bool asNewEffect(GrContext* context, GrSamplerState* sampler) const SK_OVERRIDE;
+    virtual bool asNewEffect(GrContext* context, GrEffectStage* stage) const SK_OVERRIDE;
 
     virtual void shadeSpan(int x, int y, SkPMColor* dstCParam,
                            int count) SK_OVERRIDE;
index 6104f66e8181494cf00da5e9736e6bef3f814855..c1effd7244a07fb9ecc20022ee91df0a598a015a 100644 (file)
@@ -26,7 +26,7 @@ GR_DEFINE_RESOURCE_CACHE_DOMAIN(GrClipMaskManager, GetAlphaMaskDomain)
 ////////////////////////////////////////////////////////////////////////////////
 namespace {
 // set up the draw state to enable the aa clipping mask. Besides setting up the
-// sampler matrix this also alters the vertex layout
+// stage matrix this also alters the vertex layout
 void setup_drawstate_aaclip(GrGpu* gpu,
                             GrTexture* result,
                             const GrIRect &devBound) {
@@ -41,7 +41,7 @@ void setup_drawstate_aaclip(GrGpu* gpu,
                      SkIntToScalar(-devBound.fTop));
     mat.preConcat(drawState->getViewMatrix());
 
-    drawState->sampler(kMaskStage)->reset();
+    drawState->stage(kMaskStage)->reset();
     drawState->createTextureEffect(kMaskStage, result, mat);
 }
 
index 23583dd45f3426250ce9f24147b0da9d6200bfcc..b2733c26e88c09a0aeb8b8cd786abf51cda269c3 100644 (file)
@@ -204,7 +204,7 @@ void convolve_gaussian(GrDrawTarget* target,
     SkAutoTUnref<GrConvolutionEffect> conv(SkNEW_ARGS(GrConvolutionEffect,
                                                       (texture, direction, radius,
                                                        sigma)));
-    drawState->sampler(0)->setEffect(conv, sampleM);
+    drawState->stage(0)->setEffect(conv, sampleM);
     target->drawSimpleRect(rect, NULL);
 }
 
@@ -331,7 +331,7 @@ GrTexture* GrContext::createResizedTexture(const GrTextureDesc& desc,
         texture->releaseRenderTarget();
     } else {
         // TODO: Our CPU stretch doesn't filter. But we create separate
-        // stretched textures when the sampler state is either filtered or
+        // stretched textures when the texture params is either filtered or
         // not. Either implement filtered stretch blit on CPU or just create
         // one when FBO case fails.
 
@@ -340,17 +340,13 @@ GrTexture* GrContext::createResizedTexture(const GrTextureDesc& desc,
         rtDesc.fWidth  = GrNextPow2(desc.fWidth);
         rtDesc.fHeight = GrNextPow2(desc.fHeight);
         int bpp = GrBytesPerPixel(desc.fConfig);
-        SkAutoSMalloc<128*128*4> stretchedPixels(bpp *
-                                                    rtDesc.fWidth *
-                                                    rtDesc.fHeight);
+        SkAutoSMalloc<128*128*4> stretchedPixels(bpp * rtDesc.fWidth * rtDesc.fHeight);
         stretchImage(stretchedPixels.get(), rtDesc.fWidth, rtDesc.fHeight,
-                        srcData, desc.fWidth, desc.fHeight, bpp);
+                     srcData, desc.fWidth, desc.fHeight, bpp);
 
         size_t stretchedRowBytes = rtDesc.fWidth * bpp;
 
-        GrTexture* texture = fGpu->createTexture(rtDesc,
-                                                    stretchedPixels.get(),
-                                                    stretchedRowBytes);
+        GrTexture* texture = fGpu->createTexture(rtDesc, stretchedPixels.get(), stretchedRowBytes);
         GrAssert(NULL != texture);
     }
 
@@ -452,9 +448,9 @@ GrTexture* GrContext::lockScratchTexture(const GrTextureDesc& inDesc,
         }
     }
 
-    // If the caller gives us the same desc/sampler twice we don't want
-    // to return the same texture the second time (unless it was previously
-    // released). So make it exclusive to hide it from future searches.
+    // If the caller gives us the same desc twice we don't want to return the
+    // same texture the second time (unless it was previously released). So
+    // make it exclusive to hide it from future searches.
     if (NULL != resource) {
         fTextureCache->makeExclusive(resource->getCacheEntry());
     }
@@ -858,7 +854,7 @@ void GrContext::drawRectToRect(const GrPaint& paint,
         m.postConcat(*srcMatrix);
     }
 
-    drawState->sampler(GrPaint::kFirstColorStage)->preConcatCoordChange(m);
+    drawState->stage(GrPaint::kFirstColorStage)->preConcatCoordChange(m);
 
     const GrVertexBuffer* sqVB = fGpu->getUnitSquareVertexBuffer();
     if (NULL == sqVB) {
@@ -1344,7 +1340,7 @@ bool GrContext::readRenderTargetPixels(GrRenderTarget* target,
                     matrix.setTranslate(SK_Scalar1 *left, SK_Scalar1 *top);
                 }
                 matrix.postIDiv(src->width(), src->height());
-                drawState->sampler(0)->setEffect(effect, matrix);
+                drawState->stage(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
@@ -1552,7 +1548,7 @@ void GrContext::writeRenderTargetPixels(GrRenderTarget* target,
     drawState->setRenderTarget(target);
 
     matrix.setIDiv(texture->width(), texture->height());
-    drawState->sampler(0)->setEffect(effect, matrix);
+    drawState->stage(0)->setEffect(effect, matrix);
 
     fGpu->drawSimpleRect(GrRect::MakeWH(SkIntToScalar(width), SkIntToScalar(height)), NULL);
 }
@@ -1816,8 +1812,8 @@ GrTexture* GrContext::gaussianBlur(GrTexture* srcTexture,
         scale_rect(&dstRect, i < scaleFactorX ? 0.5f : 1.0f,
                              i < scaleFactorY ? 0.5f : 1.0f);
 
-        paint.colorSampler(0)->setEffect(SkNEW_ARGS(GrSingleTextureEffect,
-                                                    (srcTexture, true)), matrix)->unref();
+        paint.colorStage(0)->setEffect(SkNEW_ARGS(GrSingleTextureEffect,
+                                                  (srcTexture, true)), matrix)->unref();
         this->drawRectToRect(paint, dstRect, srcRect);
         srcRect = dstRect;
         srcTexture = dstTexture;
@@ -1874,8 +1870,8 @@ GrTexture* GrContext::gaussianBlur(GrTexture* srcTexture,
         // FIXME:  This should be mitchell, not bilinear.
         matrix.setIDiv(srcTexture->width(), srcTexture->height());
         this->setRenderTarget(dstTexture->asRenderTarget());
-        paint.colorSampler(0)->setEffect(SkNEW_ARGS(GrSingleTextureEffect,(srcTexture, true)),
-                                         matrix)->unref();
+        paint.colorStage(0)->setEffect(SkNEW_ARGS(GrSingleTextureEffect,(srcTexture, true)),
+                                       matrix)->unref();
         SkRect dstRect(srcRect);
         scale_rect(&dstRect, (float) scaleFactorX, (float) scaleFactorY);
         this->drawRectToRect(paint, dstRect, srcRect);
index 0f0a27a928bee7035bb09b8de1f533801d39e316..a78bcc0fa8ddee58772434d0a36f50baf1188a62 100644 (file)
@@ -13,7 +13,7 @@ void GrDrawState::setFromPaint(const GrPaint& paint) {
     for (int i = 0; i < GrPaint::kMaxColorStages; ++i) {
         int s = i + GrPaint::kFirstColorStage;
         if (paint.isColorStageEnabled(i)) {
-            *this->sampler(s) = paint.getColorSampler(i);
+            *this->stage(s) = paint.getColorStage(i);
         }
     }
 
@@ -22,7 +22,7 @@ void GrDrawState::setFromPaint(const GrPaint& paint) {
     for (int i = 0; i < GrPaint::kMaxCoverageStages; ++i) {
         int s = i + GrPaint::kFirstCoverageStage;
         if (paint.isCoverageStageEnabled(i)) {
-            *this->sampler(s) = paint.getCoverageSampler(i);
+            *this->stage(s) = paint.getCoverageStage(i);
         }
     }
 
@@ -48,7 +48,7 @@ void GrDrawState::AutoViewMatrixRestore::restore() {
         fDrawState->setViewMatrix(fViewMatrix);
         for (int s = 0; s < GrDrawState::kNumStages; ++s) {
             if (fRestoreMask & (1 << s)) {
-                fDrawState->sampler(s)->restoreCoordChange(fSavedCoordChanges[s]);
+                fDrawState->stage(s)->restoreCoordChange(fSavedCoordChanges[s]);
             }
         }
     }
@@ -71,8 +71,8 @@ void GrDrawState::AutoViewMatrixRestore::set(GrDrawState* drawState,
     for (int s = 0; s < GrDrawState::kNumStages; ++s) {
         if (!(explicitCoordStageMask & (1 << s)) && drawState->isStageEnabled(s)) {
             fRestoreMask |= (1 << s);
-            fDrawState->sampler(s)->saveCoordChange(&fSavedCoordChanges[s]);
-            drawState->sampler(s)->preConcatCoordChange(preconcatMatrix);
+            fDrawState->stage(s)->saveCoordChange(&fSavedCoordChanges[s]);
+            drawState->stage(s)->preConcatCoordChange(preconcatMatrix);
         }
     }
 }
@@ -84,7 +84,7 @@ void GrDrawState::AutoDeviceCoordDraw::restore() {
         fDrawState->setViewMatrix(fViewMatrix);
         for (int s = 0; s < GrDrawState::kNumStages; ++s) {
             if (fRestoreMask & (1 << s)) {
-                fDrawState->sampler(s)->restoreCoordChange(fSavedCoordChanges[s]);
+                fDrawState->stage(s)->restoreCoordChange(fSavedCoordChanges[s]);
             }
         }
     }
@@ -117,9 +117,9 @@ bool GrDrawState::AutoDeviceCoordDraw::set(GrDrawState* drawState,
                 inverted = true;
             }
             fRestoreMask |= (1 << s);
-            GrSamplerState* sampler = drawState->sampler(s);
-            sampler->saveCoordChange(&fSavedCoordChanges[s]);
-            sampler->preConcatCoordChange(invVM);
+            GrEffectStage* stage = drawState->stage(s);
+            stage->saveCoordChange(&fSavedCoordChanges[s]);
+            stage->preConcatCoordChange(invVM);
         }
     }
     drawState->viewMatrix()->reset();
index 6f7ebcd6a5859e387bbe9a255b0ebbc8a7395aef..90769cb5c65640199a8153ae60b038a047b9285d 100644 (file)
@@ -11,7 +11,7 @@
 #include "GrColor.h"
 #include "GrMatrix.h"
 #include "GrRefCnt.h"
-#include "GrSamplerState.h"
+#include "GrEffectStage.h"
 #include "GrStencil.h"
 #include "GrTexture.h"
 #include "GrRenderTarget.h"
@@ -69,7 +69,7 @@ public:
 
     /**
      * Resets to the default state.
-     * Sampler states *will* be modified: textures or GrEffect objects will be released.
+     * GrEffects will be removed from all stages.
      */
     void reset() {
 
@@ -188,35 +188,36 @@ public:
     /**
      * Creates a GrSingleTextureEffect.
      */
-    void createTextureEffect(int stage, GrTexture* texture) {
-        GrAssert(!this->getSampler(stage).getEffect());
-        this->sampler(stage)->setEffect(SkNEW_ARGS(GrSingleTextureEffect, (texture)))->unref();
+    void createTextureEffect(int stageIdx, GrTexture* texture) {
+        GrAssert(!this->getStage(stageIdx).getEffect());
+        this->stage(stageIdx)->setEffect(SkNEW_ARGS(GrSingleTextureEffect, (texture)))->unref();
     }
-    void createTextureEffect(int stage, GrTexture* texture, const GrMatrix& matrix) {
-        GrAssert(!this->getSampler(stage).getEffect());
+    void createTextureEffect(int stageIdx, GrTexture* texture, const GrMatrix& matrix) {
+        GrAssert(!this->getStage(stageIdx).getEffect());
         GrEffect* effect = SkNEW_ARGS(GrSingleTextureEffect, (texture));
-        this->sampler(stage)->setEffect(effect, matrix)->unref();
+        this->stage(stageIdx)->setEffect(effect, matrix)->unref();
     }
-    void createTextureEffect(int stage, GrTexture* texture,
+    void createTextureEffect(int stageIdx,
+                             GrTexture* texture,
                              const GrMatrix& matrix,
                              const GrTextureParams& params) {
-        GrAssert(!this->getSampler(stage).getEffect());
+        GrAssert(!this->getStage(stageIdx).getEffect());
         GrEffect* effect = SkNEW_ARGS(GrSingleTextureEffect, (texture, params));
-        this->sampler(stage)->setEffect(effect, matrix)->unref();
+        this->stage(stageIdx)->setEffect(effect, matrix)->unref();
     }
 
 
     bool stagesDisabled() {
         for (int i = 0; i < kNumStages; ++i) {
-            if (NULL != fSamplerStates[i].getEffect()) {
+            if (NULL != fStages[i].getEffect()) {
                 return false;
             }
         }
         return true;
     }
 
-    void disableStage(int index) {
-        fSamplerStates[index].setEffect(NULL);
+    void disableStage(int stageIdx) {
+        fStages[stageIdx].setEffect(NULL);
     }
 
     /**
@@ -243,33 +244,33 @@ public:
     /// @}
 
     ///////////////////////////////////////////////////////////////////////////
-    /// @name Samplers
+    /// @name Stages
     ////
 
     /**
-     * Returns the current sampler for a stage.
+     * Returns the current stage by index.
      */
-    const GrSamplerState& getSampler(int stage) const {
-        GrAssert((unsigned)stage < kNumStages);
-        return fSamplerStates[stage];
+    const GrEffectStage& getStage(int stageIdx) const {
+        GrAssert((unsigned)stageIdx < kNumStages);
+        return fStages[stageIdx];
     }
 
     /**
-     * Writable pointer to a stage's sampler.
+     * Writable pointer to a stage.
      */
-    GrSamplerState* sampler(int stage) {
-        GrAssert((unsigned)stage < kNumStages);
-        return fSamplerStates + stage;
+    GrEffectStage* stage(int stageIdx) {
+        GrAssert((unsigned)stageIdx < kNumStages);
+        return fStages + stageIdx;
     }
 
     /**
      * Called when the source coord system is changing. preConcat gives the transformation from the
      * old coord system to the new coord system.
      */
-    void preConcatSamplerMatrices(const GrMatrix& preConcat) {
+    void preConcatStageMatrices(const GrMatrix& preConcat) {
         for (int i = 0; i < kNumStages; ++i) {
             if (this->isStageEnabled(i)) {
-                fSamplerStates[i].preConcatCoordChange(preConcat);
+                fStages[i].preConcatCoordChange(preConcat);
             }
         }
     }
@@ -279,7 +280,7 @@ public:
      * transformation from the old coord system to the new coord system. Returns false if the matrix
      * cannot be inverted.
      */
-    bool preConcatSamplerMatricesWithInverse(const GrMatrix& preConcatInverse) {
+    bool preConcatStageMatricesWithInverse(const GrMatrix& preConcatInverse) {
         GrMatrix inv;
         bool computed = false;
         for (int i = 0; i < kNumStages; ++i) {
@@ -289,7 +290,7 @@ public:
                 } else {
                     computed = true;
                 }
-                fSamplerStates[i].preConcatCoordChange(preConcatInverse);
+                fStages[i].preConcatCoordChange(preConcatInverse);
             }
         }
         return true;
@@ -502,7 +503,7 @@ public:
     private:
         GrDrawState*                        fDrawState;
         GrMatrix                            fViewMatrix;
-        GrSamplerState::SavedCoordChange    fSavedCoordChanges[GrDrawState::kNumStages];
+        GrEffectStage::SavedCoordChange     fSavedCoordChanges[GrDrawState::kNumStages];
         uint32_t                            fRestoreMask;
     };
 
@@ -556,7 +557,7 @@ public:
     private:
         GrDrawState*                        fDrawState;
         GrMatrix                            fViewMatrix;
-        GrSamplerState::SavedCoordChange    fSavedCoordChanges[GrDrawState::kNumStages];
+        GrEffectStage::SavedCoordChange     fSavedCoordChanges[GrDrawState::kNumStages];
         uint32_t                            fRestoreMask;
     };
 
@@ -822,7 +823,7 @@ public:
 
     bool isStageEnabled(int s) const {
         GrAssert((unsigned)s < kNumStages);
-        return (NULL != fSamplerStates[s].getEffect());
+        return (NULL != fStages[s].getEffect());
     }
 
     // Most stages are usually not used, so conditionals here
@@ -850,7 +851,7 @@ public:
             if (enabled != s.isStageEnabled(i)) {
                 return false;
             }
-            if (enabled && this->fSamplerStates[i] != s.fSamplerStates[i]) {
+            if (enabled && this->fStages[i] != s.fStages[i]) {
                 return false;
             }
         }
@@ -878,7 +879,7 @@ public:
 
         for (int i = 0; i < kNumStages; i++) {
             if (s.isStageEnabled(i)) {
-                this->fSamplerStates[i] = s.fSamplerStates[i];
+                this->fStages[i] = s.fStages[i];
             }
         }
 
@@ -905,7 +906,7 @@ private:
 
     // This field must be last; it will not be copied or compared
     // if the corresponding fTexture[] is NULL.
-    GrSamplerState      fSamplerStates[kNumStages];
+    GrEffectStage       fStages[kNumStages];
 
     typedef GrRefCnt INHERITED;
 };
index dbb04a677bdbda409ed3626e9a979be570c44c1f..d82ae5a1f29b3553c357422a1e8c0695f10aaca5 100644 (file)
@@ -146,13 +146,13 @@ size_t GrDrawTarget::VertexSize(GrVertexLayout vertexLayout) {
  * Coverage
  */
 
-int GrDrawTarget::VertexStageCoordOffset(int stage, GrVertexLayout vertexLayout) {
+int GrDrawTarget::VertexStageCoordOffset(int stageIdx, GrVertexLayout vertexLayout) {
     GrAssert(check_layout(vertexLayout));
 
-    if (!StageUsesTexCoords(vertexLayout, stage)) {
+    if (!StageUsesTexCoords(vertexLayout, stageIdx)) {
         return 0;
     }
-    int tcIdx = VertexTexCoordsForStage(stage, vertexLayout);
+    int tcIdx = VertexTexCoordsForStage(stageIdx, vertexLayout);
     if (tcIdx >= 0) {
 
         int vecSize = (vertexLayout & kTextFormat_VertexLayoutBit) ?
@@ -313,11 +313,11 @@ bool GrDrawTarget::VertexUsesTexCoordIdx(int coordIndex,
     return !!(gTexCoordMasks[coordIndex] & vertexLayout);
 }
 
-int GrDrawTarget::VertexTexCoordsForStage(int stage,
+int GrDrawTarget::VertexTexCoordsForStage(int stageIdx,
                                           GrVertexLayout vertexLayout) {
-    GrAssert(stage < GrDrawState::kNumStages);
+    GrAssert(stageIdx < GrDrawState::kNumStages);
     GrAssert(check_layout(vertexLayout));
-    int bit = vertexLayout & gStageTexCoordMasks[stage];
+    int bit = vertexLayout & gStageTexCoordMasks[stageIdx];
     if (bit) {
         // figure out which set of texture coordates is used
         // bits are ordered T0S0, T0S1, T0S2, ..., T1S0, T1S1, ...
@@ -542,8 +542,8 @@ bool GrDrawTarget::reserveIndexSpace(int indexCount,
 
 }
 
-bool GrDrawTarget::StageUsesTexCoords(GrVertexLayout layout, int stage) {
-    return SkToBool(layout & gStageTexCoordMasks[stage]);
+bool GrDrawTarget::StageUsesTexCoords(GrVertexLayout layout, int stageIdx) {
+    return SkToBool(layout & gStageTexCoordMasks[stageIdx]);
 }
 
 bool GrDrawTarget::reserveVertexAndIndexSpace(GrVertexLayout vertexLayout,
@@ -748,7 +748,7 @@ bool GrDrawTarget::checkDraw(GrPrimitiveType type, int startVertex,
     GrAssert(NULL != drawState.getRenderTarget());
     for (int s = 0; s < GrDrawState::kNumStages; ++s) {
         if (drawState.isStageEnabled(s)) {
-            const GrEffect* effect = drawState.getSampler(s).getEffect();
+            const GrEffect* effect = drawState.getStage(s).getEffect();
             int numTextures = effect->numTextures();
             for (int t = 0; t < numTextures; ++t) {
                 GrTexture* texture = effect->texture(t);
@@ -831,7 +831,7 @@ bool GrDrawTarget::srcAlphaWillBeOne(GrVertexLayout layout) const {
     // Check if a color stage could create a partial alpha
     for (int s = 0; s < drawState.getFirstCoverageStage(); ++s) {
         if (this->isStageEnabled(s)) {
-            const GrEffect* effect = drawState.getSampler(s).getEffect();
+            const GrEffect* effect = drawState.getStage(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.
index 134cccd9de4815de136cc2435ae48cf60258c637..3a9813bd0f11c8ab7a744fe8344fa5016e636a01 100644 (file)
@@ -190,18 +190,18 @@ public:
     /**
      * Generates a bit indicating that a texture stage uses texture coordinates
      *
-     * @param stage       the stage that will use texture coordinates.
+     * @param stageIdx    the stage that will use texture coordinates.
      * @param texCoordIdx the index of the texture coordinates to use
      *
      * @return the bit to add to a GrVertexLayout bitfield.
      */
-    static int StageTexCoordVertexLayoutBit(int stage, int texCoordIdx) {
-        GrAssert(stage < GrDrawState::kNumStages);
+    static int StageTexCoordVertexLayoutBit(int stageIdx, int texCoordIdx) {
+        GrAssert(stageIdx < GrDrawState::kNumStages);
         GrAssert(texCoordIdx < GrDrawState::kMaxTexCoords);
-        return 1 << (stage + (texCoordIdx * GrDrawState::kNumStages));
+        return 1 << (stageIdx + (texCoordIdx * GrDrawState::kNumStages));
     }
 
-    static bool StageUsesTexCoords(GrVertexLayout layout, int stage);
+    static bool StageUsesTexCoords(GrVertexLayout layout, int stageIdx);
 
 private:
     // non-stage bits start at this index.
@@ -674,13 +674,13 @@ public:
      * as texture coordinates, in which case the result of the function is
      * indistinguishable from the case when the stage is disabled.
      *
-     * @param stage         the stage to query
+     * @param stageIdx      the stage to query
      * @param vertexLayout  layout to query
      *
      * @return the texture coordinate index or -1 if the stage doesn't use
      *         separate (non-position) texture coordinates.
      */
-    static int VertexTexCoordsForStage(int stage, GrVertexLayout vertexLayout);
+    static int VertexTexCoordsForStage(int stageIdx, GrVertexLayout vertexLayout);
 
     /**
      * Helper function to compute the offset of texture coordinates in a vertex
@@ -688,7 +688,7 @@ public:
      *         layout has no texture coordinates. Will be 0 if positions are
      *         used as texture coordinates for the stage.
      */
-    static int VertexStageCoordOffset(int stage, GrVertexLayout vertexLayout);
+    static int VertexStageCoordOffset(int stageIdx, GrVertexLayout vertexLayout);
 
     /**
      * Helper function to compute the offset of the color in a vertex
@@ -941,8 +941,8 @@ protected:
         }
     }
 
-    bool isStageEnabled(int stage) const {
-        return this->getDrawState().isStageEnabled(stage);
+    bool isStageEnabled(int stageIdx) const {
+        return this->getDrawState().isStageEnabled(stageIdx);
     }
 
     // A sublcass can optionally overload this function to be notified before
index 2d1a0efb9478d39417daa7c9d34ecb320d42e668..7384cadae4d22886fae241ff846eba2aa05330b6 100644 (file)
@@ -129,8 +129,8 @@ void GrInOrderDrawBuffer::drawRect(const GrRect& rect,
         GrMatrix combinedMatrix = drawState->getViewMatrix();
         // We go to device space so that matrix changes allow us to concat
         // rect draws. When the caller has provided explicit source rects
-        // then we don't want to modify the sampler matrices. Otherwise
-        // we have to account for the view matrix change in the sampler
+        // then we don't want to modify the stages' matrices. Otherwise
+        // we have to account for the view matrix change in the stage
         // matrices.
         uint32_t explicitCoordMask = 0;
         if (srcRects) {
index ec0dbf188fb708dcd423878c3768ad5fb7989e5e..68d24c35ceaa49c7b559352cfa5d0c10a3b17b73 100644 (file)
@@ -212,7 +212,7 @@ void GrSWMaskHelper::DrawToTargetWithPathMask(GrTexture* texture,
         kPathMaskStage = GrPaint::kTotalStages,
     };
     GrAssert(!drawState->isStageEnabled(kPathMaskStage));
-    drawState->sampler(kPathMaskStage)->reset();
+    drawState->stage(kPathMaskStage)->reset();
     drawState->createTextureEffect(kPathMaskStage, texture);
     GrScalar w = GrIntToScalar(rect.width());
     GrScalar h = GrIntToScalar(rect.height());
index 59b9cb3fa083d37f5b8fce5276b2ec9870953f69..41949fb208f1f86b50729af2bb9f47aa2993294b 100644 (file)
@@ -29,7 +29,7 @@ void GrTextContext::flushGlyphs() {
     GrDrawState* drawState = fDrawTarget->drawState();
     if (fCurrVertex > 0) {
         // setup our sampler state for our text texture/atlas
-        drawState->sampler(kGlyphMaskStage)->reset();
+        drawState->stage(kGlyphMaskStage)->reset();
 
         GrAssert(GrIsALIGN4(fCurrVertex));
         GrAssert(fCurrTexture);
index b7de9add291e9aae65af2ba0b220595308f08fe7..8f62e283ab8fe987add623587e3977f96e51bd31 100644 (file)
@@ -441,7 +441,7 @@ SkGpuRenderTarget* SkGpuDevice::accessRenderTarget() {
 bool SkGpuDevice::bindDeviceAsTexture(GrPaint* paint) {
     GrTexture* texture = fRenderTarget->asTexture();
     if (NULL != texture) {
-        paint->colorSampler(kBitmapTextureIdx)->setEffect(
+        paint->colorStage(kBitmapTextureIdx)->setEffect(
             SkNEW_ARGS(GrSingleTextureEffect, (texture)))->unref();
         return true;
     }
@@ -514,7 +514,7 @@ inline bool skPaint2GrPaintNoShader(SkGpuDevice* dev,
         } else {
             SkAutoTUnref<GrEffect> effect(colorFilter->asNewEffect(dev->context()));
             if (NULL != effect.get()) {
-                grPaint->colorSampler(kColorFilterTextureIdx)->setEffect(effect);
+                grPaint->colorStage(kColorFilterTextureIdx)->setEffect(effect);
             } else {
                 // TODO: rewrite this using asNewEffect()
                 SkColor color;
@@ -530,7 +530,7 @@ inline bool skPaint2GrPaintNoShader(SkGpuDevice* dev,
 }
 
 // This function is similar to skPaint2GrPaintNoShader but also converts
-// skPaint's shader to a GrTexture/GrSamplerState if possible. The texture to
+// skPaint's shader to a GrTexture/GrEffectStage if possible. The texture to
 // be used is set on grPaint and returned in param act. constantColor has the
 // same meaning as in skPaint2GrPaintNoShader.
 inline bool skPaint2GrPaintShader(SkGpuDevice* dev,
@@ -551,8 +551,8 @@ inline bool skPaint2GrPaintShader(SkGpuDevice* dev,
         return false;
     }
 
-    GrSamplerState* sampler = grPaint->colorSampler(kShaderTextureIdx);
-    if (shader->asNewEffect(dev->context(), sampler)) {
+    GrEffectStage* stage = grPaint->colorStage(kShaderTextureIdx);
+    if (shader->asNewEffect(dev->context(), stage)) {
         return true;
     }
 
@@ -607,7 +607,7 @@ inline bool skPaint2GrPaintShader(SkGpuDevice* dev,
         GrScalar sy = SkFloatToScalar(1.f / bitmap.height());
         matrix.postScale(sx, sy);
     }
-    sampler->setEffect(SkNEW_ARGS(GrSingleTextureEffect, (texture, params)), matrix)->unref();
+    stage->setEffect(SkNEW_ARGS(GrSingleTextureEffect, (texture, params)), matrix)->unref();
 
     return true;
 }
@@ -874,7 +874,7 @@ bool drawWithGPUMaskFilter(GrContext* context, const SkPath& devPath,
             matrix.setIDiv(pathTexture->width(), pathTexture->height());
             // Blend pathTexture over blurTexture.
             context->setRenderTarget(blurTexture->asRenderTarget());
-            paint.colorSampler(0)->setEffect(SkNEW_ARGS(GrSingleTextureEffect, (pathTexture)), matrix)->unref();
+            paint.colorStage(0)->setEffect(SkNEW_ARGS(GrSingleTextureEffect, (pathTexture)), matrix)->unref();
             if (SkMaskFilter::kInner_BlurType == blurType) {
                 // inner:  dst = dst * src
                 paint.setBlendFunc(kDC_GrBlendCoeff, kZero_GrBlendCoeff);
@@ -904,8 +904,8 @@ bool drawWithGPUMaskFilter(GrContext* context, const SkPath& devPath,
     matrix.setTranslate(-finalRect.fLeft, -finalRect.fTop);
     matrix.postIDiv(blurTexture->width(), blurTexture->height());
 
-    grp->coverageSampler(MASK_IDX)->reset();
-    grp->coverageSampler(MASK_IDX)->setEffect(SkNEW_ARGS(GrSingleTextureEffect, (blurTexture)), matrix)->unref();
+    grp->coverageStage(MASK_IDX)->reset();
+    grp->coverageStage(MASK_IDX)->setEffect(SkNEW_ARGS(GrSingleTextureEffect, (blurTexture)), matrix)->unref();
     context->drawRect(*grp, finalRect);
     return true;
 }
@@ -961,7 +961,7 @@ bool drawWithMaskFilter(GrContext* context, const SkPath& devPath,
     m.setTranslate(-dstM.fBounds.fLeft*SK_Scalar1, -dstM.fBounds.fTop*SK_Scalar1);
     m.postIDiv(texture->width(), texture->height());
 
-    grp->coverageSampler(MASK_IDX)->setEffect(SkNEW_ARGS(GrSingleTextureEffect, (texture)), m)->unref();
+    grp->coverageStage(MASK_IDX)->setEffect(SkNEW_ARGS(GrSingleTextureEffect, (texture)), m)->unref();
     GrRect d;
     d.setLTRB(GrIntToScalar(dstM.fBounds.fLeft),
               GrIntToScalar(dstM.fBounds.fTop),
@@ -1374,7 +1374,7 @@ void SkGpuDevice::internalDrawBitmap(const SkBitmap& bitmap,
         return;
     }
 
-    GrSamplerState* sampler = grPaint->colorSampler(kBitmapTextureIdx);
+    GrEffectStage* stage = grPaint->colorStage(kBitmapTextureIdx);
 
     GrTexture* texture;
     SkAutoCachedTexture act(this, bitmap, &params, &texture);
@@ -1438,7 +1438,7 @@ void SkGpuDevice::internalDrawBitmap(const SkBitmap& bitmap,
     } else {
         effect.reset(SkNEW_ARGS(GrSingleTextureEffect, (texture, params)));
     }
-    grPaint->colorSampler(kBitmapTextureIdx)->setEffect(effect);
+    grPaint->colorStage(kBitmapTextureIdx)->setEffect(effect);
     fContext->drawRectToRect(*grPaint, dstRect, paintRect, &m);
 }
 
@@ -1458,7 +1458,7 @@ void apply_effect(GrContext* context,
     GrMatrix sampleM;
     sampleM.setIDiv(srcTexture->width(), srcTexture->height());
     GrPaint paint;
-    paint.colorSampler(0)->setEffect(effect, sampleM);
+    paint.colorStage(0)->setEffect(effect, sampleM);
     context->drawRect(paint, rect);
 }
 
@@ -1510,13 +1510,13 @@ void SkGpuDevice::drawSprite(const SkDraw& draw, const SkBitmap& bitmap,
         return;
     }
 
-    GrSamplerState* sampler = grPaint.colorSampler(kBitmapTextureIdx);
+    GrEffectStage* stage = grPaint.colorStage(kBitmapTextureIdx);
 
     GrTexture* texture;
-    sampler->reset();
+    stage->reset();
     // draw sprite uses the default texture params
     SkAutoCachedTexture act(this, bitmap, NULL, &texture);
-    grPaint.colorSampler(kBitmapTextureIdx)->setEffect(SkNEW_ARGS
+    grPaint.colorStage(kBitmapTextureIdx)->setEffect(SkNEW_ARGS
         (GrSingleTextureEffect, (texture)))->unref();
 
     SkImageFilter* filter = paint.getImageFilter();
@@ -1524,7 +1524,7 @@ void SkGpuDevice::drawSprite(const SkDraw& draw, const SkBitmap& bitmap,
         GrTexture* filteredTexture = filter_texture(this, fContext, texture, filter,
                  GrRect::MakeWH(SkIntToScalar(w), SkIntToScalar(h)));
         if (filteredTexture) {
-            grPaint.colorSampler(kBitmapTextureIdx)->setEffect(SkNEW_ARGS
+            grPaint.colorStage(kBitmapTextureIdx)->setEffect(SkNEW_ARGS
                 (GrSingleTextureEffect, (filteredTexture)))->unref();
             texture = filteredTexture;
             filteredTexture->unref();
@@ -1584,13 +1584,13 @@ void SkGpuDevice::drawDevice(const SkDraw& draw, SkDevice* device,
 
     GrPaint grPaint;
     SkAutoCachedTexture colorLutTexture;
-    grPaint.colorSampler(kBitmapTextureIdx)->reset();
+    grPaint.colorStage(kBitmapTextureIdx)->reset();
     if (!dev->bindDeviceAsTexture(&grPaint) ||
         !skPaint2GrPaintNoShader(this, paint, true, false, &colorLutTexture, &grPaint)) {
         return;
     }
 
-    GrTexture* devTex = grPaint.getColorSampler(kBitmapTextureIdx).getEffect()->texture(0);
+    GrTexture* devTex = grPaint.getColorStage(kBitmapTextureIdx).getEffect()->texture(0);
     SkASSERT(NULL != devTex);
 
     SkImageFilter* filter = paint.getImageFilter();
@@ -1599,7 +1599,7 @@ void SkGpuDevice::drawDevice(const SkDraw& draw, SkDevice* device,
                                      SkIntToScalar(devTex->height()));
         GrTexture* filteredTexture = filter_texture(this, fContext, devTex, filter, rect);
         if (filteredTexture) {
-            grPaint.colorSampler(kBitmapTextureIdx)->setEffect(SkNEW_ARGS
+            grPaint.colorStage(kBitmapTextureIdx)->setEffect(SkNEW_ARGS
                 (GrSingleTextureEffect, (filteredTexture)))->unref();
             devTex = filteredTexture;
             filteredTexture->unref();
index b6a69f21b523786439ad61661111e2ff27f97e91..cb4cb24a0261905cf60822e0a728f3a281e8e160 100644 (file)
@@ -185,16 +185,16 @@ void GrConfigConversionEffect::TestForPreservingPMConversions(GrContext* context
                                                         (tempTex, false, *pmToUPMRule)));
 
         context->setRenderTarget(readTex->asRenderTarget());
-        paint.colorSampler(0)->setEffect(pmToUPMEffect1);
+        paint.colorStage(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(upmToPMEffect);
+        paint.colorStage(0)->setEffect(upmToPMEffect);
         context->drawRectToRect(paint, kDstRect, kSrcRect);
         context->setRenderTarget(readTex->asRenderTarget());
-        paint.colorSampler(0)->setEffect(pmToUPMEffect2);
+        paint.colorStage(0)->setEffect(pmToUPMEffect2);
         context->drawRectToRect(paint, kDstRect, kSrcRect);
 
         readTex->readPixels(0, 0, 256, 256, kRGBA_8888_GrPixelConfig, secondRead);
index 30959072ea2bdb1c87cc982f98c0b657a45d7ec8..5634e2aa83ecc6177daf59631d4618f43443fd92 100644 (file)
@@ -880,7 +880,7 @@ void GrGLProgram::initSamplerUniforms() {
     for (int s = 0; s < GrDrawState::kNumStages; ++s) {
         int count = fUniforms.fStages[s].fSamplerUniforms.count();
         // FIXME: We're still always reserving one texture per stage. After GrTextureParams are
-        // expressed by the effect rather than the GrSamplerState we can move texture binding
+        // expressed by the effect rather than the GrEffectStage we can move texture binding
         // into GrGLProgram and it should be easier to fix this.
         GrAssert(count <= 1);
         for (int t = 0; t < count; ++t) {
@@ -976,9 +976,9 @@ void GrGLProgram::setData(const GrDrawState& drawState) {
     }
     for (int s = 0; s < GrDrawState::kNumStages; ++s) {
         if (NULL != fEffects[s]) {
-            const GrSamplerState& sampler = drawState.getSampler(s);
-            GrAssert(NULL != sampler.getEffect());
-            fEffects[s]->setData(fUniformManager, *sampler.getEffect());
+            const GrEffectStage& stage = drawState.getStage(s);
+            GrAssert(NULL != stage.getEffect());
+            fEffects[s]->setData(fUniformManager, *stage.getEffect());
         }
     }
 }
index e736231ee9f602966f5204224351dc2bc623f44a..d659cf7eca73c3e4f9d14307982e448b6692a0e0 100644 (file)
@@ -92,7 +92,7 @@ GrGLShaderBuilder::GrGLShaderBuilder(const GrGLContextInfo& ctx, GrGLUniformMana
     , fUsesGS(false)
     , fContext(ctx)
     , fUniformManager(uniformManager)
-    , fCurrentStage(kNonStageIdx)
+    , fCurrentStageIdx(kNonStageIdx)
     , fSetupFragPosition(false)
     , fRTHeightUniform(GrGLUniformManager::kInvalidUniformHandle)
     , fTexCoordVaryingType(kVoid_GrSLType) {
@@ -109,8 +109,8 @@ void GrGLShaderBuilder::setupTextureAccess(const char* varyingFSName, GrSLType v
             break;
         case kVec3f_GrSLType: {
             fDefaultTexCoordsName = "inCoord";
-            GrAssert(kNonStageIdx != fCurrentStage);
-            fDefaultTexCoordsName.appendS32(fCurrentStage);
+            GrAssert(kNonStageIdx != fCurrentStageIdx);
+            fDefaultTexCoordsName.appendS32(fCurrentStageIdx);
             fTexCoordVaryingType = kVec3f_GrSLType;
             fFSCode.appendf("\t%s %s = %s.xy / %s.z;\n",
                             GrGLShaderVar::TypeString(kVec2f_GrSLType),
@@ -212,10 +212,10 @@ GrGLUniformManager::UniformHandle GrGLShaderBuilder::addUniformArray(uint32_t vi
     uni.fVariable.setType(type);
     uni.fVariable.setTypeModifier(GrGLShaderVar::kUniform_TypeModifier);
     SkString* uniName = uni.fVariable.accessName();
-    if (kNonStageIdx == fCurrentStage) {
+    if (kNonStageIdx == fCurrentStageIdx) {
         uniName->printf("u%s", name);
     } else {
-        uniName->printf("u%s%d", name, fCurrentStage);
+        uniName->printf("u%s%d", name, fCurrentStageIdx);
     }
     uni.fVariable.setArrayCount(count);
     uni.fVisibility = visibility;
@@ -246,10 +246,10 @@ void GrGLShaderBuilder::addVarying(GrSLType type,
     fVSOutputs.push_back();
     fVSOutputs.back().setType(type);
     fVSOutputs.back().setTypeModifier(GrGLShaderVar::kOut_TypeModifier);
-    if (kNonStageIdx == fCurrentStage) {
+    if (kNonStageIdx == fCurrentStageIdx) {
         fVSOutputs.back().accessName()->printf("v%s", name);
     } else {
-        fVSOutputs.back().accessName()->printf("v%s%d", name, fCurrentStage);
+        fVSOutputs.back().accessName()->printf("v%s%d", name, fCurrentStageIdx);
     }
     if (vsOutName) {
         *vsOutName = fVSOutputs.back().getName().c_str();
@@ -267,10 +267,10 @@ void GrGLShaderBuilder::addVarying(GrSLType type,
         fGSOutputs.push_back();
         fGSOutputs.back().setType(type);
         fGSOutputs.back().setTypeModifier(GrGLShaderVar::kOut_TypeModifier);
-        if (kNonStageIdx == fCurrentStage) {
+        if (kNonStageIdx == fCurrentStageIdx) {
             fGSOutputs.back().accessName()->printf("g%s", name);
         } else {
-            fGSOutputs.back().accessName()->printf("g%s%d", name, fCurrentStage);
+            fGSOutputs.back().accessName()->printf("g%s%d", name, fCurrentStageIdx);
         }
         fsName = fGSOutputs.back().accessName();
     } else {
@@ -305,13 +305,13 @@ const char* GrGLShaderBuilder::fragmentPosition() {
 
             // temporarily change the stage index because we're inserting a uniform whose name
             // shouldn't be mangled to be stage-specific.
-            int oldStageIdx = fCurrentStage;
-            fCurrentStage = kNonStageIdx;
+            int oldStageIdx = fCurrentStageIdx;
+            fCurrentStageIdx = kNonStageIdx;
             fRTHeightUniform = this->addUniform(kFragment_ShaderType,
                                                 kFloat_GrSLType,
                                                 "RTHeight",
                                                 &rtHeightName);
-            fCurrentStage = oldStageIdx;
+            fCurrentStageIdx = oldStageIdx;
 
             this->fFSCode.prependf("\tvec4 %s = vec4(gl_FragCoord.x, %s - gl_FragCoord.y, gl_FragCoord.zw);\n",
                                    kCoordName, rtHeightName);
@@ -332,8 +332,8 @@ void GrGLShaderBuilder::emitFunction(ShaderType shader,
                                      SkString* outName) {
     GrAssert(kFragment_ShaderType == shader);
     fFSFunctions.append(GrGLShaderVar::TypeString(returnType));
-    if (kNonStageIdx != fCurrentStage) {
-        outName->printf(" %s_%d", name, fCurrentStage);
+    if (kNonStageIdx != fCurrentStageIdx) {
+        outName->printf(" %s_%d", name, fCurrentStageIdx);
     } else {
         *outName = name;
     }
index fa682685767c07ae83beafbad6a5dd592fcf6a5d..b67f2f00b28c3446adc20ae53e9a7e422f84877d 100644 (file)
@@ -181,8 +181,8 @@ public:
      * Sets the current stage (used to make variable names unique).
      * TODO: Hide from the GrEffects
      */
-    void setCurrentStage(int stage) { fCurrentStage = stage; }
-    void setNonStage() { fCurrentStage = kNonStageIdx; }
+    void setCurrentStage(int stageIdx) { fCurrentStageIdx = stageIdx; }
+    void setNonStage() { fCurrentStageIdx = kNonStageIdx; }
 
     GrGLUniformManager::UniformHandle getRTHeightUniform() const { return fRTHeightUniform; }
 
@@ -219,7 +219,7 @@ private:
 
     const GrGLContextInfo&              fContext;
     GrGLUniformManager&                 fUniformManager;
-    int                                 fCurrentStage;
+    int                                 fCurrentStageIdx;
     SkString                            fFSFunctions;
     SkString                            fFSHeader;
 
index 62652f8b916a8821cea65517ef22346ea8b83059..04d0f8eb71753398bfca5901e5dce69d7de62ef6 100644 (file)
@@ -2016,20 +2016,20 @@ inline GrGLenum tile_to_gl_wrap(SkShader::TileMode tm) {
 
 }
 
-void GrGpuGL::flushBoundTextureAndParams(int stage) {
+void GrGpuGL::flushBoundTextureAndParams(int stageIdx) {
     GrDrawState* drawState = this->drawState();
     // FIXME: Assuming at most one texture per effect
-    const GrEffect* effect = drawState->sampler(stage)->getEffect();
+    const GrEffect* effect = drawState->stage(stageIdx)->getEffect();
     if (effect->numTextures() > 0) {
         GrGLTexture* nextTexture =  static_cast<GrGLTexture*>(effect->texture(0));
         if (NULL != nextTexture) {
             const GrTextureParams& texParams = effect->textureAccess(0).getParams();
-            this->flushBoundTextureAndParams(stage, texParams, nextTexture);
+            this->flushBoundTextureAndParams(stageIdx, texParams, nextTexture);
         }
     }
 }
 
-void GrGpuGL::flushBoundTextureAndParams(int stage,
+void GrGpuGL::flushBoundTextureAndParams(int stageIdx,
                                          const GrTextureParams& params,
                                          GrGLTexture* nextTexture) {
 
@@ -2043,11 +2043,11 @@ void GrGpuGL::flushBoundTextureAndParams(int stage,
         this->onResolveRenderTarget(texRT);
     }
 
-    if (fHWBoundTextures[stage] != nextTexture) {
-        this->setTextureUnit(stage);
+    if (fHWBoundTextures[stageIdx] != nextTexture) {
+        this->setTextureUnit(stageIdx);
         GL_CALL(BindTexture(GR_GL_TEXTURE_2D, nextTexture->textureID()));
         //GrPrintf("---- bindtexture %d\n", nextTexture->textureID());
-        fHWBoundTextures[stage] = nextTexture;
+        fHWBoundTextures[stageIdx] = nextTexture;
     }
 
     ResetTimestamp timestamp;
@@ -2064,7 +2064,7 @@ void GrGpuGL::flushBoundTextureAndParams(int stage,
            GrGLShaderBuilder::GetTexParamSwizzle(nextTexture->config(), this->glCaps()),
            sizeof(newTexParams.fSwizzleRGBA));
     if (setAll || newTexParams.fFilter != oldTexParams.fFilter) {
-        this->setTextureUnit(stage);
+        this->setTextureUnit(stageIdx);
         GL_CALL(TexParameteri(GR_GL_TEXTURE_2D,
                               GR_GL_TEXTURE_MAG_FILTER,
                               newTexParams.fFilter));
@@ -2073,13 +2073,13 @@ void GrGpuGL::flushBoundTextureAndParams(int stage,
                               newTexParams.fFilter));
     }
     if (setAll || newTexParams.fWrapS != oldTexParams.fWrapS) {
-        this->setTextureUnit(stage);
+        this->setTextureUnit(stageIdx);
         GL_CALL(TexParameteri(GR_GL_TEXTURE_2D,
                               GR_GL_TEXTURE_WRAP_S,
                               newTexParams.fWrapS));
     }
     if (setAll || newTexParams.fWrapT != oldTexParams.fWrapT) {
-        this->setTextureUnit(stage);
+        this->setTextureUnit(stageIdx);
         GL_CALL(TexParameteri(GR_GL_TEXTURE_2D,
                               GR_GL_TEXTURE_WRAP_T,
                               newTexParams.fWrapT));
@@ -2088,7 +2088,7 @@ void GrGpuGL::flushBoundTextureAndParams(int stage,
         (setAll || memcmp(newTexParams.fSwizzleRGBA,
                           oldTexParams.fSwizzleRGBA,
                           sizeof(newTexParams.fSwizzleRGBA)))) {
-        this->setTextureUnit(stage);
+        this->setTextureUnit(stageIdx);
         set_tex_swizzle(newTexParams.fSwizzleRGBA,
                         this->glInterface());
     }
index 0f7b8160e7aa150efa967d720497848ad30a5e13..4985d99a127305a69adc6e2290c42bbdac91bfa9 100644 (file)
@@ -151,7 +151,7 @@ private:
 
     // This helper determines if what optimizations can be applied to the matrix after any coord
     // adjustments are applied. The return is a bitfield of GrGLProgram::StageDesc::OptFlags.
-    static int TextureMatrixOptFlags(const GrGLTexture* texture, const GrSamplerState& sampler);
+    static int TextureMatrixOptFlags(const GrGLTexture* texture, const GrEffectStage& sampler);
 
     static bool BlendCoeffReferencesConstant(GrBlendCoeff coeff);
 
@@ -216,7 +216,7 @@ private:
                                     GrGLTexture* nextTexture);
 
     // sets the texture matrix for the currently bound program
-    void flushTextureMatrix(int stage);
+    void flushTextureMatrix(int stageIdx);
 
     // sets the color specified by GrDrawState::setColor()
     void flushColor(GrColor color);
index d0b7b57b6d1444fa70dfaa2e1d8c4a711d65057e..3be5afcfc072cff0cdace7999e758fac6930a631 100644 (file)
@@ -178,10 +178,10 @@ void GrGpuGL::AdjustTextureMatrix(const GrGLTexture* texture,
 }
 
 int GrGpuGL::TextureMatrixOptFlags(const GrGLTexture* texture,
-                                   const GrSamplerState& sampler) {
+                                   const GrEffectStage& stage) {
     GrAssert(NULL != texture);
     GrMatrix matrix;
-    sampler.getTotalMatrix(&matrix);
+    stage.getTotalMatrix(&matrix);
 
     bool canBeIndentity = GrGLTexture::kTopDown_Orientation == texture->orientation();
 
@@ -199,7 +199,7 @@ void GrGpuGL::flushTextureMatrix(int s) {
     const GrDrawState& drawState = this->getDrawState();
 
     // FIXME: Still assuming only a single texture per effect
-    const GrEffect* effect = drawState.getSampler(s).getEffect();
+    const GrEffect* effect = drawState.getStage(s).getEffect();
     if (0 == effect->numTextures()) {
         return;
     }
@@ -213,7 +213,7 @@ void GrGpuGL::flushTextureMatrix(int s) {
 
         const GrMatrix& hwMatrix = fCurrentProgram->fTextureMatrices[s];
         GrMatrix samplerMatrix;
-        drawState.getSampler(s).getTotalMatrix(&samplerMatrix);
+        drawState.getStage(s).getTotalMatrix(&samplerMatrix);
 
         if (kInvalidUniformHandle != matrixUni &&
             (orientationChange || !hwMatrix.cheapEqualTo(samplerMatrix))) {
@@ -565,18 +565,18 @@ void GrGpuGL::setupGeometry(int* startVertex,
 
 namespace {
 
-void setup_effect(GrGLProgram::Desc::StageDesc* stage,
-                  const GrSamplerState& sampler,
+void setup_effect(GrGLProgram::Desc::StageDesc* stageDesc,
+                  const GrEffectStage& stage,
                   const GrGLCaps& caps,
                   const GrEffect** effects,
                   GrGLProgram* program, int index) {
-    const GrEffect* effect = sampler.getEffect();
+    const GrEffect* effect = stage.getEffect();
     if (effect) {
         const GrBackendEffectFactory& factory = effect->getFactory();
-        stage->fEffectKey = factory.glEffectKey(*effect, caps);
+        stageDesc->fEffectKey = factory.glEffectKey(*effect, caps);
         effects[index] = effect;
     } else {
-        stage->fEffectKey = 0;
+        stageDesc->fEffectKey = 0;
         effects[index] = NULL;
     }
 }
@@ -663,40 +663,40 @@ void GrGpuGL::buildProgram(bool isPoints,
     }
 
     for (int s = 0; s < GrDrawState::kNumStages; ++s) {
-        StageDesc& stage = desc->fStages[s];
+        StageDesc& stageDesc = desc->fStages[s];
 
-        stage.fOptFlags = 0;
-        stage.setEnabled(this->isStageEnabled(s));
+        stageDesc.fOptFlags = 0;
+        stageDesc.setEnabled(this->isStageEnabled(s));
 
         bool skip = s < drawState.getFirstCoverageStage() ? skipColor :
                                                             skipCoverage;
 
-        if (!skip && stage.isEnabled()) {
+        if (!skip && stageDesc.isEnabled()) {
             lastEnabledStage = s;
-            const GrSamplerState& sampler = drawState.getSampler(s);
+            const GrEffectStage& stage = drawState.getStage(s);
             // FIXME: Still assuming one texture per effect
-            const GrEffect* effect = drawState.getSampler(s).getEffect();
+            const GrEffect* effect = drawState.getStage(s).getEffect();
 
             if (effect->numTextures() > 0) {
                 const GrGLTexture* texture = static_cast<const GrGLTexture*>(effect->texture(0));
                 GrMatrix samplerMatrix;
-                sampler.getTotalMatrix(&samplerMatrix);
+                stage.getTotalMatrix(&samplerMatrix);
                 if (NULL != texture) {
                     // We call this helper function rather then simply checking the client-specified
                     // texture matrix. This is because we may have to concat a y-inversion to account
                     // for texture orientation.
-                    stage.fOptFlags |= TextureMatrixOptFlags(texture, sampler);
+                    stageDesc.fOptFlags |= TextureMatrixOptFlags(texture, stage);
                 }
             } else {
                 // Set identity to do the minimal amount of extra work for the no texture case.
                 // This will go away when effects manage their own texture matrix.
-                stage.fOptFlags |= StageDesc::kIdentityMatrix_OptFlagBit;
+                stageDesc.fOptFlags |= StageDesc::kIdentityMatrix_OptFlagBit;
             }
-            setup_effect(&stage, sampler, this->glCaps(), effects, fCurrentProgram.get(), s);
+            setup_effect(&stageDesc, stage, this->glCaps(), effects, fCurrentProgram.get(), s);
 
         } else {
-            stage.fOptFlags  = 0;
-            stage.fEffectKey = 0;
+            stageDesc.fOptFlags  = 0;
+            stageDesc.fEffectKey = 0;
             effects[s] = NULL;
         }
     }
index e6b2f56d5b5bf394fb82eed5765962df5d292530..c77c67070b52c92fd4bdec43e2c0957b1d2cfbc2 100644 (file)
@@ -121,7 +121,7 @@ bool GrGpuGL::programUnitTest() {
         SkAutoTUnref<const GrEffect> effects[GrDrawState::kNumStages];
 
         for (int s = 0; s < GrDrawState::kNumStages; ++s) {
-            StageDesc& stage = pdesc.fStages[s];
+            StageDesc& stageDesc = pdesc.fStages[s];
             // enable the stage?
             if (random_bool(&random)) {
                 // use separate tex coords?
@@ -129,25 +129,24 @@ bool GrGpuGL::programUnitTest() {
                     int t = random_int(&random, GrDrawState::kMaxTexCoords);
                     pdesc.fVertexLayout |= StageTexCoordVertexLayoutBit(s, t);
                 }
-                stage.setEnabled(true);
+                stageDesc.setEnabled(true);
             }
             // use text-formatted verts?
             if (random_bool(&random)) {
                 pdesc.fVertexLayout |= kTextFormat_VertexLayoutBit;
             }
 
-            stage.fEffectKey = 0;
+            stageDesc.fEffectKey = 0;
+            stageDesc.fOptFlags |= STAGE_OPTS[random_int(&random, GR_ARRAY_COUNT(STAGE_OPTS))];
 
-            stage.fOptFlags |= STAGE_OPTS[random_int(&random, GR_ARRAY_COUNT(STAGE_OPTS))];
-
-            if (stage.isEnabled()) {
+            if (stageDesc.isEnabled()) {
                 GrTexture* dummyTextures[] = {dummyTexture1.get(), dummyTexture2.get()};
-                effects[s].reset(create_random_effect(&stage,
+                effects[s].reset(create_random_effect(&stageDesc,
                                                       &random,
                                                       getContext(),
                                                       dummyTextures));
                 if (NULL != effects[s]) {
-                    stage.fEffectKey =
+                    stageDesc.fEffectKey =
                         effects[s]->getFactory().glEffectKey(*effects[s], this->glCaps());
                 }
             }