aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/effects
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-03-20 17:47:16 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-03-20 17:47:16 +0000
commit67e7cde5c5e59a8f1de7ee28276b8193ecb2bc7f (patch)
treefbb2c63213570deb6062b3eb8e9ba1a13c0431d4 /src/effects
parent113994051b41366a7b25851d05cd56e89866a33b (diff)
revert 8265-8264 (broke build)
git-svn-id: http://skia.googlecode.com/svn/trunk@8268 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/effects')
-rw-r--r--src/effects/SkBicubicImageFilter.cpp36
-rw-r--r--src/effects/SkBlendImageFilter.cpp53
-rw-r--r--src/effects/SkColorMatrixFilter.cpp11
-rw-r--r--src/effects/SkDisplacementMapEffect.cpp59
-rw-r--r--src/effects/SkLightingImageFilter.cpp95
-rw-r--r--src/effects/SkMagnifierImageFilter.cpp35
-rw-r--r--src/effects/SkMatrixConvolutionImageFilter.cpp55
-rw-r--r--src/effects/SkMorphologyImageFilter.cpp36
-rw-r--r--src/effects/SkTableColorFilter.cpp16
-rw-r--r--src/effects/gradients/SkGradientShader.cpp19
-rw-r--r--src/effects/gradients/SkGradientShaderPriv.h7
-rw-r--r--src/effects/gradients/SkLinearGradient.cpp14
-rw-r--r--src/effects/gradients/SkRadialGradient.cpp14
-rw-r--r--src/effects/gradients/SkSweepGradient.cpp14
-rw-r--r--src/effects/gradients/SkTwoPointConicalGradient.cpp33
-rw-r--r--src/effects/gradients/SkTwoPointRadialGradient.cpp32
16 files changed, 263 insertions, 266 deletions
diff --git a/src/effects/SkBicubicImageFilter.cpp b/src/effects/SkBicubicImageFilter.cpp
index 507612e99f..f4d474d697 100644
--- a/src/effects/SkBicubicImageFilter.cpp
+++ b/src/effects/SkBicubicImageFilter.cpp
@@ -185,17 +185,18 @@ private:
class GrGLBicubicEffect : public GrGLEffect {
public:
GrGLBicubicEffect(const GrBackendEffectFactory& factory,
- const GrDrawEffect&);
+ const GrEffectRef& effect);
virtual void emitCode(GrGLShaderBuilder*,
- const GrDrawEffect&,
+ const GrEffectStage&,
EffectKey,
+ const char* vertexCoords,
const char* outputColor,
const char* inputColor,
const TextureSamplerArray&) SK_OVERRIDE;
- static inline EffectKey GenKey(const GrDrawEffect&, const GrGLCaps&);
+ static inline EffectKey GenKey(const GrEffectStage&, const GrGLCaps&);
- virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVERRIDE;
+ virtual void setData(const GrGLUniformManager&, const GrEffectStage&) SK_OVERRIDE;
private:
typedef GrGLUniformManager::UniformHandle UniformHandle;
@@ -209,21 +210,21 @@ private:
};
GrGLBicubicEffect::GrGLBicubicEffect(const GrBackendEffectFactory& factory,
- const GrDrawEffect& drawEffect)
+ const GrEffectRef& effect)
: INHERITED(factory)
, fCoefficientsUni(GrGLUniformManager::kInvalidUniformHandle)
- , fImageIncrementUni(GrGLUniformManager::kInvalidUniformHandle)
- , fEffectMatrix(drawEffect.castEffect<GrBicubicEffect>().coordsType()) {
+ , fImageIncrementUni(GrGLUniformManager::kInvalidUniformHandle) {
}
void GrGLBicubicEffect::emitCode(GrGLShaderBuilder* builder,
- const GrDrawEffect&,
+ const GrEffectStage&,
EffectKey key,
+ const char* vertexCoords,
const char* outputColor,
const char* inputColor,
const TextureSamplerArray& samplers) {
const char* coords;
- fEffectMatrix.emitCodeMakeFSCoords2D(builder, key, &coords);
+ fEffectMatrix.emitCodeMakeFSCoords2D(builder, key, vertexCoords, &coords);
fCoefficientsUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType,
kMat44f_GrSLType, "Coefficients");
fImageIncrementUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType,
@@ -268,18 +269,17 @@ void GrGLBicubicEffect::emitCode(GrGLShaderBuilder* builder,
builder->fsCodeAppendf("\t%s = %s(%s, f.y, s0, s1, s2, s3);\n", outputColor, cubicBlendName.c_str(), coeff);
}
-GrGLEffect::EffectKey GrGLBicubicEffect::GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&) {
- const GrBicubicEffect& bicubic = drawEffect.castEffect<GrBicubicEffect>();
- EffectKey matrixKey = GrGLEffectMatrix::GenKey(bicubic.getMatrix(),
- drawEffect,
- bicubic.coordsType(),
- bicubic.texture(0));
+GrGLEffect::EffectKey GrGLBicubicEffect::GenKey(const GrEffectStage& s, const GrGLCaps&) {
+ const GrBicubicEffect& m = GetEffectFromStage<GrBicubicEffect>(s);
+ EffectKey matrixKey = GrGLEffectMatrix::GenKey(m.getMatrix(),
+ s.getCoordChangeMatrix(),
+ m.texture(0));
return matrixKey;
}
void GrGLBicubicEffect::setData(const GrGLUniformManager& uman,
- const GrDrawEffect& drawEffect) {
- const GrBicubicEffect& effect = drawEffect.castEffect<GrBicubicEffect>();
+ const GrEffectStage& stage) {
+ const GrBicubicEffect& effect = GetEffectFromStage<GrBicubicEffect>(stage);
GrTexture& texture = *effect.texture(0);
float imageIncrement[2];
imageIncrement[0] = 1.0f / texture.width();
@@ -288,7 +288,7 @@ void GrGLBicubicEffect::setData(const GrGLUniformManager& uman,
uman.setMatrix4f(fCoefficientsUni, effect.coefficients());
fEffectMatrix.setData(uman,
effect.getMatrix(),
- drawEffect,
+ stage.getCoordChangeMatrix(),
effect.texture(0));
}
diff --git a/src/effects/SkBlendImageFilter.cpp b/src/effects/SkBlendImageFilter.cpp
index 767d181dbe..ae129eb08e 100644
--- a/src/effects/SkBlendImageFilter.cpp
+++ b/src/effects/SkBlendImageFilter.cpp
@@ -94,23 +94,23 @@ bool SkBlendImageFilter::onFilterImage(Proxy* proxy,
#if SK_SUPPORT_GPU
class GrGLBlendEffect : public GrGLEffect {
public:
- GrGLBlendEffect(const GrBackendEffectFactory&, const GrDrawEffect&);
+ GrGLBlendEffect(const GrBackendEffectFactory& factory,
+ const GrEffectRef& effect);
virtual ~GrGLBlendEffect();
virtual void emitCode(GrGLShaderBuilder*,
- const GrDrawEffect&,
+ const GrEffectStage&,
EffectKey,
+ const char* vertexCoords,
const char* outputColor,
const char* inputColor,
const TextureSamplerArray&) SK_OVERRIDE;
- static inline EffectKey GenKey(const GrDrawEffect&, const GrGLCaps&);
+ static inline EffectKey GenKey(const GrEffectStage&, const GrGLCaps&);
- virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVERRIDE;
+ virtual void setData(const GrGLUniformManager&, const GrEffectStage&);
private:
- static const GrEffect::CoordsType kCoordsType = GrEffect::kLocal_CoordsType;
-
SkBlendImageFilter::Mode fMode;
GrGLEffectMatrix fForegroundEffectMatrix;
GrGLEffectMatrix fBackgroundEffectMatrix;
@@ -131,13 +131,13 @@ public:
virtual ~GrBlendEffect();
- virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE;
+ const GrBackendEffectFactory& getFactory() const;
SkBlendImageFilter::Mode mode() const { return fMode; }
typedef GrGLBlendEffect GLEffect;
static const char* Name() { return "Blend"; }
- virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags) const SK_OVERRIDE;
+ void getConstantColorComponents(GrColor* color, uint32_t* validFlags) const SK_OVERRIDE;
private:
virtual bool onIsEqual(const GrEffect&) const SK_OVERRIDE;
@@ -224,28 +224,27 @@ void GrBlendEffect::getConstantColorComponents(GrColor* color, uint32_t* validFl
///////////////////////////////////////////////////////////////////////////////
-GrGLBlendEffect::GrGLBlendEffect(const GrBackendEffectFactory& factory,
- const GrDrawEffect& drawEffect)
- : INHERITED(factory)
- , fMode(drawEffect.castEffect<GrBlendEffect>().mode())
- , fForegroundEffectMatrix(kCoordsType)
- , fBackgroundEffectMatrix(kCoordsType) {
+GrGLBlendEffect::GrGLBlendEffect(const GrBackendEffectFactory& factory, const GrEffectRef& effect)
+ : INHERITED(factory),
+ fMode(CastEffect<GrBlendEffect>(effect).mode()) {
}
GrGLBlendEffect::~GrGLBlendEffect() {
}
void GrGLBlendEffect::emitCode(GrGLShaderBuilder* builder,
- const GrDrawEffect&,
+ const GrEffectStage&,
EffectKey key,
+ const char* vertexCoords,
const char* outputColor,
const char* inputColor,
const TextureSamplerArray& samplers) {
- const GrGLShaderVar& localCoords = builder->localCoordsAttribute();
const char* fgCoords;
const char* bgCoords;
- GrSLType fgCoordsType = fForegroundEffectMatrix.emitCode(builder, key, &fgCoords, NULL, "FG");
- GrSLType bgCoordsType = fBackgroundEffectMatrix.emitCode(builder, key, &bgCoords, NULL, "BG");
+ GrSLType fgCoordsType = fForegroundEffectMatrix.emitCode(
+ builder, key, vertexCoords, &fgCoords, NULL, "FG");
+ GrSLType bgCoordsType = fBackgroundEffectMatrix.emitCode(
+ builder, key, vertexCoords, &bgCoords, NULL, "BG");
const char* bgColor = "bgColor";
const char* fgColor = "fgColor";
@@ -284,35 +283,33 @@ void GrGLBlendEffect::emitCode(GrGLShaderBuilder* builder,
}
}
-void GrGLBlendEffect::setData(const GrGLUniformManager& uman, const GrDrawEffect& drawEffect) {
- const GrBlendEffect& blend = drawEffect.castEffect<GrBlendEffect>();
+void GrGLBlendEffect::setData(const GrGLUniformManager& uman, const GrEffectStage& stage) {
+ const GrBlendEffect& blend = GetEffectFromStage<GrBlendEffect>(stage);
GrTexture* fgTex = blend.texture(0);
GrTexture* bgTex = blend.texture(1);
fForegroundEffectMatrix.setData(uman,
GrEffect::MakeDivByTextureWHMatrix(fgTex),
- drawEffect,
+ stage.getCoordChangeMatrix(),
fgTex);
fBackgroundEffectMatrix.setData(uman,
GrEffect::MakeDivByTextureWHMatrix(bgTex),
- drawEffect,
+ stage.getCoordChangeMatrix(),
bgTex);
}
-GrGLEffect::EffectKey GrGLBlendEffect::GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&) {
- const GrBlendEffect& blend = drawEffect.castEffect<GrBlendEffect>();
+GrGLEffect::EffectKey GrGLBlendEffect::GenKey(const GrEffectStage& stage, const GrGLCaps&) {
+ const GrBlendEffect& blend = GetEffectFromStage<GrBlendEffect>(stage);
GrTexture* fgTex = blend.texture(0);
GrTexture* bgTex = blend.texture(1);
EffectKey fgKey = GrGLEffectMatrix::GenKey(GrEffect::MakeDivByTextureWHMatrix(fgTex),
- drawEffect,
- kCoordsType,
+ stage.getCoordChangeMatrix(),
fgTex);
EffectKey bgKey = GrGLEffectMatrix::GenKey(GrEffect::MakeDivByTextureWHMatrix(bgTex),
- drawEffect,
- kCoordsType,
+ stage.getCoordChangeMatrix(),
bgTex);
bgKey <<= GrGLEffectMatrix::kKeyBits;
EffectKey modeKey = blend.mode() << (2 * GrGLEffectMatrix::kKeyBits);
diff --git a/src/effects/SkColorMatrixFilter.cpp b/src/effects/SkColorMatrixFilter.cpp
index 55e8bba1d7..b39c5f863f 100644
--- a/src/effects/SkColorMatrixFilter.cpp
+++ b/src/effects/SkColorMatrixFilter.cpp
@@ -386,17 +386,18 @@ public:
class GLEffect : public GrGLEffect {
public:
// this class always generates the same code.
- static EffectKey GenKey(const GrDrawEffect&, const GrGLCaps&) { return 0; }
+ static EffectKey GenKey(const GrEffectStage&, const GrGLCaps&) { return 0; }
GLEffect(const GrBackendEffectFactory& factory,
- const GrDrawEffect&)
+ const GrEffectRef& effect)
: INHERITED(factory)
, fMatrixHandle(GrGLUniformManager::kInvalidUniformHandle)
, fVectorHandle(GrGLUniformManager::kInvalidUniformHandle) {}
virtual void emitCode(GrGLShaderBuilder* builder,
- const GrDrawEffect&,
+ const GrEffectStage&,
EffectKey,
+ const char* vertexCoords,
const char* outputColor,
const char* inputColor,
const TextureSamplerArray&) SK_OVERRIDE {
@@ -423,8 +424,8 @@ public:
}
virtual void setData(const GrGLUniformManager& uniManager,
- const GrDrawEffect& drawEffect) SK_OVERRIDE {
- const ColorMatrixEffect& cme = drawEffect.castEffect<ColorMatrixEffect>();
+ const GrEffectStage& stage) SK_OVERRIDE {
+ const ColorMatrixEffect& cme = GetEffectFromStage<ColorMatrixEffect>(stage);
const float* m = cme.fMatrix.fMat;
// The GL matrix is transposed from SkColorMatrix.
GrGLfloat mt[] = {
diff --git a/src/effects/SkDisplacementMapEffect.cpp b/src/effects/SkDisplacementMapEffect.cpp
index 516afe7d3f..9c89a6a9a6 100644
--- a/src/effects/SkDisplacementMapEffect.cpp
+++ b/src/effects/SkDisplacementMapEffect.cpp
@@ -201,23 +201,22 @@ bool SkDisplacementMapEffect::onFilterImage(Proxy* proxy,
class GrGLDisplacementMapEffect : public GrGLEffect {
public:
GrGLDisplacementMapEffect(const GrBackendEffectFactory& factory,
- const GrDrawEffect& drawEffect);
+ const GrEffectRef& effect);
virtual ~GrGLDisplacementMapEffect();
virtual void emitCode(GrGLShaderBuilder*,
- const GrDrawEffect&,
+ const GrEffectStage&,
EffectKey,
+ const char* vertexCoords,
const char* outputColor,
const char* inputColor,
const TextureSamplerArray&) SK_OVERRIDE;
- static inline EffectKey GenKey(const GrDrawEffect&, const GrGLCaps&);
+ static inline EffectKey GenKey(const GrEffectStage&, const GrGLCaps&);
- virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVERRIDE;
+ virtual void setData(const GrGLUniformManager&, const GrEffectStage&);
private:
- static const GrEffect::CoordsType kCoordsType = GrEffect::kLocal_CoordsType;
-
SkDisplacementMapEffect::ChannelSelectorType fXChannelSelector;
SkDisplacementMapEffect::ChannelSelectorType fYChannelSelector;
GrGLEffectMatrix fDisplacementEffectMatrix;
@@ -246,7 +245,7 @@ public:
virtual ~GrDisplacementMapEffect();
- virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE;
+ const GrBackendEffectFactory& getFactory() const;
SkDisplacementMapEffect::ChannelSelectorType xChannelSelector() const
{ return fXChannelSelector; }
SkDisplacementMapEffect::ChannelSelectorType yChannelSelector() const
@@ -256,10 +255,9 @@ public:
typedef GrGLDisplacementMapEffect GLEffect;
static const char* Name() { return "DisplacementMap"; }
- virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags) const SK_OVERRIDE;
+ void getConstantColorComponents(GrColor* color, uint32_t* validFlags) const SK_OVERRIDE;
private:
-
virtual bool onIsEqual(const GrEffect&) const SK_OVERRIDE;
GrDisplacementMapEffect(SkDisplacementMapEffect::ChannelSelectorType xChannelSelector,
@@ -384,33 +382,32 @@ GrEffectRef* GrDisplacementMapEffect::TestCreate(SkMWCRandom* random,
///////////////////////////////////////////////////////////////////////////////
GrGLDisplacementMapEffect::GrGLDisplacementMapEffect(const GrBackendEffectFactory& factory,
- const GrDrawEffect& drawEffect)
+ const GrEffectRef& effect)
: INHERITED(factory)
- , fDisplacementEffectMatrix(kCoordsType)
- , fColorEffectMatrix(kCoordsType)
- , fXChannelSelector(drawEffect.castEffect<GrDisplacementMapEffect>().xChannelSelector())
- , fYChannelSelector(drawEffect.castEffect<GrDisplacementMapEffect>().yChannelSelector()) {
+ , fXChannelSelector(CastEffect<GrDisplacementMapEffect>(effect).xChannelSelector())
+ , fYChannelSelector(CastEffect<GrDisplacementMapEffect>(effect).yChannelSelector()) {
}
GrGLDisplacementMapEffect::~GrGLDisplacementMapEffect() {
}
void GrGLDisplacementMapEffect::emitCode(GrGLShaderBuilder* builder,
- const GrDrawEffect&,
- EffectKey key,
- const char* outputColor,
- const char* inputColor,
- const TextureSamplerArray& samplers) {
+ const GrEffectStage&,
+ EffectKey key,
+ const char* vertexCoords,
+ const char* outputColor,
+ const char* inputColor,
+ const TextureSamplerArray& samplers) {
fScaleUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType,
kVec2f_GrSLType, "Scale");
const char* scaleUni = builder->getUniformCStr(fScaleUni);
const char* dCoordsIn;
GrSLType dCoordsType = fDisplacementEffectMatrix.emitCode(
- builder, key, &dCoordsIn, NULL, "DISPL");
+ builder, key, vertexCoords, &dCoordsIn, NULL, "DISPL");
const char* cCoordsIn;
GrSLType cCoordsType = fColorEffectMatrix.emitCode(
- builder, key, &cCoordsIn, NULL, "COLOR");
+ builder, key, vertexCoords, &cCoordsIn, NULL, "COLOR");
const char* dColor = "dColor";
const char* cCoords = "cCoords";
@@ -481,19 +478,17 @@ void GrGLDisplacementMapEffect::emitCode(GrGLShaderBuilder* builder,
builder->fsCodeAppend(";\n");
}
-void GrGLDisplacementMapEffect::setData(const GrGLUniformManager& uman,
- const GrDrawEffect& drawEffect) {
- const GrDisplacementMapEffect& displacementMap =
- drawEffect.castEffect<GrDisplacementMapEffect>();
+void GrGLDisplacementMapEffect::setData(const GrGLUniformManager& uman, const GrEffectStage& stage) {
+ const GrDisplacementMapEffect& displacementMap = GetEffectFromStage<GrDisplacementMapEffect>(stage);
GrTexture* displTex = displacementMap.texture(0);
GrTexture* colorTex = displacementMap.texture(1);
fDisplacementEffectMatrix.setData(uman,
GrEffect::MakeDivByTextureWHMatrix(displTex),
- drawEffect,
+ stage.getCoordChangeMatrix(),
displTex);
fColorEffectMatrix.setData(uman,
GrEffect::MakeDivByTextureWHMatrix(colorTex),
- drawEffect,
+ stage.getCoordChangeMatrix(),
colorTex);
SkScalar scaleX = SkScalarDiv(displacementMap.scale(), SkIntToScalar(colorTex->width()));
@@ -503,22 +498,20 @@ void GrGLDisplacementMapEffect::setData(const GrGLUniformManager& uman,
SkScalarToFloat(scaleY) : SkScalarToFloat(-scaleY));
}
-GrGLEffect::EffectKey GrGLDisplacementMapEffect::GenKey(const GrDrawEffect& drawEffect,
+GrGLEffect::EffectKey GrGLDisplacementMapEffect::GenKey(const GrEffectStage& stage,
const GrGLCaps&) {
const GrDisplacementMapEffect& displacementMap =
- drawEffect.castEffect<GrDisplacementMapEffect>();
+ GetEffectFromStage<GrDisplacementMapEffect>(stage);
GrTexture* displTex = displacementMap.texture(0);
GrTexture* colorTex = displacementMap.texture(1);
EffectKey displKey = GrGLEffectMatrix::GenKey(GrEffect::MakeDivByTextureWHMatrix(displTex),
- drawEffect,
- kCoordsType,
+ stage.getCoordChangeMatrix(),
displTex);
EffectKey colorKey = GrGLEffectMatrix::GenKey(GrEffect::MakeDivByTextureWHMatrix(colorTex),
- drawEffect,
- kCoordsType,
+ stage.getCoordChangeMatrix(),
colorTex);
colorKey <<= GrGLEffectMatrix::kKeyBits;
diff --git a/src/effects/SkLightingImageFilter.cpp b/src/effects/SkLightingImageFilter.cpp
index 2d2d3b277e..177ba09c8e 100644
--- a/src/effects/SkLightingImageFilter.cpp
+++ b/src/effects/SkLightingImageFilter.cpp
@@ -980,22 +980,23 @@ SkLight* create_random_light(SkMWCRandom* random) {
class GrGLLightingEffect : public GrGLEffect {
public:
GrGLLightingEffect(const GrBackendEffectFactory& factory,
- const GrDrawEffect& effect);
+ const GrEffectRef& effect);
virtual ~GrGLLightingEffect();
virtual void emitCode(GrGLShaderBuilder*,
- const GrDrawEffect&,
+ const GrEffectStage&,
EffectKey,
+ const char* vertexCoords,
const char* outputColor,
const char* inputColor,
const TextureSamplerArray&) SK_OVERRIDE;
- static inline EffectKey GenKey(const GrDrawEffect&, const GrGLCaps&);
+ static inline EffectKey GenKey(const GrEffectStage&, const GrGLCaps&);
/**
* Subclasses of GrGLLightingEffect must call INHERITED::setData();
*/
- virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVERRIDE;
+ virtual void setData(const GrGLUniformManager&, const GrEffectStage&) SK_OVERRIDE;
protected:
virtual void emitLightFunc(GrGLShaderBuilder*, SkString* funcName) = 0;
@@ -1014,9 +1015,9 @@ private:
class GrGLDiffuseLightingEffect : public GrGLLightingEffect {
public:
GrGLDiffuseLightingEffect(const GrBackendEffectFactory& factory,
- const GrDrawEffect& drawEffect);
+ const GrEffectRef& effect);
virtual void emitLightFunc(GrGLShaderBuilder*, SkString* funcName) SK_OVERRIDE;
- virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVERRIDE;
+ virtual void setData(const GrGLUniformManager&, const GrEffectStage&) SK_OVERRIDE;
private:
typedef GrGLLightingEffect INHERITED;
@@ -1029,9 +1030,9 @@ private:
class GrGLSpecularLightingEffect : public GrGLLightingEffect {
public:
GrGLSpecularLightingEffect(const GrBackendEffectFactory& factory,
- const GrDrawEffect& effect);
+ const GrEffectRef& effect);
virtual void emitLightFunc(GrGLShaderBuilder*, SkString* funcName) SK_OVERRIDE;
- virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVERRIDE;
+ virtual void setData(const GrGLUniformManager&, const GrEffectStage&) SK_OVERRIDE;
private:
typedef GrGLLightingEffect INHERITED;
@@ -1092,12 +1093,11 @@ GrEffectRef* GrDiffuseLightingEffect::TestCreate(SkMWCRandom* random,
///////////////////////////////////////////////////////////////////////////////
GrGLLightingEffect::GrGLLightingEffect(const GrBackendEffectFactory& factory,
- const GrDrawEffect& drawEffect)
+ const GrEffectRef& effect)
: INHERITED(factory)
, fImageIncrementUni(kInvalidUniformHandle)
- , fSurfaceScaleUni(kInvalidUniformHandle)
- , fEffectMatrix(drawEffect.castEffect<GrLightingEffect>().coordsType()) {
- const GrLightingEffect& m = drawEffect.castEffect<GrLightingEffect>();
+ , fSurfaceScaleUni(kInvalidUniformHandle) {
+ const GrLightingEffect& m = CastEffect<GrLightingEffect>(effect);
fLight = m.light()->createGLLight();
}
@@ -1106,14 +1106,14 @@ GrGLLightingEffect::~GrGLLightingEffect() {
}
void GrGLLightingEffect::emitCode(GrGLShaderBuilder* builder,
- const GrDrawEffect&,
+ const GrEffectStage&,
EffectKey key,
+ const char* vertexCoords,
const char* outputColor,
const char* inputColor,
const TextureSamplerArray& samplers) {
const char* coords;
- const GrGLShaderVar& localCoords = builder->localCoordsAttribute();
- fEffectMatrix.emitCodeMakeFSCoords2D(builder, key, &coords);
+ fEffectMatrix.emitCodeMakeFSCoords2D(builder, key, vertexCoords, &coords);
fImageIncrementUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType,
kVec2f_GrSLType,
@@ -1207,30 +1207,28 @@ void GrGLLightingEffect::emitCode(GrGLShaderBuilder* builder,
builder->fsCodeAppend(modulate.c_str());
}
-GrGLEffect::EffectKey GrGLLightingEffect::GenKey(const GrDrawEffect& drawEffect,
+GrGLEffect::EffectKey GrGLLightingEffect::GenKey(const GrEffectStage& s,
const GrGLCaps& caps) {
- const GrLightingEffect& lighting = drawEffect.castEffect<GrLightingEffect>();
- EffectKey key = lighting.light()->type();
+ const GrLightingEffect& effect = GetEffectFromStage<GrLightingEffect>(s);
+ EffectKey key = effect.light()->type();
key <<= GrGLEffectMatrix::kKeyBits;
- EffectKey matrixKey = GrGLEffectMatrix::GenKey(lighting.getMatrix(),
- drawEffect,
- lighting.coordsType(),
- lighting.texture(0));
+ EffectKey matrixKey = GrGLEffectMatrix::GenKey(effect.getMatrix(),
+ s.getCoordChangeMatrix(),
+ effect.texture(0));
return key | matrixKey;
}
-void GrGLLightingEffect::setData(const GrGLUniformManager& uman,
- const GrDrawEffect& drawEffect) {
- const GrLightingEffect& lighting = drawEffect.castEffect<GrLightingEffect>();
- GrTexture* texture = lighting.texture(0);
+void GrGLLightingEffect::setData(const GrGLUniformManager& uman, const GrEffectStage& stage) {
+ const GrLightingEffect& effect = GetEffectFromStage<GrLightingEffect>(stage);
+ GrTexture* texture = effect.texture(0);
float ySign = texture->origin() == kTopLeft_GrSurfaceOrigin ? -1.0f : 1.0f;
uman.set2f(fImageIncrementUni, 1.0f / texture->width(), ySign / texture->height());
- uman.set1f(fSurfaceScaleUni, lighting.surfaceScale());
- fLight->setData(uman, lighting.light());
+ uman.set1f(fSurfaceScaleUni, effect.surfaceScale());
+ fLight->setData(uman, effect.light());
fEffectMatrix.setData(uman,
- lighting.getMatrix(),
- drawEffect,
- lighting.texture(0));
+ effect.getMatrix(),
+ stage.getCoordChangeMatrix(),
+ effect.texture(0));
}
///////////////////////////////////////////////////////////////////////////////
@@ -1238,8 +1236,8 @@ void GrGLLightingEffect::setData(const GrGLUniformManager& uman,
///////////////////////////////////////////////////////////////////////////////
GrGLDiffuseLightingEffect::GrGLDiffuseLightingEffect(const GrBackendEffectFactory& factory,
- const GrDrawEffect& drawEffect)
- : INHERITED(factory, drawEffect)
+ const GrEffectRef& effect)
+ : INHERITED(factory, effect)
, fKDUni(kInvalidUniformHandle) {
}
@@ -1268,10 +1266,10 @@ void GrGLDiffuseLightingEffect::emitLightFunc(GrGLShaderBuilder* builder, SkStri
}
void GrGLDiffuseLightingEffect::setData(const GrGLUniformManager& uman,
- const GrDrawEffect& drawEffect) {
- INHERITED::setData(uman, drawEffect);
- const GrDiffuseLightingEffect& diffuse = drawEffect.castEffect<GrDiffuseLightingEffect>();
- uman.set1f(fKDUni, diffuse.kd());
+ const GrEffectStage& stage) {
+ INHERITED::setData(uman, stage);
+ const GrDiffuseLightingEffect& effect = GetEffectFromStage<GrDiffuseLightingEffect>(stage);
+ uman.set1f(fKDUni, effect.kd());
}
///////////////////////////////////////////////////////////////////////////////
@@ -1309,8 +1307,8 @@ GrEffectRef* GrSpecularLightingEffect::TestCreate(SkMWCRandom* random,
///////////////////////////////////////////////////////////////////////////////
GrGLSpecularLightingEffect::GrGLSpecularLightingEffect(const GrBackendEffectFactory& factory,
- const GrDrawEffect& drawEffect)
- : GrGLLightingEffect(factory, drawEffect)
+ const GrEffectRef& effect)
+ : GrGLLightingEffect(factory, effect)
, fKSUni(kInvalidUniformHandle)
, fShininessUni(kInvalidUniformHandle) {
}
@@ -1344,11 +1342,11 @@ void GrGLSpecularLightingEffect::emitLightFunc(GrGLShaderBuilder* builder, SkStr
}
void GrGLSpecularLightingEffect::setData(const GrGLUniformManager& uman,
- const GrDrawEffect& drawEffect) {
- INHERITED::setData(uman, drawEffect);
- const GrSpecularLightingEffect& spec = drawEffect.castEffect<GrSpecularLightingEffect>();
- uman.set1f(fKSUni, spec.ks());
- uman.set1f(fShininessUni, spec.shininess());
+ const GrEffectStage& stage) {
+ INHERITED::setData(uman, stage);
+ const GrSpecularLightingEffect& effect = GetEffectFromStage<GrSpecularLightingEffect>(stage);
+ uman.set1f(fKSUni, effect.ks());
+ uman.set1f(fShininessUni, effect.shininess());
}
///////////////////////////////////////////////////////////////////////////////
@@ -1362,7 +1360,8 @@ void GrGLLight::emitLightColor(GrGLShaderBuilder* builder,
builder->fsCodeAppend(builder->getUniformCStr(this->lightColorUni()));
}
-void GrGLLight::setData(const GrGLUniformManager& uman, const SkLight* light) const {
+void GrGLLight::setData(const GrGLUniformManager& uman,
+ const SkLight* light) const {
setUniformPoint3(uman, fColorUni, light->color() * SkScalarInvert(SkIntToScalar(255)));
}
@@ -1384,7 +1383,8 @@ void GrGLDistantLight::emitSurfaceToLight(GrGLShaderBuilder* builder, const char
///////////////////////////////////////////////////////////////////////////////
-void GrGLPointLight::setData(const GrGLUniformManager& uman, const SkLight* light) const {
+void GrGLPointLight::setData(const GrGLUniformManager& uman,
+ const SkLight* light) const {
INHERITED::setData(uman, light);
SkASSERT(light->type() == SkLight::kPoint_LightType);
const SkPointLight* pointLight = static_cast<const SkPointLight*>(light);
@@ -1400,7 +1400,8 @@ void GrGLPointLight::emitSurfaceToLight(GrGLShaderBuilder* builder, const char*
///////////////////////////////////////////////////////////////////////////////
-void GrGLSpotLight::setData(const GrGLUniformManager& uman, const SkLight* light) const {
+void GrGLSpotLight::setData(const GrGLUniformManager& uman,
+ const SkLight* light) const {
INHERITED::setData(uman, light);
SkASSERT(light->type() == SkLight::kSpot_LightType);
const SkSpotLight* spotLight = static_cast<const SkSpotLight *>(light);
diff --git a/src/effects/SkMagnifierImageFilter.cpp b/src/effects/SkMagnifierImageFilter.cpp
index 0c4cde15c2..215ebc0872 100644
--- a/src/effects/SkMagnifierImageFilter.cpp
+++ b/src/effects/SkMagnifierImageFilter.cpp
@@ -92,20 +92,22 @@ typedef GrGLUniformManager::UniformHandle UniformHandle;
class GrGLMagnifierEffect : public GrGLEffect {
public:
- GrGLMagnifierEffect(const GrBackendEffectFactory&, const GrDrawEffect&);
+ GrGLMagnifierEffect(const GrBackendEffectFactory& factory, const GrEffectRef& effect);
virtual void emitCode(GrGLShaderBuilder*,
- const GrDrawEffect&,
+ const GrEffectStage&,
EffectKey,
+ const char* vertexCoords,
const char* outputColor,
const char* inputColor,
const TextureSamplerArray&) SK_OVERRIDE;
- virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVERRIDE;
+ virtual void setData(const GrGLUniformManager& uman, const GrEffectStage& stage) SK_OVERRIDE;
- static inline EffectKey GenKey(const GrDrawEffect&, const GrGLCaps&);
+ static inline EffectKey GenKey(const GrEffectStage&, const GrGLCaps&);
private:
+
UniformHandle fOffsetVar;
UniformHandle fZoomVar;
UniformHandle fInsetVar;
@@ -115,23 +117,22 @@ private:
typedef GrGLEffect INHERITED;
};
-GrGLMagnifierEffect::GrGLMagnifierEffect(const GrBackendEffectFactory& factory,
- const GrDrawEffect& drawEffect)
+GrGLMagnifierEffect::GrGLMagnifierEffect(const GrBackendEffectFactory& factory, const GrEffectRef&)
: INHERITED(factory)
, fOffsetVar(GrGLUniformManager::kInvalidUniformHandle)
, fZoomVar(GrGLUniformManager::kInvalidUniformHandle)
- , fInsetVar(GrGLUniformManager::kInvalidUniformHandle)
- , fEffectMatrix(drawEffect.castEffect<GrMagnifierEffect>().coordsType()) {
+ , fInsetVar(GrGLUniformManager::kInvalidUniformHandle) {
}
void GrGLMagnifierEffect::emitCode(GrGLShaderBuilder* builder,
- const GrDrawEffect&,
+ const GrEffectStage&,
EffectKey key,
+ const char* vertexCoords,
const char* outputColor,
const char* inputColor,
const TextureSamplerArray& samplers) {
const char* coords;
- fEffectMatrix.emitCodeMakeFSCoords2D(builder, key, &coords);
+ fEffectMatrix.emitCodeMakeFSCoords2D(builder, key, vertexCoords, &coords);
fOffsetVar = builder->addUniform(
GrGLShaderBuilder::kFragment_ShaderType |
GrGLShaderBuilder::kVertex_ShaderType,
@@ -178,20 +179,18 @@ void GrGLMagnifierEffect::emitCode(GrGLShaderBuilder* builder,
}
void GrGLMagnifierEffect::setData(const GrGLUniformManager& uman,
- const GrDrawEffect& drawEffect) {
- const GrMagnifierEffect& zoom = drawEffect.castEffect<GrMagnifierEffect>();
+ const GrEffectStage& stage) {
+ const GrMagnifierEffect& zoom = GetEffectFromStage<GrMagnifierEffect>(stage);
uman.set2f(fOffsetVar, zoom.x_offset(), zoom.y_offset());
uman.set2f(fZoomVar, zoom.x_zoom(), zoom.y_zoom());
uman.set2f(fInsetVar, zoom.x_inset(), zoom.y_inset());
- fEffectMatrix.setData(uman, zoom.getMatrix(), drawEffect, zoom.texture(0));
+ fEffectMatrix.setData(uman, zoom.getMatrix(), stage.getCoordChangeMatrix(), zoom.texture(0));
}
-GrGLEffect::EffectKey GrGLMagnifierEffect::GenKey(const GrDrawEffect& drawEffect,
- const GrGLCaps&) {
- const GrMagnifierEffect& zoom = drawEffect.castEffect<GrMagnifierEffect>();
+GrGLEffect::EffectKey GrGLMagnifierEffect::GenKey(const GrEffectStage& stage, const GrGLCaps&) {
+ const GrMagnifierEffect& zoom = GetEffectFromStage<GrMagnifierEffect>(stage);
return GrGLEffectMatrix::GenKey(zoom.getMatrix(),
- drawEffect,
- zoom.coordsType(),
+ stage.getCoordChangeMatrix(),
zoom.texture(0));
}
diff --git a/src/effects/SkMatrixConvolutionImageFilter.cpp b/src/effects/SkMatrixConvolutionImageFilter.cpp
index c4cffeafab..cda4f28081 100644
--- a/src/effects/SkMatrixConvolutionImageFilter.cpp
+++ b/src/effects/SkMatrixConvolutionImageFilter.cpp
@@ -284,6 +284,8 @@ public:
typedef GrGLMatrixConvolutionEffect GLEffect;
+
+
virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE;
private:
@@ -314,17 +316,18 @@ private:
class GrGLMatrixConvolutionEffect : public GrGLEffect {
public:
GrGLMatrixConvolutionEffect(const GrBackendEffectFactory& factory,
- const GrDrawEffect& effect);
+ const GrEffectRef& effect);
virtual void emitCode(GrGLShaderBuilder*,
- const GrDrawEffect&,
+ const GrEffectStage&,
EffectKey,
+ const char* vertexCoords,
const char* outputColor,
const char* inputColor,
const TextureSamplerArray&) SK_OVERRIDE;
- static inline EffectKey GenKey(const GrDrawEffect&, const GrGLCaps&);
+ static inline EffectKey GenKey(const GrEffectStage&, const GrGLCaps&);
- virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVERRIDE;
+ virtual void setData(const GrGLUniformManager&, const GrEffectStage&) SK_OVERRIDE;
private:
typedef GrGLUniformManager::UniformHandle UniformHandle;
@@ -345,15 +348,14 @@ private:
};
GrGLMatrixConvolutionEffect::GrGLMatrixConvolutionEffect(const GrBackendEffectFactory& factory,
- const GrDrawEffect& drawEffect)
+ const GrEffectRef& effect)
: INHERITED(factory)
, fKernelUni(GrGLUniformManager::kInvalidUniformHandle)
, fImageIncrementUni(GrGLUniformManager::kInvalidUniformHandle)
, fTargetUni(GrGLUniformManager::kInvalidUniformHandle)
, fGainUni(GrGLUniformManager::kInvalidUniformHandle)
- , fBiasUni(GrGLUniformManager::kInvalidUniformHandle)
- , fEffectMatrix(drawEffect.castEffect<GrMatrixConvolutionEffect>().coordsType()) {
- const GrMatrixConvolutionEffect& m = drawEffect.castEffect<GrMatrixConvolutionEffect>();
+ , fBiasUni(GrGLUniformManager::kInvalidUniformHandle) {
+ const GrMatrixConvolutionEffect& m = CastEffect<GrMatrixConvolutionEffect>(effect);
fKernelSize = m.kernelSize();
fTileMode = m.tileMode();
fConvolveAlpha = m.convolveAlpha();
@@ -381,13 +383,14 @@ static void appendTextureLookup(GrGLShaderBuilder* builder,
}
void GrGLMatrixConvolutionEffect::emitCode(GrGLShaderBuilder* builder,
- const GrDrawEffect&,
+ const GrEffectStage&,
EffectKey key,
+ const char* vertexCoords,
const char* outputColor,
const char* inputColor,
const TextureSamplerArray& samplers) {
const char* coords;
- fEffectMatrix.emitCodeMakeFSCoords2D(builder, key, &coords);
+ fEffectMatrix.emitCodeMakeFSCoords2D(builder, key, vertexCoords, &coords);
fImageIncrementUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType,
kVec2f_GrSLType, "ImageIncrement");
fKernelUni = builder->addUniformArray(GrGLShaderBuilder::kFragment_ShaderType,
@@ -447,40 +450,38 @@ int encodeXY(int x, int y) {
};
-GrGLEffect::EffectKey GrGLMatrixConvolutionEffect::GenKey(const GrDrawEffect& drawEffect,
- const GrGLCaps&) {
- const GrMatrixConvolutionEffect& m = drawEffect.castEffect<GrMatrixConvolutionEffect>();
+GrGLEffect::EffectKey GrGLMatrixConvolutionEffect::GenKey(const GrEffectStage& s, const GrGLCaps&) {
+ const GrMatrixConvolutionEffect& m = GetEffectFromStage<GrMatrixConvolutionEffect>(s);
EffectKey key = encodeXY(m.kernelSize().width(), m.kernelSize().height());
key |= m.tileMode() << 7;
key |= m.convolveAlpha() ? 1 << 9 : 0;
key <<= GrGLEffectMatrix::kKeyBits;
EffectKey matrixKey = GrGLEffectMatrix::GenKey(m.getMatrix(),
- drawEffect,
- m.coordsType(),
+ s.getCoordChangeMatrix(),
m.texture(0));
return key | matrixKey;
}
void GrGLMatrixConvolutionEffect::setData(const GrGLUniformManager& uman,
- const GrDrawEffect& drawEffect) {
- const GrMatrixConvolutionEffect& conv = drawEffect.castEffect<GrMatrixConvolutionEffect>();
- GrTexture& texture = *conv.texture(0);
+ const GrEffectStage& stage) {
+ const GrMatrixConvolutionEffect& effect = GetEffectFromStage<GrMatrixConvolutionEffect>(stage);
+ GrTexture& texture = *effect.texture(0);
// the code we generated was for a specific kernel size
- GrAssert(conv.kernelSize() == fKernelSize);
- GrAssert(conv.tileMode() == fTileMode);
+ GrAssert(effect.kernelSize() == fKernelSize);
+ GrAssert(effect.tileMode() == fTileMode);
float imageIncrement[2];
float ySign = texture.origin() == kTopLeft_GrSurfaceOrigin ? 1.0f : -1.0f;
imageIncrement[0] = 1.0f / texture.width();
imageIncrement[1] = ySign / texture.height();
uman.set2fv(fImageIncrementUni, 0, 1, imageIncrement);
- uman.set2fv(fTargetUni, 0, 1, conv.target());
- uman.set1fv(fKernelUni, 0, fKernelSize.width() * fKernelSize.height(), conv.kernel());
- uman.set1f(fGainUni, conv.gain());
- uman.set1f(fBiasUni, conv.bias());
+ uman.set2fv(fTargetUni, 0, 1, effect.target());
+ uman.set1fv(fKernelUni, 0, fKernelSize.width() * fKernelSize.height(), effect.kernel());
+ uman.set1f(fGainUni, effect.gain());
+ uman.set1f(fBiasUni, effect.bias());
fEffectMatrix.setData(uman,
- conv.getMatrix(),
- drawEffect,
- conv.texture(0));
+ effect.getMatrix(),
+ stage.getCoordChangeMatrix(),
+ effect.texture(0));
}
GrMatrixConvolutionEffect::GrMatrixConvolutionEffect(GrTexture* texture,
diff --git a/src/effects/SkMorphologyImageFilter.cpp b/src/effects/SkMorphologyImageFilter.cpp
index f2b37f2a8a..bca18e668f 100644
--- a/src/effects/SkMorphologyImageFilter.cpp
+++ b/src/effects/SkMorphologyImageFilter.cpp
@@ -278,18 +278,19 @@ private:
class GrGLMorphologyEffect : public GrGLEffect {
public:
- GrGLMorphologyEffect (const GrBackendEffectFactory&, const GrDrawEffect&);
+ GrGLMorphologyEffect (const GrBackendEffectFactory&, const GrEffectRef&);
virtual void emitCode(GrGLShaderBuilder*,
- const GrDrawEffect&,
+ const GrEffectStage&,
EffectKey,
+ const char* vertexCoords,
const char* outputColor,
const char* inputColor,
const TextureSamplerArray&) SK_OVERRIDE;
- static inline EffectKey GenKey(const GrDrawEffect&, const GrGLCaps&);
+ static inline EffectKey GenKey(const GrEffectStage&, const GrGLCaps&);
- virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVERRIDE;
+ virtual void setData(const GrGLUniformManager&, const GrEffectStage&) SK_OVERRIDE;
private:
int width() const { return GrMorphologyEffect::WidthFromRadius(fRadius); }
@@ -303,23 +304,23 @@ private:
};
GrGLMorphologyEffect::GrGLMorphologyEffect(const GrBackendEffectFactory& factory,
- const GrDrawEffect& drawEffect)
+ const GrEffectRef& effect)
: INHERITED(factory)
- , fImageIncrementUni(GrGLUniformManager::kInvalidUniformHandle)
- , fEffectMatrix(drawEffect.castEffect<GrMorphologyEffect>().coordsType()) {
- const GrMorphologyEffect& m = drawEffect.castEffect<GrMorphologyEffect>();
+ , fImageIncrementUni(GrGLUniformManager::kInvalidUniformHandle) {
+ const GrMorphologyEffect& m = CastEffect<GrMorphologyEffect>(effect);
fRadius = m.radius();
fType = m.type();
}
void GrGLMorphologyEffect::emitCode(GrGLShaderBuilder* builder,
- const GrDrawEffect&,
+ const GrEffectStage&,
EffectKey key,
+ const char* vertexCoords,
const char* outputColor,
const char* inputColor,
const TextureSamplerArray& samplers) {
const char* coords;
- fEffectMatrix.emitCodeMakeFSCoords2D(builder, key, &coords);
+ fEffectMatrix.emitCodeMakeFSCoords2D(builder, key, vertexCoords, &coords);
fImageIncrementUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType,
kVec2f_GrSLType, "ImageIncrement");
@@ -352,22 +353,19 @@ void GrGLMorphologyEffect::emitCode(GrGLShaderBuilder* builder,
builder->fsCodeAppend(modulate.c_str());
}
-GrGLEffect::EffectKey GrGLMorphologyEffect::GenKey(const GrDrawEffect& drawEffect,
- const GrGLCaps&) {
- const GrMorphologyEffect& m = drawEffect.castEffect<GrMorphologyEffect>();
+GrGLEffect::EffectKey GrGLMorphologyEffect::GenKey(const GrEffectStage& s, const GrGLCaps&) {
+ const GrMorphologyEffect& m = GetEffectFromStage<GrMorphologyEffect>(s);
EffectKey key = static_cast<EffectKey>(m.radius());
key |= (m.type() << 8);
key <<= GrGLEffectMatrix::kKeyBits;
EffectKey matrixKey = GrGLEffectMatrix::GenKey(m.getMatrix(),
- drawEffect,
- m.coordsType(),
+ s.getCoordChangeMatrix(),
m.texture(0));
return key | matrixKey;
}
-void GrGLMorphologyEffect::setData(const GrGLUniformManager& uman,
- const GrDrawEffect& drawEffect) {
- const Gr1DKernelEffect& kern = drawEffect.castEffect<Gr1DKernelEffect>();
+void GrGLMorphologyEffect::setData(const GrGLUniformManager& uman, const GrEffectStage& stage) {
+ const Gr1DKernelEffect& kern = GetEffectFromStage<Gr1DKernelEffect>(stage);
GrTexture& texture = *kern.texture(0);
// the code we generated was for a specific kernel radius
GrAssert(kern.radius() == fRadius);
@@ -383,7 +381,7 @@ void GrGLMorphologyEffect::setData(const GrGLUniformManager& uman,
GrCrash("Unknown filter direction.");
}
uman.set2fv(fImageIncrementUni, 0, 1, imageIncrement);
- fEffectMatrix.setData(uman, kern.getMatrix(), drawEffect, kern.texture(0));
+ fEffectMatrix.setData(uman, kern.getMatrix(), stage.getCoordChangeMatrix(), kern.texture(0));
}
///////////////////////////////////////////////////////////////////////////////
diff --git a/src/effects/SkTableColorFilter.cpp b/src/effects/SkTableColorFilter.cpp
index e0c497806d..16f2876af0 100644
--- a/src/effects/SkTableColorFilter.cpp
+++ b/src/effects/SkTableColorFilter.cpp
@@ -256,31 +256,33 @@ private:
class GLColorTableEffect : public GrGLEffect {
public:
- GLColorTableEffect(const GrBackendEffectFactory&, const GrDrawEffect&);
+ GLColorTableEffect(const GrBackendEffectFactory&, const GrEffectRef&);
virtual void emitCode(GrGLShaderBuilder*,
- const GrDrawEffect&,
+ const GrEffectStage&,
EffectKey,
+ const char* vertexCoords,
const char* outputColor,
const char* inputColor,
const TextureSamplerArray&) SK_OVERRIDE;
- virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVERRIDE {}
+ virtual void setData(const GrGLUniformManager&, const GrEffectStage&) SK_OVERRIDE {}
- static EffectKey GenKey(const GrDrawEffect&, const GrGLCaps&);
+ static EffectKey GenKey(const GrEffectStage&, const GrGLCaps&);
private:
typedef GrGLEffect INHERITED;
};
-GLColorTableEffect::GLColorTableEffect(const GrBackendEffectFactory& factory, const GrDrawEffect&)
+GLColorTableEffect::GLColorTableEffect(const GrBackendEffectFactory& factory, const GrEffectRef&)
: INHERITED(factory) {
}
void GLColorTableEffect::emitCode(GrGLShaderBuilder* builder,
- const GrDrawEffect&,
+ const GrEffectStage&,
EffectKey,
+ const char* vertexCoords,
const char* outputColor,
const char* inputColor,
const TextureSamplerArray& samplers) {
@@ -321,7 +323,7 @@ void GLColorTableEffect::emitCode(GrGLShaderBuilder* builder,
builder->fsCodeAppendf("\t\t%s.rgb *= %s.a;\n", outputColor, outputColor);
}
-GrGLEffect::EffectKey GLColorTableEffect::GenKey(const GrDrawEffect&, const GrGLCaps&) {
+GrGLEffect::EffectKey GLColorTableEffect::GenKey(const GrEffectStage&, const GrGLCaps&) {
return 0;
}
diff --git a/src/effects/gradients/SkGradientShader.cpp b/src/effects/gradients/SkGradientShader.cpp
index d3b2fd41f8..1158dcf92a 100644
--- a/src/effects/gradients/SkGradientShader.cpp
+++ b/src/effects/gradients/SkGradientShader.cpp
@@ -734,14 +734,12 @@ SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
#if SK_SUPPORT_GPU
#include "effects/GrTextureStripAtlas.h"
-#include "GrTBackendEffectFactory.h"
#include "SkGr.h"
GrGLGradientEffect::GrGLGradientEffect(const GrBackendEffectFactory& factory)
: INHERITED(factory)
, fCachedYCoord(SK_ScalarMax)
- , fFSYUni(GrGLUniformManager::kInvalidUniformHandle)
- , fEffectMatrix(kCoordsType) {
+ , fFSYUni(GrGLUniformManager::kInvalidUniformHandle) {
}
GrGLGradientEffect::~GrGLGradientEffect() { }
@@ -751,11 +749,10 @@ void GrGLGradientEffect::emitYCoordUniform(GrGLShaderBuilder* builder) {
kFloat_GrSLType, "GradientYCoordFS");
}
-void GrGLGradientEffect::setData(const GrGLUniformManager& uman,
- const GrDrawEffect& drawEffect) {
- const GrGradientEffect& e = drawEffect.castEffect<GrGradientEffect>();
+void GrGLGradientEffect::setData(const GrGLUniformManager& uman, const GrEffectStage& stage) {
+ const GrGradientEffect& e = GetEffectFromStage<GrGradientEffect>(stage);
const GrTexture* texture = e.texture(0);
- fEffectMatrix.setData(uman, e.getMatrix(), drawEffect, texture);
+ fEffectMatrix.setData(uman, e.getMatrix(), stage.getCoordChangeMatrix(), texture);
SkScalar yCoord = e.getYCoord();
if (yCoord != fCachedYCoord) {
@@ -764,19 +761,21 @@ void GrGLGradientEffect::setData(const GrGLUniformManager& uman,
}
}
-GrGLEffect::EffectKey GrGLGradientEffect::GenMatrixKey(const GrDrawEffect& drawEffect) {
- const GrGradientEffect& e = drawEffect.castEffect<GrGradientEffect>();
+GrGLEffect::EffectKey GrGLGradientEffect::GenMatrixKey(const GrEffectStage& s) {
+ const GrGradientEffect& e = GetEffectFromStage<GrGradientEffect>(s);
const GrTexture* texture = e.texture(0);
- return GrGLEffectMatrix::GenKey(e.getMatrix(), drawEffect, kCoordsType, texture);
+ return GrGLEffectMatrix::GenKey(e.getMatrix(), s.getCoordChangeMatrix(), texture);
}
void GrGLGradientEffect::setupMatrix(GrGLShaderBuilder* builder,
EffectKey key,
+ const char* vertexCoords,
const char** fsCoordName,
const char** vsVaryingName,
GrSLType* vsVaryingType) {
fEffectMatrix.emitCodeMakeFSCoords2D(builder,
key & kMatrixKeyMask,
+ vertexCoords,
fsCoordName,
vsVaryingName,
vsVaryingType);
diff --git a/src/effects/gradients/SkGradientShaderPriv.h b/src/effects/gradients/SkGradientShaderPriv.h
index b9dbf1b87b..271a2b6e51 100644
--- a/src/effects/gradients/SkGradientShaderPriv.h
+++ b/src/effects/gradients/SkGradientShaderPriv.h
@@ -274,7 +274,7 @@ public:
GrGLGradientEffect(const GrBackendEffectFactory& factory);
virtual ~GrGLGradientEffect();
- virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVERRIDE;
+ virtual void setData(const GrGLUniformManager&, const GrEffectStage&) SK_OVERRIDE;
protected:
/**
@@ -290,7 +290,7 @@ protected:
* Subclasses must call this. It will return a value restricted to the lower kMatrixKeyBitCnt
* bits.
*/
- static EffectKey GenMatrixKey(const GrDrawEffect&);
+ static EffectKey GenMatrixKey(const GrEffectStage& s);
/**
* Inserts code to implement the GrGradientEffect's matrix. This should be called before a
@@ -302,6 +302,7 @@ protected:
*/
void setupMatrix(GrGLShaderBuilder* builder,
EffectKey key,
+ const char* vertexCoords,
const char** fsCoordName,
const char** vsVaryingName = NULL,
GrSLType* vsVaryingType = NULL);
@@ -320,8 +321,6 @@ protected:
const GrGLShaderBuilder::TextureSampler&);
private:
- static const GrEffect::CoordsType kCoordsType = GrEffect::kLocal_CoordsType;
-
SkScalar fCachedYCoord;
GrGLUniformManager::UniformHandle fFSYUni;
GrGLEffectMatrix fEffectMatrix;
diff --git a/src/effects/gradients/SkLinearGradient.cpp b/src/effects/gradients/SkLinearGradient.cpp
index 76168a932d..3f8d7cccba 100644
--- a/src/effects/gradients/SkLinearGradient.cpp
+++ b/src/effects/gradients/SkLinearGradient.cpp
@@ -453,20 +453,21 @@ void SkLinearGradient::shadeSpan16(int x, int y,
class GrGLLinearGradient : public GrGLGradientEffect {
public:
- GrGLLinearGradient(const GrBackendEffectFactory& factory, const GrDrawEffect&)
+ GrGLLinearGradient(const GrBackendEffectFactory& factory, const GrEffectRef&)
: INHERITED (factory) { }
virtual ~GrGLLinearGradient() { }
virtual void emitCode(GrGLShaderBuilder*,
- const GrDrawEffect&,
+ const GrEffectStage&,
EffectKey,
+ const char* vertexCoords,
const char* outputColor,
const char* inputColor,
const TextureSamplerArray&) SK_OVERRIDE;
- static EffectKey GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&) {
- return GenMatrixKey(drawEffect);
+ static EffectKey GenKey(const GrEffectStage& stage, const GrGLCaps&) {
+ return GenMatrixKey(stage);
}
private:
@@ -532,14 +533,15 @@ GrEffectRef* GrLinearGradient::TestCreate(SkMWCRandom* random,
/////////////////////////////////////////////////////////////////////
void GrGLLinearGradient::emitCode(GrGLShaderBuilder* builder,
- const GrDrawEffect&,
+ const GrEffectStage& stage,
EffectKey key,
+ const char* vertexCoords,
const char* outputColor,
const char* inputColor,
const TextureSamplerArray& samplers) {
this->emitYCoordUniform(builder);
const char* coords;
- this->setupMatrix(builder, key, &coords);
+ this->setupMatrix(builder, key, vertexCoords, &coords);
SkString t;
t.append(coords);
t.append(".x");
diff --git a/src/effects/gradients/SkRadialGradient.cpp b/src/effects/gradients/SkRadialGradient.cpp
index a80cb810af..3f670ad629 100644
--- a/src/effects/gradients/SkRadialGradient.cpp
+++ b/src/effects/gradients/SkRadialGradient.cpp
@@ -474,18 +474,19 @@ class GrGLRadialGradient : public GrGLGradientEffect {
public:
GrGLRadialGradient(const GrBackendEffectFactory& factory,
- const GrDrawEffect&) : INHERITED (factory) { }
+ const GrEffectRef&) : INHERITED (factory) { }
virtual ~GrGLRadialGradient() { }
virtual void emitCode(GrGLShaderBuilder*,
- const GrDrawEffect&,
+ const GrEffectStage&,
EffectKey,
+ const char* vertexCoords,
const char* outputColor,
const char* inputColor,
const TextureSamplerArray&) SK_OVERRIDE;
- static EffectKey GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&) {
- return GenMatrixKey(drawEffect);
+ static EffectKey GenKey(const GrEffectStage& stage, const GrGLCaps&) {
+ return GenMatrixKey(stage);
}
private:
@@ -553,14 +554,15 @@ GrEffectRef* GrRadialGradient::TestCreate(SkMWCRandom* random,
/////////////////////////////////////////////////////////////////////
void GrGLRadialGradient::emitCode(GrGLShaderBuilder* builder,
- const GrDrawEffect&,
+ const GrEffectStage&,
EffectKey key,
+ const char* vertexCoords,
const char* outputColor,
const char* inputColor,
const TextureSamplerArray& samplers) {
this->emitYCoordUniform(builder);
const char* coords;
- this->setupMatrix(builder, key, &coords);
+ this->setupMatrix(builder, key, vertexCoords, &coords);
SkString t("length(");
t.append(coords);
t.append(")");
diff --git a/src/effects/gradients/SkSweepGradient.cpp b/src/effects/gradients/SkSweepGradient.cpp
index 9d24d40106..44b03d6b87 100644
--- a/src/effects/gradients/SkSweepGradient.cpp
+++ b/src/effects/gradients/SkSweepGradient.cpp
@@ -391,18 +391,19 @@ class GrGLSweepGradient : public GrGLGradientEffect {
public:
GrGLSweepGradient(const GrBackendEffectFactory& factory,
- const GrDrawEffect&) : INHERITED (factory) { }
+ const GrEffectRef&) : INHERITED (factory) { }
virtual ~GrGLSweepGradient() { }
virtual void emitCode(GrGLShaderBuilder*,
- const GrDrawEffect&,
+ const GrEffectStage&,
EffectKey,
+ const char* vertexCoords,
const char* outputColor,
const char* inputColor,
const TextureSamplerArray&) SK_OVERRIDE;
- static EffectKey GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&) {
- return GenMatrixKey(drawEffect);
+ static EffectKey GenKey(const GrEffectStage& stage, const GrGLCaps&) {
+ return GenMatrixKey(stage);
}
private:
@@ -463,14 +464,15 @@ GrEffectRef* GrSweepGradient::TestCreate(SkMWCRandom* random,
/////////////////////////////////////////////////////////////////////
void GrGLSweepGradient::emitCode(GrGLShaderBuilder* builder,
- const GrDrawEffect&,
+ const GrEffectStage&,
EffectKey key,
+ const char* vertexCoords,
const char* outputColor,
const char* inputColor,
const TextureSamplerArray& samplers) {
this->emitYCoordUniform(builder);
const char* coords;
- this->setupMatrix(builder, key, &coords);
+ this->setupMatrix(builder, key, vertexCoords, &coords);
SkString t;
t.printf("atan(- %s.y, - %s.x) * 0.1591549430918 + 0.5", coords, coords);
this->emitColorLookup(builder, t.c_str(), outputColor, inputColor, samplers[0]);
diff --git a/src/effects/gradients/SkTwoPointConicalGradient.cpp b/src/effects/gradients/SkTwoPointConicalGradient.cpp
index 0b6e30de39..04cf1ebfe5 100644
--- a/src/effects/gradients/SkTwoPointConicalGradient.cpp
+++ b/src/effects/gradients/SkTwoPointConicalGradient.cpp
@@ -343,18 +343,20 @@ static const UniformHandle kInvalidUniformHandle = GrGLUniformManager::kInvalidU
class GrGLConical2Gradient : public GrGLGradientEffect {
public:
- GrGLConical2Gradient(const GrBackendEffectFactory& factory, const GrDrawEffect&);
+ GrGLConical2Gradient(const GrBackendEffectFactory& factory,
+ const GrEffectRef&);
virtual ~GrGLConical2Gradient() { }
virtual void emitCode(GrGLShaderBuilder*,
- const GrDrawEffect&,
+ const GrEffectStage&,
EffectKey,
+ const char* vertexCoords,
const char* outputColor,
const char* inputColor,
const TextureSamplerArray&) SK_OVERRIDE;
- virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVERRIDE;
+ virtual void setData(const GrGLUniformManager&, const GrEffectStage&) SK_OVERRIDE;
- static EffectKey GenKey(const GrDrawEffect&, const GrGLCaps& caps);
+ static EffectKey GenKey(const GrEffectStage&, const GrGLCaps& caps);
protected:
@@ -474,7 +476,7 @@ GrEffectRef* GrConical2Gradient::TestCreate(SkMWCRandom* random,
/////////////////////////////////////////////////////////////////////
GrGLConical2Gradient::GrGLConical2Gradient(const GrBackendEffectFactory& factory,
- const GrDrawEffect& drawEffect)
+ const GrEffectRef& baseData)
: INHERITED(factory)
, fVSParamUni(kInvalidUniformHandle)
, fFSParamUni(kInvalidUniformHandle)
@@ -484,20 +486,21 @@ GrGLConical2Gradient::GrGLConical2Gradient(const GrBackendEffectFactory& factory
, fCachedRadius(-SK_ScalarMax)
, fCachedDiffRadius(-SK_ScalarMax) {
- const GrConical2Gradient& data = drawEffect.castEffect<GrConical2Gradient>();
+ const GrConical2Gradient& data = CastEffect<GrConical2Gradient>(baseData);
fIsDegenerate = data.isDegenerate();
}
void GrGLConical2Gradient::emitCode(GrGLShaderBuilder* builder,
- const GrDrawEffect&,
+ const GrEffectStage&,
EffectKey key,
+ const char* vertexCoords,
const char* outputColor,
const char* inputColor,
const TextureSamplerArray& samplers) {
const char* fsCoords;
const char* vsCoordsVarying;
GrSLType coordsVaryingType;
- this->setupMatrix(builder, key, &fsCoords, &vsCoordsVarying, &coordsVaryingType);
+ this->setupMatrix(builder, key, vertexCoords, &fsCoords, &vsCoordsVarying, &coordsVaryingType);
this->emitYCoordUniform(builder);
// 2 copies of uniform array, 1 for each of vertex & fragment shader,
@@ -655,10 +658,9 @@ void GrGLConical2Gradient::emitCode(GrGLShaderBuilder* builder,
}
}
-void GrGLConical2Gradient::setData(const GrGLUniformManager& uman,
- const GrDrawEffect& drawEffect) {
- INHERITED::setData(uman, drawEffect);
- const GrConical2Gradient& data = drawEffect.castEffect<GrConical2Gradient>();
+void GrGLConical2Gradient::setData(const GrGLUniformManager& uman, const GrEffectStage& stage) {
+ INHERITED::setData(uman, stage);
+ const GrConical2Gradient& data = GetEffectFromStage<GrConical2Gradient>(stage);
GrAssert(data.isDegenerate() == fIsDegenerate);
SkScalar centerX1 = data.center();
SkScalar radius0 = data.radius();
@@ -692,14 +694,13 @@ void GrGLConical2Gradient::setData(const GrGLUniformManager& uman,
}
}
-GrGLEffect::EffectKey GrGLConical2Gradient::GenKey(const GrDrawEffect& drawEffect,
- const GrGLCaps&) {
+GrGLEffect::EffectKey GrGLConical2Gradient::GenKey(const GrEffectStage& s, const GrGLCaps&) {
enum {
kIsDegenerate = 1 << kMatrixKeyBitCnt,
};
- EffectKey key = GenMatrixKey(drawEffect);
- if (drawEffect.castEffect<GrConical2Gradient>().isDegenerate()) {
+ EffectKey key = GenMatrixKey(s);
+ if (GetEffectFromStage<GrConical2Gradient>(s).isDegenerate()) {
key |= kIsDegenerate;
}
return key;
diff --git a/src/effects/gradients/SkTwoPointRadialGradient.cpp b/src/effects/gradients/SkTwoPointRadialGradient.cpp
index 6784818761..0bf308bdb1 100644
--- a/src/effects/gradients/SkTwoPointRadialGradient.cpp
+++ b/src/effects/gradients/SkTwoPointRadialGradient.cpp
@@ -384,18 +384,19 @@ class GrGLRadial2Gradient : public GrGLGradientEffect {
public:
- GrGLRadial2Gradient(const GrBackendEffectFactory& factory, const GrDrawEffect&);
+ GrGLRadial2Gradient(const GrBackendEffectFactory& factory, const GrEffectRef&);
virtual ~GrGLRadial2Gradient() { }
virtual void emitCode(GrGLShaderBuilder*,
- const GrDrawEffect&,
+ const GrEffectStage&,
EffectKey,
+ const char* vertexCoords,
const char* outputColor,
const char* inputColor,
const TextureSamplerArray&) SK_OVERRIDE;
- virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVERRIDE;
+ virtual void setData(const GrGLUniformManager&, const GrEffectStage&) SK_OVERRIDE;
- static EffectKey GenKey(const GrDrawEffect&, const GrGLCaps& caps);
+ static EffectKey GenKey(const GrEffectStage&, const GrGLCaps& caps);
protected:
@@ -515,7 +516,7 @@ GrEffectRef* GrRadial2Gradient::TestCreate(SkMWCRandom* random,
/////////////////////////////////////////////////////////////////////
GrGLRadial2Gradient::GrGLRadial2Gradient(const GrBackendEffectFactory& factory,
- const GrDrawEffect& drawEffect)
+ const GrEffectRef& baseData)
: INHERITED(factory)
, fVSParamUni(kInvalidUniformHandle)
, fFSParamUni(kInvalidUniformHandle)
@@ -525,13 +526,14 @@ GrGLRadial2Gradient::GrGLRadial2Gradient(const GrBackendEffectFactory& factory,
, fCachedRadius(-SK_ScalarMax)
, fCachedPosRoot(0) {
- const GrRadial2Gradient& data = drawEffect.castEffect<GrRadial2Gradient>();
+ const GrRadial2Gradient& data = CastEffect<GrRadial2Gradient>(baseData);
fIsDegenerate = data.isDegenerate();
}
void GrGLRadial2Gradient::emitCode(GrGLShaderBuilder* builder,
- const GrDrawEffect& drawEffect,
+ const GrEffectStage&,
EffectKey key,
+ const char* vertexCoords,
const char* outputColor,
const char* inputColor,
const TextureSamplerArray& samplers) {
@@ -540,7 +542,7 @@ void GrGLRadial2Gradient::emitCode(GrGLShaderBuilder* builder,
const char* fsCoords;
const char* vsCoordsVarying;
GrSLType coordsVaryingType;
- this->setupMatrix(builder, key, &fsCoords, &vsCoordsVarying, &coordsVaryingType);
+ this->setupMatrix(builder, key, vertexCoords, &fsCoords, &vsCoordsVarying, &coordsVaryingType);
// 2 copies of uniform array, 1 for each of vertex & fragment shader,
// to work around Xoom bug. Doesn't seem to cause performance decrease
@@ -637,10 +639,9 @@ void GrGLRadial2Gradient::emitCode(GrGLShaderBuilder* builder,
}
}
-void GrGLRadial2Gradient::setData(const GrGLUniformManager& uman,
- const GrDrawEffect& drawEffect) {
- INHERITED::setData(uman, drawEffect);
- const GrRadial2Gradient& data = drawEffect.castEffect<GrRadial2Gradient>();
+void GrGLRadial2Gradient::setData(const GrGLUniformManager& uman, const GrEffectStage& stage) {
+ INHERITED::setData(uman, stage);
+ const GrRadial2Gradient& data = GetEffectFromStage<GrRadial2Gradient>(stage);
GrAssert(data.isDegenerate() == fIsDegenerate);
SkScalar centerX1 = data.center();
SkScalar radius0 = data.radius();
@@ -672,14 +673,13 @@ void GrGLRadial2Gradient::setData(const GrGLUniformManager& uman,
}
}
-GrGLEffect::EffectKey GrGLRadial2Gradient::GenKey(const GrDrawEffect& drawEffect,
- const GrGLCaps&) {
+GrGLEffect::EffectKey GrGLRadial2Gradient::GenKey(const GrEffectStage& s, const GrGLCaps&) {
enum {
kIsDegenerate = 1 << kMatrixKeyBitCnt,
};
- EffectKey key = GenMatrixKey(drawEffect);
- if (drawEffect.castEffect<GrRadial2Gradient>().isDegenerate()) {
+ EffectKey key = GenMatrixKey(s);
+ if (GetEffectFromStage<GrRadial2Gradient>(s).isDegenerate()) {
key |= kIsDegenerate;
}
return key;