Wrap GrEffects in GrEffectPtr.
This is the first step towards automatic recycling of scratch resouces in the cache via ref-cnts.
R=robertphillips@google.com
Review URL: https://codereview.appspot.com/7092061
git-svn-id: http://skia.googlecode.com/svn/trunk@7222 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/effects/GrTextureDomainEffect.cpp b/src/gpu/effects/GrTextureDomainEffect.cpp
index 6884682..74727a0 100644
--- a/src/gpu/effects/GrTextureDomainEffect.cpp
+++ b/src/gpu/effects/GrTextureDomainEffect.cpp
@@ -121,14 +121,14 @@
///////////////////////////////////////////////////////////////////////////////
-GrEffect* GrTextureDomainEffect::Create(GrTexture* texture,
- const SkMatrix& matrix,
- const GrRect& domain,
- WrapMode wrapMode,
- bool bilerp) {
+GrEffectRef* GrTextureDomainEffect::Create(GrTexture* texture,
+ const SkMatrix& matrix,
+ const GrRect& domain,
+ WrapMode wrapMode,
+ bool bilerp) {
static const SkRect kFullRect = {0, 0, SK_Scalar1, SK_Scalar1};
if (kClamp_WrapMode == wrapMode && domain.contains(kFullRect)) {
- return SkNEW_ARGS(GrSingleTextureEffect, (texture, matrix, bilerp));
+ return GrSingleTextureEffect::Create(texture, matrix, bilerp);
} else {
SkRect clippedDomain;
// We don't currently handle domains that are empty or don't intersect the texture.
@@ -142,8 +142,14 @@
clippedDomain.fBottom = SkMinScalar(domain.fBottom, kFullRect.fBottom);
GrAssert(clippedDomain.fLeft <= clippedDomain.fRight);
GrAssert(clippedDomain.fTop <= clippedDomain.fBottom);
- return SkNEW_ARGS(GrTextureDomainEffect,
- (texture, matrix, clippedDomain, wrapMode, bilerp));
+
+ SkAutoTUnref<GrEffect> effect(SkNEW_ARGS(GrTextureDomainEffect, (texture,
+ matrix,
+ clippedDomain,
+ wrapMode,
+ bilerp)));
+ return CreateEffectPtr(effect);
+
}
}
@@ -174,9 +180,9 @@
GR_DEFINE_EFFECT_TEST(GrTextureDomainEffect);
-GrEffect* GrTextureDomainEffect::TestCreate(SkRandom* random,
- GrContext* context,
- GrTexture* textures[]) {
+GrEffectRef* GrTextureDomainEffect::TestCreate(SkRandom* random,
+ GrContext* context,
+ GrTexture* textures[]) {
int texIdx = random->nextBool() ? GrEffectUnitTest::kSkiaPMTextureIdx :
GrEffectUnitTest::kAlphaTextureIdx;
GrRect domain;