Make GrFragmentProcessor be non-refcounted and use std::unique_ptr.
Change-Id: I985e54a071338e99292a5aa2f42c92bc115b4008
Reviewed-on: https://skia-review.googlesource.com/32760
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
diff --git a/src/gpu/effects/GrBicubicEffect.cpp b/src/gpu/effects/GrBicubicEffect.cpp
index 28fcd9e..c8b302c 100644
--- a/src/gpu/effects/GrBicubicEffect.cpp
+++ b/src/gpu/effects/GrBicubicEffect.cpp
@@ -188,7 +188,7 @@
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrBicubicEffect);
#if GR_TEST_UTILS
-sk_sp<GrFragmentProcessor> GrBicubicEffect::TestCreate(GrProcessorTestData* d) {
+std::unique_ptr<GrFragmentProcessor> GrBicubicEffect::TestCreate(GrProcessorTestData* d) {
int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx
: GrProcessorUnitTest::kAlphaTextureIdx;
sk_sp<GrColorSpaceXform> colorSpaceXform = GrTest::TestColorXform(d->fRandom);
diff --git a/src/gpu/effects/GrBicubicEffect.h b/src/gpu/effects/GrBicubicEffect.h
index 65e2c3d..7812f3f 100644
--- a/src/gpu/effects/GrBicubicEffect.h
+++ b/src/gpu/effects/GrBicubicEffect.h
@@ -22,8 +22,8 @@
const char* name() const override { return "Bicubic"; }
- sk_sp<GrFragmentProcessor> clone() const override {
- return sk_sp<GrFragmentProcessor>(new GrBicubicEffect(*this));
+ std::unique_ptr<GrFragmentProcessor> clone() const override {
+ return std::unique_ptr<GrFragmentProcessor>(new GrBicubicEffect(*this));
}
const GrTextureDomain& domain() const { return fDomain; }
@@ -33,25 +33,23 @@
/**
* Create a Mitchell filter effect with specified texture matrix and x/y tile modes.
*/
- static sk_sp<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy,
- sk_sp<GrColorSpaceXform> colorSpaceXform,
- const SkMatrix& matrix,
- const SkShader::TileMode tileModes[2]) {
- return sk_sp<GrFragmentProcessor>(new GrBicubicEffect(std::move(proxy),
- std::move(colorSpaceXform),
- matrix, tileModes));
+ static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy,
+ sk_sp<GrColorSpaceXform> colorSpaceXform,
+ const SkMatrix& matrix,
+ const SkShader::TileMode tileModes[2]) {
+ return std::unique_ptr<GrFragmentProcessor>(new GrBicubicEffect(
+ std::move(proxy), std::move(colorSpaceXform), matrix, tileModes));
}
/**
* Create a Mitchell filter effect with a texture matrix and a domain.
*/
- static sk_sp<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy,
- sk_sp<GrColorSpaceXform> colorSpaceXform,
- const SkMatrix& matrix,
- const SkRect& domain) {
- return sk_sp<GrFragmentProcessor>(new GrBicubicEffect(std::move(proxy),
- std::move(colorSpaceXform),
- matrix, domain));
+ static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy,
+ sk_sp<GrColorSpaceXform> colorSpaceXform,
+ const SkMatrix& matrix,
+ const SkRect& domain) {
+ return std::unique_ptr<GrFragmentProcessor>(
+ new GrBicubicEffect(std::move(proxy), std::move(colorSpaceXform), matrix, domain));
}
/**
diff --git a/src/gpu/effects/GrBlurredEdgeFragmentProcessor.cpp b/src/gpu/effects/GrBlurredEdgeFragmentProcessor.cpp
index 8c0ff64..1b5ea60 100644
--- a/src/gpu/effects/GrBlurredEdgeFragmentProcessor.cpp
+++ b/src/gpu/effects/GrBlurredEdgeFragmentProcessor.cpp
@@ -55,7 +55,7 @@
: INHERITED(src.optimizationFlags()), fMode(src.fMode) {
this->initClassID<GrBlurredEdgeFragmentProcessor>();
}
-sk_sp<GrFragmentProcessor> GrBlurredEdgeFragmentProcessor::clone() const {
- return sk_sp<GrFragmentProcessor>(new GrBlurredEdgeFragmentProcessor(*this));
+std::unique_ptr<GrFragmentProcessor> GrBlurredEdgeFragmentProcessor::clone() const {
+ return std::unique_ptr<GrFragmentProcessor>(new GrBlurredEdgeFragmentProcessor(*this));
}
#endif
diff --git a/src/gpu/effects/GrBlurredEdgeFragmentProcessor.h b/src/gpu/effects/GrBlurredEdgeFragmentProcessor.h
index 677c285..61cc53b 100644
--- a/src/gpu/effects/GrBlurredEdgeFragmentProcessor.h
+++ b/src/gpu/effects/GrBlurredEdgeFragmentProcessor.h
@@ -19,11 +19,11 @@
public:
enum Mode { kGaussian_Mode = 0, kSmoothStep_Mode = 1 };
int mode() const { return fMode; }
- static sk_sp<GrFragmentProcessor> Make(int mode) {
- return sk_sp<GrFragmentProcessor>(new GrBlurredEdgeFragmentProcessor(mode));
+ static std::unique_ptr<GrFragmentProcessor> Make(int mode) {
+ return std::unique_ptr<GrFragmentProcessor>(new GrBlurredEdgeFragmentProcessor(mode));
}
GrBlurredEdgeFragmentProcessor(const GrBlurredEdgeFragmentProcessor& src);
- sk_sp<GrFragmentProcessor> clone() const override;
+ std::unique_ptr<GrFragmentProcessor> clone() const override;
const char* name() const override { return "BlurredEdgeFragmentProcessor"; }
private:
diff --git a/src/gpu/effects/GrCircleEffect.cpp b/src/gpu/effects/GrCircleEffect.cpp
index 6fc4755..b764559 100644
--- a/src/gpu/effects/GrCircleEffect.cpp
+++ b/src/gpu/effects/GrCircleEffect.cpp
@@ -95,12 +95,12 @@
, fRadius(src.fRadius) {
this->initClassID<GrCircleEffect>();
}
-sk_sp<GrFragmentProcessor> GrCircleEffect::clone() const {
- return sk_sp<GrFragmentProcessor>(new GrCircleEffect(*this));
+std::unique_ptr<GrFragmentProcessor> GrCircleEffect::clone() const {
+ return std::unique_ptr<GrFragmentProcessor>(new GrCircleEffect(*this));
}
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrCircleEffect);
#if GR_TEST_UTILS
-sk_sp<GrFragmentProcessor> GrCircleEffect::TestCreate(GrProcessorTestData* testData) {
+std::unique_ptr<GrFragmentProcessor> GrCircleEffect::TestCreate(GrProcessorTestData* testData) {
SkPoint center;
center.fX = testData->fRandom->nextRangeScalar(0.f, 1000.f);
center.fY = testData->fRandom->nextRangeScalar(0.f, 1000.f);
diff --git a/src/gpu/effects/GrCircleEffect.h b/src/gpu/effects/GrCircleEffect.h
index 46e46f9..0d88dcb 100644
--- a/src/gpu/effects/GrCircleEffect.h
+++ b/src/gpu/effects/GrCircleEffect.h
@@ -20,11 +20,11 @@
int edgeType() const { return fEdgeType; }
SkPoint center() const { return fCenter; }
float radius() const { return fRadius; }
- static sk_sp<GrFragmentProcessor> Make(int edgeType, SkPoint center, float radius) {
- return sk_sp<GrFragmentProcessor>(new GrCircleEffect(edgeType, center, radius));
+ static std::unique_ptr<GrFragmentProcessor> Make(int edgeType, SkPoint center, float radius) {
+ return std::unique_ptr<GrFragmentProcessor>(new GrCircleEffect(edgeType, center, radius));
}
GrCircleEffect(const GrCircleEffect& src);
- sk_sp<GrFragmentProcessor> clone() const override;
+ std::unique_ptr<GrFragmentProcessor> clone() const override;
const char* name() const override { return "CircleEffect"; }
private:
diff --git a/src/gpu/effects/GrConfigConversionEffect.cpp b/src/gpu/effects/GrConfigConversionEffect.cpp
index 8806481..e784ed7 100644
--- a/src/gpu/effects/GrConfigConversionEffect.cpp
+++ b/src/gpu/effects/GrConfigConversionEffect.cpp
@@ -70,8 +70,8 @@
this->initClassID<GrConfigConversionEffect>();
}
-sk_sp<GrFragmentProcessor> GrConfigConversionEffect::clone() const {
- return sk_sp<GrFragmentProcessor>(new GrConfigConversionEffect(fPMConversion));
+std::unique_ptr<GrFragmentProcessor> GrConfigConversionEffect::clone() const {
+ return std::unique_ptr<GrFragmentProcessor>(new GrConfigConversionEffect(fPMConversion));
}
bool GrConfigConversionEffect::onIsEqual(const GrFragmentProcessor& s) const {
@@ -84,9 +84,9 @@
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrConfigConversionEffect);
#if GR_TEST_UTILS
-sk_sp<GrFragmentProcessor> GrConfigConversionEffect::TestCreate(GrProcessorTestData* d) {
+std::unique_ptr<GrFragmentProcessor> GrConfigConversionEffect::TestCreate(GrProcessorTestData* d) {
PMConversion pmConv = static_cast<PMConversion>(d->fRandom->nextULessThan(kPMConversionCnt));
- return sk_sp<GrFragmentProcessor>(new GrConfigConversionEffect(pmConv));
+ return std::unique_ptr<GrFragmentProcessor>(new GrConfigConversionEffect(pmConv));
}
#endif
@@ -158,11 +158,13 @@
GrPaint paint1;
GrPaint paint2;
GrPaint paint3;
- sk_sp<GrFragmentProcessor> pmToUPM(new GrConfigConversionEffect(kToUnpremul_PMConversion));
- sk_sp<GrFragmentProcessor> upmToPM(new GrConfigConversionEffect(kToPremul_PMConversion));
+ std::unique_ptr<GrFragmentProcessor> pmToUPM(
+ new GrConfigConversionEffect(kToUnpremul_PMConversion));
+ std::unique_ptr<GrFragmentProcessor> upmToPM(
+ new GrConfigConversionEffect(kToPremul_PMConversion));
paint1.addColorTextureProcessor(dataProxy, nullptr, SkMatrix::I());
- paint1.addColorFragmentProcessor(pmToUPM);
+ paint1.addColorFragmentProcessor(pmToUPM->clone());
paint1.setPorterDuffXPFactory(SkBlendMode::kSrc);
readRTC->fillRectToRect(GrNoClip(), std::move(paint1), GrAA::kNo, SkMatrix::I(), kRect, kRect);
@@ -199,12 +201,12 @@
return true;
}
-sk_sp<GrFragmentProcessor> GrConfigConversionEffect::Make(sk_sp<GrFragmentProcessor> fp,
- PMConversion pmConversion) {
+std::unique_ptr<GrFragmentProcessor> GrConfigConversionEffect::Make(
+ std::unique_ptr<GrFragmentProcessor> fp, PMConversion pmConversion) {
if (!fp) {
return nullptr;
}
- sk_sp<GrFragmentProcessor> ccFP(new GrConfigConversionEffect(pmConversion));
- sk_sp<GrFragmentProcessor> fpPipeline[] = { fp, ccFP };
+ std::unique_ptr<GrFragmentProcessor> ccFP(new GrConfigConversionEffect(pmConversion));
+ std::unique_ptr<GrFragmentProcessor> fpPipeline[] = { std::move(fp), std::move(ccFP) };
return GrFragmentProcessor::RunInSeries(fpPipeline, 2);
}
diff --git a/src/gpu/effects/GrConfigConversionEffect.h b/src/gpu/effects/GrConfigConversionEffect.h
index fe8f50b..690fbd5 100644
--- a/src/gpu/effects/GrConfigConversionEffect.h
+++ b/src/gpu/effects/GrConfigConversionEffect.h
@@ -29,11 +29,12 @@
* Returns a fragment processor that calls the passed in fragment processor, and then performs
* the requested premul or unpremul conversion.
*/
- static sk_sp<GrFragmentProcessor> Make(sk_sp<GrFragmentProcessor>, PMConversion);
+ static std::unique_ptr<GrFragmentProcessor> Make(std::unique_ptr<GrFragmentProcessor>,
+ PMConversion);
const char* name() const override { return "Config Conversion"; }
- sk_sp<GrFragmentProcessor> clone() const override;
+ std::unique_ptr<GrFragmentProcessor> clone() const override;
PMConversion pmConversion() const { return fPMConversion; }
diff --git a/src/gpu/effects/GrConstColorProcessor.cpp b/src/gpu/effects/GrConstColorProcessor.cpp
index d5f4e35..0859224 100644
--- a/src/gpu/effects/GrConstColorProcessor.cpp
+++ b/src/gpu/effects/GrConstColorProcessor.cpp
@@ -62,7 +62,9 @@
///////////////////////////////////////////////////////////////////////////////
-sk_sp<GrFragmentProcessor> GrConstColorProcessor::clone() const { return Make(fColor, fMode); }
+std::unique_ptr<GrFragmentProcessor> GrConstColorProcessor::clone() const {
+ return Make(fColor, fMode);
+}
GrColor4f GrConstColorProcessor::constantOutputForConstantInput(GrColor4f input) const {
switch (fMode) {
@@ -96,7 +98,7 @@
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrConstColorProcessor);
#if GR_TEST_UTILS
-sk_sp<GrFragmentProcessor> GrConstColorProcessor::TestCreate(GrProcessorTestData* d) {
+std::unique_ptr<GrFragmentProcessor> GrConstColorProcessor::TestCreate(GrProcessorTestData* d) {
GrColor4f color;
int colorPicker = d->fRandom->nextULessThan(3);
switch (colorPicker) {
diff --git a/src/gpu/effects/GrConstColorProcessor.h b/src/gpu/effects/GrConstColorProcessor.h
index baf405a..7079a8d 100644
--- a/src/gpu/effects/GrConstColorProcessor.h
+++ b/src/gpu/effects/GrConstColorProcessor.h
@@ -26,8 +26,8 @@
};
static const int kInputModeCnt = kLastInputMode + 1;
- static sk_sp<GrFragmentProcessor> Make(GrColor4f color, InputMode mode) {
- return sk_sp<GrFragmentProcessor>(new GrConstColorProcessor(color, mode));
+ static std::unique_ptr<GrFragmentProcessor> Make(GrColor4f color, InputMode mode) {
+ return std::unique_ptr<GrFragmentProcessor>(new GrConstColorProcessor(color, mode));
}
const char* name() const override { return "Color"; }
@@ -38,7 +38,7 @@
return str;
}
- sk_sp<GrFragmentProcessor> clone() const override;
+ std::unique_ptr<GrFragmentProcessor> clone() const override;
GrColor4f color() const { return fColor; }
diff --git a/src/gpu/effects/GrConvexPolyEffect.cpp b/src/gpu/effects/GrConvexPolyEffect.cpp
index bb61cc1..e61923c 100644
--- a/src/gpu/effects/GrConvexPolyEffect.cpp
+++ b/src/gpu/effects/GrConvexPolyEffect.cpp
@@ -19,15 +19,16 @@
public:
const SkRect& getRect() const { return fRect; }
- static sk_sp<GrFragmentProcessor> Make(GrPrimitiveEdgeType edgeType, const SkRect& rect) {
- return sk_sp<GrFragmentProcessor>(new AARectEffect(edgeType, rect));
+ static std::unique_ptr<GrFragmentProcessor> Make(GrPrimitiveEdgeType edgeType,
+ const SkRect& rect) {
+ return std::unique_ptr<GrFragmentProcessor>(new AARectEffect(edgeType, rect));
}
GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; }
const char* name() const override { return "AARect"; }
- sk_sp<GrFragmentProcessor> clone() const override { return Make(fEdgeType, fRect); }
+ std::unique_ptr<GrFragmentProcessor> clone() const override { return Make(fEdgeType, fRect); }
private:
void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
@@ -58,12 +59,12 @@
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(AARectEffect);
#if GR_TEST_UTILS
-sk_sp<GrFragmentProcessor> AARectEffect::TestCreate(GrProcessorTestData* d) {
+std::unique_ptr<GrFragmentProcessor> AARectEffect::TestCreate(GrProcessorTestData* d) {
SkRect rect = SkRect::MakeLTRB(d->fRandom->nextSScalar1(),
d->fRandom->nextSScalar1(),
d->fRandom->nextSScalar1(),
d->fRandom->nextSScalar1());
- sk_sp<GrFragmentProcessor> fp;
+ std::unique_ptr<GrFragmentProcessor> fp;
do {
GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>(
d->fRandom->nextULessThan(kGrProcessorEdgeTypeCnt));
@@ -236,7 +237,8 @@
//////////////////////////////////////////////////////////////////////////////
-sk_sp<GrFragmentProcessor> GrConvexPolyEffect::Make(GrPrimitiveEdgeType type, const SkPath& path) {
+std::unique_ptr<GrFragmentProcessor> GrConvexPolyEffect::Make(GrPrimitiveEdgeType type,
+ const SkPath& path) {
if (kHairlineAA_GrProcessorEdgeType == type) {
return nullptr;
}
@@ -306,8 +308,8 @@
return Make(type, n, edges);
}
-sk_sp<GrFragmentProcessor> GrConvexPolyEffect::Make(GrPrimitiveEdgeType edgeType,
- const SkRect& rect) {
+std::unique_ptr<GrFragmentProcessor> GrConvexPolyEffect::Make(GrPrimitiveEdgeType edgeType,
+ const SkRect& rect) {
if (kHairlineAA_GrProcessorEdgeType == edgeType){
return nullptr;
}
@@ -348,8 +350,8 @@
memcpy(fEdges, that.fEdges, 3 * that.fEdgeCount * sizeof(SkScalar));
}
-sk_sp<GrFragmentProcessor> GrConvexPolyEffect::clone() const {
- return sk_sp<GrFragmentProcessor>(new GrConvexPolyEffect(*this));
+std::unique_ptr<GrFragmentProcessor> GrConvexPolyEffect::clone() const {
+ return std::unique_ptr<GrFragmentProcessor>(new GrConvexPolyEffect(*this));
}
bool GrConvexPolyEffect::onIsEqual(const GrFragmentProcessor& other) const {
@@ -364,14 +366,14 @@
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrConvexPolyEffect);
#if GR_TEST_UTILS
-sk_sp<GrFragmentProcessor> GrConvexPolyEffect::TestCreate(GrProcessorTestData* d) {
+std::unique_ptr<GrFragmentProcessor> GrConvexPolyEffect::TestCreate(GrProcessorTestData* d) {
int count = d->fRandom->nextULessThan(kMaxEdges) + 1;
SkScalar edges[kMaxEdges * 3];
for (int i = 0; i < 3 * count; ++i) {
edges[i] = d->fRandom->nextSScalar1();
}
- sk_sp<GrFragmentProcessor> fp;
+ std::unique_ptr<GrFragmentProcessor> fp;
do {
GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>(
d->fRandom->nextULessThan(kGrProcessorEdgeTypeCnt));
diff --git a/src/gpu/effects/GrConvexPolyEffect.h b/src/gpu/effects/GrConvexPolyEffect.h
index f1f6ab0..abb718e 100644
--- a/src/gpu/effects/GrConvexPolyEffect.h
+++ b/src/gpu/effects/GrConvexPolyEffect.h
@@ -38,30 +38,30 @@
* have to modify the effect/shaderbuilder interface to make it possible (e.g. give access
* to the view matrix or untransformed positions in the fragment shader).
*/
- static sk_sp<GrFragmentProcessor> Make(GrPrimitiveEdgeType edgeType, int n,
- const SkScalar edges[]) {
+ static std::unique_ptr<GrFragmentProcessor> Make(GrPrimitiveEdgeType edgeType, int n,
+ const SkScalar edges[]) {
if (n <= 0 || n > kMaxEdges || kHairlineAA_GrProcessorEdgeType == edgeType) {
return nullptr;
}
- return sk_sp<GrFragmentProcessor>(new GrConvexPolyEffect(edgeType, n, edges));
+ return std::unique_ptr<GrFragmentProcessor>(new GrConvexPolyEffect(edgeType, n, edges));
}
/**
* Creates an effect that clips against the path. If the path is not a convex polygon, is
* inverse filled, or has too many edges, this will return nullptr.
*/
- static sk_sp<GrFragmentProcessor> Make(GrPrimitiveEdgeType, const SkPath&);
+ static std::unique_ptr<GrFragmentProcessor> Make(GrPrimitiveEdgeType, const SkPath&);
/**
* Creates an effect that fills inside the rect with AA edges..
*/
- static sk_sp<GrFragmentProcessor> Make(GrPrimitiveEdgeType, const SkRect&);
+ static std::unique_ptr<GrFragmentProcessor> Make(GrPrimitiveEdgeType, const SkRect&);
~GrConvexPolyEffect() override;
const char* name() const override { return "ConvexPoly"; }
- sk_sp<GrFragmentProcessor> clone() const override;
+ std::unique_ptr<GrFragmentProcessor> clone() const override;
GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; }
diff --git a/src/gpu/effects/GrDitherEffect.cpp b/src/gpu/effects/GrDitherEffect.cpp
index f2fc678..d78af4e 100644
--- a/src/gpu/effects/GrDitherEffect.cpp
+++ b/src/gpu/effects/GrDitherEffect.cpp
@@ -62,14 +62,14 @@
: INHERITED(src.optimizationFlags()), fRangeType(src.fRangeType) {
this->initClassID<GrDitherEffect>();
}
-sk_sp<GrFragmentProcessor> GrDitherEffect::clone() const {
- return sk_sp<GrFragmentProcessor>(new GrDitherEffect(*this));
+std::unique_ptr<GrFragmentProcessor> GrDitherEffect::clone() const {
+ return std::unique_ptr<GrFragmentProcessor>(new GrDitherEffect(*this));
}
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrDitherEffect);
#if GR_TEST_UTILS
-sk_sp<GrFragmentProcessor> GrDitherEffect::TestCreate(GrProcessorTestData* testData) {
+std::unique_ptr<GrFragmentProcessor> GrDitherEffect::TestCreate(GrProcessorTestData* testData) {
float range = testData->fRandom->nextRangeF(0.001f, 0.05f);
- return sk_sp<GrFragmentProcessor>(new GrDitherEffect(range));
+ return std::unique_ptr<GrFragmentProcessor>(new GrDitherEffect(range));
}
#endif
#endif
diff --git a/src/gpu/effects/GrDitherEffect.fp b/src/gpu/effects/GrDitherEffect.fp
index 7ec852e..fe641c6 100644
--- a/src/gpu/effects/GrDitherEffect.fp
+++ b/src/gpu/effects/GrDitherEffect.fp
@@ -2,7 +2,7 @@
layout(key) in int rangeType;
@make {
- static sk_sp<GrFragmentProcessor> Make(GrPixelConfig dstConfig) {
+ static std::unique_ptr<GrFragmentProcessor> Make(GrPixelConfig dstConfig) {
int rangeType;
switch (dstConfig) {
case kGray_8_GrPixelConfig:
@@ -27,7 +27,7 @@
case kAlpha_8_GrPixelConfig:
return nullptr;
}
- return sk_sp<GrFragmentProcessor>(new GrDitherEffect(rangeType));
+ return std::unique_ptr<GrFragmentProcessor>(new GrDitherEffect(rangeType));
}
}
@@ -68,5 +68,5 @@
@test(testData) {
float range = testData->fRandom->nextRangeF(0.001f, 0.05f);
- return sk_sp<GrFragmentProcessor>(new GrDitherEffect(range));
+ return std::unique_ptr<GrFragmentProcessor>(new GrDitherEffect(range));
}
diff --git a/src/gpu/effects/GrDitherEffect.h b/src/gpu/effects/GrDitherEffect.h
index 529b5ec..d428c3c 100644
--- a/src/gpu/effects/GrDitherEffect.h
+++ b/src/gpu/effects/GrDitherEffect.h
@@ -19,7 +19,7 @@
public:
int rangeType() const { return fRangeType; }
- static sk_sp<GrFragmentProcessor> Make(GrPixelConfig dstConfig) {
+ static std::unique_ptr<GrFragmentProcessor> Make(GrPixelConfig dstConfig) {
int rangeType;
switch (dstConfig) {
case kGray_8_GrPixelConfig:
@@ -44,10 +44,10 @@
case kAlpha_8_GrPixelConfig:
return nullptr;
}
- return sk_sp<GrFragmentProcessor>(new GrDitherEffect(rangeType));
+ return std::unique_ptr<GrFragmentProcessor>(new GrDitherEffect(rangeType));
}
GrDitherEffect(const GrDitherEffect& src);
- sk_sp<GrFragmentProcessor> clone() const override;
+ std::unique_ptr<GrFragmentProcessor> clone() const override;
const char* name() const override { return "DitherEffect"; }
private:
diff --git a/src/gpu/effects/GrEllipseEffect.cpp b/src/gpu/effects/GrEllipseEffect.cpp
index edf12d2..e9443a8 100644
--- a/src/gpu/effects/GrEllipseEffect.cpp
+++ b/src/gpu/effects/GrEllipseEffect.cpp
@@ -120,12 +120,12 @@
, fRadii(src.fRadii) {
this->initClassID<GrEllipseEffect>();
}
-sk_sp<GrFragmentProcessor> GrEllipseEffect::clone() const {
- return sk_sp<GrFragmentProcessor>(new GrEllipseEffect(*this));
+std::unique_ptr<GrFragmentProcessor> GrEllipseEffect::clone() const {
+ return std::unique_ptr<GrFragmentProcessor>(new GrEllipseEffect(*this));
}
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrEllipseEffect);
#if GR_TEST_UTILS
-sk_sp<GrFragmentProcessor> GrEllipseEffect::TestCreate(GrProcessorTestData* testData) {
+std::unique_ptr<GrFragmentProcessor> GrEllipseEffect::TestCreate(GrProcessorTestData* testData) {
SkPoint center;
center.fX = testData->fRandom->nextRangeScalar(0.f, 1000.f);
center.fY = testData->fRandom->nextRangeScalar(0.f, 1000.f);
diff --git a/src/gpu/effects/GrEllipseEffect.h b/src/gpu/effects/GrEllipseEffect.h
index 2858656..1425f39 100644
--- a/src/gpu/effects/GrEllipseEffect.h
+++ b/src/gpu/effects/GrEllipseEffect.h
@@ -20,11 +20,11 @@
int edgeType() const { return fEdgeType; }
SkPoint center() const { return fCenter; }
SkPoint radii() const { return fRadii; }
- static sk_sp<GrFragmentProcessor> Make(int edgeType, SkPoint center, SkPoint radii) {
- return sk_sp<GrFragmentProcessor>(new GrEllipseEffect(edgeType, center, radii));
+ static std::unique_ptr<GrFragmentProcessor> Make(int edgeType, SkPoint center, SkPoint radii) {
+ return std::unique_ptr<GrFragmentProcessor>(new GrEllipseEffect(edgeType, center, radii));
}
GrEllipseEffect(const GrEllipseEffect& src);
- sk_sp<GrFragmentProcessor> clone() const override;
+ std::unique_ptr<GrFragmentProcessor> clone() const override;
const char* name() const override { return "EllipseEffect"; }
private:
diff --git a/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp b/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp
index ac22a8c..b54ca53 100644
--- a/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp
+++ b/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp
@@ -255,7 +255,7 @@
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrGaussianConvolutionFragmentProcessor);
#if GR_TEST_UTILS
-sk_sp<GrFragmentProcessor> GrGaussianConvolutionFragmentProcessor::TestCreate(
+std::unique_ptr<GrFragmentProcessor> GrGaussianConvolutionFragmentProcessor::TestCreate(
GrProcessorTestData* d) {
int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx
: GrProcessorUnitTest::kAlphaTextureIdx;
diff --git a/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.h b/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.h
index 74e9a94..9850e60 100644
--- a/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.h
+++ b/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.h
@@ -22,14 +22,14 @@
enum class Direction { kX, kY };
/// Convolve with a Gaussian kernel
- static sk_sp<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy,
- Direction dir,
- int halfWidth,
- float gaussianSigma,
- GrTextureDomain::Mode mode,
- int* bounds) {
- return sk_sp<GrFragmentProcessor>(new GrGaussianConvolutionFragmentProcessor(
- std::move(proxy), dir, halfWidth, gaussianSigma, mode, bounds));
+ static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy,
+ Direction dir,
+ int halfWidth,
+ float gaussianSigma,
+ GrTextureDomain::Mode mode,
+ int* bounds) {
+ return std::unique_ptr<GrFragmentProcessor>(new GrGaussianConvolutionFragmentProcessor(
+ std::move(proxy), dir, halfWidth, gaussianSigma, mode, bounds));
}
const float* kernel() const { return fKernel; }
@@ -44,8 +44,9 @@
const char* name() const override { return "GaussianConvolution"; }
- sk_sp<GrFragmentProcessor> clone() const override {
- return sk_sp<GrFragmentProcessor>(new GrGaussianConvolutionFragmentProcessor(*this));
+ std::unique_ptr<GrFragmentProcessor> clone() const override {
+ return std::unique_ptr<GrFragmentProcessor>(
+ new GrGaussianConvolutionFragmentProcessor(*this));
}
// This was decided based on the min allowed value for the max texture
diff --git a/src/gpu/effects/GrMatrixConvolutionEffect.cpp b/src/gpu/effects/GrMatrixConvolutionEffect.cpp
index 030a926..9d9a03e 100644
--- a/src/gpu/effects/GrMatrixConvolutionEffect.cpp
+++ b/src/gpu/effects/GrMatrixConvolutionEffect.cpp
@@ -194,8 +194,8 @@
memcpy(fKernelOffset, that.fKernelOffset, sizeof(fKernelOffset));
}
-sk_sp<GrFragmentProcessor> GrMatrixConvolutionEffect::clone() const {
- return sk_sp<GrFragmentProcessor>(new GrMatrixConvolutionEffect(*this));
+std::unique_ptr<GrFragmentProcessor> GrMatrixConvolutionEffect::clone() const {
+ return std::unique_ptr<GrFragmentProcessor>(new GrMatrixConvolutionEffect(*this));
}
void GrMatrixConvolutionEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps,
@@ -248,30 +248,30 @@
}
// Static function to create a 2D convolution
-sk_sp<GrFragmentProcessor> GrMatrixConvolutionEffect::MakeGaussian(
- sk_sp<GrTextureProxy> proxy,
- const SkIRect& bounds,
- const SkISize& kernelSize,
- SkScalar gain,
- SkScalar bias,
- const SkIPoint& kernelOffset,
- GrTextureDomain::Mode tileMode,
- bool convolveAlpha,
- SkScalar sigmaX,
- SkScalar sigmaY) {
+std::unique_ptr<GrFragmentProcessor> GrMatrixConvolutionEffect::MakeGaussian(
+ sk_sp<GrTextureProxy> proxy,
+ const SkIRect& bounds,
+ const SkISize& kernelSize,
+ SkScalar gain,
+ SkScalar bias,
+ const SkIPoint& kernelOffset,
+ GrTextureDomain::Mode tileMode,
+ bool convolveAlpha,
+ SkScalar sigmaX,
+ SkScalar sigmaY) {
float kernel[MAX_KERNEL_SIZE];
fill_in_2D_gaussian_kernel(kernel, kernelSize.width(), kernelSize.height(), sigmaX, sigmaY);
- return sk_sp<GrFragmentProcessor>(
- new GrMatrixConvolutionEffect(std::move(proxy), bounds, kernelSize,
- kernel, gain, bias, kernelOffset, tileMode, convolveAlpha));
+ return std::unique_ptr<GrFragmentProcessor>(
+ new GrMatrixConvolutionEffect(std::move(proxy), bounds, kernelSize, kernel, gain, bias,
+ kernelOffset, tileMode, convolveAlpha));
}
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrMatrixConvolutionEffect);
#if GR_TEST_UTILS
-sk_sp<GrFragmentProcessor> GrMatrixConvolutionEffect::TestCreate(GrProcessorTestData* d) {
+std::unique_ptr<GrFragmentProcessor> GrMatrixConvolutionEffect::TestCreate(GrProcessorTestData* d) {
int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx
: GrProcessorUnitTest::kAlphaTextureIdx;
sk_sp<GrTextureProxy> proxy = d->textureProxy(texIdx);
diff --git a/src/gpu/effects/GrMatrixConvolutionEffect.h b/src/gpu/effects/GrMatrixConvolutionEffect.h
index 9ece00e..2e859b1 100644
--- a/src/gpu/effects/GrMatrixConvolutionEffect.h
+++ b/src/gpu/effects/GrMatrixConvolutionEffect.h
@@ -16,30 +16,30 @@
class GrMatrixConvolutionEffect : public GrFragmentProcessor {
public:
- static sk_sp<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy,
- const SkIRect& bounds,
- const SkISize& kernelSize,
- const SkScalar* kernel,
- SkScalar gain,
- SkScalar bias,
- const SkIPoint& kernelOffset,
- GrTextureDomain::Mode tileMode,
- bool convolveAlpha) {
- return sk_sp<GrFragmentProcessor>(
- new GrMatrixConvolutionEffect(std::move(proxy), bounds, kernelSize,
- kernel, gain, bias, kernelOffset, tileMode, convolveAlpha));
+ static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy,
+ const SkIRect& bounds,
+ const SkISize& kernelSize,
+ const SkScalar* kernel,
+ SkScalar gain,
+ SkScalar bias,
+ const SkIPoint& kernelOffset,
+ GrTextureDomain::Mode tileMode,
+ bool convolveAlpha) {
+ return std::unique_ptr<GrFragmentProcessor>(
+ new GrMatrixConvolutionEffect(std::move(proxy), bounds, kernelSize, kernel, gain,
+ bias, kernelOffset, tileMode, convolveAlpha));
}
- static sk_sp<GrFragmentProcessor> MakeGaussian(sk_sp<GrTextureProxy> proxy,
- const SkIRect& bounds,
- const SkISize& kernelSize,
- SkScalar gain,
- SkScalar bias,
- const SkIPoint& kernelOffset,
- GrTextureDomain::Mode tileMode,
- bool convolveAlpha,
- SkScalar sigmaX,
- SkScalar sigmaY);
+ static std::unique_ptr<GrFragmentProcessor> MakeGaussian(sk_sp<GrTextureProxy> proxy,
+ const SkIRect& bounds,
+ const SkISize& kernelSize,
+ SkScalar gain,
+ SkScalar bias,
+ const SkIPoint& kernelOffset,
+ GrTextureDomain::Mode tileMode,
+ bool convolveAlpha,
+ SkScalar sigmaX,
+ SkScalar sigmaY);
const SkIRect& bounds() const { return fBounds; }
const SkISize& kernelSize() const { return fKernelSize; }
@@ -52,7 +52,7 @@
const char* name() const override { return "MatrixConvolution"; }
- sk_sp<GrFragmentProcessor> clone() const override;
+ std::unique_ptr<GrFragmentProcessor> clone() const override;
private:
GrMatrixConvolutionEffect(sk_sp<GrTextureProxy> proxy,
diff --git a/src/gpu/effects/GrNonlinearColorSpaceXformEffect.cpp b/src/gpu/effects/GrNonlinearColorSpaceXformEffect.cpp
index 6ae770b..b30746a 100644
--- a/src/gpu/effects/GrNonlinearColorSpaceXformEffect.cpp
+++ b/src/gpu/effects/GrNonlinearColorSpaceXformEffect.cpp
@@ -173,8 +173,8 @@
memcpy(fDstTransferFnCoeffs, that.fDstTransferFnCoeffs, sizeof(fDstTransferFnCoeffs));
}
-sk_sp<GrFragmentProcessor> GrNonlinearColorSpaceXformEffect::clone() const {
- return sk_sp<GrFragmentProcessor>(new GrNonlinearColorSpaceXformEffect(*this));
+std::unique_ptr<GrFragmentProcessor> GrNonlinearColorSpaceXformEffect::clone() const {
+ return std::unique_ptr<GrFragmentProcessor>(new GrNonlinearColorSpaceXformEffect(*this));
}
bool GrNonlinearColorSpaceXformEffect::onIsEqual(const GrFragmentProcessor& s) const {
@@ -201,7 +201,8 @@
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrNonlinearColorSpaceXformEffect);
#if GR_TEST_UTILS
-sk_sp<GrFragmentProcessor> GrNonlinearColorSpaceXformEffect::TestCreate(GrProcessorTestData* d) {
+std::unique_ptr<GrFragmentProcessor> GrNonlinearColorSpaceXformEffect::TestCreate(
+ GrProcessorTestData* d) {
// TODO: Generate a random variety of color spaces for this effect (it can handle wacky
// transfer functions, etc...)
sk_sp<SkColorSpace> srcSpace = SkColorSpace::MakeSRGBLinear();
@@ -221,8 +222,8 @@
return new GrGLNonlinearColorSpaceXformEffect();
}
-sk_sp<GrFragmentProcessor> GrNonlinearColorSpaceXformEffect::Make(const SkColorSpace* src,
- const SkColorSpace* dst) {
+std::unique_ptr<GrFragmentProcessor> GrNonlinearColorSpaceXformEffect::Make(
+ const SkColorSpace* src, const SkColorSpace* dst) {
if (!src || !dst || SkColorSpace::Equals(src, dst)) {
// No conversion possible (or necessary)
return nullptr;
@@ -257,6 +258,6 @@
}
}
- return sk_sp<GrFragmentProcessor>(new GrNonlinearColorSpaceXformEffect(
- ops, srcTransferFn, dstTransferFn, srcToDstMtx));
+ return std::unique_ptr<GrFragmentProcessor>(
+ new GrNonlinearColorSpaceXformEffect(ops, srcTransferFn, dstTransferFn, srcToDstMtx));
}
diff --git a/src/gpu/effects/GrNonlinearColorSpaceXformEffect.h b/src/gpu/effects/GrNonlinearColorSpaceXformEffect.h
index f57c64b..109ec10 100644
--- a/src/gpu/effects/GrNonlinearColorSpaceXformEffect.h
+++ b/src/gpu/effects/GrNonlinearColorSpaceXformEffect.h
@@ -27,11 +27,12 @@
* This will return nullptr if either space is nullptr, if both spaces are equal, or if either
* space has a non-parametric transfer funcion (e.g. lookup table or A2B).
*/
- static sk_sp<GrFragmentProcessor> Make(const SkColorSpace* src, const SkColorSpace* dst);
+ static std::unique_ptr<GrFragmentProcessor> Make(const SkColorSpace* src,
+ const SkColorSpace* dst);
const char* name() const override { return "NonlinearColorSpaceXform"; }
- sk_sp<GrFragmentProcessor> clone() const override;
+ std::unique_ptr<GrFragmentProcessor> clone() const override;
static const int kNumTransferFnCoeffs = 7;
diff --git a/src/gpu/effects/GrOvalEffect.cpp b/src/gpu/effects/GrOvalEffect.cpp
index 3180533..efc86a4 100644
--- a/src/gpu/effects/GrOvalEffect.cpp
+++ b/src/gpu/effects/GrOvalEffect.cpp
@@ -11,7 +11,8 @@
#include "GrEllipseEffect.h"
#include "SkRect.h"
-sk_sp<GrFragmentProcessor> GrOvalEffect::Make(GrPrimitiveEdgeType edgeType, const SkRect& oval) {
+std::unique_ptr<GrFragmentProcessor> GrOvalEffect::Make(GrPrimitiveEdgeType edgeType,
+ const SkRect& oval) {
if (kHairlineAA_GrProcessorEdgeType == edgeType) {
return nullptr;
}
diff --git a/src/gpu/effects/GrOvalEffect.h b/src/gpu/effects/GrOvalEffect.h
index 3ff241a..1372f23 100644
--- a/src/gpu/effects/GrOvalEffect.h
+++ b/src/gpu/effects/GrOvalEffect.h
@@ -16,10 +16,12 @@
struct SkRect;
namespace GrOvalEffect {
- /**
- * Creates an effect that performs clipping against an oval.
- */
- sk_sp<GrFragmentProcessor> Make(GrPrimitiveEdgeType, const SkRect&);
+
+/**
+ * Creates an effect that performs clipping against an oval.
+ */
+std::unique_ptr<GrFragmentProcessor> Make(GrPrimitiveEdgeType, const SkRect&);
+
};
#endif
diff --git a/src/gpu/effects/GrRRectEffect.cpp b/src/gpu/effects/GrRRectEffect.cpp
index 8dde914..f253dfe 100644
--- a/src/gpu/effects/GrRRectEffect.cpp
+++ b/src/gpu/effects/GrRRectEffect.cpp
@@ -45,14 +45,14 @@
// The flags are used to indicate which corners are circluar (unflagged corners are assumed to
// be square).
- static sk_sp<GrFragmentProcessor> Make(GrPrimitiveEdgeType, uint32_t circularCornerFlags,
- const SkRRect&);
+ static std::unique_ptr<GrFragmentProcessor> Make(GrPrimitiveEdgeType,
+ uint32_t circularCornerFlags, const SkRRect&);
~CircularRRectEffect() override {}
const char* name() const override { return "CircularRRect"; }
- sk_sp<GrFragmentProcessor> clone() const override;
+ std::unique_ptr<GrFragmentProcessor> clone() const override;
const SkRRect& getRRect() const { return fRRect; }
@@ -78,14 +78,14 @@
typedef GrFragmentProcessor INHERITED;
};
-sk_sp<GrFragmentProcessor> CircularRRectEffect::Make(GrPrimitiveEdgeType edgeType,
- uint32_t circularCornerFlags,
- const SkRRect& rrect) {
+std::unique_ptr<GrFragmentProcessor> CircularRRectEffect::Make(GrPrimitiveEdgeType edgeType,
+ uint32_t circularCornerFlags,
+ const SkRRect& rrect) {
if (kFillAA_GrProcessorEdgeType != edgeType && kInverseFillAA_GrProcessorEdgeType != edgeType) {
return nullptr;
}
- return sk_sp<GrFragmentProcessor>(
- new CircularRRectEffect(edgeType, circularCornerFlags, rrect));
+ return std::unique_ptr<GrFragmentProcessor>(
+ new CircularRRectEffect(edgeType, circularCornerFlags, rrect));
}
CircularRRectEffect::CircularRRectEffect(GrPrimitiveEdgeType edgeType, uint32_t circularCornerFlags,
@@ -97,8 +97,8 @@
this->initClassID<CircularRRectEffect>();
}
-sk_sp<GrFragmentProcessor> CircularRRectEffect::clone() const {
- return sk_sp<GrFragmentProcessor>(
+std::unique_ptr<GrFragmentProcessor> CircularRRectEffect::clone() const {
+ return std::unique_ptr<GrFragmentProcessor>(
new CircularRRectEffect(fEdgeType, fCircularCornerFlags, fRRect));
}
@@ -113,13 +113,13 @@
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(CircularRRectEffect);
#if GR_TEST_UTILS
-sk_sp<GrFragmentProcessor> CircularRRectEffect::TestCreate(GrProcessorTestData* d) {
+std::unique_ptr<GrFragmentProcessor> CircularRRectEffect::TestCreate(GrProcessorTestData* d) {
SkScalar w = d->fRandom->nextRangeScalar(20.f, 1000.f);
SkScalar h = d->fRandom->nextRangeScalar(20.f, 1000.f);
SkScalar r = d->fRandom->nextRangeF(kRadiusMin, 9.f);
SkRRect rrect;
rrect.setRectXY(SkRect::MakeWH(w, h), r, r);
- sk_sp<GrFragmentProcessor> fp;
+ std::unique_ptr<GrFragmentProcessor> fp;
do {
GrPrimitiveEdgeType et =
(GrPrimitiveEdgeType)d->fRandom->nextULessThan(kGrProcessorEdgeTypeCnt);
@@ -391,13 +391,13 @@
class EllipticalRRectEffect : public GrFragmentProcessor {
public:
- static sk_sp<GrFragmentProcessor> Make(GrPrimitiveEdgeType, const SkRRect&);
+ static std::unique_ptr<GrFragmentProcessor> Make(GrPrimitiveEdgeType, const SkRRect&);
~EllipticalRRectEffect() override {}
const char* name() const override { return "EllipticalRRect"; }
- sk_sp<GrFragmentProcessor> clone() const override;
+ std::unique_ptr<GrFragmentProcessor> clone() const override;
const SkRRect& getRRect() const { return fRRect; }
@@ -420,12 +420,12 @@
typedef GrFragmentProcessor INHERITED;
};
-sk_sp<GrFragmentProcessor>
-EllipticalRRectEffect::Make(GrPrimitiveEdgeType edgeType, const SkRRect& rrect) {
+std::unique_ptr<GrFragmentProcessor> EllipticalRRectEffect::Make(GrPrimitiveEdgeType edgeType,
+ const SkRRect& rrect) {
if (kFillAA_GrProcessorEdgeType != edgeType && kInverseFillAA_GrProcessorEdgeType != edgeType) {
return nullptr;
}
- return sk_sp<GrFragmentProcessor>(new EllipticalRRectEffect(edgeType, rrect));
+ return std::unique_ptr<GrFragmentProcessor>(new EllipticalRRectEffect(edgeType, rrect));
}
EllipticalRRectEffect::EllipticalRRectEffect(GrPrimitiveEdgeType edgeType, const SkRRect& rrect)
@@ -435,8 +435,8 @@
this->initClassID<EllipticalRRectEffect>();
}
-sk_sp<GrFragmentProcessor> EllipticalRRectEffect::clone() const {
- return sk_sp<GrFragmentProcessor>(new EllipticalRRectEffect(fEdgeType, fRRect));
+std::unique_ptr<GrFragmentProcessor> EllipticalRRectEffect::clone() const {
+ return std::unique_ptr<GrFragmentProcessor>(new EllipticalRRectEffect(fEdgeType, fRRect));
}
bool EllipticalRRectEffect::onIsEqual(const GrFragmentProcessor& other) const {
@@ -449,7 +449,7 @@
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(EllipticalRRectEffect);
#if GR_TEST_UTILS
-sk_sp<GrFragmentProcessor> EllipticalRRectEffect::TestCreate(GrProcessorTestData* d) {
+std::unique_ptr<GrFragmentProcessor> EllipticalRRectEffect::TestCreate(GrProcessorTestData* d) {
SkScalar w = d->fRandom->nextRangeScalar(20.f, 1000.f);
SkScalar h = d->fRandom->nextRangeScalar(20.f, 1000.f);
SkVector r[4];
@@ -476,7 +476,7 @@
rrect.setRectXY(SkRect::MakeWH(w, h), r[SkRRect::kUpperLeft_Corner].fX,
r[SkRRect::kUpperLeft_Corner].fY);
}
- sk_sp<GrFragmentProcessor> fp;
+ std::unique_ptr<GrFragmentProcessor> fp;
do {
GrPrimitiveEdgeType et =
(GrPrimitiveEdgeType)d->fRandom->nextULessThan(kGrProcessorEdgeTypeCnt);
@@ -684,7 +684,8 @@
//////////////////////////////////////////////////////////////////////////////
-sk_sp<GrFragmentProcessor> GrRRectEffect::Make(GrPrimitiveEdgeType edgeType, const SkRRect& rrect) {
+std::unique_ptr<GrFragmentProcessor> GrRRectEffect::Make(GrPrimitiveEdgeType edgeType,
+ const SkRRect& rrect) {
if (rrect.isRect()) {
return GrConvexPolyEffect::Make(edgeType, rrect.getBounds());
}
diff --git a/src/gpu/effects/GrRRectEffect.h b/src/gpu/effects/GrRRectEffect.h
index 6ff2cc9..fcd600a 100644
--- a/src/gpu/effects/GrRRectEffect.h
+++ b/src/gpu/effects/GrRRectEffect.h
@@ -17,11 +17,13 @@
class SkRRect;
namespace GrRRectEffect {
- /**
- * Creates an effect that performs anti-aliased clipping against a SkRRect. It doesn't support
- * all varieties of SkRRect so the caller must check for a nullptr return.
- */
- sk_sp<GrFragmentProcessor> Make(GrPrimitiveEdgeType, const SkRRect&);
+
+/**
+ * Creates an effect that performs anti-aliased clipping against a SkRRect. It doesn't support
+ * all varieties of SkRRect so the caller must check for a nullptr return.
+ */
+std::unique_ptr<GrFragmentProcessor> Make(GrPrimitiveEdgeType, const SkRRect&);
+
};
#endif
diff --git a/src/gpu/effects/GrSRGBEffect.cpp b/src/gpu/effects/GrSRGBEffect.cpp
index 1cffb9e..f415a6c 100644
--- a/src/gpu/effects/GrSRGBEffect.cpp
+++ b/src/gpu/effects/GrSRGBEffect.cpp
@@ -85,7 +85,7 @@
this->initClassID<GrSRGBEffect>();
}
-sk_sp<GrFragmentProcessor> GrSRGBEffect::clone() const { return Make(fMode, fAlpha); }
+std::unique_ptr<GrFragmentProcessor> GrSRGBEffect::clone() const { return Make(fMode, fAlpha); }
bool GrSRGBEffect::onIsEqual(const GrFragmentProcessor& s) const {
const GrSRGBEffect& other = s.cast<GrSRGBEffect>();
@@ -119,7 +119,7 @@
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrSRGBEffect);
#if GR_TEST_UTILS
-sk_sp<GrFragmentProcessor> GrSRGBEffect::TestCreate(GrProcessorTestData* d) {
+std::unique_ptr<GrFragmentProcessor> GrSRGBEffect::TestCreate(GrProcessorTestData* d) {
Mode testMode = static_cast<Mode>(d->fRandom->nextRangeU(0, 1));
return GrSRGBEffect::Make(testMode, Alpha::kPremul);
}
diff --git a/src/gpu/effects/GrSRGBEffect.h b/src/gpu/effects/GrSRGBEffect.h
index ef6fd28..9b51fca 100644
--- a/src/gpu/effects/GrSRGBEffect.h
+++ b/src/gpu/effects/GrSRGBEffect.h
@@ -25,8 +25,8 @@
/**
* Creates an effect that applies the sRGB transfer function (or its inverse)
*/
- static sk_sp<GrFragmentProcessor> Make(Mode mode, Alpha alpha) {
- return sk_sp<GrFragmentProcessor>(new GrSRGBEffect(mode, alpha));
+ static std::unique_ptr<GrFragmentProcessor> Make(Mode mode, Alpha alpha) {
+ return std::unique_ptr<GrFragmentProcessor>(new GrSRGBEffect(mode, alpha));
}
const char* name() const override { return "sRGB"; }
@@ -34,7 +34,7 @@
Mode mode() const { return fMode; }
Alpha alpha() const { return fAlpha; }
- sk_sp<GrFragmentProcessor> clone() const override;
+ std::unique_ptr<GrFragmentProcessor> clone() const override;
private:
GrSRGBEffect(Mode mode, Alpha);
diff --git a/src/gpu/effects/GrSimpleTextureEffect.cpp b/src/gpu/effects/GrSimpleTextureEffect.cpp
index bd2b805..9a0017c 100644
--- a/src/gpu/effects/GrSimpleTextureEffect.cpp
+++ b/src/gpu/effects/GrSimpleTextureEffect.cpp
@@ -80,12 +80,13 @@
this->addTextureSampler(&fImage);
this->addCoordTransform(&fImageCoordTransform);
}
-sk_sp<GrFragmentProcessor> GrSimpleTextureEffect::clone() const {
- return sk_sp<GrFragmentProcessor>(new GrSimpleTextureEffect(*this));
+std::unique_ptr<GrFragmentProcessor> GrSimpleTextureEffect::clone() const {
+ return std::unique_ptr<GrFragmentProcessor>(new GrSimpleTextureEffect(*this));
}
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrSimpleTextureEffect);
#if GR_TEST_UTILS
-sk_sp<GrFragmentProcessor> GrSimpleTextureEffect::TestCreate(GrProcessorTestData* testData) {
+std::unique_ptr<GrFragmentProcessor> GrSimpleTextureEffect::TestCreate(
+ GrProcessorTestData* testData) {
int texIdx = testData->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx
: GrProcessorUnitTest::kAlphaTextureIdx;
static const SkShader::TileMode kTileModes[] = {
diff --git a/src/gpu/effects/GrSimpleTextureEffect.fp b/src/gpu/effects/GrSimpleTextureEffect.fp
index 6f7c818..80824fe 100644
--- a/src/gpu/effects/GrSimpleTextureEffect.fp
+++ b/src/gpu/effects/GrSimpleTextureEffect.fp
@@ -22,29 +22,29 @@
}
@make {
- static sk_sp<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy,
- sk_sp<GrColorSpaceXform> colorSpaceXform,
- const SkMatrix& matrix) {
- return sk_sp<GrFragmentProcessor>(
+ static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy,
+ sk_sp<GrColorSpaceXform> colorSpaceXform,
+ const SkMatrix& matrix) {
+ return std::unique_ptr<GrFragmentProcessor>(
new GrSimpleTextureEffect(std::move(proxy), std::move(colorSpaceXform), matrix,
GrSamplerParams(SkShader::kClamp_TileMode, GrSamplerParams::kNone_FilterMode)));
}
/* clamp mode */
- static sk_sp<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy,
- sk_sp<GrColorSpaceXform> colorSpaceXform,
- const SkMatrix& matrix,
- GrSamplerParams::FilterMode filterMode) {
- return sk_sp<GrFragmentProcessor>(
+ static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy,
+ sk_sp<GrColorSpaceXform> colorSpaceXform,
+ const SkMatrix& matrix,
+ GrSamplerParams::FilterMode filterMode) {
+ return std::unique_ptr<GrFragmentProcessor>(
new GrSimpleTextureEffect(std::move(proxy), std::move(colorSpaceXform), matrix,
GrSamplerParams(SkShader::kClamp_TileMode, filterMode)));
}
- static sk_sp<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy,
- sk_sp<GrColorSpaceXform> colorSpaceXform,
- const SkMatrix& matrix,
- const GrSamplerParams& p) {
- return sk_sp<GrFragmentProcessor>(
+ static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy,
+ sk_sp<GrColorSpaceXform> colorSpaceXform,
+ const SkMatrix& matrix,
+ const GrSamplerParams& p) {
+ return std::unique_ptr<GrFragmentProcessor>(
new GrSimpleTextureEffect(std::move(proxy), std::move(colorSpaceXform), matrix, p));
}
}
diff --git a/src/gpu/effects/GrSimpleTextureEffect.h b/src/gpu/effects/GrSimpleTextureEffect.h
index 25ef1c5..11564bb 100644
--- a/src/gpu/effects/GrSimpleTextureEffect.h
+++ b/src/gpu/effects/GrSimpleTextureEffect.h
@@ -20,35 +20,35 @@
sk_sp<GrColorSpaceXform> colorXform() const { return fColorXform; }
SkMatrix44 matrix() const { return fMatrix; }
- static sk_sp<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy,
- sk_sp<GrColorSpaceXform>
- colorSpaceXform,
- const SkMatrix& matrix) {
- return sk_sp<GrFragmentProcessor>(new GrSimpleTextureEffect(
+ static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy,
+ sk_sp<GrColorSpaceXform>
+ colorSpaceXform,
+ const SkMatrix& matrix) {
+ return std::unique_ptr<GrFragmentProcessor>(new GrSimpleTextureEffect(
std::move(proxy), std::move(colorSpaceXform), matrix,
GrSamplerParams(SkShader::kClamp_TileMode, GrSamplerParams::kNone_FilterMode)));
}
- static sk_sp<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy,
- sk_sp<GrColorSpaceXform>
- colorSpaceXform,
- const SkMatrix& matrix,
- GrSamplerParams::FilterMode filterMode) {
- return sk_sp<GrFragmentProcessor>(
+ static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy,
+ sk_sp<GrColorSpaceXform>
+ colorSpaceXform,
+ const SkMatrix& matrix,
+ GrSamplerParams::FilterMode filterMode) {
+ return std::unique_ptr<GrFragmentProcessor>(
new GrSimpleTextureEffect(std::move(proxy), std::move(colorSpaceXform), matrix,
GrSamplerParams(SkShader::kClamp_TileMode, filterMode)));
}
- static sk_sp<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy,
- sk_sp<GrColorSpaceXform>
- colorSpaceXform,
- const SkMatrix& matrix,
- const GrSamplerParams& p) {
- return sk_sp<GrFragmentProcessor>(
+ static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy,
+ sk_sp<GrColorSpaceXform>
+ colorSpaceXform,
+ const SkMatrix& matrix,
+ const GrSamplerParams& p) {
+ return std::unique_ptr<GrFragmentProcessor>(
new GrSimpleTextureEffect(std::move(proxy), std::move(colorSpaceXform), matrix, p));
}
GrSimpleTextureEffect(const GrSimpleTextureEffect& src);
- sk_sp<GrFragmentProcessor> clone() const override;
+ std::unique_ptr<GrFragmentProcessor> clone() const override;
const char* name() const override { return "SimpleTextureEffect"; }
private:
diff --git a/src/gpu/effects/GrTextureDomain.cpp b/src/gpu/effects/GrTextureDomain.cpp
index ee7985c..5101762 100644
--- a/src/gpu/effects/GrTextureDomain.cpp
+++ b/src/gpu/effects/GrTextureDomain.cpp
@@ -206,21 +206,20 @@
}
}
-sk_sp<GrFragmentProcessor> GrTextureDomainEffect::Make(sk_sp<GrTextureProxy> proxy,
- sk_sp<GrColorSpaceXform> colorSpaceXform,
- const SkMatrix& matrix,
- const SkRect& domain,
- GrTextureDomain::Mode mode,
- GrSamplerParams::FilterMode filterMode) {
+std::unique_ptr<GrFragmentProcessor> GrTextureDomainEffect::Make(
+ sk_sp<GrTextureProxy> proxy,
+ sk_sp<GrColorSpaceXform> colorSpaceXform,
+ const SkMatrix& matrix,
+ const SkRect& domain,
+ GrTextureDomain::Mode mode,
+ GrSamplerParams::FilterMode filterMode) {
if (GrTextureDomain::kIgnore_Mode == mode ||
(GrTextureDomain::kClamp_Mode == mode && can_ignore_rect(proxy.get(), domain))) {
return GrSimpleTextureEffect::Make(std::move(proxy),
std::move(colorSpaceXform), matrix, filterMode);
} else {
- return sk_sp<GrFragmentProcessor>(
- new GrTextureDomainEffect(std::move(proxy),
- std::move(colorSpaceXform),
- matrix, domain, mode, filterMode));
+ return std::unique_ptr<GrFragmentProcessor>(new GrTextureDomainEffect(
+ std::move(proxy), std::move(colorSpaceXform), matrix, domain, mode, filterMode));
}
}
@@ -312,7 +311,7 @@
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrTextureDomainEffect);
#if GR_TEST_UTILS
-sk_sp<GrFragmentProcessor> GrTextureDomainEffect::TestCreate(GrProcessorTestData* d) {
+std::unique_ptr<GrFragmentProcessor> GrTextureDomainEffect::TestCreate(GrProcessorTestData* d) {
int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx
: GrProcessorUnitTest::kAlphaTextureIdx;
sk_sp<GrTextureProxy> proxy = d->textureProxy(texIdx);
@@ -337,11 +336,9 @@
#endif
///////////////////////////////////////////////////////////////////////////////
-sk_sp<GrFragmentProcessor> GrDeviceSpaceTextureDecalFragmentProcessor::Make(
- sk_sp<GrTextureProxy> proxy,
- const SkIRect& subset,
- const SkIPoint& deviceSpaceOffset) {
- return sk_sp<GrFragmentProcessor>(new GrDeviceSpaceTextureDecalFragmentProcessor(
+std::unique_ptr<GrFragmentProcessor> GrDeviceSpaceTextureDecalFragmentProcessor::Make(
+ sk_sp<GrTextureProxy> proxy, const SkIRect& subset, const SkIPoint& deviceSpaceOffset) {
+ return std::unique_ptr<GrFragmentProcessor>(new GrDeviceSpaceTextureDecalFragmentProcessor(
std::move(proxy), subset, deviceSpaceOffset));
}
@@ -369,8 +366,9 @@
this->addTextureSampler(&fTextureSampler);
}
-sk_sp<GrFragmentProcessor> GrDeviceSpaceTextureDecalFragmentProcessor::clone() const {
- return sk_sp<GrFragmentProcessor>(new GrDeviceSpaceTextureDecalFragmentProcessor(*this));
+std::unique_ptr<GrFragmentProcessor> GrDeviceSpaceTextureDecalFragmentProcessor::clone() const {
+ return std::unique_ptr<GrFragmentProcessor>(
+ new GrDeviceSpaceTextureDecalFragmentProcessor(*this));
}
GrGLSLFragmentProcessor* GrDeviceSpaceTextureDecalFragmentProcessor::onCreateGLSLInstance() const {
@@ -441,7 +439,7 @@
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrDeviceSpaceTextureDecalFragmentProcessor);
#if GR_TEST_UTILS
-sk_sp<GrFragmentProcessor> GrDeviceSpaceTextureDecalFragmentProcessor::TestCreate(
+std::unique_ptr<GrFragmentProcessor> GrDeviceSpaceTextureDecalFragmentProcessor::TestCreate(
GrProcessorTestData* d) {
int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx
: GrProcessorUnitTest::kAlphaTextureIdx;
diff --git a/src/gpu/effects/GrTextureDomain.h b/src/gpu/effects/GrTextureDomain.h
index 10c2e56..0db7d2c 100644
--- a/src/gpu/effects/GrTextureDomain.h
+++ b/src/gpu/effects/GrTextureDomain.h
@@ -153,17 +153,17 @@
*/
class GrTextureDomainEffect : public GrFragmentProcessor {
public:
- static sk_sp<GrFragmentProcessor> Make(sk_sp<GrTextureProxy>,
- sk_sp<GrColorSpaceXform>,
- const SkMatrix&,
- const SkRect& domain,
- GrTextureDomain::Mode,
- GrSamplerParams::FilterMode filterMode);
+ static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy>,
+ sk_sp<GrColorSpaceXform>,
+ const SkMatrix&,
+ const SkRect& domain,
+ GrTextureDomain::Mode,
+ GrSamplerParams::FilterMode filterMode);
const char* name() const override { return "TextureDomain"; }
- sk_sp<GrFragmentProcessor> clone() const override {
- return sk_sp<GrFragmentProcessor>(new GrTextureDomainEffect(*this));
+ std::unique_ptr<GrFragmentProcessor> clone() const override {
+ return std::unique_ptr<GrFragmentProcessor>(new GrTextureDomainEffect(*this));
}
SkString dumpInfo() const override {
@@ -207,9 +207,9 @@
class GrDeviceSpaceTextureDecalFragmentProcessor : public GrFragmentProcessor {
public:
- static sk_sp<GrFragmentProcessor> Make(sk_sp<GrTextureProxy>,
- const SkIRect& subset,
- const SkIPoint& deviceSpaceOffset);
+ static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy>,
+ const SkIRect& subset,
+ const SkIPoint& deviceSpaceOffset);
const char* name() const override { return "GrDeviceSpaceTextureDecalFragmentProcessor"; }
@@ -223,7 +223,7 @@
return str;
}
- sk_sp<GrFragmentProcessor> clone() const override;
+ std::unique_ptr<GrFragmentProcessor> clone() const override;
private:
TextureSampler fTextureSampler;
diff --git a/src/gpu/effects/GrXfermodeFragmentProcessor.cpp b/src/gpu/effects/GrXfermodeFragmentProcessor.cpp
index 490cb39..f2c026f 100644
--- a/src/gpu/effects/GrXfermodeFragmentProcessor.cpp
+++ b/src/gpu/effects/GrXfermodeFragmentProcessor.cpp
@@ -29,11 +29,11 @@
class ComposeTwoFragmentProcessor : public GrFragmentProcessor {
public:
- static sk_sp<GrFragmentProcessor> Make(sk_sp<GrFragmentProcessor> src,
- sk_sp<GrFragmentProcessor> dst,
- SkBlendMode mode) {
- return sk_sp<GrFragmentProcessor>(new ComposeTwoFragmentProcessor(std::move(src),
- std::move(dst), mode));
+ static std::unique_ptr<GrFragmentProcessor> Make(std::unique_ptr<GrFragmentProcessor> src,
+ std::unique_ptr<GrFragmentProcessor> dst,
+ SkBlendMode mode) {
+ return std::unique_ptr<GrFragmentProcessor>(
+ new ComposeTwoFragmentProcessor(std::move(src), std::move(dst), mode));
}
const char* name() const override { return "ComposeTwo"; }
@@ -50,16 +50,15 @@
return str;
}
- sk_sp<GrFragmentProcessor> clone() const override;
+ std::unique_ptr<GrFragmentProcessor> clone() const override;
SkBlendMode getMode() const { return fMode; }
private:
- ComposeTwoFragmentProcessor(sk_sp<GrFragmentProcessor> src,
- sk_sp<GrFragmentProcessor> dst,
+ ComposeTwoFragmentProcessor(std::unique_ptr<GrFragmentProcessor> src,
+ std::unique_ptr<GrFragmentProcessor> dst,
SkBlendMode mode)
- : INHERITED(OptFlags(src.get(), dst.get(), mode))
- , fMode(mode) {
+ : INHERITED(OptFlags(src.get(), dst.get(), mode)), fMode(mode) {
this->initClassID<ComposeTwoFragmentProcessor>();
SkDEBUGCODE(int shaderAChildIndex = )this->registerChildProcessor(std::move(src));
SkDEBUGCODE(int shaderBChildIndex = )this->registerChildProcessor(std::move(dst));
@@ -182,24 +181,25 @@
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(ComposeTwoFragmentProcessor);
#if GR_TEST_UTILS
-sk_sp<GrFragmentProcessor> ComposeTwoFragmentProcessor::TestCreate(GrProcessorTestData* d) {
+std::unique_ptr<GrFragmentProcessor> ComposeTwoFragmentProcessor::TestCreate(
+ GrProcessorTestData* d) {
// Create two random frag procs.
- sk_sp<GrFragmentProcessor> fpA(GrProcessorUnitTest::MakeChildFP(d));
- sk_sp<GrFragmentProcessor> fpB(GrProcessorUnitTest::MakeChildFP(d));
+ std::unique_ptr<GrFragmentProcessor> fpA(GrProcessorUnitTest::MakeChildFP(d));
+ std::unique_ptr<GrFragmentProcessor> fpB(GrProcessorUnitTest::MakeChildFP(d));
SkBlendMode mode;
do {
mode = static_cast<SkBlendMode>(d->fRandom->nextRangeU(0, (int)SkBlendMode::kLastMode));
} while (SkBlendMode::kClear == mode || SkBlendMode::kSrc == mode || SkBlendMode::kDst == mode);
- return sk_sp<GrFragmentProcessor>(
- new ComposeTwoFragmentProcessor(std::move(fpA), std::move(fpB), mode));
+ return std::unique_ptr<GrFragmentProcessor>(
+ new ComposeTwoFragmentProcessor(std::move(fpA), std::move(fpB), mode));
}
#endif
-sk_sp<GrFragmentProcessor> ComposeTwoFragmentProcessor::clone() const {
+std::unique_ptr<GrFragmentProcessor> ComposeTwoFragmentProcessor::clone() const {
auto src = this->childProcessor(0).clone();
auto dst = this->childProcessor(1).clone();
- return sk_sp<GrFragmentProcessor>(
+ return std::unique_ptr<GrFragmentProcessor>(
new ComposeTwoFragmentProcessor(std::move(src), std::move(dst), fMode));
}
@@ -242,8 +242,10 @@
}
}
-sk_sp<GrFragmentProcessor> GrXfermodeFragmentProcessor::MakeFromTwoProcessors(
- sk_sp<GrFragmentProcessor> src, sk_sp<GrFragmentProcessor> dst, SkBlendMode mode) {
+std::unique_ptr<GrFragmentProcessor> GrXfermodeFragmentProcessor::MakeFromTwoProcessors(
+ std::unique_ptr<GrFragmentProcessor> src,
+ std::unique_ptr<GrFragmentProcessor> dst,
+ SkBlendMode mode) {
switch (mode) {
case SkBlendMode::kClear:
return GrConstColorProcessor::Make(GrColor4f::TransparentBlack(),
@@ -266,13 +268,13 @@
kSrc_Child,
};
- static sk_sp<GrFragmentProcessor> Make(sk_sp<GrFragmentProcessor> fp, SkBlendMode mode,
- Child child) {
+ static std::unique_ptr<GrFragmentProcessor> Make(std::unique_ptr<GrFragmentProcessor> fp,
+ SkBlendMode mode, Child child) {
if (!fp) {
return nullptr;
}
- return sk_sp<GrFragmentProcessor>(new ComposeOneFragmentProcessor(std::move(fp),
- mode, child));
+ return std::unique_ptr<GrFragmentProcessor>(
+ new ComposeOneFragmentProcessor(std::move(fp), mode, child));
}
const char* name() const override { return "ComposeOne"; }
@@ -290,7 +292,7 @@
return str;
}
- sk_sp<GrFragmentProcessor> clone() const override;
+ std::unique_ptr<GrFragmentProcessor> clone() const override;
SkBlendMode mode() const { return fMode; }
@@ -417,10 +419,9 @@
}
private:
- ComposeOneFragmentProcessor(sk_sp<GrFragmentProcessor> fp, SkBlendMode mode, Child child)
- : INHERITED(OptFlags(fp.get(), mode, child))
- , fMode(mode)
- , fChild(child) {
+ ComposeOneFragmentProcessor(std::unique_ptr<GrFragmentProcessor> fp, SkBlendMode mode,
+ Child child)
+ : INHERITED(OptFlags(fp.get(), mode, child)), fMode(mode), fChild(child) {
this->initClassID<ComposeOneFragmentProcessor>();
SkDEBUGCODE(int dstIndex =) this->registerChildProcessor(std::move(fp));
SkASSERT(0 == dstIndex);
@@ -474,11 +475,12 @@
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(ComposeOneFragmentProcessor);
#if GR_TEST_UTILS
-sk_sp<GrFragmentProcessor> ComposeOneFragmentProcessor::TestCreate(GrProcessorTestData* d) {
+std::unique_ptr<GrFragmentProcessor> ComposeOneFragmentProcessor::TestCreate(
+ GrProcessorTestData* d) {
// Create one random frag procs.
// For now, we'll prevent either children from being a shader with children to prevent the
// possibility of an arbitrarily large tree of procs.
- sk_sp<GrFragmentProcessor> dst(GrProcessorUnitTest::MakeChildFP(d));
+ std::unique_ptr<GrFragmentProcessor> dst(GrProcessorUnitTest::MakeChildFP(d));
SkBlendMode mode;
ComposeOneFragmentProcessor::Child child;
do {
@@ -486,7 +488,8 @@
child = d->fRandom->nextBool() ? kDst_Child : kSrc_Child;
} while (SkBlendMode::kClear == mode || (SkBlendMode::kDst == mode && child == kSrc_Child) ||
(SkBlendMode::kSrc == mode && child == kDst_Child));
- return sk_sp<GrFragmentProcessor>(new ComposeOneFragmentProcessor(std::move(dst), mode, child));
+ return std::unique_ptr<GrFragmentProcessor>(
+ new ComposeOneFragmentProcessor(std::move(dst), mode, child));
}
#endif
@@ -494,8 +497,8 @@
return new GLComposeOneFragmentProcessor;
}
-sk_sp<GrFragmentProcessor> ComposeOneFragmentProcessor::clone() const {
- return sk_sp<GrFragmentProcessor>(
+std::unique_ptr<GrFragmentProcessor> ComposeOneFragmentProcessor::clone() const {
+ return std::unique_ptr<GrFragmentProcessor>(
new ComposeOneFragmentProcessor(this->childProcessor(0).clone(), fMode, fChild));
}
@@ -507,8 +510,8 @@
// ignore the original input. This could be implemented as:
// RunInSeries(ConstColor(GrColor_WHITE, kIgnoreInput), inputFP).
-sk_sp<GrFragmentProcessor> GrXfermodeFragmentProcessor::MakeFromDstProcessor(
- sk_sp<GrFragmentProcessor> dst, SkBlendMode mode) {
+std::unique_ptr<GrFragmentProcessor> GrXfermodeFragmentProcessor::MakeFromDstProcessor(
+ std::unique_ptr<GrFragmentProcessor> dst, SkBlendMode mode) {
switch (mode) {
case SkBlendMode::kClear:
return GrConstColorProcessor::Make(GrColor4f::TransparentBlack(),
@@ -521,8 +524,8 @@
}
}
-sk_sp<GrFragmentProcessor> GrXfermodeFragmentProcessor::MakeFromSrcProcessor(
- sk_sp<GrFragmentProcessor> src, SkBlendMode mode) {
+std::unique_ptr<GrFragmentProcessor> GrXfermodeFragmentProcessor::MakeFromSrcProcessor(
+ std::unique_ptr<GrFragmentProcessor> src, SkBlendMode mode) {
switch (mode) {
case SkBlendMode::kClear:
return GrConstColorProcessor::Make(GrColor4f::TransparentBlack(),
diff --git a/src/gpu/effects/GrXfermodeFragmentProcessor.h b/src/gpu/effects/GrXfermodeFragmentProcessor.h
index edc5ae7..c5d0c59 100644
--- a/src/gpu/effects/GrXfermodeFragmentProcessor.h
+++ b/src/gpu/effects/GrXfermodeFragmentProcessor.h
@@ -14,22 +14,24 @@
class GrFragmentProcessor;
namespace GrXfermodeFragmentProcessor {
- /** The color input to the returned processor is treated as the src and the passed in processor
- is the dst. */
- sk_sp<GrFragmentProcessor> MakeFromDstProcessor(sk_sp<GrFragmentProcessor> dst,
- SkBlendMode mode);
- /** The color input to the returned processor is treated as the dst and the passed in processor
- is the src. */
- sk_sp<GrFragmentProcessor> MakeFromSrcProcessor(sk_sp<GrFragmentProcessor> src,
- SkBlendMode mode);
+/** The color input to the returned processor is treated as the src and the passed in processor is
+ the dst. */
+std::unique_ptr<GrFragmentProcessor> MakeFromDstProcessor(std::unique_ptr<GrFragmentProcessor> dst,
+ SkBlendMode mode);
- /** Takes the input color, which is assumed to be unpremultiplied, passes it as an opaque color
- to both src and dst. The outputs of a src and dst are blended using mode and the original
- input's alpha is applied to the blended color to produce a premul output. */
- sk_sp<GrFragmentProcessor> MakeFromTwoProcessors(sk_sp<GrFragmentProcessor> src,
- sk_sp<GrFragmentProcessor> dst,
- SkBlendMode mode);
+/** The color input to the returned processor is treated as the dst and the passed in processor is
+ the src. */
+std::unique_ptr<GrFragmentProcessor> MakeFromSrcProcessor(std::unique_ptr<GrFragmentProcessor> src,
+ SkBlendMode mode);
+
+/** Takes the input color, which is assumed to be unpremultiplied, passes it as an opaque color
+ to both src and dst. The outputs of a src and dst are blended using mode and the original
+ input's alpha is applied to the blended color to produce a premul output. */
+std::unique_ptr<GrFragmentProcessor> MakeFromTwoProcessors(std::unique_ptr<GrFragmentProcessor> src,
+ std::unique_ptr<GrFragmentProcessor> dst,
+ SkBlendMode mode);
+
};
#endif
diff --git a/src/gpu/effects/GrYUVEffect.cpp b/src/gpu/effects/GrYUVEffect.cpp
index 5b2eb7e..80e87c2 100644
--- a/src/gpu/effects/GrYUVEffect.cpp
+++ b/src/gpu/effects/GrYUVEffect.cpp
@@ -62,10 +62,11 @@
class YUVtoRGBEffect : public GrFragmentProcessor {
public:
- static sk_sp<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> yProxy,
- sk_sp<GrTextureProxy> uProxy,
- sk_sp<GrTextureProxy> vProxy, const SkISize sizes[3],
- SkYUVColorSpace colorSpace, bool nv12) {
+ static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> yProxy,
+ sk_sp<GrTextureProxy> uProxy,
+ sk_sp<GrTextureProxy> vProxy,
+ const SkISize sizes[3],
+ SkYUVColorSpace colorSpace, bool nv12) {
SkScalar w[3], h[3];
w[0] = SkIntToScalar(sizes[0].fWidth);
h[0] = SkIntToScalar(sizes[0].fHeight);
@@ -85,15 +86,15 @@
(sizes[2].fHeight != sizes[0].fHeight)) ?
GrSamplerParams::kBilerp_FilterMode :
GrSamplerParams::kNone_FilterMode;
- return sk_sp<GrFragmentProcessor>(new YUVtoRGBEffect(
- std::move(yProxy), std::move(uProxy), std::move(vProxy),
- yuvMatrix, uvFilterMode, colorSpace, nv12));
+ return std::unique_ptr<GrFragmentProcessor>(
+ new YUVtoRGBEffect(std::move(yProxy), std::move(uProxy), std::move(vProxy),
+ yuvMatrix, uvFilterMode, colorSpace, nv12));
}
const char* name() const override { return "YUV to RGB"; }
- sk_sp<GrFragmentProcessor> clone() const override {
- return sk_sp<GrFragmentProcessor>(new YUVtoRGBEffect(*this));
+ std::unique_ptr<GrFragmentProcessor> clone() const override {
+ return std::unique_ptr<GrFragmentProcessor>(new YUVtoRGBEffect(*this));
}
SkYUVColorSpace getColorSpace() const { return fColorSpace; }
@@ -241,15 +242,16 @@
kV_OutputChannels
};
- static sk_sp<GrFragmentProcessor> Make(sk_sp<GrFragmentProcessor> rgbFP,
- SkYUVColorSpace colorSpace,
- OutputChannels output) {
- return sk_sp<GrFragmentProcessor>(new RGBToYUVEffect(std::move(rgbFP), colorSpace, output));
+ static std::unique_ptr<GrFragmentProcessor> Make(std::unique_ptr<GrFragmentProcessor> rgbFP,
+ SkYUVColorSpace colorSpace,
+ OutputChannels output) {
+ return std::unique_ptr<GrFragmentProcessor>(
+ new RGBToYUVEffect(std::move(rgbFP), colorSpace, output));
}
const char* name() const override { return "RGBToYUV"; }
- sk_sp<GrFragmentProcessor> clone() const override {
+ std::unique_ptr<GrFragmentProcessor> clone() const override {
return Make(this->childProcessor(0).clone(), fColorSpace, fOutputChannels);
}
@@ -353,7 +355,7 @@
};
private:
- RGBToYUVEffect(sk_sp<GrFragmentProcessor> rgbFP, SkYUVColorSpace colorSpace,
+ RGBToYUVEffect(std::unique_ptr<GrFragmentProcessor> rgbFP, SkYUVColorSpace colorSpace,
OutputChannels output)
// This could advertise kConstantOutputForConstantInput, but doesn't seem useful.
: INHERITED(kPreservesOpaqueInput_OptimizationFlag)
@@ -393,42 +395,40 @@
//////////////////////////////////////////////////////////////////////////////
-sk_sp<GrFragmentProcessor> GrYUVEffect::MakeYUVToRGB(sk_sp<GrTextureProxy> yProxy,
- sk_sp<GrTextureProxy> uProxy,
- sk_sp<GrTextureProxy> vProxy,
- const SkISize sizes[3],
- SkYUVColorSpace colorSpace, bool nv12) {
+std::unique_ptr<GrFragmentProcessor> GrYUVEffect::MakeYUVToRGB(
+ sk_sp<GrTextureProxy> yProxy, sk_sp<GrTextureProxy> uProxy, sk_sp<GrTextureProxy> vProxy,
+ const SkISize sizes[3], SkYUVColorSpace colorSpace, bool nv12) {
SkASSERT(yProxy && uProxy && vProxy && sizes);
return YUVtoRGBEffect::Make(std::move(yProxy), std::move(uProxy), std::move(vProxy),
sizes, colorSpace, nv12);
}
-sk_sp<GrFragmentProcessor>
-GrYUVEffect::MakeRGBToYUV(sk_sp<GrFragmentProcessor> rgbFP, SkYUVColorSpace colorSpace) {
+std::unique_ptr<GrFragmentProcessor> GrYUVEffect::MakeRGBToYUV(
+ std::unique_ptr<GrFragmentProcessor> rgbFP, SkYUVColorSpace colorSpace) {
SkASSERT(rgbFP);
return RGBToYUVEffect::Make(std::move(rgbFP), colorSpace, RGBToYUVEffect::kYUV_OutputChannels);
}
-sk_sp<GrFragmentProcessor>
-GrYUVEffect::MakeRGBToY(sk_sp<GrFragmentProcessor> rgbFP, SkYUVColorSpace colorSpace) {
+std::unique_ptr<GrFragmentProcessor> GrYUVEffect::MakeRGBToY(
+ std::unique_ptr<GrFragmentProcessor> rgbFP, SkYUVColorSpace colorSpace) {
SkASSERT(rgbFP);
return RGBToYUVEffect::Make(std::move(rgbFP), colorSpace, RGBToYUVEffect::kY_OutputChannels);
}
-sk_sp<GrFragmentProcessor>
-GrYUVEffect::MakeRGBToUV(sk_sp<GrFragmentProcessor> rgbFP, SkYUVColorSpace colorSpace) {
+std::unique_ptr<GrFragmentProcessor> GrYUVEffect::MakeRGBToUV(
+ std::unique_ptr<GrFragmentProcessor> rgbFP, SkYUVColorSpace colorSpace) {
SkASSERT(rgbFP);
return RGBToYUVEffect::Make(std::move(rgbFP), colorSpace, RGBToYUVEffect::kUV_OutputChannels);
}
-sk_sp<GrFragmentProcessor>
-GrYUVEffect::MakeRGBToU(sk_sp<GrFragmentProcessor> rgbFP, SkYUVColorSpace colorSpace) {
+std::unique_ptr<GrFragmentProcessor> GrYUVEffect::MakeRGBToU(
+ std::unique_ptr<GrFragmentProcessor> rgbFP, SkYUVColorSpace colorSpace) {
SkASSERT(rgbFP);
return RGBToYUVEffect::Make(std::move(rgbFP), colorSpace, RGBToYUVEffect::kU_OutputChannels);
}
-sk_sp<GrFragmentProcessor>
-GrYUVEffect::MakeRGBToV(sk_sp<GrFragmentProcessor> rgbFP, SkYUVColorSpace colorSpace) {
+std::unique_ptr<GrFragmentProcessor> GrYUVEffect::MakeRGBToV(
+ std::unique_ptr<GrFragmentProcessor> rgbFP, SkYUVColorSpace colorSpace) {
SkASSERT(rgbFP);
return RGBToYUVEffect::Make(std::move(rgbFP), colorSpace, RGBToYUVEffect::kV_OutputChannels);
}
diff --git a/src/gpu/effects/GrYUVEffect.h b/src/gpu/effects/GrYUVEffect.h
index ae62a16..2ea41bf 100644
--- a/src/gpu/effects/GrYUVEffect.h
+++ b/src/gpu/effects/GrYUVEffect.h
@@ -18,32 +18,38 @@
* Creates an effect that performs color conversion from YUV to RGB. The input textures are
* assumed to be kA8_GrPixelConfig.
*/
- sk_sp<GrFragmentProcessor> MakeYUVToRGB(sk_sp<GrTextureProxy> yProxy,
- sk_sp<GrTextureProxy> uProxy,
- sk_sp<GrTextureProxy> vProxy, const SkISize sizes[3],
- SkYUVColorSpace colorSpace, bool nv12);
+std::unique_ptr<GrFragmentProcessor> MakeYUVToRGB(sk_sp<GrTextureProxy> yProxy,
+ sk_sp<GrTextureProxy> uProxy,
+ sk_sp<GrTextureProxy> vProxy,
+ const SkISize sizes[3],
+ SkYUVColorSpace colorSpace, bool nv12);
- /**
- * Creates a processor that performs color conversion from the passed in processor's RGB
- * channels to Y, U ,and V channels. The output color is (y, u, v, a) where a is the passed in
- * processor's alpha output.
- */
- sk_sp<GrFragmentProcessor> MakeRGBToYUV(sk_sp<GrFragmentProcessor>, SkYUVColorSpace);
+/**
+ * Creates a processor that performs color conversion from the passed in processor's RGB
+ * channels to Y, U ,and V channels. The output color is (y, u, v, a) where a is the passed in
+ * processor's alpha output.
+ */
+std::unique_ptr<GrFragmentProcessor> MakeRGBToYUV(std::unique_ptr<GrFragmentProcessor>,
+ SkYUVColorSpace);
- /**
- * Creates a processor that performs color conversion from the passed in processor's RGB
- * channels to U and V channels. The output color is (u, v, 0, a) where a is the passed in
- * processor's alpha output.
- */
- sk_sp<GrFragmentProcessor> MakeRGBToUV(sk_sp<GrFragmentProcessor>, SkYUVColorSpace);
- /**
- * Creates a processor that performs color conversion from the passed in fragment processors's
- * RGB channels to Y, U, or V (replicated across all four output color channels). The alpha
- * output of the passed in fragment processor is ignored.
- */
- sk_sp<GrFragmentProcessor> MakeRGBToY(sk_sp<GrFragmentProcessor>, SkYUVColorSpace);
- sk_sp<GrFragmentProcessor> MakeRGBToU(sk_sp<GrFragmentProcessor>, SkYUVColorSpace);
- sk_sp<GrFragmentProcessor> MakeRGBToV(sk_sp<GrFragmentProcessor>, SkYUVColorSpace);
+/**
+ * Creates a processor that performs color conversion from the passed in processor's RGB
+ * channels to U and V channels. The output color is (u, v, 0, a) where a is the passed in
+ * processor's alpha output.
+ */
+std::unique_ptr<GrFragmentProcessor> MakeRGBToUV(std::unique_ptr<GrFragmentProcessor>,
+ SkYUVColorSpace);
+/**
+ * Creates a processor that performs color conversion from the passed in fragment processors's
+ * RGB channels to Y, U, or V (replicated across all four output color channels). The alpha
+ * output of the passed in fragment processor is ignored.
+ */
+std::unique_ptr<GrFragmentProcessor> MakeRGBToY(std::unique_ptr<GrFragmentProcessor>,
+ SkYUVColorSpace);
+std::unique_ptr<GrFragmentProcessor> MakeRGBToU(std::unique_ptr<GrFragmentProcessor>,
+ SkYUVColorSpace);
+std::unique_ptr<GrFragmentProcessor> MakeRGBToV(std::unique_ptr<GrFragmentProcessor>,
+ SkYUVColorSpace);
};
#endif