sk_sp for Ganesh.
Convert use of GrFragmentProcessor, GrGeometryProcessor, and
GrXPFactory to sk_sp. This clarifies ownership and should
reduce reference count churn by moving ownership.
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2041113004
Review-Url: https://codereview.chromium.org/2041113004
diff --git a/src/gpu/GrBlurUtils.cpp b/src/gpu/GrBlurUtils.cpp
index 1e85b87..94c6ea0 100644
--- a/src/gpu/GrBlurUtils.cpp
+++ b/src/gpu/GrBlurUtils.cpp
@@ -35,8 +35,8 @@
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 fd741b9..9348181 100644
--- a/src/gpu/GrClipMaskManager.cpp
+++ b/src/gpu/GrClipMaskManager.cpp
@@ -32,8 +32,8 @@
////////////////////////////////////////////////////////////////////////////////
// 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 @@
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 @@
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 @@
// 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 @@
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 @@
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 @@
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 @@
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 @@
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 51ab64d..a9c6089 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -317,12 +317,11 @@
// 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 @@
}
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 @@
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 @@
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 @@
}
}
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 @@
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 @@
}
}
-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 @@
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 @@
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 df13d5d..9efd9eb 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 @@
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 @@
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 @@
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 @@
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 @@
}
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 23bcb45..f7ddb06 100644
--- a/src/gpu/GrDefaultGeoProcFactory.h
+++ b/src/gpu/GrDefaultGeoProcFactory.h
@@ -115,20 +115,20 @@
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 2f78d1e..64ce0ce 100644
--- a/src/gpu/GrDrawContext.cpp
+++ b/src/gpu/GrDrawContext.cpp
@@ -420,7 +420,7 @@
GrPaint paint;
paint.setAntiAlias(doAA);
- SkSafeUnref(paint.setXPFactory(GrDisableColorXPFactory::Create()));
+ paint.setXPFactory(GrDisableColorXPFactory::Make());
bool useHWAA;
SkAutoTUnref<GrDrawBatch> batch(
@@ -671,18 +671,18 @@
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 ac0c766..7213a92 100644
--- a/src/gpu/GrDrawTarget.cpp
+++ b/src/gpu/GrDrawTarget.cpp
@@ -245,9 +245,9 @@
// 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 @@
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 @@
// 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 @@
// 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 9524c84..96a0f71 100644
--- a/src/gpu/GrFragmentProcessor.cpp
+++ b/src/gpu/GrFragmentProcessor.cpp
@@ -89,7 +89,7 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
}
// 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);
- } else {
- int firstIdx = info.firstEffectiveProcessorIndex();
- 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;
+ 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 {
+ 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 2accbf6..cef08f4 100644
--- a/src/gpu/GrOvalRenderer.cpp
+++ b/src/gpu/GrOvalRenderer.cpp
@@ -184,8 +184,9 @@
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 @@
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 @@
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 f41469e..fd78f9f 100644
--- a/src/gpu/GrPaint.cpp
+++ b/src/gpu/GrPaint.cpp
@@ -19,36 +19,34 @@
, 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 f7848ba..e142de2 100644
--- a/src/gpu/GrPipelineBuilder.cpp
+++ b/src/gpu/GrPipelineBuilder.cpp
@@ -27,11 +27,11 @@
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 @@
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 @@
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 cccbc2c..a7556eb 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 @@
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 @@
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 @@
* 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 @@
* 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 @@
// 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 bdc602c..3f43389 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 05e270f..0c42a2b 100644
--- a/src/gpu/GrSWMaskHelper.cpp
+++ b/src/gpu/GrSWMaskHelper.cpp
@@ -189,10 +189,10 @@
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 076750e..a68c3d7 100644
--- a/src/gpu/GrTextureParamsAdjuster.cpp
+++ b/src/gpu/GrTextureParamsAdjuster.cpp
@@ -93,9 +93,9 @@
// 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 @@
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 @@
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 @@
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 5f0f271..08d71c4 100644
--- a/src/gpu/GrTextureParamsAdjuster.h
+++ b/src/gpu/GrTextureParamsAdjuster.h
@@ -59,7 +59,7 @@
* @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 @@
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 @@
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 4215602..58c4b9a 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 @@
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 @@
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 a7281da..b30ff1f 100644
--- a/src/gpu/GrYUVProvider.cpp
+++ b/src/gpu/GrYUVProvider.cpp
@@ -121,13 +121,12 @@
}
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 @@
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 81e955d..a894f98 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -1198,7 +1198,7 @@
// 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 @@
}
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 @@
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 @@
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 @@
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 4ba3c8d..8dc4926 100644
--- a/src/gpu/SkGpuDevice_drawTexture.cpp
+++ b/src/gpu/SkGpuDevice_drawTexture.cpp
@@ -204,7 +204,7 @@
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 fb2916d..ca7d6b8 100644
--- a/src/gpu/SkGr.cpp
+++ b/src/gpu/SkGr.cpp
@@ -506,7 +506,7 @@
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 @@
// 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 @@
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 @@
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 @@
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 @@
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 @@
/** 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 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 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 290c056..266cfff 100644
--- a/src/gpu/SkGrPriv.h
+++ b/src/gpu/SkGrPriv.h
@@ -62,7 +62,7 @@
no primitive color. */
bool SkPaintToGrPaintReplaceShader(GrContext*,
const SkPaint& skPaint,
- const GrFragmentProcessor* shaderFP,
+ sk_sp<GrFragmentProcessor> shaderFP,
bool allowSRGBInputs,
GrPaint* grPaint);
@@ -93,7 +93,7 @@
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 e875f1c..390162e 100644
--- a/src/gpu/batches/GrAAConvexPathRenderer.cpp
+++ b/src/gpu/batches/GrAAConvexPathRenderer.cpp
@@ -526,9 +526,9 @@
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 @@
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 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 @@
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 @@
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 @@
vertexBuffer, indexBuffer,
firstVertex, firstIndex,
tess.numPts(), tess.numIndices());
- target->draw(gp, mesh);
+ target->draw(gp.get(), mesh);
}
}
@@ -857,8 +857,8 @@
}
// 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 @@
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 ed9902c..e6be590 100644
--- a/src/gpu/batches/GrAADistanceFieldPathRenderer.cpp
+++ b/src/gpu/batches/GrAADistanceFieldPathRenderer.cpp
@@ -172,9 +172,9 @@
}
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 @@
// 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 @@
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 2c90b8b..94cef02 100644
--- a/src/gpu/batches/GrAAFillRectBatch.cpp
+++ b/src/gpu/batches/GrAAFillRectBatch.cpp
@@ -44,7 +44,7 @@
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 @@
// 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 @@
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 @@
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 ac5ecc1..f44c454 100644
--- a/src/gpu/batches/GrAAHairLinePathRenderer.cpp
+++ b/src/gpu/batches/GrAAHairLinePathRenderer.cpp
@@ -831,7 +831,7 @@
// do lines first
if (lineCount) {
- SkAutoTUnref<const GrGeometryProcessor> lineGP;
+ sk_sp<GrGeometryProcessor> lineGP;
{
using namespace GrDefaultGeoProcFactory;
@@ -840,8 +840,8 @@
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 @@
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()));
+ sk_sp<GrGeometryProcessor> quadGP(
+ GrQuadEffect::Make(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> conicGP(
+ GrConicEffect::Make(this->color(),
+ *geometryProcessorViewM,
+ kHairlineAA_GrProcessorEdgeType,
+ target->caps(),
+ *geometryProcessorLocalM,
+ this->usesLocalCoords(),
+ this->coverage()));
const GrBuffer* vertexBuffer;
int firstVertex;
@@ -927,7 +927,7 @@
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 @@
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 227f86b..1847a67 100644
--- a/src/gpu/batches/GrAALinearizingConvexPathRenderer.cpp
+++ b/src/gpu/batches/GrAALinearizingConvexPathRenderer.cpp
@@ -96,7 +96,7 @@
}
}
-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 @@
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 @@
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 @@
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 @@
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 cc54408..98b764a 100644
--- a/src/gpu/batches/GrAAStrokeRectBatch.cpp
+++ b/src/gpu/batches/GrAAStrokeRectBatch.cpp
@@ -21,7 +21,7 @@
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 @@
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::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 @@
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 32a64c3..3c4b4a5 100644
--- a/src/gpu/batches/GrAtlasTextBatch.cpp
+++ b/src/gpu/batches/GrAtlasTextBatch.cpp
@@ -100,17 +100,16 @@
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 @@
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 @@
// 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 @@
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 72e299d..89a2f4e 100644
--- a/src/gpu/batches/GrAtlasTextBatch.h
+++ b/src/gpu/batches/GrAtlasTextBatch.h
@@ -101,11 +101,11 @@
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 @@
// 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 c643c49..7fd7913 100644
--- a/src/gpu/batches/GrDefaultPathRenderer.cpp
+++ b/src/gpu/batches/GrDefaultPathRenderer.cpp
@@ -128,7 +128,7 @@
}
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 @@
}
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 @@
} 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 @@
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 58ce137..5b823a9 100644
--- a/src/gpu/batches/GrDrawAtlasBatch.cpp
+++ b/src/gpu/batches/GrDrawAtlasBatch.cpp
@@ -36,7 +36,7 @@
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 @@
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 @@
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 12ea05a..dd1ed62 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 @@
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::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 @@
} 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 cd2713e..edc285e 100644
--- a/src/gpu/batches/GrMSAAPathRenderer.cpp
+++ b/src/gpu/batches/GrMSAAPathRenderer.cpp
@@ -84,7 +84,7 @@
*(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 @@
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 @@
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 @@
const Attribute* fInUV;
const Attribute* fInColor;
SkMatrix fViewMatrix;
-
+
GR_DECLARE_GEOMETRY_PROCESSOR_TEST;
typedef GrGeometryProcessor INHERITED;
@@ -232,14 +232,14 @@
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 @@
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 @@
return;
}
- GrPrimitiveType primitiveType = fIsIndexed ? kTriangles_GrPrimitiveType
+ GrPrimitiveType primitiveType = fIsIndexed ? kTriangles_GrPrimitiveType
: kTriangleFan_GrPrimitiveType;
// allocate vertex / index buffers
@@ -327,9 +327,9 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 24e3dd6..5f53395 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 @@
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 @@
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 5e9d176..3b4c5da 100644
--- a/src/gpu/batches/GrNonAAFillRectBatch.cpp
+++ b/src/gpu/batches/GrNonAAFillRectBatch.cpp
@@ -51,10 +51,10 @@
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 @@
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 @@
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 @@
(!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 36092ea..a38760c 100644
--- a/src/gpu/batches/GrNonAAStrokeRectBatch.cpp
+++ b/src/gpu/batches/GrNonAAStrokeRectBatch.cpp
@@ -105,7 +105,7 @@
}
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 @@
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 @@
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 344748c..2a48018 100644
--- a/src/gpu/batches/GrStencilAndCoverPathRenderer.cpp
+++ b/src/gpu/batches/GrStencilAndCoverPathRenderer.cpp
@@ -72,7 +72,7 @@
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 b85b3aa..c501fd9 100644
--- a/src/gpu/batches/GrTInstanceBatch.h
+++ b/src/gpu/batches/GrTInstanceBatch.h
@@ -89,8 +89,7 @@
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 @@
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 e9c6e1e..6bc8549 100644
--- a/src/gpu/batches/GrTessellatingPathRenderer.cpp
+++ b/src/gpu/batches/GrTessellatingPathRenderer.cpp
@@ -211,7 +211,7 @@
}
void onPrepareDraws(Target* target) const override {
- SkAutoTUnref<const GrGeometryProcessor> gp;
+ sk_sp<GrGeometryProcessor> gp;
{
using namespace GrDefaultGeoProcFactory;
@@ -226,8 +226,7 @@
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 075ce16..9d3e8ee 100644
--- a/src/gpu/effects/GrBezierEffect.cpp
+++ b/src/gpu/effects/GrBezierEffect.cpp
@@ -272,15 +272,15 @@
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 @@
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 @@
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 ddb249b..50dca99 100644
--- a/src/gpu/effects/GrBezierEffect.h
+++ b/src/gpu/effects/GrBezierEffect.h
@@ -58,30 +58,33 @@
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 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 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 0a06b62..5e6967c 100644
--- a/src/gpu/effects/GrBicubicEffect.cpp
+++ b/src/gpu/effects/GrBicubicEffect.cpp
@@ -179,14 +179,14 @@
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 2087192..3c84f97 100644
--- a/src/gpu/effects/GrBicubicEffect.h
+++ b/src/gpu/effects/GrBicubicEffect.h
@@ -32,43 +32,46 @@
/**
* 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 246d7be..633a880 100644
--- a/src/gpu/effects/GrBitmapTextGeoProc.cpp
+++ b/src/gpu/effects/GrBitmapTextGeoProc.cpp
@@ -164,7 +164,7 @@
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 @@
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 @@
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 5501d93..226ae77 100644
--- a/src/gpu/effects/GrBitmapTextGeoProc.h
+++ b/src/gpu/effects/GrBitmapTextGeoProc.h
@@ -21,10 +21,11 @@
*/
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 9791cb4..d2fde96 100644
--- a/src/gpu/effects/GrConfigConversionEffect.cpp
+++ b/src/gpu/effects/GrConfigConversionEffect.cpp
@@ -125,14 +125,15 @@
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 @@
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 @@
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 @@
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 @@
}
}
-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 @@
// 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 65c55e7..93b49aa 100644
--- a/src/gpu/effects/GrConfigConversionEffect.h
+++ b/src/gpu/effects/GrConfigConversionEffect.h
@@ -33,8 +33,8 @@
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 c51ab8e..0684c9c 100644
--- a/src/gpu/effects/GrConstColorProcessor.cpp
+++ b/src/gpu/effects/GrConstColorProcessor.cpp
@@ -112,7 +112,7 @@
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 @@
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 caf86c2..5ce7867 100644
--- a/src/gpu/effects/GrConvexPolyEffect.cpp
+++ b/src/gpu/effects/GrConvexPolyEffect.cpp
@@ -19,8 +19,8 @@
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 @@
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 @@
//////////////////////////////////////////////////////////////////////////////
-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 @@
// 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 @@
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 @@
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 316f111..8fc76fe 100644
--- a/src/gpu/effects/GrConvexPolyEffect.h
+++ b/src/gpu/effects/GrConvexPolyEffect.h
@@ -38,12 +38,12 @@
* 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 @@
* 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 9567e4c..2266c47 100644
--- a/src/gpu/effects/GrConvolutionEffect.cpp
+++ b/src/gpu/effects/GrConvolutionEffect.cpp
@@ -213,7 +213,7 @@
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 @@
}
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 af58021..c353542 100644
--- a/src/gpu/effects/GrConvolutionEffect.h
+++ b/src/gpu/effects/GrConvolutionEffect.h
@@ -21,23 +21,25 @@
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 c0ba62f..90657ea 100644
--- a/src/gpu/effects/GrCoverageSetOpXP.cpp
+++ b/src/gpu/effects/GrCoverageSetOpXP.cpp
@@ -243,65 +243,65 @@
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 @@
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 50fe5cb..1b94a6b 100644
--- a/src/gpu/effects/GrCustomXfermode.cpp
+++ b/src/gpu/effects/GrCustomXfermode.cpp
@@ -382,19 +382,19 @@
}
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 8a7cb5e..ae37540 100644
--- a/src/gpu/effects/GrDashingEffect.cpp
+++ b/src/gpu/effects/GrDashingEffect.cpp
@@ -232,11 +232,11 @@
* 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 @@
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 @@
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 @@
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 @@
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 @@
//////////////////////////////////////////////////////////////////////////////
-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 @@
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 @@
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 @@
//////////////////////////////////////////////////////////////////////////////
-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 @@
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 @@
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 7d776e7..1ff8ad6 100644
--- a/src/gpu/effects/GrDisableColorXP.cpp
+++ b/src/gpu/effects/GrDisableColorXP.cpp
@@ -104,6 +104,6 @@
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 5584954..4aed6b6 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 e87021e..f43a1e8 100644
--- a/src/gpu/effects/GrDistanceFieldGeoProc.cpp
+++ b/src/gpu/effects/GrDistanceFieldGeoProc.cpp
@@ -260,7 +260,7 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 406c352..0f6d8c1 100644
--- a/src/gpu/effects/GrDistanceFieldGeoProc.h
+++ b/src/gpu/effects/GrDistanceFieldGeoProc.h
@@ -49,18 +49,20 @@
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 @@
*/
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 @@
}
};
- 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 39d4063..abce5ca 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 @@
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 @@
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 64c85f7..b92723d 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 @@
/**
* 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 71d8c91..63ffc32 100644
--- a/src/gpu/effects/GrGammaEffect.cpp
+++ b/src/gpu/effects/GrGammaEffect.cpp
@@ -116,11 +116,11 @@
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 @@
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 2e53b09..3f84ac9 100644
--- a/src/gpu/effects/GrGammaEffect.h
+++ b/src/gpu/effects/GrGammaEffect.h
@@ -21,7 +21,7 @@
/**
* 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 60f518b..5422755 100644
--- a/src/gpu/effects/GrMatrixConvolutionEffect.cpp
+++ b/src/gpu/effects/GrMatrixConvolutionEffect.cpp
@@ -191,17 +191,17 @@
}
// 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 @@
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 @@
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 066da65..b8df437 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 3e6287b..a288537 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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
//////////////////////////////////////////////////////////////////////////////
-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 @@
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 8f85365..3ff241a 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 @@
/**
* 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 8168de6..9aae026 100644
--- a/src/gpu/effects/GrPorterDuffXferProcessor.cpp
+++ b/src/gpu/effects/GrPorterDuffXferProcessor.cpp
@@ -704,7 +704,7 @@
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 @@
if (xfermode < 0 || xfermode > SkXfermode::kLastCoeffMode) {
return nullptr;
}
- return SkRef(gFactories[xfermode]);
+ return sk_sp<GrXPFactory>(SkRef(gFactories[xfermode]));
}
GrXferProcessor*
@@ -826,9 +826,9 @@
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 d1d811d..14d03dd 100644
--- a/src/gpu/effects/GrRRectEffect.cpp
+++ b/src/gpu/effects/GrRRectEffect.cpp
@@ -45,8 +45,8 @@
// 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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
//////////////////////////////////////////////////////////////////////////////
-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 @@
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 @@
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 63e08a4..6ff2cc9 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 @@
* 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 f4cbd06..7e7b828 100644
--- a/src/gpu/effects/GrSimpleTextureEffect.cpp
+++ b/src/gpu/effects/GrSimpleTextureEffect.cpp
@@ -46,7 +46,7 @@
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 @@
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 18a8a78..08eb8c1 100644
--- a/src/gpu/effects/GrSimpleTextureEffect.h
+++ b/src/gpu/effects/GrSimpleTextureEffect.h
@@ -21,25 +21,27 @@
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 cf6ebe5..3fbf000 100644
--- a/src/gpu/effects/GrTextureDomain.cpp
+++ b/src/gpu/effects/GrTextureDomain.cpp
@@ -218,18 +218,19 @@
///////////////////////////////////////////////////////////////////////////////
-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 @@
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 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 387016e..a86ce95 100644
--- a/src/gpu/effects/GrTextureDomain.h
+++ b/src/gpu/effects/GrTextureDomain.h
@@ -166,12 +166,12 @@
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 a881999..051061f 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 @@
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 @@
}
}
-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 @@
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 @@
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 @@
//////////////////////////////////////////////////////////////////////////////
-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 97ef663..94dca84 100644
--- a/src/gpu/effects/GrYUVEffect.cpp
+++ b/src/gpu/effects/GrYUVEffect.cpp
@@ -62,9 +62,9 @@
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 @@
(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 @@
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 @@
//////////////////////////////////////////////////////////////////////////////
-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 4f3848e..6d3b158 100644
--- a/src/gpu/effects/GrYUVEffect.h
+++ b/src/gpu/effects/GrYUVEffect.h
@@ -18,33 +18,33 @@
* 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