aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/effects
diff options
context:
space:
mode:
authorGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-01-22 19:55:59 +0000
committerGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-01-22 19:55:59 +0000
commit6340a41108633ac1ce5941e5cd30538630c4c55b (patch)
treec6f791722f09f6cf31207aea8093b1b06be3ae92 /src/effects
parentba3284e7bbb830749206414890f8152e421969f2 (diff)
Let them eat GrEffectRef.
Changes the remaining existing code that operates on naked GrEffects to GrEffectRef. Review URL: https://codereview.appspot.com/7124058 git-svn-id: http://skia.googlecode.com/svn/trunk@7321 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/effects')
-rw-r--r--src/effects/SkBicubicImageFilter.cpp19
-rw-r--r--src/effects/SkBlendImageFilter.cpp18
-rw-r--r--src/effects/SkColorMatrixFilter.cpp11
-rw-r--r--src/effects/SkDisplacementMapEffect.cpp29
-rw-r--r--src/effects/SkLightingImageFilter.cpp64
-rw-r--r--src/effects/SkMagnifierImageFilter.cpp31
-rw-r--r--src/effects/SkMatrixConvolutionImageFilter.cpp35
-rw-r--r--src/effects/SkMorphologyImageFilter.cpp20
-rw-r--r--src/effects/SkTableColorFilter.cpp14
-rw-r--r--src/effects/gradients/SkGradientShader.cpp8
-rw-r--r--src/effects/gradients/SkGradientShaderPriv.h3
-rw-r--r--src/effects/gradients/SkLinearGradient.cpp5
-rw-r--r--src/effects/gradients/SkRadialGradient.cpp4
-rw-r--r--src/effects/gradients/SkSweepGradient.cpp4
-rw-r--r--src/effects/gradients/SkTwoPointConicalGradient.cpp20
-rw-r--r--src/effects/gradients/SkTwoPointRadialGradient.cpp21
16 files changed, 141 insertions, 165 deletions
diff --git a/src/effects/SkBicubicImageFilter.cpp b/src/effects/SkBicubicImageFilter.cpp
index cb85c81a9c..36a4e47454 100644
--- a/src/effects/SkBicubicImageFilter.cpp
+++ b/src/effects/SkBicubicImageFilter.cpp
@@ -161,16 +161,16 @@ public:
typedef GrGLBicubicEffect GLEffect;
virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE;
- virtual bool onIsEqual(const GrEffect&) const SK_OVERRIDE;
virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags) const SK_OVERRIDE;
static GrEffectRef* Create(GrTexture* tex, const SkScalar coefficients[16]) {
- SkAutoTUnref<GrEffect> effect(SkNEW_ARGS(GrBicubicEffect, (tex, coefficients)));
+ AutoEffectUnref effect(SkNEW_ARGS(GrBicubicEffect, (tex, coefficients)));
return CreateEffectRef(effect);
}
private:
GrBicubicEffect(GrTexture*, const SkScalar coefficients[16]);
+ virtual bool onIsEqual(const GrEffectRef&) const SK_OVERRIDE;
float fCoefficients[16];
GR_DECLARE_EFFECT_TEST;
@@ -181,7 +181,7 @@ private:
class GrGLBicubicEffect : public GrGLEffect {
public:
GrGLBicubicEffect(const GrBackendEffectFactory& factory,
- const GrEffect& effect);
+ const GrEffectRef& effect);
virtual void emitCode(GrGLShaderBuilder*,
const GrEffectStage&,
EffectKey,
@@ -206,7 +206,7 @@ private:
};
GrGLBicubicEffect::GrGLBicubicEffect(const GrBackendEffectFactory& factory,
- const GrEffect& effect)
+ const GrEffectRef& effect)
: INHERITED(factory)
, fCoefficientsUni(GrGLUniformManager::kInvalidUniformHandle)
, fImageIncrementUni(GrGLUniformManager::kInvalidUniformHandle) {
@@ -265,8 +265,7 @@ void GrGLBicubicEffect::emitCode(GrGLShaderBuilder* builder,
}
GrGLEffect::EffectKey GrGLBicubicEffect::GenKey(const GrEffectStage& s, const GrGLCaps&) {
- const GrBicubicEffect& m =
- static_cast<const GrBicubicEffect&>(*s.getEffect());
+ const GrBicubicEffect& m = GetEffectFromStage<GrBicubicEffect>(s);
EffectKey matrixKey = GrGLEffectMatrix::GenKey(m.getMatrix(),
s.getCoordChangeMatrix(),
m.texture(0));
@@ -275,8 +274,7 @@ GrGLEffect::EffectKey GrGLBicubicEffect::GenKey(const GrEffectStage& s, const Gr
void GrGLBicubicEffect::setData(const GrGLUniformManager& uman,
const GrEffectStage& stage) {
- const GrBicubicEffect& effect =
- static_cast<const GrBicubicEffect&>(*stage.getEffect());
+ const GrBicubicEffect& effect = GetEffectFromStage<GrBicubicEffect>(stage);
GrTexture& texture = *effect.texture(0);
float imageIncrement[2];
imageIncrement[0] = 1.0f / texture.width();
@@ -307,9 +305,8 @@ const GrBackendEffectFactory& GrBicubicEffect::getFactory() const {
return GrTBackendEffectFactory<GrBicubicEffect>::getInstance();
}
-bool GrBicubicEffect::onIsEqual(const GrEffect& sBase) const {
- const GrBicubicEffect& s =
- static_cast<const GrBicubicEffect&>(sBase);
+bool GrBicubicEffect::onIsEqual(const GrEffectRef& sBase) const {
+ const GrBicubicEffect& s = CastEffect<GrBicubicEffect>(sBase);
return this->texture(0) == s.texture(0) &&
!memcmp(fCoefficients, s.coefficients(), 16);
}
diff --git a/src/effects/SkBlendImageFilter.cpp b/src/effects/SkBlendImageFilter.cpp
index 43915b3a79..840912c0ee 100644
--- a/src/effects/SkBlendImageFilter.cpp
+++ b/src/effects/SkBlendImageFilter.cpp
@@ -116,7 +116,7 @@ bool SkBlendImageFilter::onFilterImage(Proxy* proxy,
class GrGLBlendEffect : public GrGLEffect {
public:
GrGLBlendEffect(const GrBackendEffectFactory& factory,
- const GrEffect& effect);
+ const GrEffectRef& effect);
virtual ~GrGLBlendEffect();
virtual void emitCode(GrGLShaderBuilder*,
@@ -146,7 +146,7 @@ public:
static GrEffectRef* Create(SkBlendImageFilter::Mode mode,
GrTexture* foreground,
GrTexture* background) {
- SkAutoTUnref<GrEffect> effect(SkNEW_ARGS(GrBlendEffect, (mode, foreground, background)));
+ AutoEffectUnref effect(SkNEW_ARGS(GrBlendEffect, (mode, foreground, background)));
return CreateEffectRef(effect);
}
@@ -161,7 +161,7 @@ public:
void getConstantColorComponents(GrColor* color, uint32_t* validFlags) const SK_OVERRIDE;
private:
- virtual bool onIsEqual(const GrEffect&) const SK_OVERRIDE;
+ virtual bool onIsEqual(const GrEffectRef&) const SK_OVERRIDE;
GrBlendEffect(SkBlendImageFilter::Mode mode, GrTexture* foreground, GrTexture* background);
GrTextureAccess fForegroundAccess;
@@ -246,8 +246,8 @@ GrBlendEffect::GrBlendEffect(SkBlendImageFilter::Mode mode,
GrBlendEffect::~GrBlendEffect() {
}
-bool GrBlendEffect::onIsEqual(const GrEffect& sBase) const {
- const GrBlendEffect& s = static_cast<const GrBlendEffect&>(sBase);
+bool GrBlendEffect::onIsEqual(const GrEffectRef& sBase) const {
+ const GrBlendEffect& s = CastEffect<GrBlendEffect>(sBase);
return fForegroundAccess.getTexture() == s.fForegroundAccess.getTexture() &&
fBackgroundAccess.getTexture() == s.fBackgroundAccess.getTexture() &&
fMode == s.fMode;
@@ -272,9 +272,9 @@ void GrBlendEffect::getConstantColorComponents(GrColor* color, uint32_t* validFl
///////////////////////////////////////////////////////////////////////////////
-GrGLBlendEffect::GrGLBlendEffect(const GrBackendEffectFactory& factory, const GrEffect& effect)
+GrGLBlendEffect::GrGLBlendEffect(const GrBackendEffectFactory& factory, const GrEffectRef& effect)
: INHERITED(factory),
- fMode(static_cast<const GrBlendEffect&>(effect).mode()) {
+ fMode(CastEffect<GrBlendEffect>(effect).mode()) {
}
GrGLBlendEffect::~GrGLBlendEffect() {
@@ -327,7 +327,7 @@ void GrGLBlendEffect::emitCode(GrGLShaderBuilder* builder,
}
void GrGLBlendEffect::setData(const GrGLUniformManager& uman, const GrEffectStage& stage) {
- const GrBlendEffect& blend = static_cast<const GrBlendEffect&>(*stage.getEffect());
+ const GrBlendEffect& blend = GetEffectFromStage<GrBlendEffect>(stage);
GrTexture* fgTex = blend.texture(0);
GrTexture* bgTex = blend.texture(1);
fForegroundEffectMatrix.setData(uman,
@@ -342,7 +342,7 @@ void GrGLBlendEffect::setData(const GrGLUniformManager& uman, const GrEffectStag
}
GrGLEffect::EffectKey GrGLBlendEffect::GenKey(const GrEffectStage& stage, const GrGLCaps&) {
- const GrBlendEffect& blend = static_cast<const GrBlendEffect&>(*stage.getEffect());
+ const GrBlendEffect& blend = GetEffectFromStage<GrBlendEffect>(stage);
GrTexture* fgTex = blend.texture(0);
GrTexture* bgTex = blend.texture(1);
diff --git a/src/effects/SkColorMatrixFilter.cpp b/src/effects/SkColorMatrixFilter.cpp
index 06fb4efed0..dfd9566b28 100644
--- a/src/effects/SkColorMatrixFilter.cpp
+++ b/src/effects/SkColorMatrixFilter.cpp
@@ -326,7 +326,7 @@ bool SkColorMatrixFilter::asColorMatrix(SkScalar matrix[20]) const {
class ColorMatrixEffect : public GrEffect {
public:
static GrEffectRef* Create(const SkColorMatrix& matrix) {
- SkAutoTUnref<GrEffect> effect(SkNEW_ARGS(ColorMatrixEffect, (matrix)));
+ AutoEffectUnref effect(SkNEW_ARGS(ColorMatrixEffect, (matrix)));
return CreateEffectRef(effect);
}
@@ -389,7 +389,7 @@ public:
static EffectKey GenKey(const GrEffectStage&, const GrGLCaps&) { return 0; }
GLEffect(const GrBackendEffectFactory& factory,
- const GrEffect& effect)
+ const GrEffectRef& effect)
: INHERITED(factory)
, fMatrixHandle(GrGLUniformManager::kInvalidUniformHandle)
, fVectorHandle(GrGLUniformManager::kInvalidUniformHandle) {}
@@ -425,8 +425,7 @@ public:
virtual void setData(const GrGLUniformManager& uniManager,
const GrEffectStage& stage) SK_OVERRIDE {
- const ColorMatrixEffect& cme =
- static_cast<const ColorMatrixEffect&>(*stage.getEffect());
+ const ColorMatrixEffect& cme = GetEffectFromStage<ColorMatrixEffect>(stage);
const float* m = cme.fMatrix.fMat;
// The GL matrix is transposed from SkColorMatrix.
GrGLfloat mt[] = {
@@ -451,8 +450,8 @@ public:
private:
ColorMatrixEffect(const SkColorMatrix& matrix) : fMatrix(matrix) {}
- virtual bool onIsEqual(const GrEffect& s) const {
- const ColorMatrixEffect& cme = static_cast<const ColorMatrixEffect&>(s);
+ virtual bool onIsEqual(const GrEffectRef& s) const {
+ const ColorMatrixEffect& cme = CastEffect<ColorMatrixEffect>(s);
return cme.fMatrix == fMatrix;
}
diff --git a/src/effects/SkDisplacementMapEffect.cpp b/src/effects/SkDisplacementMapEffect.cpp
index 17abe28b18..895dd9827d 100644
--- a/src/effects/SkDisplacementMapEffect.cpp
+++ b/src/effects/SkDisplacementMapEffect.cpp
@@ -201,7 +201,7 @@ bool SkDisplacementMapEffect::onFilterImage(Proxy* proxy,
class GrGLDisplacementMapEffect : public GrGLEffect {
public:
GrGLDisplacementMapEffect(const GrBackendEffectFactory& factory,
- const GrEffect& effect);
+ const GrEffectRef& effect);
virtual ~GrGLDisplacementMapEffect();
virtual void emitCode(GrGLShaderBuilder*,
@@ -235,11 +235,11 @@ public:
static GrEffectRef* Create(SkDisplacementMapEffect::ChannelSelectorType xChannelSelector,
SkDisplacementMapEffect::ChannelSelectorType yChannelSelector,
SkScalar scale, GrTexture* displacement, GrTexture* color) {
- SkAutoTUnref<GrEffect> effect(SkNEW_ARGS(GrDisplacementMapEffect, (xChannelSelector,
- yChannelSelector,
- scale,
- displacement,
- color)));
+ AutoEffectUnref effect(SkNEW_ARGS(GrDisplacementMapEffect, (xChannelSelector,
+ yChannelSelector,
+ scale,
+ displacement,
+ color)));
return CreateEffectRef(effect);
}
@@ -258,7 +258,7 @@ public:
void getConstantColorComponents(GrColor* color, uint32_t* validFlags) const SK_OVERRIDE;
private:
- virtual bool onIsEqual(const GrEffect&) const SK_OVERRIDE;
+ virtual bool onIsEqual(const GrEffectRef&) const SK_OVERRIDE;
GrDisplacementMapEffect(SkDisplacementMapEffect::ChannelSelectorType xChannelSelector,
SkDisplacementMapEffect::ChannelSelectorType yChannelSelector,
@@ -361,8 +361,8 @@ GrDisplacementMapEffect::GrDisplacementMapEffect(
GrDisplacementMapEffect::~GrDisplacementMapEffect() {
}
-bool GrDisplacementMapEffect::onIsEqual(const GrEffect& sBase) const {
- const GrDisplacementMapEffect& s = static_cast<const GrDisplacementMapEffect&>(sBase);
+bool GrDisplacementMapEffect::onIsEqual(const GrEffectRef& sBase) const {
+ const GrDisplacementMapEffect& s = CastEffect<GrDisplacementMapEffect>(sBase);
return fDisplacementAccess.getTexture() == s.fDisplacementAccess.getTexture() &&
fColorAccess.getTexture() == s.fColorAccess.getTexture() &&
fXChannelSelector == s.fXChannelSelector &&
@@ -410,10 +410,11 @@ GrEffectRef* GrDisplacementMapEffect::TestCreate(SkRandom* random,
///////////////////////////////////////////////////////////////////////////////
-GrGLDisplacementMapEffect::GrGLDisplacementMapEffect(const GrBackendEffectFactory& factory, const GrEffect& effect)
+GrGLDisplacementMapEffect::GrGLDisplacementMapEffect(const GrBackendEffectFactory& factory,
+ const GrEffectRef& effect)
: INHERITED(factory)
- , fXChannelSelector(static_cast<const GrDisplacementMapEffect&>(effect).xChannelSelector())
- , fYChannelSelector(static_cast<const GrDisplacementMapEffect&>(effect).yChannelSelector()) {
+ , fXChannelSelector(CastEffect<GrDisplacementMapEffect>(effect).xChannelSelector())
+ , fYChannelSelector(CastEffect<GrDisplacementMapEffect>(effect).yChannelSelector()) {
}
GrGLDisplacementMapEffect::~GrGLDisplacementMapEffect() {
@@ -502,7 +503,7 @@ void GrGLDisplacementMapEffect::emitCode(GrGLShaderBuilder* builder,
}
void GrGLDisplacementMapEffect::setData(const GrGLUniformManager& uman, const GrEffectStage& stage) {
- const GrDisplacementMapEffect& displacementMap = static_cast<const GrDisplacementMapEffect&>(*stage.getEffect());
+ const GrDisplacementMapEffect& displacementMap = GetEffectFromStage<GrDisplacementMapEffect>(stage);
GrTexture* displTex = displacementMap.texture(0);
GrTexture* colorTex = displacementMap.texture(1);
fDisplacementEffectMatrix.setData(uman,
@@ -523,7 +524,7 @@ void GrGLDisplacementMapEffect::setData(const GrGLUniformManager& uman, const Gr
GrGLEffect::EffectKey GrGLDisplacementMapEffect::GenKey(const GrEffectStage& stage,
const GrGLCaps&) {
const GrDisplacementMapEffect& displacementMap =
- static_cast<const GrDisplacementMapEffect&>(*stage.getEffect());
+ GetEffectFromStage<GrDisplacementMapEffect>(stage);
GrTexture* displTex = displacementMap.texture(0);
GrTexture* colorTex = displacementMap.texture(1);
diff --git a/src/effects/SkLightingImageFilter.cpp b/src/effects/SkLightingImageFilter.cpp
index 780a3a42bd..81a686a8ff 100644
--- a/src/effects/SkLightingImageFilter.cpp
+++ b/src/effects/SkLightingImageFilter.cpp
@@ -317,7 +317,7 @@ public:
}
protected:
- virtual bool onIsEqual(const GrEffect&) const SK_OVERRIDE;
+ virtual bool onIsEqual(const GrEffectRef&) const SK_OVERRIDE;
private:
typedef GrSingleTextureEffect INHERITED;
@@ -331,10 +331,10 @@ public:
const SkLight* light,
SkScalar surfaceScale,
SkScalar kd) {
- SkAutoTUnref<GrEffect> effect(SkNEW_ARGS(GrDiffuseLightingEffect, (texture,
- light,
- surfaceScale,
- kd)));
+ AutoEffectUnref effect(SkNEW_ARGS(GrDiffuseLightingEffect, (texture,
+ light,
+ surfaceScale,
+ kd)));
return CreateEffectRef(effect);
}
@@ -346,7 +346,7 @@ public:
SkScalar kd() const { return fKD; }
private:
- virtual bool onIsEqual(const GrEffect&) const SK_OVERRIDE;
+ virtual bool onIsEqual(const GrEffectRef&) const SK_OVERRIDE;
GrDiffuseLightingEffect(GrTexture* texture,
const SkLight* light,
@@ -365,11 +365,11 @@ public:
SkScalar surfaceScale,
SkScalar ks,
SkScalar shininess) {
- SkAutoTUnref<GrEffect> effect(SkNEW_ARGS(GrSpecularLightingEffect, (texture,
- light,
- surfaceScale,
- ks,
- shininess)));
+ AutoEffectUnref effect(SkNEW_ARGS(GrSpecularLightingEffect, (texture,
+ light,
+ surfaceScale,
+ ks,
+ shininess)));
return CreateEffectRef(effect);
}
static const char* Name() { return "SpecularLighting"; }
@@ -381,7 +381,7 @@ public:
SkScalar shininess() const { return fShininess; }
private:
- virtual bool onIsEqual(const GrEffect&) const SK_OVERRIDE;
+ virtual bool onIsEqual(const GrEffectRef&) const SK_OVERRIDE;
GrSpecularLightingEffect(GrTexture* texture,
const SkLight* light,
@@ -980,7 +980,7 @@ SkLight* create_random_light(SkRandom* random) {
class GrGLLightingEffect : public GrGLEffect {
public:
GrGLLightingEffect(const GrBackendEffectFactory& factory,
- const GrEffect& effect);
+ const GrEffectRef& effect);
virtual ~GrGLLightingEffect();
virtual void emitCode(GrGLShaderBuilder*,
@@ -1015,7 +1015,7 @@ private:
class GrGLDiffuseLightingEffect : public GrGLLightingEffect {
public:
GrGLDiffuseLightingEffect(const GrBackendEffectFactory& factory,
- const GrEffect& effect);
+ const GrEffectRef& effect);
virtual void emitLightFunc(GrGLShaderBuilder*, SkString* funcName) SK_OVERRIDE;
virtual void setData(const GrGLUniformManager&, const GrEffectStage&) SK_OVERRIDE;
@@ -1030,7 +1030,7 @@ private:
class GrGLSpecularLightingEffect : public GrGLLightingEffect {
public:
GrGLSpecularLightingEffect(const GrBackendEffectFactory& factory,
- const GrEffect& effect);
+ const GrEffectRef& effect);
virtual void emitLightFunc(GrGLShaderBuilder*, SkString* funcName) SK_OVERRIDE;
virtual void setData(const GrGLUniformManager&, const GrEffectStage&) SK_OVERRIDE;
@@ -1054,8 +1054,8 @@ GrLightingEffect::~GrLightingEffect() {
fLight->unref();
}
-bool GrLightingEffect::onIsEqual(const GrEffect& sBase) const {
- const GrLightingEffect& s = static_cast<const GrLightingEffect&>(sBase);
+bool GrLightingEffect::onIsEqual(const GrEffectRef& sBase) const {
+ const GrLightingEffect& s = CastEffect<GrLightingEffect>(sBase);
return this->texture(0) == s.texture(0) &&
fLight->isEqual(*s.fLight) &&
fSurfaceScale == s.fSurfaceScale;
@@ -1071,9 +1071,8 @@ const GrBackendEffectFactory& GrDiffuseLightingEffect::getFactory() const {
return GrTBackendEffectFactory<GrDiffuseLightingEffect>::getInstance();
}
-bool GrDiffuseLightingEffect::onIsEqual(const GrEffect& sBase) const {
- const GrDiffuseLightingEffect& s =
- static_cast<const GrDiffuseLightingEffect&>(sBase);
+bool GrDiffuseLightingEffect::onIsEqual(const GrEffectRef& sBase) const {
+ const GrDiffuseLightingEffect& s = CastEffect<GrDiffuseLightingEffect>(sBase);
return INHERITED::onIsEqual(sBase) &&
this->kd() == s.kd();
}
@@ -1094,11 +1093,11 @@ GrEffectRef* GrDiffuseLightingEffect::TestCreate(SkRandom* random,
///////////////////////////////////////////////////////////////////////////////
GrGLLightingEffect::GrGLLightingEffect(const GrBackendEffectFactory& factory,
- const GrEffect& effect)
+ const GrEffectRef& effect)
: INHERITED(factory)
, fImageIncrementUni(kInvalidUniformHandle)
, fSurfaceScaleUni(kInvalidUniformHandle) {
- const GrLightingEffect& m = static_cast<const GrLightingEffect&>(effect);
+ const GrLightingEffect& m = CastEffect<GrLightingEffect>(effect);
fLight = m.light()->createGLLight();
}
@@ -1207,8 +1206,8 @@ void GrGLLightingEffect::emitCode(GrGLShaderBuilder* builder,
GrGLEffect::EffectKey GrGLLightingEffect::GenKey(const GrEffectStage& s,
const GrGLCaps& caps) {
- const GrLightingEffect& effect = static_cast<const GrLightingEffect&>(*s.getEffect());
- EffectKey key = static_cast<const GrLightingEffect&>(*s.getEffect()).light()->type();
+ const GrLightingEffect& effect = GetEffectFromStage<GrLightingEffect>(s);
+ EffectKey key = effect.light()->type();
key <<= GrGLEffectMatrix::kKeyBits;
EffectKey matrixKey = GrGLEffectMatrix::GenKey(effect.getMatrix(),
s.getCoordChangeMatrix(),
@@ -1217,7 +1216,7 @@ GrGLEffect::EffectKey GrGLLightingEffect::GenKey(const GrEffectStage& s,
}
void GrGLLightingEffect::setData(const GrGLUniformManager& uman, const GrEffectStage& stage) {
- const GrLightingEffect& effect =static_cast<const GrLightingEffect&>(*stage.getEffect());
+ const GrLightingEffect& effect = GetEffectFromStage<GrLightingEffect>(stage);
GrTexture* texture = effect.texture(0);
float ySign = texture->origin() == GrSurface::kTopLeft_Origin ? -1.0f : 1.0f;
uman.set2f(fImageIncrementUni, 1.0f / texture->width(), ySign / texture->height());
@@ -1234,7 +1233,7 @@ void GrGLLightingEffect::setData(const GrGLUniformManager& uman, const GrEffectS
///////////////////////////////////////////////////////////////////////////////
GrGLDiffuseLightingEffect::GrGLDiffuseLightingEffect(const GrBackendEffectFactory& factory,
- const GrEffect& effect)
+ const GrEffectRef& effect)
: INHERITED(factory, effect)
, fKDUni(kInvalidUniformHandle) {
}
@@ -1266,8 +1265,7 @@ void GrGLDiffuseLightingEffect::emitLightFunc(GrGLShaderBuilder* builder, SkStri
void GrGLDiffuseLightingEffect::setData(const GrGLUniformManager& uman,
const GrEffectStage& stage) {
INHERITED::setData(uman, stage);
- const GrDiffuseLightingEffect& effect =
- static_cast<const GrDiffuseLightingEffect&>(*stage.getEffect());
+ const GrDiffuseLightingEffect& effect = GetEffectFromStage<GrDiffuseLightingEffect>(stage);
uman.set1f(fKDUni, effect.kd());
}
@@ -1283,9 +1281,8 @@ const GrBackendEffectFactory& GrSpecularLightingEffect::getFactory() const {
return GrTBackendEffectFactory<GrSpecularLightingEffect>::getInstance();
}
-bool GrSpecularLightingEffect::onIsEqual(const GrEffect& sBase) const {
- const GrSpecularLightingEffect& s =
- static_cast<const GrSpecularLightingEffect&>(sBase);
+bool GrSpecularLightingEffect::onIsEqual(const GrEffectRef& sBase) const {
+ const GrSpecularLightingEffect& s = CastEffect<GrSpecularLightingEffect>(sBase);
return INHERITED::onIsEqual(sBase) &&
this->ks() == s.ks() &&
this->shininess() == s.shininess();
@@ -1307,7 +1304,7 @@ GrEffectRef* GrSpecularLightingEffect::TestCreate(SkRandom* random,
///////////////////////////////////////////////////////////////////////////////
GrGLSpecularLightingEffect::GrGLSpecularLightingEffect(const GrBackendEffectFactory& factory,
- const GrEffect& effect)
+ const GrEffectRef& effect)
: GrGLLightingEffect(factory, effect)
, fKSUni(kInvalidUniformHandle)
, fShininessUni(kInvalidUniformHandle) {
@@ -1344,8 +1341,7 @@ void GrGLSpecularLightingEffect::emitLightFunc(GrGLShaderBuilder* builder, SkStr
void GrGLSpecularLightingEffect::setData(const GrGLUniformManager& uman,
const GrEffectStage& stage) {
INHERITED::setData(uman, stage);
- const GrSpecularLightingEffect& effect =
- static_cast<const GrSpecularLightingEffect&>(*stage.getEffect());
+ const GrSpecularLightingEffect& effect = GetEffectFromStage<GrSpecularLightingEffect>(stage);
uman.set1f(fKSUni, effect.ks());
uman.set1f(fShininessUni, effect.shininess());
}
diff --git a/src/effects/SkMagnifierImageFilter.cpp b/src/effects/SkMagnifierImageFilter.cpp
index bcf0baf751..f5d9030d58 100644
--- a/src/effects/SkMagnifierImageFilter.cpp
+++ b/src/effects/SkMagnifierImageFilter.cpp
@@ -33,13 +33,13 @@ public:
float yZoom,
float xInset,
float yInset) {
- SkAutoTUnref<GrEffect> effect(SkNEW_ARGS(GrMagnifierEffect, (texture,
- xOffset,
- yOffset,
- xZoom,
- yZoom,
- xInset,
- yInset)));
+ AutoEffectUnref effect(SkNEW_ARGS(GrMagnifierEffect, (texture,
+ xOffset,
+ yOffset,
+ xZoom,
+ yZoom,
+ xInset,
+ yInset)));
return CreateEffectRef(effect);
}
@@ -75,7 +75,7 @@ private:
, fXInset(xInset)
, fYInset(yInset) {}
- virtual bool onIsEqual(const GrEffect&) const SK_OVERRIDE;
+ virtual bool onIsEqual(const GrEffectRef&) const SK_OVERRIDE;
GR_DECLARE_EFFECT_TEST;
@@ -94,8 +94,7 @@ typedef GrGLUniformManager::UniformHandle UniformHandle;
class GrGLMagnifierEffect : public GrGLEffect {
public:
- GrGLMagnifierEffect(const GrBackendEffectFactory& factory,
- const GrEffect& effect);
+ GrGLMagnifierEffect(const GrBackendEffectFactory& factory, const GrEffectRef& effect);
virtual void emitCode(GrGLShaderBuilder*,
const GrEffectStage&,
@@ -120,8 +119,7 @@ private:
typedef GrGLEffect INHERITED;
};
-GrGLMagnifierEffect::GrGLMagnifierEffect(const GrBackendEffectFactory& factory,
- const GrEffect& effect)
+GrGLMagnifierEffect::GrGLMagnifierEffect(const GrBackendEffectFactory& factory, const GrEffectRef&)
: INHERITED(factory)
, fOffsetVar(GrGLUniformManager::kInvalidUniformHandle)
, fZoomVar(GrGLUniformManager::kInvalidUniformHandle)
@@ -184,8 +182,7 @@ void GrGLMagnifierEffect::emitCode(GrGLShaderBuilder* builder,
void GrGLMagnifierEffect::setData(const GrGLUniformManager& uman,
const GrEffectStage& stage) {
- const GrMagnifierEffect& zoom = static_cast<const GrMagnifierEffect&>(*stage.getEffect());
-
+ 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());
@@ -193,7 +190,7 @@ void GrGLMagnifierEffect::setData(const GrGLUniformManager& uman,
}
GrGLEffect::EffectKey GrGLMagnifierEffect::GenKey(const GrEffectStage& stage, const GrGLCaps&) {
- const GrMagnifierEffect& zoom = static_cast<const GrMagnifierEffect&>(*stage.getEffect());
+ const GrMagnifierEffect& zoom = GetEffectFromStage<GrMagnifierEffect>(stage);
return GrGLEffectMatrix::GenKey(zoom.getMatrix(),
stage.getCoordChangeMatrix(),
zoom.texture(0));
@@ -232,8 +229,8 @@ const GrBackendEffectFactory& GrMagnifierEffect::getFactory() const {
return GrTBackendEffectFactory<GrMagnifierEffect>::getInstance();
}
-bool GrMagnifierEffect::onIsEqual(const GrEffect& sBase) const {
- const GrMagnifierEffect& s = static_cast<const GrMagnifierEffect&>(sBase);
+bool GrMagnifierEffect::onIsEqual(const GrEffectRef& sBase) const {
+ const GrMagnifierEffect& s = CastEffect<GrMagnifierEffect>(sBase);
return (this->texture(0) == s.texture(0) &&
this->fXOffset == s.fXOffset &&
this->fYOffset == s.fYOffset &&
diff --git a/src/effects/SkMatrixConvolutionImageFilter.cpp b/src/effects/SkMatrixConvolutionImageFilter.cpp
index 50933eeeb6..9efb0a3e66 100644
--- a/src/effects/SkMatrixConvolutionImageFilter.cpp
+++ b/src/effects/SkMatrixConvolutionImageFilter.cpp
@@ -255,14 +255,14 @@ public:
const SkIPoint& target,
TileMode tileMode,
bool convolveAlpha) {
- SkAutoTUnref<GrEffect> effect(SkNEW_ARGS(GrMatrixConvolutionEffect, (texture,
- kernelSize,
- kernel,
- gain,
- bias,
- target,
- tileMode,
- convolveAlpha)));
+ AutoEffectUnref effect(SkNEW_ARGS(GrMatrixConvolutionEffect, (texture,
+ kernelSize,
+ kernel,
+ gain,
+ bias,
+ target,
+ tileMode,
+ convolveAlpha)));
return CreateEffectRef(effect);
}
virtual ~GrMatrixConvolutionEffect();
@@ -298,7 +298,7 @@ private:
TileMode tileMode,
bool convolveAlpha);
- virtual bool onIsEqual(const GrEffect&) const SK_OVERRIDE;
+ virtual bool onIsEqual(const GrEffectRef&) const SK_OVERRIDE;
SkISize fKernelSize;
float *fKernel;
@@ -316,7 +316,7 @@ private:
class GrGLMatrixConvolutionEffect : public GrGLEffect {
public:
GrGLMatrixConvolutionEffect(const GrBackendEffectFactory& factory,
- const GrEffect& effect);
+ const GrEffectRef& effect);
virtual void emitCode(GrGLShaderBuilder*,
const GrEffectStage&,
EffectKey,
@@ -348,14 +348,14 @@ private:
};
GrGLMatrixConvolutionEffect::GrGLMatrixConvolutionEffect(const GrBackendEffectFactory& factory,
- const GrEffect& effect)
+ const GrEffectRef& effect)
: INHERITED(factory)
, fKernelUni(GrGLUniformManager::kInvalidUniformHandle)
, fImageIncrementUni(GrGLUniformManager::kInvalidUniformHandle)
, fTargetUni(GrGLUniformManager::kInvalidUniformHandle)
, fGainUni(GrGLUniformManager::kInvalidUniformHandle)
, fBiasUni(GrGLUniformManager::kInvalidUniformHandle) {
- const GrMatrixConvolutionEffect& m = static_cast<const GrMatrixConvolutionEffect&>(effect);
+ const GrMatrixConvolutionEffect& m = CastEffect<GrMatrixConvolutionEffect>(effect);
fKernelSize = m.kernelSize();
fTileMode = m.tileMode();
fConvolveAlpha = m.convolveAlpha();
@@ -454,8 +454,7 @@ int encodeXY(int x, int y) {
};
GrGLEffect::EffectKey GrGLMatrixConvolutionEffect::GenKey(const GrEffectStage& s, const GrGLCaps&) {
- const GrMatrixConvolutionEffect& m =
- static_cast<const GrMatrixConvolutionEffect&>(*s.getEffect());
+ 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;
@@ -468,8 +467,7 @@ GrGLEffect::EffectKey GrGLMatrixConvolutionEffect::GenKey(const GrEffectStage& s
void GrGLMatrixConvolutionEffect::setData(const GrGLUniformManager& uman,
const GrEffectStage& stage) {
- const GrMatrixConvolutionEffect& effect =
- static_cast<const GrMatrixConvolutionEffect&>(*stage.getEffect());
+ const GrMatrixConvolutionEffect& effect = GetEffectFromStage<GrMatrixConvolutionEffect>(stage);
GrTexture& texture = *effect.texture(0);
// the code we generated was for a specific kernel size
GrAssert(effect.kernelSize() == fKernelSize);
@@ -519,9 +517,8 @@ const GrBackendEffectFactory& GrMatrixConvolutionEffect::getFactory() const {
return GrTBackendEffectFactory<GrMatrixConvolutionEffect>::getInstance();
}
-bool GrMatrixConvolutionEffect::onIsEqual(const GrEffect& sBase) const {
- const GrMatrixConvolutionEffect& s =
- static_cast<const GrMatrixConvolutionEffect&>(sBase);
+bool GrMatrixConvolutionEffect::onIsEqual(const GrEffectRef& sBase) const {
+ const GrMatrixConvolutionEffect& s = CastEffect<GrMatrixConvolutionEffect>(sBase);
return this->texture(0) == s.texture(0) &&
fKernelSize == s.kernelSize() &&
!memcmp(fKernel, s.kernel(), fKernelSize.width() * fKernelSize.height() * sizeof(float)) &&
diff --git a/src/effects/SkMorphologyImageFilter.cpp b/src/effects/SkMorphologyImageFilter.cpp
index c409435926..746f966103 100644
--- a/src/effects/SkMorphologyImageFilter.cpp
+++ b/src/effects/SkMorphologyImageFilter.cpp
@@ -244,7 +244,7 @@ public:
};
static GrEffectRef* Create(GrTexture* tex, Direction dir, int radius, MorphologyType type) {
- SkAutoTUnref<GrEffect> effect(SkNEW_ARGS(GrMorphologyEffect, (tex, dir, radius, type)));
+ AutoEffectUnref effect(SkNEW_ARGS(GrMorphologyEffect, (tex, dir, radius, type)));
return CreateEffectRef(effect);
}
@@ -264,7 +264,7 @@ protected:
MorphologyType fType;
private:
- virtual bool onIsEqual(const GrEffect&) const SK_OVERRIDE;
+ virtual bool onIsEqual(const GrEffectRef&) const SK_OVERRIDE;
GrMorphologyEffect(GrTexture*, Direction, int radius, MorphologyType);
@@ -277,8 +277,7 @@ private:
class GrGLMorphologyEffect : public GrGLEffect {
public:
- GrGLMorphologyEffect (const GrBackendEffectFactory& factory,
- const GrEffect& effect);
+ GrGLMorphologyEffect (const GrBackendEffectFactory&, const GrEffectRef&);
virtual void emitCode(GrGLShaderBuilder*,
const GrEffectStage&,
@@ -304,10 +303,10 @@ private:
};
GrGLMorphologyEffect::GrGLMorphologyEffect(const GrBackendEffectFactory& factory,
- const GrEffect& effect)
+ const GrEffectRef& effect)
: INHERITED(factory)
, fImageIncrementUni(GrGLUniformManager::kInvalidUniformHandle) {
- const GrMorphologyEffect& m = static_cast<const GrMorphologyEffect&>(effect);
+ const GrMorphologyEffect& m = CastEffect<GrMorphologyEffect>(effect);
fRadius = m.radius();
fType = m.type();
}
@@ -354,7 +353,7 @@ void GrGLMorphologyEffect::emitCode(GrGLShaderBuilder* builder,
}
GrGLEffect::EffectKey GrGLMorphologyEffect::GenKey(const GrEffectStage& s, const GrGLCaps&) {
- const GrMorphologyEffect& m = static_cast<const GrMorphologyEffect&>(*s.getEffect());
+ const GrMorphologyEffect& m = GetEffectFromStage<GrMorphologyEffect>(s);
EffectKey key = static_cast<EffectKey>(m.radius());
key |= (m.type() << 8);
key <<= GrGLEffectMatrix::kKeyBits;
@@ -365,7 +364,7 @@ GrGLEffect::EffectKey GrGLMorphologyEffect::GenKey(const GrEffectStage& s, const
}
void GrGLMorphologyEffect::setData(const GrGLUniformManager& uman, const GrEffectStage& stage) {
- const Gr1DKernelEffect& kern = static_cast<const Gr1DKernelEffect&>(*stage.getEffect());
+ 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);
@@ -401,9 +400,8 @@ const GrBackendEffectFactory& GrMorphologyEffect::getFactory() const {
return GrTBackendEffectFactory<GrMorphologyEffect>::getInstance();
}
-bool GrMorphologyEffect::onIsEqual(const GrEffect& sBase) const {
- const GrMorphologyEffect& s =
- static_cast<const GrMorphologyEffect&>(sBase);
+bool GrMorphologyEffect::onIsEqual(const GrEffectRef& sBase) const {
+ const GrMorphologyEffect& s = CastEffect<GrMorphologyEffect>(sBase);
return (this->texture(0) == s.texture(0) &&
this->radius() == s.radius() &&
this->direction() == s.direction() &&
diff --git a/src/effects/SkTableColorFilter.cpp b/src/effects/SkTableColorFilter.cpp
index afb4a9926c..dcdb39f5eb 100644
--- a/src/effects/SkTableColorFilter.cpp
+++ b/src/effects/SkTableColorFilter.cpp
@@ -227,7 +227,7 @@ class GLColorTableEffect;
class ColorTableEffect : public GrEffect {
public:
static GrEffectRef* Create(GrTexture* texture, unsigned flags) {
- SkAutoTUnref<GrEffect> effect(SkNEW_ARGS(ColorTableEffect, (texture, flags)));
+ AutoEffectUnref effect(SkNEW_ARGS(ColorTableEffect, (texture, flags)));
return CreateEffectRef(effect);
}
@@ -241,7 +241,7 @@ public:
typedef GLColorTableEffect GLEffect;
private:
- virtual bool onIsEqual(const GrEffect&) const SK_OVERRIDE;
+ virtual bool onIsEqual(const GrEffectRef&) const SK_OVERRIDE;
explicit ColorTableEffect(GrTexture* texture, unsigned flags);
@@ -256,8 +256,7 @@ private:
class GLColorTableEffect : public GrGLEffect {
public:
- GLColorTableEffect(const GrBackendEffectFactory& factory,
- const GrEffect& effect);
+ GLColorTableEffect(const GrBackendEffectFactory&, const GrEffectRef&);
virtual void emitCode(GrGLShaderBuilder*,
const GrEffectStage&,
@@ -276,8 +275,7 @@ private:
typedef GrGLEffect INHERITED;
};
-GLColorTableEffect::GLColorTableEffect(
- const GrBackendEffectFactory& factory, const GrEffect& effect)
+GLColorTableEffect::GLColorTableEffect(const GrBackendEffectFactory& factory, const GrEffectRef&)
: INHERITED(factory) {
}
@@ -345,8 +343,8 @@ const GrBackendEffectFactory& ColorTableEffect::getFactory() const {
return GrTBackendEffectFactory<ColorTableEffect>::getInstance();
}
-bool ColorTableEffect::onIsEqual(const GrEffect& sBase) const {
- return this->texture(0) == sBase.texture(0);
+bool ColorTableEffect::onIsEqual(const GrEffectRef& sBase) const {
+ return this->texture(0) == sBase->texture(0);
}
void ColorTableEffect::getConstantColorComponents(GrColor* color, uint32_t* validFlags) const {
diff --git a/src/effects/gradients/SkGradientShader.cpp b/src/effects/gradients/SkGradientShader.cpp
index 76450245ff..1880425c21 100644
--- a/src/effects/gradients/SkGradientShader.cpp
+++ b/src/effects/gradients/SkGradientShader.cpp
@@ -727,7 +727,7 @@ void GrGLGradientEffect::emitYCoordUniform(GrGLShaderBuilder* builder) {
}
void GrGLGradientEffect::setData(const GrGLUniformManager& uman, const GrEffectStage& stage) {
- const GrGradientEffect& e = static_cast<const GrGradientEffect&>(*stage.getEffect());
+ const GrGradientEffect& e = GetEffectFromStage<GrGradientEffect>(stage);
const GrTexture* texture = e.texture(0);
fEffectMatrix.setData(uman, e.getMatrix(), stage.getCoordChangeMatrix(), texture);
@@ -739,7 +739,7 @@ void GrGLGradientEffect::setData(const GrGLUniformManager& uman, const GrEffectS
}
GrGLEffect::EffectKey GrGLGradientEffect::GenMatrixKey(const GrEffectStage& s) {
- const GrGradientEffect& e = static_cast<const GrGradientEffect&>(*s.getEffect());
+ const GrGradientEffect& e = GetEffectFromStage<GrGradientEffect>(s);
const GrTexture* texture = e.texture(0);
return GrGLEffectMatrix::GenKey(e.getMatrix(), s.getCoordChangeMatrix(), texture);
}
@@ -829,8 +829,8 @@ GrGradientEffect::~GrGradientEffect() {
}
}
-bool GrGradientEffect::onIsEqual(const GrEffect& effect) const {
- const GrGradientEffect& s = static_cast<const GrGradientEffect&>(effect);
+bool GrGradientEffect::onIsEqual(const GrEffectRef& effect) const {
+ const GrGradientEffect& s = CastEffect<GrGradientEffect>(effect);
return fTextureAccess.getTexture() == s.fTextureAccess.getTexture() &&
fTextureAccess.getParams().getTileModeX() ==
s.fTextureAccess.getParams().getTileModeX() &&
diff --git a/src/effects/gradients/SkGradientShaderPriv.h b/src/effects/gradients/SkGradientShaderPriv.h
index 18289051b6..a34e4ab9bb 100644
--- a/src/effects/gradients/SkGradientShaderPriv.h
+++ b/src/effects/gradients/SkGradientShaderPriv.h
@@ -255,7 +255,7 @@ protected:
SkScalar** stops,
SkShader::TileMode* tm);
- virtual bool onIsEqual(const GrEffect& effect) const SK_OVERRIDE;
+ virtual bool onIsEqual(const GrEffectRef& effect) const SK_OVERRIDE;
private:
@@ -335,4 +335,3 @@ private:
#endif
#endif
-
diff --git a/src/effects/gradients/SkLinearGradient.cpp b/src/effects/gradients/SkLinearGradient.cpp
index 6bb0329dd1..1848571386 100644
--- a/src/effects/gradients/SkLinearGradient.cpp
+++ b/src/effects/gradients/SkLinearGradient.cpp
@@ -456,8 +456,7 @@ void SkLinearGradient::shadeSpan16(int x, int y,
class GrGLLinearGradient : public GrGLGradientEffect {
public:
- GrGLLinearGradient(const GrBackendEffectFactory& factory,
- const GrEffect&)
+ GrGLLinearGradient(const GrBackendEffectFactory& factory, const GrEffectRef&)
: INHERITED (factory) { }
virtual ~GrGLLinearGradient() { }
@@ -488,7 +487,7 @@ public:
const SkLinearGradient& shader,
const SkMatrix& matrix,
SkShader::TileMode tm) {
- SkAutoTUnref<GrEffect> effect(SkNEW_ARGS(GrLinearGradient, (ctx, shader, matrix, tm)));
+ AutoEffectUnref effect(SkNEW_ARGS(GrLinearGradient, (ctx, shader, matrix, tm)));
return CreateEffectRef(effect);
}
diff --git a/src/effects/gradients/SkRadialGradient.cpp b/src/effects/gradients/SkRadialGradient.cpp
index c380ec1730..3062105ee3 100644
--- a/src/effects/gradients/SkRadialGradient.cpp
+++ b/src/effects/gradients/SkRadialGradient.cpp
@@ -479,7 +479,7 @@ class GrGLRadialGradient : public GrGLGradientEffect {
public:
GrGLRadialGradient(const GrBackendEffectFactory& factory,
- const GrEffect&) : INHERITED (factory) { }
+ const GrEffectRef&) : INHERITED (factory) { }
virtual ~GrGLRadialGradient() { }
virtual void emitCode(GrGLShaderBuilder*,
@@ -508,7 +508,7 @@ public:
const SkRadialGradient& shader,
const SkMatrix& matrix,
SkShader::TileMode tm) {
- SkAutoTUnref<GrEffect> effect(SkNEW_ARGS(GrRadialGradient, (ctx, shader, matrix, tm)));
+ AutoEffectUnref effect(SkNEW_ARGS(GrRadialGradient, (ctx, shader, matrix, tm)));
return CreateEffectRef(effect);
}
diff --git a/src/effects/gradients/SkSweepGradient.cpp b/src/effects/gradients/SkSweepGradient.cpp
index 3a1a599ec0..3cdac8577b 100644
--- a/src/effects/gradients/SkSweepGradient.cpp
+++ b/src/effects/gradients/SkSweepGradient.cpp
@@ -388,7 +388,7 @@ class GrGLSweepGradient : public GrGLGradientEffect {
public:
GrGLSweepGradient(const GrBackendEffectFactory& factory,
- const GrEffect&) : INHERITED (factory) { }
+ const GrEffectRef&) : INHERITED (factory) { }
virtual ~GrGLSweepGradient() { }
virtual void emitCode(GrGLShaderBuilder*,
@@ -416,7 +416,7 @@ public:
static GrEffectRef* Create(GrContext* ctx,
const SkSweepGradient& shader,
const SkMatrix& matrix) {
- SkAutoTUnref<GrEffect> effect(SkNEW_ARGS(GrSweepGradient, (ctx, shader, matrix)));
+ AutoEffectUnref effect(SkNEW_ARGS(GrSweepGradient, (ctx, shader, matrix)));
return CreateEffectRef(effect);
}
virtual ~GrSweepGradient() { }
diff --git a/src/effects/gradients/SkTwoPointConicalGradient.cpp b/src/effects/gradients/SkTwoPointConicalGradient.cpp
index 23b976a8f8..bef29c0437 100644
--- a/src/effects/gradients/SkTwoPointConicalGradient.cpp
+++ b/src/effects/gradients/SkTwoPointConicalGradient.cpp
@@ -325,7 +325,7 @@ class GrGLConical2Gradient : public GrGLGradientEffect {
public:
GrGLConical2Gradient(const GrBackendEffectFactory& factory,
- const GrEffect&);
+ const GrEffectRef&);
virtual ~GrGLConical2Gradient() { }
virtual void emitCode(GrGLShaderBuilder*,
@@ -373,7 +373,7 @@ public:
const SkTwoPointConicalGradient& shader,
const SkMatrix& matrix,
SkShader::TileMode tm) {
- SkAutoTUnref<GrEffect> effect(SkNEW_ARGS(GrConical2Gradient, (ctx, shader, matrix, tm)));
+ AutoEffectUnref effect(SkNEW_ARGS(GrConical2Gradient, (ctx, shader, matrix, tm)));
return CreateEffectRef(effect);
}
@@ -393,8 +393,8 @@ public:
typedef GrGLConical2Gradient GLEffect;
private:
- virtual bool onIsEqual(const GrEffect& sBase) const SK_OVERRIDE {
- const GrConical2Gradient& s = static_cast<const GrConical2Gradient&>(sBase);
+ virtual bool onIsEqual(const GrEffectRef& sBase) const SK_OVERRIDE {
+ const GrConical2Gradient& s = CastEffect<GrConical2Gradient>(sBase);
return (INHERITED::onIsEqual(sBase) &&
this->fCenterX1 == s.fCenterX1 &&
this->fRadius0 == s.fRadius0 &&
@@ -456,9 +456,8 @@ GrEffectRef* GrConical2Gradient::TestCreate(SkRandom* random,
/////////////////////////////////////////////////////////////////////
-GrGLConical2Gradient::GrGLConical2Gradient(
- const GrBackendEffectFactory& factory,
- const GrEffect& baseData)
+GrGLConical2Gradient::GrGLConical2Gradient(const GrBackendEffectFactory& factory,
+ const GrEffectRef& baseData)
: INHERITED(factory)
, fVSParamUni(kInvalidUniformHandle)
, fFSParamUni(kInvalidUniformHandle)
@@ -468,8 +467,7 @@ GrGLConical2Gradient::GrGLConical2Gradient(
, fCachedRadius(-SK_ScalarMax)
, fCachedDiffRadius(-SK_ScalarMax) {
- const GrConical2Gradient& data =
- static_cast<const GrConical2Gradient&>(baseData);
+ const GrConical2Gradient& data = CastEffect<GrConical2Gradient>(baseData);
fIsDegenerate = data.isDegenerate();
}
@@ -645,7 +643,7 @@ void GrGLConical2Gradient::emitCode(GrGLShaderBuilder* builder,
void GrGLConical2Gradient::setData(const GrGLUniformManager& uman, const GrEffectStage& stage) {
INHERITED::setData(uman, stage);
- const GrConical2Gradient& data = static_cast<const GrConical2Gradient&>(*stage.getEffect());
+ const GrConical2Gradient& data = GetEffectFromStage<GrConical2Gradient>(stage);
GrAssert(data.isDegenerate() == fIsDegenerate);
SkScalar centerX1 = data.center();
SkScalar radius0 = data.radius();
@@ -685,7 +683,7 @@ GrGLEffect::EffectKey GrGLConical2Gradient::GenKey(const GrEffectStage& s, const
};
EffectKey key = GenMatrixKey(s);
- if (static_cast<const GrConical2Gradient&>(*s.getEffect()).isDegenerate()) {
+ if (GetEffectFromStage<GrConical2Gradient>(s).isDegenerate()) {
key |= kIsDegenerate;
}
return key;
diff --git a/src/effects/gradients/SkTwoPointRadialGradient.cpp b/src/effects/gradients/SkTwoPointRadialGradient.cpp
index fb5c69ea17..b1c13037fb 100644
--- a/src/effects/gradients/SkTwoPointRadialGradient.cpp
+++ b/src/effects/gradients/SkTwoPointRadialGradient.cpp
@@ -384,8 +384,7 @@ class GrGLRadial2Gradient : public GrGLGradientEffect {
public:
- GrGLRadial2Gradient(const GrBackendEffectFactory& factory,
- const GrEffect&);
+ GrGLRadial2Gradient(const GrBackendEffectFactory& factory, const GrEffectRef&);
virtual ~GrGLRadial2Gradient() { }
virtual void emitCode(GrGLShaderBuilder*,
@@ -432,7 +431,7 @@ public:
const SkTwoPointRadialGradient& shader,
const SkMatrix& matrix,
SkShader::TileMode tm) {
- SkAutoTUnref<GrEffect> effect(SkNEW_ARGS(GrRadial2Gradient, (ctx, shader, matrix, tm)));
+ AutoEffectUnref effect(SkNEW_ARGS(GrRadial2Gradient, (ctx, shader, matrix, tm)));
return CreateEffectRef(effect);
}
@@ -452,8 +451,8 @@ public:
typedef GrGLRadial2Gradient GLEffect;
private:
- virtual bool onIsEqual(const GrEffect& sBase) const SK_OVERRIDE {
- const GrRadial2Gradient& s = static_cast<const GrRadial2Gradient&>(sBase);
+ virtual bool onIsEqual(const GrEffectRef& sBase) const SK_OVERRIDE {
+ const GrRadial2Gradient& s = CastEffect<GrRadial2Gradient>(sBase);
return (INHERITED::onIsEqual(sBase) &&
this->fCenterX1 == s.fCenterX1 &&
this->fRadius0 == s.fRadius0 &&
@@ -516,9 +515,8 @@ GrEffectRef* GrRadial2Gradient::TestCreate(SkRandom* random,
/////////////////////////////////////////////////////////////////////
-GrGLRadial2Gradient::GrGLRadial2Gradient(
- const GrBackendEffectFactory& factory,
- const GrEffect& baseData)
+GrGLRadial2Gradient::GrGLRadial2Gradient(const GrBackendEffectFactory& factory,
+ const GrEffectRef& baseData)
: INHERITED(factory)
, fVSParamUni(kInvalidUniformHandle)
, fFSParamUni(kInvalidUniformHandle)
@@ -528,8 +526,7 @@ GrGLRadial2Gradient::GrGLRadial2Gradient(
, fCachedRadius(-SK_ScalarMax)
, fCachedPosRoot(0) {
- const GrRadial2Gradient& data =
- static_cast<const GrRadial2Gradient&>(baseData);
+ const GrRadial2Gradient& data = CastEffect<GrRadial2Gradient>(baseData);
fIsDegenerate = data.isDegenerate();
}
@@ -646,7 +643,7 @@ void GrGLRadial2Gradient::emitCode(GrGLShaderBuilder* builder,
void GrGLRadial2Gradient::setData(const GrGLUniformManager& uman, const GrEffectStage& stage) {
INHERITED::setData(uman, stage);
- const GrRadial2Gradient& data = static_cast<const GrRadial2Gradient&>(*stage.getEffect());
+ const GrRadial2Gradient& data = GetEffectFromStage<GrRadial2Gradient>(stage);
GrAssert(data.isDegenerate() == fIsDegenerate);
SkScalar centerX1 = data.center();
SkScalar radius0 = data.radius();
@@ -684,7 +681,7 @@ GrGLEffect::EffectKey GrGLRadial2Gradient::GenKey(const GrEffectStage& s, const
};
EffectKey key = GenMatrixKey(s);
- if (static_cast<const GrRadial2Gradient&>(*s.getEffect()).isDegenerate()) {
+ if (GetEffectFromStage<GrRadial2Gradient>(s).isDegenerate()) {
key |= kIsDegenerate;
}
return key;