sk_sp for Ganesh.
Convert use of GrFragmentProcessor, GrGeometryProcessor, and
GrXPFactory to sk_sp. This clarifies ownership and should
reduce reference count churn by moving ownership.
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2041113004
Review-Url: https://codereview.chromium.org/2041113004
diff --git a/src/effects/GrAlphaThresholdFragmentProcessor.cpp b/src/effects/GrAlphaThresholdFragmentProcessor.cpp
index 1437989..03a4515 100644
--- a/src/effects/GrAlphaThresholdFragmentProcessor.cpp
+++ b/src/effects/GrAlphaThresholdFragmentProcessor.cpp
@@ -11,6 +11,7 @@
#include "GrInvariantOutput.h"
#include "GrTextureAccess.h"
+#include "SkRefCnt.h"
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
@@ -144,7 +145,7 @@
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrAlphaThresholdFragmentProcessor);
-const GrFragmentProcessor* GrAlphaThresholdFragmentProcessor::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> GrAlphaThresholdFragmentProcessor::TestCreate(GrProcessorTestData* d) {
GrTexture* bmpTex = d->fTextures[GrProcessorUnitTest::kSkiaPMTextureIdx];
GrTexture* maskTex = d->fTextures[GrProcessorUnitTest::kAlphaTextureIdx];
float innerThresh = d->fRandom->nextUScalar1();
@@ -158,7 +159,7 @@
SkIRect bounds = SkIRect::MakeXYWH(x, y, width, height);
return GrAlphaThresholdFragmentProcessor::Make(bmpTex, maskTex,
innerThresh, outerThresh,
- bounds).release();
+ bounds);
}
///////////////////////////////////////////////////////////////////////////////
diff --git a/src/effects/GrCircleBlurFragmentProcessor.cpp b/src/effects/GrCircleBlurFragmentProcessor.cpp
index bd8adee..e5c0299 100644
--- a/src/effects/GrCircleBlurFragmentProcessor.cpp
+++ b/src/effects/GrCircleBlurFragmentProcessor.cpp
@@ -289,11 +289,11 @@
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrCircleBlurFragmentProcessor);
-const GrFragmentProcessor* GrCircleBlurFragmentProcessor::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> GrCircleBlurFragmentProcessor::TestCreate(GrProcessorTestData* d) {
SkScalar wh = d->fRandom->nextRangeScalar(100.f, 1000.f);
SkScalar sigma = d->fRandom->nextRangeF(1.f,10.f);
SkRect circle = SkRect::MakeWH(wh, wh);
- return GrCircleBlurFragmentProcessor::Create(d->fContext->textureProvider(), circle, sigma);
+ return GrCircleBlurFragmentProcessor::Make(d->fContext->textureProvider(), circle, sigma);
}
#endif
diff --git a/src/effects/GrCircleBlurFragmentProcessor.h b/src/effects/GrCircleBlurFragmentProcessor.h
index ca12db7..6dc599b 100644
--- a/src/effects/GrCircleBlurFragmentProcessor.h
+++ b/src/effects/GrCircleBlurFragmentProcessor.h
@@ -34,8 +34,8 @@
return str;
}
- static const GrFragmentProcessor* Create(GrTextureProvider*textureProvider,
- const SkRect& circle, float sigma) {
+ static sk_sp<GrFragmentProcessor> Make(GrTextureProvider*textureProvider,
+ const SkRect& circle, float sigma) {
float offset;
SkAutoTUnref<GrTexture> blurProfile(CreateCircleBlurProfileTexture(textureProvider,
@@ -45,7 +45,8 @@
if (!blurProfile) {
return nullptr;
}
- return new GrCircleBlurFragmentProcessor(circle, sigma, offset, blurProfile);
+ return sk_sp<GrFragmentProcessor>(
+ new GrCircleBlurFragmentProcessor(circle, sigma, offset, blurProfile));
}
const SkRect& circle() const { return fCircle; }
diff --git a/src/effects/SkArithmeticMode.cpp b/src/effects/SkArithmeticMode.cpp
index e926f1b..bf17bb8 100644
--- a/src/effects/SkArithmeticMode.cpp
+++ b/src/effects/SkArithmeticMode.cpp
@@ -33,9 +33,9 @@
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkArithmeticMode_scalar)
#if SK_SUPPORT_GPU
- const GrFragmentProcessor* getFragmentProcessorForImageFilter(
- const GrFragmentProcessor* dst) const override;
- GrXPFactory* asXPFactory() const override;
+ sk_sp<GrFragmentProcessor> makeFragmentProcessorForImageFilter(
+ sk_sp<GrFragmentProcessor> dst) const override;
+ sk_sp<GrXPFactory> asXPFactory() const override;
#endif
private:
@@ -127,22 +127,22 @@
//////////////////////////////////////////////////////////////////////////////
#if SK_SUPPORT_GPU
-const GrFragmentProcessor* SkArithmeticMode_scalar::getFragmentProcessorForImageFilter(
- const GrFragmentProcessor* dst) const {
- return GrArithmeticFP::Create(SkScalarToFloat(fK[0]),
- SkScalarToFloat(fK[1]),
- SkScalarToFloat(fK[2]),
- SkScalarToFloat(fK[3]),
- fEnforcePMColor,
- dst);
+sk_sp<GrFragmentProcessor> SkArithmeticMode_scalar::makeFragmentProcessorForImageFilter(
+ sk_sp<GrFragmentProcessor> dst) const {
+ return GrArithmeticFP::Make(SkScalarToFloat(fK[0]),
+ SkScalarToFloat(fK[1]),
+ SkScalarToFloat(fK[2]),
+ SkScalarToFloat(fK[3]),
+ fEnforcePMColor,
+ std::move(dst));
}
-GrXPFactory* SkArithmeticMode_scalar::asXPFactory() const {
- return GrArithmeticXPFactory::Create(SkScalarToFloat(fK[0]),
- SkScalarToFloat(fK[1]),
- SkScalarToFloat(fK[2]),
- SkScalarToFloat(fK[3]),
- fEnforcePMColor);
+sk_sp<GrXPFactory> SkArithmeticMode_scalar::asXPFactory() const {
+ return GrArithmeticXPFactory::Make(SkScalarToFloat(fK[0]),
+ SkScalarToFloat(fK[1]),
+ SkScalarToFloat(fK[2]),
+ SkScalarToFloat(fK[3]),
+ fEnforcePMColor);
}
#endif
diff --git a/src/effects/SkArithmeticMode_gpu.cpp b/src/effects/SkArithmeticMode_gpu.cpp
index 7fb6d66..50c46ad 100644
--- a/src/effects/SkArithmeticMode_gpu.cpp
+++ b/src/effects/SkArithmeticMode_gpu.cpp
@@ -85,12 +85,12 @@
///////////////////////////////////////////////////////////////////////////////
GrArithmeticFP::GrArithmeticFP(float k1, float k2, float k3, float k4, bool enforcePMColor,
- const GrFragmentProcessor* dst)
+ sk_sp<GrFragmentProcessor> dst)
: fK1(k1), fK2(k2), fK3(k3), fK4(k4), fEnforcePMColor(enforcePMColor) {
this->initClassID<GrArithmeticFP>();
SkASSERT(dst);
- SkDEBUGCODE(int dstIndex = )this->registerChildProcessor(dst);
+ SkDEBUGCODE(int dstIndex = )this->registerChildProcessor(std::move(dst));
SkASSERT(0 == dstIndex);
}
@@ -118,15 +118,15 @@
///////////////////////////////////////////////////////////////////////////////
-const GrFragmentProcessor* GrArithmeticFP::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> GrArithmeticFP::TestCreate(GrProcessorTestData* d) {
float k1 = d->fRandom->nextF();
float k2 = d->fRandom->nextF();
float k3 = d->fRandom->nextF();
float k4 = d->fRandom->nextF();
bool enforcePMColor = d->fRandom->nextBool();
- SkAutoTUnref<const GrFragmentProcessor> dst(GrProcessorUnitTest::CreateChildFP(d));
- return new GrArithmeticFP(k1, k2, k3, k4, enforcePMColor, dst);
+ sk_sp<GrFragmentProcessor> dst(GrProcessorUnitTest::MakeChildFP(d));
+ return GrArithmeticFP::Make(k1, k2, k3, k4, enforcePMColor, std::move(dst));
}
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrArithmeticFP);
@@ -283,14 +283,14 @@
GR_DEFINE_XP_FACTORY_TEST(GrArithmeticXPFactory);
-const GrXPFactory* GrArithmeticXPFactory::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrXPFactory> GrArithmeticXPFactory::TestCreate(GrProcessorTestData* d) {
float k1 = d->fRandom->nextF();
float k2 = d->fRandom->nextF();
float k3 = d->fRandom->nextF();
float k4 = d->fRandom->nextF();
bool enforcePMColor = d->fRandom->nextBool();
- return GrArithmeticXPFactory::Create(k1, k2, k3, k4, enforcePMColor);
+ return GrArithmeticXPFactory::Make(k1, k2, k3, k4, enforcePMColor);
}
#endif
diff --git a/src/effects/SkArithmeticMode_gpu.h b/src/effects/SkArithmeticMode_gpu.h
index b8a40cf..98cbaf9 100644
--- a/src/effects/SkArithmeticMode_gpu.h
+++ b/src/effects/SkArithmeticMode_gpu.h
@@ -31,9 +31,10 @@
class GrArithmeticFP : public GrFragmentProcessor {
public:
- static const GrFragmentProcessor* Create(float k1, float k2, float k3, float k4,
- bool enforcePMColor, const GrFragmentProcessor* dst) {
- return new GrArithmeticFP(k1, k2, k3, k4, enforcePMColor, dst);
+ static sk_sp<GrFragmentProcessor> Make(float k1, float k2, float k3, float k4,
+ bool enforcePMColor, sk_sp<GrFragmentProcessor> dst) {
+ return sk_sp<GrFragmentProcessor>(new GrArithmeticFP(k1, k2, k3, k4, enforcePMColor,
+ std::move(dst)));
}
~GrArithmeticFP() override {};
@@ -62,7 +63,7 @@
void onComputeInvariantOutput(GrInvariantOutput* inout) const override;
GrArithmeticFP(float k1, float k2, float k3, float k4, bool enforcePMColor,
- const GrFragmentProcessor* dst);
+ sk_sp<GrFragmentProcessor> dst);
float fK1, fK2, fK3, fK4;
bool fEnforcePMColor;
@@ -77,8 +78,8 @@
class GrArithmeticXPFactory : public GrXPFactory {
public:
- static GrXPFactory* Create(float k1, float k2, float k3, float k4, bool enforcePMColor) {
- return new GrArithmeticXPFactory(k1, k2, k3, k4, enforcePMColor);
+ static sk_sp<GrXPFactory> Make(float k1, float k2, float k3, float k4, bool enforcePMColor) {
+ return sk_sp<GrXPFactory>(new GrArithmeticXPFactory(k1, k2, k3, k4, enforcePMColor));
}
void getInvariantBlendedColor(const GrProcOptInfo& colorPOI,
diff --git a/src/effects/SkBlurMaskFilter.cpp b/src/effects/SkBlurMaskFilter.cpp
index 969afc1..1d277f8 100644
--- a/src/effects/SkBlurMaskFilter.cpp
+++ b/src/effects/SkBlurMaskFilter.cpp
@@ -607,8 +607,8 @@
const char* name() const override { return "RectBlur"; }
- static GrFragmentProcessor* Create(GrTextureProvider *textureProvider,
- const SkRect& rect, float sigma) {
+ static sk_sp<GrFragmentProcessor> Make(GrTextureProvider *textureProvider,
+ const SkRect& rect, float sigma) {
int doubleProfileSize = SkScalarCeilToInt(12*sigma);
if (doubleProfileSize >= rect.width() || doubleProfileSize >= rect.height()) {
@@ -637,11 +637,11 @@
SkScalarAbs(rect.width()) > kMAX_BLUR_COORD ||
SkScalarAbs(rect.height()) > kMAX_BLUR_COORD) {
precision = kHigh_GrSLPrecision;
- }
- else {
+ } else {
precision = kDefault_GrSLPrecision;
}
- return new GrRectBlurEffect(rect, sigma, blurProfile, precision);
+ return sk_sp<GrFragmentProcessor>(
+ new GrRectBlurEffect(rect, sigma, blurProfile, precision));
}
const SkRect& getRect() const { return fRect; }
@@ -841,12 +841,12 @@
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrRectBlurEffect);
-const GrFragmentProcessor* GrRectBlurEffect::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> GrRectBlurEffect::TestCreate(GrProcessorTestData* d) {
float sigma = d->fRandom->nextRangeF(3,8);
float width = d->fRandom->nextRangeF(200,300);
float height = d->fRandom->nextRangeF(200,300);
- return GrRectBlurEffect::Create(d->fContext->textureProvider(), SkRect::MakeWH(width, height),
- sigma);
+ return GrRectBlurEffect::Make(d->fContext->textureProvider(), SkRect::MakeWH(width, height),
+ sigma);
}
@@ -870,16 +870,16 @@
SkScalar xformedSigma = this->computeXformedSigma(viewMatrix);
- SkAutoTUnref<const GrFragmentProcessor> fp;
+ sk_sp<GrFragmentProcessor> fp;
SkRect rect;
if (path.isRect(&rect)) {
int pad = SkScalarCeilToInt(6*xformedSigma)/2;
rect.outset(SkIntToScalar(pad), SkIntToScalar(pad));
- fp.reset(GrRectBlurEffect::Create(texProvider, rect, xformedSigma));
+ fp = GrRectBlurEffect::Make(texProvider, rect, xformedSigma);
} else if (path.isOval(&rect) && SkScalarNearlyEqual(rect.width(), rect.height())) {
- fp.reset(GrCircleBlurFragmentProcessor::Create(texProvider, rect, xformedSigma));
+ fp = GrCircleBlurFragmentProcessor::Make(texProvider, rect, xformedSigma);
// expand the rect for the coverage geometry
int pad = SkScalarCeilToInt(6*xformedSigma)/2;
@@ -892,7 +892,7 @@
return false;
}
- grp->addCoverageFragmentProcessor(fp);
+ grp->addCoverageFragmentProcessor(std::move(fp));
SkMatrix inverse;
if (!viewMatrix.invert(&inverse)) {
@@ -908,7 +908,7 @@
class GrRRectBlurEffect : public GrFragmentProcessor {
public:
- static const GrFragmentProcessor* Create(GrTextureProvider*, float sigma, const SkRRect&);
+ static sk_sp<GrFragmentProcessor> Make(GrTextureProvider*, float sigma, const SkRRect&);
virtual ~GrRRectBlurEffect() {};
const char* name() const override { return "GrRRectBlur"; }
@@ -938,10 +938,10 @@
};
-const GrFragmentProcessor* GrRRectBlurEffect::Create(GrTextureProvider* texProvider, float sigma,
+sk_sp<GrFragmentProcessor> GrRRectBlurEffect::Make(GrTextureProvider* texProvider, float sigma,
const SkRRect& rrect) {
if (rrect.isCircle()) {
- return GrCircleBlurFragmentProcessor::Create(texProvider, rrect.rect(), sigma);
+ return GrCircleBlurFragmentProcessor::Make(texProvider, rrect.rect(), sigma);
}
if (!rrect.isSimpleCircular()) {
@@ -1014,7 +1014,7 @@
}
texProvider->assignUniqueKeyToTexture(key, blurNinePatchTexture);
}
- return new GrRRectBlurEffect(sigma, rrect, blurNinePatchTexture);
+ return sk_sp<GrFragmentProcessor>(new GrRRectBlurEffect(sigma, rrect, blurNinePatchTexture));
}
void GrRRectBlurEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
@@ -1041,14 +1041,14 @@
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrRRectBlurEffect);
-const GrFragmentProcessor* GrRRectBlurEffect::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> GrRRectBlurEffect::TestCreate(GrProcessorTestData* d) {
SkScalar w = d->fRandom->nextRangeScalar(100.f, 1000.f);
SkScalar h = d->fRandom->nextRangeScalar(100.f, 1000.f);
SkScalar r = d->fRandom->nextRangeF(1.f, 9.f);
SkScalar sigma = d->fRandom->nextRangeF(1.f,10.f);
SkRRect rrect;
rrect.setRectXY(SkRect::MakeWH(w, h), r, r);
- return GrRRectBlurEffect::Create(d->fContext->textureProvider(), sigma, rrect);
+ return GrRRectBlurEffect::Make(d->fContext->textureProvider(), sigma, rrect);
}
//////////////////////////////////////////////////////////////////////////////
@@ -1174,13 +1174,12 @@
SkRect proxyRect = rrect.rect();
proxyRect.outset(extra, extra);
- SkAutoTUnref<const GrFragmentProcessor> fp(GrRRectBlurEffect::Create(texProvider,
- xformedSigma, rrect));
+ sk_sp<GrFragmentProcessor> fp(GrRRectBlurEffect::Make(texProvider, xformedSigma, rrect));
if (!fp) {
return false;
}
- grp->addCoverageFragmentProcessor(fp);
+ grp->addCoverageFragmentProcessor(std::move(fp));
SkMatrix inverse;
if (!viewMatrix.invert(&inverse)) {
@@ -1262,7 +1261,7 @@
SkMatrix matrix;
matrix.setIDiv(src->width(), src->height());
// Blend pathTexture over blurTexture.
- paint.addCoverageFragmentProcessor(GrSimpleTextureEffect::Create(src, matrix))->unref();
+ paint.addCoverageFragmentProcessor(GrSimpleTextureEffect::Make(src, matrix));
if (kInner_SkBlurStyle == fBlurStyle) {
// inner: dst = dst * src
paint.setCoverageSetOpXPFactory(SkRegion::kIntersect_Op);
diff --git a/src/effects/SkColorCubeFilter.cpp b/src/effects/SkColorCubeFilter.cpp
index fdf571c..3eb70d3 100644
--- a/src/effects/SkColorCubeFilter.cpp
+++ b/src/effects/SkColorCubeFilter.cpp
@@ -161,8 +161,9 @@
class GrColorCubeEffect : public GrFragmentProcessor {
public:
- static const GrFragmentProcessor* Create(GrTexture* colorCube) {
- return (nullptr != colorCube) ? new GrColorCubeEffect(colorCube) : nullptr;
+ static sk_sp<GrFragmentProcessor> Make(GrTexture* colorCube) {
+ return (nullptr != colorCube) ? sk_sp<GrFragmentProcessor>(new GrColorCubeEffect(colorCube))
+ : nullptr;
}
virtual ~GrColorCubeEffect();
@@ -297,7 +298,7 @@
const GrGLSLCaps&, GrProcessorKeyBuilder* b) {
}
-const GrFragmentProcessor* SkColorCubeFilter::asFragmentProcessor(GrContext* context) const {
+sk_sp<GrFragmentProcessor> SkColorCubeFilter::asFragmentProcessor(GrContext* context) const {
static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain();
GrUniqueKey key;
GrUniqueKey::Builder builder(&key, kDomain, 2);
@@ -323,6 +324,6 @@
}
}
- return GrColorCubeEffect::Create(textureCube);
+ return sk_sp<GrFragmentProcessor>(GrColorCubeEffect::Make(textureCube));
}
#endif
diff --git a/src/effects/SkDisplacementMapEffect.cpp b/src/effects/SkDisplacementMapEffect.cpp
index 541dbbd..29ce3fe 100644
--- a/src/effects/SkDisplacementMapEffect.cpp
+++ b/src/effects/SkDisplacementMapEffect.cpp
@@ -214,13 +214,14 @@
#if SK_SUPPORT_GPU
class GrDisplacementMapEffect : public GrFragmentProcessor {
public:
- static GrFragmentProcessor* Create(
+ static sk_sp<GrFragmentProcessor> Make(
SkDisplacementMapEffect::ChannelSelectorType xChannelSelector,
SkDisplacementMapEffect::ChannelSelectorType yChannelSelector, SkVector scale,
GrTexture* displacement, const SkMatrix& offsetMatrix, GrTexture* color,
const SkISize& colorDimensions) {
- return new GrDisplacementMapEffect(xChannelSelector, yChannelSelector, scale, displacement,
- offsetMatrix, color, colorDimensions);
+ return sk_sp<GrFragmentProcessor>(
+ new GrDisplacementMapEffect(xChannelSelector, yChannelSelector, scale, displacement,
+ offsetMatrix, color, colorDimensions));
}
virtual ~GrDisplacementMapEffect();
@@ -323,14 +324,13 @@
SkIntToScalar(colorOffset.fY - displOffset.fY));
paint.addColorFragmentProcessor(
- GrDisplacementMapEffect::Create(fXChannelSelector,
- fYChannelSelector,
- scale,
- displTexture.get(),
- offsetMatrix,
- colorTexture.get(),
- SkISize::Make(color->width(),
- color->height())))->unref();
+ GrDisplacementMapEffect::Make(fXChannelSelector,
+ fYChannelSelector,
+ scale,
+ displTexture.get(),
+ offsetMatrix,
+ colorTexture.get(),
+ SkISize::Make(color->width(), color->height())));
paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
SkMatrix matrix;
matrix.setTranslate(-SkIntToScalar(colorBounds.x()), -SkIntToScalar(colorBounds.y()));
@@ -504,7 +504,7 @@
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrDisplacementMapEffect);
-const GrFragmentProcessor* GrDisplacementMapEffect::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> GrDisplacementMapEffect::TestCreate(GrProcessorTestData* d) {
int texIdxDispl = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx :
GrProcessorUnitTest::kAlphaTextureIdx;
int texIdxColor = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx :
@@ -521,9 +521,9 @@
SkISize colorDimensions;
colorDimensions.fWidth = d->fRandom->nextRangeU(0, d->fTextures[texIdxColor]->width());
colorDimensions.fHeight = d->fRandom->nextRangeU(0, d->fTextures[texIdxColor]->height());
- return GrDisplacementMapEffect::Create(xChannelSelector, yChannelSelector, scale,
- d->fTextures[texIdxDispl], SkMatrix::I(),
- d->fTextures[texIdxColor], colorDimensions);
+ return GrDisplacementMapEffect::Make(xChannelSelector, yChannelSelector, scale,
+ d->fTextures[texIdxDispl], SkMatrix::I(),
+ d->fTextures[texIdxColor], colorDimensions);
}
///////////////////////////////////////////////////////////////////////////////
diff --git a/src/effects/SkGpuBlurUtils.cpp b/src/effects/SkGpuBlurUtils.cpp
index b377b41..9bc1265 100644
--- a/src/effects/SkGpuBlurUtils.cpp
+++ b/src/effects/SkGpuBlurUtils.cpp
@@ -76,9 +76,9 @@
float bounds[2]) {
GrPaint paint;
paint.setGammaCorrect(drawContext->isGammaCorrect());
- SkAutoTUnref<GrFragmentProcessor> conv(GrConvolutionEffect::CreateGaussian(
+ sk_sp<GrFragmentProcessor> conv(GrConvolutionEffect::MakeGaussian(
texture, direction, radius, sigma, useBounds, bounds));
- paint.addColorFragmentProcessor(conv);
+ paint.addColorFragmentProcessor(std::move(conv));
paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
SkMatrix localMatrix = SkMatrix::MakeTrans(-SkIntToScalar(srcOffset.x()),
-SkIntToScalar(srcOffset.y()));
@@ -104,11 +104,11 @@
paint.setGammaCorrect(drawContext->isGammaCorrect());
SkIRect bounds = srcBounds ? *srcBounds : SkIRect::EmptyIRect();
- SkAutoTUnref<GrFragmentProcessor> conv(GrMatrixConvolutionEffect::CreateGaussian(
+ sk_sp<GrFragmentProcessor> conv(GrMatrixConvolutionEffect::MakeGaussian(
texture, bounds, size, 1.0, 0.0, kernelOffset,
srcBounds ? GrTextureDomain::kDecal_Mode : GrTextureDomain::kIgnore_Mode,
true, sigmaX, sigmaY));
- paint.addColorFragmentProcessor(conv);
+ paint.addColorFragmentProcessor(std::move(conv));
paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
drawContext->fillRectWithLocalMatrix(clip, paint, SkMatrix::I(),
SkRect::Make(dstRect), localMatrix);
@@ -273,13 +273,13 @@
matrix.mapRect(&domain, SkRect::Make(*srcBounds));
domain.inset((i < scaleFactorX) ? SK_ScalarHalf / srcTexture->width() : 0.0f,
(i < scaleFactorY) ? SK_ScalarHalf / srcTexture->height() : 0.0f);
- sk_sp<const GrFragmentProcessor> fp(GrTextureDomainEffect::Create(
+ sk_sp<GrFragmentProcessor> fp(GrTextureDomainEffect::Make(
srcTexture.get(),
matrix,
domain,
GrTextureDomain::kDecal_Mode,
GrTextureParams::kBilerp_FilterMode));
- paint.addColorFragmentProcessor(fp.get());
+ paint.addColorFragmentProcessor(std::move(fp));
srcRect.offset(-srcOffset);
srcOffset.set(0, 0);
} else {
diff --git a/src/effects/SkLightingImageFilter.cpp b/src/effects/SkLightingImageFilter.cpp
index 7f4dcfd..8bf4077 100644
--- a/src/effects/SkLightingImageFilter.cpp
+++ b/src/effects/SkLightingImageFilter.cpp
@@ -359,10 +359,10 @@
SkSpecialImage* input,
const SkIRect& bounds,
const SkMatrix& matrix) const;
- virtual GrFragmentProcessor* getFragmentProcessor(GrTexture*,
- const SkMatrix&,
- const SkIRect* srcBounds,
- BoundaryMode boundaryMode) const = 0;
+ virtual sk_sp<GrFragmentProcessor> makeFragmentProcessor(GrTexture*,
+ const SkMatrix&,
+ const SkIRect* srcBounds,
+ BoundaryMode boundaryMode) const = 0;
#endif
private:
#if SK_SUPPORT_GPU
@@ -390,8 +390,9 @@
SkRect srcRect = dstRect.makeOffset(SkIntToScalar(bounds.x()), SkIntToScalar(bounds.y()));
GrPaint paint;
// SRGBTODO: AllowSRGBInputs?
- GrFragmentProcessor* fp = this->getFragmentProcessor(src, matrix, srcBounds, boundaryMode);
- paint.addColorFragmentProcessor(fp)->unref();
+ sk_sp<GrFragmentProcessor> fp(this->makeFragmentProcessor(src, matrix, srcBounds,
+ boundaryMode));
+ paint.addColorFragmentProcessor(std::move(fp));
paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
drawContext->fillRectToRect(clip, paint, SkMatrix::I(), dstRect, srcRect);
}
@@ -480,8 +481,9 @@
SkIPoint* offset) const override;
#if SK_SUPPORT_GPU
- GrFragmentProcessor* getFragmentProcessor(GrTexture*, const SkMatrix&, const SkIRect* bounds,
- BoundaryMode) const override;
+ sk_sp<GrFragmentProcessor> makeFragmentProcessor(GrTexture*, const SkMatrix&,
+ const SkIRect* bounds,
+ BoundaryMode) const override;
#endif
private:
@@ -515,8 +517,9 @@
SkIPoint* offset) const override;
#if SK_SUPPORT_GPU
- GrFragmentProcessor* getFragmentProcessor(GrTexture*, const SkMatrix&, const SkIRect* bounds,
- BoundaryMode) const override;
+ sk_sp<GrFragmentProcessor> makeFragmentProcessor(GrTexture*, const SkMatrix&,
+ const SkIRect* bounds,
+ BoundaryMode) const override;
#endif
private:
@@ -560,15 +563,16 @@
class GrDiffuseLightingEffect : public GrLightingEffect {
public:
- static GrFragmentProcessor* Create(GrTexture* texture,
- const SkImageFilterLight* light,
- SkScalar surfaceScale,
- const SkMatrix& matrix,
- SkScalar kd,
- BoundaryMode boundaryMode,
- const SkIRect* srcBounds) {
- return new GrDiffuseLightingEffect(texture, light, surfaceScale, matrix, kd, boundaryMode,
- srcBounds);
+ static sk_sp<GrFragmentProcessor> Make(GrTexture* texture,
+ const SkImageFilterLight* light,
+ SkScalar surfaceScale,
+ const SkMatrix& matrix,
+ SkScalar kd,
+ BoundaryMode boundaryMode,
+ const SkIRect* srcBounds) {
+ return sk_sp<GrFragmentProcessor>(
+ new GrDiffuseLightingEffect(texture, light, surfaceScale, matrix, kd, boundaryMode,
+ srcBounds));
}
const char* name() const override { return "DiffuseLighting"; }
@@ -597,16 +601,17 @@
class GrSpecularLightingEffect : public GrLightingEffect {
public:
- static GrFragmentProcessor* Create(GrTexture* texture,
- const SkImageFilterLight* light,
- SkScalar surfaceScale,
- const SkMatrix& matrix,
- SkScalar ks,
- SkScalar shininess,
- BoundaryMode boundaryMode,
- const SkIRect* srcBounds) {
- return new GrSpecularLightingEffect(texture, light, surfaceScale, matrix, ks, shininess,
- boundaryMode, srcBounds);
+ static sk_sp<GrFragmentProcessor> Make(GrTexture* texture,
+ const SkImageFilterLight* light,
+ SkScalar surfaceScale,
+ const SkMatrix& matrix,
+ SkScalar ks,
+ SkScalar shininess,
+ BoundaryMode boundaryMode,
+ const SkIRect* srcBounds) {
+ return sk_sp<GrFragmentProcessor>(
+ new GrSpecularLightingEffect(texture, light, surfaceScale, matrix, ks, shininess,
+ boundaryMode, srcBounds));
}
const char* name() const override { return "SpecularLighting"; }
@@ -1330,14 +1335,14 @@
#endif
#if SK_SUPPORT_GPU
-GrFragmentProcessor* SkDiffuseLightingImageFilter::getFragmentProcessor(
+sk_sp<GrFragmentProcessor> SkDiffuseLightingImageFilter::makeFragmentProcessor(
GrTexture* texture,
const SkMatrix& matrix,
const SkIRect* srcBounds,
BoundaryMode boundaryMode) const {
SkScalar scale = SkScalarMul(this->surfaceScale(), SkIntToScalar(255));
- return GrDiffuseLightingEffect::Create(texture, this->light(), scale, matrix, this->kd(),
- boundaryMode, srcBounds);
+ return GrDiffuseLightingEffect::Make(texture, this->light(), scale, matrix, this->kd(),
+ boundaryMode, srcBounds);
}
#endif
@@ -1495,14 +1500,14 @@
#endif
#if SK_SUPPORT_GPU
-GrFragmentProcessor* SkSpecularLightingImageFilter::getFragmentProcessor(
+sk_sp<GrFragmentProcessor> SkSpecularLightingImageFilter::makeFragmentProcessor(
GrTexture* texture,
const SkMatrix& matrix,
const SkIRect* srcBounds,
BoundaryMode boundaryMode) const {
SkScalar scale = SkScalarMul(this->surfaceScale(), SkIntToScalar(255));
- return GrSpecularLightingEffect::Create(texture, this->light(), scale, matrix, this->ks(),
- this->shininess(), boundaryMode, srcBounds);
+ return GrSpecularLightingEffect::Make(texture, this->light(), scale, matrix, this->ks(),
+ this->shininess(), boundaryMode, srcBounds);
}
#endif
@@ -1746,7 +1751,7 @@
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrDiffuseLightingEffect);
-const GrFragmentProcessor* GrDiffuseLightingEffect::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> GrDiffuseLightingEffect::TestCreate(GrProcessorTestData* d) {
int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx :
GrProcessorUnitTest::kAlphaTextureIdx;
GrTexture* tex = d->fTextures[texIdx];
@@ -1762,7 +1767,7 @@
d->fRandom->nextRangeU(0, tex->width()),
d->fRandom->nextRangeU(0, tex->height()));
BoundaryMode mode = static_cast<BoundaryMode>(d->fRandom->nextU() % kBoundaryModeCount);
- return GrDiffuseLightingEffect::Create(tex, light, surfaceScale, matrix, kd, mode, &srcBounds);
+ return GrDiffuseLightingEffect::Make(tex, light, surfaceScale, matrix, kd, mode, &srcBounds);
}
@@ -1963,7 +1968,7 @@
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrSpecularLightingEffect);
-const GrFragmentProcessor* GrSpecularLightingEffect::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> GrSpecularLightingEffect::TestCreate(GrProcessorTestData* d) {
int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx :
GrProcessorUnitTest::kAlphaTextureIdx;
GrTexture* tex = d->fTextures[texIdx];
@@ -1980,9 +1985,9 @@
d->fRandom->nextRangeU(0, tex->height()),
d->fRandom->nextRangeU(0, tex->width()),
d->fRandom->nextRangeU(0, tex->height()));
- return GrSpecularLightingEffect::Create(d->fTextures[GrProcessorUnitTest::kAlphaTextureIdx],
- light, surfaceScale, matrix, ks, shininess, mode,
- &srcBounds);
+ return GrSpecularLightingEffect::Make(d->fTextures[GrProcessorUnitTest::kAlphaTextureIdx],
+ light, surfaceScale, matrix, ks, shininess, mode,
+ &srcBounds);
}
///////////////////////////////////////////////////////////////////////////////
diff --git a/src/effects/SkLumaColorFilter.cpp b/src/effects/SkLumaColorFilter.cpp
index 28b2e1e..ec94eca 100644
--- a/src/effects/SkLumaColorFilter.cpp
+++ b/src/effects/SkLumaColorFilter.cpp
@@ -58,8 +58,8 @@
#if SK_SUPPORT_GPU
class LumaColorFilterEffect : public GrFragmentProcessor {
public:
- static const GrFragmentProcessor* Create() {
- return new LumaColorFilterEffect;
+ static sk_sp<GrFragmentProcessor> Make() {
+ return sk_sp<GrFragmentProcessor>(new LumaColorFilterEffect);
}
const char* name() const override { return "Luminance-to-Alpha"; }
@@ -111,8 +111,7 @@
}
};
-const GrFragmentProcessor* SkLumaColorFilter::asFragmentProcessor(GrContext*) const {
-
- return LumaColorFilterEffect::Create();
+sk_sp<GrFragmentProcessor> SkLumaColorFilter::asFragmentProcessor(GrContext*) const {
+ return LumaColorFilterEffect::Make();
}
#endif
diff --git a/src/effects/SkMagnifierImageFilter.cpp b/src/effects/SkMagnifierImageFilter.cpp
index 517e31d..cc2d243 100644
--- a/src/effects/SkMagnifierImageFilter.cpp
+++ b/src/effects/SkMagnifierImageFilter.cpp
@@ -28,18 +28,18 @@
class GrMagnifierEffect : public GrSingleTextureEffect {
public:
- static GrFragmentProcessor* Create(GrTexture* texture,
- const SkRect& bounds,
- float xOffset,
- float yOffset,
- float xInvZoom,
- float yInvZoom,
- float xInvInset,
- float yInvInset) {
- return new GrMagnifierEffect(texture, bounds,
- xOffset, yOffset,
- xInvZoom, yInvZoom,
- xInvInset, yInvInset);
+ static sk_sp<GrFragmentProcessor> Make(GrTexture* texture,
+ const SkRect& bounds,
+ float xOffset,
+ float yOffset,
+ float xInvZoom,
+ float yInvZoom,
+ float xInvInset,
+ float yInvInset) {
+ return sk_sp<GrFragmentProcessor>(new GrMagnifierEffect(texture, bounds,
+ xOffset, yOffset,
+ xInvZoom, yInvZoom,
+ xInvInset, yInvInset));
}
~GrMagnifierEffect() override {};
@@ -192,7 +192,7 @@
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrMagnifierEffect);
-const GrFragmentProcessor* GrMagnifierEffect::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> GrMagnifierEffect::TestCreate(GrProcessorTestData* d) {
GrTexture* texture = d->fTextures[0];
const int kMaxWidth = 200;
const int kMaxHeight = 200;
@@ -203,7 +203,7 @@
uint32_t y = d->fRandom->nextULessThan(kMaxHeight - height);
uint32_t inset = d->fRandom->nextULessThan(kMaxInset);
- GrFragmentProcessor* effect = GrMagnifierEffect::Create(
+ sk_sp<GrFragmentProcessor> effect(GrMagnifierEffect::Make(
texture,
SkRect::MakeWH(SkIntToScalar(kMaxWidth), SkIntToScalar(kMaxHeight)),
(float) width / texture->width(),
@@ -211,7 +211,7 @@
texture->width() / (float) x,
texture->height() / (float) y,
(float) inset / texture->width(),
- (float) inset / texture->height());
+ (float) inset / texture->height()));
SkASSERT(effect);
return effect;
}
@@ -324,7 +324,7 @@
SkIntToScalar(inputTexture->width()) / bounds.width(),
SkIntToScalar(inputTexture->height()) / bounds.height());
// SRGBTODO: Handle sRGB here
- sk_sp<GrFragmentProcessor> fp(GrMagnifierEffect::Create(
+ sk_sp<GrFragmentProcessor> fp(GrMagnifierEffect::Make(
inputTexture.get(),
effectBounds,
fSrcRect.x() / inputTexture->width(),
diff --git a/src/effects/SkMatrixConvolutionImageFilter.cpp b/src/effects/SkMatrixConvolutionImageFilter.cpp
index f5d9a3f..67d155b 100644
--- a/src/effects/SkMatrixConvolutionImageFilter.cpp
+++ b/src/effects/SkMatrixConvolutionImageFilter.cpp
@@ -315,8 +315,7 @@
bounds.offset(-inputOffset);
// SRGBTODO: handle sRGB here
- sk_sp<GrFragmentProcessor> fp(GrMatrixConvolutionEffect::Create(
- inputTexture.get(),
+ sk_sp<GrFragmentProcessor> fp(GrMatrixConvolutionEffect::Make(inputTexture.get(),
bounds,
fKernelSize,
fKernel,
diff --git a/src/effects/SkMorphologyImageFilter.cpp b/src/effects/SkMorphologyImageFilter.cpp
index bbd236e..4ac6568 100644
--- a/src/effects/SkMorphologyImageFilter.cpp
+++ b/src/effects/SkMorphologyImageFilter.cpp
@@ -143,14 +143,14 @@
kDilate_MorphologyType,
};
- static GrFragmentProcessor* Create(GrTexture* tex, Direction dir, int radius,
- MorphologyType type) {
- return new GrMorphologyEffect(tex, dir, radius, type);
+ static sk_sp<GrFragmentProcessor> Make(GrTexture* tex, Direction dir, int radius,
+ MorphologyType type) {
+ return sk_sp<GrFragmentProcessor>(new GrMorphologyEffect(tex, dir, radius, type));
}
- static GrFragmentProcessor* Create(GrTexture* tex, Direction dir, int radius,
- MorphologyType type, float bounds[2]) {
- return new GrMorphologyEffect(tex, dir, radius, type, bounds);
+ static sk_sp<GrFragmentProcessor> Make(GrTexture* tex, Direction dir, int radius,
+ MorphologyType type, float bounds[2]) {
+ return sk_sp<GrFragmentProcessor>(new GrMorphologyEffect(tex, dir, radius, type, bounds));
}
virtual ~GrMorphologyEffect();
@@ -370,16 +370,16 @@
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrMorphologyEffect);
-const GrFragmentProcessor* GrMorphologyEffect::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> GrMorphologyEffect::TestCreate(GrProcessorTestData* d) {
int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx :
- GrProcessorUnitTest::kAlphaTextureIdx;
+ GrProcessorUnitTest::kAlphaTextureIdx;
Direction dir = d->fRandom->nextBool() ? kX_Direction : kY_Direction;
static const int kMaxRadius = 10;
int radius = d->fRandom->nextRangeU(1, kMaxRadius);
MorphologyType type = d->fRandom->nextBool() ? GrMorphologyEffect::kErode_MorphologyType :
GrMorphologyEffect::kDilate_MorphologyType;
- return GrMorphologyEffect::Create(d->fTextures[texIdx], dir, radius, type);
+ return GrMorphologyEffect::Make(d->fTextures[texIdx], dir, radius, type);
}
@@ -394,11 +394,11 @@
Gr1DKernelEffect::Direction direction) {
GrPaint paint;
// SRGBTODO: AllowSRGBInputs?
- paint.addColorFragmentProcessor(GrMorphologyEffect::Create(texture,
- direction,
- radius,
- morphType,
- bounds))->unref();
+ paint.addColorFragmentProcessor(GrMorphologyEffect::Make(texture,
+ direction,
+ radius,
+ morphType,
+ bounds));
paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
drawContext->fillRectToRect(clip, paint, SkMatrix::I(), SkRect::Make(dstRect),
SkRect::Make(srcRect));
@@ -414,10 +414,8 @@
Gr1DKernelEffect::Direction direction) {
GrPaint paint;
// SRGBTODO: AllowSRGBInputs?
- paint.addColorFragmentProcessor(GrMorphologyEffect::Create(texture,
- direction,
- radius,
- morphType))->unref();
+ paint.addColorFragmentProcessor(GrMorphologyEffect::Make(texture, direction, radius,
+ morphType));
paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
drawContext->fillRectToRect(clip, paint, SkMatrix::I(), SkRect::Make(dstRect),
SkRect::Make(srcRect));
diff --git a/src/effects/SkPerlinNoiseShader.cpp b/src/effects/SkPerlinNoiseShader.cpp
index d2d4606..1400905 100644
--- a/src/effects/SkPerlinNoiseShader.cpp
+++ b/src/effects/SkPerlinNoiseShader.cpp
@@ -495,13 +495,14 @@
class GrPerlinNoiseEffect : public GrFragmentProcessor {
public:
- static GrFragmentProcessor* Create(SkPerlinNoiseShader::Type type,
- int numOctaves, bool stitchTiles,
- SkPerlinNoiseShader::PaintingData* paintingData,
- GrTexture* permutationsTexture, GrTexture* noiseTexture,
- const SkMatrix& matrix) {
- return new GrPerlinNoiseEffect(type, numOctaves, stitchTiles, paintingData,
- permutationsTexture, noiseTexture, matrix);
+ static sk_sp<GrFragmentProcessor> Make(SkPerlinNoiseShader::Type type,
+ int numOctaves, bool stitchTiles,
+ SkPerlinNoiseShader::PaintingData* paintingData,
+ GrTexture* permutationsTexture, GrTexture* noiseTexture,
+ const SkMatrix& matrix) {
+ return sk_sp<GrFragmentProcessor>(
+ new GrPerlinNoiseEffect(type, numOctaves, stitchTiles, paintingData,
+ permutationsTexture, noiseTexture, matrix));
}
virtual ~GrPerlinNoiseEffect() { delete fPaintingData; }
@@ -574,7 +575,7 @@
/////////////////////////////////////////////////////////////////////
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrPerlinNoiseEffect);
-const GrFragmentProcessor* GrPerlinNoiseEffect::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> GrPerlinNoiseEffect::TestCreate(GrProcessorTestData* d) {
int numOctaves = d->fRandom->nextRangeU(2, 10);
bool stitchTiles = d->fRandom->nextBool();
SkScalar seed = SkIntToScalar(d->fRandom->nextU());
@@ -892,7 +893,7 @@
}
/////////////////////////////////////////////////////////////////////
-const GrFragmentProcessor* SkPerlinNoiseShader::asFragmentProcessor(
+sk_sp<GrFragmentProcessor> SkPerlinNoiseShader::asFragmentProcessor(
GrContext* context,
const SkMatrix& viewM,
const SkMatrix* externalLocalMatrix,
@@ -911,13 +912,13 @@
if (0 == fNumOctaves) {
if (kFractalNoise_Type == fType) {
// Extract the incoming alpha and emit rgba = (a/4, a/4, a/4, a/2)
- SkAutoTUnref<const GrFragmentProcessor> inner(
- GrConstColorProcessor::Create(0x80404040,
- GrConstColorProcessor::kModulateRGBA_InputMode));
- return GrFragmentProcessor::MulOutputByInputAlpha(inner);
+ sk_sp<GrFragmentProcessor> inner(
+ GrConstColorProcessor::Make(0x80404040,
+ GrConstColorProcessor::kModulateRGBA_InputMode));
+ return GrFragmentProcessor::MulOutputByInputAlpha(std::move(inner));
}
// Emit zero.
- return GrConstColorProcessor::Create(0x0, GrConstColorProcessor::kIgnore_InputMode);
+ return GrConstColorProcessor::Make(0x0, GrConstColorProcessor::kIgnore_InputMode);
}
// Either we don't stitch tiles, either we have a valid tile size
@@ -936,14 +937,14 @@
m.setTranslateX(-localMatrix.getTranslateX() + SK_Scalar1);
m.setTranslateY(-localMatrix.getTranslateY() + SK_Scalar1);
if ((permutationsTexture) && (noiseTexture)) {
- SkAutoTUnref<GrFragmentProcessor> inner(
- GrPerlinNoiseEffect::Create(fType,
- fNumOctaves,
- fStitchTiles,
- paintingData,
- permutationsTexture, noiseTexture,
- m));
- return GrFragmentProcessor::MulOutputByInputAlpha(inner);
+ sk_sp<GrFragmentProcessor> inner(
+ GrPerlinNoiseEffect::Make(fType,
+ fNumOctaves,
+ fStitchTiles,
+ paintingData,
+ permutationsTexture, noiseTexture,
+ m));
+ return GrFragmentProcessor::MulOutputByInputAlpha(std::move(inner));
}
delete paintingData;
return nullptr;
diff --git a/src/effects/SkTableColorFilter.cpp b/src/effects/SkTableColorFilter.cpp
index e87a053..20d11f1 100644
--- a/src/effects/SkTableColorFilter.cpp
+++ b/src/effects/SkTableColorFilter.cpp
@@ -49,7 +49,7 @@
sk_sp<SkColorFilter> makeComposed(sk_sp<SkColorFilter> inner) const override;
#if SK_SUPPORT_GPU
- const GrFragmentProcessor* asFragmentProcessor(GrContext*) const override;
+ sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext*) const override;
#endif
void filterSpan(const SkPMColor src[], int count, SkPMColor dst[]) const override;
@@ -343,7 +343,7 @@
class ColorTableEffect : public GrFragmentProcessor {
public:
- static const GrFragmentProcessor* Create(GrContext* context, SkBitmap bitmap, unsigned flags);
+ static sk_sp<GrFragmentProcessor> Make(GrContext* context, SkBitmap bitmap, unsigned flags);
virtual ~ColorTableEffect();
@@ -459,8 +459,8 @@
}
///////////////////////////////////////////////////////////////////////////////
-const GrFragmentProcessor* ColorTableEffect::Create(GrContext* context, SkBitmap bitmap,
- unsigned flags) {
+sk_sp<GrFragmentProcessor> ColorTableEffect::Make(GrContext* context, SkBitmap bitmap,
+ unsigned flags) {
GrTextureStripAtlas::Desc desc;
desc.fWidth = bitmap.width();
@@ -479,7 +479,7 @@
texture.reset(SkRef(atlas->getTexture()));
}
- return new ColorTableEffect(texture, atlas, row, flags);
+ return sk_sp<GrFragmentProcessor>(new ColorTableEffect(texture, atlas, row, flags));
}
ColorTableEffect::ColorTableEffect(GrTexture* texture, GrTextureStripAtlas* atlas, int row,
@@ -540,7 +540,7 @@
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(ColorTableEffect);
-const GrFragmentProcessor* ColorTableEffect::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> ColorTableEffect::TestCreate(GrProcessorTestData* d) {
int flags = 0;
uint8_t luts[256][4];
do {
@@ -562,16 +562,16 @@
(flags & (1 << 3)) ? luts[3] : nullptr
));
- const GrFragmentProcessor* fp = filter->asFragmentProcessor(d->fContext);
+ sk_sp<GrFragmentProcessor> fp = filter->asFragmentProcessor(d->fContext);
SkASSERT(fp);
return fp;
}
-const GrFragmentProcessor* SkTable_ColorFilter::asFragmentProcessor(GrContext* context) const {
+sk_sp<GrFragmentProcessor> SkTable_ColorFilter::asFragmentProcessor(GrContext* context) const {
SkBitmap bitmap;
this->asComponentTable(&bitmap);
- return ColorTableEffect::Create(context, bitmap, fFlags);
+ return ColorTableEffect::Make(context, bitmap, fFlags);
}
#endif // SK_SUPPORT_GPU
diff --git a/src/effects/SkXfermodeImageFilter.cpp b/src/effects/SkXfermodeImageFilter.cpp
index 1921e00..785b46f 100644
--- a/src/effects/SkXfermodeImageFilter.cpp
+++ b/src/effects/SkXfermodeImageFilter.cpp
@@ -180,22 +180,22 @@
GrPaint paint;
// SRGBTODO: AllowSRGBInputs?
- SkAutoTUnref<const GrFragmentProcessor> bgFP;
+ sk_sp<GrFragmentProcessor> bgFP;
if (backgroundTex) {
SkMatrix backgroundMatrix;
backgroundMatrix.setIDiv(backgroundTex->width(), backgroundTex->height());
backgroundMatrix.preTranslate(SkIntToScalar(-backgroundOffset.fX),
SkIntToScalar(-backgroundOffset.fY));
- bgFP.reset(GrTextureDomainEffect::Create(
+ bgFP = GrTextureDomainEffect::Make(
backgroundTex.get(), backgroundMatrix,
GrTextureDomain::MakeTexelDomain(backgroundTex.get(),
background->subset()),
GrTextureDomain::kDecal_Mode,
- GrTextureParams::kNone_FilterMode));
+ GrTextureParams::kNone_FilterMode);
} else {
- bgFP.reset(GrConstColorProcessor::Create(GrColor_TRANSPARENT_BLACK,
- GrConstColorProcessor::kIgnore_InputMode));
+ bgFP = GrConstColorProcessor::Make(GrColor_TRANSPARENT_BLACK,
+ GrConstColorProcessor::kIgnore_InputMode);
}
if (foregroundTex) {
@@ -204,16 +204,16 @@
foregroundMatrix.preTranslate(SkIntToScalar(-foregroundOffset.fX),
SkIntToScalar(-foregroundOffset.fY));
- SkAutoTUnref<const GrFragmentProcessor> foregroundFP;
+ sk_sp<GrFragmentProcessor> foregroundFP;
- foregroundFP.reset(GrTextureDomainEffect::Create(
+ foregroundFP = GrTextureDomainEffect::Make(
foregroundTex.get(), foregroundMatrix,
GrTextureDomain::MakeTexelDomain(foregroundTex.get(),
foreground->subset()),
GrTextureDomain::kDecal_Mode,
- GrTextureParams::kNone_FilterMode));
+ GrTextureParams::kNone_FilterMode);
- paint.addColorFragmentProcessor(foregroundFP.get());
+ paint.addColorFragmentProcessor(std::move(foregroundFP));
// A null fMode is interpreted to mean kSrcOver_Mode (to match raster).
SkAutoTUnref<SkXfermode> mode(SkSafeRef(fMode.get()));
@@ -228,14 +228,15 @@
mode.reset(new SkProcCoeffXfermode(rec, SkXfermode::kSrcOver_Mode));
}
- sk_sp<const GrFragmentProcessor> xferFP(mode->getFragmentProcessorForImageFilter(bgFP));
+ sk_sp<GrFragmentProcessor> xferFP(
+ mode->makeFragmentProcessorForImageFilter(std::move(bgFP)));
// A null 'xferFP' here means kSrc_Mode was used in which case we can just proceed
if (xferFP) {
- paint.addColorFragmentProcessor(xferFP.get());
+ paint.addColorFragmentProcessor(std::move(xferFP));
}
} else {
- paint.addColorFragmentProcessor(bgFP);
+ paint.addColorFragmentProcessor(std::move(bgFP));
}
paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
diff --git a/src/effects/gradients/SkLinearGradient.cpp b/src/effects/gradients/SkLinearGradient.cpp
index cd55673..40340fe 100644
--- a/src/effects/gradients/SkLinearGradient.cpp
+++ b/src/effects/gradients/SkLinearGradient.cpp
@@ -7,6 +7,7 @@
#include "Sk4fLinearGradient.h"
#include "SkLinearGradient.h"
+#include "SkRefCnt.h"
// define to test the 4f gradient path
// #define FORCE_4F_CONTEXT
@@ -369,11 +370,11 @@
class GrLinearGradient : public GrGradientEffect {
public:
- static GrFragmentProcessor* Create(GrContext* ctx,
- const SkLinearGradient& shader,
- const SkMatrix& matrix,
- SkShader::TileMode tm) {
- return new GrLinearGradient(ctx, shader, matrix, tm);
+ static sk_sp<GrFragmentProcessor> Make(GrContext* ctx,
+ const SkLinearGradient& shader,
+ const SkMatrix& matrix,
+ SkShader::TileMode tm) {
+ return sk_sp<GrFragmentProcessor>(new GrLinearGradient(ctx, shader, matrix, tm));
}
virtual ~GrLinearGradient() { }
@@ -407,7 +408,7 @@
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrLinearGradient);
-const GrFragmentProcessor* GrLinearGradient::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> GrLinearGradient::TestCreate(GrProcessorTestData* d) {
SkPoint points[] = {{d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()},
{d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()}};
@@ -417,7 +418,7 @@
SkShader::TileMode tm;
int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm);
auto shader = SkGradientShader::MakeLinear(points, colors, stops, colorCount, tm);
- const GrFragmentProcessor* fp = shader->asFragmentProcessor(d->fContext,
+ sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(d->fContext,
GrTest::TestMatrix(d->fRandom), NULL, kNone_SkFilterQuality,
SkSourceGammaTreatment::kRespect);
GrAlwaysAssert(fp);
@@ -442,7 +443,7 @@
/////////////////////////////////////////////////////////////////////
-const GrFragmentProcessor* SkLinearGradient::asFragmentProcessor(
+sk_sp<GrFragmentProcessor> SkLinearGradient::asFragmentProcessor(
GrContext* context,
const SkMatrix& viewm,
const SkMatrix* localMatrix,
@@ -463,9 +464,8 @@
}
matrix.postConcat(fPtsToUnit);
- SkAutoTUnref<const GrFragmentProcessor> inner(
- GrLinearGradient::Create(context, *this, matrix, fTileMode));
- return GrFragmentProcessor::MulOutputByInputAlpha(inner);
+ sk_sp<GrFragmentProcessor> inner(GrLinearGradient::Make(context, *this, matrix, fTileMode));
+ return GrFragmentProcessor::MulOutputByInputAlpha(std::move(inner));
}
diff --git a/src/effects/gradients/SkLinearGradient.h b/src/effects/gradients/SkLinearGradient.h
index 8edcb9d..5800e57 100644
--- a/src/effects/gradients/SkLinearGradient.h
+++ b/src/effects/gradients/SkLinearGradient.h
@@ -57,7 +57,7 @@
GradientType asAGradient(GradientInfo* info) const override;
#if SK_SUPPORT_GPU
- const GrFragmentProcessor* asFragmentProcessor(GrContext*,
+ sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext*,
const SkMatrix& viewM,
const SkMatrix*,
SkFilterQuality,
diff --git a/src/effects/gradients/SkRadialGradient.cpp b/src/effects/gradients/SkRadialGradient.cpp
index a0fee27..c7e6656 100644
--- a/src/effects/gradients/SkRadialGradient.cpp
+++ b/src/effects/gradients/SkRadialGradient.cpp
@@ -264,11 +264,11 @@
class GrRadialGradient : public GrGradientEffect {
public:
- static GrFragmentProcessor* Create(GrContext* ctx,
- const SkRadialGradient& shader,
- const SkMatrix& matrix,
- SkShader::TileMode tm) {
- return new GrRadialGradient(ctx, shader, matrix, tm);
+ static sk_sp<GrFragmentProcessor> Make(GrContext* ctx,
+ const SkRadialGradient& shader,
+ const SkMatrix& matrix,
+ SkShader::TileMode tm) {
+ return sk_sp<GrFragmentProcessor>(new GrRadialGradient(ctx, shader, matrix, tm));
}
virtual ~GrRadialGradient() { }
@@ -302,7 +302,7 @@
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrRadialGradient);
-const GrFragmentProcessor* GrRadialGradient::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> GrRadialGradient::TestCreate(GrProcessorTestData* d) {
SkPoint center = {d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()};
SkScalar radius = d->fRandom->nextUScalar1();
@@ -312,7 +312,7 @@
SkShader::TileMode tm;
int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm);
auto shader = SkGradientShader::MakeRadial(center, radius, colors, stops, colorCount, tm);
- const GrFragmentProcessor* fp = shader->asFragmentProcessor(d->fContext,
+ sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(d->fContext,
GrTest::TestMatrix(d->fRandom), NULL, kNone_SkFilterQuality,
SkSourceGammaTreatment::kRespect);
GrAlwaysAssert(fp);
@@ -338,7 +338,7 @@
/////////////////////////////////////////////////////////////////////
-const GrFragmentProcessor* SkRadialGradient::asFragmentProcessor(
+sk_sp<GrFragmentProcessor> SkRadialGradient::asFragmentProcessor(
GrContext* context,
const SkMatrix& viewM,
const SkMatrix* localMatrix,
@@ -358,9 +358,8 @@
matrix.postConcat(inv);
}
matrix.postConcat(fPtsToUnit);
- SkAutoTUnref<const GrFragmentProcessor> inner(
- GrRadialGradient::Create(context, *this, matrix, fTileMode));
- return GrFragmentProcessor::MulOutputByInputAlpha(inner);
+ sk_sp<GrFragmentProcessor> inner(GrRadialGradient::Make(context, *this, matrix, fTileMode));
+ return GrFragmentProcessor::MulOutputByInputAlpha(std::move(inner));
}
#endif
diff --git a/src/effects/gradients/SkRadialGradient.h b/src/effects/gradients/SkRadialGradient.h
index 8eb1f76..dfa6823 100644
--- a/src/effects/gradients/SkRadialGradient.h
+++ b/src/effects/gradients/SkRadialGradient.h
@@ -26,7 +26,7 @@
GradientType asAGradient(GradientInfo* info) const override;
#if SK_SUPPORT_GPU
- const GrFragmentProcessor* asFragmentProcessor(GrContext*,
+ sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext*,
const SkMatrix& viewM,
const SkMatrix*,
SkFilterQuality,
diff --git a/src/effects/gradients/SkSweepGradient.cpp b/src/effects/gradients/SkSweepGradient.cpp
index 08232bc..9e2b909 100644
--- a/src/effects/gradients/SkSweepGradient.cpp
+++ b/src/effects/gradients/SkSweepGradient.cpp
@@ -147,9 +147,9 @@
class GrSweepGradient : public GrGradientEffect {
public:
- static GrFragmentProcessor* Create(GrContext* ctx, const SkSweepGradient& shader,
- const SkMatrix& m) {
- return new GrSweepGradient(ctx, shader, m);
+ static sk_sp<GrFragmentProcessor> Make(GrContext* ctx, const SkSweepGradient& shader,
+ const SkMatrix& m) {
+ return sk_sp<GrFragmentProcessor>(new GrSweepGradient(ctx, shader, m));
}
virtual ~GrSweepGradient() { }
@@ -181,7 +181,7 @@
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrSweepGradient);
-const GrFragmentProcessor* GrSweepGradient::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> GrSweepGradient::TestCreate(GrProcessorTestData* d) {
SkPoint center = {d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()};
SkColor colors[kMaxRandomGradientColors];
@@ -191,7 +191,7 @@
int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tmIgnored);
sk_sp<SkShader> shader(SkGradientShader::MakeSweep(center.fX, center.fY, colors, stops,
colorCount));
- const GrFragmentProcessor* fp = shader->asFragmentProcessor(d->fContext,
+ sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(d->fContext,
GrTest::TestMatrix(d->fRandom),
NULL, kNone_SkFilterQuality,
SkSourceGammaTreatment::kRespect);
@@ -227,7 +227,7 @@
/////////////////////////////////////////////////////////////////////
-const GrFragmentProcessor* SkSweepGradient::asFragmentProcessor(
+sk_sp<GrFragmentProcessor> SkSweepGradient::asFragmentProcessor(
GrContext* context,
const SkMatrix& viewM,
const SkMatrix* localMatrix,
@@ -247,9 +247,8 @@
}
matrix.postConcat(fPtsToUnit);
- SkAutoTUnref<const GrFragmentProcessor> inner(
- GrSweepGradient::Create(context, *this, matrix));
- return GrFragmentProcessor::MulOutputByInputAlpha(inner);
+ sk_sp<GrFragmentProcessor> inner(GrSweepGradient::Make(context, *this, matrix));
+ return GrFragmentProcessor::MulOutputByInputAlpha(std::move(inner));
}
#endif
diff --git a/src/effects/gradients/SkSweepGradient.h b/src/effects/gradients/SkSweepGradient.h
index d0807da..0812a58 100644
--- a/src/effects/gradients/SkSweepGradient.h
+++ b/src/effects/gradients/SkSweepGradient.h
@@ -27,7 +27,7 @@
GradientType asAGradient(GradientInfo* info) const override;
#if SK_SUPPORT_GPU
- const GrFragmentProcessor* asFragmentProcessor(GrContext*,
+ sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext*,
const SkMatrix& viewM,
const SkMatrix*,
SkFilterQuality,
diff --git a/src/effects/gradients/SkTwoPointConicalGradient.cpp b/src/effects/gradients/SkTwoPointConicalGradient.cpp
index a7cdc7e..afc77fe 100644
--- a/src/effects/gradients/SkTwoPointConicalGradient.cpp
+++ b/src/effects/gradients/SkTwoPointConicalGradient.cpp
@@ -356,7 +356,7 @@
#include "SkGr.h"
-const GrFragmentProcessor* SkTwoPointConicalGradient::asFragmentProcessor(
+sk_sp<GrFragmentProcessor> SkTwoPointConicalGradient::asFragmentProcessor(
GrContext* context,
const SkMatrix& viewM,
const SkMatrix* localMatrix,
@@ -364,9 +364,9 @@
SkSourceGammaTreatment) const {
SkASSERT(context);
SkASSERT(fPtsToUnit.isIdentity());
- SkAutoTUnref<const GrFragmentProcessor> inner(
- Gr2PtConicalGradientEffect::Create(context, *this, fTileMode, localMatrix));
- return GrFragmentProcessor::MulOutputByInputAlpha(inner);
+ sk_sp<GrFragmentProcessor> inner(
+ Gr2PtConicalGradientEffect::Make(context, *this, fTileMode, localMatrix));
+ return GrFragmentProcessor::MulOutputByInputAlpha(std::move(inner));
}
#endif
diff --git a/src/effects/gradients/SkTwoPointConicalGradient.h b/src/effects/gradients/SkTwoPointConicalGradient.h
index b50a5e3..f2102c1 100644
--- a/src/effects/gradients/SkTwoPointConicalGradient.h
+++ b/src/effects/gradients/SkTwoPointConicalGradient.h
@@ -57,7 +57,7 @@
SkShader::GradientType asAGradient(GradientInfo* info) const override;
#if SK_SUPPORT_GPU
- const GrFragmentProcessor* asFragmentProcessor(GrContext*,
+ sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext*,
const SkMatrix&,
const SkMatrix*,
SkFilterQuality,
diff --git a/src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp b/src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp
index e638982..91b0a93 100644
--- a/src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp
+++ b/src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp
@@ -61,11 +61,11 @@
class Edge2PtConicalEffect : public GrGradientEffect {
public:
- static GrFragmentProcessor* Create(GrContext* ctx,
- const SkTwoPointConicalGradient& shader,
- const SkMatrix& matrix,
- SkShader::TileMode tm) {
- return new Edge2PtConicalEffect(ctx, shader, matrix, tm);
+ static sk_sp<GrFragmentProcessor> Make(GrContext* ctx,
+ const SkTwoPointConicalGradient& shader,
+ const SkMatrix& matrix,
+ SkShader::TileMode tm) {
+ return sk_sp<GrFragmentProcessor>(new Edge2PtConicalEffect(ctx, shader, matrix, tm));
}
virtual ~Edge2PtConicalEffect() {}
@@ -184,7 +184,7 @@
/*
* All Two point conical gradient test create functions may occasionally create edge case shaders
*/
-const GrFragmentProcessor* Edge2PtConicalEffect::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> Edge2PtConicalEffect::TestCreate(GrProcessorTestData* d) {
SkPoint center1 = {d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()};
SkScalar radius1 = d->fRandom->nextUScalar1();
SkPoint center2;
@@ -208,7 +208,7 @@
int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm);
auto shader = SkGradientShader::MakeTwoPointConical(center1, radius1, center2, radius2,
colors, stops, colorCount, tm);
- const GrFragmentProcessor* fp = shader->asFragmentProcessor(d->fContext,
+ sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(d->fContext,
GrTest::TestMatrix(d->fRandom), NULL, kNone_SkFilterQuality,
SkSourceGammaTreatment::kRespect);
GrAlwaysAssert(fp);
@@ -370,12 +370,13 @@
class FocalOutside2PtConicalEffect : public GrGradientEffect {
public:
- static GrFragmentProcessor* Create(GrContext* ctx,
- const SkTwoPointConicalGradient& shader,
- const SkMatrix& matrix,
- SkShader::TileMode tm,
- SkScalar focalX) {
- return new FocalOutside2PtConicalEffect(ctx, shader, matrix, tm, focalX);
+ static sk_sp<GrFragmentProcessor> Make(GrContext* ctx,
+ const SkTwoPointConicalGradient& shader,
+ const SkMatrix& matrix,
+ SkShader::TileMode tm,
+ SkScalar focalX) {
+ return sk_sp<GrFragmentProcessor>(
+ new FocalOutside2PtConicalEffect(ctx, shader, matrix, tm, focalX));
}
virtual ~FocalOutside2PtConicalEffect() { }
@@ -463,7 +464,7 @@
/*
* All Two point conical gradient test create functions may occasionally create edge case shaders
*/
-const GrFragmentProcessor* FocalOutside2PtConicalEffect::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> FocalOutside2PtConicalEffect::TestCreate(GrProcessorTestData* d) {
SkPoint center1 = {d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()};
SkScalar radius1 = 0.f;
SkPoint center2;
@@ -484,7 +485,7 @@
int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm);
auto shader = SkGradientShader::MakeTwoPointConical(center1, radius1, center2, radius2,
colors, stops, colorCount, tm);
- const GrFragmentProcessor* fp = shader->asFragmentProcessor(d->fContext,
+ sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(d->fContext,
GrTest::TestMatrix(d->fRandom), NULL, kNone_SkFilterQuality,
SkSourceGammaTreatment::kRespect);
GrAlwaysAssert(fp);
@@ -580,12 +581,13 @@
class FocalInside2PtConicalEffect : public GrGradientEffect {
public:
- static GrFragmentProcessor* Create(GrContext* ctx,
- const SkTwoPointConicalGradient& shader,
- const SkMatrix& matrix,
- SkShader::TileMode tm,
- SkScalar focalX) {
- return new FocalInside2PtConicalEffect(ctx, shader, matrix, tm, focalX);
+ static sk_sp<GrFragmentProcessor> Make(GrContext* ctx,
+ const SkTwoPointConicalGradient& shader,
+ const SkMatrix& matrix,
+ SkShader::TileMode tm,
+ SkScalar focalX) {
+ return sk_sp<GrFragmentProcessor>(
+ new FocalInside2PtConicalEffect(ctx, shader, matrix, tm, focalX));
}
virtual ~FocalInside2PtConicalEffect() {}
@@ -668,7 +670,7 @@
/*
* All Two point conical gradient test create functions may occasionally create edge case shaders
*/
-const GrFragmentProcessor* FocalInside2PtConicalEffect::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> FocalInside2PtConicalEffect::TestCreate(GrProcessorTestData* d) {
SkPoint center1 = {d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()};
SkScalar radius1 = 0.f;
SkPoint center2;
@@ -691,7 +693,7 @@
int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm);
auto shader = SkGradientShader::MakeTwoPointConical(center1, radius1, center2, radius2,
colors, stops, colorCount, tm);
- const GrFragmentProcessor* fp = shader->asFragmentProcessor(d->fContext,
+ sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(d->fContext,
GrTest::TestMatrix(d->fRandom), NULL, kNone_SkFilterQuality,
SkSourceGammaTreatment::kRespect);
GrAlwaysAssert(fp);
@@ -819,12 +821,13 @@
class CircleInside2PtConicalEffect : public GrGradientEffect {
public:
- static GrFragmentProcessor* Create(GrContext* ctx,
- const SkTwoPointConicalGradient& shader,
- const SkMatrix& matrix,
- SkShader::TileMode tm,
- const CircleConicalInfo& info) {
- return new CircleInside2PtConicalEffect(ctx, shader, matrix, tm, info);
+ static sk_sp<GrFragmentProcessor> Make(GrContext* ctx,
+ const SkTwoPointConicalGradient& shader,
+ const SkMatrix& matrix,
+ SkShader::TileMode tm,
+ const CircleConicalInfo& info) {
+ return sk_sp<GrFragmentProcessor>(
+ new CircleInside2PtConicalEffect(ctx, shader, matrix, tm, info));
}
virtual ~CircleInside2PtConicalEffect() {}
@@ -916,7 +919,7 @@
/*
* All Two point conical gradient test create functions may occasionally create edge case shaders
*/
-const GrFragmentProcessor* CircleInside2PtConicalEffect::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> CircleInside2PtConicalEffect::TestCreate(GrProcessorTestData* d) {
SkPoint center1 = {d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()};
SkScalar radius1 = d->fRandom->nextUScalar1() + 0.0001f; // make sure radius1 != 0
SkPoint center2;
@@ -938,7 +941,7 @@
int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm);
auto shader = SkGradientShader::MakeTwoPointConical(center1, radius1, center2, radius2,
colors, stops, colorCount, tm);
- const GrFragmentProcessor* fp = shader->asFragmentProcessor(d->fContext,
+ sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(d->fContext,
GrTest::TestMatrix(d->fRandom), NULL, kNone_SkFilterQuality,
SkSourceGammaTreatment::kRespect);
GrAlwaysAssert(fp);
@@ -1035,12 +1038,13 @@
class CircleOutside2PtConicalEffect : public GrGradientEffect {
public:
- static GrFragmentProcessor* Create(GrContext* ctx,
- const SkTwoPointConicalGradient& shader,
- const SkMatrix& matrix,
- SkShader::TileMode tm,
- const CircleConicalInfo& info) {
- return new CircleOutside2PtConicalEffect(ctx, shader, matrix, tm, info);
+ static sk_sp<GrFragmentProcessor> Make(GrContext* ctx,
+ const SkTwoPointConicalGradient& shader,
+ const SkMatrix& matrix,
+ SkShader::TileMode tm,
+ const CircleConicalInfo& info) {
+ return sk_sp<GrFragmentProcessor>(
+ new CircleOutside2PtConicalEffect(ctx, shader, matrix, tm, info));
}
virtual ~CircleOutside2PtConicalEffect() {}
@@ -1147,7 +1151,7 @@
/*
* All Two point conical gradient test create functions may occasionally create edge case shaders
*/
-const GrFragmentProcessor* CircleOutside2PtConicalEffect::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> CircleOutside2PtConicalEffect::TestCreate(GrProcessorTestData* d) {
SkPoint center1 = {d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()};
SkScalar radius1 = d->fRandom->nextUScalar1() + 0.0001f; // make sure radius1 != 0
SkPoint center2;
@@ -1170,7 +1174,7 @@
int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm);
auto shader = SkGradientShader::MakeTwoPointConical(center1, radius1, center2, radius2,
colors, stops, colorCount, tm);
- const GrFragmentProcessor* fp = shader->asFragmentProcessor(
+ sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(
d->fContext,GrTest::TestMatrix(d->fRandom), NULL, kNone_SkFilterQuality,
SkSourceGammaTreatment::kRespect);
GrAlwaysAssert(fp);
@@ -1291,10 +1295,10 @@
//////////////////////////////////////////////////////////////////////////////
-GrFragmentProcessor* Gr2PtConicalGradientEffect::Create(GrContext* ctx,
- const SkTwoPointConicalGradient& shader,
- SkShader::TileMode tm,
- const SkMatrix* localMatrix) {
+sk_sp<GrFragmentProcessor> Gr2PtConicalGradientEffect::Make(GrContext* ctx,
+ const SkTwoPointConicalGradient& shader,
+ SkShader::TileMode tm,
+ const SkMatrix* localMatrix) {
SkMatrix matrix;
if (!shader.getLocalMatrix().invert(&matrix)) {
return nullptr;
@@ -1311,12 +1315,12 @@
SkScalar focalX;
ConicalType type = set_matrix_focal_conical(shader, &matrix, &focalX);
if (type == kInside_ConicalType) {
- return FocalInside2PtConicalEffect::Create(ctx, shader, matrix, tm, focalX);
+ return FocalInside2PtConicalEffect::Make(ctx, shader, matrix, tm, focalX);
} else if(type == kEdge_ConicalType) {
set_matrix_edge_conical(shader, &matrix);
- return Edge2PtConicalEffect::Create(ctx, shader, matrix, tm);
+ return Edge2PtConicalEffect::Make(ctx, shader, matrix, tm);
} else {
- return FocalOutside2PtConicalEffect::Create(ctx, shader, matrix, tm, focalX);
+ return FocalOutside2PtConicalEffect::Make(ctx, shader, matrix, tm, focalX);
}
}
@@ -1324,12 +1328,12 @@
ConicalType type = set_matrix_circle_conical(shader, &matrix, &info);
if (type == kInside_ConicalType) {
- return CircleInside2PtConicalEffect::Create(ctx, shader, matrix, tm, info);
+ return CircleInside2PtConicalEffect::Make(ctx, shader, matrix, tm, info);
} else if (type == kEdge_ConicalType) {
set_matrix_edge_conical(shader, &matrix);
- return Edge2PtConicalEffect::Create(ctx, shader, matrix, tm);
+ return Edge2PtConicalEffect::Make(ctx, shader, matrix, tm);
} else {
- return CircleOutside2PtConicalEffect::Create(ctx, shader, matrix, tm, info);
+ return CircleOutside2PtConicalEffect::Make(ctx, shader, matrix, tm, info);
}
}
diff --git a/src/effects/gradients/SkTwoPointConicalGradient_gpu.h b/src/effects/gradients/SkTwoPointConicalGradient_gpu.h
index 601a166..9dd058d 100644
--- a/src/effects/gradients/SkTwoPointConicalGradient_gpu.h
+++ b/src/effects/gradients/SkTwoPointConicalGradient_gpu.h
@@ -18,8 +18,8 @@
* Creates an effect that produces a two point conical gradient based on the
* shader passed in.
*/
- GrFragmentProcessor* Create(GrContext* ctx, const SkTwoPointConicalGradient& shader,
- SkShader::TileMode tm, const SkMatrix* localMatrix);
+ sk_sp<GrFragmentProcessor> Make(GrContext* ctx, const SkTwoPointConicalGradient& shader,
+ SkShader::TileMode tm, const SkMatrix* localMatrix);
};
#endif