diff --git a/include/gpu/GrEffect.h b/include/gpu/GrEffect.h index 978ad3a6a6..13a6c4308f 100644 --- a/include/gpu/GrEffect.h +++ b/include/gpu/GrEffect.h @@ -169,29 +169,7 @@ protected: , fWillUseInputColor(true) , fHasVertexCode(false) {} - /** This should be called by GrEffect subclass factories. See the comment on AutoEffectUnref for - an example factory function. */ - static GrEffect* CreateEffectRef(GrEffect* effect) { - return SkRef(effect); - } - - static const GrEffect* CreateEffectRef(const GrEffect* effect) { - return CreateEffectRef(const_cast(effect)); - } - - /** Helper used in subclass factory functions to unref the effect after it has been wrapped in a - GrEffectRef. E.g.: - - class EffectSubclass : public GrEffect { - public: - GrEffectRef* Create(ParamType1 param1, ParamType2 param2, ...) { - AutoEffectUnref effect(SkNEW_ARGS(EffectSubclass, (param1, param2, ...))); - return CreateEffectRef(effect); - } - */ - typedef SkAutoTUnref AutoEffectUnref; - - /** Helper for getting the GrEffect out of a GrEffectRef and down-casting to a GrEffect subclass + /** Helper for down-casting to a GrEffect subclass */ template static const T& CastEffect(const GrEffect& effectRef) { diff --git a/src/core/SkXfermode.cpp b/src/core/SkXfermode.cpp index b3e2ed16bf..cf4f19f448 100644 --- a/src/core/SkXfermode.cpp +++ b/src/core/SkXfermode.cpp @@ -797,8 +797,7 @@ public: if (!IsSupportedMode(mode)) { return NULL; } else { - AutoEffectUnref effect(SkNEW_ARGS(XferEffect, (mode, background))); - return CreateEffectRef(effect); + return SkNEW_ARGS(XferEffect, (mode, background)); } } @@ -1230,8 +1229,7 @@ GrEffectRef* XferEffect::TestCreate(SkRandom* rand, GrTexture*[]) { int mode = rand->nextRangeU(SkXfermode::kLastCoeffMode + 1, SkXfermode::kLastSeparableMode); - AutoEffectUnref gEffect(SkNEW_ARGS(XferEffect, (static_cast(mode), NULL))); - return CreateEffectRef(gEffect); + return SkNEW_ARGS(XferEffect, (static_cast(mode), NULL)); } #endif diff --git a/src/effects/SkAlphaThresholdFilter.cpp b/src/effects/SkAlphaThresholdFilter.cpp index 0bc906dae9..b375c88c11 100644 --- a/src/effects/SkAlphaThresholdFilter.cpp +++ b/src/effects/SkAlphaThresholdFilter.cpp @@ -60,11 +60,10 @@ public: GrTexture* maskTexture, float innerThreshold, float outerThreshold) { - AutoEffectUnref effect(SkNEW_ARGS(AlphaThresholdEffect, (texture, - maskTexture, - innerThreshold, - outerThreshold))); - return CreateEffectRef(effect); + return SkNEW_ARGS(AlphaThresholdEffect, (texture, + maskTexture, + innerThreshold, + outerThreshold)); } virtual ~AlphaThresholdEffect() {}; diff --git a/src/effects/SkArithmeticMode.cpp b/src/effects/SkArithmeticMode.cpp index 41cc266741..f04ccf23f3 100644 --- a/src/effects/SkArithmeticMode.cpp +++ b/src/effects/SkArithmeticMode.cpp @@ -264,9 +264,7 @@ class GrArithmeticEffect : public GrEffect { public: static GrEffectRef* Create(float k1, float k2, float k3, float k4, bool enforcePMColor, GrTexture* background) { - AutoEffectUnref effect(SkNEW_ARGS(GrArithmeticEffect, (k1, k2, k3, k4, enforcePMColor, - background))); - return CreateEffectRef(effect); + return SkNEW_ARGS(GrArithmeticEffect, (k1, k2, k3, k4, enforcePMColor, background)); } virtual ~GrArithmeticEffect(); @@ -422,9 +420,7 @@ GrEffectRef* GrArithmeticEffect::TestCreate(SkRandom* rand, float k4 = rand->nextF(); bool enforcePMColor = rand->nextBool(); - AutoEffectUnref gEffect(SkNEW_ARGS(GrArithmeticEffect, - (k1, k2, k3, k4, enforcePMColor, NULL))); - return CreateEffectRef(gEffect); + return SkNEW_ARGS(GrArithmeticEffect, (k1, k2, k3, k4, enforcePMColor, NULL)); } GR_DEFINE_EFFECT_TEST(GrArithmeticEffect); diff --git a/src/effects/SkBlurMaskFilter.cpp b/src/effects/SkBlurMaskFilter.cpp index fca38a1eaa..86a4f5a1a5 100644 --- a/src/effects/SkBlurMaskFilter.cpp +++ b/src/effects/SkBlurMaskFilter.cpp @@ -572,8 +572,7 @@ public: if (!createdBlurProfileTexture) { return NULL; } - AutoEffectUnref effect(SkNEW_ARGS(GrRectBlurEffect, (rect, sigma, blurProfileTexture))); - return CreateEffectRef(effect); + return SkNEW_ARGS(GrRectBlurEffect, (rect, sigma, blurProfileTexture)); } const SkRect& getRect() const { return fRect; } @@ -914,8 +913,7 @@ GrEffectRef* GrRRectBlurEffect::Create(GrContext* context, float sigma, const Sk return NULL; } - return CreateEffectRef(AutoEffectUnref(SkNEW_ARGS(GrRRectBlurEffect, - (sigma, rrect, blurNinePatchTexture)))); + return SkNEW_ARGS(GrRRectBlurEffect, (sigma, rrect, blurNinePatchTexture)); } void GrRRectBlurEffect::getConstantColorComponents(GrColor* color, uint32_t* validFlags) const { diff --git a/src/effects/SkColorFilters.cpp b/src/effects/SkColorFilters.cpp index bee3a50f3b..18dbb9509e 100644 --- a/src/effects/SkColorFilters.cpp +++ b/src/effects/SkColorFilters.cpp @@ -195,8 +195,7 @@ public: SkDebugf("Failing to create color filter for mode %d\n", mode); return NULL; } - AutoEffectUnref effect(SkNEW_ARGS(ModeColorFilterEffect, (c, mode))); - return CreateEffectRef(effect); + return SkNEW_ARGS(ModeColorFilterEffect, (c, mode)); } virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags) const SK_OVERRIDE; diff --git a/src/effects/SkColorMatrixFilter.cpp b/src/effects/SkColorMatrixFilter.cpp index bd1df79d14..b3b9c295ab 100644 --- a/src/effects/SkColorMatrixFilter.cpp +++ b/src/effects/SkColorMatrixFilter.cpp @@ -331,8 +331,7 @@ bool SkColorMatrixFilter::asColorMatrix(SkScalar matrix[20]) const { class ColorMatrixEffect : public GrEffect { public: static GrEffectRef* Create(const SkColorMatrix& matrix) { - AutoEffectUnref effect(SkNEW_ARGS(ColorMatrixEffect, (matrix))); - return CreateEffectRef(effect); + return SkNEW_ARGS(ColorMatrixEffect, (matrix)); } static const char* Name() { return "Color Matrix"; } diff --git a/src/effects/SkDisplacementMapEffect.cpp b/src/effects/SkDisplacementMapEffect.cpp index a5519d1e9a..44c3908779 100644 --- a/src/effects/SkDisplacementMapEffect.cpp +++ b/src/effects/SkDisplacementMapEffect.cpp @@ -305,13 +305,12 @@ public: SkVector scale, GrTexture* displacement, const SkMatrix& offsetMatrix, GrTexture* color) { - AutoEffectUnref effect(SkNEW_ARGS(GrDisplacementMapEffect, (xChannelSelector, - yChannelSelector, - scale, - displacement, - offsetMatrix, - color))); - return CreateEffectRef(effect); + return SkNEW_ARGS(GrDisplacementMapEffect, (xChannelSelector, + yChannelSelector, + scale, + displacement, + offsetMatrix, + color)); } virtual ~GrDisplacementMapEffect(); diff --git a/src/effects/SkLightingImageFilter.cpp b/src/effects/SkLightingImageFilter.cpp index c0c605ca04..5fc3474e3d 100644 --- a/src/effects/SkLightingImageFilter.cpp +++ b/src/effects/SkLightingImageFilter.cpp @@ -339,12 +339,11 @@ public: SkScalar surfaceScale, const SkMatrix& matrix, SkScalar kd) { - AutoEffectUnref effect(SkNEW_ARGS(GrDiffuseLightingEffect, (texture, - light, - surfaceScale, - matrix, - kd))); - return CreateEffectRef(effect); + return SkNEW_ARGS(GrDiffuseLightingEffect, (texture, + light, + surfaceScale, + matrix, + kd)); } static const char* Name() { return "DiffuseLighting"; } @@ -376,13 +375,12 @@ public: const SkMatrix& matrix, SkScalar ks, SkScalar shininess) { - AutoEffectUnref effect(SkNEW_ARGS(GrSpecularLightingEffect, (texture, - light, - surfaceScale, - matrix, - ks, - shininess))); - return CreateEffectRef(effect); + return SkNEW_ARGS(GrSpecularLightingEffect, (texture, + light, + surfaceScale, + matrix, + ks, + shininess)); } static const char* Name() { return "SpecularLighting"; } diff --git a/src/effects/SkLumaColorFilter.cpp b/src/effects/SkLumaColorFilter.cpp index 4c90f3d4f4..54dfc08c19 100644 --- a/src/effects/SkLumaColorFilter.cpp +++ b/src/effects/SkLumaColorFilter.cpp @@ -61,8 +61,8 @@ void SkLumaColorFilter::toString(SkString* str) const { class LumaColorFilterEffect : public GrEffect { public: static GrEffectRef* Create() { - AutoEffectUnref effect(SkNEW(LumaColorFilterEffect)); - return CreateEffectRef(effect); + GR_CREATE_STATIC_EFFECT(gLumaEffect, LumaColorFilterEffect, ()); + return SkRef(gLumaEffect); } static const char* Name() { return "Luminance-to-Alpha"; } diff --git a/src/effects/SkMagnifierImageFilter.cpp b/src/effects/SkMagnifierImageFilter.cpp index 99c0176a11..16f4066d3a 100644 --- a/src/effects/SkMagnifierImageFilter.cpp +++ b/src/effects/SkMagnifierImageFilter.cpp @@ -32,14 +32,13 @@ public: float yInvZoom, float xInvInset, float yInvInset) { - AutoEffectUnref effect(SkNEW_ARGS(GrMagnifierEffect, (texture, - xOffset, - yOffset, - xInvZoom, - yInvZoom, - xInvInset, - yInvInset))); - return CreateEffectRef(effect); + return SkNEW_ARGS(GrMagnifierEffect, (texture, + xOffset, + yOffset, + xInvZoom, + yInvZoom, + xInvInset, + yInvInset)); } virtual ~GrMagnifierEffect() {}; diff --git a/src/effects/SkMatrixConvolutionImageFilter.cpp b/src/effects/SkMatrixConvolutionImageFilter.cpp index ca2cfcaab7..2740edc3ef 100644 --- a/src/effects/SkMatrixConvolutionImageFilter.cpp +++ b/src/effects/SkMatrixConvolutionImageFilter.cpp @@ -339,16 +339,15 @@ public: const SkIPoint& kernelOffset, TileMode tileMode, bool convolveAlpha) { - AutoEffectUnref effect(SkNEW_ARGS(GrMatrixConvolutionEffect, (texture, - bounds, - kernelSize, - kernel, - gain, - bias, - kernelOffset, - tileMode, - convolveAlpha))); - return CreateEffectRef(effect); + return SkNEW_ARGS(GrMatrixConvolutionEffect, (texture, + bounds, + kernelSize, + kernel, + gain, + bias, + kernelOffset, + tileMode, + convolveAlpha)); } virtual ~GrMatrixConvolutionEffect(); diff --git a/src/effects/SkMorphologyImageFilter.cpp b/src/effects/SkMorphologyImageFilter.cpp index 19a9b68aa8..8de8ddaf68 100644 --- a/src/effects/SkMorphologyImageFilter.cpp +++ b/src/effects/SkMorphologyImageFilter.cpp @@ -279,8 +279,7 @@ public: }; static GrEffectRef* Create(GrTexture* tex, Direction dir, int radius, MorphologyType type) { - AutoEffectUnref effect(SkNEW_ARGS(GrMorphologyEffect, (tex, dir, radius, type))); - return CreateEffectRef(effect); + return SkNEW_ARGS(GrMorphologyEffect, (tex, dir, radius, type)); } virtual ~GrMorphologyEffect(); diff --git a/src/effects/SkPerlinNoiseShader.cpp b/src/effects/SkPerlinNoiseShader.cpp index 502cc0764b..894af42cea 100644 --- a/src/effects/SkPerlinNoiseShader.cpp +++ b/src/effects/SkPerlinNoiseShader.cpp @@ -530,9 +530,8 @@ public: SkPerlinNoiseShader::PaintingData* paintingData, GrTexture* permutationsTexture, GrTexture* noiseTexture, const SkMatrix& matrix, uint8_t alpha) { - AutoEffectUnref effect(SkNEW_ARGS(GrPerlinNoiseEffect, (type, numOctaves, - stitchTiles, paintingData, permutationsTexture, noiseTexture, matrix, alpha))); - return CreateEffectRef(effect); + return SkNEW_ARGS(GrPerlinNoiseEffect, (type, numOctaves, stitchTiles, paintingData, + permutationsTexture, noiseTexture, matrix, alpha)); } virtual ~GrPerlinNoiseEffect() { diff --git a/src/effects/SkTableColorFilter.cpp b/src/effects/SkTableColorFilter.cpp index 771d2fa0d3..d4a111e64b 100644 --- a/src/effects/SkTableColorFilter.cpp +++ b/src/effects/SkTableColorFilter.cpp @@ -237,8 +237,7 @@ class GLColorTableEffect; class ColorTableEffect : public GrEffect { public: static GrEffectRef* Create(GrTexture* texture, unsigned flags) { - AutoEffectUnref effect(SkNEW_ARGS(ColorTableEffect, (texture, flags))); - return CreateEffectRef(effect); + return SkNEW_ARGS(ColorTableEffect, (texture, flags)); } virtual ~ColorTableEffect(); diff --git a/src/effects/gradients/SkLinearGradient.cpp b/src/effects/gradients/SkLinearGradient.cpp index 768623a2b0..d518cc700f 100644 --- a/src/effects/gradients/SkLinearGradient.cpp +++ b/src/effects/gradients/SkLinearGradient.cpp @@ -484,8 +484,7 @@ public: const SkLinearGradient& shader, const SkMatrix& matrix, SkShader::TileMode tm) { - AutoEffectUnref effect(SkNEW_ARGS(GrLinearGradient, (ctx, shader, matrix, tm))); - return CreateEffectRef(effect); + return SkNEW_ARGS(GrLinearGradient, (ctx, shader, matrix, tm)); } virtual ~GrLinearGradient() { } diff --git a/src/effects/gradients/SkRadialGradient.cpp b/src/effects/gradients/SkRadialGradient.cpp index 38e6f33b38..bb60d0f061 100644 --- a/src/effects/gradients/SkRadialGradient.cpp +++ b/src/effects/gradients/SkRadialGradient.cpp @@ -493,8 +493,7 @@ public: const SkRadialGradient& shader, const SkMatrix& matrix, SkShader::TileMode tm) { - AutoEffectUnref effect(SkNEW_ARGS(GrRadialGradient, (ctx, shader, matrix, tm))); - return CreateEffectRef(effect); + return SkNEW_ARGS(GrRadialGradient, (ctx, shader, matrix, tm)); } virtual ~GrRadialGradient() { } diff --git a/src/effects/gradients/SkSweepGradient.cpp b/src/effects/gradients/SkSweepGradient.cpp index 3b54ac8ae9..b3474ec1a2 100644 --- a/src/effects/gradients/SkSweepGradient.cpp +++ b/src/effects/gradients/SkSweepGradient.cpp @@ -208,8 +208,7 @@ public: static GrEffectRef* Create(GrContext* ctx, const SkSweepGradient& shader, const SkMatrix& matrix) { - AutoEffectUnref effect(SkNEW_ARGS(GrSweepGradient, (ctx, shader, matrix))); - return CreateEffectRef(effect); + return SkNEW_ARGS(GrSweepGradient, (ctx, shader, matrix)); } virtual ~GrSweepGradient() { } diff --git a/src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp b/src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp index 4f9f758467..b6959e32e1 100644 --- a/src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp +++ b/src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp @@ -63,8 +63,7 @@ public: const SkTwoPointConicalGradient& shader, const SkMatrix& matrix, SkShader::TileMode tm) { - AutoEffectUnref effect(SkNEW_ARGS(Edge2PtConicalEffect, (ctx, shader, matrix, tm))); - return CreateEffectRef(effect); + return SkNEW_ARGS(Edge2PtConicalEffect, (ctx, shader, matrix, tm)); } virtual ~Edge2PtConicalEffect() {} @@ -371,8 +370,7 @@ public: const SkMatrix& matrix, SkShader::TileMode tm, SkScalar focalX) { - AutoEffectUnref effect(SkNEW_ARGS(FocalOutside2PtConicalEffect, (ctx, shader, matrix, tm, focalX))); - return CreateEffectRef(effect); + return SkNEW_ARGS(FocalOutside2PtConicalEffect, (ctx, shader, matrix, tm, focalX)); } virtual ~FocalOutside2PtConicalEffect() { } @@ -586,8 +584,7 @@ public: const SkMatrix& matrix, SkShader::TileMode tm, SkScalar focalX) { - AutoEffectUnref effect(SkNEW_ARGS(FocalInside2PtConicalEffect, (ctx, shader, matrix, tm, focalX))); - return CreateEffectRef(effect); + return SkNEW_ARGS(FocalInside2PtConicalEffect, (ctx, shader, matrix, tm, focalX)); } virtual ~FocalInside2PtConicalEffect() {} @@ -820,8 +817,7 @@ public: const SkMatrix& matrix, SkShader::TileMode tm, const CircleConicalInfo& info) { - AutoEffectUnref effect(SkNEW_ARGS(CircleInside2PtConicalEffect, (ctx, shader, matrix, tm, info))); - return CreateEffectRef(effect); + return SkNEW_ARGS(CircleInside2PtConicalEffect, (ctx, shader, matrix, tm, info)); } virtual ~CircleInside2PtConicalEffect() {} @@ -1033,8 +1029,7 @@ public: const SkMatrix& matrix, SkShader::TileMode tm, const CircleConicalInfo& info) { - AutoEffectUnref effect(SkNEW_ARGS(CircleOutside2PtConicalEffect, (ctx, shader, matrix, tm, info))); - return CreateEffectRef(effect); + return SkNEW_ARGS(CircleOutside2PtConicalEffect, (ctx, shader, matrix, tm, info)); } virtual ~CircleOutside2PtConicalEffect() {} diff --git a/src/effects/gradients/SkTwoPointRadialGradient.cpp b/src/effects/gradients/SkTwoPointRadialGradient.cpp index 3507c891c0..22feb7189c 100644 --- a/src/effects/gradients/SkTwoPointRadialGradient.cpp +++ b/src/effects/gradients/SkTwoPointRadialGradient.cpp @@ -438,8 +438,7 @@ public: const SkTwoPointRadialGradient& shader, const SkMatrix& matrix, SkShader::TileMode tm) { - AutoEffectUnref effect(SkNEW_ARGS(GrRadial2Gradient, (ctx, shader, matrix, tm))); - return CreateEffectRef(effect); + return SkNEW_ARGS(GrRadial2Gradient, (ctx, shader, matrix, tm)); } virtual ~GrRadial2Gradient() { } diff --git a/src/gpu/effects/GrBicubicEffect.h b/src/gpu/effects/GrBicubicEffect.h index 1998e68780..eea4d4e883 100644 --- a/src/gpu/effects/GrBicubicEffect.h +++ b/src/gpu/effects/GrBicubicEffect.h @@ -44,10 +44,8 @@ public: SkShader::kClamp_TileMode }; return Create(tex, coefficients, MakeDivByTextureWHMatrix(tex), kTileModes); } else { - AutoEffectUnref effect(SkNEW_ARGS(GrBicubicEffect, (tex, coefficients, - MakeDivByTextureWHMatrix(tex), - *domain))); - return CreateEffectRef(effect); + return SkNEW_ARGS(GrBicubicEffect, (tex, coefficients, + MakeDivByTextureWHMatrix(tex), *domain)); } } @@ -65,17 +63,14 @@ public: */ static GrEffectRef* Create(GrTexture* tex, const SkScalar coefficients[16], const SkMatrix& matrix, const SkShader::TileMode tileModes[2]) { - AutoEffectUnref effect(SkNEW_ARGS(GrBicubicEffect, (tex, coefficients, matrix, tileModes))); - return CreateEffectRef(effect); + return SkNEW_ARGS(GrBicubicEffect, (tex, coefficients, matrix, tileModes)); } /** * Create a Mitchell filter effect with a texture matrix and a domain. */ static GrEffectRef* Create(GrTexture* tex, const SkMatrix& matrix, const SkRect& domain) { - AutoEffectUnref effect(SkNEW_ARGS(GrBicubicEffect, (tex, gMitchellCoefficients, matrix, - domain))); - return CreateEffectRef(effect); + return SkNEW_ARGS(GrBicubicEffect, (tex, gMitchellCoefficients, matrix, domain)); } /** diff --git a/src/gpu/effects/GrConfigConversionEffect.cpp b/src/gpu/effects/GrConfigConversionEffect.cpp index f33ad239c5..260008c1e5 100644 --- a/src/gpu/effects/GrConfigConversionEffect.cpp +++ b/src/gpu/effects/GrConfigConversionEffect.cpp @@ -129,12 +129,11 @@ GrEffectRef* GrConfigConversionEffect::TestCreate(SkRandom* random, } else { swapRB = random->nextBool(); } - AutoEffectUnref effect(SkNEW_ARGS(GrConfigConversionEffect, + return SkNEW_ARGS(GrConfigConversionEffect, (textures[GrEffectUnitTest::kSkiaPMTextureIdx], swapRB, pmConv, - GrEffectUnitTest::TestMatrix(random)))); - return CreateEffectRef(effect); + GrEffectUnitTest::TestMatrix(random))); } /////////////////////////////////////////////////////////////////////////////// @@ -200,38 +199,34 @@ void GrConfigConversionEffect::TestForPreservingPMConversions(GrContext* context // from readTex to tempTex followed by a PM->UPM draw to readTex and finally read the data. // We then verify that two reads produced the same values. - AutoEffectUnref pmToUPM1(SkNEW_ARGS(GrConfigConversionEffect, (dataTex, - false, - *pmToUPMRule, - SkMatrix::I()))); - AutoEffectUnref upmToPM(SkNEW_ARGS(GrConfigConversionEffect, (readTex, - false, - *upmToPMRule, - SkMatrix::I()))); - AutoEffectUnref pmToUPM2(SkNEW_ARGS(GrConfigConversionEffect, (tempTex, - false, - *pmToUPMRule, - SkMatrix::I()))); - - SkAutoTUnref pmToUPMEffect1(CreateEffectRef(pmToUPM1)); - SkAutoTUnref upmToPMEffect(CreateEffectRef(upmToPM)); - SkAutoTUnref pmToUPMEffect2(CreateEffectRef(pmToUPM2)); + SkAutoTUnref pmToUPM1(SkNEW_ARGS(GrConfigConversionEffect, (dataTex, + false, + *pmToUPMRule, + SkMatrix::I()))); + SkAutoTUnref upmToPM(SkNEW_ARGS(GrConfigConversionEffect, (readTex, + false, + *upmToPMRule, + SkMatrix::I()))); + SkAutoTUnref pmToUPM2(SkNEW_ARGS(GrConfigConversionEffect, (tempTex, + false, + *pmToUPMRule, + SkMatrix::I()))); context->setRenderTarget(readTex->asRenderTarget()); GrPaint paint1; - paint1.addColorEffect(pmToUPMEffect1); + paint1.addColorEffect(pmToUPM1); context->drawRectToRect(paint1, kDstRect, kSrcRect); readTex->readPixels(0, 0, 256, 256, kRGBA_8888_GrPixelConfig, firstRead); context->setRenderTarget(tempTex->asRenderTarget()); GrPaint paint2; - paint2.addColorEffect(upmToPMEffect); + paint2.addColorEffect(upmToPM); context->drawRectToRect(paint2, kDstRect, kSrcRect); context->setRenderTarget(readTex->asRenderTarget()); GrPaint paint3; - paint3.addColorEffect(pmToUPMEffect2); + paint3.addColorEffect(pmToUPM2); context->drawRectToRect(paint3, kDstRect, kSrcRect); readTex->readPixels(0, 0, 256, 256, kRGBA_8888_GrPixelConfig, secondRead); @@ -268,10 +263,9 @@ const GrEffectRef* GrConfigConversionEffect::Create(GrTexture* texture, // The PM conversions assume colors are 0..255 return NULL; } - AutoEffectUnref effect(SkNEW_ARGS(GrConfigConversionEffect, (texture, - swapRedAndBlue, - pmConversion, - matrix))); - return CreateEffectRef(effect); + return SkNEW_ARGS(GrConfigConversionEffect, (texture, + swapRedAndBlue, + pmConversion, + matrix)); } } diff --git a/src/gpu/effects/GrConvexPolyEffect.cpp b/src/gpu/effects/GrConvexPolyEffect.cpp index d24b45e10b..aebd5b0b89 100644 --- a/src/gpu/effects/GrConvexPolyEffect.cpp +++ b/src/gpu/effects/GrConvexPolyEffect.cpp @@ -25,7 +25,7 @@ public: static const char* Name() { return "AARect"; } static GrEffectRef* Create(GrEffectEdgeType edgeType, const SkRect& rect) { - return CreateEffectRef(AutoEffectUnref(SkNEW_ARGS(AARectEffect, (edgeType, rect)))); + return SkNEW_ARGS(AARectEffect, (edgeType, rect)); } virtual void getConstantColorComponents(GrColor* color, diff --git a/src/gpu/effects/GrConvexPolyEffect.h b/src/gpu/effects/GrConvexPolyEffect.h index 0e508c7c48..1a00f12d8a 100644 --- a/src/gpu/effects/GrConvexPolyEffect.h +++ b/src/gpu/effects/GrConvexPolyEffect.h @@ -41,8 +41,7 @@ public: if (n <= 0 || n > kMaxEdges || kHairlineAA_GrEffectEdgeType == edgeType) { return NULL; } - return CreateEffectRef(AutoEffectUnref(SkNEW_ARGS(GrConvexPolyEffect, - (edgeType, n, edges)))); + return SkNEW_ARGS(GrConvexPolyEffect, (edgeType, n, edges)); } /** diff --git a/src/gpu/effects/GrConvolutionEffect.h b/src/gpu/effects/GrConvolutionEffect.h index 56a54b4a6a..77c2d347c6 100644 --- a/src/gpu/effects/GrConvolutionEffect.h +++ b/src/gpu/effects/GrConvolutionEffect.h @@ -28,13 +28,12 @@ public: const float* kernel, bool useBounds, float bounds[2]) { - AutoEffectUnref effect(SkNEW_ARGS(GrConvolutionEffect, (tex, - dir, - halfWidth, - kernel, - useBounds, - bounds))); - return CreateEffectRef(effect); + return SkNEW_ARGS(GrConvolutionEffect, (tex, + dir, + halfWidth, + kernel, + useBounds, + bounds)); } /// Convolve with a Gaussian kernel @@ -44,13 +43,12 @@ public: float gaussianSigma, bool useBounds, float bounds[2]) { - AutoEffectUnref effect(SkNEW_ARGS(GrConvolutionEffect, (tex, - dir, - halfWidth, - gaussianSigma, - useBounds, - bounds))); - return CreateEffectRef(effect); + return SkNEW_ARGS(GrConvolutionEffect, (tex, + dir, + halfWidth, + gaussianSigma, + useBounds, + bounds)); } virtual ~GrConvolutionEffect(); diff --git a/src/gpu/effects/GrCustomCoordsTextureEffect.h b/src/gpu/effects/GrCustomCoordsTextureEffect.h index 1caecf2f6d..5dc830aed1 100644 --- a/src/gpu/effects/GrCustomCoordsTextureEffect.h +++ b/src/gpu/effects/GrCustomCoordsTextureEffect.h @@ -21,8 +21,7 @@ class GrGLCustomCoordsTextureEffect; class GrCustomCoordsTextureEffect : public GrVertexEffect { public: static GrEffectRef* Create(GrTexture* tex, const GrTextureParams& p) { - AutoEffectUnref effect(SkNEW_ARGS(GrCustomCoordsTextureEffect, (tex, p))); - return CreateEffectRef(effect); + return SkNEW_ARGS(GrCustomCoordsTextureEffect, (tex, p)); } virtual ~GrCustomCoordsTextureEffect() {} diff --git a/src/gpu/effects/GrDashingEffect.cpp b/src/gpu/effects/GrDashingEffect.cpp index e46cc040c7..fb58b84bc3 100644 --- a/src/gpu/effects/GrDashingEffect.cpp +++ b/src/gpu/effects/GrDashingEffect.cpp @@ -563,8 +563,7 @@ GrEffectRef* DashingCircleEffect::Create(GrEffectEdgeType edgeType, const DashIn return NULL; } - return CreateEffectRef(AutoEffectUnref(SkNEW_ARGS(DashingCircleEffect, - (edgeType, info, radius)))); + return SkNEW_ARGS(DashingCircleEffect, (edgeType, info, radius)); } DashingCircleEffect::~DashingCircleEffect() {} @@ -782,8 +781,7 @@ GrEffectRef* DashingLineEffect::Create(GrEffectEdgeType edgeType, const DashInfo return NULL; } - return CreateEffectRef(AutoEffectUnref(SkNEW_ARGS(DashingLineEffect, - (edgeType, info, strokeWidth)))); + return SkNEW_ARGS(DashingLineEffect, (edgeType, info, strokeWidth)); } DashingLineEffect::~DashingLineEffect() {} diff --git a/src/gpu/effects/GrDistanceFieldTextureEffect.h b/src/gpu/effects/GrDistanceFieldTextureEffect.h index 692290ccdb..b2e21b2895 100644 --- a/src/gpu/effects/GrDistanceFieldTextureEffect.h +++ b/src/gpu/effects/GrDistanceFieldTextureEffect.h @@ -26,17 +26,15 @@ public: static GrEffectRef* Create(GrTexture* tex, const GrTextureParams& params, GrTexture* gamma, const GrTextureParams& gammaParams, float lum, bool similarity) { - AutoEffectUnref effect(SkNEW_ARGS(GrDistanceFieldTextureEffect, (tex, params, - gamma, gammaParams, lum, - similarity))); + return SkNEW_ARGS(GrDistanceFieldTextureEffect, (tex, params, gamma, gammaParams, lum, + similarity)); + } #else static GrEffectRef* Create(GrTexture* tex, const GrTextureParams& params, bool similarity) { - AutoEffectUnref effect(SkNEW_ARGS(GrDistanceFieldTextureEffect, (tex, params, - similarity))); -#endif - return CreateEffectRef(effect); + return SkNEW_ARGS(GrDistanceFieldTextureEffect, (tex, params, similarity)); } +#endif virtual ~GrDistanceFieldTextureEffect() {} @@ -85,10 +83,8 @@ public: GrTexture* gamma, const GrTextureParams& gammaParams, SkColor textColor, bool uniformScale, bool useBGR) { - AutoEffectUnref effect(SkNEW_ARGS(GrDistanceFieldLCDTextureEffect, - (tex, params, gamma, gammaParams, textColor, uniformScale, - useBGR))); - return CreateEffectRef(effect); + return SkNEW_ARGS(GrDistanceFieldLCDTextureEffect, + (tex, params, gamma, gammaParams, textColor, uniformScale, useBGR)); } virtual ~GrDistanceFieldLCDTextureEffect() {} diff --git a/src/gpu/effects/GrDitherEffect.cpp b/src/gpu/effects/GrDitherEffect.cpp index 7409e5ff71..1db61ba146 100644 --- a/src/gpu/effects/GrDitherEffect.cpp +++ b/src/gpu/effects/GrDitherEffect.cpp @@ -20,7 +20,8 @@ class GLDitherEffect; class DitherEffect : public GrEffect { public: static GrEffectRef* Create() { - return CreateEffectRef(AutoEffectUnref(SkNEW(DitherEffect))); + GR_CREATE_STATIC_EFFECT(gDitherEffect, DitherEffect, ()) + return SkRef(gDitherEffect); } virtual ~DitherEffect() {}; diff --git a/src/gpu/effects/GrOvalEffect.cpp b/src/gpu/effects/GrOvalEffect.cpp index f2ee27880f..678abd0c38 100644 --- a/src/gpu/effects/GrOvalEffect.cpp +++ b/src/gpu/effects/GrOvalEffect.cpp @@ -53,8 +53,7 @@ GrEffectRef* CircleEffect::Create(GrEffectEdgeType edgeType, const SkPoint& center, SkScalar radius) { SkASSERT(radius >= 0); - return CreateEffectRef(AutoEffectUnref(SkNEW_ARGS(CircleEffect, - (edgeType, center, radius)))); + return SkNEW_ARGS(CircleEffect, (edgeType, center, radius)); } void CircleEffect::getConstantColorComponents(GrColor* color, uint32_t* validFlags) const { @@ -225,8 +224,7 @@ GrEffectRef* EllipseEffect::Create(GrEffectEdgeType edgeType, SkScalar rx, SkScalar ry) { SkASSERT(rx >= 0 && ry >= 0); - return CreateEffectRef(AutoEffectUnref(SkNEW_ARGS(EllipseEffect, - (edgeType, center, rx, ry)))); + return SkNEW_ARGS(EllipseEffect, (edgeType, center, rx, ry)); } void EllipseEffect::getConstantColorComponents(GrColor* color, uint32_t* validFlags) const { diff --git a/src/gpu/effects/GrRRectEffect.cpp b/src/gpu/effects/GrRRectEffect.cpp index 11d8a18e61..33291ed5b3 100644 --- a/src/gpu/effects/GrRRectEffect.cpp +++ b/src/gpu/effects/GrRRectEffect.cpp @@ -81,8 +81,7 @@ GrEffectRef* CircularRRectEffect::Create(GrEffectEdgeType edgeType, if (kFillAA_GrEffectEdgeType != edgeType && kInverseFillAA_GrEffectEdgeType != edgeType) { return NULL; } - return CreateEffectRef(AutoEffectUnref(SkNEW_ARGS(CircularRRectEffect, - (edgeType, circularCornerFlags, rrect)))); + return SkNEW_ARGS(CircularRRectEffect, (edgeType, circularCornerFlags, rrect)); } void CircularRRectEffect::getConstantColorComponents(GrColor* color, uint32_t* validFlags) const { @@ -416,7 +415,7 @@ GrEffectRef* EllipticalRRectEffect::Create(GrEffectEdgeType edgeType, const SkRR if (kFillAA_GrEffectEdgeType != edgeType && kInverseFillAA_GrEffectEdgeType != edgeType) { return NULL; } - return CreateEffectRef(AutoEffectUnref(SkNEW_ARGS(EllipticalRRectEffect, (edgeType, rrect)))); + return SkNEW_ARGS(EllipticalRRectEffect, (edgeType, rrect)); } void EllipticalRRectEffect::getConstantColorComponents(GrColor* color, uint32_t* validFlags) const { diff --git a/src/gpu/effects/GrSimpleTextureEffect.h b/src/gpu/effects/GrSimpleTextureEffect.h index c326ccf4c8..fea18e5eeb 100644 --- a/src/gpu/effects/GrSimpleTextureEffect.h +++ b/src/gpu/effects/GrSimpleTextureEffect.h @@ -26,8 +26,8 @@ public: static GrEffectRef* Create(GrTexture* tex, const SkMatrix& matrix, GrCoordSet coordSet = kLocal_GrCoordSet) { - AutoEffectUnref effect(SkNEW_ARGS(GrSimpleTextureEffect, (tex, matrix, GrTextureParams::kNone_FilterMode, coordSet))); - return CreateEffectRef(effect); + return SkNEW_ARGS(GrSimpleTextureEffect, (tex, matrix, GrTextureParams::kNone_FilterMode, + coordSet)); } /* clamp mode */ @@ -35,17 +35,14 @@ public: const SkMatrix& matrix, GrTextureParams::FilterMode filterMode, GrCoordSet coordSet = kLocal_GrCoordSet) { - AutoEffectUnref effect( - SkNEW_ARGS(GrSimpleTextureEffect, (tex, matrix, filterMode, coordSet))); - return CreateEffectRef(effect); + return SkNEW_ARGS(GrSimpleTextureEffect, (tex, matrix, filterMode, coordSet)); } static GrEffectRef* Create(GrTexture* tex, const SkMatrix& matrix, const GrTextureParams& p, GrCoordSet coordSet = kLocal_GrCoordSet) { - AutoEffectUnref effect(SkNEW_ARGS(GrSimpleTextureEffect, (tex, matrix, p, coordSet))); - return CreateEffectRef(effect); + return SkNEW_ARGS(GrSimpleTextureEffect, (tex, matrix, p, coordSet)); } virtual ~GrSimpleTextureEffect() {} diff --git a/src/gpu/effects/GrTextureDomain.cpp b/src/gpu/effects/GrTextureDomain.cpp index 656000b059..cb2ad5f5da 100644 --- a/src/gpu/effects/GrTextureDomain.cpp +++ b/src/gpu/effects/GrTextureDomain.cpp @@ -208,14 +208,12 @@ GrEffectRef* GrTextureDomainEffect::Create(GrTexture* texture, return GrSimpleTextureEffect::Create(texture, matrix, filterMode); } else { - AutoEffectUnref effect(SkNEW_ARGS(GrTextureDomainEffect, (texture, - matrix, - domain, - mode, - filterMode, - coordSet))); - return CreateEffectRef(effect); - + return SkNEW_ARGS(GrTextureDomainEffect, (texture, + matrix, + domain, + mode, + filterMode, + coordSet)); } } diff --git a/src/gpu/effects/GrYUVtoRGBEffect.cpp b/src/gpu/effects/GrYUVtoRGBEffect.cpp index 866f4a66b5..539b4ac186 100644 --- a/src/gpu/effects/GrYUVtoRGBEffect.cpp +++ b/src/gpu/effects/GrYUVtoRGBEffect.cpp @@ -17,8 +17,7 @@ namespace { class YUVtoRGBEffect : public GrEffect { public: static GrEffect* Create(GrTexture* yTexture, GrTexture* uTexture, GrTexture* vTexture) { - AutoEffectUnref effect(SkNEW_ARGS(YUVtoRGBEffect, (yTexture, uTexture, vTexture))); - return CreateEffectRef(effect); + return SkNEW_ARGS(YUVtoRGBEffect, (yTexture, uTexture, vTexture)); } static const char* Name() { return "YUV to RGB"; }