aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar bungeman <bungeman@google.com>2016-06-09 08:01:03 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-06-09 08:01:03 -0700
commit06ca8ec87cf6fab57cadd043a5ac18c4154a4129 (patch)
tree95e7eaaaf3f42ce550332277c431e3ec119446f4
parent897a8e38879643d81a64d2bb6bed4e22af982aa4 (diff)
sk_sp for Ganesh.
Convert use of GrFragmentProcessor, GrGeometryProcessor, and GrXPFactory to sk_sp. This clarifies ownership and should reduce reference count churn by moving ownership. GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2041113004 Review-Url: https://codereview.chromium.org/2041113004
-rw-r--r--experimental/SkPerlinNoiseShader2/SkPerlinNoiseShader2.cpp63
-rw-r--r--experimental/SkPerlinNoiseShader2/SkPerlinNoiseShader2.h2
-rw-r--r--gm/beziereffects.cpp45
-rw-r--r--gm/bigrrectaaeffect.cpp7
-rw-r--r--gm/constcolorprocessor.cpp4
-rw-r--r--gm/convexpolyeffect.cpp20
-rw-r--r--gm/dcshader.cpp8
-rw-r--r--gm/rrects.cpp7
-rw-r--r--gm/texturedomaineffect.cpp10
-rw-r--r--gm/yuvtorgbeffect.cpp17
-rw-r--r--include/core/SkColorFilter.h7
-rw-r--r--include/core/SkRefCnt.h4
-rw-r--r--include/core/SkShader.h5
-rw-r--r--include/core/SkXfermode.h6
-rw-r--r--include/effects/SkColorCubeFilter.h2
-rw-r--r--include/effects/SkLumaColorFilter.h3
-rw-r--r--include/effects/SkPerlinNoiseShader.h2
-rw-r--r--include/gpu/GrClip.h12
-rw-r--r--include/gpu/GrContext.h4
-rw-r--r--include/gpu/GrFragmentProcessor.h29
-rw-r--r--include/gpu/GrPaint.h66
-rw-r--r--include/gpu/GrProcessorUnitTest.h30
-rw-r--r--include/gpu/GrTypesPriv.h6
-rw-r--r--include/gpu/effects/GrConstColorProcessor.h4
-rw-r--r--include/gpu/effects/GrCoverageSetOpXP.h2
-rw-r--r--include/gpu/effects/GrCustomXfermode.h2
-rw-r--r--include/gpu/effects/GrPorterDuffXferProcessor.h2
-rw-r--r--include/gpu/effects/GrXfermodeFragmentProcessor.h14
-rw-r--r--include/private/SkTArray.h9
-rw-r--r--src/core/SkBitmapProcShader.cpp12
-rw-r--r--src/core/SkBitmapProcShader.h2
-rw-r--r--src/core/SkColorFilter.cpp14
-rw-r--r--src/core/SkColorFilterShader.cpp18
-rw-r--r--src/core/SkColorFilterShader.h2
-rw-r--r--src/core/SkColorMatrixFilterRowMajor255.cpp19
-rw-r--r--src/core/SkColorMatrixFilterRowMajor255.h2
-rw-r--r--src/core/SkColorShader.cpp8
-rw-r--r--src/core/SkColorShader.h4
-rw-r--r--src/core/SkComposeShader.cpp21
-rw-r--r--src/core/SkComposeShader.h10
-rw-r--r--src/core/SkImageFilter.cpp2
-rw-r--r--src/core/SkLightingShader.cpp8
-rw-r--r--src/core/SkLocalMatrixShader.cpp17
-rw-r--r--src/core/SkLocalMatrixShader.h12
-rw-r--r--src/core/SkModeColorFilter.cpp12
-rw-r--r--src/core/SkModeColorFilter.h2
-rw-r--r--src/core/SkPictureShader.cpp2
-rw-r--r--src/core/SkPictureShader.h2
-rw-r--r--src/core/SkShader.cpp10
-rw-r--r--src/core/SkXfermode.cpp29
-rw-r--r--src/core/SkXfermode_proccoeff.h6
-rw-r--r--src/effects/GrAlphaThresholdFragmentProcessor.cpp5
-rw-r--r--src/effects/GrCircleBlurFragmentProcessor.cpp4
-rw-r--r--src/effects/GrCircleBlurFragmentProcessor.h7
-rw-r--r--src/effects/SkArithmeticMode.cpp34
-rw-r--r--src/effects/SkArithmeticMode_gpu.cpp14
-rw-r--r--src/effects/SkArithmeticMode_gpu.h13
-rw-r--r--src/effects/SkBlurMaskFilter.cpp43
-rw-r--r--src/effects/SkColorCubeFilter.cpp9
-rw-r--r--src/effects/SkDisplacementMapEffect.cpp30
-rw-r--r--src/effects/SkGpuBlurUtils.cpp12
-rw-r--r--src/effects/SkLightingImageFilter.cpp87
-rw-r--r--src/effects/SkLumaColorFilter.cpp9
-rw-r--r--src/effects/SkMagnifierImageFilter.cpp32
-rw-r--r--src/effects/SkMatrixConvolutionImageFilter.cpp3
-rw-r--r--src/effects/SkMorphologyImageFilter.cpp34
-rw-r--r--src/effects/SkPerlinNoiseShader.cpp45
-rw-r--r--src/effects/SkTableColorFilter.cpp18
-rw-r--r--src/effects/SkXfermodeImageFilter.cpp25
-rw-r--r--src/effects/gradients/SkLinearGradient.cpp22
-rw-r--r--src/effects/gradients/SkLinearGradient.h2
-rw-r--r--src/effects/gradients/SkRadialGradient.cpp21
-rw-r--r--src/effects/gradients/SkRadialGradient.h2
-rw-r--r--src/effects/gradients/SkSweepGradient.cpp17
-rw-r--r--src/effects/gradients/SkSweepGradient.h2
-rw-r--r--src/effects/gradients/SkTwoPointConicalGradient.cpp8
-rw-r--r--src/effects/gradients/SkTwoPointConicalGradient.h2
-rw-r--r--src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp102
-rw-r--r--src/effects/gradients/SkTwoPointConicalGradient_gpu.h4
-rw-r--r--src/gpu/GrBlurUtils.cpp4
-rw-r--r--src/gpu/GrClipMaskManager.cpp57
-rw-r--r--src/gpu/GrContext.cpp35
-rw-r--r--src/gpu/GrDefaultGeoProcFactory.cpp62
-rw-r--r--src/gpu/GrDefaultGeoProcFactory.h16
-rw-r--r--src/gpu/GrDrawContext.cpp10
-rw-r--r--src/gpu/GrDrawTarget.cpp18
-rw-r--r--src/gpu/GrFragmentProcessor.cpp94
-rw-r--r--src/gpu/GrOvalRenderer.cpp17
-rw-r--r--src/gpu/GrPaint.cpp18
-rw-r--r--src/gpu/GrPipelineBuilder.cpp17
-rw-r--r--src/gpu/GrPipelineBuilder.h43
-rw-r--r--src/gpu/GrProcessorUnitTest.cpp8
-rw-r--r--src/gpu/GrSWMaskHelper.cpp8
-rw-r--r--src/gpu/GrTextureParamsAdjuster.cpp24
-rw-r--r--src/gpu/GrTextureParamsAdjuster.h6
-rw-r--r--src/gpu/GrTextureToYUVPlanes.cpp24
-rw-r--r--src/gpu/GrYUVProvider.cpp15
-rw-r--r--src/gpu/SkGpuDevice.cpp39
-rw-r--r--src/gpu/SkGpuDevice_drawTexture.cpp2
-rw-r--r--src/gpu/SkGr.cpp88
-rw-r--r--src/gpu/SkGrPriv.h4
-rw-r--r--src/gpu/batches/GrAAConvexPathRenderer.cpp34
-rw-r--r--src/gpu/batches/GrAADistanceFieldPathRenderer.cpp21
-rw-r--r--src/gpu/batches/GrAAFillRectBatch.cpp14
-rw-r--r--src/gpu/batches/GrAAHairLinePathRenderer.cpp46
-rw-r--r--src/gpu/batches/GrAALinearizingConvexPathRenderer.cpp17
-rw-r--r--src/gpu/batches/GrAAStrokeRectBatch.cpp14
-rw-r--r--src/gpu/batches/GrAtlasTextBatch.cpp66
-rw-r--r--src/gpu/batches/GrAtlasTextBatch.h14
-rw-r--r--src/gpu/batches/GrDefaultPathRenderer.cpp9
-rw-r--r--src/gpu/batches/GrDrawAtlasBatch.cpp14
-rw-r--r--src/gpu/batches/GrDrawVerticesBatch.cpp13
-rw-r--r--src/gpu/batches/GrMSAAPathRenderer.cpp74
-rw-r--r--src/gpu/batches/GrNinePatch.cpp8
-rw-r--r--src/gpu/batches/GrNonAAFillRectBatch.cpp36
-rw-r--r--src/gpu/batches/GrNonAAStrokeRectBatch.cpp7
-rw-r--r--src/gpu/batches/GrStencilAndCoverPathRenderer.cpp2
-rw-r--r--src/gpu/batches/GrTInstanceBatch.h5
-rw-r--r--src/gpu/batches/GrTessellatingPathRenderer.cpp5
-rw-r--r--src/gpu/effects/GrBezierEffect.cpp32
-rw-r--r--src/gpu/effects/GrBezierEffect.h79
-rw-r--r--src/gpu/effects/GrBicubicEffect.cpp4
-rw-r--r--src/gpu/effects/GrBicubicEffect.h35
-rw-r--r--src/gpu/effects/GrBitmapTextGeoProc.cpp10
-rw-r--r--src/gpu/effects/GrBitmapTextGeoProc.h5
-rw-r--r--src/gpu/effects/GrConfigConversionEffect.cpp33
-rw-r--r--src/gpu/effects/GrConfigConversionEffect.h4
-rw-r--r--src/gpu/effects/GrConstColorProcessor.cpp4
-rw-r--r--src/gpu/effects/GrConvexPolyEffect.cpp33
-rw-r--r--src/gpu/effects/GrConvexPolyEffect.h12
-rw-r--r--src/gpu/effects/GrConvolutionEffect.cpp14
-rw-r--r--src/gpu/effects/GrConvolutionEffect.h30
-rw-r--r--src/gpu/effects/GrCoverageSetOpXP.cpp30
-rw-r--r--src/gpu/effects/GrCustomXfermode.cpp8
-rw-r--r--src/gpu/effects/GrDashingEffect.cpp88
-rw-r--r--src/gpu/effects/GrDisableColorXP.cpp4
-rw-r--r--src/gpu/effects/GrDisableColorXP.h3
-rw-r--r--src/gpu/effects/GrDistanceFieldGeoProc.cpp42
-rw-r--r--src/gpu/effects/GrDistanceFieldGeoProc.h45
-rw-r--r--src/gpu/effects/GrDitherEffect.cpp10
-rw-r--r--src/gpu/effects/GrDitherEffect.h3
-rw-r--r--src/gpu/effects/GrGammaEffect.cpp12
-rw-r--r--src/gpu/effects/GrGammaEffect.h2
-rw-r--r--src/gpu/effects/GrMatrixConvolutionEffect.cpp47
-rw-r--r--src/gpu/effects/GrMatrixConvolutionEffect.h43
-rw-r--r--src/gpu/effects/GrOvalEffect.cpp37
-rw-r--r--src/gpu/effects/GrOvalEffect.h3
-rw-r--r--src/gpu/effects/GrPorterDuffXferProcessor.cpp8
-rw-r--r--src/gpu/effects/GrRRectEffect.cpp51
-rw-r--r--src/gpu/effects/GrRRectEffect.h3
-rw-r--r--src/gpu/effects/GrSimpleTextureEffect.cpp4
-rw-r--r--src/gpu/effects/GrSimpleTextureEffect.h30
-rw-r--r--src/gpu/effects/GrTextureDomain.cpp21
-rw-r--r--src/gpu/effects/GrTextureDomain.h12
-rw-r--r--src/gpu/effects/GrXfermodeFragmentProcessor.cpp64
-rw-r--r--src/gpu/effects/GrYUVEffect.cpp55
-rw-r--r--src/gpu/effects/GrYUVEffect.h20
-rw-r--r--src/image/SkImageShader.cpp12
-rw-r--r--src/image/SkImageShader.h2
-rw-r--r--src/image/SkImage_Gpu.cpp4
-rw-r--r--tests/GLProgramsTest.cpp67
-rw-r--r--tests/GpuColorFilterTest.cpp2
-rw-r--r--tests/GrPorterDuffTest.cpp6
-rw-r--r--tests/TessellatingPathRendererTests.cpp2
-rw-r--r--tools/debugger/SkOverdrawMode.cpp29
165 files changed, 1654 insertions, 1630 deletions
diff --git a/experimental/SkPerlinNoiseShader2/SkPerlinNoiseShader2.cpp b/experimental/SkPerlinNoiseShader2/SkPerlinNoiseShader2.cpp
index ab0c46c350..b0c60f7161 100644
--- a/experimental/SkPerlinNoiseShader2/SkPerlinNoiseShader2.cpp
+++ b/experimental/SkPerlinNoiseShader2/SkPerlinNoiseShader2.cpp
@@ -630,13 +630,14 @@ private:
class GrPerlinNoise2Effect : public GrFragmentProcessor {
public:
- static GrFragmentProcessor* Create(SkPerlinNoiseShader2::Type type,
- int numOctaves, bool stitchTiles,
- SkPerlinNoiseShader2::PaintingData* paintingData,
- GrTexture* permutationsTexture, GrTexture* noiseTexture,
- const SkMatrix& matrix) {
- return new GrPerlinNoise2Effect(type, numOctaves, stitchTiles, paintingData,
- permutationsTexture, noiseTexture, matrix);
+ static sk_sp<GrFragmentProcessor> Make(SkPerlinNoiseShader2::Type type,
+ int numOctaves, bool stitchTiles,
+ SkPerlinNoiseShader2::PaintingData* paintingData,
+ GrTexture* permutationsTexture, GrTexture* noiseTexture,
+ const SkMatrix& matrix) {
+ return sk_sp<GrFragmentProcessor>(
+ new GrPerlinNoise2Effect(type, numOctaves, stitchTiles, paintingData,
+ permutationsTexture, noiseTexture, matrix));
}
virtual ~GrPerlinNoise2Effect() { delete fPaintingData; }
@@ -709,7 +710,7 @@ private:
/////////////////////////////////////////////////////////////////////
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrPerlinNoise2Effect);
-const GrFragmentProcessor* GrPerlinNoise2Effect::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> GrPerlinNoise2Effect::TestCreate(GrProcessorTestData* d) {
int numOctaves = d->fRandom->nextRangeU(2, 10);
bool stitchTiles = d->fRandom->nextBool();
SkScalar seed = SkIntToScalar(d->fRandom->nextU());
@@ -1050,12 +1051,14 @@ private:
class GrImprovedPerlinNoiseEffect : public GrFragmentProcessor {
public:
- static GrFragmentProcessor* Create(int octaves, SkScalar z,
- SkPerlinNoiseShader2::PaintingData* paintingData,
- GrTexture* permutationsTexture, GrTexture* gradientTexture,
- const SkMatrix& matrix) {
- return new GrImprovedPerlinNoiseEffect(octaves, z, paintingData, permutationsTexture,
- gradientTexture, matrix);
+ static sk_sp<GrFragmentProcessor> Make(int octaves, SkScalar z,
+ SkPerlinNoiseShader2::PaintingData* paintingData,
+ GrTexture* permutationsTexture,
+ GrTexture* gradientTexture,
+ const SkMatrix& matrix) {
+ return sk_sp<GrFragmentProcessor>(
+ new GrImprovedPerlinNoiseEffect(octaves, z, paintingData, permutationsTexture,
+ gradientTexture, matrix));
}
virtual ~GrImprovedPerlinNoiseEffect() { delete fPaintingData; }
@@ -1118,7 +1121,7 @@ private:
/////////////////////////////////////////////////////////////////////
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrImprovedPerlinNoiseEffect);
-const GrFragmentProcessor* GrImprovedPerlinNoiseEffect::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> GrImprovedPerlinNoiseEffect::TestCreate(GrProcessorTestData* d) {
SkScalar baseFrequencyX = d->fRandom->nextRangeScalar(0.01f,
0.99f);
SkScalar baseFrequencyY = d->fRandom->nextRangeScalar(0.01f,
@@ -1298,7 +1301,7 @@ void GrGLImprovedPerlinNoise::onSetData(const GrGLSLProgramDataManager& pdman,
}
/////////////////////////////////////////////////////////////////////
-const GrFragmentProcessor* SkPerlinNoiseShader2::asFragmentProcessor(
+sk_sp<GrFragmentProcessor> SkPerlinNoiseShader2::asFragmentProcessor(
GrContext* context,
const SkMatrix& viewM,
const SkMatrix* externalLocalMatrix,
@@ -1333,20 +1336,20 @@ const GrFragmentProcessor* SkPerlinNoiseShader2::asFragmentProcessor(
SkAutoTUnref<GrTexture> gradientTexture(
GrRefCachedBitmapTexture(context, paintingData->getGradientBitmap(),
textureParams, gammaTreatment));
- return GrImprovedPerlinNoiseEffect::Create(fNumOctaves, fSeed, paintingData,
+ return GrImprovedPerlinNoiseEffect::Make(fNumOctaves, fSeed, paintingData,
permutationsTexture, gradientTexture, m);
}
if (0 == fNumOctaves) {
if (kFractalNoise_Type == fType) {
// Extract the incoming alpha and emit rgba = (a/4, a/4, a/4, a/2)
- SkAutoTUnref<const GrFragmentProcessor> inner(
- GrConstColorProcessor::Create(0x80404040,
- GrConstColorProcessor::kModulateRGBA_InputMode));
- return GrFragmentProcessor::MulOutputByInputAlpha(inner);
+ sk_sp<GrFragmentProcessor> inner(
+ GrConstColorProcessor::Make(0x80404040,
+ GrConstColorProcessor::kModulateRGBA_InputMode));
+ return GrFragmentProcessor::MulOutputByInputAlpha(std::move(inner));
}
// Emit zero.
- return GrConstColorProcessor::Create(0x0, GrConstColorProcessor::kIgnore_InputMode);
+ return GrConstColorProcessor::Make(0x0, GrConstColorProcessor::kIgnore_InputMode);
}
SkAutoTUnref<GrTexture> permutationsTexture(
@@ -1357,14 +1360,14 @@ const GrFragmentProcessor* SkPerlinNoiseShader2::asFragmentProcessor(
GrTextureParams::ClampNoFilter(), gammaTreatment));
if ((permutationsTexture) && (noiseTexture)) {
- SkAutoTUnref<GrFragmentProcessor> inner(
- GrPerlinNoise2Effect::Create(fType,
- fNumOctaves,
- fStitchTiles,
- paintingData,
- permutationsTexture, noiseTexture,
- m));
- return GrFragmentProcessor::MulOutputByInputAlpha(inner);
+ sk_sp<GrFragmentProcessor> inner(
+ GrPerlinNoise2Effect::Make(fType,
+ fNumOctaves,
+ fStitchTiles,
+ paintingData,
+ permutationsTexture, noiseTexture,
+ m));
+ return GrFragmentProcessor::MulOutputByInputAlpha(std::move(inner));
}
delete paintingData;
return nullptr;
diff --git a/experimental/SkPerlinNoiseShader2/SkPerlinNoiseShader2.h b/experimental/SkPerlinNoiseShader2/SkPerlinNoiseShader2.h
index e62458e88e..196d3847f2 100644
--- a/experimental/SkPerlinNoiseShader2/SkPerlinNoiseShader2.h
+++ b/experimental/SkPerlinNoiseShader2/SkPerlinNoiseShader2.h
@@ -106,7 +106,7 @@ public:
};
#if SK_SUPPORT_GPU
- const GrFragmentProcessor* asFragmentProcessor(GrContext* context, const SkMatrix& viewM,
+ sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext* context, const SkMatrix& viewM,
const SkMatrix*, SkFilterQuality,
SkSourceGammaTreatment) const override;
#endif
diff --git a/gm/beziereffects.cpp b/gm/beziereffects.cpp
index 1224c1a8bb..ae1c37fdf6 100644
--- a/gm/beziereffects.cpp
+++ b/gm/beziereffects.cpp
@@ -34,10 +34,10 @@ public:
const char* name() const override { return "BezierCubicOrConicTestBatch"; }
- BezierCubicOrConicTestBatch(const GrGeometryProcessor* gp, const SkRect& bounds,
+ BezierCubicOrConicTestBatch(sk_sp<GrGeometryProcessor> gp, const SkRect& bounds,
GrColor color, const SkScalar klmEqs[9], SkScalar sign)
: INHERITED(ClassID(), bounds, color)
- , fGeometryProcessor(SkRef(gp)) {
+ , fGeometryProcessor(std::move(gp)) {
for (int i = 0; i < 9; i++) {
fKlmEqs[i] = klmEqs[i];
}
@@ -67,12 +67,12 @@ private:
verts[v].fKLM[1] = eval_line(verts[v].fPosition, fKlmEqs + 3, fSign);
verts[v].fKLM[2] = eval_line(verts[v].fPosition, fKlmEqs + 6, 1.f);
}
- helper.recordDraw(target, fGeometryProcessor);
+ helper.recordDraw(target, fGeometryProcessor.get());
}
- SkScalar fKlmEqs[9];
- SkScalar fSign;
- SkAutoTUnref<const GrGeometryProcessor> fGeometryProcessor;
+ SkScalar fKlmEqs[9];
+ SkScalar fSign;
+ sk_sp<GrGeometryProcessor> fGeometryProcessor;
static const int kVertsPerCubic = 4;
static const int kIndicesPerCubic = 6;
@@ -135,10 +135,9 @@ protected:
{rand.nextRangeF(0.f, w), rand.nextRangeF(0.f, h)}
};
for(int edgeType = 0; edgeType < kGrProcessorEdgeTypeCnt; ++edgeType) {
- SkAutoTUnref<GrGeometryProcessor> gp;
+ sk_sp<GrGeometryProcessor> gp;
GrPrimitiveEdgeType et = (GrPrimitiveEdgeType)edgeType;
- gp.reset(GrCubicEffect::Create(color, SkMatrix::I(), et,
- *context->caps()));
+ gp = GrCubicEffect::Make(color, SkMatrix::I(), et, *context->caps());
if (!gp) {
continue;
}
@@ -191,7 +190,7 @@ protected:
GrPipelineBuilder pipelineBuilder;
pipelineBuilder.setXPFactory(
- GrPorterDuffXPFactory::Create(SkXfermode::kSrc_Mode))->unref();
+ GrPorterDuffXPFactory::Make(SkXfermode::kSrc_Mode));
SkAutoTUnref<GrDrawBatch> batch(
new BezierCubicOrConicTestBatch(gp, bounds, color, klmEqs, klmSigns[c]));
@@ -269,10 +268,10 @@ protected:
};
SkScalar weight = rand.nextRangeF(0.f, 2.f);
for(int edgeType = 0; edgeType < kGrProcessorEdgeTypeCnt; ++edgeType) {
- SkAutoTUnref<GrGeometryProcessor> gp;
+ sk_sp<GrGeometryProcessor> gp;
GrPrimitiveEdgeType et = (GrPrimitiveEdgeType)edgeType;
- gp.reset(GrConicEffect::Create(color, SkMatrix::I(), et,
- *context->caps(), SkMatrix::I(), false));
+ gp = GrConicEffect::Make(color, SkMatrix::I(), et,
+ *context->caps(), SkMatrix::I(), false);
if (!gp) {
continue;
}
@@ -323,7 +322,7 @@ protected:
GrPipelineBuilder pipelineBuilder;
pipelineBuilder.setXPFactory(
- GrPorterDuffXPFactory::Create(SkXfermode::kSrc_Mode))->unref();
+ GrPorterDuffXPFactory::Make(SkXfermode::kSrc_Mode));
SkAutoTUnref<GrDrawBatch> batch(
new BezierCubicOrConicTestBatch(gp, bounds, color, klmEqs, 1.f));
@@ -387,11 +386,11 @@ public:
DEFINE_BATCH_CLASS_ID
const char* name() const override { return "BezierQuadTestBatch"; }
- BezierQuadTestBatch(const GrGeometryProcessor* gp, const SkRect& bounds, GrColor color,
+ BezierQuadTestBatch(sk_sp<GrGeometryProcessor> gp, const SkRect& bounds, GrColor color,
const GrPathUtils::QuadUVMatrix& devToUV)
: INHERITED(ClassID(), bounds, color)
, fDevToUV(devToUV)
- , fGeometryProcessor(SkRef(gp)) {
+ , fGeometryProcessor(std::move(gp)) {
}
private:
@@ -413,11 +412,11 @@ private:
verts[0].fPosition.setRectFan(bounds.fLeft, bounds.fTop, bounds.fRight, bounds.fBottom,
sizeof(Vertex));
fDevToUV.apply<4, sizeof(Vertex), sizeof(SkPoint)>(verts);
- helper.recordDraw(target, fGeometryProcessor);
+ helper.recordDraw(target, fGeometryProcessor.get());
}
- GrPathUtils::QuadUVMatrix fDevToUV;
- SkAutoTUnref<const GrGeometryProcessor> fGeometryProcessor;
+ GrPathUtils::QuadUVMatrix fDevToUV;
+ sk_sp<GrGeometryProcessor> fGeometryProcessor;
static const int kVertsPerCubic = 4;
static const int kIndicesPerCubic = 6;
@@ -479,10 +478,10 @@ protected:
{rand.nextRangeF(0.f, w), rand.nextRangeF(0.f, h)}
};
for(int edgeType = 0; edgeType < kGrProcessorEdgeTypeCnt; ++edgeType) {
- SkAutoTUnref<GrGeometryProcessor> gp;
+ sk_sp<GrGeometryProcessor> gp;
GrPrimitiveEdgeType et = (GrPrimitiveEdgeType)edgeType;
- gp.reset(GrQuadEffect::Create(color, SkMatrix::I(), et,
- *context->caps(), SkMatrix::I(), false));
+ gp = GrQuadEffect::Make(color, SkMatrix::I(), et,
+ *context->caps(), SkMatrix::I(), false);
if (!gp) {
continue;
}
@@ -530,7 +529,7 @@ protected:
GrPipelineBuilder pipelineBuilder;
pipelineBuilder.setXPFactory(
- GrPorterDuffXPFactory::Create(SkXfermode::kSrc_Mode))->unref();
+ GrPorterDuffXPFactory::Make(SkXfermode::kSrc_Mode));
GrPathUtils::QuadUVMatrix DevToUV(pts);
diff --git a/gm/bigrrectaaeffect.cpp b/gm/bigrrectaaeffect.cpp
index 1036ed0dab..924704a5ac 100644
--- a/gm/bigrrectaaeffect.cpp
+++ b/gm/bigrrectaaeffect.cpp
@@ -75,15 +75,14 @@ protected:
canvas->drawRect(testBounds, paint);
GrPipelineBuilder pipelineBuilder;
- pipelineBuilder.setXPFactory(
- GrPorterDuffXPFactory::Create(SkXfermode::kSrc_Mode))->unref();
+ pipelineBuilder.setXPFactory(GrPorterDuffXPFactory::Make(SkXfermode::kSrc_Mode));
SkRRect rrect = fRRect;
rrect.offset(SkIntToScalar(x + kGap), SkIntToScalar(y + kGap));
- SkAutoTUnref<GrFragmentProcessor> fp(GrRRectEffect::Create(edgeType, rrect));
+ sk_sp<GrFragmentProcessor> fp(GrRRectEffect::Make(edgeType, rrect));
SkASSERT(fp);
if (fp) {
- pipelineBuilder.addCoverageFragmentProcessor(fp);
+ pipelineBuilder.addCoverageFragmentProcessor(std::move(fp));
SkRect bounds = testBounds;
bounds.offset(SkIntToScalar(x), SkIntToScalar(y));
diff --git a/gm/constcolorprocessor.cpp b/gm/constcolorprocessor.cpp
index ce2ae6e9fd..8ae93a4ae9 100644
--- a/gm/constcolorprocessor.cpp
+++ b/gm/constcolorprocessor.cpp
@@ -105,10 +105,10 @@ protected:
GrConstColorProcessor::InputMode mode = (GrConstColorProcessor::InputMode) m;
GrColor color = kColors[procColor];
- SkAutoTUnref<GrFragmentProcessor> fp(GrConstColorProcessor::Create(color, mode));
+ sk_sp<GrFragmentProcessor> fp(GrConstColorProcessor::Make(color, mode));
GrPipelineBuilder pipelineBuilder(grPaint, drawContext->mustUseHWAA(grPaint));
- pipelineBuilder.addColorFragmentProcessor(fp);
+ pipelineBuilder.addColorFragmentProcessor(std::move(fp));
SkAutoTUnref<GrDrawBatch> batch(
GrRectBatchFactory::CreateNonAAFill(grPaint.getColor(), viewMatrix,
diff --git a/gm/convexpolyeffect.cpp b/gm/convexpolyeffect.cpp
index 13659476ba..3f8ae09a1a 100644
--- a/gm/convexpolyeffect.cpp
+++ b/gm/convexpolyeffect.cpp
@@ -58,8 +58,8 @@ private:
Color color(this->color());
Coverage coverage(Coverage::kSolid_Type);
LocalCoords localCoords(LocalCoords::kUnused_Type);
- SkAutoTUnref<const GrGeometryProcessor> gp(
- GrDefaultGeoProcFactory::Create(color, coverage, localCoords, SkMatrix::I()));
+ sk_sp<GrGeometryProcessor> gp(
+ GrDefaultGeoProcFactory::Make(color, coverage, localCoords, SkMatrix::I()));
size_t vertexStride = gp->getVertexStride();
SkASSERT(vertexStride == sizeof(SkPoint));
@@ -71,7 +71,7 @@ private:
fRect.toQuad(verts);
- helper.recordDraw(target, gp);
+ helper.recordDraw(target, gp.get());
}
SkRect fRect;
@@ -173,15 +173,14 @@ protected:
path->transform(m, &p);
GrPrimitiveEdgeType edgeType = (GrPrimitiveEdgeType) et;
- SkAutoTUnref<GrFragmentProcessor> fp(GrConvexPolyEffect::Create(edgeType, p));
+ sk_sp<GrFragmentProcessor> fp(GrConvexPolyEffect::Make(edgeType, p));
if (!fp) {
continue;
}
GrPipelineBuilder pipelineBuilder;
- pipelineBuilder.setXPFactory(
- GrPorterDuffXPFactory::Create(SkXfermode::kSrc_Mode))->unref();
- pipelineBuilder.addCoverageFragmentProcessor(fp);
+ pipelineBuilder.setXPFactory(GrPorterDuffXPFactory::Make(SkXfermode::kSrc_Mode));
+ pipelineBuilder.addCoverageFragmentProcessor(std::move(fp));
SkAutoTUnref<GrDrawBatch> batch(new PolyBoundsBatch(p.getBounds(), 0xff000000));
@@ -213,15 +212,14 @@ protected:
SkRect rect = *iter.get();
rect.offset(x, y);
GrPrimitiveEdgeType edgeType = (GrPrimitiveEdgeType) et;
- SkAutoTUnref<GrFragmentProcessor> fp(GrConvexPolyEffect::Create(edgeType, rect));
+ sk_sp<GrFragmentProcessor> fp(GrConvexPolyEffect::Make(edgeType, rect));
if (!fp) {
continue;
}
GrPipelineBuilder pipelineBuilder;
- pipelineBuilder.setXPFactory(
- GrPorterDuffXPFactory::Create(SkXfermode::kSrc_Mode))->unref();
- pipelineBuilder.addCoverageFragmentProcessor(fp);
+ pipelineBuilder.setXPFactory(GrPorterDuffXPFactory::Make(SkXfermode::kSrc_Mode));
+ pipelineBuilder.addCoverageFragmentProcessor(std::move(fp));
SkAutoTUnref<GrDrawBatch> batch(new PolyBoundsBatch(rect, 0xff000000));
diff --git a/gm/dcshader.cpp b/gm/dcshader.cpp
index 568a35376c..2b179a0a1f 100644
--- a/gm/dcshader.cpp
+++ b/gm/dcshader.cpp
@@ -35,7 +35,7 @@ public:
buf.writeMatrix(fDeviceMatrix);
}
- const GrFragmentProcessor* asFragmentProcessor(GrContext*,
+ sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext*,
const SkMatrix& viewM,
const SkMatrix* localMatrix,
SkFilterQuality,
@@ -99,13 +99,13 @@ private:
GrCoordTransform fDeviceTransform;
};
-const GrFragmentProcessor* DCShader::asFragmentProcessor(GrContext*,
+sk_sp<GrFragmentProcessor> DCShader::asFragmentProcessor(GrContext*,
const SkMatrix& viewM,
const SkMatrix* localMatrix,
SkFilterQuality,
SkSourceGammaTreatment) const {
- SkAutoTUnref<const GrFragmentProcessor> inner(new DCFP(fDeviceMatrix));
- return GrFragmentProcessor::MulOutputByInputAlpha(inner);
+ sk_sp<GrFragmentProcessor> inner(new DCFP(fDeviceMatrix));
+ return GrFragmentProcessor::MulOutputByInputAlpha(std::move(inner));
}
class DCShaderGM : public GM {
diff --git a/gm/rrects.cpp b/gm/rrects.cpp
index 5f28c9e4a2..e104aea433 100644
--- a/gm/rrects.cpp
+++ b/gm/rrects.cpp
@@ -103,15 +103,14 @@ protected:
#if SK_SUPPORT_GPU
GrPipelineBuilder pipelineBuilder;
pipelineBuilder.setXPFactory(
- GrPorterDuffXPFactory::Create(SkXfermode::kSrc_Mode))->unref();
+ GrPorterDuffXPFactory::Make(SkXfermode::kSrc_Mode));
SkRRect rrect = fRRects[curRRect];
rrect.offset(SkIntToScalar(x), SkIntToScalar(y));
GrPrimitiveEdgeType edgeType = (GrPrimitiveEdgeType) et;
- SkAutoTUnref<GrFragmentProcessor> fp(GrRRectEffect::Create(edgeType,
- rrect));
+ sk_sp<GrFragmentProcessor> fp(GrRRectEffect::Make(edgeType, rrect));
if (fp) {
- pipelineBuilder.addCoverageFragmentProcessor(fp);
+ pipelineBuilder.addCoverageFragmentProcessor(std::move(fp));
SkRect bounds = rrect.getBounds();
bounds.outset(2.f, 2.f);
diff --git a/gm/texturedomaineffect.cpp b/gm/texturedomaineffect.cpp
index 27cb59120e..cac2b9c8d5 100644
--- a/gm/texturedomaineffect.cpp
+++ b/gm/texturedomaineffect.cpp
@@ -114,18 +114,18 @@ protected:
GrTextureDomain::Mode mode = (GrTextureDomain::Mode) m;
GrPipelineBuilder pipelineBuilder;
pipelineBuilder.setXPFactory(
- GrPorterDuffXPFactory::Create(SkXfermode::kSrc_Mode))->unref();
- SkAutoTUnref<const GrFragmentProcessor> fp(
- GrTextureDomainEffect::Create(texture, textureMatrices[tm],
+ GrPorterDuffXPFactory::Make(SkXfermode::kSrc_Mode));
+ sk_sp<GrFragmentProcessor> fp(
+ GrTextureDomainEffect::Make(texture, textureMatrices[tm],
GrTextureDomain::MakeTexelDomain(texture,
- texelDomains[d]),
+ texelDomains[d]),
mode, GrTextureParams::kNone_FilterMode));
if (!fp) {
continue;
}
const SkMatrix viewMatrix = SkMatrix::MakeTrans(x, y);
- pipelineBuilder.addColorFragmentProcessor(fp);
+ pipelineBuilder.addColorFragmentProcessor(std::move(fp));
SkAutoTUnref<GrDrawBatch> batch(
GrRectBatchFactory::CreateNonAAFill(GrColor_WHITE, viewMatrix,
diff --git a/gm/yuvtorgbeffect.cpp b/gm/yuvtorgbeffect.cpp
index ca39c6c188..7fc8ff411b 100644
--- a/gm/yuvtorgbeffect.cpp
+++ b/gm/yuvtorgbeffect.cpp
@@ -114,18 +114,17 @@ protected:
for (int i = 0; i < 6; ++i) {
GrPipelineBuilder pipelineBuilder;
- pipelineBuilder.setXPFactory(
- GrPorterDuffXPFactory::Create(SkXfermode::kSrc_Mode))->unref();
- SkAutoTUnref<const GrFragmentProcessor> fp(
- GrYUVEffect::CreateYUVToRGB(texture[indices[i][0]],
- texture[indices[i][1]],
- texture[indices[i][2]],
- sizes,
- static_cast<SkYUVColorSpace>(space)));
+ pipelineBuilder.setXPFactory(GrPorterDuffXPFactory::Make(SkXfermode::kSrc_Mode));
+ sk_sp<GrFragmentProcessor> fp(
+ GrYUVEffect::MakeYUVToRGB(texture[indices[i][0]],
+ texture[indices[i][1]],
+ texture[indices[i][2]],
+ sizes,
+ static_cast<SkYUVColorSpace>(space)));
if (fp) {
SkMatrix viewMatrix;
viewMatrix.setTranslate(x, y);
- pipelineBuilder.addColorFragmentProcessor(fp);
+ pipelineBuilder.addColorFragmentProcessor(std::move(fp));
SkAutoTUnref<GrDrawBatch> batch(
GrRectBatchFactory::CreateNonAAFill(GrColor_WHITE, viewMatrix,
renderRect, nullptr, nullptr));
diff --git a/include/core/SkColorFilter.h b/include/core/SkColorFilter.h
index 7ac335fb10..7b2ee7845e 100644
--- a/include/core/SkColorFilter.h
+++ b/include/core/SkColorFilter.h
@@ -10,6 +10,7 @@
#include "SkColor.h"
#include "SkFlattenable.h"
+#include "SkRefCnt.h"
#include "SkXfermode.h"
class GrContext;
@@ -142,6 +143,7 @@ public:
}
#endif
+#if SK_SUPPORT_GPU
/**
* A subclass may implement this factory function to work with the GPU backend. It returns
* a GrFragmentProcessor that implemets the color filter in GPU shader code.
@@ -151,9 +153,8 @@ public:
*
* A null return indicates that the color filter isn't implemented for the GPU backend.
*/
- virtual const GrFragmentProcessor* asFragmentProcessor(GrContext*) const {
- return nullptr;
- }
+ virtual sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext*) const;
+#endif
bool affectsTransparentBlack() const {
return this->filterColor(0) != 0;
diff --git a/include/core/SkRefCnt.h b/include/core/SkRefCnt.h
index c45ed6bbf0..3227e68740 100644
--- a/include/core/SkRefCnt.h
+++ b/include/core/SkRefCnt.h
@@ -264,8 +264,8 @@ template <typename T> class sk_sp {
public:
using element_type = T;
- sk_sp() : fPtr(nullptr) {}
- sk_sp(std::nullptr_t) : fPtr(nullptr) {}
+ constexpr sk_sp() : fPtr(nullptr) {}
+ constexpr sk_sp(std::nullptr_t) : fPtr(nullptr) {}
/**
* Shares the underlying object by calling ref(), so that both the argument and the newly
diff --git a/include/core/SkShader.h b/include/core/SkShader.h
index 33ac8db6bc..1f80ea1c09 100644
--- a/include/core/SkShader.h
+++ b/include/core/SkShader.h
@@ -310,7 +310,7 @@ public:
virtual bool asACompose(ComposeRec*) const { return false; }
-
+#if SK_SUPPORT_GPU
/**
* Returns a GrFragmentProcessor that implements the shader for the GPU backend. NULL is
* returned if there is no GPU implementation.
@@ -324,11 +324,12 @@ public:
* The returned GrFragmentProcessor should expect an unpremultiplied input color and
* produce a premultiplied output.
*/
- virtual const GrFragmentProcessor* asFragmentProcessor(GrContext*,
+ virtual sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext*,
const SkMatrix& viewMatrix,
const SkMatrix* localMatrix,
SkFilterQuality,
SkSourceGammaTreatment) const;
+#endif
/**
* If the shader can represent its "average" luminance in a single color, return true and
diff --git a/include/core/SkXfermode.h b/include/core/SkXfermode.h
index c4578ffaf7..6215315576 100644
--- a/include/core/SkXfermode.h
+++ b/include/core/SkXfermode.h
@@ -220,14 +220,14 @@ public:
It is legal for the function to return a null output. This indicates that
the output of the blend is simply the src color.
*/
- virtual const GrFragmentProcessor* getFragmentProcessorForImageFilter(
- const GrFragmentProcessor* dst) const;
+ virtual sk_sp<GrFragmentProcessor> makeFragmentProcessorForImageFilter(
+ sk_sp<GrFragmentProcessor> dst) const;
/** A subclass must implement this factory function to work with the GPU backend.
The xfermode will return a factory for which the caller will get a ref. It is up
to the caller to install it. XferProcessors cannot use a background texture.
*/
- virtual GrXPFactory* asXPFactory() const;
+ virtual sk_sp<GrXPFactory> asXPFactory() const;
#endif
SK_TO_STRING_PUREVIRT()
diff --git a/include/effects/SkColorCubeFilter.h b/include/effects/SkColorCubeFilter.h
index 10e370a3af..fbfe698ba8 100644
--- a/include/effects/SkColorCubeFilter.h
+++ b/include/effects/SkColorCubeFilter.h
@@ -30,7 +30,7 @@ public:
uint32_t getFlags() const override;
#if SK_SUPPORT_GPU
- const GrFragmentProcessor* asFragmentProcessor(GrContext*) const override;
+ sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext*) const override;
#endif
SK_TO_STRING_OVERRIDE()
diff --git a/include/effects/SkLumaColorFilter.h b/include/effects/SkLumaColorFilter.h
index 3a68607b19..1ffaa733b2 100644
--- a/include/effects/SkLumaColorFilter.h
+++ b/include/effects/SkLumaColorFilter.h
@@ -9,6 +9,7 @@
#define SkLumaColorFilter_DEFINED
#include "SkColorFilter.h"
+#include "SkRefCnt.h"
/**
* Luminance-to-alpha color filter, as defined in
@@ -32,7 +33,7 @@ public:
void filterSpan(const SkPMColor src[], int count, SkPMColor[]) const override;
#if SK_SUPPORT_GPU
- const GrFragmentProcessor* asFragmentProcessor(GrContext*) const override;
+ sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext*) const override;
#endif
SK_TO_STRING_OVERRIDE()
diff --git a/include/effects/SkPerlinNoiseShader.h b/include/effects/SkPerlinNoiseShader.h
index 37d59f264e..ed706c19e8 100644
--- a/include/effects/SkPerlinNoiseShader.h
+++ b/include/effects/SkPerlinNoiseShader.h
@@ -102,7 +102,7 @@ public:
};
#if SK_SUPPORT_GPU
- const GrFragmentProcessor* asFragmentProcessor(GrContext* context, const SkMatrix& viewM,
+ sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext* context, const SkMatrix& viewM,
const SkMatrix*, SkFilterQuality,
SkSourceGammaTreatment) const override;
#endif
diff --git a/include/gpu/GrClip.h b/include/gpu/GrClip.h
index e684dfafd7..ce0f155e2f 100644
--- a/include/gpu/GrClip.h
+++ b/include/gpu/GrClip.h
@@ -22,7 +22,7 @@ class GrPipelineBuilder;
class GrAppliedClip : public SkNoncopyable {
public:
GrAppliedClip() : fHasStencilClip(false) {}
- const GrFragmentProcessor* clipCoverageFragmentProcessor() const {
+ GrFragmentProcessor* getClipCoverageFragmentProcessor() const {
return fClipCoverageFP.get();
}
const GrScissorState& scissorState() const { return fScissorState; }
@@ -40,22 +40,22 @@ public:
fHasStencilClip = hasStencil;
}
- void makeFPBased(sk_sp<const GrFragmentProcessor> fp) {
+ void makeFPBased(sk_sp<GrFragmentProcessor> fp) {
fClipCoverageFP = fp;
fScissorState.setDisabled();
fHasStencilClip = false;
}
- void makeScissoredFPBased(sk_sp<const GrFragmentProcessor> fp, SkIRect& scissor) {
+ void makeScissoredFPBased(sk_sp<GrFragmentProcessor> fp, SkIRect& scissor) {
fClipCoverageFP = fp;
fScissorState.set(scissor);
fHasStencilClip = false;
}
private:
- sk_sp<const GrFragmentProcessor> fClipCoverageFP;
- GrScissorState fScissorState;
- bool fHasStencilClip;
+ sk_sp<GrFragmentProcessor> fClipCoverageFP;
+ GrScissorState fScissorState;
+ bool fHasStencilClip;
typedef SkNoncopyable INHERITED;
};
diff --git a/include/gpu/GrContext.h b/include/gpu/GrContext.h
index 4e2546b6e2..f9d06f097a 100644
--- a/include/gpu/GrContext.h
+++ b/include/gpu/GrContext.h
@@ -457,9 +457,9 @@ private:
* of effects that make a readToUPM->writeToPM->readToUPM cycle invariant. Otherwise, they
* return NULL. They also can perform a swizzle as part of the draw.
*/
- const GrFragmentProcessor* createPMToUPMEffect(GrTexture*, const GrSwizzle&,
+ sk_sp<GrFragmentProcessor> createPMToUPMEffect(GrTexture*, const GrSwizzle&,
const SkMatrix&) const;
- const GrFragmentProcessor* createUPMToPMEffect(GrTexture*, const GrSwizzle&,
+ sk_sp<GrFragmentProcessor> createUPMToPMEffect(GrTexture*, const GrSwizzle&,
const SkMatrix&) const;
/** Called before either of the above two functions to determine the appropriate fragment
processors for conversions. This must be called by readSurfacePixels before a mutex is
diff --git a/include/gpu/GrFragmentProcessor.h b/include/gpu/GrFragmentProcessor.h
index c3f291cc5f..b8ebeca303 100644
--- a/include/gpu/GrFragmentProcessor.h
+++ b/include/gpu/GrFragmentProcessor.h
@@ -31,29 +31,31 @@ public:
* does so by returning a parent FP that multiplies the passed in FPs output by the parent's
* input alpha. The passed in FP will not receive an input color.
*/
- static const GrFragmentProcessor* MulOutputByInputAlpha(const GrFragmentProcessor*);
+ static sk_sp<GrFragmentProcessor> MulOutputByInputAlpha(sk_sp<GrFragmentProcessor>);
/**
* Similar to the above but it modulates the output r,g,b of the child processor by the input
* rgb and then multiplies all the components by the input alpha. This effectively modulates
* the child processor's premul color by a unpremul'ed input and produces a premul output
*/
- static const GrFragmentProcessor* MulOutputByInputUnpremulColor(const GrFragmentProcessor*);
+ static sk_sp<GrFragmentProcessor> MulOutputByInputUnpremulColor(sk_sp<GrFragmentProcessor>);
/**
* Returns a parent fragment processor that adopts the passed fragment processor as a child.
* The parent will ignore its input color and instead feed the passed in color as input to the
* child.
*/
- static const GrFragmentProcessor* OverrideInput(const GrFragmentProcessor*, GrColor);
+ static sk_sp<GrFragmentProcessor> OverrideInput(sk_sp<GrFragmentProcessor>, GrColor);
/**
* Returns a fragment processor that runs the passed in array of fragment processors in a
* series. The original input is passed to the first, the first's output is passed to the
* second, etc. The output of the returned processor is the output of the last processor of the
* series.
+ *
+ * The array elements with be moved.
*/
- static const GrFragmentProcessor* RunInSeries(const GrFragmentProcessor*[], int cnt);
+ static sk_sp<GrFragmentProcessor> RunInSeries(sk_sp<GrFragmentProcessor>*, int cnt);
GrFragmentProcessor()
: INHERITED()
@@ -155,7 +157,7 @@ protected:
* processors will allow the ProgramBuilder to automatically handle their transformed coords and
* texture accesses and mangle their uniform and output color names.
*/
- int registerChildProcessor(const GrFragmentProcessor* child);
+ int registerChildProcessor(sk_sp<GrFragmentProcessor> child);
/**
* Subclass implements this to support getConstantColorComponents(...).
@@ -187,7 +189,7 @@ private:
bool hasSameTransforms(const GrFragmentProcessor&) const;
- bool fUsesLocalCoords;
+ bool fUsesLocalCoords;
/**
* fCoordTransforms stores the transforms of this proc, followed by all the transforms of this
@@ -212,11 +214,16 @@ private:
*
* The same goes for fTextureAccesses with textures.
*/
- SkSTArray<4, const GrCoordTransform*, true> fCoordTransforms;
- int fNumTexturesExclChildren;
- int fNumBuffersExclChildren;
- int fNumTransformsExclChildren;
- SkSTArray<1, const GrFragmentProcessor*, true> fChildProcessors;
+ SkSTArray<4, const GrCoordTransform*, true> fCoordTransforms;
+ int fNumTexturesExclChildren;
+ int fNumBuffersExclChildren;
+ int fNumTransformsExclChildren;
+
+ /**
+ * This is not SkSTArray<1, sk_sp<GrFragmentProcessor>> because this class holds strong
+ * references until notifyRefCntIsZero and then it holds pending executions.
+ */
+ SkSTArray<1, GrFragmentProcessor*, true> fChildProcessors;
typedef GrProcessor INHERITED;
};
diff --git a/include/gpu/GrPaint.h b/include/gpu/GrPaint.h
index 7de559ca4c..af408488d7 100644
--- a/include/gpu/GrPaint.h
+++ b/include/gpu/GrPaint.h
@@ -15,6 +15,7 @@
#include "effects/GrPorterDuffXferProcessor.h"
#include "GrFragmentProcessor.h"
+#include "SkRefCnt.h"
#include "SkRegion.h"
#include "SkXfermode.h"
@@ -42,7 +43,7 @@ public:
GrPaint(const GrPaint& paint) { *this = paint; }
- ~GrPaint() { this->resetFragmentProcessors(); }
+ ~GrPaint() { }
/**
* The initial color of the drawn primitive. Defaults to solid white.
@@ -79,13 +80,12 @@ public:
setAllowSRGBInputs(gammaCorrect);
}
- const GrXPFactory* setXPFactory(const GrXPFactory* xpFactory) {
- fXPFactory.reset(SkSafeRef(xpFactory));
- return xpFactory;
+ void setXPFactory(sk_sp<GrXPFactory> xpFactory) {
+ fXPFactory = std::move(xpFactory);
}
void setPorterDuffXPFactory(SkXfermode::Mode mode) {
- fXPFactory.reset(GrPorterDuffXPFactory::Create(mode));
+ fXPFactory = GrPorterDuffXPFactory::Make(mode);
}
void setCoverageSetOpXPFactory(SkRegion::Op regionOp, bool invertCoverage = false);
@@ -93,19 +93,17 @@ public:
/**
* Appends an additional color processor to the color computation.
*/
- const GrFragmentProcessor* addColorFragmentProcessor(const GrFragmentProcessor* fp) {
+ void addColorFragmentProcessor(sk_sp<GrFragmentProcessor> fp) {
SkASSERT(fp);
- fColorFragmentProcessors.push_back(SkRef(fp));
- return fp;
+ fColorFragmentProcessors.push_back(std::move(fp));
}
/**
* Appends an additional coverage processor to the coverage computation.
*/
- const GrFragmentProcessor* addCoverageFragmentProcessor(const GrFragmentProcessor* fp) {
+ void addCoverageFragmentProcessor(sk_sp<GrFragmentProcessor> fp) {
SkASSERT(fp);
- fCoverageFragmentProcessors.push_back(SkRef(fp));
- return fp;
+ fCoverageFragmentProcessors.push_back(std::move(fp));
}
/**
@@ -122,15 +120,15 @@ public:
int numTotalFragmentProcessors() const { return this->numColorFragmentProcessors() +
this->numCoverageFragmentProcessors(); }
- const GrXPFactory* getXPFactory() const {
- return fXPFactory;
+ GrXPFactory* getXPFactory() const {
+ return fXPFactory.get();
}
- const GrFragmentProcessor* getColorFragmentProcessor(int i) const {
- return fColorFragmentProcessors[i];
+ GrFragmentProcessor* getColorFragmentProcessor(int i) const {
+ return fColorFragmentProcessors[i].get();
}
- const GrFragmentProcessor* getCoverageFragmentProcessor(int i) const {
- return fCoverageFragmentProcessors[i];
+ GrFragmentProcessor* getCoverageFragmentProcessor(int i) const {
+ return fCoverageFragmentProcessors[i].get();
}
GrPaint& operator=(const GrPaint& paint) {
@@ -139,17 +137,10 @@ public:
fAllowSRGBInputs = paint.fAllowSRGBInputs;
fColor = paint.fColor;
- this->resetFragmentProcessors();
fColorFragmentProcessors = paint.fColorFragmentProcessors;
fCoverageFragmentProcessors = paint.fCoverageFragmentProcessors;
- for (int i = 0; i < fColorFragmentProcessors.count(); ++i) {
- fColorFragmentProcessors[i]->ref();
- }
- for (int i = 0; i < fCoverageFragmentProcessors.count(); ++i) {
- fCoverageFragmentProcessors[i]->ref();
- }
- fXPFactory.reset(SkSafeRef(paint.getXPFactory()));
+ fXPFactory = paint.fXPFactory;
return *this;
}
@@ -163,26 +154,15 @@ public:
bool isConstantBlendedColor(GrColor* constantColor) const;
private:
- void resetFragmentProcessors() {
- for (int i = 0; i < fColorFragmentProcessors.count(); ++i) {
- fColorFragmentProcessors[i]->unref();
- }
- for (int i = 0; i < fCoverageFragmentProcessors.count(); ++i) {
- fCoverageFragmentProcessors[i]->unref();
- }
- fColorFragmentProcessors.reset();
- fCoverageFragmentProcessors.reset();
- }
-
- mutable SkAutoTUnref<const GrXPFactory> fXPFactory;
- SkSTArray<4, const GrFragmentProcessor*, true> fColorFragmentProcessors;
- SkSTArray<2, const GrFragmentProcessor*, true> fCoverageFragmentProcessors;
+ mutable sk_sp<GrXPFactory> fXPFactory;
+ SkSTArray<4, sk_sp<GrFragmentProcessor>> fColorFragmentProcessors;
+ SkSTArray<2, sk_sp<GrFragmentProcessor>> fCoverageFragmentProcessors;
- bool fAntiAlias;
- bool fDisableOutputConversionToSRGB;
- bool fAllowSRGBInputs;
+ bool fAntiAlias;
+ bool fDisableOutputConversionToSRGB;
+ bool fAllowSRGBInputs;
- GrColor fColor;
+ GrColor fColor;
};
#endif
diff --git a/include/gpu/GrProcessorUnitTest.h b/include/gpu/GrProcessorUnitTest.h
index bc90204d2a..4f26665cbe 100644
--- a/include/gpu/GrProcessorUnitTest.h
+++ b/include/gpu/GrProcessorUnitTest.h
@@ -28,7 +28,7 @@ enum {
/** This allows parent FPs to implement a test create with known leaf children in order to avoid
creating an unbounded FP tree which may overflow various shader limits. */
-const GrFragmentProcessor* CreateChildFP(GrProcessorTestData*);
+sk_sp<GrFragmentProcessor> MakeChildFP(GrProcessorTestData*);
}
@@ -66,28 +66,28 @@ class GrTexture;
template <class Processor> class GrProcessorTestFactory : SkNoncopyable {
public:
- typedef const Processor* (*CreateProc)(GrProcessorTestData*);
+ typedef sk_sp<Processor> (*MakeProc)(GrProcessorTestData*);
- GrProcessorTestFactory(CreateProc createProc) {
- fCreateProc = createProc;
+ GrProcessorTestFactory(MakeProc makeProc) {
+ fMakeProc = makeProc;
GetFactories()->push_back(this);
}
/** Pick a random factory function and create a processor. */
- static const Processor* Create(GrProcessorTestData* data) {
+ static sk_sp<Processor> Make(GrProcessorTestData* data) {
VerifyFactoryCount();
SkASSERT(GetFactories()->count());
uint32_t idx = data->fRandom->nextRangeU(0, GetFactories()->count() - 1);
- return CreateIdx(idx, data);
+ return MakeIdx(idx, data);
}
/** Number of registered factory functions */
static int Count() { return GetFactories()->count(); }
/** Use factory function at Index idx to create a processor. */
- static const Processor* CreateIdx(int idx, GrProcessorTestData* data) {
+ static sk_sp<Processor> MakeIdx(int idx, GrProcessorTestData* data) {
GrProcessorTestFactory<Processor>* factory = (*GetFactories())[idx];
- return factory->fCreateProc(data);
+ return factory->fMakeProc(data);
}
/*
@@ -96,7 +96,7 @@ public:
static void VerifyFactoryCount();
private:
- CreateProc fCreateProc;
+ MakeProc fMakeProc;
static SkTArray<GrProcessorTestFactory<Processor>*, true>* GetFactories();
};
@@ -106,15 +106,15 @@ private:
*/
#define GR_DECLARE_GEOMETRY_PROCESSOR_TEST \
static GrProcessorTestFactory<GrGeometryProcessor> gTestFactory SK_UNUSED; \
- static const GrGeometryProcessor* TestCreate(GrProcessorTestData*)
+ static sk_sp<GrGeometryProcessor> TestCreate(GrProcessorTestData*)
#define GR_DECLARE_FRAGMENT_PROCESSOR_TEST \
static GrProcessorTestFactory<GrFragmentProcessor> gTestFactory SK_UNUSED; \
- static const GrFragmentProcessor* TestCreate(GrProcessorTestData*)
+ static sk_sp<GrFragmentProcessor> TestCreate(GrProcessorTestData*)
#define GR_DECLARE_XP_FACTORY_TEST \
static GrProcessorTestFactory<GrXPFactory> gTestFactory SK_UNUSED; \
- static const GrXPFactory* TestCreate(GrProcessorTestData*)
+ static sk_sp<GrXPFactory> TestCreate(GrProcessorTestData*)
/** GrProcessor subclasses should insert this macro in their implementation file. They must then
* also implement this static function:
@@ -134,19 +134,19 @@ private:
// The unit test relies on static initializers. Just declare the TestCreate function so that
// its definitions will compile.
#define GR_DECLARE_FRAGMENT_PROCESSOR_TEST \
- static const GrFragmentProcessor* TestCreate(GrProcessorTestData*)
+ static sk_sp<GrFragmentProcessor> TestCreate(GrProcessorTestData*)
#define GR_DEFINE_FRAGMENT_PROCESSOR_TEST(X)
// The unit test relies on static initializers. Just declare the TestCreate function so that
// its definitions will compile.
#define GR_DECLARE_XP_FACTORY_TEST \
- static const GrXPFactory* TestCreate(GrProcessorTestData*)
+ static sk_sp<GrXPFactory> TestCreate(GrProcessorTestData*)
#define GR_DEFINE_XP_FACTORY_TEST(X)
// The unit test relies on static initializers. Just declare the TestCreate function so that
// its definitions will compile.
#define GR_DECLARE_GEOMETRY_PROCESSOR_TEST \
- static const GrGeometryProcessor* TestCreate(GrProcessorTestData*)
+ static sk_sp<GrGeometryProcessor> TestCreate(GrProcessorTestData*)
#define GR_DEFINE_GEOMETRY_PROCESSOR_TEST(X)
#endif // !SK_ALLOW_STATIC_GLOBAL_INITIALIZERS
diff --git a/include/gpu/GrTypesPriv.h b/include/gpu/GrTypesPriv.h
index 6a6fd54c7b..8c7d6bda65 100644
--- a/include/gpu/GrTypesPriv.h
+++ b/include/gpu/GrTypesPriv.h
@@ -10,6 +10,7 @@
#include "GrTypes.h"
#include "SkRect.h"
+#include "SkRefCnt.h"
/**
* Types of shader-language-specific boxed variables we can create. (Currently only GrGLShaderVars,
@@ -476,4 +477,9 @@ enum class GrBackendObjectOwnership : bool {
kOwned = true
};
+template <typename T> T * const * sk_sp_address_as_pointer_address(sk_sp<T> const * sp) {
+ static_assert(sizeof(T*) == sizeof(sk_sp<T>), "sk_sp not expected size.");
+ return reinterpret_cast<T * const *>(sp);
+}
+
#endif
diff --git a/include/gpu/effects/GrConstColorProcessor.h b/include/gpu/effects/GrConstColorProcessor.h
index 679533eac5..e9781bb22a 100644
--- a/include/gpu/effects/GrConstColorProcessor.h
+++ b/include/gpu/effects/GrConstColorProcessor.h
@@ -26,8 +26,8 @@ public:
};
static const int kInputModeCnt = kLastInputMode + 1;
- static GrFragmentProcessor* Create(GrColor color, InputMode mode) {
- return new GrConstColorProcessor(color, mode);
+ static sk_sp<GrFragmentProcessor> Make(GrColor color, InputMode mode) {
+ return sk_sp<GrFragmentProcessor>(new GrConstColorProcessor(color, mode));
}
const char* name() const override { return "Color"; }
diff --git a/include/gpu/effects/GrCoverageSetOpXP.h b/include/gpu/effects/GrCoverageSetOpXP.h
index 06cc759812..e5d197f338 100644
--- a/include/gpu/effects/GrCoverageSetOpXP.h
+++ b/include/gpu/effects/GrCoverageSetOpXP.h
@@ -21,7 +21,7 @@ class GrProcOptInfo;
*/
class GrCoverageSetOpXPFactory : public GrXPFactory {
public:
- static GrXPFactory* Create(SkRegion::Op regionOp, bool invertCoverage = false);
+ static sk_sp<GrXPFactory> Make(SkRegion::Op regionOp, bool invertCoverage = false);
void getInvariantBlendedColor(const GrProcOptInfo& colorPOI,
GrXPFactory::InvariantBlendedColor*) const override;
diff --git a/include/gpu/effects/GrCustomXfermode.h b/include/gpu/effects/GrCustomXfermode.h
index bcbd5833ca..3bd3214475 100644
--- a/include/gpu/effects/GrCustomXfermode.h
+++ b/include/gpu/effects/GrCustomXfermode.h
@@ -18,7 +18,7 @@ class GrTexture;
*/
namespace GrCustomXfermode {
bool IsSupportedMode(SkXfermode::Mode mode);
- GrXPFactory* CreateXPFactory(SkXfermode::Mode mode);
+ sk_sp<GrXPFactory> MakeXPFactory(SkXfermode::Mode mode);
};
#endif
diff --git a/include/gpu/effects/GrPorterDuffXferProcessor.h b/include/gpu/effects/GrPorterDuffXferProcessor.h
index 476a039ad2..8399d5805e 100644
--- a/include/gpu/effects/GrPorterDuffXferProcessor.h
+++ b/include/gpu/effects/GrPorterDuffXferProcessor.h
@@ -16,7 +16,7 @@ class GrProcOptInfo;
class GrPorterDuffXPFactory : public GrXPFactory {
public:
- static GrXPFactory* Create(SkXfermode::Mode mode);
+ static sk_sp<GrXPFactory> Make(SkXfermode::Mode mode);
void getInvariantBlendedColor(const GrProcOptInfo& colorPOI,
GrXPFactory::InvariantBlendedColor*) const override;
diff --git a/include/gpu/effects/GrXfermodeFragmentProcessor.h b/include/gpu/effects/GrXfermodeFragmentProcessor.h
index fb07d003cd..0e2435ea93 100644
--- a/include/gpu/effects/GrXfermodeFragmentProcessor.h
+++ b/include/gpu/effects/GrXfermodeFragmentProcessor.h
@@ -15,20 +15,20 @@ class GrFragmentProcessor;
namespace GrXfermodeFragmentProcessor {
/** The color input to the returned processor is treated as the src and the passed in processor
is the dst. */
- const GrFragmentProcessor* CreateFromDstProcessor(const GrFragmentProcessor* dst,
- SkXfermode::Mode mode);
+ sk_sp<GrFragmentProcessor> MakeFromDstProcessor(sk_sp<GrFragmentProcessor> dst,
+ SkXfermode::Mode mode);
/** The color input to the returned processor is treated as the dst and the passed in processor
is the src. */
- const GrFragmentProcessor* CreateFromSrcProcessor(const GrFragmentProcessor* src,
- SkXfermode::Mode mode);
+ sk_sp<GrFragmentProcessor> MakeFromSrcProcessor(sk_sp<GrFragmentProcessor> src,
+ SkXfermode::Mode 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. */
- const GrFragmentProcessor* CreateFromTwoProcessors(const GrFragmentProcessor* src,
- const GrFragmentProcessor* dst,
- SkXfermode::Mode mode);
+ sk_sp<GrFragmentProcessor> MakeFromTwoProcessors(sk_sp<GrFragmentProcessor> src,
+ sk_sp<GrFragmentProcessor> dst,
+ SkXfermode::Mode mode);
};
#endif
diff --git a/include/private/SkTArray.h b/include/private/SkTArray.h
index 55d4f86aaa..1fe2c3857c 100644
--- a/include/private/SkTArray.h
+++ b/include/private/SkTArray.h
@@ -121,6 +121,15 @@ public:
}
/**
+ * Ensures there is enough reserved space for n elements.
+ */
+ void reserve(int n) {
+ if (fCount < n) {
+ this->checkRealloc(n - fCount);
+ }
+ }
+
+ /**
* Resets to a copy of a C array.
*/
void reset(const T* array, int count) {
diff --git a/src/core/SkBitmapProcShader.cpp b/src/core/SkBitmapProcShader.cpp
index e140f0feb0..972d73173f 100644
--- a/src/core/SkBitmapProcShader.cpp
+++ b/src/core/SkBitmapProcShader.cpp
@@ -410,7 +410,7 @@ void SkBitmapProcShader::toString(SkString* str) const {
#include "SkGr.h"
#include "effects/GrSimpleTextureEffect.h"
-const GrFragmentProcessor* SkBitmapProcShader::asFragmentProcessor(GrContext* context,
+sk_sp<GrFragmentProcessor> SkBitmapProcShader::asFragmentProcessor(GrContext* context,
const SkMatrix& viewM, const SkMatrix* localMatrix,
SkFilterQuality filterQuality,
SkSourceGammaTreatment gammaTreatment) const {
@@ -453,17 +453,17 @@ const GrFragmentProcessor* SkBitmapProcShader::asFragmentProcessor(GrContext* co
return nullptr;
}
- SkAutoTUnref<const GrFragmentProcessor> inner;
+ sk_sp<GrFragmentProcessor> inner;
if (doBicubic) {
- inner.reset(GrBicubicEffect::Create(texture, matrix, tm));
+ inner = GrBicubicEffect::Make(texture, matrix, tm);
} else {
- inner.reset(GrSimpleTextureEffect::Create(texture, matrix, params));
+ inner = GrSimpleTextureEffect::Make(texture, matrix, params);
}
if (kAlpha_8_SkColorType == fRawBitmap.colorType()) {
- return GrFragmentProcessor::MulOutputByInputUnpremulColor(inner);
+ return GrFragmentProcessor::MulOutputByInputUnpremulColor(std::move(inner));
}
- return GrFragmentProcessor::MulOutputByInputAlpha(inner);
+ return GrFragmentProcessor::MulOutputByInputAlpha(std::move(inner));
}
#endif
diff --git a/src/core/SkBitmapProcShader.h b/src/core/SkBitmapProcShader.h
index dbd82a7b8d..1d374335c2 100644
--- a/src/core/SkBitmapProcShader.h
+++ b/src/core/SkBitmapProcShader.h
@@ -25,7 +25,7 @@ public:
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBitmapProcShader)
#if SK_SUPPORT_GPU
- const GrFragmentProcessor* asFragmentProcessor(GrContext*, const SkMatrix& viewM,
+ sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext*, const SkMatrix& viewM,
const SkMatrix*, SkFilterQuality,
SkSourceGammaTreatment) const override;
#endif
diff --git a/src/core/SkColorFilter.cpp b/src/core/SkColorFilter.cpp
index e3d8957947..9470766732 100644
--- a/src/core/SkColorFilter.cpp
+++ b/src/core/SkColorFilter.cpp
@@ -31,6 +31,12 @@ bool SkColorFilter::asComponentTable(SkBitmap*) const {
return false;
}
+#if SK_SUPPORT_GPU
+sk_sp<GrFragmentProcessor> SkColorFilter::asFragmentProcessor(GrContext*) const {
+ return nullptr;
+}
+#endif
+
void SkColorFilter::filterSpan4f(const SkPM4f[], int count, SkPM4f span[]) const {
const int N = 128;
SkPMColor tmp[N];
@@ -99,13 +105,13 @@ public:
#endif
#if SK_SUPPORT_GPU
- const GrFragmentProcessor* asFragmentProcessor(GrContext* context) const override {
- SkAutoTUnref<const GrFragmentProcessor> innerFP(fInner->asFragmentProcessor(context));
- SkAutoTUnref<const GrFragmentProcessor> outerFP(fOuter->asFragmentProcessor(context));
+ sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext* context) const override {
+ sk_sp<GrFragmentProcessor> innerFP(fInner->asFragmentProcessor(context));
+ sk_sp<GrFragmentProcessor> outerFP(fOuter->asFragmentProcessor(context));
if (!innerFP || !outerFP) {
return nullptr;
}
- const GrFragmentProcessor* series[] = { innerFP, outerFP };
+ sk_sp<GrFragmentProcessor> series[] = { std::move(innerFP), std::move(outerFP) };
return GrFragmentProcessor::RunInSeries(series, 2);
}
#endif
diff --git a/src/core/SkColorFilterShader.cpp b/src/core/SkColorFilterShader.cpp
index 4ab232aa38..6f9fc97819 100644
--- a/src/core/SkColorFilterShader.cpp
+++ b/src/core/SkColorFilterShader.cpp
@@ -97,27 +97,25 @@ void SkColorFilterShader::FilterShaderContext::shadeSpan4f(int x, int y, SkPM4f
#if SK_SUPPORT_GPU
/////////////////////////////////////////////////////////////////////
-const GrFragmentProcessor* SkColorFilterShader::asFragmentProcessor(
+sk_sp<GrFragmentProcessor> SkColorFilterShader::asFragmentProcessor(
GrContext* context,
const SkMatrix& viewM,
const SkMatrix* localMatrix,
SkFilterQuality fq,
SkSourceGammaTreatment gammaTreatment) const {
- SkAutoTUnref<const GrFragmentProcessor> fp1(fShader->asFragmentProcessor(context, viewM,
- localMatrix, fq,
- gammaTreatment));
- if (!fp1.get()) {
+ sk_sp<GrFragmentProcessor> fp1(fShader->asFragmentProcessor(context, viewM, localMatrix, fq,
+ gammaTreatment));
+ if (!fp1) {
return nullptr;
}
- SkAutoTUnref<const GrFragmentProcessor> fp2(fFilter->asFragmentProcessor(context));
- if (!fp2.get()) {
- return fp1.release();
+ sk_sp<GrFragmentProcessor> fp2(fFilter->asFragmentProcessor(context));
+ if (!fp2) {
+ return fp1;
}
- const GrFragmentProcessor* fpSeries[] = { fp1.get(), fp2.get() };
-
+ sk_sp<GrFragmentProcessor> fpSeries[] = { std::move(fp1), std::move(fp2) };
return GrFragmentProcessor::RunInSeries(fpSeries, 2);
}
#endif
diff --git a/src/core/SkColorFilterShader.h b/src/core/SkColorFilterShader.h
index 01a03f8200..39a62ab066 100644
--- a/src/core/SkColorFilterShader.h
+++ b/src/core/SkColorFilterShader.h
@@ -16,7 +16,7 @@ public:
SkColorFilterShader(sk_sp<SkShader> shader, sk_sp<SkColorFilter> filter);
#if SK_SUPPORT_GPU
- const GrFragmentProcessor* asFragmentProcessor(GrContext*,
+ sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext*,
const SkMatrix& viewM,
const SkMatrix* localMatrix,
SkFilterQuality,
diff --git a/src/core/SkColorMatrixFilterRowMajor255.cpp b/src/core/SkColorMatrixFilterRowMajor255.cpp
index c158a7948f..cdfd1df496 100644
--- a/src/core/SkColorMatrixFilterRowMajor255.cpp
+++ b/src/core/SkColorMatrixFilterRowMajor255.cpp
@@ -8,11 +8,12 @@
#include "SkColorMatrixFilterRowMajor255.h"
#include "SkColorPriv.h"
#include "SkNx.h"
+#include "SkPM4fPriv.h"
#include "SkReadBuffer.h"
-#include "SkWriteBuffer.h"
-#include "SkUnPreMultiply.h"
+#include "SkRefCnt.h"
#include "SkString.h"
-#include "SkPM4fPriv.h"
+#include "SkUnPreMultiply.h"
+#include "SkWriteBuffer.h"
static void transpose(float dst[20], const float src[20]) {
const float* srcR = src + 0;
@@ -247,8 +248,8 @@ SkColorMatrixFilterRowMajor255::makeComposed(sk_sp<SkColorFilter> innerFilter) c
class ColorMatrixEffect : public GrFragmentProcessor {
public:
- static const GrFragmentProcessor* Create(const SkScalar matrix[20]) {
- return new ColorMatrixEffect(matrix);
+ static sk_sp<GrFragmentProcessor> Make(const SkScalar matrix[20]) {
+ return sk_sp<GrFragmentProcessor>(new ColorMatrixEffect(matrix));
}
const char* name() const override { return "Color Matrix"; }
@@ -387,16 +388,16 @@ private:
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(ColorMatrixEffect);
-const GrFragmentProcessor* ColorMatrixEffect::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> ColorMatrixEffect::TestCreate(GrProcessorTestData* d) {
SkScalar colorMatrix[20];
for (size_t i = 0; i < SK_ARRAY_COUNT(colorMatrix); ++i) {
colorMatrix[i] = d->fRandom->nextSScalar1();
}
- return ColorMatrixEffect::Create(colorMatrix);
+ return ColorMatrixEffect::Make(colorMatrix);
}
-const GrFragmentProcessor* SkColorMatrixFilterRowMajor255::asFragmentProcessor(GrContext*) const {
- return ColorMatrixEffect::Create(fMatrix);
+sk_sp<GrFragmentProcessor> SkColorMatrixFilterRowMajor255::asFragmentProcessor(GrContext*) const {
+ return ColorMatrixEffect::Make(fMatrix);
}
#endif
diff --git a/src/core/SkColorMatrixFilterRowMajor255.h b/src/core/SkColorMatrixFilterRowMajor255.h
index 0ad64fa2f0..79709b3282 100644
--- a/src/core/SkColorMatrixFilterRowMajor255.h
+++ b/src/core/SkColorMatrixFilterRowMajor255.h
@@ -25,7 +25,7 @@ public:
sk_sp<SkColorFilter> makeComposed(sk_sp<SkColorFilter>) const override;
#if SK_SUPPORT_GPU
- const GrFragmentProcessor* asFragmentProcessor(GrContext*) const override;
+ sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext*) const override;
#endif
SK_TO_STRING_OVERRIDE()
diff --git a/src/core/SkColorShader.cpp b/src/core/SkColorShader.cpp
index 2c7ee8bf34..83fd239a92 100644
--- a/src/core/SkColorShader.cpp
+++ b/src/core/SkColorShader.cpp
@@ -89,12 +89,12 @@ SkShader::GradientType SkColorShader::asAGradient(GradientInfo* info) const {
#include "SkGr.h"
#include "effects/GrConstColorProcessor.h"
-const GrFragmentProcessor* SkColorShader::asFragmentProcessor(GrContext*, const SkMatrix&,
+sk_sp<GrFragmentProcessor> SkColorShader::asFragmentProcessor(GrContext*, const SkMatrix&,
const SkMatrix*,
SkFilterQuality,
SkSourceGammaTreatment) const {
GrColor color = SkColorToPremulGrColor(fColor);
- return GrConstColorProcessor::Create(color, GrConstColorProcessor::kModulateA_InputMode);
+ return GrConstColorProcessor::Make(color, GrConstColorProcessor::kModulateA_InputMode);
}
#endif
@@ -217,13 +217,13 @@ SkShader::GradientType SkColor4Shader::asAGradient(GradientInfo* info) const {
#include "SkGr.h"
#include "effects/GrConstColorProcessor.h"
-const GrFragmentProcessor* SkColor4Shader::asFragmentProcessor(GrContext*, const SkMatrix&,
+sk_sp<GrFragmentProcessor> SkColor4Shader::asFragmentProcessor(GrContext*, const SkMatrix&,
const SkMatrix*,
SkFilterQuality,
SkSourceGammaTreatment) const {
// TODO: how to communicate color4f to Gr
GrColor color = SkColorToPremulGrColor(fCachedByteColor);
- return GrConstColorProcessor::Create(color, GrConstColorProcessor::kModulateA_InputMode);
+ return GrConstColorProcessor::Make(color, GrConstColorProcessor::kModulateA_InputMode);
}
#endif
diff --git a/src/core/SkColorShader.h b/src/core/SkColorShader.h
index 841974204a..9e0c542ce8 100644
--- a/src/core/SkColorShader.h
+++ b/src/core/SkColorShader.h
@@ -49,7 +49,7 @@ public:
GradientType asAGradient(GradientInfo* info) const override;
#if SK_SUPPORT_GPU
- const GrFragmentProcessor* asFragmentProcessor(GrContext*, const SkMatrix& viewM,
+ sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext*, const SkMatrix& viewM,
const SkMatrix*, SkFilterQuality,
SkSourceGammaTreatment) const override;
#endif
@@ -104,7 +104,7 @@ public:
GradientType asAGradient(GradientInfo* info) const override;
#if SK_SUPPORT_GPU
- const GrFragmentProcessor* asFragmentProcessor(GrContext*, const SkMatrix& viewM,
+ sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext*, const SkMatrix& viewM,
const SkMatrix*, SkFilterQuality,
SkSourceGammaTreatment) const override;
#endif
diff --git a/src/core/SkComposeShader.cpp b/src/core/SkComposeShader.cpp
index 13569f1b48..e9f3f4c618 100644
--- a/src/core/SkComposeShader.cpp
+++ b/src/core/SkComposeShader.cpp
@@ -183,7 +183,7 @@ void SkComposeShader::ComposeShaderContext::shadeSpan(int x, int y, SkPMColor re
/////////////////////////////////////////////////////////////////////
-const GrFragmentProcessor* SkComposeShader::asFragmentProcessor(
+sk_sp<GrFragmentProcessor> SkComposeShader::asFragmentProcessor(
GrContext* context,
const SkMatrix& viewM,
const SkMatrix* localMatrix,
@@ -197,8 +197,8 @@ const GrFragmentProcessor* SkComposeShader::asFragmentProcessor(
switch (mode) {
case SkXfermode::kClear_Mode:
- return GrConstColorProcessor::Create(GrColor_TRANSPARENT_BLACK,
- GrConstColorProcessor::kIgnore_InputMode);
+ return GrConstColorProcessor::Make(GrColor_TRANSPARENT_BLACK,
+ GrConstColorProcessor::kIgnore_InputMode);
break;
case SkXfermode::kSrc_Mode:
return fShaderB->asFragmentProcessor(context, viewM, localMatrix, fq, gammaTreatment);
@@ -207,17 +207,18 @@ const GrFragmentProcessor* SkComposeShader::asFragmentProcessor(
return fShaderA->asFragmentProcessor(context, viewM, localMatrix, fq, gammaTreatment);
break;
default:
- SkAutoTUnref<const GrFragmentProcessor> fpA(fShaderA->asFragmentProcessor(context,
- viewM, localMatrix, fq, gammaTreatment));
- if (!fpA.get()) {
+ sk_sp<GrFragmentProcessor> fpA(fShaderA->asFragmentProcessor(context,
+ viewM, localMatrix, fq, gammaTreatment));
+ if (!fpA) {
return nullptr;
}
- SkAutoTUnref<const GrFragmentProcessor> fpB(fShaderB->asFragmentProcessor(context,
- viewM, localMatrix, fq, gammaTreatment));
- if (!fpB.get()) {
+ sk_sp<GrFragmentProcessor> fpB(fShaderB->asFragmentProcessor(context,
+ viewM, localMatrix, fq, gammaTreatment));
+ if (!fpB) {
return nullptr;
}
- return GrXfermodeFragmentProcessor::CreateFromTwoProcessors(fpB, fpA, mode);
+ return GrXfermodeFragmentProcessor::MakeFromTwoProcessors(std::move(fpB),
+ std::move(fpA), mode);
}
}
#endif
diff --git a/src/core/SkComposeShader.h b/src/core/SkComposeShader.h
index ed89b88e88..dcd43d3ab7 100644
--- a/src/core/SkComposeShader.h
+++ b/src/core/SkComposeShader.h
@@ -35,11 +35,11 @@ public:
{}
#if SK_SUPPORT_GPU
- const GrFragmentProcessor* asFragmentProcessor(GrContext*,
- const SkMatrix& viewM,
- const SkMatrix* localMatrix,
- SkFilterQuality,
- SkSourceGammaTreatment) const override;
+ sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext*,
+ const SkMatrix& viewM,
+ const SkMatrix* localMatrix,
+ SkFilterQuality,
+ SkSourceGammaTreatment) const override;
#endif
class ComposeShaderContext : public SkShader::Context {
diff --git a/src/core/SkImageFilter.cpp b/src/core/SkImageFilter.cpp
index c7a570121b..9e215258fd 100644
--- a/src/core/SkImageFilter.cpp
+++ b/src/core/SkImageFilter.cpp
@@ -277,7 +277,7 @@ sk_sp<SkSpecialImage> SkImageFilter::DrawWithFP(GrContext* context,
sk_sp<GrFragmentProcessor> fp,
const SkIRect& bounds) {
GrPaint paint;
- paint.addColorFragmentProcessor(fp.get());
+ paint.addColorFragmentProcessor(std::move(fp));
paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
sk_sp<GrDrawContext> drawContext(context->newDrawContext(SkBackingFit::kApprox,
diff --git a/src/core/SkLightingShader.cpp b/src/core/SkLightingShader.cpp
index 542d0f3e67..a2ce52fe28 100644
--- a/src/core/SkLightingShader.cpp
+++ b/src/core/SkLightingShader.cpp
@@ -72,7 +72,7 @@ public:
bool isOpaque() const override;
#if SK_SUPPORT_GPU
- const GrFragmentProcessor* asFragmentProcessor(GrContext*,
+ sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext*,
const SkMatrix& viewM,
const SkMatrix* localMatrix,
SkFilterQuality,
@@ -350,7 +350,7 @@ static bool make_mat(const SkBitmap& bm,
return true;
}
-const GrFragmentProcessor* SkLightingShaderImpl::asFragmentProcessor(
+sk_sp<GrFragmentProcessor> SkLightingShaderImpl::asFragmentProcessor(
GrContext* context,
const SkMatrix& viewM,
const SkMatrix* localMatrix,
@@ -404,10 +404,10 @@ const GrFragmentProcessor* SkLightingShaderImpl::asFragmentProcessor(
return nullptr;
}
- SkAutoTUnref<const GrFragmentProcessor> inner (
+ sk_sp<GrFragmentProcessor> inner (
new LightingFP(diffuseTexture, normalTexture, diffM, normM, diffParams, normParams, fLights,
fInvNormRotation));
- return GrFragmentProcessor::MulOutputByInputAlpha(inner);
+ return GrFragmentProcessor::MulOutputByInputAlpha(std::move(inner));
}
#endif
diff --git a/src/core/SkLocalMatrixShader.cpp b/src/core/SkLocalMatrixShader.cpp
index ea4db5352c..cb85019827 100644
--- a/src/core/SkLocalMatrixShader.cpp
+++ b/src/core/SkLocalMatrixShader.cpp
@@ -7,6 +7,23 @@
#include "SkLocalMatrixShader.h"
+#if SK_SUPPORT_GPU
+#include "GrFragmentProcessor.h"
+#endif
+
+#if SK_SUPPORT_GPU
+sk_sp<GrFragmentProcessor> SkLocalMatrixShader::asFragmentProcessor(
+ GrContext* context, const SkMatrix& viewM,
+ const SkMatrix* localMatrix, SkFilterQuality fq,
+ SkSourceGammaTreatment gammaTreatment) const {
+ SkMatrix tmp = this->getLocalMatrix();
+ if (localMatrix) {
+ tmp.preConcat(*localMatrix);
+ }
+ return fProxyShader->asFragmentProcessor(context, viewM, &tmp, fq, gammaTreatment);
+}
+#endif
+
sk_sp<SkFlattenable> SkLocalMatrixShader::CreateProc(SkReadBuffer& buffer) {
SkMatrix lm;
buffer.readMatrix(&lm);
diff --git a/src/core/SkLocalMatrixShader.h b/src/core/SkLocalMatrixShader.h
index 3d590e43e6..ea784190b4 100644
--- a/src/core/SkLocalMatrixShader.h
+++ b/src/core/SkLocalMatrixShader.h
@@ -12,6 +12,8 @@
#include "SkReadBuffer.h"
#include "SkWriteBuffer.h"
+class GrFragmentProcessor;
+
class SkLocalMatrixShader : public SkShader {
public:
SkLocalMatrixShader(SkShader* proxy, const SkMatrix& localMatrix)
@@ -24,16 +26,10 @@ public:
}
#if SK_SUPPORT_GPU
- const GrFragmentProcessor* asFragmentProcessor(
+ sk_sp<GrFragmentProcessor> asFragmentProcessor(
GrContext* context, const SkMatrix& viewM,
const SkMatrix* localMatrix, SkFilterQuality fq,
- SkSourceGammaTreatment gammaTreatment) const override {
- SkMatrix tmp = this->getLocalMatrix();
- if (localMatrix) {
- tmp.preConcat(*localMatrix);
- }
- return fProxyShader->asFragmentProcessor(context, viewM, &tmp, fq, gammaTreatment);
- }
+ SkSourceGammaTreatment gammaTreatment) const override;
#endif
SkShader* refAsALocalMatrixShader(SkMatrix* localMatrix) const override {
diff --git a/src/core/SkModeColorFilter.cpp b/src/core/SkModeColorFilter.cpp
index eacd261b5c..ba3b50d763 100644
--- a/src/core/SkModeColorFilter.cpp
+++ b/src/core/SkModeColorFilter.cpp
@@ -91,16 +91,16 @@ sk_sp<SkFlattenable> SkModeColorFilter::CreateProc(SkReadBuffer& buffer) {
#include "effects/GrConstColorProcessor.h"
#include "SkGr.h"
-const GrFragmentProcessor* SkModeColorFilter::asFragmentProcessor(GrContext*) const {
+sk_sp<GrFragmentProcessor> SkModeColorFilter::asFragmentProcessor(GrContext*) const {
if (SkXfermode::kDst_Mode == fMode) {
return nullptr;
}
- SkAutoTUnref<const GrFragmentProcessor> constFP(
- GrConstColorProcessor::Create(SkColorToPremulGrColor(fColor),
- GrConstColorProcessor::kIgnore_InputMode));
- const GrFragmentProcessor* fp =
- GrXfermodeFragmentProcessor::CreateFromSrcProcessor(constFP, fMode);
+ sk_sp<GrFragmentProcessor> constFP(
+ GrConstColorProcessor::Make(SkColorToPremulGrColor(fColor),
+ GrConstColorProcessor::kIgnore_InputMode));
+ sk_sp<GrFragmentProcessor> fp(
+ GrXfermodeFragmentProcessor::MakeFromSrcProcessor(std::move(constFP), fMode));
if (!fp) {
return nullptr;
}
diff --git a/src/core/SkModeColorFilter.h b/src/core/SkModeColorFilter.h
index d73cab7932..01d1eaa347 100644
--- a/src/core/SkModeColorFilter.h
+++ b/src/core/SkModeColorFilter.h
@@ -36,7 +36,7 @@ public:
#endif
#if SK_SUPPORT_GPU
- const GrFragmentProcessor* asFragmentProcessor(GrContext*) const override;
+ sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext*) const override;
#endif
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkModeColorFilter)
diff --git a/src/core/SkPictureShader.cpp b/src/core/SkPictureShader.cpp
index a880db3536..a6186e6c7d 100644
--- a/src/core/SkPictureShader.cpp
+++ b/src/core/SkPictureShader.cpp
@@ -318,7 +318,7 @@ void SkPictureShader::toString(SkString* str) const {
#endif
#if SK_SUPPORT_GPU
-const GrFragmentProcessor* SkPictureShader::asFragmentProcessor(
+sk_sp<GrFragmentProcessor> SkPictureShader::asFragmentProcessor(
GrContext* context, const SkMatrix& viewM,
const SkMatrix* localMatrix,
SkFilterQuality fq,
diff --git a/src/core/SkPictureShader.h b/src/core/SkPictureShader.h
index 01a66ec6ea..11bec1afc7 100644
--- a/src/core/SkPictureShader.h
+++ b/src/core/SkPictureShader.h
@@ -28,7 +28,7 @@ public:
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPictureShader)
#if SK_SUPPORT_GPU
- const GrFragmentProcessor* asFragmentProcessor(GrContext*,
+ sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext*,
const SkMatrix& viewM,
const SkMatrix*,
SkFilterQuality,
diff --git a/src/core/SkShader.cpp b/src/core/SkShader.cpp
index 2ec3b0b661..1ab4ea7ed2 100644
--- a/src/core/SkShader.cpp
+++ b/src/core/SkShader.cpp
@@ -18,6 +18,10 @@
#include "SkShader.h"
#include "SkWriteBuffer.h"
+#if SK_SUPPORT_GPU
+#include "GrFragmentProcessor.h"
+#endif
+
//#define SK_TRACK_SHADER_LIFETIME
#ifdef SK_TRACK_SHADER_LIFETIME
@@ -220,11 +224,13 @@ SkShader::GradientType SkShader::asAGradient(GradientInfo* info) const {
return kNone_GradientType;
}
-const GrFragmentProcessor* SkShader::asFragmentProcessor(GrContext*, const SkMatrix&,
+#if SK_SUPPORT_GPU
+sk_sp<GrFragmentProcessor> SkShader::asFragmentProcessor(GrContext*, const SkMatrix&,
const SkMatrix*, SkFilterQuality,
- SkSourceGammaTreatment) const {
+ SkSourceGammaTreatment) const {
return nullptr;
}
+#endif
SkShader* SkShader::refAsALocalMatrixShader(SkMatrix*) const {
return nullptr;
diff --git a/src/core/SkXfermode.cpp b/src/core/SkXfermode.cpp
index b6d23888a7..e91f53a6cc 100644
--- a/src/core/SkXfermode.cpp
+++ b/src/core/SkXfermode.cpp
@@ -16,6 +16,13 @@
#include "SkWriteBuffer.h"
#include "SkPM4f.h"
+#if SK_SUPPORT_GPU
+#include "GrFragmentProcessor.h"
+#include "effects/GrCustomXfermode.h"
+#include "effects/GrPorterDuffXferProcessor.h"
+#include "effects/GrXfermodeFragmentProcessor.h"
+#endif
+
#define SkAlphaMulAlpha(a, b) SkMulDiv255Round(a, b)
static inline unsigned saturated_add(unsigned a, unsigned b) {
@@ -985,15 +992,15 @@ bool SkXfermode::asMode(Mode* mode) const {
}
#if SK_SUPPORT_GPU
-const GrFragmentProcessor* SkXfermode::getFragmentProcessorForImageFilter(
- const GrFragmentProcessor*) const {
+sk_sp<GrFragmentProcessor> SkXfermode::makeFragmentProcessorForImageFilter(
+ sk_sp<GrFragmentProcessor>) const {
// This should never be called.
// TODO: make pure virtual in SkXfermode once Android update lands
SkASSERT(0);
return nullptr;
}
-GrXPFactory* SkXfermode::asXPFactory() const {
+sk_sp<GrXPFactory> SkXfermode::asXPFactory() const {
// This should never be called.
// TODO: make pure virtual in SkXfermode once Android update lands
SkASSERT(0);
@@ -1240,25 +1247,21 @@ void SkProcCoeffXfermode::xferA8(SkAlpha* SK_RESTRICT dst,
}
#if SK_SUPPORT_GPU
-#include "effects/GrCustomXfermode.h"
-#include "effects/GrPorterDuffXferProcessor.h"
-#include "effects/GrXfermodeFragmentProcessor.h"
-
-const GrFragmentProcessor* SkProcCoeffXfermode::getFragmentProcessorForImageFilter(
- const GrFragmentProcessor* dst) const {
+sk_sp<GrFragmentProcessor> SkProcCoeffXfermode::makeFragmentProcessorForImageFilter(
+ sk_sp<GrFragmentProcessor> dst) const {
SkASSERT(dst);
- return GrXfermodeFragmentProcessor::CreateFromDstProcessor(dst, fMode);
+ return GrXfermodeFragmentProcessor::MakeFromDstProcessor(std::move(dst), fMode);
}
-GrXPFactory* SkProcCoeffXfermode::asXPFactory() const {
+sk_sp<GrXPFactory> SkProcCoeffXfermode::asXPFactory() const {
if (CANNOT_USE_COEFF != fSrcCoeff) {
- GrXPFactory* result = GrPorterDuffXPFactory::Create(fMode);
+ sk_sp<GrXPFactory> result(GrPorterDuffXPFactory::Make(fMode));
SkASSERT(result);
return result;
}
SkASSERT(GrCustomXfermode::IsSupportedMode(fMode));
- return GrCustomXfermode::CreateXPFactory(fMode);
+ return GrCustomXfermode::MakeXPFactory(fMode);
}
#endif
diff --git a/src/core/SkXfermode_proccoeff.h b/src/core/SkXfermode_proccoeff.h
index 3b45594867..357de4324c 100644
--- a/src/core/SkXfermode_proccoeff.h
+++ b/src/core/SkXfermode_proccoeff.h
@@ -45,9 +45,9 @@ public:
bool isOpaque(SkXfermode::SrcColorOpacity opacityType) const override;
#if SK_SUPPORT_GPU
- const GrFragmentProcessor* getFragmentProcessorForImageFilter(
- const GrFragmentProcessor*) const override;
- GrXPFactory* asXPFactory() const override;
+ sk_sp<GrFragmentProcessor> makeFragmentProcessorForImageFilter(
+ sk_sp<GrFragmentProcessor>) const override;
+ sk_sp<GrXPFactory> asXPFactory() const override;
#endif
SK_TO_STRING_OVERRIDE()
diff --git a/src/effects/GrAlphaThresholdFragmentProcessor.cpp b/src/effects/GrAlphaThresholdFragmentProcessor.cpp
index 143798990f..03a4515191 100644
--- a/src/effects/GrAlphaThresholdFragmentProcessor.cpp
+++ b/src/effects/GrAlphaThresholdFragmentProcessor.cpp
@@ -11,6 +11,7 @@
#include "GrInvariantOutput.h"
#include "GrTextureAccess.h"
+#include "SkRefCnt.h"
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
@@ -144,7 +145,7 @@ void GrGLAlphaThresholdFragmentProcessor::onSetData(const GrGLSLProgramDataManag
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrAlphaThresholdFragmentProcessor);
-const GrFragmentProcessor* GrAlphaThresholdFragmentProcessor::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> GrAlphaThresholdFragmentProcessor::TestCreate(GrProcessorTestData* d) {
GrTexture* bmpTex = d->fTextures[GrProcessorUnitTest::kSkiaPMTextureIdx];
GrTexture* maskTex = d->fTextures[GrProcessorUnitTest::kAlphaTextureIdx];
float innerThresh = d->fRandom->nextUScalar1();
@@ -158,7 +159,7 @@ const GrFragmentProcessor* GrAlphaThresholdFragmentProcessor::TestCreate(GrProce
SkIRect bounds = SkIRect::MakeXYWH(x, y, width, height);
return GrAlphaThresholdFragmentProcessor::Make(bmpTex, maskTex,
innerThresh, outerThresh,
- bounds).release();
+ bounds);
}
///////////////////////////////////////////////////////////////////////////////
diff --git a/src/effects/GrCircleBlurFragmentProcessor.cpp b/src/effects/GrCircleBlurFragmentProcessor.cpp
index bd8adeee81..e5c0299856 100644
--- a/src/effects/GrCircleBlurFragmentProcessor.cpp
+++ b/src/effects/GrCircleBlurFragmentProcessor.cpp
@@ -289,11 +289,11 @@ GrTexture* GrCircleBlurFragmentProcessor::CreateCircleBlurProfileTexture(
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrCircleBlurFragmentProcessor);
-const GrFragmentProcessor* GrCircleBlurFragmentProcessor::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> GrCircleBlurFragmentProcessor::TestCreate(GrProcessorTestData* d) {
SkScalar wh = d->fRandom->nextRangeScalar(100.f, 1000.f);
SkScalar sigma = d->fRandom->nextRangeF(1.f,10.f);
SkRect circle = SkRect::MakeWH(wh, wh);
- return GrCircleBlurFragmentProcessor::Create(d->fContext->textureProvider(), circle, sigma);
+ return GrCircleBlurFragmentProcessor::Make(d->fContext->textureProvider(), circle, sigma);
}
#endif
diff --git a/src/effects/GrCircleBlurFragmentProcessor.h b/src/effects/GrCircleBlurFragmentProcessor.h
index ca12db7f60..6dc599b7bb 100644
--- a/src/effects/GrCircleBlurFragmentProcessor.h
+++ b/src/effects/GrCircleBlurFragmentProcessor.h
@@ -34,8 +34,8 @@ public:
return str;
}
- static const GrFragmentProcessor* Create(GrTextureProvider*textureProvider,
- const SkRect& circle, float sigma) {
+ static sk_sp<GrFragmentProcessor> Make(GrTextureProvider*textureProvider,
+ const SkRect& circle, float sigma) {
float offset;
SkAutoTUnref<GrTexture> blurProfile(CreateCircleBlurProfileTexture(textureProvider,
@@ -45,7 +45,8 @@ public:
if (!blurProfile) {
return nullptr;
}
- return new GrCircleBlurFragmentProcessor(circle, sigma, offset, blurProfile);
+ return sk_sp<GrFragmentProcessor>(
+ new GrCircleBlurFragmentProcessor(circle, sigma, offset, blurProfile));
}
const SkRect& circle() const { return fCircle; }
diff --git a/src/effects/SkArithmeticMode.cpp b/src/effects/SkArithmeticMode.cpp
index e926f1bc9a..bf17bb833d 100644
--- a/src/effects/SkArithmeticMode.cpp
+++ b/src/effects/SkArithmeticMode.cpp
@@ -33,9 +33,9 @@ public:
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkArithmeticMode_scalar)
#if SK_SUPPORT_GPU
- const GrFragmentProcessor* getFragmentProcessorForImageFilter(
- const GrFragmentProcessor* dst) const override;
- GrXPFactory* asXPFactory() const override;
+ sk_sp<GrFragmentProcessor> makeFragmentProcessorForImageFilter(
+ sk_sp<GrFragmentProcessor> dst) const override;
+ sk_sp<GrXPFactory> asXPFactory() const override;
#endif
private:
@@ -127,22 +127,22 @@ sk_sp<SkXfermode> SkArithmeticMode::Make(SkScalar k1, SkScalar k2, SkScalar k3,
//////////////////////////////////////////////////////////////////////////////
#if SK_SUPPORT_GPU
-const GrFragmentProcessor* SkArithmeticMode_scalar::getFragmentProcessorForImageFilter(
- const GrFragmentProcessor* dst) const {
- return GrArithmeticFP::Create(SkScalarToFloat(fK[0]),
- SkScalarToFloat(fK[1]),
- SkScalarToFloat(fK[2]),
- SkScalarToFloat(fK[3]),
- fEnforcePMColor,
- dst);
+sk_sp<GrFragmentProcessor> SkArithmeticMode_scalar::makeFragmentProcessorForImageFilter(
+ sk_sp<GrFragmentProcessor> dst) const {
+ return GrArithmeticFP::Make(SkScalarToFloat(fK[0]),
+ SkScalarToFloat(fK[1]),
+ SkScalarToFloat(fK[2]),
+ SkScalarToFloat(fK[3]),
+ fEnforcePMColor,
+ std::move(dst));
}
-GrXPFactory* SkArithmeticMode_scalar::asXPFactory() const {
- return GrArithmeticXPFactory::Create(SkScalarToFloat(fK[0]),
- SkScalarToFloat(fK[1]),
- SkScalarToFloat(fK[2]),
- SkScalarToFloat(fK[3]),
- fEnforcePMColor);
+sk_sp<GrXPFactory> SkArithmeticMode_scalar::asXPFactory() const {
+ return GrArithmeticXPFactory::Make(SkScalarToFloat(fK[0]),
+ SkScalarToFloat(fK[1]),
+ SkScalarToFloat(fK[2]),
+ SkScalarToFloat(fK[3]),
+ fEnforcePMColor);
}
#endif
diff --git a/src/effects/SkArithmeticMode_gpu.cpp b/src/effects/SkArithmeticMode_gpu.cpp
index 7fb6d66050..50c46ad243 100644
--- a/src/effects/SkArithmeticMode_gpu.cpp
+++ b/src/effects/SkArithmeticMode_gpu.cpp
@@ -85,12 +85,12 @@ private:
///////////////////////////////////////////////////////////////////////////////
GrArithmeticFP::GrArithmeticFP(float k1, float k2, float k3, float k4, bool enforcePMColor,
- const GrFragmentProcessor* dst)
+ sk_sp<GrFragmentProcessor> dst)
: fK1(k1), fK2(k2), fK3(k3), fK4(k4), fEnforcePMColor(enforcePMColor) {
this->initClassID<GrArithmeticFP>();
SkASSERT(dst);
- SkDEBUGCODE(int dstIndex = )this->registerChildProcessor(dst);
+ SkDEBUGCODE(int dstIndex = )this->registerChildProcessor(std::move(dst));
SkASSERT(0 == dstIndex);
}
@@ -118,15 +118,15 @@ void GrArithmeticFP::onComputeInvariantOutput(GrInvariantOutput* inout) const {
///////////////////////////////////////////////////////////////////////////////
-const GrFragmentProcessor* GrArithmeticFP::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> GrArithmeticFP::TestCreate(GrProcessorTestData* d) {
float k1 = d->fRandom->nextF();
float k2 = d->fRandom->nextF();
float k3 = d->fRandom->nextF();
float k4 = d->fRandom->nextF();
bool enforcePMColor = d->fRandom->nextBool();
- SkAutoTUnref<const GrFragmentProcessor> dst(GrProcessorUnitTest::CreateChildFP(d));
- return new GrArithmeticFP(k1, k2, k3, k4, enforcePMColor, dst);
+ sk_sp<GrFragmentProcessor> dst(GrProcessorUnitTest::MakeChildFP(d));
+ return GrArithmeticFP::Make(k1, k2, k3, k4, enforcePMColor, std::move(dst));
}
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrArithmeticFP);
@@ -283,14 +283,14 @@ void GrArithmeticXPFactory::getInvariantBlendedColor(const GrProcOptInfo& colorP
GR_DEFINE_XP_FACTORY_TEST(GrArithmeticXPFactory);
-const GrXPFactory* GrArithmeticXPFactory::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrXPFactory> GrArithmeticXPFactory::TestCreate(GrProcessorTestData* d) {
float k1 = d->fRandom->nextF();
float k2 = d->fRandom->nextF();
float k3 = d->fRandom->nextF();
float k4 = d->fRandom->nextF();
bool enforcePMColor = d->fRandom->nextBool();
- return GrArithmeticXPFactory::Create(k1, k2, k3, k4, enforcePMColor);
+ return GrArithmeticXPFactory::Make(k1, k2, k3, k4, enforcePMColor);
}
#endif
diff --git a/src/effects/SkArithmeticMode_gpu.h b/src/effects/SkArithmeticMode_gpu.h
index b8a40cf827..98cbaf90a5 100644
--- a/src/effects/SkArithmeticMode_gpu.h
+++ b/src/effects/SkArithmeticMode_gpu.h
@@ -31,9 +31,10 @@ class GrGLArtithmeticFP;
class GrArithmeticFP : public GrFragmentProcessor {
public:
- static const GrFragmentProcessor* Create(float k1, float k2, float k3, float k4,
- bool enforcePMColor, const GrFragmentProcessor* dst) {
- return new GrArithmeticFP(k1, k2, k3, k4, enforcePMColor, dst);
+ static sk_sp<GrFragmentProcessor> Make(float k1, float k2, float k3, float k4,
+ bool enforcePMColor, sk_sp<GrFragmentProcessor> dst) {
+ return sk_sp<GrFragmentProcessor>(new GrArithmeticFP(k1, k2, k3, k4, enforcePMColor,
+ std::move(dst)));
}
~GrArithmeticFP() override {};
@@ -62,7 +63,7 @@ private:
void onComputeInvariantOutput(GrInvariantOutput* inout) const override;
GrArithmeticFP(float k1, float k2, float k3, float k4, bool enforcePMColor,
- const GrFragmentProcessor* dst);
+ sk_sp<GrFragmentProcessor> dst);
float fK1, fK2, fK3, fK4;
bool fEnforcePMColor;
@@ -77,8 +78,8 @@ private:
class GrArithmeticXPFactory : public GrXPFactory {
public:
- static GrXPFactory* Create(float k1, float k2, float k3, float k4, bool enforcePMColor) {
- return new GrArithmeticXPFactory(k1, k2, k3, k4, enforcePMColor);
+ static sk_sp<GrXPFactory> Make(float k1, float k2, float k3, float k4, bool enforcePMColor) {
+ return sk_sp<GrXPFactory>(new GrArithmeticXPFactory(k1, k2, k3, k4, enforcePMColor));
}
void getInvariantBlendedColor(const GrProcOptInfo& colorPOI,
diff --git a/src/effects/SkBlurMaskFilter.cpp b/src/effects/SkBlurMaskFilter.cpp
index 969afc12df..1d277f8d76 100644
--- a/src/effects/SkBlurMaskFilter.cpp
+++ b/src/effects/SkBlurMaskFilter.cpp
@@ -607,8 +607,8 @@ public:
const char* name() const override { return "RectBlur"; }
- static GrFragmentProcessor* Create(GrTextureProvider *textureProvider,
- const SkRect& rect, float sigma) {
+ static sk_sp<GrFragmentProcessor> Make(GrTextureProvider *textureProvider,
+ const SkRect& rect, float sigma) {
int doubleProfileSize = SkScalarCeilToInt(12*sigma);
if (doubleProfileSize >= rect.width() || doubleProfileSize >= rect.height()) {
@@ -637,11 +637,11 @@ public:
SkScalarAbs(rect.width()) > kMAX_BLUR_COORD ||
SkScalarAbs(rect.height()) > kMAX_BLUR_COORD) {
precision = kHigh_GrSLPrecision;
- }
- else {
+ } else {
precision = kDefault_GrSLPrecision;
}
- return new GrRectBlurEffect(rect, sigma, blurProfile, precision);
+ return sk_sp<GrFragmentProcessor>(
+ new GrRectBlurEffect(rect, sigma, blurProfile, precision));
}
const SkRect& getRect() const { return fRect; }
@@ -841,12 +841,12 @@ void GrRectBlurEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrRectBlurEffect);
-const GrFragmentProcessor* GrRectBlurEffect::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> GrRectBlurEffect::TestCreate(GrProcessorTestData* d) {
float sigma = d->fRandom->nextRangeF(3,8);
float width = d->fRandom->nextRangeF(200,300);
float height = d->fRandom->nextRangeF(200,300);
- return GrRectBlurEffect::Create(d->fContext->textureProvider(), SkRect::MakeWH(width, height),
- sigma);
+ return GrRectBlurEffect::Make(d->fContext->textureProvider(), SkRect::MakeWH(width, height),
+ sigma);
}
@@ -870,16 +870,16 @@ bool SkBlurMaskFilterImpl::directFilterMaskGPU(GrTextureProvider* texProvider,
SkScalar xformedSigma = this->computeXformedSigma(viewMatrix);
- SkAutoTUnref<const GrFragmentProcessor> fp;
+ sk_sp<GrFragmentProcessor> fp;
SkRect rect;
if (path.isRect(&rect)) {
int pad = SkScalarCeilToInt(6*xformedSigma)/2;
rect.outset(SkIntToScalar(pad), SkIntToScalar(pad));
- fp.reset(GrRectBlurEffect::Create(texProvider, rect, xformedSigma));
+ fp = GrRectBlurEffect::Make(texProvider, rect, xformedSigma);
} else if (path.isOval(&rect) && SkScalarNearlyEqual(rect.width(), rect.height())) {
- fp.reset(GrCircleBlurFragmentProcessor::Create(texProvider, rect, xformedSigma));
+ fp = GrCircleBlurFragmentProcessor::Make(texProvider, rect, xformedSigma);
// expand the rect for the coverage geometry
int pad = SkScalarCeilToInt(6*xformedSigma)/2;
@@ -892,7 +892,7 @@ bool SkBlurMaskFilterImpl::directFilterMaskGPU(GrTextureProvider* texProvider,
return false;
}
- grp->addCoverageFragmentProcessor(fp);
+ grp->addCoverageFragmentProcessor(std::move(fp));
SkMatrix inverse;
if (!viewMatrix.invert(&inverse)) {
@@ -908,7 +908,7 @@ bool SkBlurMaskFilterImpl::directFilterMaskGPU(GrTextureProvider* texProvider,
class GrRRectBlurEffect : public GrFragmentProcessor {
public:
- static const GrFragmentProcessor* Create(GrTextureProvider*, float sigma, const SkRRect&);
+ static sk_sp<GrFragmentProcessor> Make(GrTextureProvider*, float sigma, const SkRRect&);
virtual ~GrRRectBlurEffect() {};
const char* name() const override { return "GrRRectBlur"; }
@@ -938,10 +938,10 @@ private:
};
-const GrFragmentProcessor* GrRRectBlurEffect::Create(GrTextureProvider* texProvider, float sigma,
+sk_sp<GrFragmentProcessor> GrRRectBlurEffect::Make(GrTextureProvider* texProvider, float sigma,
const SkRRect& rrect) {
if (rrect.isCircle()) {
- return GrCircleBlurFragmentProcessor::Create(texProvider, rrect.rect(), sigma);
+ return GrCircleBlurFragmentProcessor::Make(texProvider, rrect.rect(), sigma);
}
if (!rrect.isSimpleCircular()) {
@@ -1014,7 +1014,7 @@ const GrFragmentProcessor* GrRRectBlurEffect::Create(GrTextureProvider* texProvi
}
texProvider->assignUniqueKeyToTexture(key, blurNinePatchTexture);
}
- return new GrRRectBlurEffect(sigma, rrect, blurNinePatchTexture);
+ return sk_sp<GrFragmentProcessor>(new GrRRectBlurEffect(sigma, rrect, blurNinePatchTexture));
}
void GrRRectBlurEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
@@ -1041,14 +1041,14 @@ bool GrRRectBlurEffect::onIsEqual(const GrFragmentProcessor& other) const {
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrRRectBlurEffect);
-const GrFragmentProcessor* GrRRectBlurEffect::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> GrRRectBlurEffect::TestCreate(GrProcessorTestData* d) {
SkScalar w = d->fRandom->nextRangeScalar(100.f, 1000.f);
SkScalar h = d->fRandom->nextRangeScalar(100.f, 1000.f);
SkScalar r = d->fRandom->nextRangeF(1.f, 9.f);
SkScalar sigma = d->fRandom->nextRangeF(1.f,10.f);
SkRRect rrect;
rrect.setRectXY(SkRect::MakeWH(w, h), r, r);
- return GrRRectBlurEffect::Create(d->fContext->textureProvider(), sigma, rrect);
+ return GrRRectBlurEffect::Make(d->fContext->textureProvider(), sigma, rrect);
}
//////////////////////////////////////////////////////////////////////////////
@@ -1174,13 +1174,12 @@ bool SkBlurMaskFilterImpl::directFilterRRectMaskGPU(GrTextureProvider* texProvid
SkRect proxyRect = rrect.rect();
proxyRect.outset(extra, extra);
- SkAutoTUnref<const GrFragmentProcessor> fp(GrRRectBlurEffect::Create(texProvider,
- xformedSigma, rrect));
+ sk_sp<GrFragmentProcessor> fp(GrRRectBlurEffect::Make(texProvider, xformedSigma, rrect));
if (!fp) {
return false;
}
- grp->addCoverageFragmentProcessor(fp);
+ grp->addCoverageFragmentProcessor(std::move(fp));
SkMatrix inverse;
if (!viewMatrix.invert(&inverse)) {
@@ -1262,7 +1261,7 @@ bool SkBlurMaskFilterImpl::filterMaskGPU(GrTexture* src,
SkMatrix matrix;
matrix.setIDiv(src->width(), src->height());
// Blend pathTexture over blurTexture.
- paint.addCoverageFragmentProcessor(GrSimpleTextureEffect::Create(src, matrix))->unref();
+ paint.addCoverageFragmentProcessor(GrSimpleTextureEffect::Make(src, matrix));
if (kInner_SkBlurStyle == fBlurStyle) {
// inner: dst = dst * src
paint.setCoverageSetOpXPFactory(SkRegion::kIntersect_Op);
diff --git a/src/effects/SkColorCubeFilter.cpp b/src/effects/SkColorCubeFilter.cpp
index fdf571cbf3..3eb70d32d0 100644
--- a/src/effects/SkColorCubeFilter.cpp
+++ b/src/effects/SkColorCubeFilter.cpp
@@ -161,8 +161,9 @@ void SkColorCubeFilter::toString(SkString* str) const {
class GrColorCubeEffect : public GrFragmentProcessor {
public:
- static const GrFragmentProcessor* Create(GrTexture* colorCube) {
- return (nullptr != colorCube) ? new GrColorCubeEffect(colorCube) : nullptr;
+ static sk_sp<GrFragmentProcessor> Make(GrTexture* colorCube) {
+ return (nullptr != colorCube) ? sk_sp<GrFragmentProcessor>(new GrColorCubeEffect(colorCube))
+ : nullptr;
}
virtual ~GrColorCubeEffect();
@@ -297,7 +298,7 @@ void GrColorCubeEffect::GLSLProcessor::GenKey(const GrProcessor& proc,
const GrGLSLCaps&, GrProcessorKeyBuilder* b) {
}
-const GrFragmentProcessor* SkColorCubeFilter::asFragmentProcessor(GrContext* context) const {
+sk_sp<GrFragmentProcessor> SkColorCubeFilter::asFragmentProcessor(GrContext* context) const {
static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain();
GrUniqueKey key;
GrUniqueKey::Builder builder(&key, kDomain, 2);
@@ -323,6 +324,6 @@ const GrFragmentProcessor* SkColorCubeFilter::asFragmentProcessor(GrContext* con
}
}
- return GrColorCubeEffect::Create(textureCube);
+ return sk_sp<GrFragmentProcessor>(GrColorCubeEffect::Make(textureCube));
}
#endif
diff --git a/src/effects/SkDisplacementMapEffect.cpp b/src/effects/SkDisplacementMapEffect.cpp
index 541dbbd058..29ce3fef52 100644
--- a/src/effects/SkDisplacementMapEffect.cpp
+++ b/src/effects/SkDisplacementMapEffect.cpp
@@ -214,13 +214,14 @@ void SkDisplacementMapEffect::flatten(SkWriteBuffer& buffer) const {
#if SK_SUPPORT_GPU
class GrDisplacementMapEffect : public GrFragmentProcessor {
public:
- static GrFragmentProcessor* Create(
+ static sk_sp<GrFragmentProcessor> Make(
SkDisplacementMapEffect::ChannelSelectorType xChannelSelector,
SkDisplacementMapEffect::ChannelSelectorType yChannelSelector, SkVector scale,
GrTexture* displacement, const SkMatrix& offsetMatrix, GrTexture* color,
const SkISize& colorDimensions) {
- return new GrDisplacementMapEffect(xChannelSelector, yChannelSelector, scale, displacement,
- offsetMatrix, color, colorDimensions);
+ return sk_sp<GrFragmentProcessor>(
+ new GrDisplacementMapEffect(xChannelSelector, yChannelSelector, scale, displacement,
+ offsetMatrix, color, colorDimensions));
}
virtual ~GrDisplacementMapEffect();
@@ -323,14 +324,13 @@ sk_sp<SkSpecialImage> SkDisplacementMapEffect::onFilterImage(SkSpecialImage* sou
SkIntToScalar(colorOffset.fY - displOffset.fY));
paint.addColorFragmentProcessor(
- GrDisplacementMapEffect::Create(fXChannelSelector,
- fYChannelSelector,
- scale,
- displTexture.get(),
- offsetMatrix,
- colorTexture.get(),
- SkISize::Make(color->width(),
- color->height())))->unref();
+ GrDisplacementMapEffect::Make(fXChannelSelector,
+ fYChannelSelector,
+ scale,
+ displTexture.get(),
+ offsetMatrix,
+ colorTexture.get(),
+ SkISize::Make(color->width(), color->height())));
paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
SkMatrix matrix;
matrix.setTranslate(-SkIntToScalar(colorBounds.x()), -SkIntToScalar(colorBounds.y()));
@@ -504,7 +504,7 @@ void GrDisplacementMapEffect::onComputeInvariantOutput(GrInvariantOutput* inout)
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrDisplacementMapEffect);
-const GrFragmentProcessor* GrDisplacementMapEffect::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> GrDisplacementMapEffect::TestCreate(GrProcessorTestData* d) {
int texIdxDispl = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx :
GrProcessorUnitTest::kAlphaTextureIdx;
int texIdxColor = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx :
@@ -521,9 +521,9 @@ const GrFragmentProcessor* GrDisplacementMapEffect::TestCreate(GrProcessorTestDa
SkISize colorDimensions;
colorDimensions.fWidth = d->fRandom->nextRangeU(0, d->fTextures[texIdxColor]->width());
colorDimensions.fHeight = d->fRandom->nextRangeU(0, d->fTextures[texIdxColor]->height());
- return GrDisplacementMapEffect::Create(xChannelSelector, yChannelSelector, scale,
- d->fTextures[texIdxDispl], SkMatrix::I(),
- d->fTextures[texIdxColor], colorDimensions);
+ return GrDisplacementMapEffect::Make(xChannelSelector, yChannelSelector, scale,
+ d->fTextures[texIdxDispl], SkMatrix::I(),
+ d->fTextures[texIdxColor], colorDimensions);
}
///////////////////////////////////////////////////////////////////////////////
diff --git a/src/effects/SkGpuBlurUtils.cpp b/src/effects/SkGpuBlurUtils.cpp
index b377b417c5..9bc1265276 100644
--- a/src/effects/SkGpuBlurUtils.cpp
+++ b/src/effects/SkGpuBlurUtils.cpp
@@ -76,9 +76,9 @@ static void convolve_gaussian_1d(GrDrawContext* drawContext,
float bounds[2]) {
GrPaint paint;
paint.setGammaCorrect(drawContext->isGammaCorrect());
- SkAutoTUnref<GrFragmentProcessor> conv(GrConvolutionEffect::CreateGaussian(
+ sk_sp<GrFragmentProcessor> conv(GrConvolutionEffect::MakeGaussian(
texture, direction, radius, sigma, useBounds, bounds));
- paint.addColorFragmentProcessor(conv);
+ paint.addColorFragmentProcessor(std::move(conv));
paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
SkMatrix localMatrix = SkMatrix::MakeTrans(-SkIntToScalar(srcOffset.x()),
-SkIntToScalar(srcOffset.y()));
@@ -104,11 +104,11 @@ static void convolve_gaussian_2d(GrDrawContext* drawContext,
paint.setGammaCorrect(drawContext->isGammaCorrect());
SkIRect bounds = srcBounds ? *srcBounds : SkIRect::EmptyIRect();
- SkAutoTUnref<GrFragmentProcessor> conv(GrMatrixConvolutionEffect::CreateGaussian(
+ sk_sp<GrFragmentProcessor> conv(GrMatrixConvolutionEffect::MakeGaussian(
texture, bounds, size, 1.0, 0.0, kernelOffset,
srcBounds ? GrTextureDomain::kDecal_Mode : GrTextureDomain::kIgnore_Mode,
true, sigmaX, sigmaY));
- paint.addColorFragmentProcessor(conv);
+ paint.addColorFragmentProcessor(std::move(conv));
paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
drawContext->fillRectWithLocalMatrix(clip, paint, SkMatrix::I(),
SkRect::Make(dstRect), localMatrix);
@@ -273,13 +273,13 @@ sk_sp<GrDrawContext> GaussianBlur(GrContext* context,
matrix.mapRect(&domain, SkRect::Make(*srcBounds));
domain.inset((i < scaleFactorX) ? SK_ScalarHalf / srcTexture->width() : 0.0f,
(i < scaleFactorY) ? SK_ScalarHalf / srcTexture->height() : 0.0f);
- sk_sp<const GrFragmentProcessor> fp(GrTextureDomainEffect::Create(
+ sk_sp<GrFragmentProcessor> fp(GrTextureDomainEffect::Make(
srcTexture.get(),
matrix,
domain,
GrTextureDomain::kDecal_Mode,
GrTextureParams::kBilerp_FilterMode));
- paint.addColorFragmentProcessor(fp.get());
+ paint.addColorFragmentProcessor(std::move(fp));
srcRect.offset(-srcOffset);
srcOffset.set(0, 0);
} else {
diff --git a/src/effects/SkLightingImageFilter.cpp b/src/effects/SkLightingImageFilter.cpp
index 7f4dcfdf03..8bf4077602 100644
--- a/src/effects/SkLightingImageFilter.cpp
+++ b/src/effects/SkLightingImageFilter.cpp
@@ -359,10 +359,10 @@ protected:
SkSpecialImage* input,
const SkIRect& bounds,
const SkMatrix& matrix) const;
- virtual GrFragmentProcessor* getFragmentProcessor(GrTexture*,
- const SkMatrix&,
- const SkIRect* srcBounds,
- BoundaryMode boundaryMode) const = 0;
+ virtual sk_sp<GrFragmentProcessor> makeFragmentProcessor(GrTexture*,
+ const SkMatrix&,
+ const SkIRect* srcBounds,
+ BoundaryMode boundaryMode) const = 0;
#endif
private:
#if SK_SUPPORT_GPU
@@ -390,8 +390,9 @@ void SkLightingImageFilterInternal::drawRect(GrDrawContext* drawContext,
SkRect srcRect = dstRect.makeOffset(SkIntToScalar(bounds.x()), SkIntToScalar(bounds.y()));
GrPaint paint;
// SRGBTODO: AllowSRGBInputs?
- GrFragmentProcessor* fp = this->getFragmentProcessor(src, matrix, srcBounds, boundaryMode);
- paint.addColorFragmentProcessor(fp)->unref();
+ sk_sp<GrFragmentProcessor> fp(this->makeFragmentProcessor(src, matrix, srcBounds,
+ boundaryMode));
+ paint.addColorFragmentProcessor(std::move(fp));
paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
drawContext->fillRectToRect(clip, paint, SkMatrix::I(), dstRect, srcRect);
}
@@ -480,8 +481,9 @@ protected:
SkIPoint* offset) const override;
#if SK_SUPPORT_GPU
- GrFragmentProcessor* getFragmentProcessor(GrTexture*, const SkMatrix&, const SkIRect* bounds,
- BoundaryMode) const override;
+ sk_sp<GrFragmentProcessor> makeFragmentProcessor(GrTexture*, const SkMatrix&,
+ const SkIRect* bounds,
+ BoundaryMode) const override;
#endif
private:
@@ -515,8 +517,9 @@ protected:
SkIPoint* offset) const override;
#if SK_SUPPORT_GPU
- GrFragmentProcessor* getFragmentProcessor(GrTexture*, const SkMatrix&, const SkIRect* bounds,
- BoundaryMode) const override;
+ sk_sp<GrFragmentProcessor> makeFragmentProcessor(GrTexture*, const SkMatrix&,
+ const SkIRect* bounds,
+ BoundaryMode) const override;
#endif
private:
@@ -560,15 +563,16 @@ private:
class GrDiffuseLightingEffect : public GrLightingEffect {
public:
- static GrFragmentProcessor* Create(GrTexture* texture,
- const SkImageFilterLight* light,
- SkScalar surfaceScale,
- const SkMatrix& matrix,
- SkScalar kd,
- BoundaryMode boundaryMode,
- const SkIRect* srcBounds) {
- return new GrDiffuseLightingEffect(texture, light, surfaceScale, matrix, kd, boundaryMode,
- srcBounds);
+ static sk_sp<GrFragmentProcessor> Make(GrTexture* texture,
+ const SkImageFilterLight* light,
+ SkScalar surfaceScale,
+ const SkMatrix& matrix,
+ SkScalar kd,
+ BoundaryMode boundaryMode,
+ const SkIRect* srcBounds) {
+ return sk_sp<GrFragmentProcessor>(
+ new GrDiffuseLightingEffect(texture, light, surfaceScale, matrix, kd, boundaryMode,
+ srcBounds));
}
const char* name() const override { return "DiffuseLighting"; }
@@ -597,16 +601,17 @@ private:
class GrSpecularLightingEffect : public GrLightingEffect {
public:
- static GrFragmentProcessor* Create(GrTexture* texture,
- const SkImageFilterLight* light,
- SkScalar surfaceScale,
- const SkMatrix& matrix,
- SkScalar ks,
- SkScalar shininess,
- BoundaryMode boundaryMode,
- const SkIRect* srcBounds) {
- return new GrSpecularLightingEffect(texture, light, surfaceScale, matrix, ks, shininess,
- boundaryMode, srcBounds);
+ static sk_sp<GrFragmentProcessor> Make(GrTexture* texture,
+ const SkImageFilterLight* light,
+ SkScalar surfaceScale,
+ const SkMatrix& matrix,
+ SkScalar ks,
+ SkScalar shininess,
+ BoundaryMode boundaryMode,
+ const SkIRect* srcBounds) {
+ return sk_sp<GrFragmentProcessor>(
+ new GrSpecularLightingEffect(texture, light, surfaceScale, matrix, ks, shininess,
+ boundaryMode, srcBounds));
}
const char* name() const override { return "SpecularLighting"; }
@@ -1330,14 +1335,14 @@ void SkDiffuseLightingImageFilter::toString(SkString* str) const {
#endif
#if SK_SUPPORT_GPU
-GrFragmentProcessor* SkDiffuseLightingImageFilter::getFragmentProcessor(
+sk_sp<GrFragmentProcessor> SkDiffuseLightingImageFilter::makeFragmentProcessor(
GrTexture* texture,
const SkMatrix& matrix,
const SkIRect* srcBounds,
BoundaryMode boundaryMode) const {
SkScalar scale = SkScalarMul(this->surfaceScale(), SkIntToScalar(255));
- return GrDiffuseLightingEffect::Create(texture, this->light(), scale, matrix, this->kd(),
- boundaryMode, srcBounds);
+ return GrDiffuseLightingEffect::Make(texture, this->light(), scale, matrix, this->kd(),
+ boundaryMode, srcBounds);
}
#endif
@@ -1495,14 +1500,14 @@ void SkSpecularLightingImageFilter::toString(SkString* str) const {
#endif
#if SK_SUPPORT_GPU
-GrFragmentProcessor* SkSpecularLightingImageFilter::getFragmentProcessor(
+sk_sp<GrFragmentProcessor> SkSpecularLightingImageFilter::makeFragmentProcessor(
GrTexture* texture,
const SkMatrix& matrix,
const SkIRect* srcBounds,
BoundaryMode boundaryMode) const {
SkScalar scale = SkScalarMul(this->surfaceScale(), SkIntToScalar(255));
- return GrSpecularLightingEffect::Create(texture, this->light(), scale, matrix, this->ks(),
- this->shininess(), boundaryMode, srcBounds);
+ return GrSpecularLightingEffect::Make(texture, this->light(), scale, matrix, this->ks(),
+ this->shininess(), boundaryMode, srcBounds);
}
#endif
@@ -1746,7 +1751,7 @@ GrGLSLFragmentProcessor* GrDiffuseLightingEffect::onCreateGLSLInstance() const {
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrDiffuseLightingEffect);
-const GrFragmentProcessor* GrDiffuseLightingEffect::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> GrDiffuseLightingEffect::TestCreate(GrProcessorTestData* d) {
int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx :
GrProcessorUnitTest::kAlphaTextureIdx;
GrTexture* tex = d->fTextures[texIdx];
@@ -1762,7 +1767,7 @@ const GrFragmentProcessor* GrDiffuseLightingEffect::TestCreate(GrProcessorTestDa
d->fRandom->nextRangeU(0, tex->width()),
d->fRandom->nextRangeU(0, tex->height()));
BoundaryMode mode = static_cast<BoundaryMode>(d->fRandom->nextU() % kBoundaryModeCount);
- return GrDiffuseLightingEffect::Create(tex, light, surfaceScale, matrix, kd, mode, &srcBounds);
+ return GrDiffuseLightingEffect::Make(tex, light, surfaceScale, matrix, kd, mode, &srcBounds);
}
@@ -1963,7 +1968,7 @@ GrGLSLFragmentProcessor* GrSpecularLightingEffect::onCreateGLSLInstance() const
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrSpecularLightingEffect);
-const GrFragmentProcessor* GrSpecularLightingEffect::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> GrSpecularLightingEffect::TestCreate(GrProcessorTestData* d) {
int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx :
GrProcessorUnitTest::kAlphaTextureIdx;
GrTexture* tex = d->fTextures[texIdx];
@@ -1980,9 +1985,9 @@ const GrFragmentProcessor* GrSpecularLightingEffect::TestCreate(GrProcessorTestD
d->fRandom->nextRangeU(0, tex->height()),
d->fRandom->nextRangeU(0, tex->width()),
d->fRandom->nextRangeU(0, tex->height()));
- return GrSpecularLightingEffect::Create(d->fTextures[GrProcessorUnitTest::kAlphaTextureIdx],
- light, surfaceScale, matrix, ks, shininess, mode,
- &srcBounds);
+ return GrSpecularLightingEffect::Make(d->fTextures[GrProcessorUnitTest::kAlphaTextureIdx],
+ light, surfaceScale, matrix, ks, shininess, mode,
+ &srcBounds);
}
///////////////////////////////////////////////////////////////////////////////
diff --git a/src/effects/SkLumaColorFilter.cpp b/src/effects/SkLumaColorFilter.cpp
index 28b2e1eb44..ec94eca76d 100644
--- a/src/effects/SkLumaColorFilter.cpp
+++ b/src/effects/SkLumaColorFilter.cpp
@@ -58,8 +58,8 @@ void SkLumaColorFilter::toString(SkString* str) const {
#if SK_SUPPORT_GPU
class LumaColorFilterEffect : public GrFragmentProcessor {
public:
- static const GrFragmentProcessor* Create() {
- return new LumaColorFilterEffect;
+ static sk_sp<GrFragmentProcessor> Make() {
+ return sk_sp<GrFragmentProcessor>(new LumaColorFilterEffect);
}
const char* name() const override { return "Luminance-to-Alpha"; }
@@ -111,8 +111,7 @@ private:
}
};
-const GrFragmentProcessor* SkLumaColorFilter::asFragmentProcessor(GrContext*) const {
-
- return LumaColorFilterEffect::Create();
+sk_sp<GrFragmentProcessor> SkLumaColorFilter::asFragmentProcessor(GrContext*) const {
+ return LumaColorFilterEffect::Make();
}
#endif
diff --git a/src/effects/SkMagnifierImageFilter.cpp b/src/effects/SkMagnifierImageFilter.cpp
index 517e31d250..cc2d243f1e 100644
--- a/src/effects/SkMagnifierImageFilter.cpp
+++ b/src/effects/SkMagnifierImageFilter.cpp
@@ -28,18 +28,18 @@
class GrMagnifierEffect : public GrSingleTextureEffect {
public:
- static GrFragmentProcessor* Create(GrTexture* texture,
- const SkRect& bounds,
- float xOffset,
- float yOffset,
- float xInvZoom,
- float yInvZoom,
- float xInvInset,
- float yInvInset) {
- return new GrMagnifierEffect(texture, bounds,
- xOffset, yOffset,
- xInvZoom, yInvZoom,
- xInvInset, yInvInset);
+ static sk_sp<GrFragmentProcessor> Make(GrTexture* texture,
+ const SkRect& bounds,
+ float xOffset,
+ float yOffset,
+ float xInvZoom,
+ float yInvZoom,
+ float xInvInset,
+ float yInvInset) {
+ return sk_sp<GrFragmentProcessor>(new GrMagnifierEffect(texture, bounds,
+ xOffset, yOffset,
+ xInvZoom, yInvZoom,
+ xInvInset, yInvInset));
}
~GrMagnifierEffect() override {};
@@ -192,7 +192,7 @@ GrGLSLFragmentProcessor* GrMagnifierEffect::onCreateGLSLInstance() const {
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrMagnifierEffect);
-const GrFragmentProcessor* GrMagnifierEffect::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> GrMagnifierEffect::TestCreate(GrProcessorTestData* d) {
GrTexture* texture = d->fTextures[0];
const int kMaxWidth = 200;
const int kMaxHeight = 200;
@@ -203,7 +203,7 @@ const GrFragmentProcessor* GrMagnifierEffect::TestCreate(GrProcessorTestData* d)
uint32_t y = d->fRandom->nextULessThan(kMaxHeight - height);
uint32_t inset = d->fRandom->nextULessThan(kMaxInset);
- GrFragmentProcessor* effect = GrMagnifierEffect::Create(
+ sk_sp<GrFragmentProcessor> effect(GrMagnifierEffect::Make(
texture,
SkRect::MakeWH(SkIntToScalar(kMaxWidth), SkIntToScalar(kMaxHeight)),
(float) width / texture->width(),
@@ -211,7 +211,7 @@ const GrFragmentProcessor* GrMagnifierEffect::TestCreate(GrProcessorTestData* d)
texture->width() / (float) x,
texture->height() / (float) y,
(float) inset / texture->width(),
- (float) inset / texture->height());
+ (float) inset / texture->height()));
SkASSERT(effect);
return effect;
}
@@ -324,7 +324,7 @@ sk_sp<SkSpecialImage> SkMagnifierImageFilter::onFilterImage(SkSpecialImage* sour
SkIntToScalar(inputTexture->width()) / bounds.width(),
SkIntToScalar(inputTexture->height()) / bounds.height());
// SRGBTODO: Handle sRGB here
- sk_sp<GrFragmentProcessor> fp(GrMagnifierEffect::Create(
+ sk_sp<GrFragmentProcessor> fp(GrMagnifierEffect::Make(
inputTexture.get(),
effectBounds,
fSrcRect.x() / inputTexture->width(),
diff --git a/src/effects/SkMatrixConvolutionImageFilter.cpp b/src/effects/SkMatrixConvolutionImageFilter.cpp
index f5d9a3f7d2..67d155b06b 100644
--- a/src/effects/SkMatrixConvolutionImageFilter.cpp
+++ b/src/effects/SkMatrixConvolutionImageFilter.cpp
@@ -315,8 +315,7 @@ sk_sp<SkSpecialImage> SkMatrixConvolutionImageFilter::onFilterImage(SkSpecialIma
bounds.offset(-inputOffset);
// SRGBTODO: handle sRGB here
- sk_sp<GrFragmentProcessor> fp(GrMatrixConvolutionEffect::Create(
- inputTexture.get(),
+ sk_sp<GrFragmentProcessor> fp(GrMatrixConvolutionEffect::Make(inputTexture.get(),
bounds,
fKernelSize,
fKernel,
diff --git a/src/effects/SkMorphologyImageFilter.cpp b/src/effects/SkMorphologyImageFilter.cpp
index bbd236ea72..4ac65686ff 100644
--- a/src/effects/SkMorphologyImageFilter.cpp
+++ b/src/effects/SkMorphologyImageFilter.cpp
@@ -143,14 +143,14 @@ public:
kDilate_MorphologyType,
};
- static GrFragmentProcessor* Create(GrTexture* tex, Direction dir, int radius,
- MorphologyType type) {
- return new GrMorphologyEffect(tex, dir, radius, type);
+ static sk_sp<GrFragmentProcessor> Make(GrTexture* tex, Direction dir, int radius,
+ MorphologyType type) {
+ return sk_sp<GrFragmentProcessor>(new GrMorphologyEffect(tex, dir, radius, type));
}
- static GrFragmentProcessor* Create(GrTexture* tex, Direction dir, int radius,
- MorphologyType type, float bounds[2]) {
- return new GrMorphologyEffect(tex, dir, radius, type, bounds);
+ static sk_sp<GrFragmentProcessor> Make(GrTexture* tex, Direction dir, int radius,
+ MorphologyType type, float bounds[2]) {
+ return sk_sp<GrFragmentProcessor>(new GrMorphologyEffect(tex, dir, radius, type, bounds));
}
virtual ~GrMorphologyEffect();
@@ -370,16 +370,16 @@ void GrMorphologyEffect::onComputeInvariantOutput(GrInvariantOutput* inout) cons
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrMorphologyEffect);
-const GrFragmentProcessor* GrMorphologyEffect::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> GrMorphologyEffect::TestCreate(GrProcessorTestData* d) {
int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx :
- GrProcessorUnitTest::kAlphaTextureIdx;
+ GrProcessorUnitTest::kAlphaTextureIdx;
Direction dir = d->fRandom->nextBool() ? kX_Direction : kY_Direction;
static const int kMaxRadius = 10;
int radius = d->fRandom->nextRangeU(1, kMaxRadius);
MorphologyType type = d->fRandom->nextBool() ? GrMorphologyEffect::kErode_MorphologyType :
GrMorphologyEffect::kDilate_MorphologyType;
- return GrMorphologyEffect::Create(d->fTextures[texIdx], dir, radius, type);
+ return GrMorphologyEffect::Make(d->fTextures[texIdx], dir, radius, type);
}
@@ -394,11 +394,11 @@ static void apply_morphology_rect(GrDrawContext* drawContext,
Gr1DKernelEffect::Direction direction) {
GrPaint paint;
// SRGBTODO: AllowSRGBInputs?
- paint.addColorFragmentProcessor(GrMorphologyEffect::Create(texture,
- direction,
- radius,
- morphType,
- bounds))->unref();
+ paint.addColorFragmentProcessor(GrMorphologyEffect::Make(texture,
+ direction,
+ radius,
+ morphType,
+ bounds));
paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
drawContext->fillRectToRect(clip, paint, SkMatrix::I(), SkRect::Make(dstRect),
SkRect::Make(srcRect));
@@ -414,10 +414,8 @@ static void apply_morphology_rect_no_bounds(GrDrawContext* drawContext,
Gr1DKernelEffect::Direction direction) {
GrPaint paint;
// SRGBTODO: AllowSRGBInputs?
- paint.addColorFragmentProcessor(GrMorphologyEffect::Create(texture,
- direction,
- radius,
- morphType))->unref();
+ paint.addColorFragmentProcessor(GrMorphologyEffect::Make(texture, direction, radius,
+ morphType));
paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
drawContext->fillRectToRect(clip, paint, SkMatrix::I(), SkRect::Make(dstRect),
SkRect::Make(srcRect));
diff --git a/src/effects/SkPerlinNoiseShader.cpp b/src/effects/SkPerlinNoiseShader.cpp
index d2d460648f..1400905bfe 100644
--- a/src/effects/SkPerlinNoiseShader.cpp
+++ b/src/effects/SkPerlinNoiseShader.cpp
@@ -495,13 +495,14 @@ private:
class GrPerlinNoiseEffect : public GrFragmentProcessor {
public:
- static GrFragmentProcessor* Create(SkPerlinNoiseShader::Type type,
- int numOctaves, bool stitchTiles,
- SkPerlinNoiseShader::PaintingData* paintingData,
- GrTexture* permutationsTexture, GrTexture* noiseTexture,
- const SkMatrix& matrix) {
- return new GrPerlinNoiseEffect(type, numOctaves, stitchTiles, paintingData,
- permutationsTexture, noiseTexture, matrix);
+ static sk_sp<GrFragmentProcessor> Make(SkPerlinNoiseShader::Type type,
+ int numOctaves, bool stitchTiles,
+ SkPerlinNoiseShader::PaintingData* paintingData,
+ GrTexture* permutationsTexture, GrTexture* noiseTexture,
+ const SkMatrix& matrix) {
+ return sk_sp<GrFragmentProcessor>(
+ new GrPerlinNoiseEffect(type, numOctaves, stitchTiles, paintingData,
+ permutationsTexture, noiseTexture, matrix));
}
virtual ~GrPerlinNoiseEffect() { delete fPaintingData; }
@@ -574,7 +575,7 @@ private:
/////////////////////////////////////////////////////////////////////
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrPerlinNoiseEffect);
-const GrFragmentProcessor* GrPerlinNoiseEffect::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> GrPerlinNoiseEffect::TestCreate(GrProcessorTestData* d) {
int numOctaves = d->fRandom->nextRangeU(2, 10);
bool stitchTiles = d->fRandom->nextBool();
SkScalar seed = SkIntToScalar(d->fRandom->nextU());
@@ -892,7 +893,7 @@ void GrGLPerlinNoise::onSetData(const GrGLSLProgramDataManager& pdman,
}
/////////////////////////////////////////////////////////////////////
-const GrFragmentProcessor* SkPerlinNoiseShader::asFragmentProcessor(
+sk_sp<GrFragmentProcessor> SkPerlinNoiseShader::asFragmentProcessor(
GrContext* context,
const SkMatrix& viewM,
const SkMatrix* externalLocalMatrix,
@@ -911,13 +912,13 @@ const GrFragmentProcessor* SkPerlinNoiseShader::asFragmentProcessor(
if (0 == fNumOctaves) {
if (kFractalNoise_Type == fType) {
// Extract the incoming alpha and emit rgba = (a/4, a/4, a/4, a/2)
- SkAutoTUnref<const GrFragmentProcessor> inner(
- GrConstColorProcessor::Create(0x80404040,
- GrConstColorProcessor::kModulateRGBA_InputMode));
- return GrFragmentProcessor::MulOutputByInputAlpha(inner);
+ sk_sp<GrFragmentProcessor> inner(
+ GrConstColorProcessor::Make(0x80404040,
+ GrConstColorProcessor::kModulateRGBA_InputMode));
+ return GrFragmentProcessor::MulOutputByInputAlpha(std::move(inner));
}
// Emit zero.
- return GrConstColorProcessor::Create(0x0, GrConstColorProcessor::kIgnore_InputMode);
+ return GrConstColorProcessor::Make(0x0, GrConstColorProcessor::kIgnore_InputMode);
}
// Either we don't stitch tiles, either we have a valid tile size
@@ -936,14 +937,14 @@ const GrFragmentProcessor* SkPerlinNoiseShader::asFragmentProcessor(
m.setTranslateX(-localMatrix.getTranslateX() + SK_Scalar1);
m.setTranslateY(-localMatrix.getTranslateY() + SK_Scalar1);
if ((permutationsTexture) && (noiseTexture)) {
- SkAutoTUnref<GrFragmentProcessor> inner(
- GrPerlinNoiseEffect::Create(fType,
- fNumOctaves,
- fStitchTiles,
- paintingData,
- permutationsTexture, noiseTexture,
- m));
- return GrFragmentProcessor::MulOutputByInputAlpha(inner);
+ sk_sp<GrFragmentProcessor> inner(
+ GrPerlinNoiseEffect::Make(fType,
+ fNumOctaves,
+ fStitchTiles,
+ paintingData,
+ permutationsTexture, noiseTexture,
+ m));
+ return GrFragmentProcessor::MulOutputByInputAlpha(std::move(inner));
}
delete paintingData;
return nullptr;
diff --git a/src/effects/SkTableColorFilter.cpp b/src/effects/SkTableColorFilter.cpp
index e87a053735..20d11f101b 100644
--- a/src/effects/SkTableColorFilter.cpp
+++ b/src/effects/SkTableColorFilter.cpp
@@ -49,7 +49,7 @@ public:
sk_sp<SkColorFilter> makeComposed(sk_sp<SkColorFilter> inner) const override;
#if SK_SUPPORT_GPU
- const GrFragmentProcessor* asFragmentProcessor(GrContext*) const override;
+ sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext*) const override;
#endif
void filterSpan(const SkPMColor src[], int count, SkPMColor dst[]) const override;
@@ -343,7 +343,7 @@ sk_sp<SkColorFilter> SkTable_ColorFilter::makeComposed(sk_sp<SkColorFilter> inne
class ColorTableEffect : public GrFragmentProcessor {
public:
- static const GrFragmentProcessor* Create(GrContext* context, SkBitmap bitmap, unsigned flags);
+ static sk_sp<GrFragmentProcessor> Make(GrContext* context, SkBitmap bitmap, unsigned flags);
virtual ~ColorTableEffect();
@@ -459,8 +459,8 @@ void GLColorTableEffect::emitCode(EmitArgs& args) {
}
///////////////////////////////////////////////////////////////////////////////
-const GrFragmentProcessor* ColorTableEffect::Create(GrContext* context, SkBitmap bitmap,
- unsigned flags) {
+sk_sp<GrFragmentProcessor> ColorTableEffect::Make(GrContext* context, SkBitmap bitmap,
+ unsigned flags) {
GrTextureStripAtlas::Desc desc;
desc.fWidth = bitmap.width();
@@ -479,7 +479,7 @@ const GrFragmentProcessor* ColorTableEffect::Create(GrContext* context, SkBitmap
texture.reset(SkRef(atlas->getTexture()));
}
- return new ColorTableEffect(texture, atlas, row, flags);
+ return sk_sp<GrFragmentProcessor>(new ColorTableEffect(texture, atlas, row, flags));
}
ColorTableEffect::ColorTableEffect(GrTexture* texture, GrTextureStripAtlas* atlas, int row,
@@ -540,7 +540,7 @@ void ColorTableEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(ColorTableEffect);
-const GrFragmentProcessor* ColorTableEffect::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> ColorTableEffect::TestCreate(GrProcessorTestData* d) {
int flags = 0;
uint8_t luts[256][4];
do {
@@ -562,16 +562,16 @@ const GrFragmentProcessor* ColorTableEffect::TestCreate(GrProcessorTestData* d)
(flags & (1 << 3)) ? luts[3] : nullptr
));
- const GrFragmentProcessor* fp = filter->asFragmentProcessor(d->fContext);
+ sk_sp<GrFragmentProcessor> fp = filter->asFragmentProcessor(d->fContext);
SkASSERT(fp);
return fp;
}
-const GrFragmentProcessor* SkTable_ColorFilter::asFragmentProcessor(GrContext* context) const {
+sk_sp<GrFragmentProcessor> SkTable_ColorFilter::asFragmentProcessor(GrContext* context) const {
SkBitmap bitmap;
this->asComponentTable(&bitmap);
- return ColorTableEffect::Create(context, bitmap, fFlags);
+ return ColorTableEffect::Make(context, bitmap, fFlags);
}
#endif // SK_SUPPORT_GPU
diff --git a/src/effects/SkXfermodeImageFilter.cpp b/src/effects/SkXfermodeImageFilter.cpp
index 1921e00a1a..785b46fcc7 100644
--- a/src/effects/SkXfermodeImageFilter.cpp
+++ b/src/effects/SkXfermodeImageFilter.cpp
@@ -180,22 +180,22 @@ sk_sp<SkSpecialImage> SkXfermodeImageFilter::filterImageGPU(SkSpecialImage* sour
GrPaint paint;
// SRGBTODO: AllowSRGBInputs?
- SkAutoTUnref<const GrFragmentProcessor> bgFP;
+ sk_sp<GrFragmentProcessor> bgFP;
if (backgroundTex) {
SkMatrix backgroundMatrix;
backgroundMatrix.setIDiv(backgroundTex->width(), backgroundTex->height());
backgroundMatrix.preTranslate(SkIntToScalar(-backgroundOffset.fX),
SkIntToScalar(-backgroundOffset.fY));
- bgFP.reset(GrTextureDomainEffect::Create(
+ bgFP = GrTextureDomainEffect::Make(
backgroundTex.get(), backgroundMatrix,
GrTextureDomain::MakeTexelDomain(backgroundTex.get(),
background->subset()),
GrTextureDomain::kDecal_Mode,
- GrTextureParams::kNone_FilterMode));
+ GrTextureParams::kNone_FilterMode);
} else {
- bgFP.reset(GrConstColorProcessor::Create(GrColor_TRANSPARENT_BLACK,
- GrConstColorProcessor::kIgnore_InputMode));
+ bgFP = GrConstColorProcessor::Make(GrColor_TRANSPARENT_BLACK,
+ GrConstColorProcessor::kIgnore_InputMode);
}
if (foregroundTex) {
@@ -204,16 +204,16 @@ sk_sp<SkSpecialImage> SkXfermodeImageFilter::filterImageGPU(SkSpecialImage* sour
foregroundMatrix.preTranslate(SkIntToScalar(-foregroundOffset.fX),
SkIntToScalar(-foregroundOffset.fY));
- SkAutoTUnref<const GrFragmentProcessor> foregroundFP;
+ sk_sp<GrFragmentProcessor> foregroundFP;
- foregroundFP.reset(GrTextureDomainEffect::Create(
+ foregroundFP = GrTextureDomainEffect::Make(
foregroundTex.get(), foregroundMatrix,
GrTextureDomain::MakeTexelDomain(foregroundTex.get(),
foreground->subset()),
GrTextureDomain::kDecal_Mode,
- GrTextureParams::kNone_FilterMode));
+ GrTextureParams::kNone_FilterMode);
- paint.addColorFragmentProcessor(foregroundFP.get());
+ paint.addColorFragmentProcessor(std::move(foregroundFP));
// A null fMode is interpreted to mean kSrcOver_Mode (to match raster).
SkAutoTUnref<SkXfermode> mode(SkSafeRef(fMode.get()));
@@ -228,14 +228,15 @@ sk_sp<SkSpecialImage> SkXfermodeImageFilter::filterImageGPU(SkSpecialImage* sour
mode.reset(new SkProcCoeffXfermode(rec, SkXfermode::kSrcOver_Mode));
}
- sk_sp<const GrFragmentProcessor> xferFP(mode->getFragmentProcessorForImageFilter(bgFP));
+ sk_sp<GrFragmentProcessor> xferFP(
+ mode->makeFragmentProcessorForImageFilter(std::move(bgFP)));
// A null 'xferFP' here means kSrc_Mode was used in which case we can just proceed
if (xferFP) {
- paint.addColorFragmentProcessor(xferFP.get());
+ paint.addColorFragmentProcessor(std::move(xferFP));
}
} else {
- paint.addColorFragmentProcessor(bgFP);
+ paint.addColorFragmentProcessor(std::move(bgFP));
}
paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
diff --git a/src/effects/gradients/SkLinearGradient.cpp b/src/effects/gradients/SkLinearGradient.cpp
index cd55673dc9..40340fe4df 100644
--- a/src/effects/gradients/SkLinearGradient.cpp
+++ b/src/effects/gradients/SkLinearGradient.cpp
@@ -7,6 +7,7 @@
#include "Sk4fLinearGradient.h"
#include "SkLinearGradient.h"
+#include "SkRefCnt.h"
// define to test the 4f gradient path
// #define FORCE_4F_CONTEXT
@@ -369,11 +370,11 @@ private:
class GrLinearGradient : public GrGradientEffect {
public:
- static GrFragmentProcessor* Create(GrContext* ctx,
- const SkLinearGradient& shader,
- const SkMatrix& matrix,
- SkShader::TileMode tm) {
- return new GrLinearGradient(ctx, shader, matrix, tm);
+ static sk_sp<GrFragmentProcessor> Make(GrContext* ctx,
+ const SkLinearGradient& shader,
+ const SkMatrix& matrix,
+ SkShader::TileMode tm) {
+ return sk_sp<GrFragmentProcessor>(new GrLinearGradient(ctx, shader, matrix, tm));
}
virtual ~GrLinearGradient() { }
@@ -407,7 +408,7 @@ private:
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrLinearGradient);
-const GrFragmentProcessor* GrLinearGradient::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> GrLinearGradient::TestCreate(GrProcessorTestData* d) {
SkPoint points[] = {{d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()},
{d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()}};
@@ -417,7 +418,7 @@ const GrFragmentProcessor* GrLinearGradient::TestCreate(GrProcessorTestData* d)
SkShader::TileMode tm;
int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm);
auto shader = SkGradientShader::MakeLinear(points, colors, stops, colorCount, tm);
- const GrFragmentProcessor* fp = shader->asFragmentProcessor(d->fContext,
+ sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(d->fContext,
GrTest::TestMatrix(d->fRandom), NULL, kNone_SkFilterQuality,
SkSourceGammaTreatment::kRespect);
GrAlwaysAssert(fp);
@@ -442,7 +443,7 @@ void GrGLLinearGradient::emitCode(EmitArgs& args) {
/////////////////////////////////////////////////////////////////////
-const GrFragmentProcessor* SkLinearGradient::asFragmentProcessor(
+sk_sp<GrFragmentProcessor> SkLinearGradient::asFragmentProcessor(
GrContext* context,
const SkMatrix& viewm,
const SkMatrix* localMatrix,
@@ -463,9 +464,8 @@ const GrFragmentProcessor* SkLinearGradient::asFragmentProcessor(
}
matrix.postConcat(fPtsToUnit);
- SkAutoTUnref<const GrFragmentProcessor> inner(
- GrLinearGradient::Create(context, *this, matrix, fTileMode));
- return GrFragmentProcessor::MulOutputByInputAlpha(inner);
+ sk_sp<GrFragmentProcessor> inner(GrLinearGradient::Make(context, *this, matrix, fTileMode));
+ return GrFragmentProcessor::MulOutputByInputAlpha(std::move(inner));
}
diff --git a/src/effects/gradients/SkLinearGradient.h b/src/effects/gradients/SkLinearGradient.h
index 8edcb9d639..5800e576db 100644
--- a/src/effects/gradients/SkLinearGradient.h
+++ b/src/effects/gradients/SkLinearGradient.h
@@ -57,7 +57,7 @@ public:
GradientType asAGradient(GradientInfo* info) const override;
#if SK_SUPPORT_GPU
- const GrFragmentProcessor* asFragmentProcessor(GrContext*,
+ sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext*,
const SkMatrix& viewM,
const SkMatrix*,
SkFilterQuality,
diff --git a/src/effects/gradients/SkRadialGradient.cpp b/src/effects/gradients/SkRadialGradient.cpp
index a0fee273d7..c7e6656549 100644
--- a/src/effects/gradients/SkRadialGradient.cpp
+++ b/src/effects/gradients/SkRadialGradient.cpp
@@ -264,11 +264,11 @@ private:
class GrRadialGradient : public GrGradientEffect {
public:
- static GrFragmentProcessor* Create(GrContext* ctx,
- const SkRadialGradient& shader,
- const SkMatrix& matrix,
- SkShader::TileMode tm) {
- return new GrRadialGradient(ctx, shader, matrix, tm);
+ static sk_sp<GrFragmentProcessor> Make(GrContext* ctx,
+ const SkRadialGradient& shader,
+ const SkMatrix& matrix,
+ SkShader::TileMode tm) {
+ return sk_sp<GrFragmentProcessor>(new GrRadialGradient(ctx, shader, matrix, tm));
}
virtual ~GrRadialGradient() { }
@@ -302,7 +302,7 @@ private:
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrRadialGradient);
-const GrFragmentProcessor* GrRadialGradient::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> GrRadialGradient::TestCreate(GrProcessorTestData* d) {
SkPoint center = {d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()};
SkScalar radius = d->fRandom->nextUScalar1();
@@ -312,7 +312,7 @@ const GrFragmentProcessor* GrRadialGradient::TestCreate(GrProcessorTestData* d)
SkShader::TileMode tm;
int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm);
auto shader = SkGradientShader::MakeRadial(center, radius, colors, stops, colorCount, tm);
- const GrFragmentProcessor* fp = shader->asFragmentProcessor(d->fContext,
+ sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(d->fContext,
GrTest::TestMatrix(d->fRandom), NULL, kNone_SkFilterQuality,
SkSourceGammaTreatment::kRespect);
GrAlwaysAssert(fp);
@@ -338,7 +338,7 @@ void GrGLRadialGradient::emitCode(EmitArgs& args) {
/////////////////////////////////////////////////////////////////////
-const GrFragmentProcessor* SkRadialGradient::asFragmentProcessor(
+sk_sp<GrFragmentProcessor> SkRadialGradient::asFragmentProcessor(
GrContext* context,
const SkMatrix& viewM,
const SkMatrix* localMatrix,
@@ -358,9 +358,8 @@ const GrFragmentProcessor* SkRadialGradient::asFragmentProcessor(
matrix.postConcat(inv);
}
matrix.postConcat(fPtsToUnit);
- SkAutoTUnref<const GrFragmentProcessor> inner(
- GrRadialGradient::Create(context, *this, matrix, fTileMode));
- return GrFragmentProcessor::MulOutputByInputAlpha(inner);
+ sk_sp<GrFragmentProcessor> inner(GrRadialGradient::Make(context, *this, matrix, fTileMode));
+ return GrFragmentProcessor::MulOutputByInputAlpha(std::move(inner));
}
#endif
diff --git a/src/effects/gradients/SkRadialGradient.h b/src/effects/gradients/SkRadialGradient.h
index 8eb1f76832..dfa6823c0e 100644
--- a/src/effects/gradients/SkRadialGradient.h
+++ b/src/effects/gradients/SkRadialGradient.h
@@ -26,7 +26,7 @@ public:
GradientType asAGradient(GradientInfo* info) const override;
#if SK_SUPPORT_GPU
- const GrFragmentProcessor* asFragmentProcessor(GrContext*,
+ sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext*,
const SkMatrix& viewM,
const SkMatrix*,
SkFilterQuality,
diff --git a/src/effects/gradients/SkSweepGradient.cpp b/src/effects/gradients/SkSweepGradient.cpp
index 08232bccb3..9e2b909075 100644
--- a/src/effects/gradients/SkSweepGradient.cpp
+++ b/src/effects/gradients/SkSweepGradient.cpp
@@ -147,9 +147,9 @@ private:
class GrSweepGradient : public GrGradientEffect {
public:
- static GrFragmentProcessor* Create(GrContext* ctx, const SkSweepGradient& shader,
- const SkMatrix& m) {
- return new GrSweepGradient(ctx, shader, m);
+ static sk_sp<GrFragmentProcessor> Make(GrContext* ctx, const SkSweepGradient& shader,
+ const SkMatrix& m) {
+ return sk_sp<GrFragmentProcessor>(new GrSweepGradient(ctx, shader, m));
}
virtual ~GrSweepGradient() { }
@@ -181,7 +181,7 @@ private:
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrSweepGradient);
-const GrFragmentProcessor* GrSweepGradient::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> GrSweepGradient::TestCreate(GrProcessorTestData* d) {
SkPoint center = {d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()};
SkColor colors[kMaxRandomGradientColors];
@@ -191,7 +191,7 @@ const GrFragmentProcessor* GrSweepGradient::TestCreate(GrProcessorTestData* d) {
int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tmIgnored);
sk_sp<SkShader> shader(SkGradientShader::MakeSweep(center.fX, center.fY, colors, stops,
colorCount));
- const GrFragmentProcessor* fp = shader->asFragmentProcessor(d->fContext,
+ sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(d->fContext,
GrTest::TestMatrix(d->fRandom),
NULL, kNone_SkFilterQuality,
SkSourceGammaTreatment::kRespect);
@@ -227,7 +227,7 @@ void GrGLSweepGradient::emitCode(EmitArgs& args) {
/////////////////////////////////////////////////////////////////////
-const GrFragmentProcessor* SkSweepGradient::asFragmentProcessor(
+sk_sp<GrFragmentProcessor> SkSweepGradient::asFragmentProcessor(
GrContext* context,
const SkMatrix& viewM,
const SkMatrix* localMatrix,
@@ -247,9 +247,8 @@ const GrFragmentProcessor* SkSweepGradient::asFragmentProcessor(
}
matrix.postConcat(fPtsToUnit);
- SkAutoTUnref<const GrFragmentProcessor> inner(
- GrSweepGradient::Create(context, *this, matrix));
- return GrFragmentProcessor::MulOutputByInputAlpha(inner);
+ sk_sp<GrFragmentProcessor> inner(GrSweepGradient::Make(context, *this, matrix));
+ return GrFragmentProcessor::MulOutputByInputAlpha(std::move(inner));
}
#endif
diff --git a/src/effects/gradients/SkSweepGradient.h b/src/effects/gradients/SkSweepGradient.h
index d0807daf23..0812a583a4 100644
--- a/src/effects/gradients/SkSweepGradient.h
+++ b/src/effects/gradients/SkSweepGradient.h
@@ -27,7 +27,7 @@ public:
GradientType asAGradient(GradientInfo* info) const override;
#if SK_SUPPORT_GPU
- const GrFragmentProcessor* asFragmentProcessor(GrContext*,
+ sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext*,
const SkMatrix& viewM,
const SkMatrix*,
SkFilterQuality,
diff --git a/src/effects/gradients/SkTwoPointConicalGradient.cpp b/src/effects/gradients/SkTwoPointConicalGradient.cpp
index a7cdc7e1b4..afc77feb5f 100644
--- a/src/effects/gradients/SkTwoPointConicalGradient.cpp
+++ b/src/effects/gradients/SkTwoPointConicalGradient.cpp
@@ -356,7 +356,7 @@ void SkTwoPointConicalGradient::flatten(SkWriteBuffer& buffer) const {
#include "SkGr.h"
-const GrFragmentProcessor* SkTwoPointConicalGradient::asFragmentProcessor(
+sk_sp<GrFragmentProcessor> SkTwoPointConicalGradient::asFragmentProcessor(
GrContext* context,
const SkMatrix& viewM,
const SkMatrix* localMatrix,
@@ -364,9 +364,9 @@ const GrFragmentProcessor* SkTwoPointConicalGradient::asFragmentProcessor(
SkSourceGammaTreatment) const {
SkASSERT(context);
SkASSERT(fPtsToUnit.isIdentity());
- SkAutoTUnref<const GrFragmentProcessor> inner(
- Gr2PtConicalGradientEffect::Create(context, *this, fTileMode, localMatrix));
- return GrFragmentProcessor::MulOutputByInputAlpha(inner);
+ sk_sp<GrFragmentProcessor> inner(
+ Gr2PtConicalGradientEffect::Make(context, *this, fTileMode, localMatrix));
+ return GrFragmentProcessor::MulOutputByInputAlpha(std::move(inner));
}
#endif
diff --git a/src/effects/gradients/SkTwoPointConicalGradient.h b/src/effects/gradients/SkTwoPointConicalGradient.h
index b50a5e3a4e..f2102c1472 100644
--- a/src/effects/gradients/SkTwoPointConicalGradient.h
+++ b/src/effects/gradients/SkTwoPointConicalGradient.h
@@ -57,7 +57,7 @@ public:
SkShader::GradientType asAGradient(GradientInfo* info) const override;
#if SK_SUPPORT_GPU
- const GrFragmentProcessor* asFragmentProcessor(GrContext*,
+ sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext*,
const SkMatrix&,
const SkMatrix*,
SkFilterQuality,
diff --git a/src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp b/src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp
index e638982d0c..91b0a9326d 100644
--- a/src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp
+++ b/src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp
@@ -61,11 +61,11 @@ static void set_matrix_edge_conical(const SkTwoPointConicalGradient& shader,
class Edge2PtConicalEffect : public GrGradientEffect {
public:
- static GrFragmentProcessor* Create(GrContext* ctx,
- const SkTwoPointConicalGradient& shader,
- const SkMatrix& matrix,
- SkShader::TileMode tm) {
- return new Edge2PtConicalEffect(ctx, shader, matrix, tm);
+ static sk_sp<GrFragmentProcessor> Make(GrContext* ctx,
+ const SkTwoPointConicalGradient& shader,
+ const SkMatrix& matrix,
+ SkShader::TileMode tm) {
+ return sk_sp<GrFragmentProcessor>(new Edge2PtConicalEffect(ctx, shader, matrix, tm));
}
virtual ~Edge2PtConicalEffect() {}
@@ -184,7 +184,7 @@ GR_DEFINE_FRAGMENT_PROCESSOR_TEST(Edge2PtConicalEffect);
/*
* All Two point conical gradient test create functions may occasionally create edge case shaders
*/
-const GrFragmentProcessor* Edge2PtConicalEffect::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> Edge2PtConicalEffect::TestCreate(GrProcessorTestData* d) {
SkPoint center1 = {d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()};
SkScalar radius1 = d->fRandom->nextUScalar1();
SkPoint center2;
@@ -208,7 +208,7 @@ const GrFragmentProcessor* Edge2PtConicalEffect::TestCreate(GrProcessorTestData*
int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm);
auto shader = SkGradientShader::MakeTwoPointConical(center1, radius1, center2, radius2,
colors, stops, colorCount, tm);
- const GrFragmentProcessor* fp = shader->asFragmentProcessor(d->fContext,
+ sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(d->fContext,
GrTest::TestMatrix(d->fRandom), NULL, kNone_SkFilterQuality,
SkSourceGammaTreatment::kRespect);
GrAlwaysAssert(fp);
@@ -370,12 +370,13 @@ static ConicalType set_matrix_focal_conical(const SkTwoPointConicalGradient& sha
class FocalOutside2PtConicalEffect : public GrGradientEffect {
public:
- static GrFragmentProcessor* Create(GrContext* ctx,
- const SkTwoPointConicalGradient& shader,
- const SkMatrix& matrix,
- SkShader::TileMode tm,
- SkScalar focalX) {
- return new FocalOutside2PtConicalEffect(ctx, shader, matrix, tm, focalX);
+ static sk_sp<GrFragmentProcessor> Make(GrContext* ctx,
+ const SkTwoPointConicalGradient& shader,
+ const SkMatrix& matrix,
+ SkShader::TileMode tm,
+ SkScalar focalX) {
+ return sk_sp<GrFragmentProcessor>(
+ new FocalOutside2PtConicalEffect(ctx, shader, matrix, tm, focalX));
}
virtual ~FocalOutside2PtConicalEffect() { }
@@ -463,7 +464,7 @@ GR_DEFINE_FRAGMENT_PROCESSOR_TEST(FocalOutside2PtConicalEffect);
/*
* All Two point conical gradient test create functions may occasionally create edge case shaders
*/
-const GrFragmentProcessor* FocalOutside2PtConicalEffect::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> FocalOutside2PtConicalEffect::TestCreate(GrProcessorTestData* d) {
SkPoint center1 = {d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()};
SkScalar radius1 = 0.f;
SkPoint center2;
@@ -484,7 +485,7 @@ const GrFragmentProcessor* FocalOutside2PtConicalEffect::TestCreate(GrProcessorT
int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm);
auto shader = SkGradientShader::MakeTwoPointConical(center1, radius1, center2, radius2,
colors, stops, colorCount, tm);
- const GrFragmentProcessor* fp = shader->asFragmentProcessor(d->fContext,
+ sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(d->fContext,
GrTest::TestMatrix(d->fRandom), NULL, kNone_SkFilterQuality,
SkSourceGammaTreatment::kRespect);
GrAlwaysAssert(fp);
@@ -580,12 +581,13 @@ class GLFocalInside2PtConicalEffect;
class FocalInside2PtConicalEffect : public GrGradientEffect {
public:
- static GrFragmentProcessor* Create(GrContext* ctx,
- const SkTwoPointConicalGradient& shader,
- const SkMatrix& matrix,
- SkShader::TileMode tm,
- SkScalar focalX) {
- return new FocalInside2PtConicalEffect(ctx, shader, matrix, tm, focalX);
+ static sk_sp<GrFragmentProcessor> Make(GrContext* ctx,
+ const SkTwoPointConicalGradient& shader,
+ const SkMatrix& matrix,
+ SkShader::TileMode tm,
+ SkScalar focalX) {
+ return sk_sp<GrFragmentProcessor>(
+ new FocalInside2PtConicalEffect(ctx, shader, matrix, tm, focalX));
}
virtual ~FocalInside2PtConicalEffect() {}
@@ -668,7 +670,7 @@ GR_DEFINE_FRAGMENT_PROCESSOR_TEST(FocalInside2PtConicalEffect);
/*
* All Two point conical gradient test create functions may occasionally create edge case shaders
*/
-const GrFragmentProcessor* FocalInside2PtConicalEffect::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> FocalInside2PtConicalEffect::TestCreate(GrProcessorTestData* d) {
SkPoint center1 = {d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()};
SkScalar radius1 = 0.f;
SkPoint center2;
@@ -691,7 +693,7 @@ const GrFragmentProcessor* FocalInside2PtConicalEffect::TestCreate(GrProcessorTe
int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm);
auto shader = SkGradientShader::MakeTwoPointConical(center1, radius1, center2, radius2,
colors, stops, colorCount, tm);
- const GrFragmentProcessor* fp = shader->asFragmentProcessor(d->fContext,
+ sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(d->fContext,
GrTest::TestMatrix(d->fRandom), NULL, kNone_SkFilterQuality,
SkSourceGammaTreatment::kRespect);
GrAlwaysAssert(fp);
@@ -819,12 +821,13 @@ static ConicalType set_matrix_circle_conical(const SkTwoPointConicalGradient& sh
class CircleInside2PtConicalEffect : public GrGradientEffect {
public:
- static GrFragmentProcessor* Create(GrContext* ctx,
- const SkTwoPointConicalGradient& shader,
- const SkMatrix& matrix,
- SkShader::TileMode tm,
- const CircleConicalInfo& info) {
- return new CircleInside2PtConicalEffect(ctx, shader, matrix, tm, info);
+ static sk_sp<GrFragmentProcessor> Make(GrContext* ctx,
+ const SkTwoPointConicalGradient& shader,
+ const SkMatrix& matrix,
+ SkShader::TileMode tm,
+ const CircleConicalInfo& info) {
+ return sk_sp<GrFragmentProcessor>(
+ new CircleInside2PtConicalEffect(ctx, shader, matrix, tm, info));
}
virtual ~CircleInside2PtConicalEffect() {}
@@ -916,7 +919,7 @@ GR_DEFINE_FRAGMENT_PROCESSOR_TEST(CircleInside2PtConicalEffect);
/*
* All Two point conical gradient test create functions may occasionally create edge case shaders
*/
-const GrFragmentProcessor* CircleInside2PtConicalEffect::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> CircleInside2PtConicalEffect::TestCreate(GrProcessorTestData* d) {
SkPoint center1 = {d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()};
SkScalar radius1 = d->fRandom->nextUScalar1() + 0.0001f; // make sure radius1 != 0
SkPoint center2;
@@ -938,7 +941,7 @@ const GrFragmentProcessor* CircleInside2PtConicalEffect::TestCreate(GrProcessorT
int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm);
auto shader = SkGradientShader::MakeTwoPointConical(center1, radius1, center2, radius2,
colors, stops, colorCount, tm);
- const GrFragmentProcessor* fp = shader->asFragmentProcessor(d->fContext,
+ sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(d->fContext,
GrTest::TestMatrix(d->fRandom), NULL, kNone_SkFilterQuality,
SkSourceGammaTreatment::kRespect);
GrAlwaysAssert(fp);
@@ -1035,12 +1038,13 @@ void GLCircleInside2PtConicalEffect::GenKey(const GrProcessor& processor,
class CircleOutside2PtConicalEffect : public GrGradientEffect {
public:
- static GrFragmentProcessor* Create(GrContext* ctx,
- const SkTwoPointConicalGradient& shader,
- const SkMatrix& matrix,
- SkShader::TileMode tm,
- const CircleConicalInfo& info) {
- return new CircleOutside2PtConicalEffect(ctx, shader, matrix, tm, info);
+ static sk_sp<GrFragmentProcessor> Make(GrContext* ctx,
+ const SkTwoPointConicalGradient& shader,
+ const SkMatrix& matrix,
+ SkShader::TileMode tm,
+ const CircleConicalInfo& info) {
+ return sk_sp<GrFragmentProcessor>(
+ new CircleOutside2PtConicalEffect(ctx, shader, matrix, tm, info));
}
virtual ~CircleOutside2PtConicalEffect() {}
@@ -1147,7 +1151,7 @@ GR_DEFINE_FRAGMENT_PROCESSOR_TEST(CircleOutside2PtConicalEffect);
/*
* All Two point conical gradient test create functions may occasionally create edge case shaders
*/
-const GrFragmentProcessor* CircleOutside2PtConicalEffect::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> CircleOutside2PtConicalEffect::TestCreate(GrProcessorTestData* d) {
SkPoint center1 = {d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()};
SkScalar radius1 = d->fRandom->nextUScalar1() + 0.0001f; // make sure radius1 != 0
SkPoint center2;
@@ -1170,7 +1174,7 @@ const GrFragmentProcessor* CircleOutside2PtConicalEffect::TestCreate(GrProcessor
int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm);
auto shader = SkGradientShader::MakeTwoPointConical(center1, radius1, center2, radius2,
colors, stops, colorCount, tm);
- const GrFragmentProcessor* fp = shader->asFragmentProcessor(
+ sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(
d->fContext,GrTest::TestMatrix(d->fRandom), NULL, kNone_SkFilterQuality,
SkSourceGammaTreatment::kRespect);
GrAlwaysAssert(fp);
@@ -1291,10 +1295,10 @@ void GLCircleOutside2PtConicalEffect::GenKey(const GrProcessor& processor,
//////////////////////////////////////////////////////////////////////////////
-GrFragmentProcessor* Gr2PtConicalGradientEffect::Create(GrContext* ctx,
- const SkTwoPointConicalGradient& shader,
- SkShader::TileMode tm,
- const SkMatrix* localMatrix) {
+sk_sp<GrFragmentProcessor> Gr2PtConicalGradientEffect::Make(GrContext* ctx,
+ const SkTwoPointConicalGradient& shader,
+ SkShader::TileMode tm,
+ const SkMatrix* localMatrix) {
SkMatrix matrix;
if (!shader.getLocalMatrix().invert(&matrix)) {
return nullptr;
@@ -1311,12 +1315,12 @@ GrFragmentProcessor* Gr2PtConicalGradientEffect::Create(GrContext* ctx,
SkScalar focalX;
ConicalType type = set_matrix_focal_conical(shader, &matrix, &focalX);
if (type == kInside_ConicalType) {
- return FocalInside2PtConicalEffect::Create(ctx, shader, matrix, tm, focalX);
+ return FocalInside2PtConicalEffect::Make(ctx, shader, matrix, tm, focalX);
} else if(type == kEdge_ConicalType) {
set_matrix_edge_conical(shader, &matrix);
- return Edge2PtConicalEffect::Create(ctx, shader, matrix, tm);
+ return Edge2PtConicalEffect::Make(ctx, shader, matrix, tm);
} else {
- return FocalOutside2PtConicalEffect::Create(ctx, shader, matrix, tm, focalX);
+ return FocalOutside2PtConicalEffect::Make(ctx, shader, matrix, tm, focalX);
}
}
@@ -1324,12 +1328,12 @@ GrFragmentProcessor* Gr2PtConicalGradientEffect::Create(GrContext* ctx,
ConicalType type = set_matrix_circle_conical(shader, &matrix, &info);
if (type == kInside_ConicalType) {
- return CircleInside2PtConicalEffect::Create(ctx, shader, matrix, tm, info);
+ return CircleInside2PtConicalEffect::Make(ctx, shader, matrix, tm, info);
} else if (type == kEdge_ConicalType) {
set_matrix_edge_conical(shader, &matrix);
- return Edge2PtConicalEffect::Create(ctx, shader, matrix, tm);
+ return Edge2PtConicalEffect::Make(ctx, shader, matrix, tm);
} else {
- return CircleOutside2PtConicalEffect::Create(ctx, shader, matrix, tm, info);
+ return CircleOutside2PtConicalEffect::Make(ctx, shader, matrix, tm, info);
}
}
diff --git a/src/effects/gradients/SkTwoPointConicalGradient_gpu.h b/src/effects/gradients/SkTwoPointConicalGradient_gpu.h
index 601a1667c4..9dd058d4b1 100644
--- a/src/effects/gradients/SkTwoPointConicalGradient_gpu.h
+++ b/src/effects/gradients/SkTwoPointConicalGradient_gpu.h
@@ -18,8 +18,8 @@ namespace Gr2PtConicalGradientEffect {
* Creates an effect that produces a two point conical gradient based on the
* shader passed in.
*/
- GrFragmentProcessor* Create(GrContext* ctx, const SkTwoPointConicalGradient& shader,
- SkShader::TileMode tm, const SkMatrix* localMatrix);
+ sk_sp<GrFragmentProcessor> Make(GrContext* ctx, const SkTwoPointConicalGradient& shader,
+ SkShader::TileMode tm, const SkMatrix* localMatrix);
};
#endif
diff --git a/src/gpu/GrBlurUtils.cpp b/src/gpu/GrBlurUtils.cpp
index 1e85b87dcf..94c6ea0669 100644
--- a/src/gpu/GrBlurUtils.cpp
+++ b/src/gpu/GrBlurUtils.cpp
@@ -35,8 +35,8 @@ static bool draw_mask(GrDrawContext* drawContext,
matrix.setTranslate(-SkIntToScalar(maskRect.fLeft), -SkIntToScalar(maskRect.fTop));
matrix.postIDiv(mask->width(), mask->height());
- grp->addCoverageFragmentProcessor(GrSimpleTextureEffect::Create(mask, matrix,
- kDevice_GrCoordSet))->unref();
+ grp->addCoverageFragmentProcessor(GrSimpleTextureEffect::Make(mask, matrix,
+ kDevice_GrCoordSet));
SkMatrix inverse;
if (!viewMatrix.invert(&inverse)) {
diff --git a/src/gpu/GrClipMaskManager.cpp b/src/gpu/GrClipMaskManager.cpp
index fd741b9a2b..9348181145 100644
--- a/src/gpu/GrClipMaskManager.cpp
+++ b/src/gpu/GrClipMaskManager.cpp
@@ -32,8 +32,8 @@ static const int kMaxAnalyticElements = 4;
////////////////////////////////////////////////////////////////////////////////
// set up the draw state to enable the aa clipping mask. Besides setting up the
// stage matrix this also alters the vertex layout
-static sk_sp<const GrFragmentProcessor> create_fp_for_mask(GrTexture* result,
- const SkIRect &devBound) {
+static sk_sp<GrFragmentProcessor> create_fp_for_mask(GrTexture* result,
+ const SkIRect &devBound) {
SkMatrix mat;
// We use device coords to compute the texture coordinates. We set our matrix to be a
// translation to the devBound, and then a scaling matrix to normalized coords.
@@ -42,7 +42,7 @@ static sk_sp<const GrFragmentProcessor> create_fp_for_mask(GrTexture* result,
SkIntToScalar(-devBound.fTop));
SkIRect domainTexels = SkIRect::MakeWH(devBound.width(), devBound.height());
- return sk_sp<const GrFragmentProcessor>(GrTextureDomainEffect::Create(
+ return sk_sp<GrFragmentProcessor>(GrTextureDomainEffect::Make(
result,
mat,
GrTextureDomain::MakeTexelDomain(result, domainTexels),
@@ -156,20 +156,15 @@ static bool get_analytic_clip_processor(const GrReducedClip::ElementList& elemen
bool abortIfAA,
SkVector& clipToRTOffset,
const SkRect* drawBounds,
- sk_sp<const GrFragmentProcessor>* resultFP) {
+ sk_sp<GrFragmentProcessor>* resultFP) {
SkRect boundsInClipSpace;
if (drawBounds) {
boundsInClipSpace = *drawBounds;
boundsInClipSpace.offset(-clipToRTOffset.fX, -clipToRTOffset.fY);
}
SkASSERT(elements.count() <= kMaxAnalyticElements);
- const GrFragmentProcessor* fps[kMaxAnalyticElements];
- for (int i = 0; i < kMaxAnalyticElements; ++i) {
- fps[i] = nullptr;
- }
- int fpCnt = 0;
+ SkSTArray<kMaxAnalyticElements, sk_sp<GrFragmentProcessor>> fps;
GrReducedClip::ElementList::Iter iter(elements);
- bool failed = false;
while (iter.get()) {
SkRegion::Op op = iter.get()->getOp();
bool invert;
@@ -190,18 +185,13 @@ static bool get_analytic_clip_processor(const GrReducedClip::ElementList& elemen
// element's primitive, so don't attempt to set skip.
break;
default:
- failed = true;
- break;
- }
- if (failed) {
- break;
+ return false;
}
if (!skip) {
GrPrimitiveEdgeType edgeType;
if (iter.get()->isAA()) {
if (abortIfAA) {
- failed = true;
- break;
+ return false;
}
edgeType =
invert ? kInverseFillAA_GrProcessorEdgeType : kFillAA_GrProcessorEdgeType;
@@ -212,41 +202,36 @@ static bool get_analytic_clip_processor(const GrReducedClip::ElementList& elemen
switch (iter.get()->getType()) {
case SkClipStack::Element::kPath_Type:
- fps[fpCnt] = GrConvexPolyEffect::Create(edgeType, iter.get()->getPath(),
- &clipToRTOffset);
+ fps.emplace_back(GrConvexPolyEffect::Make(edgeType, iter.get()->getPath(),
+ &clipToRTOffset));
break;
case SkClipStack::Element::kRRect_Type: {
SkRRect rrect = iter.get()->getRRect();
rrect.offset(clipToRTOffset.fX, clipToRTOffset.fY);
- fps[fpCnt] = GrRRectEffect::Create(edgeType, rrect);
+ fps.emplace_back(GrRRectEffect::Make(edgeType, rrect));
break;
}
case SkClipStack::Element::kRect_Type: {
SkRect rect = iter.get()->getRect();
rect.offset(clipToRTOffset.fX, clipToRTOffset.fY);
- fps[fpCnt] = GrConvexPolyEffect::Create(edgeType, rect);
+ fps.emplace_back(GrConvexPolyEffect::Make(edgeType, rect));
break;
}
default:
break;
}
- if (!fps[fpCnt]) {
- failed = true;
- break;
+ if (!fps.back()) {
+ return false;
}
- fpCnt++;
}
iter.next();
}
*resultFP = nullptr;
- if (!failed && fpCnt) {
- resultFP->reset(GrFragmentProcessor::RunInSeries(fps, fpCnt));
+ if (fps.count()) {
+ *resultFP = GrFragmentProcessor::RunInSeries(fps.begin(), fps.count());
}
- for (int i = 0; i < fpCnt; ++i) {
- fps[i]->unref();
- }
- return !failed;
+ return true;
}
////////////////////////////////////////////////////////////////////////////////
@@ -320,7 +305,7 @@ bool GrClipMaskManager::SetupClipping(GrContext* context,
disallowAnalyticAA = pipelineBuilder.isHWAntialias() ||
pipelineBuilder.hasUserStencilSettings();
}
- sk_sp<const GrFragmentProcessor> clipFP;
+ sk_sp<GrFragmentProcessor> clipFP;
if (elements.isEmpty() ||
(requiresAA &&
get_analytic_clip_processor(elements, disallowAnalyticAA, clipToRTOffset, devBounds,
@@ -328,10 +313,10 @@ bool GrClipMaskManager::SetupClipping(GrContext* context,
SkIRect scissorSpaceIBounds(clipSpaceIBounds);
scissorSpaceIBounds.offset(-clip.origin());
if (!devBounds || !SkRect::Make(scissorSpaceIBounds).contains(*devBounds)) {
- out->makeScissoredFPBased(clipFP, scissorSpaceIBounds);
+ out->makeScissoredFPBased(std::move(clipFP), scissorSpaceIBounds);
return true;
}
- out->makeFPBased(clipFP);
+ out->makeFPBased(std::move(clipFP));
return true;
}
}
@@ -683,7 +668,7 @@ bool GrClipMaskManager::CreateStencilClipMask(GrContext* context,
if (!clipPath.isEmpty()) {
if (canRenderDirectToStencil) {
GrPaint paint;
- SkSafeUnref(paint.setXPFactory(GrDisableColorXPFactory::Create()));
+ paint.setXPFactory(GrDisableColorXPFactory::Make());
paint.setAntiAlias(element->isAA());
GrPathRenderer::DrawPathArgs args;
@@ -724,7 +709,7 @@ bool GrClipMaskManager::CreateStencilClipMask(GrContext* context,
viewMatrix, element->getRect(), element->isAA(), *pass);
} else {
GrPaint paint;
- SkSafeUnref(paint.setXPFactory(GrDisableColorXPFactory::Create()));
+ paint.setXPFactory(GrDisableColorXPFactory::Make());
paint.setAntiAlias(element->isAA());
GrPathRenderer::DrawPathArgs args;
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index 51ab64d219..a9c6089728 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -317,12 +317,11 @@ bool GrContext::writeSurfacePixels(GrSurface* surface,
// temp buffer for doing sw premul conversion, if needed.
SkAutoSTMalloc<128 * 128, uint32_t> tmpPixels(0);
if (tempTexture) {
- SkAutoTUnref<const GrFragmentProcessor> fp;
+ sk_sp<GrFragmentProcessor> fp;
SkMatrix textureMatrix;
textureMatrix.setIDiv(tempTexture->width(), tempTexture->height());
if (applyPremulToSrc) {
- fp.reset(this->createUPMToPMEffect(tempTexture, tempDrawInfo.fSwizzle,
- textureMatrix));
+ fp = this->createUPMToPMEffect(tempTexture, tempDrawInfo.fSwizzle, textureMatrix);
// If premultiplying was the only reason for the draw, fall back to a straight write.
if (!fp) {
if (GrGpu::kCallerPrefersDraw_DrawPreference == drawPreference) {
@@ -334,8 +333,9 @@ bool GrContext::writeSurfacePixels(GrSurface* surface,
}
if (tempTexture) {
if (!fp) {
- fp.reset(GrConfigConversionEffect::Create(tempTexture, tempDrawInfo.fSwizzle,
- GrConfigConversionEffect::kNone_PMConversion, textureMatrix));
+ fp = GrConfigConversionEffect::Make(tempTexture, tempDrawInfo.fSwizzle,
+ GrConfigConversionEffect::kNone_PMConversion,
+ textureMatrix);
if (!fp) {
return false;
}
@@ -368,7 +368,7 @@ bool GrContext::writeSurfacePixels(GrSurface* surface,
return false;
}
GrPaint paint;
- paint.addColorFragmentProcessor(fp);
+ paint.addColorFragmentProcessor(std::move(fp));
paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
paint.setAllowSRGBInputs(true);
SkRect rect = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(height));
@@ -461,10 +461,10 @@ bool GrContext::readSurfacePixels(GrSurface* src,
SkMatrix textureMatrix;
textureMatrix.setTranslate(SkIntToScalar(left), SkIntToScalar(top));
textureMatrix.postIDiv(src->width(), src->height());
- SkAutoTUnref<const GrFragmentProcessor> fp;
+ sk_sp<GrFragmentProcessor> fp;
if (unpremul) {
- fp.reset(this->createPMToUPMEffect(src->asTexture(), tempDrawInfo.fSwizzle,
- textureMatrix));
+ fp = this->createPMToUPMEffect(src->asTexture(), tempDrawInfo.fSwizzle,
+ textureMatrix);
if (fp) {
unpremul = false; // we no longer need to do this on CPU after the read back.
} else if (GrGpu::kCallerPrefersDraw_DrawPreference == drawPreference) {
@@ -474,12 +474,13 @@ bool GrContext::readSurfacePixels(GrSurface* src,
}
}
if (!fp && temp) {
- fp.reset(GrConfigConversionEffect::Create(src->asTexture(), tempDrawInfo.fSwizzle,
- GrConfigConversionEffect::kNone_PMConversion, textureMatrix));
+ fp = GrConfigConversionEffect::Make(src->asTexture(), tempDrawInfo.fSwizzle,
+ GrConfigConversionEffect::kNone_PMConversion,
+ textureMatrix);
}
if (fp) {
GrPaint paint;
- paint.addColorFragmentProcessor(fp);
+ paint.addColorFragmentProcessor(std::move(fp));
paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
paint.setAllowSRGBInputs(true);
SkRect rect = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(height));
@@ -550,7 +551,7 @@ bool GrContext::applyGamma(GrRenderTarget* dst, GrTexture* src, SkScalar gamma){
GrPaint paint;
paint.addColorTextureProcessor(src, GrCoordTransform::MakeDivByTextureWHMatrix(src));
if (!SkScalarNearlyEqual(gamma, 1.0f)) {
- paint.addColorFragmentProcessor(GrGammaEffect::Create(gamma))->unref();
+ paint.addColorFragmentProcessor(GrGammaEffect::Make(gamma));
}
paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
paint.setGammaCorrect(true);
@@ -709,7 +710,7 @@ void GrContext::testPMConversionsIfNecessary(uint32_t flags) {
}
}
-const GrFragmentProcessor* GrContext::createPMToUPMEffect(GrTexture* texture,
+sk_sp<GrFragmentProcessor> GrContext::createPMToUPMEffect(GrTexture* texture,
const GrSwizzle& swizzle,
const SkMatrix& matrix) const {
ASSERT_SINGLE_OWNER
@@ -718,13 +719,13 @@ const GrFragmentProcessor* GrContext::createPMToUPMEffect(GrTexture* texture,
GrConfigConversionEffect::PMConversion pmToUPM =
static_cast<GrConfigConversionEffect::PMConversion>(fPMToUPMConversion);
if (GrConfigConversionEffect::kNone_PMConversion != pmToUPM) {
- return GrConfigConversionEffect::Create(texture, swizzle, pmToUPM, matrix);
+ return GrConfigConversionEffect::Make(texture, swizzle, pmToUPM, matrix);
} else {
return nullptr;
}
}
-const GrFragmentProcessor* GrContext::createUPMToPMEffect(GrTexture* texture,
+sk_sp<GrFragmentProcessor> GrContext::createUPMToPMEffect(GrTexture* texture,
const GrSwizzle& swizzle,
const SkMatrix& matrix) const {
ASSERT_SINGLE_OWNER
@@ -733,7 +734,7 @@ const GrFragmentProcessor* GrContext::createUPMToPMEffect(GrTexture* texture,
GrConfigConversionEffect::PMConversion upmToPM =
static_cast<GrConfigConversionEffect::PMConversion>(fUPMToPMConversion);
if (GrConfigConversionEffect::kNone_PMConversion != upmToPM) {
- return GrConfigConversionEffect::Create(texture, swizzle, upmToPM, matrix);
+ return GrConfigConversionEffect::Make(texture, swizzle, upmToPM, matrix);
} else {
return nullptr;
}
diff --git a/src/gpu/GrDefaultGeoProcFactory.cpp b/src/gpu/GrDefaultGeoProcFactory.cpp
index df13d5d9bb..9efd9eb718 100644
--- a/src/gpu/GrDefaultGeoProcFactory.cpp
+++ b/src/gpu/GrDefaultGeoProcFactory.cpp
@@ -8,6 +8,7 @@
#include "GrDefaultGeoProcFactory.h"
#include "GrInvariantOutput.h"
+#include "SkRefCnt.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
#include "glsl/GrGLSLGeometryProcessor.h"
#include "glsl/GrGLSLVertexShaderBuilder.h"
@@ -30,15 +31,16 @@ enum GPFlag {
class DefaultGeoProc : public GrGeometryProcessor {
public:
- static GrGeometryProcessor* Create(uint32_t gpTypeFlags,
- GrColor color,
- const SkMatrix& viewMatrix,
- const SkMatrix& localMatrix,
- bool localCoordsWillBeRead,
- bool coverageWillBeIgnored,
- uint8_t coverage) {
- return new DefaultGeoProc(gpTypeFlags, color, viewMatrix, localMatrix, coverage,
- localCoordsWillBeRead, coverageWillBeIgnored);
+ static sk_sp<GrGeometryProcessor> Make(uint32_t gpTypeFlags,
+ GrColor color,
+ const SkMatrix& viewMatrix,
+ const SkMatrix& localMatrix,
+ bool localCoordsWillBeRead,
+ bool coverageWillBeIgnored,
+ uint8_t coverage) {
+ return sk_sp<GrGeometryProcessor>(new DefaultGeoProc(
+ gpTypeFlags, color, viewMatrix, localMatrix, coverage,
+ localCoordsWillBeRead, coverageWillBeIgnored));
}
const char* name() const override { return "DefaultGeometryProcessor"; }
@@ -271,7 +273,7 @@ private:
GR_DEFINE_GEOMETRY_PROCESSOR_TEST(DefaultGeoProc);
-const GrGeometryProcessor* DefaultGeoProc::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrGeometryProcessor> DefaultGeoProc::TestCreate(GrProcessorTestData* d) {
uint32_t flags = 0;
if (d->fRandom->nextBool()) {
flags |= kColor_GPFlag;
@@ -286,19 +288,19 @@ const GrGeometryProcessor* DefaultGeoProc::TestCreate(GrProcessorTestData* d) {
flags |= kTransformedLocalCoord_GPFlag;
}
- return DefaultGeoProc::Create(flags,
- GrRandomColor(d->fRandom),
- GrTest::TestMatrix(d->fRandom),
- GrTest::TestMatrix(d->fRandom),
- d->fRandom->nextBool(),
- d->fRandom->nextBool(),
- GrRandomCoverage(d->fRandom));
+ return DefaultGeoProc::Make(flags,
+ GrRandomColor(d->fRandom),
+ GrTest::TestMatrix(d->fRandom),
+ GrTest::TestMatrix(d->fRandom),
+ d->fRandom->nextBool(),
+ d->fRandom->nextBool(),
+ GrRandomCoverage(d->fRandom));
}
-const GrGeometryProcessor* GrDefaultGeoProcFactory::Create(const Color& color,
- const Coverage& coverage,
- const LocalCoords& localCoords,
- const SkMatrix& viewMatrix) {
+sk_sp<GrGeometryProcessor> GrDefaultGeoProcFactory::Make(const Color& color,
+ const Coverage& coverage,
+ const LocalCoords& localCoords,
+ const SkMatrix& viewMatrix) {
uint32_t flags = 0;
flags |= color.fType == Color::kAttribute_Type ? kColor_GPFlag : 0;
flags |= coverage.fType == Coverage::kAttribute_Type ? kCoverage_GPFlag : 0;
@@ -311,16 +313,16 @@ const GrGeometryProcessor* GrDefaultGeoProcFactory::Create(const Color& color,
bool localCoordsWillBeRead = localCoords.fType != LocalCoords::kUnused_Type;
GrColor inColor = color.fColor;
- return DefaultGeoProc::Create(flags,
- inColor,
- viewMatrix,
- localCoords.fMatrix ? *localCoords.fMatrix : SkMatrix::I(),
- localCoordsWillBeRead,
- coverageWillBeIgnored,
- inCoverage);
+ return DefaultGeoProc::Make(flags,
+ inColor,
+ viewMatrix,
+ localCoords.fMatrix ? *localCoords.fMatrix : SkMatrix::I(),
+ localCoordsWillBeRead,
+ coverageWillBeIgnored,
+ inCoverage);
}
-const GrGeometryProcessor* GrDefaultGeoProcFactory::CreateForDeviceSpace(
+sk_sp<GrGeometryProcessor> GrDefaultGeoProcFactory::MakeForDeviceSpace(
const Color& color,
const Coverage& coverage,
const LocalCoords& localCoords,
@@ -339,5 +341,5 @@ const GrGeometryProcessor* GrDefaultGeoProcFactory::CreateForDeviceSpace(
}
LocalCoords inverted(LocalCoords::kUsePosition_Type, &invert);
- return Create(color, coverage, inverted, SkMatrix::I());
+ return Make(color, coverage, inverted, SkMatrix::I());
}
diff --git a/src/gpu/GrDefaultGeoProcFactory.h b/src/gpu/GrDefaultGeoProcFactory.h
index 23bcb451c6..f7ddb061fd 100644
--- a/src/gpu/GrDefaultGeoProcFactory.h
+++ b/src/gpu/GrDefaultGeoProcFactory.h
@@ -115,20 +115,20 @@ namespace GrDefaultGeoProcFactory {
const SkMatrix* fMatrix;
};
- const GrGeometryProcessor* Create(const Color&,
- const Coverage&,
- const LocalCoords&,
- const SkMatrix& viewMatrix);
+ sk_sp<GrGeometryProcessor> Make(const Color&,
+ const Coverage&,
+ const LocalCoords&,
+ const SkMatrix& viewMatrix);
/*
* Use this factory to create a GrGeometryProcessor that expects a device space vertex position
* attribute. The view matrix must still be provided to compute correctly transformed
* coordinates for GrFragmentProcessors. It may fail if the view matrix is not invertible.
*/
- const GrGeometryProcessor* CreateForDeviceSpace(const Color&,
- const Coverage&,
- const LocalCoords&,
- const SkMatrix& viewMatrix);
+ sk_sp<GrGeometryProcessor> MakeForDeviceSpace(const Color&,
+ const Coverage&,
+ const LocalCoords&,
+ const SkMatrix& viewMatrix);
inline size_t DefaultVertexStride() { return sizeof(PositionAttr); }
};
diff --git a/src/gpu/GrDrawContext.cpp b/src/gpu/GrDrawContext.cpp
index 2f78d1e4f6..64ce0cec31 100644
--- a/src/gpu/GrDrawContext.cpp
+++ b/src/gpu/GrDrawContext.cpp
@@ -420,7 +420,7 @@ void GrDrawContextPriv::stencilRect(const GrFixedClip& clip,
GrPaint paint;
paint.setAntiAlias(doAA);
- SkSafeUnref(paint.setXPFactory(GrDisableColorXPFactory::Create()));
+ paint.setXPFactory(GrDisableColorXPFactory::Make());
bool useHWAA;
SkAutoTUnref<GrDrawBatch> batch(
@@ -671,18 +671,18 @@ bool GrDrawContext::drawFilledDRRect(const GrClip& clip,
grPaint.setAntiAlias(false);
// TODO these need to be a geometry processors
- SkAutoTUnref<GrFragmentProcessor> innerEffect(GrRRectEffect::Create(innerEdgeType, *inner));
+ sk_sp<GrFragmentProcessor> innerEffect(GrRRectEffect::Make(innerEdgeType, *inner));
if (!innerEffect) {
return false;
}
- SkAutoTUnref<GrFragmentProcessor> outerEffect(GrRRectEffect::Create(outerEdgeType, *outer));
+ sk_sp<GrFragmentProcessor> outerEffect(GrRRectEffect::Make(outerEdgeType, *outer));
if (!outerEffect) {
return false;
}
- grPaint.addCoverageFragmentProcessor(innerEffect);
- grPaint.addCoverageFragmentProcessor(outerEffect);
+ grPaint.addCoverageFragmentProcessor(std::move(innerEffect));
+ grPaint.addCoverageFragmentProcessor(std::move(outerEffect));
SkRect bounds = outer->getBounds();
if (applyAA) {
diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp
index ac0c766704..7213a92152 100644
--- a/src/gpu/GrDrawTarget.cpp
+++ b/src/gpu/GrDrawTarget.cpp
@@ -245,9 +245,9 @@ void GrDrawTarget::drawBatch(const GrPipelineBuilder& pipelineBuilder,
// TODO: this is the only remaining usage of the AutoRestoreFragmentProcessorState - remove it
GrPipelineBuilder::AutoRestoreFragmentProcessorState arfps;
- if (appliedClip.clipCoverageFragmentProcessor()) {
+ if (appliedClip.getClipCoverageFragmentProcessor()) {
arfps.set(&pipelineBuilder);
- arfps.addCoverageFragmentProcessor(appliedClip.clipCoverageFragmentProcessor());
+ arfps.addCoverageFragmentProcessor(sk_ref_sp(appliedClip.getClipCoverageFragmentProcessor()));
}
GrPipeline::CreateArgs args;
@@ -288,11 +288,12 @@ void GrDrawTarget::drawBatch(const GrPipelineBuilder& pipelineBuilder,
finalScissor.set(ibounds);
args.fScissor = &finalScissor;
}
- args.fOpts.fColorPOI.completeCalculations(pipelineBuilder.fColorFragmentProcessors.begin(),
- pipelineBuilder.numColorFragmentProcessors());
+ args.fOpts.fColorPOI.completeCalculations(
+ sk_sp_address_as_pointer_address(pipelineBuilder.fColorFragmentProcessors.begin()),
+ pipelineBuilder.numColorFragmentProcessors());
args.fOpts.fCoveragePOI.completeCalculations(
- pipelineBuilder.fCoverageFragmentProcessors.begin(),
- pipelineBuilder.numCoverageFragmentProcessors());
+ sk_sp_address_as_pointer_address(pipelineBuilder.fCoverageFragmentProcessors.begin()),
+ pipelineBuilder.numCoverageFragmentProcessors());
if (!this->setupDstReadIfNecessary(pipelineBuilder, drawContext->accessRenderTarget(),
clip, args.fOpts,
&args.fDstTexture, batch->bounds())) {
@@ -330,7 +331,7 @@ void GrDrawTarget::stencilPath(const GrPipelineBuilder& pipelineBuilder,
// Coverage AA does not make sense when rendering to the stencil buffer. The caller should never
// attempt this in a situation that would require coverage AA.
- SkASSERT(!appliedClip.clipCoverageFragmentProcessor());
+ SkASSERT(!appliedClip.getClipCoverageFragmentProcessor());
GrStencilAttachment* stencilAttachment = fResourceProvider->attachStencilAttachment(
drawContext->accessRenderTarget());
@@ -379,8 +380,7 @@ void GrDrawTarget::clear(const SkIRect* rect,
// TODO: flip this into real draw!
GrPipelineBuilder pipelineBuilder;
- pipelineBuilder.setXPFactory(
- GrPorterDuffXPFactory::Create(SkXfermode::kSrc_Mode))->unref();
+ pipelineBuilder.setXPFactory(GrPorterDuffXPFactory::Make(SkXfermode::kSrc_Mode));
SkRect scalarRect = SkRect::Make(*rect);
SkAutoTUnref<GrDrawBatch> batch(
diff --git a/src/gpu/GrFragmentProcessor.cpp b/src/gpu/GrFragmentProcessor.cpp
index 9524c84df1..96a0f716c9 100644
--- a/src/gpu/GrFragmentProcessor.cpp
+++ b/src/gpu/GrFragmentProcessor.cpp
@@ -89,7 +89,7 @@ void GrFragmentProcessor::addCoordTransform(const GrCoordTransform* transform) {
fNumTransformsExclChildren++;
}
-int GrFragmentProcessor::registerChildProcessor(const GrFragmentProcessor* child) {
+int GrFragmentProcessor::registerChildProcessor(sk_sp<GrFragmentProcessor> child) {
// Append the child's transforms to our transforms array and the child's textures array to our
// textures array
if (!child->fCoordTransforms.empty()) {
@@ -101,15 +101,15 @@ int GrFragmentProcessor::registerChildProcessor(const GrFragmentProcessor* child
child->fTextureAccesses.begin());
}
- int index = fChildProcessors.count();
- fChildProcessors.push_back(SkRef(child));
-
this->combineRequiredFeatures(*child);
if (child->usesLocalCoords()) {
fUsesLocalCoords = true;
}
+ int index = fChildProcessors.count();
+ fChildProcessors.push_back(child.release());
+
return index;
}
@@ -134,20 +134,21 @@ bool GrFragmentProcessor::hasSameTransforms(const GrFragmentProcessor& that) con
return true;
}
-const GrFragmentProcessor* GrFragmentProcessor::MulOutputByInputAlpha(
- const GrFragmentProcessor* fp) {
+sk_sp<GrFragmentProcessor> GrFragmentProcessor::MulOutputByInputAlpha(
+ sk_sp<GrFragmentProcessor> fp) {
if (!fp) {
return nullptr;
}
- return GrXfermodeFragmentProcessor::CreateFromDstProcessor(fp, SkXfermode::kDstIn_Mode);
+ return GrXfermodeFragmentProcessor::MakeFromDstProcessor(std::move(fp),
+ SkXfermode::kDstIn_Mode);
}
-const GrFragmentProcessor* GrFragmentProcessor::MulOutputByInputUnpremulColor(
- const GrFragmentProcessor* fp) {
+sk_sp<GrFragmentProcessor> GrFragmentProcessor::MulOutputByInputUnpremulColor(
+ sk_sp<GrFragmentProcessor> fp) {
class PremulFragmentProcessor : public GrFragmentProcessor {
public:
- PremulFragmentProcessor(const GrFragmentProcessor* processor) {
+ PremulFragmentProcessor(sk_sp<GrFragmentProcessor> processor) {
this->initClassID<PremulFragmentProcessor>();
this->registerChildProcessor(processor);
}
@@ -209,19 +210,19 @@ const GrFragmentProcessor* GrFragmentProcessor::MulOutputByInputUnpremulColor(
if (!fp) {
return nullptr;
}
- return new PremulFragmentProcessor(fp);
+ return sk_sp<GrFragmentProcessor>(new PremulFragmentProcessor(std::move(fp)));
}
//////////////////////////////////////////////////////////////////////////////
-const GrFragmentProcessor* GrFragmentProcessor::OverrideInput(const GrFragmentProcessor* fp,
+sk_sp<GrFragmentProcessor> GrFragmentProcessor::OverrideInput(sk_sp<GrFragmentProcessor> fp,
GrColor color) {
class ReplaceInputFragmentProcessor : public GrFragmentProcessor {
public:
- ReplaceInputFragmentProcessor(const GrFragmentProcessor* child, GrColor color)
+ ReplaceInputFragmentProcessor(sk_sp<GrFragmentProcessor> child, GrColor color)
: fColor(color) {
this->initClassID<ReplaceInputFragmentProcessor>();
- this->registerChildProcessor(child);
+ this->registerChildProcessor(std::move(child));
}
const char* name() const override { return "Replace Color"; }
@@ -285,21 +286,21 @@ const GrFragmentProcessor* GrFragmentProcessor::OverrideInput(const GrFragmentPr
GrInvariantOutput childOut(0x0, kNone_GrColorComponentFlags, false);
fp->computeInvariantOutput(&childOut);
if (childOut.willUseInputColor()) {
- return new ReplaceInputFragmentProcessor(fp, color);
+ return sk_sp<GrFragmentProcessor>(new ReplaceInputFragmentProcessor(std::move(fp), color));
} else {
- return SkRef(fp);
+ return fp;
}
}
-const GrFragmentProcessor* GrFragmentProcessor::RunInSeries(const GrFragmentProcessor* series[],
+sk_sp<GrFragmentProcessor> GrFragmentProcessor::RunInSeries(sk_sp<GrFragmentProcessor>* series,
int cnt) {
class SeriesFragmentProcessor : public GrFragmentProcessor {
public:
- SeriesFragmentProcessor(const GrFragmentProcessor* children[], int cnt){
+ SeriesFragmentProcessor(sk_sp<GrFragmentProcessor>* children, int cnt){
SkASSERT(cnt > 1);
this->initClassID<SeriesFragmentProcessor>();
for (int i = 0; i < cnt; ++i) {
- this->registerChildProcessor(children[i]);
+ this->registerChildProcessor(std::move(children[i]));
}
}
@@ -330,13 +331,8 @@ const GrFragmentProcessor* GrFragmentProcessor::RunInSeries(const GrFragmentProc
void onComputeInvariantOutput(GrInvariantOutput* inout) const override {
GrProcOptInfo info;
- SkTDArray<const GrFragmentProcessor*> children;
- children.setCount(this->numChildProcessors());
- for (int i = 0; i < children.count(); ++i) {
- children[i] = &this->childProcessor(i);
- }
- info.calcWithInitialValues(children.begin(), children.count(), inout->color(),
- inout->validFlags(), false, false);
+ info.calcWithInitialValues(fChildProcessors.begin(), fChildProcessors.count(),
+ inout->color(), inout->validFlags(), false, false);
for (int i = 0; i < this->numChildProcessors(); ++i) {
this->childProcessor(i).computeInvariantOutput(inout);
}
@@ -348,36 +344,34 @@ const GrFragmentProcessor* GrFragmentProcessor::RunInSeries(const GrFragmentProc
}
// Run the through the series, do the invariant output processing, and look for eliminations.
- SkTDArray<const GrFragmentProcessor*> replacementSeries;
- SkAutoTUnref<const GrFragmentProcessor> colorFP;
GrProcOptInfo info;
-
- info.calcWithInitialValues(series, cnt, 0x0, kNone_GrColorComponentFlags, false, false);
+ info.calcWithInitialValues(sk_sp_address_as_pointer_address(series), cnt,
+ 0x0, kNone_GrColorComponentFlags, false, false);
if (kRGBA_GrColorComponentFlags == info.validFlags()) {
- return GrConstColorProcessor::Create(info.color(),
- GrConstColorProcessor::kIgnore_InputMode);
+ return GrConstColorProcessor::Make(info.color(), GrConstColorProcessor::kIgnore_InputMode);
+ }
+
+ SkTArray<sk_sp<GrFragmentProcessor>> replacementSeries;
+
+ int firstIdx = info.firstEffectiveProcessorIndex();
+ cnt -= firstIdx;
+ if (firstIdx > 0 && info.inputColorIsUsed()) {
+ sk_sp<GrFragmentProcessor> colorFP(GrConstColorProcessor::Make(
+ info.inputColorToFirstEffectiveProccesor(), GrConstColorProcessor::kIgnore_InputMode));
+ cnt += 1;
+ replacementSeries.reserve(cnt);
+ replacementSeries.emplace_back(std::move(colorFP));
+ for (int i = 0; i < cnt - 1; ++i) {
+ replacementSeries.emplace_back(std::move(series[firstIdx + i]));
+ }
+ series = replacementSeries.begin();
} else {
- int firstIdx = info.firstEffectiveProcessorIndex();
+ series += firstIdx;
cnt -= firstIdx;
- if (firstIdx > 0 && info.inputColorIsUsed()) {
- colorFP.reset(GrConstColorProcessor::Create(info.inputColorToFirstEffectiveProccesor(),
- GrConstColorProcessor::kIgnore_InputMode));
- cnt += 1;
- replacementSeries.setCount(cnt);
- replacementSeries[0] = colorFP;
- for (int i = 0; i < cnt - 1; ++i) {
- replacementSeries[i + 1] = series[firstIdx + i];
- }
- series = replacementSeries.begin();
- } else {
- series += firstIdx;
- cnt -= firstIdx;
- }
}
if (1 == cnt) {
- return SkRef(series[0]);
- } else {
- return new SeriesFragmentProcessor(series, cnt);
+ return series[0];
}
+ return sk_sp<GrFragmentProcessor>(new SeriesFragmentProcessor(series, cnt));
}
diff --git a/src/gpu/GrOvalRenderer.cpp b/src/gpu/GrOvalRenderer.cpp
index 2accbf67ae..cef08f431e 100644
--- a/src/gpu/GrOvalRenderer.cpp
+++ b/src/gpu/GrOvalRenderer.cpp
@@ -184,8 +184,9 @@ private:
GR_DEFINE_GEOMETRY_PROCESSOR_TEST(CircleGeometryProcessor);
-const GrGeometryProcessor* CircleGeometryProcessor::TestCreate(GrProcessorTestData* d) {
- return new CircleGeometryProcessor(d->fRandom->nextBool(), GrTest::TestMatrix(d->fRandom));
+sk_sp<GrGeometryProcessor> CircleGeometryProcessor::TestCreate(GrProcessorTestData* d) {
+ return sk_sp<GrGeometryProcessor>(
+ new CircleGeometryProcessor(d->fRandom->nextBool(), GrTest::TestMatrix(d->fRandom)));
}
///////////////////////////////////////////////////////////////////////////////
@@ -335,8 +336,9 @@ private:
GR_DEFINE_GEOMETRY_PROCESSOR_TEST(EllipseGeometryProcessor);
-const GrGeometryProcessor* EllipseGeometryProcessor::TestCreate(GrProcessorTestData* d) {
- return new EllipseGeometryProcessor(d->fRandom->nextBool(), GrTest::TestMatrix(d->fRandom));
+sk_sp<GrGeometryProcessor> EllipseGeometryProcessor::TestCreate(GrProcessorTestData* d) {
+ return sk_sp<GrGeometryProcessor>(
+ new EllipseGeometryProcessor(d->fRandom->nextBool(), GrTest::TestMatrix(d->fRandom)));
}
///////////////////////////////////////////////////////////////////////////////
@@ -514,9 +516,10 @@ private:
GR_DEFINE_GEOMETRY_PROCESSOR_TEST(DIEllipseGeometryProcessor);
-const GrGeometryProcessor* DIEllipseGeometryProcessor::TestCreate(GrProcessorTestData* d) {
- return new DIEllipseGeometryProcessor(GrTest::TestMatrix(d->fRandom),
- (DIEllipseStyle)(d->fRandom->nextRangeU(0,2)));
+sk_sp<GrGeometryProcessor> DIEllipseGeometryProcessor::TestCreate(GrProcessorTestData* d) {
+ return sk_sp<GrGeometryProcessor>(
+ new DIEllipseGeometryProcessor(GrTest::TestMatrix(d->fRandom),
+ (DIEllipseStyle)(d->fRandom->nextRangeU(0,2))));
}
///////////////////////////////////////////////////////////////////////////////
diff --git a/src/gpu/GrPaint.cpp b/src/gpu/GrPaint.cpp
index f41469e08e..fd78f9f819 100644
--- a/src/gpu/GrPaint.cpp
+++ b/src/gpu/GrPaint.cpp
@@ -19,36 +19,34 @@ GrPaint::GrPaint()
, fColor(GrColor_WHITE) {}
void GrPaint::setCoverageSetOpXPFactory(SkRegion::Op regionOp, bool invertCoverage) {
- fXPFactory.reset(GrCoverageSetOpXPFactory::Create(regionOp, invertCoverage));
+ fXPFactory = GrCoverageSetOpXPFactory::Make(regionOp, invertCoverage);
}
void GrPaint::addColorTextureProcessor(GrTexture* texture, const SkMatrix& matrix) {
- this->addColorFragmentProcessor(GrSimpleTextureEffect::Create(texture, matrix))->unref();
+ this->addColorFragmentProcessor(GrSimpleTextureEffect::Make(texture, matrix));
}
void GrPaint::addCoverageTextureProcessor(GrTexture* texture, const SkMatrix& matrix) {
- this->addCoverageFragmentProcessor(GrSimpleTextureEffect::Create(texture, matrix))->unref();
+ this->addCoverageFragmentProcessor(GrSimpleTextureEffect::Make(texture, matrix));
}
void GrPaint::addColorTextureProcessor(GrTexture* texture,
const SkMatrix& matrix,
const GrTextureParams& params) {
- this->addColorFragmentProcessor(GrSimpleTextureEffect::Create(texture,
- matrix, params))->unref();
+ this->addColorFragmentProcessor(GrSimpleTextureEffect::Make(texture, matrix, params));
}
void GrPaint::addCoverageTextureProcessor(GrTexture* texture,
const SkMatrix& matrix,
const GrTextureParams& params) {
- this->addCoverageFragmentProcessor(GrSimpleTextureEffect::Create(texture,
- matrix, params))->unref();
+ this->addCoverageFragmentProcessor(GrSimpleTextureEffect::Make(texture, matrix, params));
}
bool GrPaint::isConstantBlendedColor(GrColor* color) const {
GrProcOptInfo colorProcInfo;
- colorProcInfo.calcWithInitialValues(fColorFragmentProcessors.begin(),
- this->numColorFragmentProcessors(), fColor,
- kRGBA_GrColorComponentFlags, false);
+ colorProcInfo.calcWithInitialValues(
+ sk_sp_address_as_pointer_address(fColorFragmentProcessors.begin()),
+ this->numColorFragmentProcessors(), fColor, kRGBA_GrColorComponentFlags, false);
GrXPFactory::InvariantBlendedColor blendedColor;
if (fXPFactory) {
diff --git a/src/gpu/GrPipelineBuilder.cpp b/src/gpu/GrPipelineBuilder.cpp
index f7848ba9d6..e142de25a3 100644
--- a/src/gpu/GrPipelineBuilder.cpp
+++ b/src/gpu/GrPipelineBuilder.cpp
@@ -27,11 +27,11 @@ GrPipelineBuilder::GrPipelineBuilder(const GrPaint& paint, bool useHWAA)
SkDEBUGCODE(fBlockEffectRemovalCnt = 0;)
for (int i = 0; i < paint.numColorFragmentProcessors(); ++i) {
- fColorFragmentProcessors.push_back(SkRef(paint.getColorFragmentProcessor(i)));
+ fColorFragmentProcessors.emplace_back(SkRef(paint.getColorFragmentProcessor(i)));
}
for (int i = 0; i < paint.numCoverageFragmentProcessors(); ++i) {
- fCoverageFragmentProcessors.push_back(SkRef(paint.getCoverageFragmentProcessor(i)));
+ fCoverageFragmentProcessors.emplace_back(SkRef(paint.getCoverageFragmentProcessor(i)));
}
fXPFactory.reset(SkSafeRef(paint.getXPFactory()));
@@ -58,17 +58,12 @@ void GrPipelineBuilder::AutoRestoreFragmentProcessorState::set(
if (fPipelineBuilder) {
int m = fPipelineBuilder->numColorFragmentProcessors() - fColorEffectCnt;
SkASSERT(m >= 0);
- for (int i = 0; i < m; ++i) {
- fPipelineBuilder->fColorFragmentProcessors.fromBack(i)->unref();
- }
fPipelineBuilder->fColorFragmentProcessors.pop_back_n(m);
int n = fPipelineBuilder->numCoverageFragmentProcessors() - fCoverageEffectCnt;
SkASSERT(n >= 0);
- for (int i = 0; i < n; ++i) {
- fPipelineBuilder->fCoverageFragmentProcessors.fromBack(i)->unref();
- }
fPipelineBuilder->fCoverageFragmentProcessors.pop_back_n(n);
+
SkDEBUGCODE(--fPipelineBuilder->fBlockEffectRemovalCnt;)
}
fPipelineBuilder = const_cast<GrPipelineBuilder*>(pipelineBuilder);
@@ -83,10 +78,4 @@ void GrPipelineBuilder::AutoRestoreFragmentProcessorState::set(
GrPipelineBuilder::~GrPipelineBuilder() {
SkASSERT(0 == fBlockEffectRemovalCnt);
- for (int i = 0; i < fColorFragmentProcessors.count(); ++i) {
- fColorFragmentProcessors[i]->unref();
- }
- for (int i = 0; i < fCoverageFragmentProcessors.count(); ++i) {
- fCoverageFragmentProcessors[i]->unref();
- }
}
diff --git a/src/gpu/GrPipelineBuilder.h b/src/gpu/GrPipelineBuilder.h
index cccbc2c47d..a7556eb59d 100644
--- a/src/gpu/GrPipelineBuilder.h
+++ b/src/gpu/GrPipelineBuilder.h
@@ -16,6 +16,7 @@
#include "GrUserStencilSettings.h"
#include "GrXferProcessor.h"
#include "SkMatrix.h"
+#include "SkRefCnt.h"
#include "effects/GrCoverageSetOpXP.h"
#include "effects/GrDisableColorXP.h"
#include "effects/GrPorterDuffXferProcessor.h"
@@ -56,47 +57,43 @@ public:
this->numCoverageFragmentProcessors(); }
const GrFragmentProcessor* getColorFragmentProcessor(int idx) const {
- return fColorFragmentProcessors[idx];
+ return fColorFragmentProcessors[idx].get();
}
const GrFragmentProcessor* getCoverageFragmentProcessor(int idx) const {
- return fCoverageFragmentProcessors[idx];
+ return fCoverageFragmentProcessors[idx].get();
}
- const GrFragmentProcessor* addColorFragmentProcessor(const GrFragmentProcessor* processor) {
+ void addColorFragmentProcessor(sk_sp<GrFragmentProcessor> processor) {
SkASSERT(processor);
- fColorFragmentProcessors.push_back(SkRef(processor));
- return processor;
+ fColorFragmentProcessors.push_back(std::move(processor));
}
- const GrFragmentProcessor* addCoverageFragmentProcessor(const GrFragmentProcessor* processor) {
+ void addCoverageFragmentProcessor(sk_sp<GrFragmentProcessor> processor) {
SkASSERT(processor);
- fCoverageFragmentProcessors.push_back(SkRef(processor));
- return processor;
+ fCoverageFragmentProcessors.push_back(std::move(processor));
}
/**
* Creates a GrSimpleTextureEffect that uses local coords as texture coordinates.
*/
void addColorTextureProcessor(GrTexture* texture, const SkMatrix& matrix) {
- this->addColorFragmentProcessor(GrSimpleTextureEffect::Create(texture, matrix))->unref();
+ this->addColorFragmentProcessor(GrSimpleTextureEffect::Make(texture, matrix));
}
void addCoverageTextureProcessor(GrTexture* texture, const SkMatrix& matrix) {
- this->addCoverageFragmentProcessor(GrSimpleTextureEffect::Create(texture, matrix))->unref();
+ this->addCoverageFragmentProcessor(GrSimpleTextureEffect::Make(texture, matrix));
}
void addColorTextureProcessor(GrTexture* texture,
const SkMatrix& matrix,
const GrTextureParams& params) {
- this->addColorFragmentProcessor(GrSimpleTextureEffect::Create(texture, matrix,
- params))->unref();
+ this->addColorFragmentProcessor(GrSimpleTextureEffect::Make(texture, matrix, params));
}
void addCoverageTextureProcessor(GrTexture* texture,
const SkMatrix& matrix,
const GrTextureParams& params) {
- this->addCoverageFragmentProcessor(GrSimpleTextureEffect::Create(texture, matrix,
- params))->unref();
+ this->addCoverageFragmentProcessor(GrSimpleTextureEffect::Make(texture, matrix, params));
}
/**
@@ -125,10 +122,9 @@ public:
bool isSet() const { return SkToBool(fPipelineBuilder); }
- const GrFragmentProcessor* addCoverageFragmentProcessor(
- const GrFragmentProcessor* processor) {
+ void addCoverageFragmentProcessor(sk_sp<GrFragmentProcessor> processor) {
SkASSERT(this->isSet());
- return fPipelineBuilder->addCoverageFragmentProcessor(processor);
+ return fPipelineBuilder->addCoverageFragmentProcessor(std::move(processor));
}
private:
@@ -148,9 +144,8 @@ public:
* Installs a GrXPFactory. This object controls how src color, fractional pixel coverage,
* and the dst color are blended.
*/
- const GrXPFactory* setXPFactory(const GrXPFactory* xpFactory) {
- fXPFactory.reset(SkSafeRef(xpFactory));
- return xpFactory;
+ void setXPFactory(sk_sp<GrXPFactory> xpFactory) {
+ fXPFactory = std::move(xpFactory);
}
/**
@@ -158,11 +153,11 @@ public:
* rendering to the stencil buffer.
*/
void setDisableColorXPFactory() {
- fXPFactory.reset(GrDisableColorXPFactory::Create());
+ fXPFactory = GrDisableColorXPFactory::Make();
}
const GrXPFactory* getXPFactory() const {
- return fXPFactory;
+ return fXPFactory.get();
}
/**
@@ -304,12 +299,12 @@ private:
// This is used to assert that this condition holds.
SkDEBUGCODE(mutable int fBlockEffectRemovalCnt;)
- typedef SkSTArray<4, const GrFragmentProcessor*, true> FragmentProcessorArray;
+ typedef SkSTArray<4, sk_sp<GrFragmentProcessor>> FragmentProcessorArray;
uint32_t fFlags;
const GrUserStencilSettings* fUserStencilSettings;
DrawFace fDrawFace;
- mutable SkAutoTUnref<const GrXPFactory> fXPFactory;
+ mutable sk_sp<GrXPFactory> fXPFactory;
FragmentProcessorArray fColorFragmentProcessors;
FragmentProcessorArray fCoverageFragmentProcessors;
diff --git a/src/gpu/GrProcessorUnitTest.cpp b/src/gpu/GrProcessorUnitTest.cpp
index bdc602c9bf..3f43389fe0 100644
--- a/src/gpu/GrProcessorUnitTest.cpp
+++ b/src/gpu/GrProcessorUnitTest.cpp
@@ -8,14 +8,14 @@
#include "GrProcessorUnitTest.h"
#include "GrFragmentProcessor.h"
-const GrFragmentProcessor* GrProcessorUnitTest::CreateChildFP(GrProcessorTestData* data) {
+sk_sp<GrFragmentProcessor> GrProcessorUnitTest::MakeChildFP(GrProcessorTestData* data) {
#if SK_ALLOW_STATIC_GLOBAL_INITIALIZERS
- SkAutoTUnref<const GrFragmentProcessor> fp;
+ sk_sp<GrFragmentProcessor> fp;
do {
- fp.reset(GrProcessorTestFactory<GrFragmentProcessor>::Create(data));
+ fp = GrProcessorTestFactory<GrFragmentProcessor>::Make(data);
SkASSERT(fp);
} while (fp->numChildProcessors() != 0);
- return SkRef(fp.get());
+ return fp;
#else
SkFAIL("Should not be called if !SK_ALLOW_STATIC_GLOBAL_INITIALIZERS");
return nullptr;
diff --git a/src/gpu/GrSWMaskHelper.cpp b/src/gpu/GrSWMaskHelper.cpp
index 05e270f213..0c42a2bb98 100644
--- a/src/gpu/GrSWMaskHelper.cpp
+++ b/src/gpu/GrSWMaskHelper.cpp
@@ -189,10 +189,10 @@ void GrSWMaskHelper::DrawToTargetWithPathMask(GrTexture* texture,
pipelineBuilder.setUserStencil(userStencilSettings);
pipelineBuilder.addCoverageFragmentProcessor(
- GrSimpleTextureEffect::Create(texture,
- maskMatrix,
- GrTextureParams::kNone_FilterMode,
- kDevice_GrCoordSet))->unref();
+ GrSimpleTextureEffect::Make(texture,
+ maskMatrix,
+ GrTextureParams::kNone_FilterMode,
+ kDevice_GrCoordSet));
SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateNonAAFill(color, SkMatrix::I(),
dstRect, nullptr, &invert));
diff --git a/src/gpu/GrTextureParamsAdjuster.cpp b/src/gpu/GrTextureParamsAdjuster.cpp
index 076750ee5a..a68c3d7657 100644
--- a/src/gpu/GrTextureParamsAdjuster.cpp
+++ b/src/gpu/GrTextureParamsAdjuster.cpp
@@ -93,9 +93,9 @@ static GrTexture* copy_on_gpu(GrTexture* inputTexture, const SkIRect* subset,
// better!
SkASSERT(copyParams.fFilter != GrTextureParams::kMipMap_FilterMode);
paint.addColorFragmentProcessor(
- GrTextureDomainEffect::Create(inputTexture, SkMatrix::I(), domain,
- GrTextureDomain::kClamp_Mode,
- copyParams.fFilter))->unref();
+ GrTextureDomainEffect::Make(inputTexture, SkMatrix::I(), domain,
+ GrTextureDomain::kClamp_Mode,
+ copyParams.fFilter));
} else {
GrTextureParams params(SkShader::kClamp_TileMode, copyParams.fFilter);
paint.addColorTextureProcessor(inputTexture, SkMatrix::I(), params);
@@ -342,7 +342,7 @@ static DomainMode determine_domain_mode(
return kDomain_DomainMode;
}
-static const GrFragmentProcessor* create_fp_for_domain_and_filter(
+static sk_sp<GrFragmentProcessor> create_fp_for_domain_and_filter(
GrTexture* texture,
const SkMatrix& textureMatrix,
DomainMode domainMode,
@@ -351,25 +351,25 @@ static const GrFragmentProcessor* create_fp_for_domain_and_filter(
SkASSERT(kTightCopy_DomainMode != domainMode);
if (filterOrNullForBicubic) {
if (kDomain_DomainMode == domainMode) {
- return GrTextureDomainEffect::Create(texture, textureMatrix, domain,
- GrTextureDomain::kClamp_Mode,
- *filterOrNullForBicubic);
+ return GrTextureDomainEffect::Make(texture, textureMatrix, domain,
+ GrTextureDomain::kClamp_Mode,
+ *filterOrNullForBicubic);
} else {
GrTextureParams params(SkShader::kClamp_TileMode, *filterOrNullForBicubic);
- return GrSimpleTextureEffect::Create(texture, textureMatrix, params);
+ return GrSimpleTextureEffect::Make(texture, textureMatrix, params);
}
} else {
if (kDomain_DomainMode == domainMode) {
- return GrBicubicEffect::Create(texture, textureMatrix, domain);
+ return GrBicubicEffect::Make(texture, textureMatrix, domain);
} else {
static const SkShader::TileMode kClampClamp[] =
{ SkShader::kClamp_TileMode, SkShader::kClamp_TileMode };
- return GrBicubicEffect::Create(texture, textureMatrix, kClampClamp);
+ return GrBicubicEffect::Make(texture, textureMatrix, kClampClamp);
}
}
}
-const GrFragmentProcessor* GrTextureAdjuster::createFragmentProcessor(
+sk_sp<GrFragmentProcessor> GrTextureAdjuster::createFragmentProcessor(
const SkMatrix& origTextureMatrix,
const SkRect& origConstraintRect,
FilterConstraint filterConstraint,
@@ -467,7 +467,7 @@ GrTexture* GrTextureMaker::refTextureForParams(const GrTextureParams& params,
return result;
}
-const GrFragmentProcessor* GrTextureMaker::createFragmentProcessor(
+sk_sp<GrFragmentProcessor> GrTextureMaker::createFragmentProcessor(
const SkMatrix& textureMatrix,
const SkRect& constraintRect,
FilterConstraint filterConstraint,
diff --git a/src/gpu/GrTextureParamsAdjuster.h b/src/gpu/GrTextureParamsAdjuster.h
index 5f0f2715be..08d71c4563 100644
--- a/src/gpu/GrTextureParamsAdjuster.h
+++ b/src/gpu/GrTextureParamsAdjuster.h
@@ -59,7 +59,7 @@ public:
* @param filterOrNullForBicubic If non-null indicates the filter mode. If null means
* use bicubic filtering.
**/
- virtual const GrFragmentProcessor* createFragmentProcessor(
+ virtual sk_sp<GrFragmentProcessor> createFragmentProcessor(
const SkMatrix& textureMatrix,
const SkRect& constraintRect,
FilterConstraint filterConstraint,
@@ -131,7 +131,7 @@ public:
GrTexture* refTextureSafeForParams(const GrTextureParams&, SkSourceGammaTreatment,
SkIPoint* outOffset);
- const GrFragmentProcessor* createFragmentProcessor(
+ sk_sp<GrFragmentProcessor> createFragmentProcessor(
const SkMatrix& textureMatrix,
const SkRect& constraintRect,
FilterConstraint,
@@ -172,7 +172,7 @@ public:
the texture. */
GrTexture* refTextureForParams(const GrTextureParams&, SkSourceGammaTreatment);
- const GrFragmentProcessor* createFragmentProcessor(
+ sk_sp<GrFragmentProcessor> createFragmentProcessor(
const SkMatrix& textureMatrix,
const SkRect& constraintRect,
FilterConstraint filterConstraint,
diff --git a/src/gpu/GrTextureToYUVPlanes.cpp b/src/gpu/GrTextureToYUVPlanes.cpp
index 42156026a3..58c4b9ac5e 100644
--- a/src/gpu/GrTextureToYUVPlanes.cpp
+++ b/src/gpu/GrTextureToYUVPlanes.cpp
@@ -15,12 +15,12 @@
#include "GrTextureProvider.h"
namespace {
- using CreateFPProc = const GrFragmentProcessor* (*)(const GrFragmentProcessor*,
- SkYUVColorSpace colorSpace);
+ using MakeFPProc = sk_sp<GrFragmentProcessor> (*)(sk_sp<GrFragmentProcessor>,
+ SkYUVColorSpace colorSpace);
};
static bool convert_texture(GrTexture* src, GrDrawContext* dst, int dstW, int dstH,
- SkYUVColorSpace colorSpace, CreateFPProc proc) {
+ SkYUVColorSpace colorSpace, MakeFPProc proc) {
SkScalar xScale = SkIntToScalar(src->width()) / dstW / src->width();
SkScalar yScale = SkIntToScalar(src->height()) / dstH / src->height();
@@ -31,18 +31,18 @@ static bool convert_texture(GrTexture* src, GrDrawContext* dst, int dstW, int ds
filter = GrTextureParams::kBilerp_FilterMode;
}
- SkAutoTUnref<const GrFragmentProcessor> fp(
- GrSimpleTextureEffect::Create(src, SkMatrix::MakeScale(xScale, yScale), filter));
+ sk_sp<GrFragmentProcessor> fp(
+ GrSimpleTextureEffect::Make(src, SkMatrix::MakeScale(xScale, yScale), filter));
if (!fp) {
return false;
}
- fp.reset(proc(fp, colorSpace));
+ fp = proc(std::move(fp), colorSpace);
if (!fp) {
return false;
}
GrPaint paint;
paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
- paint.addColorFragmentProcessor(fp);
+ paint.addColorFragmentProcessor(std::move(fp));
dst->drawRect(GrNoClip(), paint, SkMatrix::I(), SkRect::MakeIWH(dstW, dstH));
return true;
}
@@ -107,32 +107,32 @@ bool GrTextureToYUVPlanes(GrTexture* texture, const SkISize sizes[3], void* cons
if (yuvDrawContext) {
if (!convert_texture(texture, yuvDrawContext.get(),
sizes[0].fWidth, sizes[0].fHeight,
- colorSpace, GrYUVEffect::CreateRGBToYUV)) {
+ colorSpace, GrYUVEffect::MakeRGBToYUV)) {
return false;
}
} else {
SkASSERT(yDrawContext);
if (!convert_texture(texture, yDrawContext.get(),
sizes[0].fWidth, sizes[0].fHeight,
- colorSpace, GrYUVEffect::CreateRGBToY)) {
+ colorSpace, GrYUVEffect::MakeRGBToY)) {
return false;
}
if (uvDrawContext) {
if (!convert_texture(texture, uvDrawContext.get(),
sizes[1].fWidth, sizes[1].fHeight,
- colorSpace, GrYUVEffect::CreateRGBToUV)) {
+ colorSpace, GrYUVEffect::MakeRGBToUV)) {
return false;
}
} else {
SkASSERT(uDrawContext && vDrawContext);
if (!convert_texture(texture, uDrawContext.get(),
sizes[1].fWidth, sizes[1].fHeight,
- colorSpace, GrYUVEffect::CreateRGBToU)) {
+ colorSpace, GrYUVEffect::MakeRGBToU)) {
return false;
}
if (!convert_texture(texture, vDrawContext.get(),
sizes[2].fWidth, sizes[2].fHeight,
- colorSpace, GrYUVEffect::CreateRGBToV)) {
+ colorSpace, GrYUVEffect::MakeRGBToV)) {
return false;
}
}
diff --git a/src/gpu/GrYUVProvider.cpp b/src/gpu/GrYUVProvider.cpp
index a7281da27b..b30ff1fa3c 100644
--- a/src/gpu/GrYUVProvider.cpp
+++ b/src/gpu/GrYUVProvider.cpp
@@ -121,13 +121,12 @@ sk_sp<GrTexture> GrYUVProvider::refAsTexture(GrContext* ctx,
}
GrPaint paint;
- SkAutoTUnref<const GrFragmentProcessor> yuvToRgbProcessor(
- GrYUVEffect::CreateYUVToRGB(yuvTextures[0],
- yuvTextures[1],
- yuvTextures[2],
- yuvInfo.fSizeInfo.fSizes,
- yuvInfo.fColorSpace));
- paint.addColorFragmentProcessor(yuvToRgbProcessor);
+ sk_sp<GrFragmentProcessor> yuvToRgbProcessor(GrYUVEffect::MakeYUVToRGB(yuvTextures[0],
+ yuvTextures[1],
+ yuvTextures[2],
+ yuvInfo.fSizeInfo.fSizes,
+ yuvInfo.fColorSpace));
+ paint.addColorFragmentProcessor(std::move(yuvToRgbProcessor));
// If we're decoding an sRGB image, the result of our linear math on the YUV planes is already
// in sRGB. (The encoding is just math on bytes, with no concept of color spaces.) So, we need
@@ -139,7 +138,7 @@ sk_sp<GrTexture> GrYUVProvider::refAsTexture(GrContext* ctx,
if (ctx->caps()->srgbWriteControl()) {
paint.setDisableOutputConversionToSRGB(true);
} else {
- paint.addColorFragmentProcessor(GrGammaEffect::Create(2.2f))->unref();
+ paint.addColorFragmentProcessor(GrGammaEffect::Make(2.2f));
}
}
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 81e955d702..a894f983b5 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -1198,7 +1198,7 @@ void SkGpuDevice::internalDrawBitmap(const SkBitmap& bitmap,
// Construct a GrPaint by setting the bitmap texture as the first effect and then configuring
// the rest from the SkPaint.
- SkAutoTUnref<const GrFragmentProcessor> fp;
+ sk_sp<GrFragmentProcessor> fp;
if (needsTextureDomain && (SkCanvas::kStrict_SrcRectConstraint == constraint)) {
// Use a constrained texture domain to avoid color bleeding
@@ -1219,24 +1219,21 @@ void SkGpuDevice::internalDrawBitmap(const SkBitmap& bitmap,
}
textureDomain.setLTRB(left, top, right, bottom);
if (bicubic) {
- fp.reset(GrBicubicEffect::Create(texture, texMatrix, textureDomain));
+ fp = GrBicubicEffect::Make(texture, texMatrix, textureDomain);
} else {
- fp.reset(GrTextureDomainEffect::Create(texture,
- texMatrix,
- textureDomain,
- GrTextureDomain::kClamp_Mode,
- params.filterMode()));
+ fp = GrTextureDomainEffect::Make(texture, texMatrix, textureDomain,
+ GrTextureDomain::kClamp_Mode, params.filterMode());
}
} else if (bicubic) {
SkASSERT(GrTextureParams::kNone_FilterMode == params.filterMode());
SkShader::TileMode tileModes[2] = { params.getTileModeX(), params.getTileModeY() };
- fp.reset(GrBicubicEffect::Create(texture, texMatrix, tileModes));
+ fp = GrBicubicEffect::Make(texture, texMatrix, tileModes);
} else {
- fp.reset(GrSimpleTextureEffect::Create(texture, texMatrix, params));
+ fp = GrSimpleTextureEffect::Make(texture, texMatrix, params);
}
GrPaint grPaint;
- if (!SkPaintToGrPaintWithTexture(this->context(), paint, viewMatrix, fp,
+ if (!SkPaintToGrPaintWithTexture(this->context(), paint, viewMatrix, std::move(fp),
kAlpha_8_SkColorType == bitmap.colorType(),
this->surfaceProps().isGammaCorrect(), &grPaint)) {
return;
@@ -1280,14 +1277,13 @@ void SkGpuDevice::drawSprite(const SkDraw& draw, const SkBitmap& bitmap,
SkASSERT(!paint.getImageFilter());
GrPaint grPaint;
- SkAutoTUnref<const GrFragmentProcessor> fp(
- GrSimpleTextureEffect::Create(texture, SkMatrix::I()));
+ sk_sp<GrFragmentProcessor> fp(GrSimpleTextureEffect::Make(texture, SkMatrix::I()));
if (alphaOnly) {
- fp.reset(GrFragmentProcessor::MulOutputByInputUnpremulColor(fp));
+ fp = GrFragmentProcessor::MulOutputByInputUnpremulColor(std::move(fp));
} else {
- fp.reset(GrFragmentProcessor::MulOutputByInputAlpha(fp));
+ fp = GrFragmentProcessor::MulOutputByInputAlpha(std::move(fp));
}
- if (!SkPaintToGrPaintReplaceShader(this->context(), paint, fp,
+ if (!SkPaintToGrPaintReplaceShader(this->context(), paint, std::move(fp),
this->surfaceProps().isGammaCorrect(), &grPaint)) {
return;
}
@@ -1415,16 +1411,15 @@ void SkGpuDevice::drawDevice(const SkDraw& draw, SkBaseDevice* device,
SkASSERT(!paint.getImageFilter());
GrPaint grPaint;
- SkAutoTUnref<const GrFragmentProcessor> fp(
- GrSimpleTextureEffect::Create(devTex.get(), SkMatrix::I()));
+ sk_sp<GrFragmentProcessor> fp(GrSimpleTextureEffect::Make(devTex.get(), SkMatrix::I()));
if (GrPixelConfigIsAlphaOnly(devTex->config())) {
// Can this happen?
- fp.reset(GrFragmentProcessor::MulOutputByInputUnpremulColor(fp));
+ fp = GrFragmentProcessor::MulOutputByInputUnpremulColor(std::move(fp));
} else {
- fp.reset(GrFragmentProcessor::MulOutputByInputAlpha(fp));
+ fp = GrFragmentProcessor::MulOutputByInputAlpha(std::move(fp));
}
- if (!SkPaintToGrPaintReplaceShader(this->context(), paint, fp,
+ if (!SkPaintToGrPaintReplaceShader(this->context(), paint, std::move(fp),
this->surfaceProps().isGammaCorrect(), &grPaint)) {
return;
}
@@ -1529,13 +1524,13 @@ void SkGpuDevice::drawProducerNine(const SkDraw& draw, GrTextureProducer* produc
bool gammaCorrect = this->surfaceProps().isGammaCorrect();
SkSourceGammaTreatment gammaTreatment = gammaCorrect
? SkSourceGammaTreatment::kRespect : SkSourceGammaTreatment::kIgnore;
- SkAutoTUnref<const GrFragmentProcessor> fp(
+ sk_sp<GrFragmentProcessor> fp(
producer->createFragmentProcessor(SkMatrix::I(),
SkRect::MakeIWH(producer->width(), producer->height()),
GrTextureProducer::kNo_FilterConstraint, true,
&kMode, gammaTreatment));
GrPaint grPaint;
- if (!SkPaintToGrPaintWithTexture(this->context(), paint, *draw.fMatrix, fp,
+ if (!SkPaintToGrPaintWithTexture(this->context(), paint, *draw.fMatrix, std::move(fp),
producer->isAlphaOnly(), gammaCorrect, &grPaint)) {
return;
}
diff --git a/src/gpu/SkGpuDevice_drawTexture.cpp b/src/gpu/SkGpuDevice_drawTexture.cpp
index 4ba3c8df9c..8dc4926c53 100644
--- a/src/gpu/SkGpuDevice_drawTexture.cpp
+++ b/src/gpu/SkGpuDevice_drawTexture.cpp
@@ -204,7 +204,7 @@ void SkGpuDevice::drawTextureProducerImpl(GrTextureProducer* producer,
bool gammaCorrect = this->surfaceProps().isGammaCorrect();
SkSourceGammaTreatment gammaTreatment = gammaCorrect
? SkSourceGammaTreatment::kRespect : SkSourceGammaTreatment::kIgnore;
- SkAutoTUnref<const GrFragmentProcessor> fp(producer->createFragmentProcessor(
+ sk_sp<GrFragmentProcessor> fp(producer->createFragmentProcessor(
*textureMatrix, clippedSrcRect, constraintMode, coordsAllInsideSrcRect, filterMode,
gammaTreatment));
if (!fp) {
diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp
index fb2916daff..ca7d6b8e84 100644
--- a/src/gpu/SkGr.cpp
+++ b/src/gpu/SkGr.cpp
@@ -506,7 +506,7 @@ static inline bool blend_requires_shader(const SkXfermode::Mode mode, bool primi
static inline bool skpaint_to_grpaint_impl(GrContext* context,
const SkPaint& skPaint,
const SkMatrix& viewM,
- const GrFragmentProcessor** shaderProcessor,
+ sk_sp<GrFragmentProcessor>* shaderProcessor,
SkXfermode::Mode* primColorMode,
bool primitiveIsSrc,
bool allowSRGBInputs,
@@ -516,17 +516,15 @@ static inline bool skpaint_to_grpaint_impl(GrContext* context,
// Setup the initial color considering the shader, the SkPaint color, and the presence or not
// of per-vertex colors.
- SkAutoTUnref<const GrFragmentProcessor> aufp;
- const GrFragmentProcessor* shaderFP = nullptr;
+ sk_sp<GrFragmentProcessor> shaderFP;
if (!primColorMode || blend_requires_shader(*primColorMode, primitiveIsSrc)) {
if (shaderProcessor) {
shaderFP = *shaderProcessor;
} else if (const SkShader* shader = skPaint.getShader()) {
SkSourceGammaTreatment gammaTreatment = allowSRGBInputs
? SkSourceGammaTreatment::kRespect : SkSourceGammaTreatment::kIgnore;
- aufp.reset(shader->asFragmentProcessor(context, viewM, nullptr,
- skPaint.getFilterQuality(), gammaTreatment));
- shaderFP = aufp;
+ shaderFP = shader->asFragmentProcessor(context, viewM, nullptr,
+ skPaint.getFilterQuality(), gammaTreatment);
if (!shaderFP) {
return false;
}
@@ -549,16 +547,13 @@ static inline bool skpaint_to_grpaint_impl(GrContext* context,
GrColor shaderInput = SkColorToOpaqueGrColor(skPaint.getColor());
shaderFP = GrFragmentProcessor::OverrideInput(shaderFP, shaderInput);
- aufp.reset(shaderFP);
-
if (primitiveIsSrc) {
- shaderFP = GrXfermodeFragmentProcessor::CreateFromDstProcessor(shaderFP,
- *primColorMode);
+ shaderFP = GrXfermodeFragmentProcessor::MakeFromDstProcessor(std::move(shaderFP),
+ *primColorMode);
} else {
- shaderFP = GrXfermodeFragmentProcessor::CreateFromSrcProcessor(shaderFP,
- *primColorMode);
+ shaderFP = GrXfermodeFragmentProcessor::MakeFromSrcProcessor(std::move(shaderFP),
+ *primColorMode);
}
- aufp.reset(shaderFP);
// The above may return null if compose results in a pass through of the prim color.
if (shaderFP) {
grPaint->addColorFragmentProcessor(shaderFP);
@@ -566,39 +561,38 @@ static inline bool skpaint_to_grpaint_impl(GrContext* context,
GrColor paintAlpha = SkColorAlphaToGrColor(skPaint.getColor());
if (GrColor_WHITE != paintAlpha) {
- grPaint->addColorFragmentProcessor(GrConstColorProcessor::Create(
- paintAlpha, GrConstColorProcessor::kModulateRGBA_InputMode))->unref();
+ grPaint->addColorFragmentProcessor(GrConstColorProcessor::Make(
+ paintAlpha, GrConstColorProcessor::kModulateRGBA_InputMode));
}
} else {
// The shader's FP sees the paint unpremul color
grPaint->setColor(SkColorToUnpremulGrColor(skPaint.getColor()));
- grPaint->addColorFragmentProcessor(shaderFP);
+ grPaint->addColorFragmentProcessor(std::move(shaderFP));
}
} else {
if (primColorMode) {
// There is a blend between the primitive color and the paint color. The blend considers
// the opaque paint color. The paint's alpha is applied to the post-blended color.
- SkAutoTUnref<const GrFragmentProcessor> processor(
- GrConstColorProcessor::Create(SkColorToOpaqueGrColor(skPaint.getColor()),
+ sk_sp<GrFragmentProcessor> processor(
+ GrConstColorProcessor::Make(SkColorToOpaqueGrColor(skPaint.getColor()),
GrConstColorProcessor::kIgnore_InputMode));
if (primitiveIsSrc) {
- processor.reset(GrXfermodeFragmentProcessor::CreateFromDstProcessor(processor,
- *primColorMode));
+ processor = GrXfermodeFragmentProcessor::MakeFromDstProcessor(std::move(processor),
+ *primColorMode);
} else {
- processor.reset(GrXfermodeFragmentProcessor::CreateFromSrcProcessor(processor,
- *primColorMode));
-
+ processor = GrXfermodeFragmentProcessor::MakeFromSrcProcessor(std::move(processor),
+ *primColorMode);
}
if (processor) {
- grPaint->addColorFragmentProcessor(processor);
+ grPaint->addColorFragmentProcessor(std::move(processor));
}
grPaint->setColor(SkColorToOpaqueGrColor(skPaint.getColor()));
GrColor paintAlpha = SkColorAlphaToGrColor(skPaint.getColor());
if (GrColor_WHITE != paintAlpha) {
- grPaint->addColorFragmentProcessor(GrConstColorProcessor::Create(
- paintAlpha, GrConstColorProcessor::kModulateRGBA_InputMode))->unref();
+ grPaint->addColorFragmentProcessor(GrConstColorProcessor::Make(
+ paintAlpha, GrConstColorProcessor::kModulateRGBA_InputMode));
}
} else {
// No shader, no primitive color.
@@ -612,10 +606,9 @@ static inline bool skpaint_to_grpaint_impl(GrContext* context,
if (applyColorFilterToPaintColor) {
grPaint->setColor(SkColorToPremulGrColor(colorFilter->filterColor(skPaint.getColor())));
} else {
- SkAutoTUnref<const GrFragmentProcessor> cfFP(
- colorFilter->asFragmentProcessor(context));
+ sk_sp<GrFragmentProcessor> cfFP(colorFilter->asFragmentProcessor(context));
if (cfFP) {
- grPaint->addColorFragmentProcessor(cfFP);
+ grPaint->addColorFragmentProcessor(std::move(cfFP));
} else {
return false;
}
@@ -627,14 +620,12 @@ static inline bool skpaint_to_grpaint_impl(GrContext* context,
SkASSERT(!grPaint->getXPFactory());
SkXfermode* xfermode = skPaint.getXfermode();
if (xfermode) {
- // SafeUnref in case a new xfermode is added that returns null.
- // In such cases we will fall back to kSrcOver_Mode.
- SkSafeUnref(grPaint->setXPFactory(xfermode->asXPFactory()));
+ grPaint->setXPFactory(xfermode->asXPFactory());
}
#ifndef SK_IGNORE_GPU_DITHER
if (skPaint.isDither() && grPaint->numColorFragmentProcessors() > 0) {
- grPaint->addColorFragmentProcessor(GrDitherEffect::Create())->unref();
+ grPaint->addColorFragmentProcessor(GrDitherEffect::Make());
}
#endif
return true;
@@ -649,7 +640,7 @@ bool SkPaintToGrPaint(GrContext* context, const SkPaint& skPaint, const SkMatrix
/** Replaces the SkShader (if any) on skPaint with the passed in GrFragmentProcessor. */
bool SkPaintToGrPaintReplaceShader(GrContext* context,
const SkPaint& skPaint,
- const GrFragmentProcessor* shaderFP,
+ sk_sp<GrFragmentProcessor> shaderFP,
bool allowSRGBInputs,
GrPaint* grPaint) {
if (!shaderFP) {
@@ -665,8 +656,8 @@ bool SkPaintToGrPaintNoShader(GrContext* context,
bool allowSRGBInputs,
GrPaint* grPaint) {
// Use a ptr to a nullptr to to indicate that the SkShader is ignored and not replaced.
- static const GrFragmentProcessor* kNullShaderFP = nullptr;
- static const GrFragmentProcessor** kIgnoreShader = &kNullShaderFP;
+ static sk_sp<GrFragmentProcessor> kNullShaderFP(nullptr);
+ static sk_sp<GrFragmentProcessor>* kIgnoreShader = &kNullShaderFP;
return skpaint_to_grpaint_impl(context, skPaint, SkMatrix::I(), kIgnoreShader, nullptr, false,
allowSRGBInputs, grPaint);
}
@@ -687,33 +678,34 @@ bool SkPaintToGrPaintWithXfermode(GrContext* context,
bool SkPaintToGrPaintWithTexture(GrContext* context,
const SkPaint& paint,
const SkMatrix& viewM,
- const GrFragmentProcessor* fp,
+ sk_sp<GrFragmentProcessor> fp,
bool textureIsAlphaOnly,
bool allowSRGBInputs,
GrPaint* grPaint) {
- SkAutoTUnref<const GrFragmentProcessor> shaderFP;
+ sk_sp<GrFragmentProcessor> shaderFP;
if (textureIsAlphaOnly) {
if (const SkShader* shader = paint.getShader()) {
SkSourceGammaTreatment gammaTreatment = allowSRGBInputs
? SkSourceGammaTreatment::kRespect : SkSourceGammaTreatment::kIgnore;
- shaderFP.reset(shader->asFragmentProcessor(context,
- viewM,
- nullptr,
- paint.getFilterQuality(),
- gammaTreatment));
+ shaderFP = shader->asFragmentProcessor(context,
+ viewM,
+ nullptr,
+ paint.getFilterQuality(),
+ gammaTreatment);
if (!shaderFP) {
return false;
}
- const GrFragmentProcessor* fpSeries[] = { shaderFP.get(), fp };
- shaderFP.reset(GrFragmentProcessor::RunInSeries(fpSeries, 2));
+ sk_sp<GrFragmentProcessor> fpSeries[] = { std::move(shaderFP), std::move(fp) };
+ shaderFP = GrFragmentProcessor::RunInSeries(fpSeries, 2);
} else {
- shaderFP.reset(GrFragmentProcessor::MulOutputByInputUnpremulColor(fp));
+ shaderFP = GrFragmentProcessor::MulOutputByInputUnpremulColor(fp);
}
} else {
- shaderFP.reset(GrFragmentProcessor::MulOutputByInputAlpha(fp));
+ shaderFP = GrFragmentProcessor::MulOutputByInputAlpha(fp);
}
- return SkPaintToGrPaintReplaceShader(context, paint, shaderFP.get(), allowSRGBInputs, grPaint);
+ return SkPaintToGrPaintReplaceShader(context, paint, std::move(shaderFP), allowSRGBInputs,
+ grPaint);
}
diff --git a/src/gpu/SkGrPriv.h b/src/gpu/SkGrPriv.h
index 290c056a42..266cfff61c 100644
--- a/src/gpu/SkGrPriv.h
+++ b/src/gpu/SkGrPriv.h
@@ -62,7 +62,7 @@ bool SkPaintToGrPaintNoShader(GrContext* context,
no primitive color. */
bool SkPaintToGrPaintReplaceShader(GrContext*,
const SkPaint& skPaint,
- const GrFragmentProcessor* shaderFP,
+ sk_sp<GrFragmentProcessor> shaderFP,
bool allowSRGBInputs,
GrPaint* grPaint);
@@ -93,7 +93,7 @@ inline bool SkPaintToGrPaintWithPrimitiveColor(GrContext* context, const SkPaint
bool SkPaintToGrPaintWithTexture(GrContext* context,
const SkPaint& paint,
const SkMatrix& viewM,
- const GrFragmentProcessor* fp,
+ sk_sp<GrFragmentProcessor> fp,
bool textureIsAlphaOnly,
bool allowSRGBInputs,
GrPaint* grPaint);
diff --git a/src/gpu/batches/GrAAConvexPathRenderer.cpp b/src/gpu/batches/GrAAConvexPathRenderer.cpp
index e875f1c3ec..390162ede2 100644
--- a/src/gpu/batches/GrAAConvexPathRenderer.cpp
+++ b/src/gpu/batches/GrAAConvexPathRenderer.cpp
@@ -526,9 +526,9 @@ static void create_vertices(const SegmentArray& segments,
class QuadEdgeEffect : public GrGeometryProcessor {
public:
- static GrGeometryProcessor* Create(GrColor color, const SkMatrix& localMatrix,
- bool usesLocalCoords) {
- return new QuadEdgeEffect(color, localMatrix, usesLocalCoords);
+ static sk_sp<GrGeometryProcessor> Make(GrColor color, const SkMatrix& localMatrix,
+ bool usesLocalCoords) {
+ return sk_sp<GrGeometryProcessor>(new QuadEdgeEffect(color, localMatrix, usesLocalCoords));
}
virtual ~QuadEdgeEffect() {}
@@ -669,12 +669,12 @@ private:
GR_DEFINE_GEOMETRY_PROCESSOR_TEST(QuadEdgeEffect);
-const GrGeometryProcessor* QuadEdgeEffect::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrGeometryProcessor> QuadEdgeEffect::TestCreate(GrProcessorTestData* d) {
// Doesn't work without derivative instructions.
return d->fCaps->shaderCaps()->shaderDerivativeSupport() ?
- QuadEdgeEffect::Create(GrRandomColor(d->fRandom),
- GrTest::TestMatrix(d->fRandom),
- d->fRandom->nextBool()) : nullptr;
+ QuadEdgeEffect::Make(GrRandomColor(d->fRandom),
+ GrTest::TestMatrix(d->fRandom),
+ d->fRandom->nextBool()) : nullptr;
}
///////////////////////////////////////////////////////////////////////////////
@@ -718,7 +718,7 @@ static void extract_verts(const GrAAConvexTessellator& tess,
}
}
-static const GrGeometryProcessor* create_fill_gp(bool tweakAlphaForCoverage,
+static sk_sp<GrGeometryProcessor> create_fill_gp(bool tweakAlphaForCoverage,
const SkMatrix& viewMatrix,
bool usesLocalCoords,
bool coverageIgnored) {
@@ -737,7 +737,7 @@ static const GrGeometryProcessor* create_fill_gp(bool tweakAlphaForCoverage,
Coverage coverage(coverageType);
LocalCoords localCoords(usesLocalCoords ? LocalCoords::kUsePosition_Type :
LocalCoords::kUnused_Type);
- return CreateForDeviceSpace(color, coverage, localCoords, viewMatrix);
+ return MakeForDeviceSpace(color, coverage, localCoords, viewMatrix);
}
class AAConvexPathBatch : public GrVertexBatch {
@@ -782,10 +782,10 @@ private:
bool canTweakAlphaForCoverage = this->canTweakAlphaForCoverage();
// Setup GrGeometryProcessor
- SkAutoTUnref<const GrGeometryProcessor> gp(create_fill_gp(canTweakAlphaForCoverage,
- this->viewMatrix(),
- this->usesLocalCoords(),
- this->coverageIgnored()));
+ sk_sp<GrGeometryProcessor> gp(create_fill_gp(canTweakAlphaForCoverage,
+ this->viewMatrix(),
+ this->usesLocalCoords(),
+ this->coverageIgnored()));
if (!gp) {
SkDebugf("Could not create GrGeometryProcessor\n");
return;
@@ -836,7 +836,7 @@ private:
vertexBuffer, indexBuffer,
firstVertex, firstIndex,
tess.numPts(), tess.numIndices());
- target->draw(gp, mesh);
+ target->draw(gp.get(), mesh);
}
}
@@ -857,8 +857,8 @@ private:
}
// Setup GrGeometryProcessor
- SkAutoTUnref<GrGeometryProcessor> quadProcessor(
- QuadEdgeEffect::Create(this->color(), invert, this->usesLocalCoords()));
+ sk_sp<GrGeometryProcessor> quadProcessor(
+ QuadEdgeEffect::Make(this->color(), invert, this->usesLocalCoords()));
// TODO generate all segments for all paths and use one vertex buffer
for (int i = 0; i < instanceCount; i++) {
@@ -924,7 +924,7 @@ private:
const Draw& draw = draws[j];
mesh.initIndexed(kTriangles_GrPrimitiveType, vertexBuffer, indexBuffer,
firstVertex, firstIndex, draw.fVertexCnt, draw.fIndexCnt);
- target->draw(quadProcessor, mesh);
+ target->draw(quadProcessor.get(), mesh);
firstVertex += draw.fVertexCnt;
firstIndex += draw.fIndexCnt;
}
diff --git a/src/gpu/batches/GrAADistanceFieldPathRenderer.cpp b/src/gpu/batches/GrAADistanceFieldPathRenderer.cpp
index ed9902ca33..e6be590fc5 100644
--- a/src/gpu/batches/GrAADistanceFieldPathRenderer.cpp
+++ b/src/gpu/batches/GrAADistanceFieldPathRenderer.cpp
@@ -172,9 +172,9 @@ private:
}
struct FlushInfo {
- SkAutoTUnref<const GrBuffer> fVertexBuffer;
- SkAutoTUnref<const GrBuffer> fIndexBuffer;
- SkAutoTUnref<const GrGeometryProcessor> fGeometryProcessor;
+ SkAutoTUnref<const GrBuffer> fVertexBuffer;
+ SkAutoTUnref<const GrBuffer> fIndexBuffer;
+ sk_sp<GrGeometryProcessor> fGeometryProcessor;
int fVertexOffset;
int fInstancesToFlush;
};
@@ -200,13 +200,12 @@ private:
// Setup GrGeometryProcessor
GrBatchAtlas* atlas = fAtlas;
- flushInfo.fGeometryProcessor.reset(
- GrDistanceFieldPathGeoProc::Create(this->color(),
- this->viewMatrix(),
- atlas->getTexture(),
- params,
- flags,
- this->usesLocalCoords()));
+ flushInfo.fGeometryProcessor = GrDistanceFieldPathGeoProc::Make(this->color(),
+ this->viewMatrix(),
+ atlas->getTexture(),
+ params,
+ flags,
+ this->usesLocalCoords());
// allocate vertices
size_t vertexStride = flushInfo.fGeometryProcessor->getVertexStride();
@@ -484,7 +483,7 @@ private:
mesh.initInstanced(kTriangles_GrPrimitiveType, flushInfo->fVertexBuffer,
flushInfo->fIndexBuffer, flushInfo->fVertexOffset, kVerticesPerQuad,
kIndicesPerQuad, flushInfo->fInstancesToFlush, maxInstancesPerDraw);
- target->draw(flushInfo->fGeometryProcessor, mesh);
+ target->draw(flushInfo->fGeometryProcessor.get(), mesh);
flushInfo->fVertexOffset += kVerticesPerQuad * flushInfo->fInstancesToFlush;
flushInfo->fInstancesToFlush = 0;
}
diff --git a/src/gpu/batches/GrAAFillRectBatch.cpp b/src/gpu/batches/GrAAFillRectBatch.cpp
index 2c90b8bcf2..94cef02a1a 100644
--- a/src/gpu/batches/GrAAFillRectBatch.cpp
+++ b/src/gpu/batches/GrAAFillRectBatch.cpp
@@ -44,7 +44,7 @@ const GrBuffer* get_index_buffer(GrResourceProvider* resourceProvider) {
gAAFillRectIndexBufferKey);
}
-static const GrGeometryProcessor* create_fill_rect_gp(
+static sk_sp<GrGeometryProcessor> create_fill_rect_gp(
const SkMatrix& viewMatrix,
const GrXPOverridesForBatch& overrides,
GrDefaultGeoProcFactory::LocalCoords::Type localCoordsType) {
@@ -65,11 +65,11 @@ static const GrGeometryProcessor* create_fill_rect_gp(
// We assume the caller has inverted the viewmatrix
if (LocalCoords::kHasExplicit_Type == localCoordsType) {
LocalCoords localCoords(localCoordsType);
- return GrDefaultGeoProcFactory::Create(color, coverage, localCoords, SkMatrix::I());
+ return GrDefaultGeoProcFactory::Make(color, coverage, localCoords, SkMatrix::I());
} else {
LocalCoords localCoords(overrides.readsLocalCoords() ? localCoordsType :
LocalCoords::kUnused_Type);
- return CreateForDeviceSpace(color, coverage, localCoords, viewMatrix);
+ return MakeForDeviceSpace(color, coverage, localCoords, viewMatrix);
}
}
@@ -239,9 +239,9 @@ public:
return !overrides.readsLocalCoords() || mine.fViewMatrix.cheapEqualTo(theirs.fViewMatrix);
}
- static const GrGeometryProcessor* CreateGP(const Geometry& geo,
+ static sk_sp<GrGeometryProcessor> MakeGP(const Geometry& geo,
const GrXPOverridesForBatch& overrides) {
- const GrGeometryProcessor* gp =
+ sk_sp<GrGeometryProcessor> gp =
create_fill_rect_gp(geo.fViewMatrix, overrides,
GrDefaultGeoProcFactory::LocalCoords::kUsePosition_Type);
@@ -286,9 +286,9 @@ public:
return true;
}
- static const GrGeometryProcessor* CreateGP(const Geometry& geo,
+ static sk_sp<GrGeometryProcessor> MakeGP(const Geometry& geo,
const GrXPOverridesForBatch& overrides) {
- const GrGeometryProcessor* gp =
+ sk_sp<GrGeometryProcessor> gp =
create_fill_rect_gp(geo.fViewMatrix, overrides,
GrDefaultGeoProcFactory::LocalCoords::kHasExplicit_Type);
diff --git a/src/gpu/batches/GrAAHairLinePathRenderer.cpp b/src/gpu/batches/GrAAHairLinePathRenderer.cpp
index ac5ecc1614..f44c454bb5 100644
--- a/src/gpu/batches/GrAAHairLinePathRenderer.cpp
+++ b/src/gpu/batches/GrAAHairLinePathRenderer.cpp
@@ -831,7 +831,7 @@ void AAHairlineBatch::onPrepareDraws(Target* target) const {
// do lines first
if (lineCount) {
- SkAutoTUnref<const GrGeometryProcessor> lineGP;
+ sk_sp<GrGeometryProcessor> lineGP;
{
using namespace GrDefaultGeoProcFactory;
@@ -840,8 +840,8 @@ void AAHairlineBatch::onPrepareDraws(Target* target) const {
LocalCoords localCoords(this->usesLocalCoords() ? LocalCoords::kUsePosition_Type :
LocalCoords::kUnused_Type);
localCoords.fMatrix = geometryProcessorLocalM;
- lineGP.reset(GrDefaultGeoProcFactory::Create(color, coverage, localCoords,
- *geometryProcessorViewM));
+ lineGP = GrDefaultGeoProcFactory::Make(color, coverage, localCoords,
+ *geometryProcessorViewM);
}
SkAutoTUnref<const GrBuffer> linesIndexBuffer(
@@ -870,27 +870,27 @@ void AAHairlineBatch::onPrepareDraws(Target* target) const {
mesh.initInstanced(kTriangles_GrPrimitiveType, vertexBuffer, linesIndexBuffer,
firstVertex, kLineSegNumVertices, kIdxsPerLineSeg, lineCount,
kLineSegsNumInIdxBuffer);
- target->draw(lineGP, mesh);
+ target->draw(lineGP.get(), mesh);
}
if (quadCount || conicCount) {
- SkAutoTUnref<const GrGeometryProcessor> quadGP(
- GrQuadEffect::Create(this->color(),
- *geometryProcessorViewM,
- kHairlineAA_GrProcessorEdgeType,
- target->caps(),
- *geometryProcessorLocalM,
- this->usesLocalCoords(),
- this->coverage()));
-
- SkAutoTUnref<const GrGeometryProcessor> conicGP(
- GrConicEffect::Create(this->color(),
- *geometryProcessorViewM,
- kHairlineAA_GrProcessorEdgeType,
- target->caps(),
- *geometryProcessorLocalM,
- this->usesLocalCoords(),
- this->coverage()));
+ sk_sp<GrGeometryProcessor> quadGP(
+ GrQuadEffect::Make(this->color(),
+ *geometryProcessorViewM,
+ kHairlineAA_GrProcessorEdgeType,
+ target->caps(),
+ *geometryProcessorLocalM,
+ this->usesLocalCoords(),
+ this->coverage()));
+
+ sk_sp<GrGeometryProcessor> conicGP(
+ GrConicEffect::Make(this->color(),
+ *geometryProcessorViewM,
+ kHairlineAA_GrProcessorEdgeType,
+ target->caps(),
+ *geometryProcessorLocalM,
+ this->usesLocalCoords(),
+ this->coverage()));
const GrBuffer* vertexBuffer;
int firstVertex;
@@ -927,7 +927,7 @@ void AAHairlineBatch::onPrepareDraws(Target* target) const {
mesh.initInstanced(kTriangles_GrPrimitiveType, vertexBuffer, quadsIndexBuffer,
firstVertex, kQuadNumVertices, kIdxsPerQuad, quadCount,
kQuadsNumInIdxBuffer);
- target->draw(quadGP, mesh);
+ target->draw(quadGP.get(), mesh);
firstVertex += quadCount * kQuadNumVertices;
}
@@ -936,7 +936,7 @@ void AAHairlineBatch::onPrepareDraws(Target* target) const {
mesh.initInstanced(kTriangles_GrPrimitiveType, vertexBuffer, quadsIndexBuffer,
firstVertex, kQuadNumVertices, kIdxsPerQuad, conicCount,
kQuadsNumInIdxBuffer);
- target->draw(conicGP, mesh);
+ target->draw(conicGP.get(), mesh);
}
}
}
diff --git a/src/gpu/batches/GrAALinearizingConvexPathRenderer.cpp b/src/gpu/batches/GrAALinearizingConvexPathRenderer.cpp
index 227f86bf77..1847a673e2 100644
--- a/src/gpu/batches/GrAALinearizingConvexPathRenderer.cpp
+++ b/src/gpu/batches/GrAALinearizingConvexPathRenderer.cpp
@@ -96,7 +96,7 @@ static void extract_verts(const GrAAConvexTessellator& tess,
}
}
-static const GrGeometryProcessor* create_fill_gp(bool tweakAlphaForCoverage,
+static sk_sp<GrGeometryProcessor> create_fill_gp(bool tweakAlphaForCoverage,
const SkMatrix& viewMatrix,
bool usesLocalCoords,
bool coverageIgnored) {
@@ -115,7 +115,7 @@ static const GrGeometryProcessor* create_fill_gp(bool tweakAlphaForCoverage,
Coverage coverage(coverageType);
LocalCoords localCoords(usesLocalCoords ? LocalCoords::kUsePosition_Type :
LocalCoords::kUnused_Type);
- return CreateForDeviceSpace(color, coverage, localCoords, viewMatrix);
+ return MakeForDeviceSpace(color, coverage, localCoords, viewMatrix);
}
class AAFlatteningConvexPathBatch : public GrVertexBatch {
@@ -195,10 +195,10 @@ private:
bool canTweakAlphaForCoverage = this->canTweakAlphaForCoverage();
// Setup GrGeometryProcessor
- SkAutoTUnref<const GrGeometryProcessor> gp(create_fill_gp(canTweakAlphaForCoverage,
- this->viewMatrix(),
- this->usesLocalCoords(),
- this->coverageIgnored()));
+ sk_sp<GrGeometryProcessor> gp(create_fill_gp(canTweakAlphaForCoverage,
+ this->viewMatrix(),
+ this->usesLocalCoords(),
+ this->coverageIgnored()));
if (!gp) {
SkDebugf("Couldn't create a GrGeometryProcessor\n");
return;
@@ -231,7 +231,8 @@ private:
if (indexCount + currentIndices > UINT16_MAX) {
// if we added the current instance, we would overflow the indices we can store in a
// uint16_t. Draw what we've got so far and reset.
- this->draw(target, gp, vertexCount, vertexStride, vertices, indexCount, indices);
+ this->draw(target, gp.get(),
+ vertexCount, vertexStride, vertices, indexCount, indices);
vertexCount = 0;
indexCount = 0;
}
@@ -250,7 +251,7 @@ private:
vertexCount += currentVertices;
indexCount += currentIndices;
}
- this->draw(target, gp, vertexCount, vertexStride, vertices, indexCount, indices);
+ this->draw(target, gp.get(), vertexCount, vertexStride, vertices, indexCount, indices);
sk_free(vertices);
sk_free(indices);
}
diff --git a/src/gpu/batches/GrAAStrokeRectBatch.cpp b/src/gpu/batches/GrAAStrokeRectBatch.cpp
index cc5440871f..98b764aa5b 100644
--- a/src/gpu/batches/GrAAStrokeRectBatch.cpp
+++ b/src/gpu/batches/GrAAStrokeRectBatch.cpp
@@ -21,7 +21,7 @@ static void set_inset_fan(SkPoint* pts, size_t stride,
r.fRight - dx, r.fBottom - dy, stride);
}
-static const GrGeometryProcessor* create_stroke_rect_gp(bool tweakAlphaForCoverage,
+static sk_sp<GrGeometryProcessor> create_stroke_rect_gp(bool tweakAlphaForCoverage,
const SkMatrix& viewMatrix,
bool usesLocalCoords,
bool coverageIgnored) {
@@ -40,7 +40,7 @@ static const GrGeometryProcessor* create_stroke_rect_gp(bool tweakAlphaForCovera
Coverage coverage(coverageType);
LocalCoords localCoords(usesLocalCoords ? LocalCoords::kUsePosition_Type :
LocalCoords::kUnused_Type);
- return CreateForDeviceSpace(color, coverage, localCoords, viewMatrix);
+ return MakeForDeviceSpace(color, coverage, localCoords, viewMatrix);
}
class AAStrokeRectBatch : public GrVertexBatch {
@@ -183,10 +183,10 @@ void AAStrokeRectBatch::initBatchTracker(const GrXPOverridesForBatch& overrides)
void AAStrokeRectBatch::onPrepareDraws(Target* target) const {
bool canTweakAlphaForCoverage = this->canTweakAlphaForCoverage();
- SkAutoTUnref<const GrGeometryProcessor> gp(create_stroke_rect_gp(canTweakAlphaForCoverage,
- this->viewMatrix(),
- this->usesLocalCoords(),
- this->coverageIgnored()));
+ sk_sp<GrGeometryProcessor> gp(create_stroke_rect_gp(canTweakAlphaForCoverage,
+ this->viewMatrix(),
+ this->usesLocalCoords(),
+ this->coverageIgnored()));
if (!gp) {
SkDebugf("Couldn't create GrGeometryProcessor\n");
return;
@@ -229,7 +229,7 @@ void AAStrokeRectBatch::onPrepareDraws(Target* target) const {
args.fDegenerate,
canTweakAlphaForCoverage);
}
- helper.recordDraw(target, gp);
+ helper.recordDraw(target, gp.get());
}
const GrBuffer* AAStrokeRectBatch::GetIndexBuffer(GrResourceProvider* resourceProvider,
diff --git a/src/gpu/batches/GrAtlasTextBatch.cpp b/src/gpu/batches/GrAtlasTextBatch.cpp
index 32a64c3b17..3c4b4a5135 100644
--- a/src/gpu/batches/GrAtlasTextBatch.cpp
+++ b/src/gpu/batches/GrAtlasTextBatch.cpp
@@ -100,17 +100,16 @@ void GrAtlasTextBatch::onPrepareDraws(Target* target) const {
FlushInfo flushInfo;
if (this->usesDistanceFields()) {
- flushInfo.fGeometryProcessor.reset(
- this->setupDfProcessor(this->viewMatrix(), fFilteredColor, this->color(), texture));
+ flushInfo.fGeometryProcessor =
+ this->setupDfProcessor(this->viewMatrix(), fFilteredColor, this->color(), texture);
} else {
GrTextureParams params(SkShader::kClamp_TileMode, GrTextureParams::kNone_FilterMode);
- flushInfo.fGeometryProcessor.reset(
- GrBitmapTextGeoProc::Create(this->color(),
- texture,
- params,
- maskFormat,
- localMatrix,
- this->usesLocalCoords()));
+ flushInfo.fGeometryProcessor = GrBitmapTextGeoProc::Make(this->color(),
+ texture,
+ params,
+ maskFormat,
+ localMatrix,
+ this->usesLocalCoords());
}
flushInfo.fGlyphsToFlush = 0;
@@ -178,7 +177,7 @@ void GrAtlasTextBatch::flush(GrVertexBatch::Target* target, FlushInfo* flushInfo
flushInfo->fIndexBuffer, flushInfo->fVertexOffset,
kVerticesPerGlyph, kIndicesPerGlyph, flushInfo->fGlyphsToFlush,
maxGlyphsPerDraw);
- target->draw(flushInfo->fGeometryProcessor, mesh);
+ target->draw(flushInfo->fGeometryProcessor.get(), mesh);
flushInfo->fVertexOffset += kVerticesPerGlyph * flushInfo->fGlyphsToFlush;
flushInfo->fGlyphsToFlush = 0;
}
@@ -246,9 +245,10 @@ bool GrAtlasTextBatch::onCombineIfPossible(GrBatch* t, const GrCaps& caps) {
// TODO just use class params
// TODO trying to figure out why lcd is so whack
-GrGeometryProcessor* GrAtlasTextBatch::setupDfProcessor(const SkMatrix& viewMatrix,
- SkColor filteredColor,
- GrColor color, GrTexture* texture) const {
+sk_sp<GrGeometryProcessor> GrAtlasTextBatch::setupDfProcessor(const SkMatrix& viewMatrix,
+ SkColor filteredColor,
+ GrColor color,
+ GrTexture* texture) const {
GrTextureParams params(SkShader::kClamp_TileMode, GrTextureParams::kBilerp_FilterMode);
bool isLCD = this->isLCD();
// set up any flags
@@ -277,32 +277,32 @@ GrGeometryProcessor* GrAtlasTextBatch::setupDfProcessor(const SkMatrix& viewMatr
greenCorrection,
blueCorrection);
- return GrDistanceFieldLCDTextGeoProc::Create(color,
- viewMatrix,
- texture,
- params,
- widthAdjust,
- flags,
- this->usesLocalCoords());
+ return GrDistanceFieldLCDTextGeoProc::Make(color,
+ viewMatrix,
+ texture,
+ params,
+ widthAdjust,
+ flags,
+ this->usesLocalCoords());
} else {
#ifdef SK_GAMMA_APPLY_TO_A8
U8CPU lum = SkColorSpaceLuminance::computeLuminance(SK_GAMMA_EXPONENT, filteredColor);
float correction = fDistanceAdjustTable->getAdjustment(
lum >> kDistanceAdjustLumShift, fUseGammaCorrectDistanceTable);
- return GrDistanceFieldA8TextGeoProc::Create(color,
- viewMatrix,
- texture,
- params,
- correction,
- flags,
- this->usesLocalCoords());
+ return GrDistanceFieldA8TextGeoProc::Make(color,
+ viewMatrix,
+ texture,
+ params,
+ correction,
+ flags,
+ this->usesLocalCoords());
#else
- return GrDistanceFieldA8TextGeoProc::Create(color,
- viewMatrix,
- texture,
- params,
- flags,
- this->usesLocalCoords());
+ return GrDistanceFieldA8TextGeoProc::Make(color,
+ viewMatrix,
+ texture,
+ params,
+ flags,
+ this->usesLocalCoords());
#endif
}
diff --git a/src/gpu/batches/GrAtlasTextBatch.h b/src/gpu/batches/GrAtlasTextBatch.h
index 72e299d3fa..89a2f4e753 100644
--- a/src/gpu/batches/GrAtlasTextBatch.h
+++ b/src/gpu/batches/GrAtlasTextBatch.h
@@ -101,11 +101,11 @@ private:
void initBatchTracker(const GrXPOverridesForBatch& overrides) override;
struct FlushInfo {
- SkAutoTUnref<const GrBuffer> fVertexBuffer;
- SkAutoTUnref<const GrBuffer> fIndexBuffer;
- SkAutoTUnref<const GrGeometryProcessor> fGeometryProcessor;
- int fGlyphsToFlush;
- int fVertexOffset;
+ SkAutoTUnref<const GrBuffer> fVertexBuffer;
+ SkAutoTUnref<const GrBuffer> fIndexBuffer;
+ sk_sp<GrGeometryProcessor> fGeometryProcessor;
+ int fGlyphsToFlush;
+ int fVertexOffset;
};
void onPrepareDraws(Target* target) const override;
@@ -153,8 +153,8 @@ private:
// TODO just use class params
// TODO trying to figure out why lcd is so whack
- GrGeometryProcessor* setupDfProcessor(const SkMatrix& viewMatrix, SkColor filteredColor,
- GrColor color, GrTexture* texture) const;
+ sk_sp<GrGeometryProcessor> setupDfProcessor(const SkMatrix& viewMatrix, SkColor filteredColor,
+ GrColor color, GrTexture* texture) const;
struct BatchTracker {
GrColor fColor;
diff --git a/src/gpu/batches/GrDefaultPathRenderer.cpp b/src/gpu/batches/GrDefaultPathRenderer.cpp
index c643c49e48..7fd7913aae 100644
--- a/src/gpu/batches/GrDefaultPathRenderer.cpp
+++ b/src/gpu/batches/GrDefaultPathRenderer.cpp
@@ -128,7 +128,7 @@ private:
}
void onPrepareDraws(Target* target) const override {
- SkAutoTUnref<const GrGeometryProcessor> gp;
+ sk_sp<GrGeometryProcessor> gp;
{
using namespace GrDefaultGeoProcFactory;
Color color(this->color());
@@ -138,8 +138,7 @@ private:
}
LocalCoords localCoords(this->usesLocalCoords() ? LocalCoords::kUsePosition_Type :
LocalCoords::kUnused_Type);
- gp.reset(GrDefaultGeoProcFactory::Create(color, coverage, localCoords,
- this->viewMatrix()));
+ gp = GrDefaultGeoProcFactory::Make(color, coverage, localCoords, this->viewMatrix());
}
size_t vertexStride = gp->getVertexStride();
@@ -243,7 +242,7 @@ private:
} else {
mesh.init(primitiveType, vertexBuffer, firstVertex, vertexOffset);
}
- target->draw(gp, mesh);
+ target->draw(gp.get(), mesh);
// put back reserves
target->putBackIndices((size_t)(maxIndices - indexOffset));
@@ -627,7 +626,7 @@ void GrDefaultPathRenderer::onStencilPath(const StencilPathArgs& args) {
SkASSERT(SkPath::kInverseWinding_FillType != args.fPath->getFillType());
GrPaint paint;
- SkSafeUnref(paint.setXPFactory(GrDisableColorXPFactory::Create()));
+ paint.setXPFactory(GrDisableColorXPFactory::Make());
paint.setAntiAlias(args.fIsAA);
this->internalDrawPath(args.fDrawContext,
diff --git a/src/gpu/batches/GrDrawAtlasBatch.cpp b/src/gpu/batches/GrDrawAtlasBatch.cpp
index 58ce137d76..5b823a95a1 100644
--- a/src/gpu/batches/GrDrawAtlasBatch.cpp
+++ b/src/gpu/batches/GrDrawAtlasBatch.cpp
@@ -36,7 +36,7 @@ void GrDrawAtlasBatch::initBatchTracker(const GrXPOverridesForBatch& overrides)
fCoverageIgnored = !overrides.readsCoverage();
}
-static const GrGeometryProcessor* set_vertex_attributes(bool hasColors,
+static sk_sp<GrGeometryProcessor> set_vertex_attributes(bool hasColors,
GrColor color,
const SkMatrix& viewMatrix,
bool coverageIgnored) {
@@ -48,15 +48,15 @@ static const GrGeometryProcessor* set_vertex_attributes(bool hasColors,
Coverage coverage(coverageIgnored ? Coverage::kNone_Type : Coverage::kSolid_Type);
LocalCoords localCoords(LocalCoords::kHasExplicit_Type);
- return GrDefaultGeoProcFactory::Create(gpColor, coverage, localCoords, viewMatrix);
+ return GrDefaultGeoProcFactory::Make(gpColor, coverage, localCoords, viewMatrix);
}
void GrDrawAtlasBatch::onPrepareDraws(Target* target) const {
// Setup geometry processor
- SkAutoTUnref<const GrGeometryProcessor> gp(set_vertex_attributes(this->hasColors(),
- this->color(),
- this->viewMatrix(),
- this->coverageIgnored()));
+ sk_sp<GrGeometryProcessor> gp(set_vertex_attributes(this->hasColors(),
+ this->color(),
+ this->viewMatrix(),
+ this->coverageIgnored()));
int instanceCount = fGeoData.count();
size_t vertexStride = gp->getVertexStride();
@@ -79,7 +79,7 @@ void GrDrawAtlasBatch::onPrepareDraws(Target* target) const {
memcpy(vertPtr, args.fVerts.begin(), allocSize);
vertPtr += allocSize;
}
- helper.recordDraw(target, gp);
+ helper.recordDraw(target, gp.get());
}
GrDrawAtlasBatch::GrDrawAtlasBatch(const Geometry& geometry, const SkMatrix& viewMatrix,
diff --git a/src/gpu/batches/GrDrawVerticesBatch.cpp b/src/gpu/batches/GrDrawVerticesBatch.cpp
index 12ea05a747..dd1ed627c6 100644
--- a/src/gpu/batches/GrDrawVerticesBatch.cpp
+++ b/src/gpu/batches/GrDrawVerticesBatch.cpp
@@ -11,7 +11,7 @@
#include "GrInvariantOutput.h"
#include "GrDefaultGeoProcFactory.h"
-static const GrGeometryProcessor* set_vertex_attributes(bool hasLocalCoords,
+static sk_sp<GrGeometryProcessor> set_vertex_attributes(bool hasLocalCoords,
int* colorOffset,
int* texOffset,
const SkMatrix& viewMatrix,
@@ -27,8 +27,8 @@ static const GrGeometryProcessor* set_vertex_attributes(bool hasLocalCoords,
if (hasLocalCoords) {
*texOffset = sizeof(SkPoint) + sizeof(GrColor);
}
- return GrDefaultGeoProcFactory::Create(Color(Color::kAttribute_Type),
- coverage, localCoords, viewMatrix);
+ return GrDefaultGeoProcFactory::Make(Color(Color::kAttribute_Type),
+ coverage, localCoords, viewMatrix);
}
GrDrawVerticesBatch::GrDrawVerticesBatch(const Geometry& geometry, GrPrimitiveType primitiveType,
@@ -94,9 +94,8 @@ void GrDrawVerticesBatch::initBatchTracker(const GrXPOverridesForBatch& override
void GrDrawVerticesBatch::onPrepareDraws(Target* target) const {
bool hasLocalCoords = !fGeoData[0].fLocalCoords.isEmpty();
int colorOffset = -1, texOffset = -1;
- SkAutoTUnref<const GrGeometryProcessor> gp(
- set_vertex_attributes(hasLocalCoords, &colorOffset, &texOffset, fViewMatrix,
- fCoverageIgnored));
+ sk_sp<GrGeometryProcessor> gp(set_vertex_attributes(hasLocalCoords, &colorOffset, &texOffset,
+ fViewMatrix, fCoverageIgnored));
size_t vertexStride = gp->getVertexStride();
SkASSERT(vertexStride == sizeof(SkPoint) + (hasLocalCoords ? sizeof(SkPoint) : 0)
@@ -162,7 +161,7 @@ void GrDrawVerticesBatch::onPrepareDraws(Target* target) const {
} else {
mesh.init(this->primitiveType(), vertexBuffer, firstVertex, fVertexCount);
}
- target->draw(gp, mesh);
+ target->draw(gp.get(), mesh);
}
bool GrDrawVerticesBatch::onCombineIfPossible(GrBatch* t, const GrCaps& caps) {
diff --git a/src/gpu/batches/GrMSAAPathRenderer.cpp b/src/gpu/batches/GrMSAAPathRenderer.cpp
index cd2713e98d..edc285e411 100644
--- a/src/gpu/batches/GrMSAAPathRenderer.cpp
+++ b/src/gpu/batches/GrMSAAPathRenderer.cpp
@@ -84,7 +84,7 @@ static inline void append_contour_edge_indices(uint16_t fanCenterIdx,
*(lines.nextIndex++) = edgeV0Idx + 1;
}
-static inline void add_quad(MSAALineVertices& lines, MSAAQuadVertices& quads, const SkPoint pts[],
+static inline void add_quad(MSAALineVertices& lines, MSAAQuadVertices& quads, const SkPoint pts[],
SkColor color, bool indexed, uint16_t subpathLineIdxStart) {
SkASSERT(lines.nextVertex < lines.verticesEnd);
*lines.nextVertex = { pts[2], color };
@@ -144,16 +144,16 @@ public:
vsBuilder->codeAppendf("%s = %s;", uv.vsOut(), qp.inUV()->fName);
// Setup position
- this->setupPosition(vsBuilder, uniformHandler, gpArgs, qp.inPosition()->fName,
+ this->setupPosition(vsBuilder, uniformHandler, gpArgs, qp.inPosition()->fName,
qp.viewMatrix(), &fViewMatrixUniform);
// emit transforms
- this->emitTransforms(vsBuilder, varyingHandler, uniformHandler, gpArgs->fPositionVar,
- qp.inPosition()->fName, SkMatrix::I(), args.fTransformsIn,
+ this->emitTransforms(vsBuilder, varyingHandler, uniformHandler, gpArgs->fPositionVar,
+ qp.inPosition()->fName, SkMatrix::I(), args.fTransformsIn,
args.fTransformsOut);
GrGLSLPPFragmentBuilder* fsBuilder = args.fFragBuilder;
- fsBuilder->codeAppendf("if (%s.x * %s.x >= %s.y) discard;", uv.fsIn(), uv.fsIn(),
+ fsBuilder->codeAppendf("if (%s.x * %s.x >= %s.y) discard;", uv.fsIn(), uv.fsIn(),
uv.fsIn());
fsBuilder->codeAppendf("%s = vec4(1.0);", args.fOutputCoverage);
}
@@ -204,9 +204,9 @@ private:
MSAAQuadProcessor(const SkMatrix& viewMatrix)
: fViewMatrix(viewMatrix) {
this->initClassID<MSAAQuadProcessor>();
- fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertexAttribType,
+ fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertexAttribType,
kHigh_GrSLPrecision));
- fInUV = &this->addVertexAttrib(Attribute("inUV", kVec2f_GrVertexAttribType,
+ fInUV = &this->addVertexAttrib(Attribute("inUV", kVec2f_GrVertexAttribType,
kHigh_GrSLPrecision));
fInColor = &this->addVertexAttrib(Attribute("inColor", kVec4ub_GrVertexAttribType));
this->setSampleShading(1.0f);
@@ -216,7 +216,7 @@ private:
const Attribute* fInUV;
const Attribute* fInColor;
SkMatrix fViewMatrix;
-
+
GR_DECLARE_GEOMETRY_PROCESSOR_TEST;
typedef GrGeometryProcessor INHERITED;
@@ -232,14 +232,14 @@ public:
SkScalar fTolerance;
};
- static MSAAPathBatch* Create(const Geometry& geometry, const SkMatrix& viewMatrix,
+ static MSAAPathBatch* Create(const Geometry& geometry, const SkMatrix& viewMatrix,
const SkRect& devBounds) {
return new MSAAPathBatch(geometry, viewMatrix, devBounds);
}
const char* name() const override { return "MSAAPathBatch"; }
- void computePipelineOptimizations(GrInitInvariantOutput* color,
+ void computePipelineOptimizations(GrInitInvariantOutput* color,
GrInitInvariantOutput* coverage,
GrBatchToXPOverrides* overrides) const override {
// When this is called on a batch, there is only one geometry bundle
@@ -260,7 +260,7 @@ private:
overrides.getOverrideColorIfSet(&fGeoData[0].fColor);
}
- void computeWorstCasePointCount(const SkPath& path, int* subpaths, SkScalar tol,
+ void computeWorstCasePointCount(const SkPath& path, int* subpaths, SkScalar tol,
int* outLinePointCount, int* outQuadPointCount) const {
int linePointCount = 0;
int quadPointCount = 0;
@@ -319,7 +319,7 @@ private:
return;
}
- GrPrimitiveType primitiveType = fIsIndexed ? kTriangles_GrPrimitiveType
+ GrPrimitiveType primitiveType = fIsIndexed ? kTriangles_GrPrimitiveType
: kTriangleFan_GrPrimitiveType;
// allocate vertex / index buffers
@@ -327,9 +327,9 @@ private:
int firstLineVertex;
MSAALineVertices lines;
size_t lineVertexStride = sizeof(MSAALineVertices::Vertex);
- lines.vertices = (MSAALineVertices::Vertex*) target->makeVertexSpace(lineVertexStride,
+ lines.vertices = (MSAALineVertices::Vertex*) target->makeVertexSpace(lineVertexStride,
fMaxLineVertices,
- &lineVertexBuffer,
+ &lineVertexBuffer,
&firstLineVertex);
if (!lines.vertices) {
SkDebugf("Could not allocate vertices\n");
@@ -348,7 +348,7 @@ private:
const GrBuffer* lineIndexBuffer = nullptr;
int firstLineIndex;
if (fIsIndexed) {
- lines.indices = target->makeIndexSpace(fMaxLineIndices, &lineIndexBuffer,
+ lines.indices = target->makeIndexSpace(fMaxLineIndices, &lineIndexBuffer,
&firstLineIndex);
if (!lines.indices) {
SkDebugf("Could not allocate indices\n");
@@ -392,26 +392,26 @@ private:
SkASSERT(quadVertexOffset <= fMaxQuadVertices && quadIndexOffset <= fMaxQuadIndices);
if (lineVertexOffset) {
- SkAutoTUnref<const GrGeometryProcessor> lineGP;
+ sk_sp<GrGeometryProcessor> lineGP;
{
using namespace GrDefaultGeoProcFactory;
- lineGP.reset(GrDefaultGeoProcFactory::Create(Color(Color::kAttribute_Type),
- Coverage(255),
- LocalCoords(LocalCoords::kUnused_Type),
- fViewMatrix));
+ lineGP = GrDefaultGeoProcFactory::Make(Color(Color::kAttribute_Type),
+ Coverage(255),
+ LocalCoords(LocalCoords::kUnused_Type),
+ fViewMatrix);
}
SkASSERT(lineVertexStride == lineGP->getVertexStride());
GrMesh lineMeshes;
if (fIsIndexed) {
- lineMeshes.initIndexed(primitiveType, lineVertexBuffer, lineIndexBuffer,
- firstLineVertex, firstLineIndex, lineVertexOffset,
+ lineMeshes.initIndexed(primitiveType, lineVertexBuffer, lineIndexBuffer,
+ firstLineVertex, firstLineIndex, lineVertexOffset,
lineIndexOffset);
} else {
- lineMeshes.init(primitiveType, lineVertexBuffer, firstLineVertex,
+ lineMeshes.init(primitiveType, lineVertexBuffer, firstLineVertex,
lineVertexOffset);
}
- target->draw(lineGP, lineMeshes);
+ target->draw(lineGP.get(), lineMeshes);
}
if (quadVertexOffset) {
@@ -420,7 +420,7 @@ private:
const GrBuffer* quadVertexBuffer;
int firstQuadVertex;
- MSAAQuadVertices::Vertex* quadVertices = (MSAAQuadVertices::Vertex*)
+ MSAAQuadVertices::Vertex* quadVertices = (MSAAQuadVertices::Vertex*)
target->makeVertexSpace(quadVertexStride, quadVertexOffset, &quadVertexBuffer,
&firstQuadVertex);
memcpy(quadVertices, quads.vertices, quadVertexStride * quadVertexOffset);
@@ -428,15 +428,15 @@ private:
if (fIsIndexed) {
const GrBuffer* quadIndexBuffer;
int firstQuadIndex;
- uint16_t* quadIndices = (uint16_t*) target->makeIndexSpace(quadIndexOffset,
- &quadIndexBuffer,
+ uint16_t* quadIndices = (uint16_t*) target->makeIndexSpace(quadIndexOffset,
+ &quadIndexBuffer,
&firstQuadIndex);
memcpy(quadIndices, quads.indices, sizeof(uint16_t) * quadIndexOffset);
- quadMeshes.initIndexed(kTriangles_GrPrimitiveType, quadVertexBuffer,
- quadIndexBuffer, firstQuadVertex, firstQuadIndex,
+ quadMeshes.initIndexed(kTriangles_GrPrimitiveType, quadVertexBuffer,
+ quadIndexBuffer, firstQuadVertex, firstQuadIndex,
quadVertexOffset, quadIndexOffset);
} else {
- quadMeshes.init(kTriangles_GrPrimitiveType, quadVertexBuffer, firstQuadVertex,
+ quadMeshes.init(kTriangles_GrPrimitiveType, quadVertexBuffer, firstQuadVertex,
quadVertexOffset);
}
target->draw(quadGP, quadMeshes);
@@ -451,7 +451,7 @@ private:
fGeoData.push_back(geometry);
this->setBounds(devBounds);
int contourCount;
- this->computeWorstCasePointCount(geometry.fPath, &contourCount, kTolerance,
+ this->computeWorstCasePointCount(geometry.fPath, &contourCount, kTolerance,
&fMaxLineVertices, &fMaxQuadVertices);
fMaxLineIndices = fMaxLineVertices * 3;
fMaxQuadIndices = fMaxQuadVertices * 3;
@@ -469,7 +469,7 @@ private:
return false;
}
- if ((fMaxLineIndices + that->fMaxLineIndices > SK_MaxU16) ||
+ if ((fMaxLineIndices + that->fMaxLineIndices > SK_MaxU16) ||
(fMaxQuadIndices + that->fMaxQuadIndices > SK_MaxU16)) {
return false;
}
@@ -524,17 +524,17 @@ private:
case SkPath::kConic_Verb: {
SkScalar weight = iter.conicWeight();
SkAutoConicToQuads converter;
- const SkPoint* quadPts = converter.computeQuads(pts, weight,
+ const SkPoint* quadPts = converter.computeQuads(pts, weight,
kTolerance);
for (int i = 0; i < converter.countQuads(); ++i) {
- add_quad(lines, quads, quadPts + i * 2, color, isIndexed,
+ add_quad(lines, quads, quadPts + i * 2, color, isIndexed,
subpathIdxStart);
}
break;
}
case SkPath::kQuad_Verb: {
add_quad(lines, quads, pts, color, isIndexed, subpathIdxStart);
- break;
+ break;
}
case SkPath::kCubic_Verb: {
SkSTArray<15, SkPoint, true> quadPts;
@@ -682,7 +682,7 @@ bool GrMSAAPathRenderer::internalDrawPath(GrDrawContext* drawContext,
geometry.fPath = path;
geometry.fTolerance = kTolerance;
- SkAutoTUnref<MSAAPathBatch> batch(MSAAPathBatch::Create(geometry, viewMatrix,
+ SkAutoTUnref<MSAAPathBatch> batch(MSAAPathBatch::Create(geometry, viewMatrix,
devBounds));
if (!batch->isValid()) {
return false;
@@ -749,7 +749,7 @@ void GrMSAAPathRenderer::onStencilPath(const StencilPathArgs& args) {
SkASSERT(SkPath::kInverseWinding_FillType != args.fPath->getFillType());
GrPaint paint;
- SkSafeUnref(paint.setXPFactory(GrDisableColorXPFactory::Create()));
+ paint.setXPFactory(GrDisableColorXPFactory::Make());
paint.setAntiAlias(args.fIsAA);
this->internalDrawPath(args.fDrawContext,
diff --git a/src/gpu/batches/GrNinePatch.cpp b/src/gpu/batches/GrNinePatch.cpp
index 24e3dd6e03..5f5339543b 100644
--- a/src/gpu/batches/GrNinePatch.cpp
+++ b/src/gpu/batches/GrNinePatch.cpp
@@ -15,12 +15,12 @@
#include "SkNinePatchIter.h"
#include "SkRect.h"
-static const GrGeometryProcessor* create_gp(bool readsCoverage) {
+static sk_sp<GrGeometryProcessor> create_gp(bool readsCoverage) {
using namespace GrDefaultGeoProcFactory;
Color color(Color::kAttribute_Type);
Coverage coverage(readsCoverage ? Coverage::kSolid_Type : Coverage::kNone_Type);
LocalCoords localCoords(LocalCoords::kHasExplicit_Type);
- return GrDefaultGeoProcFactory::Create(color, coverage, localCoords, SkMatrix::I());
+ return GrDefaultGeoProcFactory::Make(color, coverage, localCoords, SkMatrix::I());
}
class GrNonAANinePatchBatch : public GrVertexBatch {
@@ -85,7 +85,7 @@ public:
private:
void onPrepareDraws(Target* target) const override {
- SkAutoTUnref<const GrGeometryProcessor> gp(create_gp(fOverrides.readsCoverage()));
+ sk_sp<GrGeometryProcessor> gp(create_gp(fOverrides.readsCoverage()));
if (!gp) {
SkDebugf("Couldn't create GrGeometryProcessor\n");
return;
@@ -136,7 +136,7 @@ private:
verts += kVertsPerRect * vertexStride;
}
}
- helper.recordDraw(target, gp);
+ helper.recordDraw(target, gp.get());
}
void initBatchTracker(const GrXPOverridesForBatch& overrides) override {
diff --git a/src/gpu/batches/GrNonAAFillRectBatch.cpp b/src/gpu/batches/GrNonAAFillRectBatch.cpp
index 5e9d1769b5..3b4c5da732 100644
--- a/src/gpu/batches/GrNonAAFillRectBatch.cpp
+++ b/src/gpu/batches/GrNonAAFillRectBatch.cpp
@@ -51,10 +51,10 @@ public:
The vertex attrib order is always pos, color, [local coords].
*/
-static const GrGeometryProcessor* create_gp(const SkMatrix& viewMatrix,
- bool readsCoverage,
- bool hasExplicitLocalCoords,
- const SkMatrix* localMatrix) {
+static sk_sp<GrGeometryProcessor> make_gp(const SkMatrix& viewMatrix,
+ bool readsCoverage,
+ bool hasExplicitLocalCoords,
+ const SkMatrix* localMatrix) {
using namespace GrDefaultGeoProcFactory;
Color color(Color::kAttribute_Type);
Coverage coverage(readsCoverage ? Coverage::kSolid_Type : Coverage::kNone_Type);
@@ -67,14 +67,14 @@ static const GrGeometryProcessor* create_gp(const SkMatrix& viewMatrix,
LocalCoords localCoords(hasExplicitLocalCoords ? LocalCoords::kHasExplicit_Type :
LocalCoords::kUsePosition_Type,
localMatrix);
- return GrDefaultGeoProcFactory::Create(color, coverage, localCoords, viewMatrix);
+ return GrDefaultGeoProcFactory::Make(color, coverage, localCoords, viewMatrix);
} else if (hasExplicitLocalCoords) {
LocalCoords localCoords(LocalCoords::kHasExplicit_Type);
- return GrDefaultGeoProcFactory::Create(color, coverage, localCoords, SkMatrix::I());
+ return GrDefaultGeoProcFactory::Make(color, coverage, localCoords, SkMatrix::I());
} else {
LocalCoords localCoords(LocalCoords::kUsePosition_Type, localMatrix);
- return GrDefaultGeoProcFactory::CreateForDeviceSpace(color, coverage, localCoords,
- viewMatrix);
+ return GrDefaultGeoProcFactory::MakeForDeviceSpace(color, coverage, localCoords,
+ viewMatrix);
}
}
@@ -138,10 +138,10 @@ public:
return true;
}
- static const GrGeometryProcessor* CreateGP(const Geometry& geo,
- const GrXPOverridesForBatch& overrides) {
- const GrGeometryProcessor* gp = create_gp(geo.fViewMatrix, overrides.readsCoverage(), true,
- nullptr);
+ static sk_sp<GrGeometryProcessor> MakeGP(const Geometry& geo,
+ const GrXPOverridesForBatch& overrides) {
+ sk_sp<GrGeometryProcessor> gp = make_gp(geo.fViewMatrix, overrides.readsCoverage(), true,
+ nullptr);
SkASSERT(gp->getVertexStride() ==
sizeof(GrDefaultGeoProcFactory::PositionColorLocalCoordAttr));
@@ -186,12 +186,12 @@ public:
(!mine.fHasLocalMatrix || mine.fLocalMatrix.cheapEqualTo(theirs.fLocalMatrix));
}
- static const GrGeometryProcessor* CreateGP(const Geometry& geo,
- const GrXPOverridesForBatch& overrides) {
- const GrGeometryProcessor* gp = create_gp(geo.fViewMatrix, overrides.readsCoverage(),
- geo.fHasLocalRect,
- geo.fHasLocalMatrix ? &geo.fLocalMatrix :
- nullptr);
+ static sk_sp<GrGeometryProcessor> MakeGP(const Geometry& geo,
+ const GrXPOverridesForBatch& overrides) {
+ sk_sp<GrGeometryProcessor> gp = make_gp(geo.fViewMatrix, overrides.readsCoverage(),
+ geo.fHasLocalRect,
+ geo.fHasLocalMatrix ? &geo.fLocalMatrix
+ : nullptr);
SkASSERT(geo.fHasLocalRect ?
gp->getVertexStride() == sizeof(GrDefaultGeoProcFactory::PositionColorLocalCoordAttr) :
diff --git a/src/gpu/batches/GrNonAAStrokeRectBatch.cpp b/src/gpu/batches/GrNonAAStrokeRectBatch.cpp
index 36092ea3f7..a38760c362 100644
--- a/src/gpu/batches/GrNonAAStrokeRectBatch.cpp
+++ b/src/gpu/batches/GrNonAAStrokeRectBatch.cpp
@@ -105,7 +105,7 @@ private:
}
void onPrepareDraws(Target* target) const override {
- SkAutoTUnref<const GrGeometryProcessor> gp;
+ sk_sp<GrGeometryProcessor> gp;
{
using namespace GrDefaultGeoProcFactory;
Color color(this->color());
@@ -113,8 +113,7 @@ private:
Coverage::kNone_Type);
LocalCoords localCoords(this->usesLocalCoords() ? LocalCoords::kUsePosition_Type :
LocalCoords::kUnused_Type);
- gp.reset(GrDefaultGeoProcFactory::Create(color, coverage, localCoords,
- this->viewMatrix()));
+ gp = GrDefaultGeoProcFactory::Make(color, coverage, localCoords, this->viewMatrix());
}
size_t vertexStride = gp->getVertexStride();
@@ -157,7 +156,7 @@ private:
GrMesh mesh;
mesh.init(primType, vertexBuffer, firstVertex, vertexCount);
- target->draw(gp, mesh);
+ target->draw(gp.get(), mesh);
}
void initBatchTracker(const GrXPOverridesForBatch& overrides) override {
diff --git a/src/gpu/batches/GrStencilAndCoverPathRenderer.cpp b/src/gpu/batches/GrStencilAndCoverPathRenderer.cpp
index 344748ceca..2a480189fa 100644
--- a/src/gpu/batches/GrStencilAndCoverPathRenderer.cpp
+++ b/src/gpu/batches/GrStencilAndCoverPathRenderer.cpp
@@ -72,7 +72,7 @@ void GrStencilAndCoverPathRenderer::onStencilPath(const StencilPathArgs& args) {
SkASSERT(!args.fIsAA || args.fDrawContext->isStencilBufferMultisampled());
GrPaint paint;
- SkSafeUnref(paint.setXPFactory(GrDisableColorXPFactory::Create()));
+ paint.setXPFactory(GrDisableColorXPFactory::Make());
paint.setAntiAlias(args.fIsAA);
const GrPipelineBuilder pipelineBuilder(paint, args.fIsAA);
diff --git a/src/gpu/batches/GrTInstanceBatch.h b/src/gpu/batches/GrTInstanceBatch.h
index b85b3aa13d..c501fd967a 100644
--- a/src/gpu/batches/GrTInstanceBatch.h
+++ b/src/gpu/batches/GrTInstanceBatch.h
@@ -89,8 +89,7 @@ private:
GrTInstanceBatch() : INHERITED(ClassID()) {}
void onPrepareDraws(Target* target) const override {
- SkAutoTUnref<const GrGeometryProcessor> gp(Impl::CreateGP(this->seedGeometry(),
- fOverrides));
+ sk_sp<GrGeometryProcessor> gp(Impl::MakeGP(this->seedGeometry(), fOverrides));
if (!gp) {
SkDebugf("Couldn't create GrGeometryProcessor\n");
return;
@@ -115,7 +114,7 @@ private:
i * Impl::kVertsPerInstance * vertexStride;
Impl::Tesselate(verts, vertexStride, fGeoData[i], fOverrides);
}
- helper.recordDraw(target, gp);
+ helper.recordDraw(target, gp.get());
}
const Geometry& seedGeometry() const { return fGeoData[0]; }
diff --git a/src/gpu/batches/GrTessellatingPathRenderer.cpp b/src/gpu/batches/GrTessellatingPathRenderer.cpp
index e9c6e1ecf8..6bc8549e30 100644
--- a/src/gpu/batches/GrTessellatingPathRenderer.cpp
+++ b/src/gpu/batches/GrTessellatingPathRenderer.cpp
@@ -211,7 +211,7 @@ private:
}
void onPrepareDraws(Target* target) const override {
- SkAutoTUnref<const GrGeometryProcessor> gp;
+ sk_sp<GrGeometryProcessor> gp;
{
using namespace GrDefaultGeoProcFactory;
@@ -226,8 +226,7 @@ private:
coverageType = Coverage::kNone_Type;
}
Coverage coverage(coverageType);
- gp.reset(GrDefaultGeoProcFactory::Create(color, coverage, localCoords,
- fViewMatrix));
+ gp = GrDefaultGeoProcFactory::Make(color, coverage, localCoords, fViewMatrix);
}
this->draw(target, gp.get());
}
diff --git a/src/gpu/effects/GrBezierEffect.cpp b/src/gpu/effects/GrBezierEffect.cpp
index 075ce16434..9d3e8eec4f 100644
--- a/src/gpu/effects/GrBezierEffect.cpp
+++ b/src/gpu/effects/GrBezierEffect.cpp
@@ -272,15 +272,15 @@ GrConicEffect::GrConicEffect(GrColor color, const SkMatrix& viewMatrix, uint8_t
GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrConicEffect);
-const GrGeometryProcessor* GrConicEffect::TestCreate(GrProcessorTestData* d) {
- GrGeometryProcessor* gp;
+sk_sp<GrGeometryProcessor> GrConicEffect::TestCreate(GrProcessorTestData* d) {
+ sk_sp<GrGeometryProcessor> gp;
do {
GrPrimitiveEdgeType edgeType =
static_cast<GrPrimitiveEdgeType>(
d->fRandom->nextULessThan(kGrProcessorEdgeTypeCnt));
- gp = GrConicEffect::Create(GrRandomColor(d->fRandom), GrTest::TestMatrix(d->fRandom),
- edgeType, *d->fCaps,
- GrTest::TestMatrix(d->fRandom), d->fRandom->nextBool());
+ gp = GrConicEffect::Make(GrRandomColor(d->fRandom), GrTest::TestMatrix(d->fRandom),
+ edgeType, *d->fCaps,
+ GrTest::TestMatrix(d->fRandom), d->fRandom->nextBool());
} while (nullptr == gp);
return gp;
}
@@ -488,16 +488,16 @@ GrQuadEffect::GrQuadEffect(GrColor color, const SkMatrix& viewMatrix, uint8_t co
GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrQuadEffect);
-const GrGeometryProcessor* GrQuadEffect::TestCreate(GrProcessorTestData* d) {
- GrGeometryProcessor* gp;
+sk_sp<GrGeometryProcessor> GrQuadEffect::TestCreate(GrProcessorTestData* d) {
+ sk_sp<GrGeometryProcessor> gp;
do {
GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>(
d->fRandom->nextULessThan(kGrProcessorEdgeTypeCnt));
- gp = GrQuadEffect::Create(GrRandomColor(d->fRandom),
- GrTest::TestMatrix(d->fRandom),
- edgeType, *d->fCaps,
- GrTest::TestMatrix(d->fRandom),
- d->fRandom->nextBool());
+ gp = GrQuadEffect::Make(GrRandomColor(d->fRandom),
+ GrTest::TestMatrix(d->fRandom),
+ edgeType, *d->fCaps,
+ GrTest::TestMatrix(d->fRandom),
+ d->fRandom->nextBool());
} while (nullptr == gp);
return gp;
}
@@ -716,14 +716,14 @@ GrCubicEffect::GrCubicEffect(GrColor color, const SkMatrix& viewMatrix,
GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrCubicEffect);
-const GrGeometryProcessor* GrCubicEffect::TestCreate(GrProcessorTestData* d) {
- GrGeometryProcessor* gp;
+sk_sp<GrGeometryProcessor> GrCubicEffect::TestCreate(GrProcessorTestData* d) {
+ sk_sp<GrGeometryProcessor> gp;
do {
GrPrimitiveEdgeType edgeType =
static_cast<GrPrimitiveEdgeType>(
d->fRandom->nextULessThan(kGrProcessorEdgeTypeCnt));
- gp = GrCubicEffect::Create(GrRandomColor(d->fRandom),
- GrTest::TestMatrix(d->fRandom), edgeType, *d->fCaps);
+ gp = GrCubicEffect::Make(GrRandomColor(d->fRandom),
+ GrTest::TestMatrix(d->fRandom), edgeType, *d->fCaps);
} while (nullptr == gp);
return gp;
}
diff --git a/src/gpu/effects/GrBezierEffect.h b/src/gpu/effects/GrBezierEffect.h
index ddb249b587..50dca99242 100644
--- a/src/gpu/effects/GrBezierEffect.h
+++ b/src/gpu/effects/GrBezierEffect.h
@@ -58,30 +58,33 @@ class GrGLConicEffect;
class GrConicEffect : public GrGeometryProcessor {
public:
- static GrGeometryProcessor* Create(GrColor color,
- const SkMatrix& viewMatrix,
- const GrPrimitiveEdgeType edgeType,
- const GrCaps& caps,
- const SkMatrix& localMatrix,
- bool usesLocalCoords,
- uint8_t coverage = 0xff) {
+ static sk_sp<GrGeometryProcessor> Make(GrColor color,
+ const SkMatrix& viewMatrix,
+ const GrPrimitiveEdgeType edgeType,
+ const GrCaps& caps,
+ const SkMatrix& localMatrix,
+ bool usesLocalCoords,
+ uint8_t coverage = 0xff) {
switch (edgeType) {
case kFillAA_GrProcessorEdgeType:
if (!caps.shaderCaps()->shaderDerivativeSupport()) {
return nullptr;
}
- return new GrConicEffect(color, viewMatrix, coverage, kFillAA_GrProcessorEdgeType,
- localMatrix, usesLocalCoords);
+ return sk_sp<GrGeometryProcessor>(
+ new GrConicEffect(color, viewMatrix, coverage, kFillAA_GrProcessorEdgeType,
+ localMatrix, usesLocalCoords));
case kHairlineAA_GrProcessorEdgeType:
if (!caps.shaderCaps()->shaderDerivativeSupport()) {
return nullptr;
}
- return new GrConicEffect(color, viewMatrix, coverage,
- kHairlineAA_GrProcessorEdgeType, localMatrix,
- usesLocalCoords);
+ return sk_sp<GrGeometryProcessor>(
+ new GrConicEffect(color, viewMatrix, coverage,
+ kHairlineAA_GrProcessorEdgeType, localMatrix,
+ usesLocalCoords));
case kFillBW_GrProcessorEdgeType:
- return new GrConicEffect(color, viewMatrix, coverage, kFillBW_GrProcessorEdgeType,
- localMatrix, usesLocalCoords);
+ return sk_sp<GrGeometryProcessor>(
+ new GrConicEffect(color, viewMatrix, coverage, kFillBW_GrProcessorEdgeType,
+ localMatrix, usesLocalCoords));
default:
return nullptr;
}
@@ -138,30 +141,33 @@ class GrGLQuadEffect;
class GrQuadEffect : public GrGeometryProcessor {
public:
- static GrGeometryProcessor* Create(GrColor color,
- const SkMatrix& viewMatrix,
- const GrPrimitiveEdgeType edgeType,
- const GrCaps& caps,
- const SkMatrix& localMatrix,
- bool usesLocalCoords,
- uint8_t coverage = 0xff) {
+ static sk_sp<GrGeometryProcessor> Make(GrColor color,
+ const SkMatrix& viewMatrix,
+ const GrPrimitiveEdgeType edgeType,
+ const GrCaps& caps,
+ const SkMatrix& localMatrix,
+ bool usesLocalCoords,
+ uint8_t coverage = 0xff) {
switch (edgeType) {
case kFillAA_GrProcessorEdgeType:
if (!caps.shaderCaps()->shaderDerivativeSupport()) {
return nullptr;
}
- return new GrQuadEffect(color, viewMatrix, coverage, kFillAA_GrProcessorEdgeType,
- localMatrix, usesLocalCoords);
+ return sk_sp<GrGeometryProcessor>(
+ new GrQuadEffect(color, viewMatrix, coverage, kFillAA_GrProcessorEdgeType,
+ localMatrix, usesLocalCoords));
case kHairlineAA_GrProcessorEdgeType:
if (!caps.shaderCaps()->shaderDerivativeSupport()) {
return nullptr;
}
- return new GrQuadEffect(color, viewMatrix, coverage,
- kHairlineAA_GrProcessorEdgeType, localMatrix,
- usesLocalCoords);
+ return sk_sp<GrGeometryProcessor>(
+ new GrQuadEffect(color, viewMatrix, coverage,
+ kHairlineAA_GrProcessorEdgeType, localMatrix,
+ usesLocalCoords));
case kFillBW_GrProcessorEdgeType:
- return new GrQuadEffect(color, viewMatrix, coverage, kFillBW_GrProcessorEdgeType,
- localMatrix, usesLocalCoords);
+ return sk_sp<GrGeometryProcessor>(
+ new GrQuadEffect(color, viewMatrix, coverage, kFillBW_GrProcessorEdgeType,
+ localMatrix, usesLocalCoords));
default:
return nullptr;
}
@@ -220,23 +226,26 @@ class GrGLCubicEffect;
class GrCubicEffect : public GrGeometryProcessor {
public:
- static GrGeometryProcessor* Create(GrColor color,
- const SkMatrix& viewMatrix,
- const GrPrimitiveEdgeType edgeType,
- const GrCaps& caps) {
+ static sk_sp<GrGeometryProcessor> Make(GrColor color,
+ const SkMatrix& viewMatrix,
+ const GrPrimitiveEdgeType edgeType,
+ const GrCaps& caps) {
switch (edgeType) {
case kFillAA_GrProcessorEdgeType:
if (!caps.shaderCaps()->shaderDerivativeSupport()) {
return nullptr;
}
- return new GrCubicEffect(color, viewMatrix, kFillAA_GrProcessorEdgeType);
+ return sk_sp<GrGeometryProcessor>(
+ new GrCubicEffect(color, viewMatrix, kFillAA_GrProcessorEdgeType));
case kHairlineAA_GrProcessorEdgeType:
if (!caps.shaderCaps()->shaderDerivativeSupport()) {
return nullptr;
}
- return new GrCubicEffect(color, viewMatrix, kHairlineAA_GrProcessorEdgeType);
+ return sk_sp<GrGeometryProcessor>(
+ new GrCubicEffect(color, viewMatrix, kHairlineAA_GrProcessorEdgeType));
case kFillBW_GrProcessorEdgeType:
- return new GrCubicEffect(color, viewMatrix, kFillBW_GrProcessorEdgeType);
+ return sk_sp<GrGeometryProcessor>(
+ new GrCubicEffect(color, viewMatrix, kFillBW_GrProcessorEdgeType));
default:
return nullptr;
}
diff --git a/src/gpu/effects/GrBicubicEffect.cpp b/src/gpu/effects/GrBicubicEffect.cpp
index 0a06b62c41..5e6967ce4b 100644
--- a/src/gpu/effects/GrBicubicEffect.cpp
+++ b/src/gpu/effects/GrBicubicEffect.cpp
@@ -179,14 +179,14 @@ void GrBicubicEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrBicubicEffect);
-const GrFragmentProcessor* GrBicubicEffect::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> GrBicubicEffect::TestCreate(GrProcessorTestData* d) {
int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx :
GrProcessorUnitTest::kAlphaTextureIdx;
SkScalar coefficients[16];
for (int i = 0; i < 16; i++) {
coefficients[i] = d->fRandom->nextSScalar1();
}
- return GrBicubicEffect::Create(d->fTextures[texIdx], coefficients);
+ return GrBicubicEffect::Make(d->fTextures[texIdx], coefficients);
}
//////////////////////////////////////////////////////////////////////////////
diff --git a/src/gpu/effects/GrBicubicEffect.h b/src/gpu/effects/GrBicubicEffect.h
index 208719217b..3c84f97919 100644
--- a/src/gpu/effects/GrBicubicEffect.h
+++ b/src/gpu/effects/GrBicubicEffect.h
@@ -32,43 +32,46 @@ public:
/**
* Create a simple filter effect with custom bicubic coefficients and optional domain.
*/
- static const GrFragmentProcessor* Create(GrTexture* tex, const SkScalar coefficients[16],
- const SkRect* domain = nullptr) {
+ static sk_sp<GrFragmentProcessor> Make(GrTexture* tex, const SkScalar coefficients[16],
+ const SkRect* domain = nullptr) {
if (nullptr == domain) {
static const SkShader::TileMode kTileModes[] = { SkShader::kClamp_TileMode,
SkShader::kClamp_TileMode };
- return Create(tex, coefficients, GrCoordTransform::MakeDivByTextureWHMatrix(tex),
- kTileModes);
+ return Make(tex, coefficients, GrCoordTransform::MakeDivByTextureWHMatrix(tex),
+ kTileModes);
} else {
- return new GrBicubicEffect(tex, coefficients,
- GrCoordTransform::MakeDivByTextureWHMatrix(tex), *domain);
+ return sk_sp<GrFragmentProcessor>(
+ new GrBicubicEffect(tex, coefficients,
+ GrCoordTransform::MakeDivByTextureWHMatrix(tex), *domain));
}
}
/**
* Create a Mitchell filter effect with specified texture matrix and x/y tile modes.
*/
- static const GrFragmentProcessor* Create(GrTexture* tex, const SkMatrix& matrix,
- const SkShader::TileMode tileModes[2]) {
- return Create(tex, gMitchellCoefficients, matrix, tileModes);
+ static sk_sp<GrFragmentProcessor> Make(GrTexture* tex, const SkMatrix& matrix,
+ const SkShader::TileMode tileModes[2]) {
+ return Make(tex, gMitchellCoefficients, matrix, tileModes);
}
/**
* Create a filter effect with custom bicubic coefficients, the texture matrix, and the x/y
* tilemodes.
*/
- static const GrFragmentProcessor* Create(GrTexture* tex, const SkScalar coefficients[16],
- const SkMatrix& matrix,
- const SkShader::TileMode tileModes[2]) {
- return new GrBicubicEffect(tex, coefficients, matrix, tileModes);
+ static sk_sp<GrFragmentProcessor> Make(GrTexture* tex, const SkScalar coefficients[16],
+ const SkMatrix& matrix,
+ const SkShader::TileMode tileModes[2]) {
+ return sk_sp<GrFragmentProcessor>(new GrBicubicEffect(tex, coefficients, matrix,
+ tileModes));
}
/**
* Create a Mitchell filter effect with a texture matrix and a domain.
*/
- static const GrFragmentProcessor* Create(GrTexture* tex, const SkMatrix& matrix,
- const SkRect& domain) {
- return new GrBicubicEffect(tex, gMitchellCoefficients, matrix, domain);
+ static sk_sp<GrFragmentProcessor> Make(GrTexture* tex, const SkMatrix& matrix,
+ const SkRect& domain) {
+ return sk_sp<GrFragmentProcessor>(new GrBicubicEffect(tex, gMitchellCoefficients, matrix,
+ domain));
}
/**
diff --git a/src/gpu/effects/GrBitmapTextGeoProc.cpp b/src/gpu/effects/GrBitmapTextGeoProc.cpp
index 246d7be627..633a8806ef 100644
--- a/src/gpu/effects/GrBitmapTextGeoProc.cpp
+++ b/src/gpu/effects/GrBitmapTextGeoProc.cpp
@@ -164,7 +164,7 @@ GrGLSLPrimitiveProcessor* GrBitmapTextGeoProc::createGLSLInstance(const GrGLSLCa
GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrBitmapTextGeoProc);
-const GrGeometryProcessor* GrBitmapTextGeoProc::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrGeometryProcessor> GrBitmapTextGeoProc::TestCreate(GrProcessorTestData* d) {
int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx :
GrProcessorUnitTest::kAlphaTextureIdx;
static const SkShader::TileMode kTileModes[] = {
@@ -177,7 +177,7 @@ const GrGeometryProcessor* GrBitmapTextGeoProc::TestCreate(GrProcessorTestData*
kTileModes[d->fRandom->nextULessThan(SK_ARRAY_COUNT(kTileModes))],
};
GrTextureParams params(tileModes, d->fRandom->nextBool() ? GrTextureParams::kBilerp_FilterMode :
- GrTextureParams::kNone_FilterMode);
+ GrTextureParams::kNone_FilterMode);
GrMaskFormat format = kARGB_GrMaskFormat; // init to avoid warning
switch (d->fRandom->nextULessThan(3)) {
@@ -192,7 +192,7 @@ const GrGeometryProcessor* GrBitmapTextGeoProc::TestCreate(GrProcessorTestData*
break;
}
- return GrBitmapTextGeoProc::Create(GrRandomColor(d->fRandom), d->fTextures[texIdx], params,
- format, GrTest::TestMatrix(d->fRandom),
- d->fRandom->nextBool());
+ return GrBitmapTextGeoProc::Make(GrRandomColor(d->fRandom), d->fTextures[texIdx], params,
+ format, GrTest::TestMatrix(d->fRandom),
+ d->fRandom->nextBool());
}
diff --git a/src/gpu/effects/GrBitmapTextGeoProc.h b/src/gpu/effects/GrBitmapTextGeoProc.h
index 5501d938f5..226ae770e7 100644
--- a/src/gpu/effects/GrBitmapTextGeoProc.h
+++ b/src/gpu/effects/GrBitmapTextGeoProc.h
@@ -21,10 +21,11 @@ class GrInvariantOutput;
*/
class GrBitmapTextGeoProc : public GrGeometryProcessor {
public:
- static GrGeometryProcessor* Create(GrColor color, GrTexture* tex, const GrTextureParams& p,
+ static sk_sp<GrGeometryProcessor> Make(GrColor color, GrTexture* tex, const GrTextureParams& p,
GrMaskFormat format, const SkMatrix& localMatrix,
bool usesLocalCoords) {
- return new GrBitmapTextGeoProc(color, tex, p, format, localMatrix, usesLocalCoords);
+ return sk_sp<GrGeometryProcessor>(
+ new GrBitmapTextGeoProc(color, tex, p, format, localMatrix, usesLocalCoords));
}
virtual ~GrBitmapTextGeoProc() {}
diff --git a/src/gpu/effects/GrConfigConversionEffect.cpp b/src/gpu/effects/GrConfigConversionEffect.cpp
index 9791cb4b82..d2fde96bb3 100644
--- a/src/gpu/effects/GrConfigConversionEffect.cpp
+++ b/src/gpu/effects/GrConfigConversionEffect.cpp
@@ -125,14 +125,15 @@ void GrConfigConversionEffect::onComputeInvariantOutput(GrInvariantOutput* inout
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrConfigConversionEffect);
-const GrFragmentProcessor* GrConfigConversionEffect::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> GrConfigConversionEffect::TestCreate(GrProcessorTestData* d) {
PMConversion pmConv = static_cast<PMConversion>(d->fRandom->nextULessThan(kPMConversionCnt));
GrSwizzle swizzle;
do {
swizzle = GrSwizzle::CreateRandom(d->fRandom);
} while (pmConv == kNone_PMConversion && swizzle == GrSwizzle::RGBA());
- return new GrConfigConversionEffect(d->fTextures[GrProcessorUnitTest::kSkiaPMTextureIdx],
- swizzle, pmConv, GrTest::TestMatrix(d->fRandom));
+ return sk_sp<GrFragmentProcessor>(
+ new GrConfigConversionEffect(d->fTextures[GrProcessorUnitTest::kSkiaPMTextureIdx],
+ swizzle, pmConv, GrTest::TestMatrix(d->fRandom)));
}
///////////////////////////////////////////////////////////////////////////////
@@ -214,17 +215,16 @@ void GrConfigConversionEffect::TestForPreservingPMConversions(GrContext* context
GrPaint paint1;
GrPaint paint2;
GrPaint paint3;
- SkAutoTUnref<GrFragmentProcessor> pmToUPM1(new GrConfigConversionEffect(
+ sk_sp<GrFragmentProcessor> pmToUPM1(new GrConfigConversionEffect(
dataTex, GrSwizzle::RGBA(), *pmToUPMRule, SkMatrix::I()));
- SkAutoTUnref<GrFragmentProcessor> upmToPM(new GrConfigConversionEffect(
+ sk_sp<GrFragmentProcessor> upmToPM(new GrConfigConversionEffect(
readTex, GrSwizzle::RGBA(), *upmToPMRule, SkMatrix::I()));
- SkAutoTUnref<GrFragmentProcessor> pmToUPM2(new GrConfigConversionEffect(
+ sk_sp<GrFragmentProcessor> pmToUPM2(new GrConfigConversionEffect(
tempTex, GrSwizzle::RGBA(), *pmToUPMRule, SkMatrix::I()));
- paint1.addColorFragmentProcessor(pmToUPM1);
+ paint1.addColorFragmentProcessor(std::move(pmToUPM1));
paint1.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
-
sk_sp<GrDrawContext> readDrawContext(
context->drawContext(sk_ref_sp(readTex->asRenderTarget())));
if (!readDrawContext) {
@@ -240,7 +240,7 @@ void GrConfigConversionEffect::TestForPreservingPMConversions(GrContext* context
readTex->readPixels(0, 0, 256, 256, kRGBA_8888_GrPixelConfig, firstRead);
- paint2.addColorFragmentProcessor(upmToPM);
+ paint2.addColorFragmentProcessor(std::move(upmToPM));
paint2.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
sk_sp<GrDrawContext> tempDrawContext(
@@ -255,7 +255,7 @@ void GrConfigConversionEffect::TestForPreservingPMConversions(GrContext* context
kDstRect,
kSrcRect);
- paint3.addColorFragmentProcessor(pmToUPM2);
+ paint3.addColorFragmentProcessor(std::move(pmToUPM2));
paint3.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
readDrawContext = context->drawContext(sk_ref_sp(readTex->asRenderTarget()));
@@ -288,15 +288,15 @@ void GrConfigConversionEffect::TestForPreservingPMConversions(GrContext* context
}
}
-const GrFragmentProcessor* GrConfigConversionEffect::Create(GrTexture* texture,
- const GrSwizzle& swizzle,
- PMConversion pmConversion,
- const SkMatrix& matrix) {
+sk_sp<GrFragmentProcessor> GrConfigConversionEffect::Make(GrTexture* texture,
+ const GrSwizzle& swizzle,
+ PMConversion pmConversion,
+ const SkMatrix& matrix) {
if (swizzle == GrSwizzle::RGBA() && kNone_PMConversion == pmConversion) {
// If we returned a GrConfigConversionEffect that was equivalent to a GrSimpleTextureEffect
// then we may pollute our texture cache with redundant shaders. So in the case that no
// conversions were requested we instead return a GrSimpleTextureEffect.
- return GrSimpleTextureEffect::Create(texture, matrix);
+ return GrSimpleTextureEffect::Make(texture, matrix);
} else {
if (kRGBA_8888_GrPixelConfig != texture->config() &&
kBGRA_8888_GrPixelConfig != texture->config() &&
@@ -304,6 +304,7 @@ const GrFragmentProcessor* GrConfigConversionEffect::Create(GrTexture* texture,
// The PM conversions assume colors are 0..255
return nullptr;
}
- return new GrConfigConversionEffect(texture, swizzle, pmConversion, matrix);
+ return sk_sp<GrFragmentProcessor>(
+ new GrConfigConversionEffect(texture, swizzle, pmConversion, matrix));
}
}
diff --git a/src/gpu/effects/GrConfigConversionEffect.h b/src/gpu/effects/GrConfigConversionEffect.h
index 65c55e78b6..93b49aa656 100644
--- a/src/gpu/effects/GrConfigConversionEffect.h
+++ b/src/gpu/effects/GrConfigConversionEffect.h
@@ -33,8 +33,8 @@ public:
kPMConversionCnt
};
- static const GrFragmentProcessor* Create(GrTexture*, const GrSwizzle&, PMConversion,
- const SkMatrix&);
+ static sk_sp<GrFragmentProcessor> Make(GrTexture*, const GrSwizzle&, PMConversion,
+ const SkMatrix&);
const char* name() const override { return "Config Conversion"; }
diff --git a/src/gpu/effects/GrConstColorProcessor.cpp b/src/gpu/effects/GrConstColorProcessor.cpp
index c51ab8e92f..0684c9cdb2 100644
--- a/src/gpu/effects/GrConstColorProcessor.cpp
+++ b/src/gpu/effects/GrConstColorProcessor.cpp
@@ -112,7 +112,7 @@ bool GrConstColorProcessor::onIsEqual(const GrFragmentProcessor& other) const {
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrConstColorProcessor);
-const GrFragmentProcessor* GrConstColorProcessor::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> GrConstColorProcessor::TestCreate(GrProcessorTestData* d) {
GrColor color SK_INIT_TO_AVOID_WARNING;
int colorPicker = d->fRandom->nextULessThan(3);
switch (colorPicker) {
@@ -133,5 +133,5 @@ const GrFragmentProcessor* GrConstColorProcessor::TestCreate(GrProcessorTestData
break;
}
InputMode mode = static_cast<InputMode>(d->fRandom->nextULessThan(kInputModeCnt));
- return GrConstColorProcessor::Create(color, mode);
+ return GrConstColorProcessor::Make(color, mode);
}
diff --git a/src/gpu/effects/GrConvexPolyEffect.cpp b/src/gpu/effects/GrConvexPolyEffect.cpp
index caf86c2804..5ce7867997 100644
--- a/src/gpu/effects/GrConvexPolyEffect.cpp
+++ b/src/gpu/effects/GrConvexPolyEffect.cpp
@@ -19,8 +19,8 @@ class AARectEffect : public GrFragmentProcessor {
public:
const SkRect& getRect() const { return fRect; }
- static GrFragmentProcessor* Create(GrPrimitiveEdgeType edgeType, const SkRect& rect) {
- return new AARectEffect(edgeType, rect);
+ static sk_sp<GrFragmentProcessor> Make(GrPrimitiveEdgeType edgeType, const SkRect& rect) {
+ return sk_sp<GrFragmentProcessor>(new AARectEffect(edgeType, rect));
}
GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; }
@@ -63,17 +63,17 @@ private:
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(AARectEffect);
-const GrFragmentProcessor* AARectEffect::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> AARectEffect::TestCreate(GrProcessorTestData* d) {
SkRect rect = SkRect::MakeLTRB(d->fRandom->nextSScalar1(),
d->fRandom->nextSScalar1(),
d->fRandom->nextSScalar1(),
d->fRandom->nextSScalar1());
- GrFragmentProcessor* fp;
+ sk_sp<GrFragmentProcessor> fp;
do {
GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>(
d->fRandom->nextULessThan(kGrProcessorEdgeTypeCnt));
- fp = AARectEffect::Create(edgeType, rect);
+ fp = AARectEffect::Make(edgeType, rect);
} while (nullptr == fp);
return fp;
}
@@ -237,8 +237,8 @@ void GrGLConvexPolyEffect::GenKey(const GrProcessor& processor, const GrGLSLCaps
//////////////////////////////////////////////////////////////////////////////
-GrFragmentProcessor* GrConvexPolyEffect::Create(GrPrimitiveEdgeType type, const SkPath& path,
- const SkVector* offset) {
+sk_sp<GrFragmentProcessor> GrConvexPolyEffect::Make(GrPrimitiveEdgeType type, const SkPath& path,
+ const SkVector* offset) {
if (kHairlineAA_GrProcessorEdgeType == type) {
return nullptr;
}
@@ -253,10 +253,10 @@ GrFragmentProcessor* GrConvexPolyEffect::Create(GrPrimitiveEdgeType type, const
// skip the draw or omit the clip element.
if (!SkPathPriv::CheapComputeFirstDirection(path, &dir)) {
if (GrProcessorEdgeTypeIsInverseFill(type)) {
- return GrConstColorProcessor::Create(0xFFFFFFFF,
- GrConstColorProcessor::kModulateRGBA_InputMode);
+ return GrConstColorProcessor::Make(0xFFFFFFFF,
+ GrConstColorProcessor::kModulateRGBA_InputMode);
}
- return GrConstColorProcessor::Create(0, GrConstColorProcessor::kIgnore_InputMode);
+ return GrConstColorProcessor::Make(0, GrConstColorProcessor::kIgnore_InputMode);
}
SkVector t;
@@ -308,14 +308,15 @@ GrFragmentProcessor* GrConvexPolyEffect::Create(GrPrimitiveEdgeType type, const
if (path.isInverseFillType()) {
type = GrInvertProcessorEdgeType(type);
}
- return Create(type, n, edges);
+ return Make(type, n, edges);
}
-GrFragmentProcessor* GrConvexPolyEffect::Create(GrPrimitiveEdgeType edgeType, const SkRect& rect) {
+sk_sp<GrFragmentProcessor> GrConvexPolyEffect::Make(GrPrimitiveEdgeType edgeType,
+ const SkRect& rect) {
if (kHairlineAA_GrProcessorEdgeType == edgeType){
return nullptr;
}
- return AARectEffect::Create(edgeType, rect);
+ return AARectEffect::Make(edgeType, rect);
}
GrConvexPolyEffect::~GrConvexPolyEffect() {}
@@ -359,18 +360,18 @@ bool GrConvexPolyEffect::onIsEqual(const GrFragmentProcessor& other) const {
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrConvexPolyEffect);
-const GrFragmentProcessor* GrConvexPolyEffect::TestCreate(GrProcessorTestData* d) {
+sk_sp<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();
}
- GrFragmentProcessor* fp;
+ sk_sp<GrFragmentProcessor> fp;
do {
GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>(
d->fRandom->nextULessThan(kGrProcessorEdgeTypeCnt));
- fp = GrConvexPolyEffect::Create(edgeType, count, edges);
+ fp = GrConvexPolyEffect::Make(edgeType, count, edges);
} while (nullptr == fp);
return fp;
}
diff --git a/src/gpu/effects/GrConvexPolyEffect.h b/src/gpu/effects/GrConvexPolyEffect.h
index 316f1117bb..8fc76feb5b 100644
--- a/src/gpu/effects/GrConvexPolyEffect.h
+++ b/src/gpu/effects/GrConvexPolyEffect.h
@@ -38,12 +38,12 @@ public:
* 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 GrFragmentProcessor* Create(GrPrimitiveEdgeType edgeType, int n,
- const SkScalar edges[]) {
+ static sk_sp<GrFragmentProcessor> Make(GrPrimitiveEdgeType edgeType, int n,
+ const SkScalar edges[]) {
if (n <= 0 || n > kMaxEdges || kHairlineAA_GrProcessorEdgeType == edgeType) {
return nullptr;
}
- return new GrConvexPolyEffect(edgeType, n, edges);
+ return sk_sp<GrFragmentProcessor>(new GrConvexPolyEffect(edgeType, n, edges));
}
/**
@@ -51,13 +51,13 @@ public:
* inverse filled, or has too many edges, this will return nullptr. If offset is non-nullptr, then
* the path is translated by the vector.
*/
- static GrFragmentProcessor* Create(GrPrimitiveEdgeType, const SkPath&,
- const SkVector* offset = nullptr);
+ static sk_sp<GrFragmentProcessor> Make(GrPrimitiveEdgeType, const SkPath&,
+ const SkVector* offset = nullptr);
/**
* Creates an effect that fills inside the rect with AA edges..
*/
- static GrFragmentProcessor* Create(GrPrimitiveEdgeType, const SkRect&);
+ static sk_sp<GrFragmentProcessor> Make(GrPrimitiveEdgeType, const SkRect&);
virtual ~GrConvexPolyEffect();
diff --git a/src/gpu/effects/GrConvolutionEffect.cpp b/src/gpu/effects/GrConvolutionEffect.cpp
index 9567e4c221..2266c47eeb 100644
--- a/src/gpu/effects/GrConvolutionEffect.cpp
+++ b/src/gpu/effects/GrConvolutionEffect.cpp
@@ -213,7 +213,7 @@ bool GrConvolutionEffect::onIsEqual(const GrFragmentProcessor& sBase) const {
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrConvolutionEffect);
-const GrFragmentProcessor* GrConvolutionEffect::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> GrConvolutionEffect::TestCreate(GrProcessorTestData* d) {
int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx :
GrProcessorUnitTest::kAlphaTextureIdx;
Direction dir = d->fRandom->nextBool() ? kX_Direction : kY_Direction;
@@ -228,10 +228,10 @@ const GrFragmentProcessor* GrConvolutionEffect::TestCreate(GrProcessorTestData*
}
bool useBounds = d->fRandom->nextBool();
- return GrConvolutionEffect::Create(d->fTextures[texIdx],
- dir,
- radius,
- kernel,
- useBounds,
- bounds);
+ return GrConvolutionEffect::Make(d->fTextures[texIdx],
+ dir,
+ radius,
+ kernel,
+ useBounds,
+ bounds);
}
diff --git a/src/gpu/effects/GrConvolutionEffect.h b/src/gpu/effects/GrConvolutionEffect.h
index af580217d9..c353542d03 100644
--- a/src/gpu/effects/GrConvolutionEffect.h
+++ b/src/gpu/effects/GrConvolutionEffect.h
@@ -21,23 +21,25 @@ class GrConvolutionEffect : public Gr1DKernelEffect {
public:
/// Convolve with an arbitrary user-specified kernel
- static GrFragmentProcessor* Create(GrTexture* tex,
- Direction dir,
- int halfWidth,
- const float* kernel,
- bool useBounds,
- float bounds[2]) {
- return new GrConvolutionEffect(tex, dir, halfWidth, kernel, useBounds, bounds);
+ static sk_sp<GrFragmentProcessor> Make(GrTexture* tex,
+ Direction dir,
+ int halfWidth,
+ const float* kernel,
+ bool useBounds,
+ float bounds[2]) {
+ return sk_sp<GrFragmentProcessor>(
+ new GrConvolutionEffect(tex, dir, halfWidth, kernel, useBounds, bounds));
}
/// Convolve with a Gaussian kernel
- static GrFragmentProcessor* CreateGaussian(GrTexture* tex,
- Direction dir,
- int halfWidth,
- float gaussianSigma,
- bool useBounds,
- float bounds[2]) {
- return new GrConvolutionEffect(tex, dir, halfWidth, gaussianSigma, useBounds, bounds);
+ static sk_sp<GrFragmentProcessor> MakeGaussian(GrTexture* tex,
+ Direction dir,
+ int halfWidth,
+ float gaussianSigma,
+ bool useBounds,
+ float bounds[2]) {
+ return sk_sp<GrFragmentProcessor>(
+ new GrConvolutionEffect(tex, dir, halfWidth, gaussianSigma, useBounds, bounds));
}
virtual ~GrConvolutionEffect();
diff --git a/src/gpu/effects/GrCoverageSetOpXP.cpp b/src/gpu/effects/GrCoverageSetOpXP.cpp
index c0ba62f741..90657ea2b1 100644
--- a/src/gpu/effects/GrCoverageSetOpXP.cpp
+++ b/src/gpu/effects/GrCoverageSetOpXP.cpp
@@ -243,65 +243,65 @@ GrCoverageSetOpXPFactory::GrCoverageSetOpXPFactory(SkRegion::Op regionOp, bool i
this->initClassID<GrCoverageSetOpXPFactory>();
}
-GrXPFactory* GrCoverageSetOpXPFactory::Create(SkRegion::Op regionOp, bool invertCoverage) {
+sk_sp<GrXPFactory> GrCoverageSetOpXPFactory::Make(SkRegion::Op regionOp, bool invertCoverage) {
switch (regionOp) {
case SkRegion::kReplace_Op: {
if (invertCoverage) {
static GrCoverageSetOpXPFactory gReplaceCDXPFI(regionOp, invertCoverage);
- return SkRef(&gReplaceCDXPFI);
+ return sk_sp<GrXPFactory>(SkRef(&gReplaceCDXPFI));
} else {
static GrCoverageSetOpXPFactory gReplaceCDXPF(regionOp, invertCoverage);
- return SkRef(&gReplaceCDXPF);
+ return sk_sp<GrXPFactory>(SkRef(&gReplaceCDXPF));
}
break;
}
case SkRegion::kIntersect_Op: {
if (invertCoverage) {
static GrCoverageSetOpXPFactory gIntersectCDXPFI(regionOp, invertCoverage);
- return SkRef(&gIntersectCDXPFI);
+ return sk_sp<GrXPFactory>(SkRef(&gIntersectCDXPFI));
} else {
static GrCoverageSetOpXPFactory gIntersectCDXPF(regionOp, invertCoverage);
- return SkRef(&gIntersectCDXPF);
+ return sk_sp<GrXPFactory>(SkRef(&gIntersectCDXPF));
}
break;
}
case SkRegion::kUnion_Op: {
if (invertCoverage) {
static GrCoverageSetOpXPFactory gUnionCDXPFI(regionOp, invertCoverage);
- return SkRef(&gUnionCDXPFI);
+ return sk_sp<GrXPFactory>(SkRef(&gUnionCDXPFI));
} else {
static GrCoverageSetOpXPFactory gUnionCDXPF(regionOp, invertCoverage);
- return SkRef(&gUnionCDXPF);
+ return sk_sp<GrXPFactory>(SkRef(&gUnionCDXPF));
}
break;
}
case SkRegion::kXOR_Op: {
if (invertCoverage) {
static GrCoverageSetOpXPFactory gXORCDXPFI(regionOp, invertCoverage);
- return SkRef(&gXORCDXPFI);
+ return sk_sp<GrXPFactory>(SkRef(&gXORCDXPFI));
} else {
static GrCoverageSetOpXPFactory gXORCDXPF(regionOp, invertCoverage);
- return SkRef(&gXORCDXPF);
+ return sk_sp<GrXPFactory>(SkRef(&gXORCDXPF));
}
break;
}
case SkRegion::kDifference_Op: {
if (invertCoverage) {
static GrCoverageSetOpXPFactory gDifferenceCDXPFI(regionOp, invertCoverage);
- return SkRef(&gDifferenceCDXPFI);
+ return sk_sp<GrXPFactory>(SkRef(&gDifferenceCDXPFI));
} else {
static GrCoverageSetOpXPFactory gDifferenceCDXPF(regionOp, invertCoverage);
- return SkRef(&gDifferenceCDXPF);
+ return sk_sp<GrXPFactory>(SkRef(&gDifferenceCDXPF));
}
break;
}
case SkRegion::kReverseDifference_Op: {
if (invertCoverage) {
static GrCoverageSetOpXPFactory gRevDiffCDXPFI(regionOp, invertCoverage);
- return SkRef(&gRevDiffCDXPFI);
+ return sk_sp<GrXPFactory>(SkRef(&gRevDiffCDXPFI));
} else {
static GrCoverageSetOpXPFactory gRevDiffCDXPF(regionOp, invertCoverage);
- return SkRef(&gRevDiffCDXPF);
+ return sk_sp<GrXPFactory>(SkRef(&gRevDiffCDXPF));
}
break;
}
@@ -337,8 +337,8 @@ void GrCoverageSetOpXPFactory::getInvariantBlendedColor(const GrProcOptInfo& col
GR_DEFINE_XP_FACTORY_TEST(GrCoverageSetOpXPFactory);
-const GrXPFactory* GrCoverageSetOpXPFactory::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrXPFactory> GrCoverageSetOpXPFactory::TestCreate(GrProcessorTestData* d) {
SkRegion::Op regionOp = SkRegion::Op(d->fRandom->nextULessThan(SkRegion::kLastOp + 1));
bool invertCoverage = !d->fDrawContext->hasMixedSamples() && d->fRandom->nextBool();
- return GrCoverageSetOpXPFactory::Create(regionOp, invertCoverage);
+ return GrCoverageSetOpXPFactory::Make(regionOp, invertCoverage);
}
diff --git a/src/gpu/effects/GrCustomXfermode.cpp b/src/gpu/effects/GrCustomXfermode.cpp
index 50fe5cb9e2..1b94a6bee1 100644
--- a/src/gpu/effects/GrCustomXfermode.cpp
+++ b/src/gpu/effects/GrCustomXfermode.cpp
@@ -382,19 +382,19 @@ void CustomXPFactory::getInvariantBlendedColor(const GrProcOptInfo& colorPOI,
}
GR_DEFINE_XP_FACTORY_TEST(CustomXPFactory);
-const GrXPFactory* CustomXPFactory::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrXPFactory> CustomXPFactory::TestCreate(GrProcessorTestData* d) {
int mode = d->fRandom->nextRangeU(SkXfermode::kLastCoeffMode + 1,
SkXfermode::kLastSeparableMode);
- return new CustomXPFactory(static_cast<SkXfermode::Mode>(mode));
+ return sk_sp<GrXPFactory>(new CustomXPFactory(static_cast<SkXfermode::Mode>(mode)));
}
///////////////////////////////////////////////////////////////////////////////
-GrXPFactory* GrCustomXfermode::CreateXPFactory(SkXfermode::Mode mode) {
+sk_sp<GrXPFactory> GrCustomXfermode::MakeXPFactory(SkXfermode::Mode mode) {
if (!GrCustomXfermode::IsSupportedMode(mode)) {
return nullptr;
} else {
- return new CustomXPFactory(mode);
+ return sk_sp<GrXPFactory>(new CustomXPFactory(mode));
}
}
diff --git a/src/gpu/effects/GrDashingEffect.cpp b/src/gpu/effects/GrDashingEffect.cpp
index 8a7cb5edc4..ae375409cb 100644
--- a/src/gpu/effects/GrDashingEffect.cpp
+++ b/src/gpu/effects/GrDashingEffect.cpp
@@ -232,11 +232,11 @@ static void setup_dashed_rect_pos(const SkRect& rect, int idx, const SkMatrix& m
* Bounding geometry is rendered and the effect computes coverage based on the fragment's
* position relative to the dashed line.
*/
-static GrGeometryProcessor* create_dash_gp(GrColor,
- AAMode aaMode,
- DashCap cap,
- const SkMatrix& localMatrix,
- bool usesLocalCoords);
+static sk_sp<GrGeometryProcessor> make_dash_gp(GrColor,
+ AAMode aaMode,
+ DashCap cap,
+ const SkMatrix& localMatrix,
+ bool usesLocalCoords);
class DashBatch : public GrVertexBatch {
public:
@@ -331,10 +331,10 @@ private:
bool isRoundCap = SkPaint::kRound_Cap == cap;
DashCap capType = isRoundCap ? kRound_DashCap : kNonRound_DashCap;
- SkAutoTUnref<const GrGeometryProcessor> gp;
+ sk_sp<GrGeometryProcessor> gp;
if (this->fullDash()) {
- gp.reset(create_dash_gp(this->color(), this->aaMode(), capType, this->viewMatrix(),
- this->usesLocalCoords()));
+ gp = make_dash_gp(this->color(), this->aaMode(), capType, this->viewMatrix(),
+ this->usesLocalCoords());
} else {
// Set up the vertex data for the line and start/end dashes
using namespace GrDefaultGeoProcFactory;
@@ -343,7 +343,7 @@ private:
Coverage::kSolid_Type);
LocalCoords localCoords(this->usesLocalCoords() ? LocalCoords::kUsePosition_Type :
LocalCoords::kUnused_Type);
- gp.reset(CreateForDeviceSpace(color, coverage, localCoords, this->viewMatrix()));
+ gp = MakeForDeviceSpace(color, coverage, localCoords, this->viewMatrix());
}
if (!gp) {
@@ -622,7 +622,7 @@ private:
rectIndex++;
}
SkASSERT(0 == (curVIdx % 4) && (curVIdx / 4) == totalRectCount);
- helper.recordDraw(target, gp);
+ helper.recordDraw(target, gp.get());
}
bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override {
@@ -757,10 +757,10 @@ class DashingCircleEffect : public GrGeometryProcessor {
public:
typedef SkPathEffect::DashInfo DashInfo;
- static GrGeometryProcessor* Create(GrColor,
- AAMode aaMode,
- const SkMatrix& localMatrix,
- bool usesLocalCoords);
+ static sk_sp<GrGeometryProcessor> Make(GrColor,
+ AAMode aaMode,
+ const SkMatrix& localMatrix,
+ bool usesLocalCoords);
const char* name() const override { return "DashingCircleEffect"; }
@@ -919,11 +919,12 @@ void GLDashingCircleEffect::GenKey(const GrGeometryProcessor& gp,
//////////////////////////////////////////////////////////////////////////////
-GrGeometryProcessor* DashingCircleEffect::Create(GrColor color,
- AAMode aaMode,
- const SkMatrix& localMatrix,
- bool usesLocalCoords) {
- return new DashingCircleEffect(color, aaMode, localMatrix, usesLocalCoords);
+sk_sp<GrGeometryProcessor> DashingCircleEffect::Make(GrColor color,
+ AAMode aaMode,
+ const SkMatrix& localMatrix,
+ bool usesLocalCoords) {
+ return sk_sp<GrGeometryProcessor>(
+ new DashingCircleEffect(color, aaMode, localMatrix, usesLocalCoords));
}
void DashingCircleEffect::getGLSLProcessorKey(const GrGLSLCaps& caps,
@@ -952,11 +953,11 @@ DashingCircleEffect::DashingCircleEffect(GrColor color,
GR_DEFINE_GEOMETRY_PROCESSOR_TEST(DashingCircleEffect);
-const GrGeometryProcessor* DashingCircleEffect::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrGeometryProcessor> DashingCircleEffect::TestCreate(GrProcessorTestData* d) {
AAMode aaMode = static_cast<AAMode>(d->fRandom->nextULessThan(GrDashingEffect::kAAModeCnt));
- return DashingCircleEffect::Create(GrRandomColor(d->fRandom),
- aaMode, GrTest::TestMatrix(d->fRandom),
- d->fRandom->nextBool());
+ return DashingCircleEffect::Make(GrRandomColor(d->fRandom),
+ aaMode, GrTest::TestMatrix(d->fRandom),
+ d->fRandom->nextBool());
}
//////////////////////////////////////////////////////////////////////////////
@@ -976,10 +977,10 @@ class DashingLineEffect : public GrGeometryProcessor {
public:
typedef SkPathEffect::DashInfo DashInfo;
- static GrGeometryProcessor* Create(GrColor,
- AAMode aaMode,
- const SkMatrix& localMatrix,
- bool usesLocalCoords);
+ static sk_sp<GrGeometryProcessor> Make(GrColor,
+ AAMode aaMode,
+ const SkMatrix& localMatrix,
+ bool usesLocalCoords);
const char* name() const override { return "DashingEffect"; }
@@ -1151,11 +1152,12 @@ void GLDashingLineEffect::GenKey(const GrGeometryProcessor& gp,
//////////////////////////////////////////////////////////////////////////////
-GrGeometryProcessor* DashingLineEffect::Create(GrColor color,
- AAMode aaMode,
- const SkMatrix& localMatrix,
- bool usesLocalCoords) {
- return new DashingLineEffect(color, aaMode, localMatrix, usesLocalCoords);
+sk_sp<GrGeometryProcessor> DashingLineEffect::Make(GrColor color,
+ AAMode aaMode,
+ const SkMatrix& localMatrix,
+ bool usesLocalCoords) {
+ return sk_sp<GrGeometryProcessor>(
+ new DashingLineEffect(color, aaMode, localMatrix, usesLocalCoords));
}
void DashingLineEffect::getGLSLProcessorKey(const GrGLSLCaps& caps,
@@ -1183,20 +1185,20 @@ DashingLineEffect::DashingLineEffect(GrColor color,
GR_DEFINE_GEOMETRY_PROCESSOR_TEST(DashingLineEffect);
-const GrGeometryProcessor* DashingLineEffect::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrGeometryProcessor> DashingLineEffect::TestCreate(GrProcessorTestData* d) {
AAMode aaMode = static_cast<AAMode>(d->fRandom->nextULessThan(GrDashingEffect::kAAModeCnt));
- return DashingLineEffect::Create(GrRandomColor(d->fRandom),
- aaMode, GrTest::TestMatrix(d->fRandom),
- d->fRandom->nextBool());
+ return DashingLineEffect::Make(GrRandomColor(d->fRandom),
+ aaMode, GrTest::TestMatrix(d->fRandom),
+ d->fRandom->nextBool());
}
//////////////////////////////////////////////////////////////////////////////
-static GrGeometryProcessor* create_dash_gp(GrColor color,
- AAMode aaMode,
- DashCap cap,
- const SkMatrix& viewMatrix,
- bool usesLocalCoords) {
+static sk_sp<GrGeometryProcessor> make_dash_gp(GrColor color,
+ AAMode aaMode,
+ DashCap cap,
+ const SkMatrix& viewMatrix,
+ bool usesLocalCoords) {
SkMatrix invert;
if (usesLocalCoords && !viewMatrix.invert(&invert)) {
SkDebugf("Failed to invert\n");
@@ -1205,9 +1207,9 @@ static GrGeometryProcessor* create_dash_gp(GrColor color,
switch (cap) {
case kRound_DashCap:
- return DashingCircleEffect::Create(color, aaMode, invert, usesLocalCoords);
+ return DashingCircleEffect::Make(color, aaMode, invert, usesLocalCoords);
case kNonRound_DashCap:
- return DashingLineEffect::Create(color, aaMode, invert, usesLocalCoords);
+ return DashingLineEffect::Make(color, aaMode, invert, usesLocalCoords);
}
return nullptr;
}
diff --git a/src/gpu/effects/GrDisableColorXP.cpp b/src/gpu/effects/GrDisableColorXP.cpp
index 7d776e72ea..1ff8ad66a4 100644
--- a/src/gpu/effects/GrDisableColorXP.cpp
+++ b/src/gpu/effects/GrDisableColorXP.cpp
@@ -104,6 +104,6 @@ GrDisableColorXPFactory::onCreateXferProcessor(const GrCaps& caps,
GR_DEFINE_XP_FACTORY_TEST(GrDisableColorXPFactory);
-const GrXPFactory* GrDisableColorXPFactory::TestCreate(GrProcessorTestData*) {
- return GrDisableColorXPFactory::Create();
+sk_sp<GrXPFactory> GrDisableColorXPFactory::TestCreate(GrProcessorTestData*) {
+ return GrDisableColorXPFactory::Make();
}
diff --git a/src/gpu/effects/GrDisableColorXP.h b/src/gpu/effects/GrDisableColorXP.h
index 558495451d..4aed6b671e 100644
--- a/src/gpu/effects/GrDisableColorXP.h
+++ b/src/gpu/effects/GrDisableColorXP.h
@@ -10,12 +10,13 @@
#include "GrTypes.h"
#include "GrXferProcessor.h"
+#include "SkRefCnt.h"
class GrProcOptInfo;
class GrDisableColorXPFactory : public GrXPFactory {
public:
- static GrXPFactory* Create() { return new GrDisableColorXPFactory; }
+ static sk_sp<GrXPFactory> Make() { return sk_sp<GrXPFactory>(new GrDisableColorXPFactory); }
void getInvariantBlendedColor(const GrProcOptInfo& colorPOI,
GrXPFactory::InvariantBlendedColor* blendedColor) const override {
diff --git a/src/gpu/effects/GrDistanceFieldGeoProc.cpp b/src/gpu/effects/GrDistanceFieldGeoProc.cpp
index e87021e978..f43a1e8994 100644
--- a/src/gpu/effects/GrDistanceFieldGeoProc.cpp
+++ b/src/gpu/effects/GrDistanceFieldGeoProc.cpp
@@ -260,7 +260,7 @@ GrGLSLPrimitiveProcessor* GrDistanceFieldA8TextGeoProc::createGLSLInstance(const
GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrDistanceFieldA8TextGeoProc);
-const GrGeometryProcessor* GrDistanceFieldA8TextGeoProc::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrGeometryProcessor> GrDistanceFieldA8TextGeoProc::TestCreate(GrProcessorTestData* d) {
int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx :
GrProcessorUnitTest::kAlphaTextureIdx;
static const SkShader::TileMode kTileModes[] = {
@@ -281,14 +281,14 @@ const GrGeometryProcessor* GrDistanceFieldA8TextGeoProc::TestCreate(GrProcessorT
flags |= d->fRandom->nextBool() ? kScaleOnly_DistanceFieldEffectFlag : 0;
}
- return GrDistanceFieldA8TextGeoProc::Create(GrRandomColor(d->fRandom),
- GrTest::TestMatrix(d->fRandom),
- d->fTextures[texIdx], params,
+ return GrDistanceFieldA8TextGeoProc::Make(GrRandomColor(d->fRandom),
+ GrTest::TestMatrix(d->fRandom),
+ d->fTextures[texIdx], params,
#ifdef SK_GAMMA_APPLY_TO_A8
- d->fRandom->nextF(),
+ d->fRandom->nextF(),
#endif
- flags,
- d->fRandom->nextBool());
+ flags,
+ d->fRandom->nextBool());
}
///////////////////////////////////////////////////////////////////////////////
@@ -497,7 +497,7 @@ GrGLSLPrimitiveProcessor* GrDistanceFieldPathGeoProc::createGLSLInstance(const G
GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrDistanceFieldPathGeoProc);
-const GrGeometryProcessor* GrDistanceFieldPathGeoProc::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrGeometryProcessor> GrDistanceFieldPathGeoProc::TestCreate(GrProcessorTestData* d) {
int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx
: GrProcessorUnitTest::kAlphaTextureIdx;
static const SkShader::TileMode kTileModes[] = {
@@ -518,12 +518,12 @@ const GrGeometryProcessor* GrDistanceFieldPathGeoProc::TestCreate(GrProcessorTes
flags |= d->fRandom->nextBool() ? kScaleOnly_DistanceFieldEffectFlag : 0;
}
- return GrDistanceFieldPathGeoProc::Create(GrRandomColor(d->fRandom),
- GrTest::TestMatrix(d->fRandom),
- d->fTextures[texIdx],
- params,
- flags,
- d->fRandom->nextBool());
+ return GrDistanceFieldPathGeoProc::Make(GrRandomColor(d->fRandom),
+ GrTest::TestMatrix(d->fRandom),
+ d->fTextures[texIdx],
+ params,
+ flags,
+ d->fRandom->nextBool());
}
///////////////////////////////////////////////////////////////////////////////
@@ -794,7 +794,7 @@ GrGLSLPrimitiveProcessor* GrDistanceFieldLCDTextGeoProc::createGLSLInstance(cons
GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrDistanceFieldLCDTextGeoProc);
-const GrGeometryProcessor* GrDistanceFieldLCDTextGeoProc::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrGeometryProcessor> GrDistanceFieldLCDTextGeoProc::TestCreate(GrProcessorTestData* d) {
int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx :
GrProcessorUnitTest::kAlphaTextureIdx;
static const SkShader::TileMode kTileModes[] = {
@@ -815,10 +815,10 @@ const GrGeometryProcessor* GrDistanceFieldLCDTextGeoProc::TestCreate(GrProcessor
flags |= d->fRandom->nextBool() ? kScaleOnly_DistanceFieldEffectFlag : 0;
}
flags |= d->fRandom->nextBool() ? kBGR_DistanceFieldEffectFlag : 0;
- return GrDistanceFieldLCDTextGeoProc::Create(GrRandomColor(d->fRandom),
- GrTest::TestMatrix(d->fRandom),
- d->fTextures[texIdx], params,
- wa,
- flags,
- d->fRandom->nextBool());
+ return GrDistanceFieldLCDTextGeoProc::Make(GrRandomColor(d->fRandom),
+ GrTest::TestMatrix(d->fRandom),
+ d->fTextures[texIdx], params,
+ wa,
+ flags,
+ d->fRandom->nextBool());
}
diff --git a/src/gpu/effects/GrDistanceFieldGeoProc.h b/src/gpu/effects/GrDistanceFieldGeoProc.h
index 406c352409..0f6d8c1b3f 100644
--- a/src/gpu/effects/GrDistanceFieldGeoProc.h
+++ b/src/gpu/effects/GrDistanceFieldGeoProc.h
@@ -49,18 +49,20 @@ enum GrDistanceFieldEffectFlags {
class GrDistanceFieldA8TextGeoProc : public GrGeometryProcessor {
public:
#ifdef SK_GAMMA_APPLY_TO_A8
- static GrGeometryProcessor* Create(GrColor color, const SkMatrix& viewMatrix,
- GrTexture* tex, const GrTextureParams& params,
- float lum, uint32_t flags, bool usesLocalCoords) {
- return new GrDistanceFieldA8TextGeoProc(color, viewMatrix, tex, params, lum, flags,
- usesLocalCoords);
+ static sk_sp<GrGeometryProcessor> Make(GrColor color, const SkMatrix& viewMatrix,
+ GrTexture* tex, const GrTextureParams& params,
+ float lum, uint32_t flags, bool usesLocalCoords) {
+ return sk_sp<GrGeometryProcessor>(
+ new GrDistanceFieldA8TextGeoProc(color, viewMatrix, tex, params, lum, flags,
+ usesLocalCoords));
}
#else
- static GrGeometryProcessor* Create(GrColor color, const SkMatrix& viewMatrix,
- GrTexture* tex, const GrTextureParams& params,
- uint32_t flags, bool usesLocalCoords) {
- return new GrDistanceFieldA8TextGeoProc(color, viewMatrix, tex, params, flags,
- usesLocalCoords);
+ static sk_sp<GrGeometryProcessor> Make(GrColor color, const SkMatrix& viewMatrix,
+ GrTexture* tex, const GrTextureParams& params,
+ uint32_t flags, bool usesLocalCoords) {
+ return sk_sp<GrGeometryProcessor>(
+ new GrDistanceFieldA8TextGeoProc(color, viewMatrix, tex, params, flags,
+ usesLocalCoords));
}
#endif
@@ -118,11 +120,11 @@ private:
*/
class GrDistanceFieldPathGeoProc : public GrGeometryProcessor {
public:
- static GrGeometryProcessor* Create(GrColor color, const SkMatrix& viewMatrix, GrTexture* tex,
- const GrTextureParams& params,
- uint32_t flags, bool usesLocalCoords) {
- return new GrDistanceFieldPathGeoProc(color, viewMatrix, tex, params, flags,
- usesLocalCoords);
+ static sk_sp<GrGeometryProcessor> Make(GrColor color, const SkMatrix& viewMatrix,
+ GrTexture* tex, const GrTextureParams& params,
+ uint32_t flags, bool usesLocalCoords) {
+ return sk_sp<GrGeometryProcessor>(
+ new GrDistanceFieldPathGeoProc(color, viewMatrix, tex, params, flags, usesLocalCoords));
}
virtual ~GrDistanceFieldPathGeoProc() {}
@@ -184,12 +186,13 @@ public:
}
};
- static GrGeometryProcessor* Create(GrColor color, const SkMatrix& viewMatrix,
- GrTexture* tex, const GrTextureParams& params,
- DistanceAdjust distanceAdjust, uint32_t flags,
- bool usesLocalCoords) {
- return new GrDistanceFieldLCDTextGeoProc(color, viewMatrix, tex, params, distanceAdjust,
- flags, usesLocalCoords);
+ static sk_sp<GrGeometryProcessor> Make(GrColor color, const SkMatrix& viewMatrix,
+ GrTexture* tex, const GrTextureParams& params,
+ DistanceAdjust distanceAdjust, uint32_t flags,
+ bool usesLocalCoords) {
+ return sk_sp<GrGeometryProcessor>(
+ new GrDistanceFieldLCDTextGeoProc(color, viewMatrix, tex, params, distanceAdjust,
+ flags, usesLocalCoords));
}
virtual ~GrDistanceFieldLCDTextGeoProc() {}
diff --git a/src/gpu/effects/GrDitherEffect.cpp b/src/gpu/effects/GrDitherEffect.cpp
index 39d4063a58..abce5ca6c7 100644
--- a/src/gpu/effects/GrDitherEffect.cpp
+++ b/src/gpu/effects/GrDitherEffect.cpp
@@ -16,8 +16,8 @@
class DitherEffect : public GrFragmentProcessor {
public:
- static GrFragmentProcessor* Create() {
- return new DitherEffect;
+ static sk_sp<GrFragmentProcessor> Make() {
+ return sk_sp<GrFragmentProcessor>(new DitherEffect);
}
virtual ~DitherEffect() {};
@@ -52,8 +52,8 @@ void DitherEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(DitherEffect);
-const GrFragmentProcessor* DitherEffect::TestCreate(GrProcessorTestData*) {
- return DitherEffect::Create();
+sk_sp<GrFragmentProcessor> DitherEffect::TestCreate(GrProcessorTestData*) {
+ return DitherEffect::Make();
}
//////////////////////////////////////////////////////////////////////////////
@@ -95,4 +95,4 @@ GrGLSLFragmentProcessor* DitherEffect::onCreateGLSLInstance() const {
return new GLDitherEffect;
}
-GrFragmentProcessor* GrDitherEffect::Create() { return DitherEffect::Create(); }
+sk_sp<GrFragmentProcessor> GrDitherEffect::Make() { return DitherEffect::Make(); }
diff --git a/src/gpu/effects/GrDitherEffect.h b/src/gpu/effects/GrDitherEffect.h
index 64c85f7bf4..b92723d339 100644
--- a/src/gpu/effects/GrDitherEffect.h
+++ b/src/gpu/effects/GrDitherEffect.h
@@ -10,6 +10,7 @@
#include "GrTypes.h"
#include "GrTypesPriv.h"
+#include "SkRefCnt.h"
class GrFragmentProcessor;
@@ -17,7 +18,7 @@ namespace GrDitherEffect {
/**
* Creates an effect that dithers the resulting color to an RGBA8 framebuffer
*/
- GrFragmentProcessor* Create();
+ sk_sp<GrFragmentProcessor> Make();
};
#endif
diff --git a/src/gpu/effects/GrGammaEffect.cpp b/src/gpu/effects/GrGammaEffect.cpp
index 71d8c91423..63ffc32424 100644
--- a/src/gpu/effects/GrGammaEffect.cpp
+++ b/src/gpu/effects/GrGammaEffect.cpp
@@ -116,11 +116,11 @@ void GrGammaEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrGammaEffect);
-const GrFragmentProcessor* GrGammaEffect::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> GrGammaEffect::TestCreate(GrProcessorTestData* d) {
// We want to be sure and test sRGB sometimes
Mode testMode = static_cast<Mode>(d->fRandom->nextRangeU(0, 2));
SkScalar gamma = d->fRandom->nextRangeScalar(0.5f, 2.0f);
- return new GrGammaEffect(testMode, gamma);
+ return sk_sp<GrFragmentProcessor>(new GrGammaEffect(testMode, gamma));
}
///////////////////////////////////////////////////////////////////////////////
@@ -134,15 +134,15 @@ GrGLSLFragmentProcessor* GrGammaEffect::onCreateGLSLInstance() const {
return new GrGLGammaEffect();
}
-const GrFragmentProcessor* GrGammaEffect::Create(SkScalar gamma) {
+sk_sp<GrFragmentProcessor> GrGammaEffect::Make(SkScalar gamma) {
// TODO: Once our public-facing API for specifying gamma curves settles down, expose this,
// and allow clients to explicitly request sRGB, rather than inferring from the exponent.
// Note that AdobeRGB (for example) is speficied as x^2.2, not the Rec.709 curves.
if (SkScalarNearlyEqual(gamma, 2.2f)) {
- return new GrGammaEffect(Mode::kSRGBToLinear, 2.2f);
+ return sk_sp<GrFragmentProcessor>(new GrGammaEffect(Mode::kSRGBToLinear, 2.2f));
} else if (SkScalarNearlyEqual(gamma, 1.0f / 2.2f)) {
- return new GrGammaEffect(Mode::kLinearToSRGB, 1.0f / 2.2f);
+ return sk_sp<GrFragmentProcessor>(new GrGammaEffect(Mode::kLinearToSRGB, 1.0f / 2.2f));
} else {
- return new GrGammaEffect(Mode::kExponential, gamma);
+ return sk_sp<GrFragmentProcessor>(new GrGammaEffect(Mode::kExponential, gamma));
}
}
diff --git a/src/gpu/effects/GrGammaEffect.h b/src/gpu/effects/GrGammaEffect.h
index 2e53b09278..3f84ac91e0 100644
--- a/src/gpu/effects/GrGammaEffect.h
+++ b/src/gpu/effects/GrGammaEffect.h
@@ -21,7 +21,7 @@ public:
/**
* Creates an effect that applies a gamma curve.
*/
- static const GrFragmentProcessor* Create(SkScalar gamma);
+ static sk_sp<GrFragmentProcessor> Make(SkScalar gamma);
const char* name() const override { return "Gamma"; }
diff --git a/src/gpu/effects/GrMatrixConvolutionEffect.cpp b/src/gpu/effects/GrMatrixConvolutionEffect.cpp
index 60f518ba24..5422755c2e 100644
--- a/src/gpu/effects/GrMatrixConvolutionEffect.cpp
+++ b/src/gpu/effects/GrMatrixConvolutionEffect.cpp
@@ -191,17 +191,17 @@ bool GrMatrixConvolutionEffect::onIsEqual(const GrFragmentProcessor& sBase) cons
}
// Static function to create a 2D convolution
-GrFragmentProcessor*
-GrMatrixConvolutionEffect::CreateGaussian(GrTexture* texture,
- const SkIRect& bounds,
- const SkISize& kernelSize,
- SkScalar gain,
- SkScalar bias,
- const SkIPoint& kernelOffset,
- GrTextureDomain::Mode tileMode,
- bool convolveAlpha,
- SkScalar sigmaX,
- SkScalar sigmaY) {
+sk_sp<GrFragmentProcessor>
+GrMatrixConvolutionEffect::MakeGaussian(GrTexture* texture,
+ 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];
int width = kernelSize.width();
int height = kernelSize.height();
@@ -228,13 +228,14 @@ GrMatrixConvolutionEffect::CreateGaussian(GrTexture* texture,
for (int i = 0; i < width * height; ++i) {
kernel[i] *= scale;
}
- return new GrMatrixConvolutionEffect(texture, bounds, kernelSize, kernel, gain, bias,
- kernelOffset, tileMode, convolveAlpha);
+ return sk_sp<GrFragmentProcessor>(
+ new GrMatrixConvolutionEffect(texture, bounds, kernelSize, kernel, gain, bias,
+ kernelOffset, tileMode, convolveAlpha));
}
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrMatrixConvolutionEffect);
-const GrFragmentProcessor* GrMatrixConvolutionEffect::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> GrMatrixConvolutionEffect::TestCreate(GrProcessorTestData* d) {
int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx :
GrProcessorUnitTest::kAlphaTextureIdx;
int width = d->fRandom->nextRangeU(1, MAX_KERNEL_SIZE);
@@ -255,13 +256,13 @@ const GrFragmentProcessor* GrMatrixConvolutionEffect::TestCreate(GrProcessorTest
GrTextureDomain::Mode tileMode =
static_cast<GrTextureDomain::Mode>(d->fRandom->nextRangeU(0, 2));
bool convolveAlpha = d->fRandom->nextBool();
- return GrMatrixConvolutionEffect::Create(d->fTextures[texIdx],
- bounds,
- kernelSize,
- kernel.get(),
- gain,
- bias,
- kernelOffset,
- tileMode,
- convolveAlpha);
+ return GrMatrixConvolutionEffect::Make(d->fTextures[texIdx],
+ bounds,
+ kernelSize,
+ kernel.get(),
+ gain,
+ bias,
+ kernelOffset,
+ tileMode,
+ convolveAlpha);
}
diff --git a/src/gpu/effects/GrMatrixConvolutionEffect.h b/src/gpu/effects/GrMatrixConvolutionEffect.h
index 066da65681..b8df437681 100644
--- a/src/gpu/effects/GrMatrixConvolutionEffect.h
+++ b/src/gpu/effects/GrMatrixConvolutionEffect.h
@@ -18,29 +18,30 @@
class GrMatrixConvolutionEffect : public GrSingleTextureEffect {
public:
- static GrFragmentProcessor* Create(GrTexture* texture,
- const SkIRect& bounds,
- const SkISize& kernelSize,
- const SkScalar* kernel,
- SkScalar gain,
- SkScalar bias,
- const SkIPoint& kernelOffset,
- GrTextureDomain::Mode tileMode,
- bool convolveAlpha) {
- return new GrMatrixConvolutionEffect(texture, bounds, kernelSize, kernel, gain, bias,
- kernelOffset, tileMode, convolveAlpha);
+ static sk_sp<GrFragmentProcessor> Make(GrTexture* texture,
+ 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(texture, bounds, kernelSize, kernel, gain, bias,
+ kernelOffset, tileMode, convolveAlpha));
}
- static GrFragmentProcessor* CreateGaussian(GrTexture* texture,
- const SkIRect& bounds,
- const SkISize& kernelSize,
- SkScalar gain,
- SkScalar bias,
- const SkIPoint& kernelOffset,
- GrTextureDomain::Mode tileMode,
- bool convolveAlpha,
- SkScalar sigmaX,
- SkScalar sigmaY);
+ static sk_sp<GrFragmentProcessor> MakeGaussian(GrTexture* texture,
+ 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; }
diff --git a/src/gpu/effects/GrOvalEffect.cpp b/src/gpu/effects/GrOvalEffect.cpp
index 3e6287bbd2..a288537d50 100644
--- a/src/gpu/effects/GrOvalEffect.cpp
+++ b/src/gpu/effects/GrOvalEffect.cpp
@@ -19,7 +19,8 @@
class CircleEffect : public GrFragmentProcessor {
public:
- static GrFragmentProcessor* Create(GrPrimitiveEdgeType, const SkPoint& center, SkScalar radius);
+ static sk_sp<GrFragmentProcessor> Make(GrPrimitiveEdgeType, const SkPoint& center,
+ SkScalar radius);
virtual ~CircleEffect() {};
@@ -50,10 +51,10 @@ private:
typedef GrFragmentProcessor INHERITED;
};
-GrFragmentProcessor* CircleEffect::Create(GrPrimitiveEdgeType edgeType, const SkPoint& center,
- SkScalar radius) {
+sk_sp<GrFragmentProcessor> CircleEffect::Make(GrPrimitiveEdgeType edgeType, const SkPoint& center,
+ SkScalar radius) {
SkASSERT(radius >= 0);
- return new CircleEffect(edgeType, center, radius);
+ return sk_sp<GrFragmentProcessor>(new CircleEffect(edgeType, center, radius));
}
void CircleEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
@@ -77,7 +78,7 @@ bool CircleEffect::onIsEqual(const GrFragmentProcessor& other) const {
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(CircleEffect);
-const GrFragmentProcessor* CircleEffect::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> CircleEffect::TestCreate(GrProcessorTestData* d) {
SkPoint center;
center.fX = d->fRandom->nextRangeScalar(0.f, 1000.f);
center.fY = d->fRandom->nextRangeScalar(0.f, 1000.f);
@@ -86,7 +87,7 @@ const GrFragmentProcessor* CircleEffect::TestCreate(GrProcessorTestData* d) {
do {
et = (GrPrimitiveEdgeType)d->fRandom->nextULessThan(kGrProcessorEdgeTypeCnt);
} while (kHairlineAA_GrProcessorEdgeType == et);
- return CircleEffect::Create(et, center, radius);
+ return CircleEffect::Make(et, center, radius);
}
//////////////////////////////////////////////////////////////////////////////
@@ -183,8 +184,8 @@ GrGLSLFragmentProcessor* CircleEffect::onCreateGLSLInstance() const {
class EllipseEffect : public GrFragmentProcessor {
public:
- static GrFragmentProcessor* Create(GrPrimitiveEdgeType, const SkPoint& center, SkScalar rx,
- SkScalar ry);
+ static sk_sp<GrFragmentProcessor> Make(GrPrimitiveEdgeType, const SkPoint& center,
+ SkScalar rx, SkScalar ry);
virtual ~EllipseEffect() {};
@@ -215,12 +216,12 @@ private:
typedef GrFragmentProcessor INHERITED;
};
-GrFragmentProcessor* EllipseEffect::Create(GrPrimitiveEdgeType edgeType,
- const SkPoint& center,
- SkScalar rx,
- SkScalar ry) {
+sk_sp<GrFragmentProcessor> EllipseEffect::Make(GrPrimitiveEdgeType edgeType,
+ const SkPoint& center,
+ SkScalar rx,
+ SkScalar ry) {
SkASSERT(rx >= 0 && ry >= 0);
- return new EllipseEffect(edgeType, center, rx, ry);
+ return sk_sp<GrFragmentProcessor>(new EllipseEffect(edgeType, center, rx, ry));
}
void EllipseEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
@@ -244,7 +245,7 @@ bool EllipseEffect::onIsEqual(const GrFragmentProcessor& other) const {
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(EllipseEffect);
-const GrFragmentProcessor* EllipseEffect::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> EllipseEffect::TestCreate(GrProcessorTestData* d) {
SkPoint center;
center.fX = d->fRandom->nextRangeScalar(0.f, 1000.f);
center.fY = d->fRandom->nextRangeScalar(0.f, 1000.f);
@@ -254,7 +255,7 @@ const GrFragmentProcessor* EllipseEffect::TestCreate(GrProcessorTestData* d) {
do {
et = (GrPrimitiveEdgeType)d->fRandom->nextULessThan(kGrProcessorEdgeTypeCnt);
} while (kHairlineAA_GrProcessorEdgeType == et);
- return EllipseEffect::Create(et, center, rx, ry);
+ return EllipseEffect::Make(et, center, rx, ry);
}
//////////////////////////////////////////////////////////////////////////////
@@ -391,7 +392,7 @@ GrGLSLFragmentProcessor* EllipseEffect::onCreateGLSLInstance() const {
//////////////////////////////////////////////////////////////////////////////
-GrFragmentProcessor* GrOvalEffect::Create(GrPrimitiveEdgeType edgeType, const SkRect& oval) {
+sk_sp<GrFragmentProcessor> GrOvalEffect::Make(GrPrimitiveEdgeType edgeType, const SkRect& oval) {
if (kHairlineAA_GrProcessorEdgeType == edgeType) {
return nullptr;
}
@@ -399,11 +400,11 @@ GrFragmentProcessor* GrOvalEffect::Create(GrPrimitiveEdgeType edgeType, const Sk
SkScalar h = oval.height();
if (SkScalarNearlyEqual(w, h)) {
w /= 2;
- return CircleEffect::Create(edgeType, SkPoint::Make(oval.fLeft + w, oval.fTop + w), w);
+ return CircleEffect::Make(edgeType, SkPoint::Make(oval.fLeft + w, oval.fTop + w), w);
} else {
w /= 2;
h /= 2;
- return EllipseEffect::Create(edgeType, SkPoint::Make(oval.fLeft + w, oval.fTop + h), w, h);
+ return EllipseEffect::Make(edgeType, SkPoint::Make(oval.fLeft + w, oval.fTop + h), w, h);
}
return nullptr;
diff --git a/src/gpu/effects/GrOvalEffect.h b/src/gpu/effects/GrOvalEffect.h
index 8f85365731..3ff241a65d 100644
--- a/src/gpu/effects/GrOvalEffect.h
+++ b/src/gpu/effects/GrOvalEffect.h
@@ -10,6 +10,7 @@
#include "GrTypes.h"
#include "GrTypesPriv.h"
+#include "SkRefCnt.h"
class GrFragmentProcessor;
struct SkRect;
@@ -18,7 +19,7 @@ namespace GrOvalEffect {
/**
* Creates an effect that performs clipping against an oval.
*/
- GrFragmentProcessor* Create(GrPrimitiveEdgeType, const SkRect&);
+ sk_sp<GrFragmentProcessor> Make(GrPrimitiveEdgeType, const SkRect&);
};
#endif
diff --git a/src/gpu/effects/GrPorterDuffXferProcessor.cpp b/src/gpu/effects/GrPorterDuffXferProcessor.cpp
index 8168de6a5d..9aae0262be 100644
--- a/src/gpu/effects/GrPorterDuffXferProcessor.cpp
+++ b/src/gpu/effects/GrPorterDuffXferProcessor.cpp
@@ -704,7 +704,7 @@ GrPorterDuffXPFactory::GrPorterDuffXPFactory(SkXfermode::Mode xfermode)
this->initClassID<GrPorterDuffXPFactory>();
}
-GrXPFactory* GrPorterDuffXPFactory::Create(SkXfermode::Mode xfermode) {
+sk_sp<GrXPFactory> GrPorterDuffXPFactory::Make(SkXfermode::Mode xfermode) {
static GrPorterDuffXPFactory gClearPDXPF(SkXfermode::kClear_Mode);
static GrPorterDuffXPFactory gSrcPDXPF(SkXfermode::kSrc_Mode);
static GrPorterDuffXPFactory gDstPDXPF(SkXfermode::kDst_Mode);
@@ -731,7 +731,7 @@ GrXPFactory* GrPorterDuffXPFactory::Create(SkXfermode::Mode xfermode) {
if (xfermode < 0 || xfermode > SkXfermode::kLastCoeffMode) {
return nullptr;
}
- return SkRef(gFactories[xfermode]);
+ return sk_sp<GrXPFactory>(SkRef(gFactories[xfermode]));
}
GrXferProcessor*
@@ -826,9 +826,9 @@ bool GrPorterDuffXPFactory::onWillReadDstColor(const GrCaps& caps,
GR_DEFINE_XP_FACTORY_TEST(GrPorterDuffXPFactory);
-const GrXPFactory* GrPorterDuffXPFactory::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrXPFactory> GrPorterDuffXPFactory::TestCreate(GrProcessorTestData* d) {
SkXfermode::Mode mode = SkXfermode::Mode(d->fRandom->nextULessThan(SkXfermode::kLastCoeffMode));
- return GrPorterDuffXPFactory::Create(mode);
+ return GrPorterDuffXPFactory::Make(mode);
}
void GrPorterDuffXPFactory::TestGetXPOutputTypes(const GrXferProcessor* xp,
diff --git a/src/gpu/effects/GrRRectEffect.cpp b/src/gpu/effects/GrRRectEffect.cpp
index d1d811da90..14d03dd9ed 100644
--- a/src/gpu/effects/GrRRectEffect.cpp
+++ b/src/gpu/effects/GrRRectEffect.cpp
@@ -45,8 +45,8 @@ public:
// The flags are used to indicate which corners are circluar (unflagged corners are assumed to
// be square).
- static GrFragmentProcessor* Create(GrPrimitiveEdgeType, uint32_t circularCornerFlags,
- const SkRRect&);
+ static sk_sp<GrFragmentProcessor> Make(GrPrimitiveEdgeType, uint32_t circularCornerFlags,
+ const SkRRect&);
virtual ~CircularRRectEffect() {};
@@ -78,13 +78,14 @@ private:
typedef GrFragmentProcessor INHERITED;
};
-GrFragmentProcessor* CircularRRectEffect::Create(GrPrimitiveEdgeType edgeType,
- uint32_t circularCornerFlags,
- const SkRRect& rrect) {
+sk_sp<GrFragmentProcessor> CircularRRectEffect::Make(GrPrimitiveEdgeType edgeType,
+ uint32_t circularCornerFlags,
+ const SkRRect& rrect) {
if (kFillAA_GrProcessorEdgeType != edgeType && kInverseFillAA_GrProcessorEdgeType != edgeType) {
return nullptr;
}
- return new CircularRRectEffect(edgeType, circularCornerFlags, rrect);
+ return sk_sp<GrFragmentProcessor>(
+ new CircularRRectEffect(edgeType, circularCornerFlags, rrect));
}
void CircularRRectEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
@@ -110,17 +111,17 @@ bool CircularRRectEffect::onIsEqual(const GrFragmentProcessor& other) const {
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(CircularRRectEffect);
-const GrFragmentProcessor* CircularRRectEffect::TestCreate(GrProcessorTestData* d) {
+sk_sp<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);
- GrFragmentProcessor* fp;
+ sk_sp<GrFragmentProcessor> fp;
do {
GrPrimitiveEdgeType et =
(GrPrimitiveEdgeType)d->fRandom->nextULessThan(kGrProcessorEdgeTypeCnt);
- fp = GrRRectEffect::Create(et, rrect);
+ fp = GrRRectEffect::Make(et, rrect);
} while (nullptr == fp);
return fp;
}
@@ -387,7 +388,7 @@ GrGLSLFragmentProcessor* CircularRRectEffect::onCreateGLSLInstance() const {
class EllipticalRRectEffect : public GrFragmentProcessor {
public:
- static GrFragmentProcessor* Create(GrPrimitiveEdgeType, const SkRRect&);
+ static sk_sp<GrFragmentProcessor> Make(GrPrimitiveEdgeType, const SkRRect&);
virtual ~EllipticalRRectEffect() {};
@@ -416,12 +417,12 @@ private:
typedef GrFragmentProcessor INHERITED;
};
-GrFragmentProcessor*
-EllipticalRRectEffect::Create(GrPrimitiveEdgeType edgeType, const SkRRect& rrect) {
+sk_sp<GrFragmentProcessor>
+EllipticalRRectEffect::Make(GrPrimitiveEdgeType edgeType, const SkRRect& rrect) {
if (kFillAA_GrProcessorEdgeType != edgeType && kInverseFillAA_GrProcessorEdgeType != edgeType) {
return nullptr;
}
- return new EllipticalRRectEffect(edgeType, rrect);
+ return sk_sp<GrFragmentProcessor>(new EllipticalRRectEffect(edgeType, rrect));
}
void EllipticalRRectEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
@@ -444,7 +445,7 @@ bool EllipticalRRectEffect::onIsEqual(const GrFragmentProcessor& other) const {
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(EllipticalRRectEffect);
-const GrFragmentProcessor* EllipticalRRectEffect::TestCreate(GrProcessorTestData* d) {
+sk_sp<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];
@@ -471,11 +472,11 @@ const GrFragmentProcessor* EllipticalRRectEffect::TestCreate(GrProcessorTestData
rrect.setRectXY(SkRect::MakeWH(w, h), r[SkRRect::kUpperLeft_Corner].fX,
r[SkRRect::kUpperLeft_Corner].fY);
}
- GrFragmentProcessor* fp;
+ sk_sp<GrFragmentProcessor> fp;
do {
GrPrimitiveEdgeType et =
(GrPrimitiveEdgeType)d->fRandom->nextULessThan(kGrProcessorEdgeTypeCnt);
- fp = GrRRectEffect::Create(et, rrect);
+ fp = GrRRectEffect::Make(et, rrect);
} while (nullptr == fp);
return fp;
}
@@ -680,26 +681,26 @@ GrGLSLFragmentProcessor* EllipticalRRectEffect::onCreateGLSLInstance() const {
//////////////////////////////////////////////////////////////////////////////
-GrFragmentProcessor* GrRRectEffect::Create(GrPrimitiveEdgeType edgeType, const SkRRect& rrect) {
+sk_sp<GrFragmentProcessor> GrRRectEffect::Make(GrPrimitiveEdgeType edgeType, const SkRRect& rrect) {
if (rrect.isRect()) {
- return GrConvexPolyEffect::Create(edgeType, rrect.getBounds());
+ return GrConvexPolyEffect::Make(edgeType, rrect.getBounds());
}
if (rrect.isOval()) {
- return GrOvalEffect::Create(edgeType, rrect.getBounds());
+ return GrOvalEffect::Make(edgeType, rrect.getBounds());
}
if (rrect.isSimple()) {
if (rrect.getSimpleRadii().fX < kRadiusMin || rrect.getSimpleRadii().fY < kRadiusMin) {
// In this case the corners are extremely close to rectangular and we collapse the
// clip to a rectangular clip.
- return GrConvexPolyEffect::Create(edgeType, rrect.getBounds());
+ return GrConvexPolyEffect::Make(edgeType, rrect.getBounds());
}
if (rrect.getSimpleRadii().fX == rrect.getSimpleRadii().fY) {
- return CircularRRectEffect::Create(edgeType, CircularRRectEffect::kAll_CornerFlags,
+ return CircularRRectEffect::Make(edgeType, CircularRRectEffect::kAll_CornerFlags,
rrect);
} else {
- return EllipticalRRectEffect::Create(edgeType, rrect);
+ return EllipticalRRectEffect::Make(edgeType, rrect);
}
}
@@ -755,10 +756,10 @@ GrFragmentProcessor* GrRRectEffect::Create(GrPrimitiveEdgeType edgeType, const S
if (squashedRadii) {
rr.writable()->setRectRadii(rrect.getBounds(), radii);
}
- return CircularRRectEffect::Create(edgeType, cornerFlags, *rr);
+ return CircularRRectEffect::Make(edgeType, cornerFlags, *rr);
}
case CircularRRectEffect::kNone_CornerFlags:
- return GrConvexPolyEffect::Create(edgeType, rrect.getBounds());
+ return GrConvexPolyEffect::Make(edgeType, rrect.getBounds());
default: {
if (squashedRadii) {
// If we got here then we squashed some but not all the radii to zero. (If all
@@ -767,7 +768,7 @@ GrFragmentProcessor* GrRRectEffect::Create(GrPrimitiveEdgeType edgeType, const S
return nullptr;
}
if (rrect.isNinePatch()) {
- return EllipticalRRectEffect::Create(edgeType, rrect);
+ return EllipticalRRectEffect::Make(edgeType, rrect);
}
return nullptr;
}
diff --git a/src/gpu/effects/GrRRectEffect.h b/src/gpu/effects/GrRRectEffect.h
index 63e08a4424..6ff2cc9735 100644
--- a/src/gpu/effects/GrRRectEffect.h
+++ b/src/gpu/effects/GrRRectEffect.h
@@ -10,6 +10,7 @@
#include "GrTypes.h"
#include "GrTypesPriv.h"
+#include "SkRefCnt.h"
class GrFragmentProcessor;
class GrProcessor;
@@ -20,7 +21,7 @@ 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.
*/
- GrFragmentProcessor* Create(GrPrimitiveEdgeType, const SkRRect&);
+ sk_sp<GrFragmentProcessor> Make(GrPrimitiveEdgeType, const SkRRect&);
};
#endif
diff --git a/src/gpu/effects/GrSimpleTextureEffect.cpp b/src/gpu/effects/GrSimpleTextureEffect.cpp
index f4cbd06af9..7e7b828d3d 100644
--- a/src/gpu/effects/GrSimpleTextureEffect.cpp
+++ b/src/gpu/effects/GrSimpleTextureEffect.cpp
@@ -46,7 +46,7 @@ GrGLSLFragmentProcessor* GrSimpleTextureEffect::onCreateGLSLInstance() const {
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrSimpleTextureEffect);
-const GrFragmentProcessor* GrSimpleTextureEffect::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> GrSimpleTextureEffect::TestCreate(GrProcessorTestData* d) {
int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx :
GrProcessorUnitTest::kAlphaTextureIdx;
static const SkShader::TileMode kTileModes[] = {
@@ -68,5 +68,5 @@ const GrFragmentProcessor* GrSimpleTextureEffect::TestCreate(GrProcessorTestData
GrCoordSet coordSet = kCoordSets[d->fRandom->nextULessThan(SK_ARRAY_COUNT(kCoordSets))];
const SkMatrix& matrix = GrTest::TestMatrix(d->fRandom);
- return GrSimpleTextureEffect::Create(d->fTextures[texIdx], matrix, coordSet);
+ return GrSimpleTextureEffect::Make(d->fTextures[texIdx], matrix, coordSet);
}
diff --git a/src/gpu/effects/GrSimpleTextureEffect.h b/src/gpu/effects/GrSimpleTextureEffect.h
index 18a8a78fc4..08eb8c17e1 100644
--- a/src/gpu/effects/GrSimpleTextureEffect.h
+++ b/src/gpu/effects/GrSimpleTextureEffect.h
@@ -21,25 +21,27 @@ class GrInvariantOutput;
class GrSimpleTextureEffect : public GrSingleTextureEffect {
public:
/* unfiltered, clamp mode */
- static const GrFragmentProcessor* Create(GrTexture* tex,
- const SkMatrix& matrix,
- GrCoordSet coordSet = kLocal_GrCoordSet) {
- return new GrSimpleTextureEffect(tex, matrix, GrTextureParams::kNone_FilterMode, coordSet);
+ static sk_sp<GrFragmentProcessor> Make(GrTexture* tex,
+ const SkMatrix& matrix,
+ GrCoordSet coordSet = kLocal_GrCoordSet) {
+ return sk_sp<GrFragmentProcessor>(
+ new GrSimpleTextureEffect(tex, matrix, GrTextureParams::kNone_FilterMode, coordSet));
}
/* clamp mode */
- static GrFragmentProcessor* Create(GrTexture* tex,
- const SkMatrix& matrix,
- GrTextureParams::FilterMode filterMode,
- GrCoordSet coordSet = kLocal_GrCoordSet) {
- return new GrSimpleTextureEffect(tex, matrix, filterMode, coordSet);
+ static sk_sp<GrFragmentProcessor> Make(GrTexture* tex,
+ const SkMatrix& matrix,
+ GrTextureParams::FilterMode filterMode,
+ GrCoordSet coordSet = kLocal_GrCoordSet) {
+ return sk_sp<GrFragmentProcessor>(
+ new GrSimpleTextureEffect(tex, matrix, filterMode, coordSet));
}
- static GrFragmentProcessor* Create(GrTexture* tex,
- const SkMatrix& matrix,
- const GrTextureParams& p,
- GrCoordSet coordSet = kLocal_GrCoordSet) {
- return new GrSimpleTextureEffect(tex, matrix, p, coordSet);
+ static sk_sp<GrFragmentProcessor> Make(GrTexture* tex,
+ const SkMatrix& matrix,
+ const GrTextureParams& p,
+ GrCoordSet coordSet = kLocal_GrCoordSet) {
+ return sk_sp<GrFragmentProcessor>(new GrSimpleTextureEffect(tex, matrix, p, coordSet));
}
virtual ~GrSimpleTextureEffect() {}
diff --git a/src/gpu/effects/GrTextureDomain.cpp b/src/gpu/effects/GrTextureDomain.cpp
index cf6ebe54be..3fbf0008a4 100644
--- a/src/gpu/effects/GrTextureDomain.cpp
+++ b/src/gpu/effects/GrTextureDomain.cpp
@@ -218,18 +218,19 @@ void GrGLTextureDomainEffect::GenKey(const GrProcessor& processor, const GrGLSLC
///////////////////////////////////////////////////////////////////////////////
-const GrFragmentProcessor* GrTextureDomainEffect::Create(GrTexture* texture,
- const SkMatrix& matrix,
- const SkRect& domain,
- GrTextureDomain::Mode mode,
- GrTextureParams::FilterMode filterMode,
- GrCoordSet coordSet) {
+sk_sp<GrFragmentProcessor> GrTextureDomainEffect::Make(GrTexture* texture,
+ const SkMatrix& matrix,
+ const SkRect& domain,
+ GrTextureDomain::Mode mode,
+ GrTextureParams::FilterMode filterMode,
+ GrCoordSet coordSet) {
static const SkRect kFullRect = {0, 0, SK_Scalar1, SK_Scalar1};
if (GrTextureDomain::kIgnore_Mode == mode ||
(GrTextureDomain::kClamp_Mode == mode && domain.contains(kFullRect))) {
- return GrSimpleTextureEffect::Create(texture, matrix, filterMode);
+ return GrSimpleTextureEffect::Make(texture, matrix, filterMode);
} else {
- return new GrTextureDomainEffect(texture, matrix, domain, mode, filterMode, coordSet);
+ return sk_sp<GrFragmentProcessor>(
+ new GrTextureDomainEffect(texture, matrix, domain, mode, filterMode, coordSet));
}
}
@@ -278,7 +279,7 @@ void GrTextureDomainEffect::onComputeInvariantOutput(GrInvariantOutput* inout) c
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrTextureDomainEffect);
-const GrFragmentProcessor* GrTextureDomainEffect::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> GrTextureDomainEffect::TestCreate(GrProcessorTestData* d) {
int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx :
GrProcessorUnitTest::kAlphaTextureIdx;
SkRect domain;
@@ -291,7 +292,7 @@ const GrFragmentProcessor* GrTextureDomainEffect::TestCreate(GrProcessorTestData
const SkMatrix& matrix = GrTest::TestMatrix(d->fRandom);
bool bilerp = mode != GrTextureDomain::kRepeat_Mode ? d->fRandom->nextBool() : false;
GrCoordSet coords = d->fRandom->nextBool() ? kLocal_GrCoordSet : kDevice_GrCoordSet;
- return GrTextureDomainEffect::Create(
+ return GrTextureDomainEffect::Make(
d->fTextures[texIdx],
matrix,
domain,
diff --git a/src/gpu/effects/GrTextureDomain.h b/src/gpu/effects/GrTextureDomain.h
index 387016ed56..a86ce95497 100644
--- a/src/gpu/effects/GrTextureDomain.h
+++ b/src/gpu/effects/GrTextureDomain.h
@@ -166,12 +166,12 @@ protected:
class GrTextureDomainEffect : public GrSingleTextureEffect {
public:
- static const GrFragmentProcessor* Create(GrTexture*,
- const SkMatrix&,
- const SkRect& domain,
- GrTextureDomain::Mode,
- GrTextureParams::FilterMode filterMode,
- GrCoordSet = kLocal_GrCoordSet);
+ static sk_sp<GrFragmentProcessor> Make(GrTexture*,
+ const SkMatrix&,
+ const SkRect& domain,
+ GrTextureDomain::Mode,
+ GrTextureParams::FilterMode filterMode,
+ GrCoordSet = kLocal_GrCoordSet);
virtual ~GrTextureDomainEffect();
diff --git a/src/gpu/effects/GrXfermodeFragmentProcessor.cpp b/src/gpu/effects/GrXfermodeFragmentProcessor.cpp
index a881999e0a..051061ffa8 100644
--- a/src/gpu/effects/GrXfermodeFragmentProcessor.cpp
+++ b/src/gpu/effects/GrXfermodeFragmentProcessor.cpp
@@ -17,12 +17,12 @@
class ComposeTwoFragmentProcessor : public GrFragmentProcessor {
public:
- ComposeTwoFragmentProcessor(const GrFragmentProcessor* src, const GrFragmentProcessor* dst,
- SkXfermode::Mode mode)
+ ComposeTwoFragmentProcessor(sk_sp<GrFragmentProcessor> src, sk_sp<GrFragmentProcessor> dst,
+ SkXfermode::Mode mode)
: fMode(mode) {
this->initClassID<ComposeTwoFragmentProcessor>();
- SkDEBUGCODE(int shaderAChildIndex = )this->registerChildProcessor(src);
- SkDEBUGCODE(int shaderBChildIndex = )this->registerChildProcessor(dst);
+ SkDEBUGCODE(int shaderAChildIndex = )this->registerChildProcessor(std::move(src));
+ SkDEBUGCODE(int shaderBChildIndex = )this->registerChildProcessor(std::move(dst));
SkASSERT(0 == shaderAChildIndex);
SkASSERT(1 == shaderBChildIndex);
}
@@ -69,14 +69,15 @@ private:
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(ComposeTwoFragmentProcessor);
-const GrFragmentProcessor* ComposeTwoFragmentProcessor::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> ComposeTwoFragmentProcessor::TestCreate(GrProcessorTestData* d) {
// Create two random frag procs.
- SkAutoTUnref<const GrFragmentProcessor> fpA(GrProcessorUnitTest::CreateChildFP(d));
- SkAutoTUnref<const GrFragmentProcessor> fpB(GrProcessorUnitTest::CreateChildFP(d));
+ sk_sp<GrFragmentProcessor> fpA(GrProcessorUnitTest::MakeChildFP(d));
+ sk_sp<GrFragmentProcessor> fpB(GrProcessorUnitTest::MakeChildFP(d));
SkXfermode::Mode mode = static_cast<SkXfermode::Mode>(
d->fRandom->nextRangeU(0, SkXfermode::kLastMode));
- return new ComposeTwoFragmentProcessor(fpA, fpB, mode);
+ return sk_sp<GrFragmentProcessor>(
+ new ComposeTwoFragmentProcessor(std::move(fpA), std::move(fpB), mode));
}
GrGLSLFragmentProcessor* ComposeTwoFragmentProcessor::onCreateGLSLInstance() const{
@@ -118,18 +119,19 @@ void GLComposeTwoFragmentProcessor::emitCode(EmitArgs& args) {
}
}
-const GrFragmentProcessor* GrXfermodeFragmentProcessor::CreateFromTwoProcessors(
- const GrFragmentProcessor* src, const GrFragmentProcessor* dst, SkXfermode::Mode mode) {
+sk_sp<GrFragmentProcessor> GrXfermodeFragmentProcessor::MakeFromTwoProcessors(
+ sk_sp<GrFragmentProcessor> src, sk_sp<GrFragmentProcessor> dst, SkXfermode::Mode mode) {
switch (mode) {
case SkXfermode::kClear_Mode:
- return GrConstColorProcessor::Create(GrColor_TRANSPARENT_BLACK,
- GrConstColorProcessor::kIgnore_InputMode);
+ return GrConstColorProcessor::Make(GrColor_TRANSPARENT_BLACK,
+ GrConstColorProcessor::kIgnore_InputMode);
case SkXfermode::kSrc_Mode:
- return SkRef(src);
+ return src;
case SkXfermode::kDst_Mode:
- return SkRef(dst);
+ return dst;
default:
- return new ComposeTwoFragmentProcessor(src, dst, mode);
+ return sk_sp<GrFragmentProcessor>(
+ new ComposeTwoFragmentProcessor(std::move(src), std::move(dst), mode));
}
}
@@ -142,11 +144,11 @@ public:
kSrc_Child,
};
- ComposeOneFragmentProcessor(const GrFragmentProcessor* dst, SkXfermode::Mode mode, Child child)
+ ComposeOneFragmentProcessor(sk_sp<GrFragmentProcessor> dst, SkXfermode::Mode mode, Child child)
: fMode(mode)
, fChild(child) {
this->initClassID<ComposeOneFragmentProcessor>();
- SkDEBUGCODE(int dstIndex = )this->registerChildProcessor(dst);
+ SkDEBUGCODE(int dstIndex = )this->registerChildProcessor(std::move(dst));
SkASSERT(0 == dstIndex);
}
@@ -260,17 +262,17 @@ private:
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(ComposeOneFragmentProcessor);
-const GrFragmentProcessor* ComposeOneFragmentProcessor::TestCreate(GrProcessorTestData* d) {
+sk_sp<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.
- SkAutoTUnref<const GrFragmentProcessor> dst(GrProcessorUnitTest::CreateChildFP(d));
+ sk_sp<GrFragmentProcessor> dst(GrProcessorUnitTest::MakeChildFP(d));
SkXfermode::Mode mode = static_cast<SkXfermode::Mode>(
d->fRandom->nextRangeU(0, SkXfermode::kLastMode));
ComposeOneFragmentProcessor::Child child = d->fRandom->nextBool() ?
ComposeOneFragmentProcessor::kDst_Child :
ComposeOneFragmentProcessor::kSrc_Child;
- return new ComposeOneFragmentProcessor(dst, mode, child);
+ return sk_sp<GrFragmentProcessor>(new ComposeOneFragmentProcessor(std::move(dst), mode, child));
}
GrGLSLFragmentProcessor* ComposeOneFragmentProcessor::onCreateGLSLInstance() const {
@@ -279,30 +281,32 @@ GrGLSLFragmentProcessor* ComposeOneFragmentProcessor::onCreateGLSLInstance() con
//////////////////////////////////////////////////////////////////////////////
-const GrFragmentProcessor* GrXfermodeFragmentProcessor::CreateFromDstProcessor(
- const GrFragmentProcessor* dst, SkXfermode::Mode mode) {
+sk_sp<GrFragmentProcessor> GrXfermodeFragmentProcessor::MakeFromDstProcessor(
+ sk_sp<GrFragmentProcessor> dst, SkXfermode::Mode mode) {
switch (mode) {
case SkXfermode::kClear_Mode:
- return GrConstColorProcessor::Create(GrColor_TRANSPARENT_BLACK,
+ return GrConstColorProcessor::Make(GrColor_TRANSPARENT_BLACK,
GrConstColorProcessor::kIgnore_InputMode);
case SkXfermode::kSrc_Mode:
return nullptr;
default:
- return new ComposeOneFragmentProcessor(dst, mode,
- ComposeOneFragmentProcessor::kDst_Child);
+ return sk_sp<GrFragmentProcessor>(
+ new ComposeOneFragmentProcessor(std::move(dst), mode,
+ ComposeOneFragmentProcessor::kDst_Child));
}
}
-const GrFragmentProcessor* GrXfermodeFragmentProcessor::CreateFromSrcProcessor(
- const GrFragmentProcessor* src, SkXfermode::Mode mode) {
+sk_sp<GrFragmentProcessor> GrXfermodeFragmentProcessor::MakeFromSrcProcessor(
+ sk_sp<GrFragmentProcessor> src, SkXfermode::Mode mode) {
switch (mode) {
case SkXfermode::kClear_Mode:
- return GrConstColorProcessor::Create(GrColor_TRANSPARENT_BLACK,
+ return GrConstColorProcessor::Make(GrColor_TRANSPARENT_BLACK,
GrConstColorProcessor::kIgnore_InputMode);
case SkXfermode::kDst_Mode:
return nullptr;
default:
- return new ComposeOneFragmentProcessor(src, mode,
- ComposeOneFragmentProcessor::kSrc_Child);
+ return sk_sp<GrFragmentProcessor>(
+ new ComposeOneFragmentProcessor(src, mode,
+ ComposeOneFragmentProcessor::kSrc_Child));
}
}
diff --git a/src/gpu/effects/GrYUVEffect.cpp b/src/gpu/effects/GrYUVEffect.cpp
index 97ef663bb7..94dca84df6 100644
--- a/src/gpu/effects/GrYUVEffect.cpp
+++ b/src/gpu/effects/GrYUVEffect.cpp
@@ -62,9 +62,9 @@ static const float kRec709InverseConversionMatrix[16] = {
class YUVtoRGBEffect : public GrFragmentProcessor {
public:
- static GrFragmentProcessor* Create(GrTexture* yTexture, GrTexture* uTexture,
- GrTexture* vTexture, const SkISize sizes[3],
- SkYUVColorSpace colorSpace) {
+ static sk_sp<GrFragmentProcessor> Make(GrTexture* yTexture, GrTexture* uTexture,
+ GrTexture* vTexture, const SkISize sizes[3],
+ SkYUVColorSpace colorSpace) {
SkScalar w[3], h[3];
w[0] = SkIntToScalar(sizes[0].fWidth) / SkIntToScalar(yTexture->width());
h[0] = SkIntToScalar(sizes[0].fHeight) / SkIntToScalar(yTexture->height());
@@ -85,8 +85,8 @@ public:
(sizes[2].fHeight != sizes[0].fHeight)) ?
GrTextureParams::kBilerp_FilterMode :
GrTextureParams::kNone_FilterMode;
- return new YUVtoRGBEffect(yTexture, uTexture, vTexture, yuvMatrix, uvFilterMode,
- colorSpace);
+ return sk_sp<GrFragmentProcessor>(
+ new YUVtoRGBEffect(yTexture, uTexture, vTexture, yuvMatrix, uvFilterMode, colorSpace));
}
const char* name() const override { return "YUV to RGB"; }
@@ -206,12 +206,12 @@ public:
kV_OutputChannels
};
- RGBToYUVEffect(const GrFragmentProcessor* rgbFP, SkYUVColorSpace colorSpace,
+ RGBToYUVEffect(sk_sp<GrFragmentProcessor> rgbFP, SkYUVColorSpace colorSpace,
OutputChannels output)
: fColorSpace(colorSpace)
, fOutputChannels(output) {
this->initClassID<RGBToYUVEffect>();
- this->registerChildProcessor(rgbFP);
+ this->registerChildProcessor(std::move(rgbFP));
}
const char* name() const override { return "RGBToYUV"; }
@@ -350,39 +350,44 @@ private:
//////////////////////////////////////////////////////////////////////////////
-const GrFragmentProcessor*
-GrYUVEffect::CreateYUVToRGB(GrTexture* yTexture, GrTexture* uTexture, GrTexture* vTexture,
+sk_sp<GrFragmentProcessor>
+GrYUVEffect::MakeYUVToRGB(GrTexture* yTexture, GrTexture* uTexture, GrTexture* vTexture,
const SkISize sizes[3], SkYUVColorSpace colorSpace) {
SkASSERT(yTexture && uTexture && vTexture && sizes);
- return YUVtoRGBEffect::Create(yTexture, uTexture, vTexture, sizes, colorSpace);
+ return YUVtoRGBEffect::Make(yTexture, uTexture, vTexture, sizes, colorSpace);
}
-const GrFragmentProcessor*
-GrYUVEffect::CreateRGBToYUV(const GrFragmentProcessor* rgbFP, SkYUVColorSpace colorSpace) {
+sk_sp<GrFragmentProcessor>
+GrYUVEffect::MakeRGBToYUV(sk_sp<GrFragmentProcessor> rgbFP, SkYUVColorSpace colorSpace) {
SkASSERT(rgbFP);
- return new RGBToYUVEffect(rgbFP, colorSpace, RGBToYUVEffect::kYUV_OutputChannels);
+ return sk_sp<GrFragmentProcessor>(
+ new RGBToYUVEffect(std::move(rgbFP), colorSpace, RGBToYUVEffect::kYUV_OutputChannels));
}
-const GrFragmentProcessor*
-GrYUVEffect::CreateRGBToY(const GrFragmentProcessor* rgbFP, SkYUVColorSpace colorSpace) {
+sk_sp<GrFragmentProcessor>
+GrYUVEffect::MakeRGBToY(sk_sp<GrFragmentProcessor> rgbFP, SkYUVColorSpace colorSpace) {
SkASSERT(rgbFP);
- return new RGBToYUVEffect(rgbFP, colorSpace, RGBToYUVEffect::kY_OutputChannels);
+ return sk_sp<GrFragmentProcessor>(
+ new RGBToYUVEffect(std::move(rgbFP), colorSpace, RGBToYUVEffect::kY_OutputChannels));
}
-const GrFragmentProcessor*
-GrYUVEffect::CreateRGBToUV(const GrFragmentProcessor* rgbFP, SkYUVColorSpace colorSpace) {
+sk_sp<GrFragmentProcessor>
+GrYUVEffect::MakeRGBToUV(sk_sp<GrFragmentProcessor> rgbFP, SkYUVColorSpace colorSpace) {
SkASSERT(rgbFP);
- return new RGBToYUVEffect(rgbFP, colorSpace, RGBToYUVEffect::kUV_OutputChannels);
+ return sk_sp<GrFragmentProcessor>(
+ new RGBToYUVEffect(std::move(rgbFP), colorSpace, RGBToYUVEffect::kUV_OutputChannels));
}
-const GrFragmentProcessor*
-GrYUVEffect::CreateRGBToU(const GrFragmentProcessor* rgbFP, SkYUVColorSpace colorSpace) {
+sk_sp<GrFragmentProcessor>
+GrYUVEffect::MakeRGBToU(sk_sp<GrFragmentProcessor> rgbFP, SkYUVColorSpace colorSpace) {
SkASSERT(rgbFP);
- return new RGBToYUVEffect(rgbFP, colorSpace, RGBToYUVEffect::kU_OutputChannels);
+ return sk_sp<GrFragmentProcessor>(
+ new RGBToYUVEffect(std::move(rgbFP), colorSpace, RGBToYUVEffect::kU_OutputChannels));
}
-const GrFragmentProcessor*
-GrYUVEffect::CreateRGBToV(const GrFragmentProcessor* rgbFP, SkYUVColorSpace colorSpace) {
+sk_sp<GrFragmentProcessor>
+GrYUVEffect::MakeRGBToV(sk_sp<GrFragmentProcessor> rgbFP, SkYUVColorSpace colorSpace) {
SkASSERT(rgbFP);
- return new RGBToYUVEffect(rgbFP, colorSpace, RGBToYUVEffect::kV_OutputChannels);
+ return sk_sp<GrFragmentProcessor>(
+ new RGBToYUVEffect(std::move(rgbFP), colorSpace, RGBToYUVEffect::kV_OutputChannels));
}
diff --git a/src/gpu/effects/GrYUVEffect.h b/src/gpu/effects/GrYUVEffect.h
index 4f3848e532..6d3b158ae9 100644
--- a/src/gpu/effects/GrYUVEffect.h
+++ b/src/gpu/effects/GrYUVEffect.h
@@ -18,33 +18,33 @@ namespace GrYUVEffect {
* Creates an effect that performs color conversion from YUV to RGB. The input textures are
* assumed to be kA8_GrPixelConfig.
*/
- const GrFragmentProcessor* CreateYUVToRGB(GrTexture* yTexture, GrTexture* uTexture,
- GrTexture* vTexture, const SkISize sizes[3],
- SkYUVColorSpace colorSpace);
+ sk_sp<GrFragmentProcessor> MakeYUVToRGB(GrTexture* yTexture, GrTexture* uTexture,
+ GrTexture* vTexture, const SkISize sizes[3],
+ SkYUVColorSpace colorSpace);
/**
* 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.
*/
- const GrFragmentProcessor* CreateRGBToYUV(const GrFragmentProcessor*,
- SkYUVColorSpace colorSpace);
+ sk_sp<GrFragmentProcessor> MakeRGBToYUV(sk_sp<GrFragmentProcessor>,
+ SkYUVColorSpace colorSpace);
/**
* 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.
*/
- const GrFragmentProcessor* CreateRGBToUV(const GrFragmentProcessor*,
- SkYUVColorSpace colorSpace);
+ sk_sp<GrFragmentProcessor> MakeRGBToUV(sk_sp<GrFragmentProcessor>,
+ SkYUVColorSpace colorSpace);
/**
* 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.
*/
- const GrFragmentProcessor* CreateRGBToY(const GrFragmentProcessor*, SkYUVColorSpace colorSpace);
- const GrFragmentProcessor* CreateRGBToU(const GrFragmentProcessor*, SkYUVColorSpace colorSpace);
- const GrFragmentProcessor* CreateRGBToV(const GrFragmentProcessor*, SkYUVColorSpace colorSpace);
+ sk_sp<GrFragmentProcessor> MakeRGBToY(sk_sp<GrFragmentProcessor>, SkYUVColorSpace colorSpace);
+ sk_sp<GrFragmentProcessor> MakeRGBToU(sk_sp<GrFragmentProcessor>, SkYUVColorSpace colorSpace);
+ sk_sp<GrFragmentProcessor> MakeRGBToV(sk_sp<GrFragmentProcessor>, SkYUVColorSpace colorSpace);
};
#endif
diff --git a/src/image/SkImageShader.cpp b/src/image/SkImageShader.cpp
index b2fab39e11..33edfdeb57 100644
--- a/src/image/SkImageShader.cpp
+++ b/src/image/SkImageShader.cpp
@@ -83,7 +83,7 @@ void SkImageShader::toString(SkString* str) const {
#include "effects/GrBicubicEffect.h"
#include "effects/GrSimpleTextureEffect.h"
-const GrFragmentProcessor* SkImageShader::asFragmentProcessor(
+sk_sp<GrFragmentProcessor> SkImageShader::asFragmentProcessor(
GrContext* context,
const SkMatrix& viewM,
const SkMatrix* localMatrix,
@@ -120,17 +120,17 @@ const GrFragmentProcessor* SkImageShader::asFragmentProcessor(
return nullptr;
}
- SkAutoTUnref<const GrFragmentProcessor> inner;
+ sk_sp<GrFragmentProcessor> inner;
if (doBicubic) {
- inner.reset(GrBicubicEffect::Create(texture, matrix, tm));
+ inner = GrBicubicEffect::Make(texture, matrix, tm);
} else {
- inner.reset(GrSimpleTextureEffect::Create(texture, matrix, params));
+ inner = GrSimpleTextureEffect::Make(texture, matrix, params);
}
if (GrPixelConfigIsAlphaOnly(texture->config())) {
- return SkRef(inner.get());
+ return inner;
}
- return GrFragmentProcessor::MulOutputByInputAlpha(inner);
+ return sk_sp<GrFragmentProcessor>(GrFragmentProcessor::MulOutputByInputAlpha(std::move(inner)));
}
#endif
diff --git a/src/image/SkImageShader.h b/src/image/SkImageShader.h
index 58b22dd3af..c0d95898cb 100644
--- a/src/image/SkImageShader.h
+++ b/src/image/SkImageShader.h
@@ -22,7 +22,7 @@ public:
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkImageShader)
#if SK_SUPPORT_GPU
- const GrFragmentProcessor* asFragmentProcessor(GrContext*, const SkMatrix& viewM,
+ sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext*, const SkMatrix& viewM,
const SkMatrix*, SkFilterQuality,
SkSourceGammaTreatment) const override;
#endif
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp
index 0c4769fa95..cc92d4efa5 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -266,8 +266,8 @@ sk_sp<SkImage> SkImage::MakeFromYUVTexturesCopy(GrContext* ctx , SkYUVColorSpace
GrPaint paint;
paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
- paint.addColorFragmentProcessor(GrYUVEffect::CreateYUVToRGB(yTex, uTex, vTex, yuvSizes,
- colorSpace))->unref();
+ paint.addColorFragmentProcessor(GrYUVEffect::MakeYUVToRGB(yTex, uTex, vTex, yuvSizes,
+ colorSpace));
const SkRect rect = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(height));
diff --git a/tests/GLProgramsTest.cpp b/tests/GLProgramsTest.cpp
index 2470061257..7ce71c6637 100644
--- a/tests/GLProgramsTest.cpp
+++ b/tests/GLProgramsTest.cpp
@@ -66,8 +66,8 @@ private:
class BigKeyProcessor : public GrFragmentProcessor {
public:
- static GrFragmentProcessor* Create() {
- return new BigKeyProcessor;
+ static sk_sp<GrFragmentProcessor> Make() {
+ return sk_sp<GrFragmentProcessor>(new BigKeyProcessor);
}
const char* name() const override { return "Big Ole Key"; }
@@ -94,16 +94,16 @@ private:
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(BigKeyProcessor);
-const GrFragmentProcessor* BigKeyProcessor::TestCreate(GrProcessorTestData*) {
- return BigKeyProcessor::Create();
+sk_sp<GrFragmentProcessor> BigKeyProcessor::TestCreate(GrProcessorTestData*) {
+ return BigKeyProcessor::Make();
}
//////////////////////////////////////////////////////////////////////////////
class BlockInputFragmentProcessor : public GrFragmentProcessor {
public:
- static GrFragmentProcessor* Create(const GrFragmentProcessor* fp) {
- return new BlockInputFragmentProcessor(fp);
+ static sk_sp<GrFragmentProcessor> Make(sk_sp<GrFragmentProcessor> fp) {
+ return sk_sp<GrFragmentProcessor>(new BlockInputFragmentProcessor(fp));
}
const char* name() const override { return "Block Input"; }
@@ -121,9 +121,9 @@ private:
typedef GrGLSLFragmentProcessor INHERITED;
};
- BlockInputFragmentProcessor(const GrFragmentProcessor* child) {
+ BlockInputFragmentProcessor(sk_sp<GrFragmentProcessor> child) {
this->initClassID<BlockInputFragmentProcessor>();
- this->registerChildProcessor(child);
+ this->registerChildProcessor(std::move(child));
}
void onGetGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const override {}
@@ -185,13 +185,13 @@ static sk_sp<GrDrawContext> random_draw_context(GrContext* context,
}
static void set_random_xpf(GrPipelineBuilder* pipelineBuilder, GrProcessorTestData* d) {
- SkAutoTUnref<const GrXPFactory> xpf(GrProcessorTestFactory<GrXPFactory>::Create(d));
+ sk_sp<GrXPFactory> xpf(GrProcessorTestFactory<GrXPFactory>::Make(d));
SkASSERT(xpf);
- pipelineBuilder->setXPFactory(xpf.get());
+ pipelineBuilder->setXPFactory(std::move(xpf));
}
-static const GrFragmentProcessor* create_random_proc_tree(GrProcessorTestData* d,
- int minLevels, int maxLevels) {
+static sk_sp<GrFragmentProcessor> create_random_proc_tree(GrProcessorTestData* d,
+ int minLevels, int maxLevels) {
SkASSERT(1 <= minLevels);
SkASSERT(minLevels <= maxLevels);
@@ -202,14 +202,13 @@ static const GrFragmentProcessor* create_random_proc_tree(GrProcessorTestData* d
if (1 == minLevels) {
bool terminate = (1 == maxLevels) || (d->fRandom->nextF() < terminateProbability);
if (terminate) {
- const GrFragmentProcessor* fp;
+ sk_sp<GrFragmentProcessor> fp;
while (true) {
- fp = GrProcessorTestFactory<GrFragmentProcessor>::Create(d);
+ fp = GrProcessorTestFactory<GrFragmentProcessor>::Make(d);
SkASSERT(fp);
if (0 == fp->numChildProcessors()) {
break;
}
- fp->unref();
}
return fp;
}
@@ -220,18 +219,18 @@ static const GrFragmentProcessor* create_random_proc_tree(GrProcessorTestData* d
if (minLevels > 1) {
--minLevels;
}
- SkAutoTUnref<const GrFragmentProcessor> minLevelsChild(create_random_proc_tree(d, minLevels,
- maxLevels - 1));
- SkAutoTUnref<const GrFragmentProcessor> otherChild(create_random_proc_tree(d, 1,
- maxLevels - 1));
+ sk_sp<GrFragmentProcessor> minLevelsChild(create_random_proc_tree(d, minLevels, maxLevels - 1));
+ sk_sp<GrFragmentProcessor> otherChild(create_random_proc_tree(d, 1, maxLevels - 1));
SkXfermode::Mode mode = static_cast<SkXfermode::Mode>(d->fRandom->nextRangeU(0,
SkXfermode::kLastCoeffMode));
- const GrFragmentProcessor* fp;
+ sk_sp<GrFragmentProcessor> fp;
if (d->fRandom->nextF() < 0.5f) {
- fp = GrXfermodeFragmentProcessor::CreateFromTwoProcessors(minLevelsChild, otherChild, mode);
+ fp = GrXfermodeFragmentProcessor::MakeFromTwoProcessors(std::move(minLevelsChild),
+ std::move(otherChild), mode);
SkASSERT(fp);
} else {
- fp = GrXfermodeFragmentProcessor::CreateFromTwoProcessors(otherChild, minLevelsChild, mode);
+ fp = GrXfermodeFragmentProcessor::MakeFromTwoProcessors(std::move(otherChild),
+ std::move(minLevelsChild), mode);
SkASSERT(fp);
}
return fp;
@@ -245,23 +244,21 @@ static void set_random_color_coverage_stages(GrPipelineBuilder* pipelineBuilder,
// A full tree with 5 levels (31 nodes) may exceed the max allowed length of the gl
// processor key; maxTreeLevels should be a number from 1 to 4 inclusive.
const int maxTreeLevels = 4;
- SkAutoTUnref<const GrFragmentProcessor> fp(
- create_random_proc_tree(d, 2, maxTreeLevels));
- pipelineBuilder->addColorFragmentProcessor(fp);
+ sk_sp<GrFragmentProcessor> fp(create_random_proc_tree(d, 2, maxTreeLevels));
+ pipelineBuilder->addColorFragmentProcessor(std::move(fp));
} else {
int numProcs = d->fRandom->nextULessThan(maxStages + 1);
int numColorProcs = d->fRandom->nextULessThan(numProcs + 1);
for (int s = 0; s < numProcs;) {
- SkAutoTUnref<const GrFragmentProcessor> fp(
- GrProcessorTestFactory<GrFragmentProcessor>::Create(d));
+ sk_sp<GrFragmentProcessor> fp(GrProcessorTestFactory<GrFragmentProcessor>::Make(d));
SkASSERT(fp);
// finally add the stage to the correct pipeline in the drawstate
if (s < numColorProcs) {
- pipelineBuilder->addColorFragmentProcessor(fp);
+ pipelineBuilder->addColorFragmentProcessor(std::move(fp));
} else {
- pipelineBuilder->addCoverageFragmentProcessor(fp);
+ pipelineBuilder->addCoverageFragmentProcessor(std::move(fp));
}
++s;
}
@@ -385,13 +382,13 @@ bool GrDrawingManager::ProgramUnitTest(GrContext* context, int maxStages) {
GrProcessorTestData ptd(&random, context, context->caps(),
drawContext.get(), dummyTextures);
GrPipelineBuilder builder;
- builder.setXPFactory(GrPorterDuffXPFactory::Create(SkXfermode::kSrc_Mode))->unref();
+ builder.setXPFactory(GrPorterDuffXPFactory::Make(SkXfermode::kSrc_Mode));
- SkAutoTUnref<const GrFragmentProcessor> fp(
- GrProcessorTestFactory<GrFragmentProcessor>::CreateIdx(i, &ptd));
- SkAutoTUnref<const GrFragmentProcessor> blockFP(
- BlockInputFragmentProcessor::Create(fp));
- builder.addColorFragmentProcessor(blockFP);
+ sk_sp<GrFragmentProcessor> fp(
+ GrProcessorTestFactory<GrFragmentProcessor>::MakeIdx(i, &ptd));
+ sk_sp<GrFragmentProcessor> blockFP(
+ BlockInputFragmentProcessor::Make(std::move(fp)));
+ builder.addColorFragmentProcessor(std::move(blockFP));
drawContext->drawContextPriv().testingOnly_drawBatch(builder, batch);
drawingManager->flush();
diff --git a/tests/GpuColorFilterTest.cpp b/tests/GpuColorFilterTest.cpp
index b18af18b1c..0fbce6c562 100644
--- a/tests/GpuColorFilterTest.cpp
+++ b/tests/GpuColorFilterTest.cpp
@@ -99,7 +99,7 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(GpuColorFilter, reporter, ctxInfo) {
for (size_t i = 0; i < SK_ARRAY_COUNT(filterTests); ++i) {
const GetConstantComponentTestCase& test = filterTests[i];
auto cf(SkColorFilter::MakeModeFilter(test.filterColor, test.filterMode));
- SkAutoTUnref<const GrFragmentProcessor> fp( cf->asFragmentProcessor(ctxInfo.grContext()));
+ sk_sp<GrFragmentProcessor> fp(cf->asFragmentProcessor(ctxInfo.grContext()));
REPORTER_ASSERT(reporter, fp);
GrInvariantOutput inout(test.inputColor,
static_cast<GrColorComponentFlags>(test.inputComponents),
diff --git a/tests/GrPorterDuffTest.cpp b/tests/GrPorterDuffTest.cpp
index a5ac868023..71db9939b8 100644
--- a/tests/GrPorterDuffTest.cpp
+++ b/tests/GrPorterDuffTest.cpp
@@ -69,7 +69,7 @@ public:
struct XPInfo {
XPInfo(skiatest::Reporter* reporter, SkXfermode::Mode xfermode, const GrCaps& caps,
const GrPipelineOptimizations& optimizations) {
- SkAutoTUnref<GrXPFactory> xpf(GrPorterDuffXPFactory::Create(xfermode));
+ sk_sp<GrXPFactory> xpf(GrPorterDuffXPFactory::Make(xfermode));
SkAutoTUnref<GrXferProcessor> xp(
xpf->createXferProcessor(optimizations, false, nullptr, caps));
TEST_ASSERT(!xpf->willNeedDstTexture(caps, optimizations));
@@ -1121,7 +1121,7 @@ static void test_lcd_coverage_fallback_case(skiatest::Reporter* reporter, const
SkASSERT(kRGBA_GrColorComponentFlags == colorPOI.validFlags());
SkASSERT(covPOI.isFourChannelOutput());
- SkAutoTUnref<GrXPFactory> xpf(GrPorterDuffXPFactory::Create(SkXfermode::kSrcOver_Mode));
+ sk_sp<GrXPFactory> xpf(GrPorterDuffXPFactory::Make(SkXfermode::kSrcOver_Mode));
TEST_ASSERT(!xpf->willNeedDstTexture(caps, opts));
SkAutoTUnref<GrXferProcessor> xp(
@@ -1198,7 +1198,7 @@ DEF_GPUTEST(PorterDuffNoDualSourceBlending, reporter, /*factory*/) {
}
for (int m = 0; m <= SkXfermode::kLastCoeffMode; m++) {
SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m);
- SkAutoTUnref<GrXPFactory> xpf(GrPorterDuffXPFactory::Create(xfermode));
+ sk_sp<GrXPFactory> xpf(GrPorterDuffXPFactory::Make(xfermode));
GrXferProcessor::DstTexture* dstTexture =
xpf->willNeedDstTexture(caps, optimizations) ? &fakeDstTexture : 0;
SkAutoTUnref<GrXferProcessor> xp(
diff --git a/tests/TessellatingPathRendererTests.cpp b/tests/TessellatingPathRendererTests.cpp
index 6d562ea24d..51ccef9329 100644
--- a/tests/TessellatingPathRendererTests.cpp
+++ b/tests/TessellatingPathRendererTests.cpp
@@ -236,7 +236,7 @@ static void test_path(GrDrawContext* drawContext, GrResourceProvider* rp, const
GrTessellatingPathRenderer tess;
GrPaint paint;
- paint.setXPFactory(GrPorterDuffXPFactory::Create(SkXfermode::kSrc_Mode))->unref();
+ paint.setXPFactory(GrPorterDuffXPFactory::Make(SkXfermode::kSrc_Mode));
GrNoClip noClip;
GrStyle style(SkStrokeRec::kFill_InitStyle);
diff --git a/tools/debugger/SkOverdrawMode.cpp b/tools/debugger/SkOverdrawMode.cpp
index bbf61cc76b..58b47edc8c 100644
--- a/tools/debugger/SkOverdrawMode.cpp
+++ b/tools/debugger/SkOverdrawMode.cpp
@@ -26,8 +26,8 @@ class GLOverdrawFP;
class GrOverdrawFP : public GrFragmentProcessor {
public:
- static const GrFragmentProcessor* Create(const GrFragmentProcessor* dst) {
- return new GrOverdrawFP(dst);
+ static sk_sp<GrFragmentProcessor> Make(sk_sp<GrFragmentProcessor> dst) {
+ return sk_sp<GrFragmentProcessor>(new GrOverdrawFP(std::move(dst)));
}
~GrOverdrawFP() override { }
@@ -50,11 +50,11 @@ private:
inout->setToUnknown(GrInvariantOutput::kWill_ReadInput);
}
- GrOverdrawFP(const GrFragmentProcessor* dst) {
+ GrOverdrawFP(sk_sp<GrFragmentProcessor> dst) {
this->initClassID<GrOverdrawFP>();
SkASSERT(dst);
- SkDEBUGCODE(int dstIndex = )this->registerChildProcessor(dst);
+ SkDEBUGCODE(int dstIndex = )this->registerChildProcessor(std::move(dst));
SkASSERT(0 == dstIndex);
}
@@ -129,9 +129,8 @@ void GrOverdrawFP::onGetGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyB
GLOverdrawFP::GenKey(*this, caps, b);
}
-const GrFragmentProcessor* GrOverdrawFP::TestCreate(GrProcessorTestData* d) {
- SkAutoTUnref<const GrFragmentProcessor> dst(GrProcessorUnitTest::CreateChildFP(d));
- return new GrOverdrawFP(dst);
+sk_sp<GrFragmentProcessor> GrOverdrawFP::TestCreate(GrProcessorTestData* d) {
+ return GrOverdrawFP::Make(GrProcessorUnitTest::MakeChildFP(d));
}
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrOverdrawFP);
@@ -209,7 +208,7 @@ GrGLSLXferProcessor* OverdrawXP::createGLSLInstance() const { return new GLOverd
///////////////////////////////////////////////////////////////////////////////
class GrOverdrawXPFactory : public GrXPFactory {
public:
- static GrXPFactory* Create() { return new GrOverdrawXPFactory(); }
+ static sk_sp<GrXPFactory> Make() { return sk_sp<GrXPFactory>(new GrOverdrawXPFactory()); }
void getInvariantBlendedColor(const GrProcOptInfo& colorPOI,
GrXPFactory::InvariantBlendedColor* blendedColor) const override {
@@ -242,8 +241,8 @@ private:
GR_DEFINE_XP_FACTORY_TEST(GrOverdrawXPFactory);
-const GrXPFactory* GrOverdrawXPFactory::TestCreate(GrProcessorTestData* d) {
- return GrOverdrawXPFactory::Create();
+sk_sp<GrXPFactory> GrOverdrawXPFactory::TestCreate(GrProcessorTestData* d) {
+ return GrOverdrawXPFactory::Make();
}
#endif
@@ -289,13 +288,13 @@ public:
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkOverdrawXfermode)
#if SK_SUPPORT_GPU
- const GrFragmentProcessor* getFragmentProcessorForImageFilter(
- const GrFragmentProcessor* dst) const override {
- return GrOverdrawFP::Create(dst);
+ sk_sp<GrFragmentProcessor> makeFragmentProcessorForImageFilter(
+ sk_sp<GrFragmentProcessor> dst) const override {
+ return GrOverdrawFP::Make(dst);
}
- GrXPFactory* asXPFactory() const override {
- return GrOverdrawXPFactory::Create();
+ sk_sp<GrXPFactory> asXPFactory() const override {
+ return GrOverdrawXPFactory::Make();
}
#endif