Change some function/vars from EffectPtr to EffectRef to reflect GrEffectPtr->GrEffectRef renaming.
git-svn-id: http://skia.googlecode.com/svn/trunk@7226 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
87c472653b
commit
a1ebbe447d
@ -153,28 +153,28 @@ protected:
|
||||
*/
|
||||
void addTextureAccess(const GrTextureAccess* textureAccess);
|
||||
|
||||
GrEffect() : fEffectPtr(NULL) {};
|
||||
GrEffect() : fEffectRef(NULL) {};
|
||||
|
||||
/** This should be called by GrEffect subclass factories */
|
||||
static GrEffectRef* CreateEffectPtr(GrEffect* effect) {
|
||||
if (NULL == effect->fEffectPtr) {
|
||||
effect->fEffectPtr = SkNEW_ARGS(GrEffectRef, (effect));
|
||||
static GrEffectRef* CreateEffectRef(GrEffect* effect) {
|
||||
if (NULL == effect->fEffectRef) {
|
||||
effect->fEffectRef = SkNEW_ARGS(GrEffectRef, (effect));
|
||||
} else {
|
||||
effect->fEffectPtr->ref();
|
||||
effect->fEffectRef->ref();
|
||||
GrCrash("This function should only be called once per effect currently.");
|
||||
}
|
||||
return effect->fEffectPtr;
|
||||
return effect->fEffectRef;
|
||||
}
|
||||
|
||||
private:
|
||||
void effectPtrDestroyed() {
|
||||
fEffectPtr = NULL;
|
||||
void EffectRefDestroyed() {
|
||||
fEffectRef = NULL;
|
||||
}
|
||||
|
||||
friend class GrEffectRef; // to call GrEffectRef destroyed
|
||||
|
||||
SkSTArray<4, const GrTextureAccess*, true> fTextureAccesses;
|
||||
GrEffectRef* fEffectPtr;
|
||||
GrEffectRef* fEffectRef;
|
||||
|
||||
typedef GrRefCnt INHERITED;
|
||||
};
|
||||
|
@ -22,20 +22,20 @@ class GrEffectStage {
|
||||
public:
|
||||
|
||||
GrEffectStage()
|
||||
: fEffectPtr (NULL) {
|
||||
: fEffectRef (NULL) {
|
||||
GR_DEBUGCODE(fSavedCoordChangeCnt = 0;)
|
||||
}
|
||||
|
||||
~GrEffectStage() {
|
||||
GrSafeUnref(fEffectPtr);
|
||||
GrSafeUnref(fEffectRef);
|
||||
GrAssert(0 == fSavedCoordChangeCnt);
|
||||
}
|
||||
|
||||
bool operator ==(const GrEffectStage& other) const {
|
||||
// first handle cases where one or the other has no effect
|
||||
if (NULL == fEffectPtr) {
|
||||
return NULL == other.fEffectPtr;
|
||||
} else if (NULL == other.fEffectPtr) {
|
||||
if (NULL == fEffectRef) {
|
||||
return NULL == other.fEffectRef;
|
||||
} else if (NULL == other.fEffectRef) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -53,8 +53,8 @@ public:
|
||||
bool operator !=(const GrEffectStage& s) const { return !(*this == s); }
|
||||
|
||||
GrEffectStage& operator =(const GrEffectStage& other) {
|
||||
GrSafeAssign(fEffectPtr, other.fEffectPtr);
|
||||
if (NULL != fEffectPtr) {
|
||||
GrSafeAssign(fEffectRef, other.fEffectRef);
|
||||
if (NULL != fEffectRef) {
|
||||
fCoordChangeMatrix = other.fCoordChangeMatrix;
|
||||
}
|
||||
return *this;
|
||||
@ -70,7 +70,7 @@ public:
|
||||
class SavedCoordChange {
|
||||
private:
|
||||
SkMatrix fCoordChangeMatrix;
|
||||
GR_DEBUGCODE(mutable SkAutoTUnref<const GrEffectRef> fEffectPtr;)
|
||||
GR_DEBUGCODE(mutable SkAutoTUnref<const GrEffectRef> fEffectRef;)
|
||||
|
||||
friend class GrEffectStage;
|
||||
};
|
||||
@ -83,9 +83,9 @@ public:
|
||||
*/
|
||||
void saveCoordChange(SavedCoordChange* savedCoordChange) const {
|
||||
savedCoordChange->fCoordChangeMatrix = fCoordChangeMatrix;
|
||||
GrAssert(NULL == savedCoordChange->fEffectPtr.get());
|
||||
GR_DEBUGCODE(GrSafeRef(fEffectPtr);)
|
||||
GR_DEBUGCODE(savedCoordChange->fEffectPtr.reset(fEffectPtr);)
|
||||
GrAssert(NULL == savedCoordChange->fEffectRef.get());
|
||||
GR_DEBUGCODE(GrSafeRef(fEffectRef);)
|
||||
GR_DEBUGCODE(savedCoordChange->fEffectRef.reset(fEffectRef);)
|
||||
GR_DEBUGCODE(++fSavedCoordChangeCnt);
|
||||
}
|
||||
|
||||
@ -94,9 +94,9 @@ public:
|
||||
*/
|
||||
void restoreCoordChange(const SavedCoordChange& savedCoordChange) {
|
||||
fCoordChangeMatrix = savedCoordChange.fCoordChangeMatrix;
|
||||
GrAssert(savedCoordChange.fEffectPtr.get() == fEffectPtr);
|
||||
GrAssert(savedCoordChange.fEffectRef.get() == fEffectRef);
|
||||
GR_DEBUGCODE(--fSavedCoordChangeCnt);
|
||||
GR_DEBUGCODE(savedCoordChange.fEffectPtr.reset(NULL);)
|
||||
GR_DEBUGCODE(savedCoordChange.fEffectRef.reset(NULL);)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -106,20 +106,20 @@ public:
|
||||
const SkMatrix& getCoordChangeMatrix() const { return fCoordChangeMatrix; }
|
||||
|
||||
void reset() {
|
||||
GrSafeSetNull(fEffectPtr);
|
||||
GrSafeSetNull(fEffectRef);
|
||||
}
|
||||
|
||||
const GrEffectRef* setEffect(const GrEffectRef* effectPtr) {
|
||||
const GrEffectRef* setEffect(const GrEffectRef* EffectRef) {
|
||||
GrAssert(0 == fSavedCoordChangeCnt);
|
||||
GrSafeAssign(fEffectPtr, effectPtr);
|
||||
GrSafeAssign(fEffectRef, EffectRef);
|
||||
fCoordChangeMatrix.reset();
|
||||
return effectPtr;
|
||||
return EffectRef;
|
||||
}
|
||||
|
||||
// TODO: Push GrEffectRef deeper and make this getter return it rather than GrEffect.
|
||||
const GrEffect* getEffect() const {
|
||||
if (NULL != fEffectPtr) {
|
||||
return fEffectPtr->get();
|
||||
if (NULL != fEffectRef) {
|
||||
return fEffectRef->get();
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
@ -127,7 +127,7 @@ public:
|
||||
|
||||
private:
|
||||
SkMatrix fCoordChangeMatrix;
|
||||
const GrEffectRef* fEffectPtr;
|
||||
const GrEffectRef* fEffectRef;
|
||||
|
||||
GR_DEBUGCODE(mutable int fSavedCoordChangeCnt;)
|
||||
};
|
||||
|
@ -147,7 +147,7 @@ public:
|
||||
GrTexture* foreground,
|
||||
GrTexture* background) {
|
||||
SkAutoTUnref<GrEffect> effect(SkNEW_ARGS(GrBlendEffect, (mode, foreground, background)));
|
||||
return CreateEffectPtr(effect);
|
||||
return CreateEffectRef(effect);
|
||||
}
|
||||
|
||||
virtual ~GrBlendEffect();
|
||||
|
@ -327,7 +327,7 @@ class ColorMatrixEffect : public GrEffect {
|
||||
public:
|
||||
static GrEffectRef* Create(const SkColorMatrix& matrix) {
|
||||
SkAutoTUnref<GrEffect> effect(SkNEW_ARGS(ColorMatrixEffect, (matrix)));
|
||||
return CreateEffectPtr(effect);
|
||||
return CreateEffectRef(effect);
|
||||
}
|
||||
|
||||
static const char* Name() { return "Color Matrix"; }
|
||||
|
@ -240,7 +240,7 @@ public:
|
||||
scale,
|
||||
displacement,
|
||||
color)));
|
||||
return CreateEffectPtr(effect);
|
||||
return CreateEffectRef(effect);
|
||||
}
|
||||
|
||||
virtual ~GrDisplacementMapEffect();
|
||||
|
@ -334,7 +334,7 @@ public:
|
||||
light,
|
||||
surfaceScale,
|
||||
kd)));
|
||||
return CreateEffectPtr(effect);
|
||||
return CreateEffectRef(effect);
|
||||
}
|
||||
|
||||
static const char* Name() { return "DiffuseLighting"; }
|
||||
@ -367,7 +367,7 @@ public:
|
||||
surfaceScale,
|
||||
ks,
|
||||
shininess)));
|
||||
return CreateEffectPtr(effect);
|
||||
return CreateEffectRef(effect);
|
||||
}
|
||||
static const char* Name() { return "SpecularLighting"; }
|
||||
|
||||
|
@ -40,7 +40,7 @@ public:
|
||||
yZoom,
|
||||
xInset,
|
||||
yInset)));
|
||||
return CreateEffectPtr(effect);
|
||||
return CreateEffectRef(effect);
|
||||
}
|
||||
|
||||
virtual ~GrMagnifierEffect() {};
|
||||
|
@ -263,7 +263,7 @@ public:
|
||||
target,
|
||||
tileMode,
|
||||
convolveAlpha)));
|
||||
return CreateEffectPtr(effect);
|
||||
return CreateEffectRef(effect);
|
||||
}
|
||||
virtual ~GrMatrixConvolutionEffect();
|
||||
|
||||
|
@ -245,7 +245,7 @@ public:
|
||||
|
||||
static GrEffectRef* Create(GrTexture* tex, Direction dir, int radius, MorphologyType type) {
|
||||
SkAutoTUnref<GrEffect> effect(SkNEW_ARGS(GrMorphologyEffect, (tex, dir, radius, type)));
|
||||
return CreateEffectPtr(effect);
|
||||
return CreateEffectRef(effect);
|
||||
}
|
||||
|
||||
virtual ~GrMorphologyEffect();
|
||||
|
@ -228,7 +228,7 @@ class ColorTableEffect : public GrEffect {
|
||||
public:
|
||||
static GrEffectRef* Create(GrTexture* texture, unsigned flags) {
|
||||
SkAutoTUnref<GrEffect> effect(SkNEW_ARGS(ColorTableEffect, (texture, flags)));
|
||||
return CreateEffectPtr(effect);
|
||||
return CreateEffectRef(effect);
|
||||
}
|
||||
|
||||
virtual ~ColorTableEffect();
|
||||
|
@ -489,7 +489,7 @@ public:
|
||||
const SkMatrix& matrix,
|
||||
SkShader::TileMode tm) {
|
||||
SkAutoTUnref<GrEffect> effect(SkNEW_ARGS(GrLinearGradient, (ctx, shader, matrix, tm)));
|
||||
return CreateEffectPtr(effect);
|
||||
return CreateEffectRef(effect);
|
||||
}
|
||||
|
||||
virtual ~GrLinearGradient() { }
|
||||
|
@ -509,7 +509,7 @@ public:
|
||||
const SkMatrix& matrix,
|
||||
SkShader::TileMode tm) {
|
||||
SkAutoTUnref<GrEffect> effect(SkNEW_ARGS(GrRadialGradient, (ctx, shader, matrix, tm)));
|
||||
return CreateEffectPtr(effect);
|
||||
return CreateEffectRef(effect);
|
||||
}
|
||||
|
||||
virtual ~GrRadialGradient() { }
|
||||
|
@ -417,7 +417,7 @@ public:
|
||||
const SkSweepGradient& shader,
|
||||
const SkMatrix& matrix) {
|
||||
SkAutoTUnref<GrEffect> effect(SkNEW_ARGS(GrSweepGradient, (ctx, shader, matrix)));
|
||||
return CreateEffectPtr(effect);
|
||||
return CreateEffectRef(effect);
|
||||
}
|
||||
virtual ~GrSweepGradient() { }
|
||||
|
||||
|
@ -374,7 +374,7 @@ public:
|
||||
const SkMatrix& matrix,
|
||||
SkShader::TileMode tm) {
|
||||
SkAutoTUnref<GrEffect> effect(SkNEW_ARGS(GrConical2Gradient, (ctx, shader, matrix, tm)));
|
||||
return CreateEffectPtr(effect);
|
||||
return CreateEffectRef(effect);
|
||||
}
|
||||
|
||||
virtual ~GrConical2Gradient() { }
|
||||
|
@ -433,7 +433,7 @@ public:
|
||||
const SkMatrix& matrix,
|
||||
SkShader::TileMode tm) {
|
||||
SkAutoTUnref<GrEffect> effect(SkNEW_ARGS(GrRadial2Gradient, (ctx, shader, matrix, tm)));
|
||||
return CreateEffectPtr(effect);
|
||||
return CreateEffectRef(effect);
|
||||
}
|
||||
|
||||
virtual ~GrRadial2Gradient() { }
|
||||
|
@ -64,7 +64,7 @@ SK_DEFINE_INST_COUNT(GrEffectRef)
|
||||
|
||||
GrEffectRef::~GrEffectRef() {
|
||||
GrAssert(1 == this->getRefCnt());
|
||||
fEffect->effectPtrDestroyed();
|
||||
fEffect->EffectRefDestroyed();
|
||||
fEffect->unref();
|
||||
}
|
||||
|
||||
@ -79,7 +79,7 @@ void GrEffectRef::operator delete(void* target) {
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
GrEffect::~GrEffect() {
|
||||
GrAssert(NULL == fEffectPtr);
|
||||
GrAssert(NULL == fEffectRef);
|
||||
}
|
||||
|
||||
const char* GrEffect::name() const {
|
||||
|
@ -139,7 +139,7 @@ GrEffectRef* GrConfigConversionEffect::TestCreate(SkRandom* random,
|
||||
swapRB,
|
||||
pmConv,
|
||||
GrEffectUnitTest::TestMatrix(random))));
|
||||
return CreateEffectPtr(effect);
|
||||
return CreateEffectRef(effect);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@ -219,9 +219,9 @@ void GrConfigConversionEffect::TestForPreservingPMConversions(GrContext* context
|
||||
*pmToUPMRule,
|
||||
SkMatrix::I())));
|
||||
|
||||
SkAutoTUnref<GrEffectRef> pmToUPMEffect1(CreateEffectPtr(pmToUPM1));
|
||||
SkAutoTUnref<GrEffectRef> upmToPMEffect(CreateEffectPtr(upmToPM));
|
||||
SkAutoTUnref<GrEffectRef> pmToUPMEffect2(CreateEffectPtr(pmToUPM2));
|
||||
SkAutoTUnref<GrEffectRef> pmToUPMEffect1(CreateEffectRef(pmToUPM1));
|
||||
SkAutoTUnref<GrEffectRef> upmToPMEffect(CreateEffectRef(upmToPM));
|
||||
SkAutoTUnref<GrEffectRef> pmToUPMEffect2(CreateEffectRef(pmToUPM2));
|
||||
|
||||
context->setRenderTarget(readTex->asRenderTarget());
|
||||
paint.colorStage(0)->setEffect(pmToUPMEffect1);
|
||||
@ -276,7 +276,7 @@ bool GrConfigConversionEffect::InstallEffect(GrTexture* texture,
|
||||
swapRedAndBlue,
|
||||
pmConversion,
|
||||
matrix)));
|
||||
stage->setEffect(CreateEffectPtr(effect))->unref();
|
||||
stage->setEffect(CreateEffectRef(effect))->unref();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ public:
|
||||
dir,
|
||||
halfWidth,
|
||||
kernel)));
|
||||
return CreateEffectPtr(effect);
|
||||
return CreateEffectRef(effect);
|
||||
}
|
||||
|
||||
/// Convolve with a Gaussian kernel
|
||||
@ -39,7 +39,7 @@ public:
|
||||
dir,
|
||||
halfWidth,
|
||||
gaussianSigma)));
|
||||
return CreateEffectPtr(effect);
|
||||
return CreateEffectRef(effect);
|
||||
}
|
||||
|
||||
virtual ~GrConvolutionEffect();
|
||||
|
@ -23,18 +23,18 @@ public:
|
||||
/* unfiltered, clamp mode */
|
||||
static GrEffectRef* Create(GrTexture* tex, const SkMatrix& matrix) {
|
||||
SkAutoTUnref<GrEffect> effect(SkNEW_ARGS(GrSingleTextureEffect, (tex, matrix)));
|
||||
return CreateEffectPtr(effect);
|
||||
return CreateEffectRef(effect);
|
||||
}
|
||||
|
||||
/* clamp mode */
|
||||
static GrEffectRef* Create(GrTexture* tex, const SkMatrix& matrix, bool bilerp) {
|
||||
SkAutoTUnref<GrEffect> effect(SkNEW_ARGS(GrSingleTextureEffect, (tex, matrix, bilerp)));
|
||||
return CreateEffectPtr(effect);
|
||||
return CreateEffectRef(effect);
|
||||
}
|
||||
|
||||
static GrEffectRef* Create(GrTexture* tex, const SkMatrix& matrix, const GrTextureParams& p) {
|
||||
SkAutoTUnref<GrEffect> effect(SkNEW_ARGS(GrSingleTextureEffect, (tex, matrix, p)));
|
||||
return CreateEffectPtr(effect);
|
||||
return CreateEffectRef(effect);
|
||||
}
|
||||
|
||||
virtual ~GrSingleTextureEffect();
|
||||
|
@ -148,7 +148,7 @@ GrEffectRef* GrTextureDomainEffect::Create(GrTexture* texture,
|
||||
clippedDomain,
|
||||
wrapMode,
|
||||
bilerp)));
|
||||
return CreateEffectPtr(effect);
|
||||
return CreateEffectRef(effect);
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user