diff options
38 files changed, 266 insertions, 276 deletions
diff --git a/gm/texdata.cpp b/gm/texdata.cpp index bbc5efa1eb..cc3476d1f6 100644 --- a/gm/texdata.cpp +++ b/gm/texdata.cpp @@ -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)); diff --git a/gyp/gpu.gypi b/gyp/gpu.gypi index 5733c469cf..8650f3cd3f 100644 --- a/gyp/gpu.gypi +++ b/gyp/gpu.gypi @@ -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', diff --git a/include/core/SkShader.h b/include/core/SkShader.h index 7329c1bf4c..90d831710c 100644 --- a/include/core/SkShader.h +++ b/include/core/SkShader.h @@ -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/GrSamplerState.h b/include/gpu/GrEffectStage.h index a70b3831aa..6f8b23fea9 100644 --- a/include/gpu/GrSamplerState.h +++ b/include/gpu/GrEffectStage.h @@ -17,20 +17,20 @@ #include "SkShader.h" -class GrSamplerState { +class GrEffectStage { public: - GrSamplerState() + GrEffectStage() : fEffect (NULL) { GR_DEBUGCODE(fSavedCoordChangeCnt = 0;) } - ~GrSamplerState() { + ~GrEffectStage() { GrSafeUnref(fEffect); GrAssert(0 == fSavedCoordChangeCnt); } - bool operator ==(const GrSamplerState& other) const { + bool operator ==(const GrEffectStage& other) const { // first handle cases where one or the other has no effect if (NULL == fEffect) { return NULL == other.fEffect; @@ -49,9 +49,9 @@ public: return fMatrix == other.fMatrix && fCoordChangeMatrix == other.fCoordChangeMatrix; } - bool operator !=(const GrSamplerState& s) const { return !(*this == s); } + bool operator !=(const GrEffectStage& s) const { return !(*this == s); } - GrSamplerState& operator =(const GrSamplerState& other) { + GrEffectStage& operator =(const GrEffectStage& other) { GrSafeAssign(fEffect, other.fEffect); if (NULL != fEffect) { fMatrix = other.fMatrix; @@ -72,7 +72,7 @@ public: GrMatrix fCoordChangeMatrix; GR_DEBUGCODE(mutable SkAutoTUnref<GrEffect> fEffect;) - friend class GrSamplerState; + friend class GrEffectStage; }; /** diff --git a/include/gpu/GrPaint.h b/include/gpu/GrPaint.h index 4b2d3cda0d..efafd7f1ab 100644 --- a/include/gpu/GrPaint.h +++ b/include/gpu/GrPaint.h @@ -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/src/core/SkShader.cpp b/src/core/SkShader.cpp index 50546ffcc3..9c9366b93a 100644 --- a/src/core/SkShader.cpp +++ b/src/core/SkShader.cpp @@ -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; } diff --git a/src/effects/SkBlendImageFilter.cpp b/src/effects/SkBlendImageFilter.cpp index c87c5d35bd..fdbf070560 100644 --- a/src/effects/SkBlendImageFilter.cpp +++ b/src/effects/SkBlendImageFilter.cpp @@ -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; diff --git a/src/effects/SkMagnifierImageFilter.cpp b/src/effects/SkMagnifierImageFilter.cpp index 3b306c17d5..ea64e530e3 100644 --- a/src/effects/SkMagnifierImageFilter.cpp +++ b/src/effects/SkMagnifierImageFilter.cpp @@ -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); diff --git a/src/effects/SkMorphologyImageFilter.cpp b/src/effects/SkMorphologyImageFilter.cpp index 1d243b9d36..3273798b9d 100644 --- a/src/effects/SkMorphologyImageFilter.cpp +++ b/src/effects/SkMorphologyImageFilter.cpp @@ -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); } diff --git a/src/effects/gradients/SkGradientShaderPriv.h b/src/effects/gradients/SkGradientShaderPriv.h index 6bb0a60e1c..194ff8c6d8 100644 --- a/src/effects/gradients/SkGradientShaderPriv.h +++ b/src/effects/gradients/SkGradientShaderPriv.h @@ -194,7 +194,7 @@ private: #include "gl/GrGLEffect.h" -class GrSamplerState; +class GrEffectStage; class GrBackendEffectFactory; /* diff --git a/src/effects/gradients/SkLinearGradient.cpp b/src/effects/gradients/SkLinearGradient.cpp index 71003cfd20..61824a042e 100644 --- a/src/effects/gradients/SkLinearGradient.cpp +++ b/src/effects/gradients/SkLinearGradient.cpp @@ -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; } diff --git a/src/effects/gradients/SkLinearGradient.h b/src/effects/gradients/SkLinearGradient.h index e0e75b4b6c..7d879266b1 100644 --- a/src/effects/gradients/SkLinearGradient.h +++ b/src/effects/gradients/SkLinearGradient.h @@ -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) diff --git a/src/effects/gradients/SkRadialGradient.cpp b/src/effects/gradients/SkRadialGradient.cpp index fa36fccbd6..6b9a678df7 100644 --- a/src/effects/gradients/SkRadialGradient.cpp +++ b/src/effects/gradients/SkRadialGradient.cpp @@ -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; } diff --git a/src/effects/gradients/SkRadialGradient.h b/src/effects/gradients/SkRadialGradient.h index 9384793d27..cf0d43d3b9 100644 --- a/src/effects/gradients/SkRadialGradient.h +++ b/src/effects/gradients/SkRadialGradient.h @@ -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) diff --git a/src/effects/gradients/SkSweepGradient.cpp b/src/effects/gradients/SkSweepGradient.cpp index 190da5973c..c606bbaca6 100644 --- a/src/effects/gradients/SkSweepGradient.cpp +++ b/src/effects/gradients/SkSweepGradient.cpp @@ -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; } diff --git a/src/effects/gradients/SkSweepGradient.h b/src/effects/gradients/SkSweepGradient.h index c685cd924e..a44b4c15f1 100644 --- a/src/effects/gradients/SkSweepGradient.h +++ b/src/effects/gradients/SkSweepGradient.h @@ -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) diff --git a/src/effects/gradients/SkTwoPointConicalGradient.cpp b/src/effects/gradients/SkTwoPointConicalGradient.cpp index 84ad087451..3c4560c909 100644 --- a/src/effects/gradients/SkTwoPointConicalGradient.cpp +++ b/src/effects/gradients/SkTwoPointConicalGradient.cpp @@ -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; } diff --git a/src/effects/gradients/SkTwoPointConicalGradient.h b/src/effects/gradients/SkTwoPointConicalGradient.h index 398735ddb1..d199650414 100644 --- a/src/effects/gradients/SkTwoPointConicalGradient.h +++ b/src/effects/gradients/SkTwoPointConicalGradient.h @@ -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; } diff --git a/src/effects/gradients/SkTwoPointRadialGradient.cpp b/src/effects/gradients/SkTwoPointRadialGradient.cpp index 9d2245c9d4..b37b568ad7 100644 --- a/src/effects/gradients/SkTwoPointRadialGradient.cpp +++ b/src/effects/gradients/SkTwoPointRadialGradient.cpp @@ -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; } diff --git a/src/effects/gradients/SkTwoPointRadialGradient.h b/src/effects/gradients/SkTwoPointRadialGradient.h index 2810f43f33..e7e451afe9 100644 --- a/src/effects/gradients/SkTwoPointRadialGradient.h +++ b/src/effects/gradients/SkTwoPointRadialGradient.h @@ -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; diff --git a/src/gpu/GrClipMaskManager.cpp b/src/gpu/GrClipMaskManager.cpp index 6104f66e81..c1effd7244 100644 --- a/src/gpu/GrClipMaskManager.cpp +++ b/src/gpu/GrClipMaskManager.cpp @@ -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); } diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp index 23583dd45f..b2733c26e8 100644 --- a/src/gpu/GrContext.cpp +++ b/src/gpu/GrContext.cpp @@ -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); diff --git a/src/gpu/GrDrawState.cpp b/src/gpu/GrDrawState.cpp index 0f0a27a928..a78bcc0fa8 100644 --- a/src/gpu/GrDrawState.cpp +++ b/src/gpu/GrDrawState.cpp @@ -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(); diff --git a/src/gpu/GrDrawState.h b/src/gpu/GrDrawState.h index 6f7ebcd6a5..90769cb5c6 100644 --- a/src/gpu/GrDrawState.h +++ b/src/gpu/GrDrawState.h @@ -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; }; diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp index dbb04a677b..d82ae5a1f2 100644 --- a/src/gpu/GrDrawTarget.cpp +++ b/src/gpu/GrDrawTarget.cpp @@ -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. diff --git a/src/gpu/GrDrawTarget.h b/src/gpu/GrDrawTarget.h index 134cccd9de..3a9813bd0f 100644 --- a/src/gpu/GrDrawTarget.h +++ b/src/gpu/GrDrawTarget.h @@ -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 diff --git a/src/gpu/GrInOrderDrawBuffer.cpp b/src/gpu/GrInOrderDrawBuffer.cpp index 2d1a0efb94..7384cadae4 100644 --- a/src/gpu/GrInOrderDrawBuffer.cpp +++ b/src/gpu/GrInOrderDrawBuffer.cpp @@ -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) { diff --git a/src/gpu/GrSWMaskHelper.cpp b/src/gpu/GrSWMaskHelper.cpp index ec0dbf188f..68d24c35ce 100644 --- a/src/gpu/GrSWMaskHelper.cpp +++ b/src/gpu/GrSWMaskHelper.cpp @@ -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()); diff --git a/src/gpu/GrTextContext.cpp b/src/gpu/GrTextContext.cpp index 59b9cb3fa0..41949fb208 100644 --- a/src/gpu/GrTextContext.cpp +++ b/src/gpu/GrTextContext.cpp @@ -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); diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp index b7de9add29..8f62e283ab 100644 --- a/src/gpu/SkGpuDevice.cpp +++ b/src/gpu/SkGpuDevice.cpp @@ -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, ¶ms, &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(); diff --git a/src/gpu/effects/GrConfigConversionEffect.cpp b/src/gpu/effects/GrConfigConversionEffect.cpp index b6a69f21b5..cb4cb24a02 100644 --- a/src/gpu/effects/GrConfigConversionEffect.cpp +++ b/src/gpu/effects/GrConfigConversionEffect.cpp @@ -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); diff --git a/src/gpu/gl/GrGLProgram.cpp b/src/gpu/gl/GrGLProgram.cpp index 30959072ea..5634e2aa83 100644 --- a/src/gpu/gl/GrGLProgram.cpp +++ b/src/gpu/gl/GrGLProgram.cpp @@ -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()); } } } diff --git a/src/gpu/gl/GrGLShaderBuilder.cpp b/src/gpu/gl/GrGLShaderBuilder.cpp index e736231ee9..d659cf7eca 100644 --- a/src/gpu/gl/GrGLShaderBuilder.cpp +++ b/src/gpu/gl/GrGLShaderBuilder.cpp @@ -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; } diff --git a/src/gpu/gl/GrGLShaderBuilder.h b/src/gpu/gl/GrGLShaderBuilder.h index fa68268576..b67f2f00b2 100644 --- a/src/gpu/gl/GrGLShaderBuilder.h +++ b/src/gpu/gl/GrGLShaderBuilder.h @@ -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; diff --git a/src/gpu/gl/GrGpuGL.cpp b/src/gpu/gl/GrGpuGL.cpp index 62652f8b91..04d0f8eb71 100644 --- a/src/gpu/gl/GrGpuGL.cpp +++ b/src/gpu/gl/GrGpuGL.cpp @@ -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()); } diff --git a/src/gpu/gl/GrGpuGL.h b/src/gpu/gl/GrGpuGL.h index 0f7b8160e7..4985d99a12 100644 --- a/src/gpu/gl/GrGpuGL.h +++ b/src/gpu/gl/GrGpuGL.h @@ -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); diff --git a/src/gpu/gl/GrGpuGL_program.cpp b/src/gpu/gl/GrGpuGL_program.cpp index d0b7b57b6d..3be5afcfc0 100644 --- a/src/gpu/gl/GrGpuGL_program.cpp +++ b/src/gpu/gl/GrGpuGL_program.cpp @@ -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; } } diff --git a/tests/GLProgramsTest.cpp b/tests/GLProgramsTest.cpp index e6b2f56d5b..c77c67070b 100644 --- a/tests/GLProgramsTest.cpp +++ b/tests/GLProgramsTest.cpp @@ -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()); } } |