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/shaders/SkColorFilterShader.cpp b/src/shaders/SkColorFilterShader.cpp
index a2d5433..bacfc37 100644
--- a/src/shaders/SkColorFilterShader.cpp
+++ b/src/shaders/SkColorFilterShader.cpp
@@ -56,20 +56,19 @@
#if SK_SUPPORT_GPU
/////////////////////////////////////////////////////////////////////
-sk_sp<GrFragmentProcessor> SkColorFilterShader::asFragmentProcessor(const AsFPArgs& args) const {
-
- sk_sp<GrFragmentProcessor> fp1(as_SB(fShader)->asFragmentProcessor(args));
+std::unique_ptr<GrFragmentProcessor> SkColorFilterShader::asFragmentProcessor(
+ const AsFPArgs& args) const {
+ auto fp1 = as_SB(fShader)->asFragmentProcessor(args);
if (!fp1) {
return nullptr;
}
- sk_sp<GrFragmentProcessor> fp2(fFilter->asFragmentProcessor(args.fContext,
- args.fDstColorSpace));
+ auto fp2 = fFilter->asFragmentProcessor(args.fContext, args.fDstColorSpace);
if (!fp2) {
return fp1;
}
- sk_sp<GrFragmentProcessor> fpSeries[] = { std::move(fp1), std::move(fp2) };
+ std::unique_ptr<GrFragmentProcessor> fpSeries[] = { std::move(fp1), std::move(fp2) };
return GrFragmentProcessor::RunInSeries(fpSeries, 2);
}
#endif
diff --git a/src/shaders/SkColorFilterShader.h b/src/shaders/SkColorFilterShader.h
index 3a1878f..9cd199e 100644
--- a/src/shaders/SkColorFilterShader.h
+++ b/src/shaders/SkColorFilterShader.h
@@ -18,7 +18,7 @@
SkColorFilterShader(sk_sp<SkShader> shader, sk_sp<SkColorFilter> filter);
#if SK_SUPPORT_GPU
- sk_sp<GrFragmentProcessor> asFragmentProcessor(const AsFPArgs&) const override;
+ std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(const AsFPArgs&) const override;
#endif
SK_TO_STRING_OVERRIDE()
diff --git a/src/shaders/SkColorShader.cpp b/src/shaders/SkColorShader.cpp
index e718cb0..33ebc53 100644
--- a/src/shaders/SkColorShader.cpp
+++ b/src/shaders/SkColorShader.cpp
@@ -89,7 +89,8 @@
#include "SkGr.h"
#include "effects/GrConstColorProcessor.h"
-sk_sp<GrFragmentProcessor> SkColorShader::asFragmentProcessor(const AsFPArgs& args) const {
+std::unique_ptr<GrFragmentProcessor> SkColorShader::asFragmentProcessor(
+ const AsFPArgs& args) const {
GrColor4f color = SkColorToPremulGrColor4f(fColor, args.fDstColorSpace);
return GrConstColorProcessor::Make(color, GrConstColorProcessor::kModulateA_InputMode);
}
@@ -206,7 +207,8 @@
#include "SkGr.h"
#include "effects/GrConstColorProcessor.h"
#include "GrColorSpaceXform.h"
-sk_sp<GrFragmentProcessor> SkColor4Shader::asFragmentProcessor(const AsFPArgs& args) const {
+std::unique_ptr<GrFragmentProcessor> SkColor4Shader::asFragmentProcessor(
+ const AsFPArgs& args) const {
sk_sp<GrColorSpaceXform> colorSpaceXform = GrColorSpaceXform::Make(fColorSpace.get(),
args.fDstColorSpace);
GrColor4f color = GrColor4f::FromSkColor4f(fColor4);
diff --git a/src/shaders/SkColorShader.h b/src/shaders/SkColorShader.h
index f1bd478..7d035f5 100644
--- a/src/shaders/SkColorShader.h
+++ b/src/shaders/SkColorShader.h
@@ -47,7 +47,7 @@
GradientType asAGradient(GradientInfo* info) const override;
#if SK_SUPPORT_GPU
- sk_sp<GrFragmentProcessor> asFragmentProcessor(const AsFPArgs&) const override;
+ std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(const AsFPArgs&) const override;
#endif
SK_TO_STRING_OVERRIDE()
@@ -104,7 +104,7 @@
GradientType asAGradient(GradientInfo* info) const override;
#if SK_SUPPORT_GPU
- sk_sp<GrFragmentProcessor> asFragmentProcessor(const AsFPArgs&) const override;
+ std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(const AsFPArgs&) const override;
#endif
SK_TO_STRING_OVERRIDE()
diff --git a/src/shaders/SkComposeShader.cpp b/src/shaders/SkComposeShader.cpp
index 7b37140..9799a1c 100644
--- a/src/shaders/SkComposeShader.cpp
+++ b/src/shaders/SkComposeShader.cpp
@@ -125,7 +125,8 @@
/////////////////////////////////////////////////////////////////////
-sk_sp<GrFragmentProcessor> SkComposeShader::asFragmentProcessor(const AsFPArgs& args) const {
+std::unique_ptr<GrFragmentProcessor> SkComposeShader::asFragmentProcessor(
+ const AsFPArgs& args) const {
if (this->isJustMode()) {
SkASSERT(fMode != SkBlendMode::kSrc && fMode != SkBlendMode::kDst); // caught in factory
if (fMode == SkBlendMode::kClear) {
@@ -134,11 +135,11 @@
}
}
- sk_sp<GrFragmentProcessor> fpA(as_SB(fDst)->asFragmentProcessor(args));
+ std::unique_ptr<GrFragmentProcessor> fpA(as_SB(fDst)->asFragmentProcessor(args));
if (!fpA) {
return nullptr;
}
- sk_sp<GrFragmentProcessor> fpB(as_SB(fSrc)->asFragmentProcessor(args));
+ std::unique_ptr<GrFragmentProcessor> fpB(as_SB(fSrc)->asFragmentProcessor(args));
if (!fpB) {
return nullptr;
}
diff --git a/src/shaders/SkComposeShader.h b/src/shaders/SkComposeShader.h
index 1389742..34abf62 100644
--- a/src/shaders/SkComposeShader.h
+++ b/src/shaders/SkComposeShader.h
@@ -23,7 +23,7 @@
}
#if SK_SUPPORT_GPU
- sk_sp<GrFragmentProcessor> asFragmentProcessor(const AsFPArgs&) const override;
+ std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(const AsFPArgs&) const override;
#endif
#ifdef SK_DEBUGx
diff --git a/src/shaders/SkImageShader.cpp b/src/shaders/SkImageShader.cpp
index 609ad4b..edd1f41 100644
--- a/src/shaders/SkImageShader.cpp
+++ b/src/shaders/SkImageShader.cpp
@@ -167,8 +167,8 @@
#include "effects/GrBicubicEffect.h"
#include "effects/GrSimpleTextureEffect.h"
-sk_sp<GrFragmentProcessor> SkImageShader::asFragmentProcessor(const AsFPArgs& args) const {
-
+std::unique_ptr<GrFragmentProcessor> SkImageShader::asFragmentProcessor(
+ const AsFPArgs& args) const {
SkMatrix lmInverse;
if (!this->getLocalMatrix().invert(&lmInverse)) {
return nullptr;
@@ -207,7 +207,7 @@
sk_sp<GrColorSpaceXform> colorSpaceXform = GrColorSpaceXform::Make(texColorSpace.get(),
args.fDstColorSpace);
- sk_sp<GrFragmentProcessor> inner;
+ std::unique_ptr<GrFragmentProcessor> inner;
if (doBicubic) {
inner = GrBicubicEffect::Make(std::move(proxy),
std::move(colorSpaceXform), lmInverse, tm);
@@ -219,7 +219,7 @@
if (isAlphaOnly) {
return inner;
}
- return sk_sp<GrFragmentProcessor>(GrFragmentProcessor::MulOutputByInputAlpha(std::move(inner)));
+ return GrFragmentProcessor::MulOutputByInputAlpha(std::move(inner));
}
#endif
diff --git a/src/shaders/SkImageShader.h b/src/shaders/SkImageShader.h
index b499b92..8e592e5 100644
--- a/src/shaders/SkImageShader.h
+++ b/src/shaders/SkImageShader.h
@@ -24,7 +24,7 @@
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkImageShader)
#if SK_SUPPORT_GPU
- sk_sp<GrFragmentProcessor> asFragmentProcessor(const AsFPArgs&) const override;
+ std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(const AsFPArgs&) const override;
#endif
SkImageShader(sk_sp<SkImage>, TileMode tx, TileMode ty, const SkMatrix* localMatrix);
diff --git a/src/shaders/SkLocalMatrixShader.cpp b/src/shaders/SkLocalMatrixShader.cpp
index e21e4a8..254092d 100644
--- a/src/shaders/SkLocalMatrixShader.cpp
+++ b/src/shaders/SkLocalMatrixShader.cpp
@@ -12,7 +12,8 @@
#endif
#if SK_SUPPORT_GPU
-sk_sp<GrFragmentProcessor> SkLocalMatrixShader::asFragmentProcessor(const AsFPArgs& args) const {
+std::unique_ptr<GrFragmentProcessor> SkLocalMatrixShader::asFragmentProcessor(
+ const AsFPArgs& args) const {
SkMatrix tmp = this->getLocalMatrix();
if (args.fLocalMatrix) {
tmp.preConcat(*args.fLocalMatrix);
diff --git a/src/shaders/SkLocalMatrixShader.h b/src/shaders/SkLocalMatrixShader.h
index 3ae44cf..407c30d 100644
--- a/src/shaders/SkLocalMatrixShader.h
+++ b/src/shaders/SkLocalMatrixShader.h
@@ -28,7 +28,7 @@
}
#if SK_SUPPORT_GPU
- sk_sp<GrFragmentProcessor> asFragmentProcessor(const AsFPArgs&) const override;
+ std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(const AsFPArgs&) const override;
#endif
sk_sp<SkShader> makeAsALocalMatrixShader(SkMatrix* localMatrix) const override {
diff --git a/src/shaders/SkPerlinNoiseShader.cpp b/src/shaders/SkPerlinNoiseShader.cpp
index 0ce007a..cc9a569 100644
--- a/src/shaders/SkPerlinNoiseShader.cpp
+++ b/src/shaders/SkPerlinNoiseShader.cpp
@@ -350,7 +350,7 @@
};
#if SK_SUPPORT_GPU
- sk_sp<GrFragmentProcessor> asFragmentProcessor(const AsFPArgs&) const override;
+ std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(const AsFPArgs&) const override;
#endif
SK_TO_STRING_OVERRIDE()
@@ -693,22 +693,20 @@
class GrPerlinNoise2Effect : public GrFragmentProcessor {
public:
- static sk_sp<GrFragmentProcessor> Make(SkPerlinNoiseShaderImpl::Type type,
- int numOctaves, bool stitchTiles,
- std::unique_ptr<SkPerlinNoiseShaderImpl::PaintingData> paintingData,
- sk_sp<GrTextureProxy> permutationsProxy,
- sk_sp<GrTextureProxy> noiseProxy,
- const SkMatrix& matrix) {
- return sk_sp<GrFragmentProcessor>(
- new GrPerlinNoise2Effect(type, numOctaves, stitchTiles,
- std::move(paintingData),
- std::move(permutationsProxy), std::move(noiseProxy), matrix));
+ static std::unique_ptr<GrFragmentProcessor> Make(
+ SkPerlinNoiseShaderImpl::Type type, int numOctaves, bool stitchTiles,
+ std::unique_ptr<SkPerlinNoiseShaderImpl::PaintingData> paintingData,
+ sk_sp<GrTextureProxy> permutationsProxy, sk_sp<GrTextureProxy> noiseProxy,
+ const SkMatrix& matrix) {
+ return std::unique_ptr<GrFragmentProcessor>(new GrPerlinNoise2Effect(
+ type, numOctaves, stitchTiles, std::move(paintingData),
+ std::move(permutationsProxy), std::move(noiseProxy), matrix));
}
const char* name() const override { return "PerlinNoise"; }
- sk_sp<GrFragmentProcessor> clone() const override {
- return sk_sp<GrFragmentProcessor>(new GrPerlinNoise2Effect(*this));
+ std::unique_ptr<GrFragmentProcessor> clone() const override {
+ return std::unique_ptr<GrFragmentProcessor>(new GrPerlinNoise2Effect(*this));
}
const SkPerlinNoiseShaderImpl::StitchData& stitchData() const { return fPaintingData->fStitchDataInit; }
@@ -789,7 +787,7 @@
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrPerlinNoise2Effect);
#if GR_TEST_UTILS
-sk_sp<GrFragmentProcessor> GrPerlinNoise2Effect::TestCreate(GrProcessorTestData* d) {
+std::unique_ptr<GrFragmentProcessor> GrPerlinNoise2Effect::TestCreate(GrProcessorTestData* d) {
int numOctaves = d->fRandom->nextRangeU(2, 10);
bool stitchTiles = d->fRandom->nextBool();
SkScalar seed = SkIntToScalar(d->fRandom->nextU());
@@ -1128,21 +1126,20 @@
class GrImprovedPerlinNoiseEffect : public GrFragmentProcessor {
public:
- static sk_sp<GrFragmentProcessor> Make(int octaves, SkScalar z,
- std::unique_ptr<SkPerlinNoiseShaderImpl::PaintingData> paintingData,
- sk_sp<GrTextureProxy> permutationsProxy,
- sk_sp<GrTextureProxy> gradientProxy,
- const SkMatrix& matrix) {
- return sk_sp<GrFragmentProcessor>(
- new GrImprovedPerlinNoiseEffect(octaves, z, std::move(paintingData),
- std::move(permutationsProxy),
- std::move(gradientProxy), matrix));
+ static std::unique_ptr<GrFragmentProcessor> Make(
+ int octaves, SkScalar z,
+ std::unique_ptr<SkPerlinNoiseShaderImpl::PaintingData> paintingData,
+ sk_sp<GrTextureProxy> permutationsProxy, sk_sp<GrTextureProxy> gradientProxy,
+ const SkMatrix& matrix) {
+ return std::unique_ptr<GrFragmentProcessor>(new GrImprovedPerlinNoiseEffect(
+ octaves, z, std::move(paintingData), std::move(permutationsProxy),
+ std::move(gradientProxy), matrix));
}
const char* name() const override { return "ImprovedPerlinNoise"; }
- sk_sp<GrFragmentProcessor> clone() const override {
- return sk_sp<GrFragmentProcessor>(new GrImprovedPerlinNoiseEffect(*this));
+ std::unique_ptr<GrFragmentProcessor> clone() const override {
+ return std::unique_ptr<GrFragmentProcessor>(new GrImprovedPerlinNoiseEffect(*this));
}
const SkVector& baseFrequency() const { return fPaintingData->fBaseFrequency; }
@@ -1213,7 +1210,8 @@
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrImprovedPerlinNoiseEffect);
#if GR_TEST_UTILS
-sk_sp<GrFragmentProcessor> GrImprovedPerlinNoiseEffect::TestCreate(GrProcessorTestData* d) {
+std::unique_ptr<GrFragmentProcessor> GrImprovedPerlinNoiseEffect::TestCreate(
+ GrProcessorTestData* d) {
SkScalar baseFrequencyX = d->fRandom->nextRangeScalar(0.01f,
0.99f);
SkScalar baseFrequencyY = d->fRandom->nextRangeScalar(0.01f,
@@ -1387,7 +1385,8 @@
}
/////////////////////////////////////////////////////////////////////
-sk_sp<GrFragmentProcessor> SkPerlinNoiseShaderImpl::asFragmentProcessor(const AsFPArgs& args) const {
+std::unique_ptr<GrFragmentProcessor> SkPerlinNoiseShaderImpl::asFragmentProcessor(
+ const AsFPArgs& args) const {
SkASSERT(args.fContext);
SkMatrix localMatrix = this->getLocalMatrix();
@@ -1434,9 +1433,9 @@
// TODO: Either treat the output of this shader as sRGB or allow client to specify a
// color space of the noise. Either way, this case (and the GLSL) need to convert to
// the destination.
- sk_sp<GrFragmentProcessor> inner(
- GrConstColorProcessor::Make(GrColor4f::FromGrColor(0x80404040),
- GrConstColorProcessor::kModulateRGBA_InputMode));
+ auto inner =
+ GrConstColorProcessor::Make(GrColor4f::FromGrColor(0x80404040),
+ GrConstColorProcessor::kModulateRGBA_InputMode);
return GrFragmentProcessor::MulOutputByInputAlpha(std::move(inner));
}
// Emit zero.
@@ -1451,14 +1450,13 @@
paintingData->getNoiseBitmap());
if (permutationsProxy && noiseProxy) {
- sk_sp<GrFragmentProcessor> inner(
- GrPerlinNoise2Effect::Make(fType,
- fNumOctaves,
- fStitchTiles,
- std::move(paintingData),
- std::move(permutationsProxy),
- std::move(noiseProxy),
- m));
+ auto inner = GrPerlinNoise2Effect::Make(fType,
+ fNumOctaves,
+ fStitchTiles,
+ std::move(paintingData),
+ std::move(permutationsProxy),
+ std::move(noiseProxy),
+ m);
return GrFragmentProcessor::MulOutputByInputAlpha(std::move(inner));
}
return nullptr;
diff --git a/src/shaders/SkPictureShader.cpp b/src/shaders/SkPictureShader.cpp
index 4c746ee..a14c211 100644
--- a/src/shaders/SkPictureShader.cpp
+++ b/src/shaders/SkPictureShader.cpp
@@ -373,7 +373,8 @@
#endif
#if SK_SUPPORT_GPU
-sk_sp<GrFragmentProcessor> SkPictureShader::asFragmentProcessor(const AsFPArgs& args) const {
+std::unique_ptr<GrFragmentProcessor> SkPictureShader::asFragmentProcessor(
+ const AsFPArgs& args) const {
int maxTextureSize = 0;
if (args.fContext) {
maxTextureSize = args.fContext->caps()->maxTextureSize();
diff --git a/src/shaders/SkPictureShader.h b/src/shaders/SkPictureShader.h
index 3d58d6d..ee1ffb5 100644
--- a/src/shaders/SkPictureShader.h
+++ b/src/shaders/SkPictureShader.h
@@ -32,7 +32,7 @@
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPictureShader)
#if SK_SUPPORT_GPU
- sk_sp<GrFragmentProcessor> asFragmentProcessor(const AsFPArgs&) const override;
+ std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(const AsFPArgs&) const override;
#endif
protected:
diff --git a/src/shaders/SkShader.cpp b/src/shaders/SkShader.cpp
index 5540b2d..d288054 100644
--- a/src/shaders/SkShader.cpp
+++ b/src/shaders/SkShader.cpp
@@ -163,7 +163,7 @@
}
#if SK_SUPPORT_GPU
-sk_sp<GrFragmentProcessor> SkShaderBase::asFragmentProcessor(const AsFPArgs&) const {
+std::unique_ptr<GrFragmentProcessor> SkShaderBase::asFragmentProcessor(const AsFPArgs&) const {
return nullptr;
}
#endif
diff --git a/src/shaders/SkShaderBase.h b/src/shaders/SkShaderBase.h
index 99cace2..8f64efe 100644
--- a/src/shaders/SkShaderBase.h
+++ b/src/shaders/SkShaderBase.h
@@ -167,7 +167,7 @@
* The returned GrFragmentProcessor should expect an unpremultiplied input color and
* produce a premultiplied output.
*/
- virtual sk_sp<GrFragmentProcessor> asFragmentProcessor(const AsFPArgs&) const;
+ virtual std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(const AsFPArgs&) const;
#endif
/**
diff --git a/src/shaders/gradients/SkLinearGradient.cpp b/src/shaders/gradients/SkLinearGradient.cpp
index 0ed5350..551368b 100644
--- a/src/shaders/gradients/SkLinearGradient.cpp
+++ b/src/shaders/gradients/SkLinearGradient.cpp
@@ -333,15 +333,15 @@
public:
class GLSLLinearProcessor;
- static sk_sp<GrFragmentProcessor> Make(const CreateArgs& args) {
- auto processor = sk_sp<GrLinearGradient>(new GrLinearGradient(args));
+ static std::unique_ptr<GrFragmentProcessor> Make(const CreateArgs& args) {
+ auto processor = std::unique_ptr<GrLinearGradient>(new GrLinearGradient(args));
return processor->isValid() ? std::move(processor) : nullptr;
}
const char* name() const override { return "Linear Gradient"; }
- sk_sp<GrFragmentProcessor> clone() const override {
- return sk_sp<GrFragmentProcessor>(new GrLinearGradient(*this));
+ std::unique_ptr<GrFragmentProcessor> clone() const override {
+ return std::unique_ptr<GrFragmentProcessor>(new GrLinearGradient(*this));
}
private:
@@ -396,7 +396,7 @@
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrLinearGradient);
#if GR_TEST_UTILS
-sk_sp<GrFragmentProcessor> GrLinearGradient::TestCreate(GrProcessorTestData* d) {
+std::unique_ptr<GrFragmentProcessor> GrLinearGradient::TestCreate(GrProcessorTestData* d) {
SkPoint points[] = {{d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()},
{d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()}};
@@ -407,7 +407,7 @@
SkGradientShader::MakeLinear(points, params.fColors, params.fStops,
params.fColorCount, params.fTileMode);
GrTest::TestAsFPArgs asFPArgs(d);
- sk_sp<GrFragmentProcessor> fp = as_SB(shader)->asFragmentProcessor(asFPArgs.args());
+ std::unique_ptr<GrFragmentProcessor> fp = as_SB(shader)->asFragmentProcessor(asFPArgs.args());
GrAlwaysAssert(fp);
return fp;
}
@@ -432,7 +432,8 @@
/////////////////////////////////////////////////////////////////////
-sk_sp<GrFragmentProcessor> SkLinearGradient::asFragmentProcessor(const AsFPArgs& args) const {
+std::unique_ptr<GrFragmentProcessor> SkLinearGradient::asFragmentProcessor(
+ const AsFPArgs& args) const {
SkASSERT(args.fContext);
SkMatrix matrix;
@@ -450,9 +451,9 @@
sk_sp<GrColorSpaceXform> colorSpaceXform = GrColorSpaceXform::Make(fColorSpace.get(),
args.fDstColorSpace);
- sk_sp<GrFragmentProcessor> inner(GrLinearGradient::Make(
- GrGradientEffect::CreateArgs(args.fContext, this, &matrix, fTileMode,
- std::move(colorSpaceXform), SkToBool(args.fDstColorSpace))));
+ auto inner = GrLinearGradient::Make(GrGradientEffect::CreateArgs(
+ args.fContext, this, &matrix, fTileMode, std::move(colorSpaceXform),
+ SkToBool(args.fDstColorSpace)));
if (!inner) {
return nullptr;
}
diff --git a/src/shaders/gradients/SkLinearGradient.h b/src/shaders/gradients/SkLinearGradient.h
index c0ba7f4..64db9dc 100644
--- a/src/shaders/gradients/SkLinearGradient.h
+++ b/src/shaders/gradients/SkLinearGradient.h
@@ -52,7 +52,7 @@
GradientType asAGradient(GradientInfo* info) const override;
#if SK_SUPPORT_GPU
- sk_sp<GrFragmentProcessor> asFragmentProcessor(const AsFPArgs&) const override;
+ std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(const AsFPArgs&) const override;
#endif
SK_TO_STRING_OVERRIDE()
diff --git a/src/shaders/gradients/SkRadialGradient.cpp b/src/shaders/gradients/SkRadialGradient.cpp
index 02086ea..94d823c 100644
--- a/src/shaders/gradients/SkRadialGradient.cpp
+++ b/src/shaders/gradients/SkRadialGradient.cpp
@@ -68,15 +68,15 @@
public:
class GLSLRadialProcessor;
- static sk_sp<GrFragmentProcessor> Make(const CreateArgs& args) {
- auto processor = sk_sp<GrRadialGradient>(new GrRadialGradient(args));
+ static std::unique_ptr<GrFragmentProcessor> Make(const CreateArgs& args) {
+ auto processor = std::unique_ptr<GrRadialGradient>(new GrRadialGradient(args));
return processor->isValid() ? std::move(processor) : nullptr;
}
const char* name() const override { return "Radial Gradient"; }
- sk_sp<GrFragmentProcessor> clone() const override {
- return sk_sp<GrFragmentProcessor>(new GrRadialGradient(*this));
+ std::unique_ptr<GrFragmentProcessor> clone() const override {
+ return std::unique_ptr<GrFragmentProcessor>(new GrRadialGradient(*this));
}
private:
@@ -132,7 +132,7 @@
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrRadialGradient);
#if GR_TEST_UTILS
-sk_sp<GrFragmentProcessor> GrRadialGradient::TestCreate(GrProcessorTestData* d) {
+std::unique_ptr<GrFragmentProcessor> GrRadialGradient::TestCreate(GrProcessorTestData* d) {
sk_sp<SkShader> shader;
do {
RandomGradientParams params(d->fRandom);
@@ -147,7 +147,7 @@
params.fTileMode);
} while (!shader);
GrTest::TestAsFPArgs asFPArgs(d);
- sk_sp<GrFragmentProcessor> fp = as_SB(shader)->asFragmentProcessor(asFPArgs.args());
+ std::unique_ptr<GrFragmentProcessor> fp = as_SB(shader)->asFragmentProcessor(asFPArgs.args());
GrAlwaysAssert(fp);
return fp;
}
@@ -172,7 +172,8 @@
/////////////////////////////////////////////////////////////////////
-sk_sp<GrFragmentProcessor> SkRadialGradient::asFragmentProcessor(const AsFPArgs& args) const {
+std::unique_ptr<GrFragmentProcessor> SkRadialGradient::asFragmentProcessor(
+ const AsFPArgs& args) const {
SkASSERT(args.fContext);
SkMatrix matrix;
@@ -189,9 +190,9 @@
matrix.postConcat(fPtsToUnit);
sk_sp<GrColorSpaceXform> colorSpaceXform = GrColorSpaceXform::Make(fColorSpace.get(),
args.fDstColorSpace);
- sk_sp<GrFragmentProcessor> inner(GrRadialGradient::Make(
- GrGradientEffect::CreateArgs(args.fContext, this, &matrix, fTileMode,
- std::move(colorSpaceXform), SkToBool(args.fDstColorSpace))));
+ auto inner = GrRadialGradient::Make(GrGradientEffect::CreateArgs(
+ args.fContext, this, &matrix, fTileMode, std::move(colorSpaceXform),
+ SkToBool(args.fDstColorSpace)));
if (!inner) {
return nullptr;
}
diff --git a/src/shaders/gradients/SkRadialGradient.h b/src/shaders/gradients/SkRadialGradient.h
index 8cd7df2..6a6dadf 100644
--- a/src/shaders/gradients/SkRadialGradient.h
+++ b/src/shaders/gradients/SkRadialGradient.h
@@ -16,7 +16,7 @@
GradientType asAGradient(GradientInfo* info) const override;
#if SK_SUPPORT_GPU
- sk_sp<GrFragmentProcessor> asFragmentProcessor(const AsFPArgs&) const override;
+ std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(const AsFPArgs&) const override;
#endif
SK_TO_STRING_OVERRIDE()
diff --git a/src/shaders/gradients/SkSweepGradient.cpp b/src/shaders/gradients/SkSweepGradient.cpp
index 011474c..87b82fd 100644
--- a/src/shaders/gradients/SkSweepGradient.cpp
+++ b/src/shaders/gradients/SkSweepGradient.cpp
@@ -74,16 +74,16 @@
public:
class GLSLSweepProcessor;
- static sk_sp<GrFragmentProcessor> Make(const CreateArgs& args, SkScalar tBias,
- SkScalar tScale) {
- auto processor = sk_sp<GrSweepGradient>(new GrSweepGradient(args, tBias, tScale));
+ static std::unique_ptr<GrFragmentProcessor> Make(const CreateArgs& args, SkScalar tBias,
+ SkScalar tScale) {
+ auto processor = std::unique_ptr<GrSweepGradient>(new GrSweepGradient(args, tBias, tScale));
return processor->isValid() ? std::move(processor) : nullptr;
}
const char* name() const override { return "Sweep Gradient"; }
- sk_sp<GrFragmentProcessor> clone() const override {
- return sk_sp<GrFragmentProcessor>(new GrSweepGradient(*this));
+ std::unique_ptr<GrFragmentProcessor> clone() const override {
+ return std::unique_ptr<GrFragmentProcessor>(new GrSweepGradient(*this));
}
private:
@@ -176,7 +176,7 @@
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrSweepGradient);
#if GR_TEST_UTILS
-sk_sp<GrFragmentProcessor> GrSweepGradient::TestCreate(GrProcessorTestData* d) {
+std::unique_ptr<GrFragmentProcessor> GrSweepGradient::TestCreate(GrProcessorTestData* d) {
SkPoint center = {d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()};
RandomGradientParams params(d->fRandom);
@@ -186,7 +186,7 @@
SkGradientShader::MakeSweep(center.fX, center.fY, params.fColors,
params.fStops, params.fColorCount);
GrTest::TestAsFPArgs asFPArgs(d);
- sk_sp<GrFragmentProcessor> fp = as_SB(shader)->asFragmentProcessor(asFPArgs.args());
+ std::unique_ptr<GrFragmentProcessor> fp = as_SB(shader)->asFragmentProcessor(asFPArgs.args());
GrAlwaysAssert(fp);
return fp;
}
@@ -229,8 +229,8 @@
/////////////////////////////////////////////////////////////////////
-sk_sp<GrFragmentProcessor> SkSweepGradient::asFragmentProcessor(const AsFPArgs& args) const {
-
+std::unique_ptr<GrFragmentProcessor> SkSweepGradient::asFragmentProcessor(
+ const AsFPArgs& args) const {
SkMatrix matrix;
if (!this->getLocalMatrix().invert(&matrix)) {
return nullptr;
@@ -246,10 +246,10 @@
sk_sp<GrColorSpaceXform> colorSpaceXform = GrColorSpaceXform::Make(fColorSpace.get(),
args.fDstColorSpace);
- sk_sp<GrFragmentProcessor> inner(GrSweepGradient::Make(
- GrGradientEffect::CreateArgs(args.fContext, this, &matrix, fTileMode,
- std::move(colorSpaceXform), SkToBool(args.fDstColorSpace)),
- fTBias, fTScale));
+ auto inner = GrSweepGradient::Make(
+ GrGradientEffect::CreateArgs(args.fContext, this, &matrix, fTileMode,
+ std::move(colorSpaceXform), SkToBool(args.fDstColorSpace)),
+ fTBias, fTScale);
if (!inner) {
return nullptr;
}
diff --git a/src/shaders/gradients/SkSweepGradient.h b/src/shaders/gradients/SkSweepGradient.h
index b42f270..061d699 100644
--- a/src/shaders/gradients/SkSweepGradient.h
+++ b/src/shaders/gradients/SkSweepGradient.h
@@ -17,7 +17,7 @@
GradientType asAGradient(GradientInfo* info) const override;
#if SK_SUPPORT_GPU
- sk_sp<GrFragmentProcessor> asFragmentProcessor(const AsFPArgs&) const override;
+ std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(const AsFPArgs&) const override;
#endif
SK_TO_STRING_OVERRIDE()
diff --git a/src/shaders/gradients/SkTwoPointConicalGradient.cpp b/src/shaders/gradients/SkTwoPointConicalGradient.cpp
index 0bee74f..a163472 100644
--- a/src/shaders/gradients/SkTwoPointConicalGradient.cpp
+++ b/src/shaders/gradients/SkTwoPointConicalGradient.cpp
@@ -133,14 +133,14 @@
#include "SkGr.h"
#include "SkTwoPointConicalGradient_gpu.h"
-sk_sp<GrFragmentProcessor> SkTwoPointConicalGradient::asFragmentProcessor(
+std::unique_ptr<GrFragmentProcessor> SkTwoPointConicalGradient::asFragmentProcessor(
const AsFPArgs& args) const {
SkASSERT(args.fContext);
sk_sp<GrColorSpaceXform> colorSpaceXform = GrColorSpaceXform::Make(fColorSpace.get(),
args.fDstColorSpace);
- sk_sp<GrFragmentProcessor> inner(Gr2PtConicalGradientEffect::Make(
- GrGradientEffect::CreateArgs(args.fContext, this, args.fLocalMatrix, fTileMode,
- std::move(colorSpaceXform), SkToBool(args.fDstColorSpace))));
+ auto inner = Gr2PtConicalGradientEffect::Make(GrGradientEffect::CreateArgs(
+ args.fContext, this, args.fLocalMatrix, fTileMode, std::move(colorSpaceXform),
+ SkToBool(args.fDstColorSpace)));
if (!inner) {
return nullptr;
}
diff --git a/src/shaders/gradients/SkTwoPointConicalGradient.h b/src/shaders/gradients/SkTwoPointConicalGradient.h
index 408f31d..4b28271 100644
--- a/src/shaders/gradients/SkTwoPointConicalGradient.h
+++ b/src/shaders/gradients/SkTwoPointConicalGradient.h
@@ -19,7 +19,7 @@
SkShader::GradientType asAGradient(GradientInfo* info) const override;
#if SK_SUPPORT_GPU
- sk_sp<GrFragmentProcessor> asFragmentProcessor(const AsFPArgs&) const override;
+ std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(const AsFPArgs&) const override;
#endif
bool isOpaque() const override;
diff --git a/src/shaders/gradients/SkTwoPointConicalGradient_gpu.cpp b/src/shaders/gradients/SkTwoPointConicalGradient_gpu.cpp
index 8263f88..caada92 100644
--- a/src/shaders/gradients/SkTwoPointConicalGradient_gpu.cpp
+++ b/src/shaders/gradients/SkTwoPointConicalGradient_gpu.cpp
@@ -61,8 +61,8 @@
public:
class GLSLEdge2PtConicalProcessor;
- static sk_sp<GrFragmentProcessor> Make(const CreateArgs& args) {
- auto processor = sk_sp<Edge2PtConicalEffect>(new Edge2PtConicalEffect(args));
+ static std::unique_ptr<GrFragmentProcessor> Make(const CreateArgs& args) {
+ auto processor = std::unique_ptr<Edge2PtConicalEffect>(new Edge2PtConicalEffect(args));
return processor->isValid() ? std::move(processor) : nullptr;
}
@@ -75,8 +75,8 @@
SkScalar diffRadius() const { return fDiffRadius; }
SkScalar radius() const { return fRadius0; }
- sk_sp<GrFragmentProcessor> clone() const override {
- return sk_sp<GrFragmentProcessor>(new Edge2PtConicalEffect(*this));
+ std::unique_ptr<GrFragmentProcessor> clone() const override {
+ return std::unique_ptr<GrFragmentProcessor>(new Edge2PtConicalEffect(*this));
}
private:
@@ -193,7 +193,7 @@
* All Two point conical gradient test create functions may occasionally create edge case shaders
*/
#if GR_TEST_UTILS
-sk_sp<GrFragmentProcessor> Edge2PtConicalEffect::TestCreate(GrProcessorTestData* d) {
+std::unique_ptr<GrFragmentProcessor> Edge2PtConicalEffect::TestCreate(GrProcessorTestData* d) {
SkPoint center1 = {d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()};
SkScalar radius1 = d->fRandom->nextUScalar1();
SkPoint center2;
@@ -219,7 +219,7 @@
params.fColors, params.fStops,
params.fColorCount, params.fTileMode);
GrTest::TestAsFPArgs asFPArgs(d);
- sk_sp<GrFragmentProcessor> fp = as_SB(shader)->asFragmentProcessor(asFPArgs.args());
+ std::unique_ptr<GrFragmentProcessor> fp = as_SB(shader)->asFragmentProcessor(asFPArgs.args());
GrAlwaysAssert(fp);
return fp;
}
@@ -381,9 +381,9 @@
public:
class GLSLFocalOutside2PtConicalProcessor;
- static sk_sp<GrFragmentProcessor> Make(const CreateArgs& args, SkScalar focalX) {
- auto processor =
- sk_sp<FocalOutside2PtConicalEffect>(new FocalOutside2PtConicalEffect(args, focalX));
+ static std::unique_ptr<GrFragmentProcessor> Make(const CreateArgs& args, SkScalar focalX) {
+ auto processor = std::unique_ptr<FocalOutside2PtConicalEffect>(
+ new FocalOutside2PtConicalEffect(args, focalX));
return processor->isValid() ? std::move(processor) : nullptr;
}
@@ -391,8 +391,8 @@
return "Two-Point Conical Gradient Focal Outside";
}
- sk_sp<GrFragmentProcessor> clone() const override {
- return sk_sp<GrFragmentProcessor>(new FocalOutside2PtConicalEffect(*this));
+ std::unique_ptr<GrFragmentProcessor> clone() const override {
+ return std::unique_ptr<GrFragmentProcessor>(new FocalOutside2PtConicalEffect(*this));
}
bool isFlipped() const { return fIsFlipped; }
@@ -481,7 +481,8 @@
* All Two point conical gradient test create functions may occasionally create edge case shaders
*/
#if GR_TEST_UTILS
-sk_sp<GrFragmentProcessor> FocalOutside2PtConicalEffect::TestCreate(GrProcessorTestData* d) {
+std::unique_ptr<GrFragmentProcessor> FocalOutside2PtConicalEffect::TestCreate(
+ GrProcessorTestData* d) {
SkPoint center1 = {d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()};
SkScalar radius1 = 0.f;
SkPoint center2;
@@ -505,7 +506,7 @@
params.fColors, params.fStops,
params.fColorCount, params.fTileMode);
GrTest::TestAsFPArgs asFPArgs(d);
- sk_sp<GrFragmentProcessor> fp = as_SB(shader)->asFragmentProcessor(asFPArgs.args());
+ std::unique_ptr<GrFragmentProcessor> fp = as_SB(shader)->asFragmentProcessor(asFPArgs.args());
GrAlwaysAssert(fp);
return fp;
}
@@ -601,9 +602,9 @@
public:
class GLSLFocalInside2PtConicalProcessor;
- static sk_sp<GrFragmentProcessor> Make(const CreateArgs& args, SkScalar focalX) {
- auto processor =
- sk_sp<FocalInside2PtConicalEffect>(new FocalInside2PtConicalEffect(args, focalX));
+ static std::unique_ptr<GrFragmentProcessor> Make(const CreateArgs& args, SkScalar focalX) {
+ auto processor = std::unique_ptr<FocalInside2PtConicalEffect>(
+ new FocalInside2PtConicalEffect(args, focalX));
return processor->isValid() ? std::move(processor) : nullptr;
}
@@ -611,8 +612,8 @@
return "Two-Point Conical Gradient Focal Inside";
}
- sk_sp<GrFragmentProcessor> clone() const override {
- return sk_sp<GrFragmentProcessor>(new FocalInside2PtConicalEffect(*this));
+ std::unique_ptr<GrFragmentProcessor> clone() const override {
+ return std::unique_ptr<GrFragmentProcessor>(new FocalInside2PtConicalEffect(*this));
}
SkScalar focal() const { return fFocalX; }
@@ -691,7 +692,8 @@
* All Two point conical gradient test create functions may occasionally create edge case shaders
*/
#if GR_TEST_UTILS
-sk_sp<GrFragmentProcessor> FocalInside2PtConicalEffect::TestCreate(GrProcessorTestData* d) {
+std::unique_ptr<GrFragmentProcessor> FocalInside2PtConicalEffect::TestCreate(
+ GrProcessorTestData* d) {
SkPoint center1 = {d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()};
SkScalar radius1 = 0.f;
SkPoint center2;
@@ -716,7 +718,7 @@
params.fColors, params.fStops,
params.fColorCount, params.fTileMode);
GrTest::TestAsFPArgs asFPArgs(d);
- sk_sp<GrFragmentProcessor> fp = as_SB(shader)->asFragmentProcessor(asFPArgs.args());
+ std::unique_ptr<GrFragmentProcessor> fp = as_SB(shader)->asFragmentProcessor(asFPArgs.args());
GrAlwaysAssert(fp);
return fp;
}
@@ -846,16 +848,17 @@
public:
class GLSLCircleInside2PtConicalProcessor;
- static sk_sp<GrFragmentProcessor> Make(const CreateArgs& args, const CircleConicalInfo& info) {
- auto processor =
- sk_sp<CircleInside2PtConicalEffect>(new CircleInside2PtConicalEffect(args, info));
+ static std::unique_ptr<GrFragmentProcessor> Make(const CreateArgs& args,
+ const CircleConicalInfo& info) {
+ auto processor = std::unique_ptr<CircleInside2PtConicalEffect>(
+ new CircleInside2PtConicalEffect(args, info));
return processor->isValid() ? std::move(processor) : nullptr;
}
const char* name() const override { return "Two-Point Conical Gradient Inside"; }
- sk_sp<GrFragmentProcessor> clone() const override {
- return sk_sp<GrFragmentProcessor>(new CircleInside2PtConicalEffect(*this));
+ std::unique_ptr<GrFragmentProcessor> clone() const override {
+ return std::unique_ptr<GrFragmentProcessor>(new CircleInside2PtConicalEffect(*this));
}
SkScalar centerX() const { return fInfo.fCenterEnd.fX; }
@@ -945,7 +948,8 @@
* All Two point conical gradient test create functions may occasionally create edge case shaders
*/
#if GR_TEST_UTILS
-sk_sp<GrFragmentProcessor> CircleInside2PtConicalEffect::TestCreate(GrProcessorTestData* d) {
+std::unique_ptr<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;
@@ -969,7 +973,7 @@
params.fColors, params.fStops,
params.fColorCount, params.fTileMode);
GrTest::TestAsFPArgs asFPArgs(d);
- sk_sp<GrFragmentProcessor> fp = as_SB(shader)->asFragmentProcessor(asFPArgs.args());
+ std::unique_ptr<GrFragmentProcessor> fp = as_SB(shader)->asFragmentProcessor(asFPArgs.args());
GrAlwaysAssert(fp);
return fp;
}
@@ -1068,15 +1072,15 @@
public:
class GLSLCircleOutside2PtConicalProcessor;
- static sk_sp<GrFragmentProcessor> Make(const CreateArgs& args, const CircleConicalInfo& info) {
- return sk_sp<GrFragmentProcessor>(
- new CircleOutside2PtConicalEffect(args, info));
+ static std::unique_ptr<GrFragmentProcessor> Make(const CreateArgs& args,
+ const CircleConicalInfo& info) {
+ return std::unique_ptr<GrFragmentProcessor>(new CircleOutside2PtConicalEffect(args, info));
}
const char* name() const override { return "Two-Point Conical Gradient Outside"; }
- sk_sp<GrFragmentProcessor> clone() const override {
- return sk_sp<GrFragmentProcessor>(new CircleOutside2PtConicalEffect(*this));
+ std::unique_ptr<GrFragmentProcessor> clone() const override {
+ return std::unique_ptr<GrFragmentProcessor>(new CircleOutside2PtConicalEffect(*this));
}
SkScalar centerX() const { return fInfo.fCenterEnd.fX; }
@@ -1187,7 +1191,8 @@
* All Two point conical gradient test create functions may occasionally create edge case shaders
*/
#if GR_TEST_UTILS
-sk_sp<GrFragmentProcessor> CircleOutside2PtConicalEffect::TestCreate(GrProcessorTestData* d) {
+std::unique_ptr<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;
@@ -1212,7 +1217,7 @@
params.fColors, params.fStops,
params.fColorCount, params.fTileMode);
GrTest::TestAsFPArgs asFPArgs(d);
- sk_sp<GrFragmentProcessor> fp = as_SB(shader)->asFragmentProcessor(asFPArgs.args());
+ std::unique_ptr<GrFragmentProcessor> fp = as_SB(shader)->asFragmentProcessor(asFPArgs.args());
GrAlwaysAssert(fp);
return fp;
}
@@ -1334,8 +1339,8 @@
//////////////////////////////////////////////////////////////////////////////
-sk_sp<GrFragmentProcessor> Gr2PtConicalGradientEffect::Make(
- const GrGradientEffect::CreateArgs& args) {
+std::unique_ptr<GrFragmentProcessor> Gr2PtConicalGradientEffect::Make(
+ const GrGradientEffect::CreateArgs& args) {
const SkTwoPointConicalGradient& shader =
*static_cast<const SkTwoPointConicalGradient*>(args.fShader);
diff --git a/src/shaders/gradients/SkTwoPointConicalGradient_gpu.h b/src/shaders/gradients/SkTwoPointConicalGradient_gpu.h
index 46edb1f..e7eac07 100644
--- a/src/shaders/gradients/SkTwoPointConicalGradient_gpu.h
+++ b/src/shaders/gradients/SkTwoPointConicalGradient_gpu.h
@@ -14,11 +14,12 @@
class SkTwoPointConicalGradient;
namespace Gr2PtConicalGradientEffect {
- /**
- * Creates an effect that produces a two point conical gradient based on the
- * shader passed in.
- */
- sk_sp<GrFragmentProcessor> Make(const GrGradientEffect::CreateArgs& args);
+
+/**
+ * Creates an effect that produces a two point conical gradient based on the shader passed in.
+ */
+std::unique_ptr<GrFragmentProcessor> Make(const GrGradientEffect::CreateArgs& args);
+
};
#endif