diff options
Diffstat (limited to 'src')
61 files changed, 567 insertions, 517 deletions
diff --git a/src/gpu/GrDrawOpTest.cpp b/src/gpu/GrDrawOpTest.cpp index bb26acc696..3cf1a90b8e 100644 --- a/src/gpu/GrDrawOpTest.cpp +++ b/src/gpu/GrDrawOpTest.cpp @@ -12,7 +12,8 @@ #ifdef GR_TEST_UTILS -#define DRAW_OP_TEST_EXTERN(Op) extern sk_sp<GrDrawOp> Op##__Test(SkRandom*, GrContext* context); +#define DRAW_OP_TEST_EXTERN(Op) \ + extern std::unique_ptr<GrDrawOp> Op##__Test(SkRandom*, GrContext* context); #define DRAW_OP_TEST_ENTRY(Op) Op##__Test @@ -37,8 +38,8 @@ DRAW_OP_TEST_EXTERN(TesselatingPathOp); DRAW_OP_TEST_EXTERN(TextBlobOp); DRAW_OP_TEST_EXTERN(VerticesOp); -sk_sp<GrDrawOp> GrRandomDrawOp(SkRandom* random, GrContext* context) { - using MakeTestDrawOpFn = sk_sp<GrDrawOp>(SkRandom* random, GrContext* context); +std::unique_ptr<GrDrawOp> GrRandomDrawOp(SkRandom* random, GrContext* context) { + using MakeTestDrawOpFn = std::unique_ptr<GrDrawOp>(SkRandom* random, GrContext* context); static constexpr MakeTestDrawOpFn* gFactories[] = { DRAW_OP_TEST_ENTRY(AAConvexPathOp), DRAW_OP_TEST_ENTRY(AADistanceFieldPathOp), diff --git a/src/gpu/GrDrawOpTest.h b/src/gpu/GrDrawOpTest.h index 0d88a40bf1..46abf18283 100644 --- a/src/gpu/GrDrawOpTest.h +++ b/src/gpu/GrDrawOpTest.h @@ -18,14 +18,15 @@ class GrContext; class SkRandom; /** This function returns a randomly configured GrDrawOp for testing purposes. */ -sk_sp<GrDrawOp> GrRandomDrawOp(SkRandom*, GrContext*); +std::unique_ptr<GrDrawOp> GrRandomDrawOp(SkRandom*, GrContext*); /** GrDrawOp subclasses should define test factory functions using this macro. */ -#define DRAW_OP_TEST_DEFINE(Op) sk_sp<GrDrawOp> Op##__Test(SkRandom* random, GrContext* context) +#define DRAW_OP_TEST_DEFINE(Op) \ + std::unique_ptr<GrDrawOp> Op##__Test(SkRandom* random, GrContext* context) /** This macro may be used if the test factory function must be made a friend of a class. */ #define DRAW_OP_TEST_FRIEND(Op) \ - friend sk_sp<GrDrawOp> Op##__Test(SkRandom* random, GrContext* context); + friend std::unique_ptr<GrDrawOp> Op##__Test(SkRandom* random, GrContext* context); #endif #endif diff --git a/src/gpu/GrRenderTargetContext.cpp b/src/gpu/GrRenderTargetContext.cpp index 93e86078fc..e9325fafec 100644 --- a/src/gpu/GrRenderTargetContext.cpp +++ b/src/gpu/GrRenderTargetContext.cpp @@ -284,8 +284,8 @@ void GrRenderTargetContextPriv::absClear(const SkIRect* clearRect, const GrColor // This path doesn't handle coalescing of full screen clears b.c. it // has to clear the entire render target - not just the content area. // It could be done but will take more finagling. - sk_sp<GrOp> op(GrClearOp::Make(rtRect, color, fRenderTargetContext->accessRenderTarget(), - !clearRect)); + std::unique_ptr<GrOp> op(GrClearOp::Make( + rtRect, color, fRenderTargetContext->accessRenderTarget(), !clearRect)); if (!op) { return; } @@ -340,7 +340,7 @@ void GrRenderTargetContext::internalClear(const GrFixedClip& clip, if (!this->accessRenderTarget()) { return; } - sk_sp<GrOp> op(GrClearOp::Make(clip, color, this->accessRenderTarget())); + std::unique_ptr<GrOp> op(GrClearOp::Make(clip, color, this->accessRenderTarget())); if (!op) { return; } @@ -464,7 +464,7 @@ bool GrRenderTargetContext::drawFilledRect(const GrClip& clip, return true; } - sk_sp<GrDrawOp> op; + std::unique_ptr<GrDrawOp> op; GrAAType aaType; if (GrCaps::InstancedSupport::kNone != fContext->caps()->instancedSupport()) { @@ -593,7 +593,7 @@ void GrRenderTargetContext::drawRect(const GrClip& clip, } bool snapToPixelCenters = false; - sk_sp<GrDrawOp> op; + std::unique_ptr<GrDrawOp> op; GrColor color = paint.getColor(); GrAAType aaType = this->decideAAType(aa); @@ -731,8 +731,9 @@ void GrRenderTargetContext::fillRectToRect(const GrClip& clip, if (GrCaps::InstancedSupport::kNone != fContext->caps()->instancedSupport()) { InstancedRendering* ir = this->getOpList()->instancedRendering(); - sk_sp<GrDrawOp> op(ir->recordRect(croppedRect, viewMatrix, paint.getColor(), - croppedLocalRect, aa, fInstancedPipelineInfo, &aaType)); + std::unique_ptr<GrDrawOp> op(ir->recordRect(croppedRect, viewMatrix, paint.getColor(), + croppedLocalRect, aa, fInstancedPipelineInfo, + &aaType)); if (op) { GrPipelineBuilder pipelineBuilder(paint, aaType); this->getOpList()->addDrawOp(pipelineBuilder, this, clip, std::move(op)); @@ -748,8 +749,8 @@ void GrRenderTargetContext::fillRectToRect(const GrClip& clip, } if (view_matrix_ok_for_aa_fill_rect(viewMatrix)) { - sk_sp<GrDrawOp> op = GrAAFillRectOp::MakeWithLocalRect(paint.getColor(), viewMatrix, - croppedRect, croppedLocalRect); + std::unique_ptr<GrDrawOp> op = GrAAFillRectOp::MakeWithLocalRect( + paint.getColor(), viewMatrix, croppedRect, croppedLocalRect); GrPipelineBuilder pipelineBuilder(paint, aaType); this->addDrawOp(pipelineBuilder, clip, std::move(op)); return; @@ -789,8 +790,9 @@ void GrRenderTargetContext::fillRectWithLocalMatrix(const GrClip& clip, if (GrCaps::InstancedSupport::kNone != fContext->caps()->instancedSupport()) { InstancedRendering* ir = this->getOpList()->instancedRendering(); - sk_sp<GrDrawOp> op(ir->recordRect(croppedRect, viewMatrix, paint.getColor(), localMatrix, - aa, fInstancedPipelineInfo, &aaType)); + std::unique_ptr<GrDrawOp> op(ir->recordRect(croppedRect, viewMatrix, paint.getColor(), + localMatrix, aa, fInstancedPipelineInfo, + &aaType)); if (op) { GrPipelineBuilder pipelineBuilder(paint, aaType); this->getOpList()->addDrawOp(pipelineBuilder, this, clip, std::move(op)); @@ -806,7 +808,7 @@ void GrRenderTargetContext::fillRectWithLocalMatrix(const GrClip& clip, } if (view_matrix_ok_for_aa_fill_rect(viewMatrix)) { - sk_sp<GrDrawOp> op = + std::unique_ptr<GrDrawOp> op = GrAAFillRectOp::Make(paint.getColor(), viewMatrix, localMatrix, croppedRect); GrPipelineBuilder pipelineBuilder(paint, aaType); this->getOpList()->addDrawOp(pipelineBuilder, this, clip, std::move(op)); @@ -853,7 +855,7 @@ void GrRenderTargetContext::drawVertices(const GrClip& clip, viewMatrix.mapRect(&bounds); - sk_sp<GrDrawOp> op = + std::unique_ptr<GrDrawOp> op = GrDrawVerticesOp::Make(paint.getColor(), primitiveType, viewMatrix, positions, vertexCount, indices, indexCount, colors, texCoords, bounds); @@ -877,7 +879,7 @@ void GrRenderTargetContext::drawAtlas(const GrClip& clip, AutoCheckFlush acf(fDrawingManager); - sk_sp<GrDrawOp> op = + std::unique_ptr<GrDrawOp> op = GrDrawAtlasOp::Make(paint.getColor(), viewMatrix, spriteCount, xform, texRect, colors); GrPipelineBuilder pipelineBuilder(paint, GrAAType::kNone); this->getOpList()->addDrawOp(pipelineBuilder, this, clip, std::move(op)); @@ -921,8 +923,8 @@ void GrRenderTargetContext::drawRRect(const GrClip& origClip, if (GrCaps::InstancedSupport::kNone != fContext->caps()->instancedSupport() && stroke.isFillStyle()) { InstancedRendering* ir = this->getOpList()->instancedRendering(); - sk_sp<GrDrawOp> op(ir->recordRRect(rrect, viewMatrix, paint.getColor(), aa, - fInstancedPipelineInfo, &aaType)); + std::unique_ptr<GrDrawOp> op(ir->recordRRect(rrect, viewMatrix, paint.getColor(), aa, + fInstancedPipelineInfo, &aaType)); if (op) { GrPipelineBuilder pipelineBuilder(paint, aaType); this->getOpList()->addDrawOp(pipelineBuilder, this, *clip, std::move(op)); @@ -933,12 +935,12 @@ void GrRenderTargetContext::drawRRect(const GrClip& origClip, aaType = this->decideAAType(aa); if (GrAAType::kCoverage == aaType) { const GrShaderCaps* shaderCaps = fContext->caps()->shaderCaps(); - sk_sp<GrDrawOp> op = GrOvalOpFactory::MakeRRectOp(paint.getColor(), - paint.usesDistanceVectorField(), - viewMatrix, - rrect, - stroke, - shaderCaps); + std::unique_ptr<GrDrawOp> op = GrOvalOpFactory::MakeRRectOp(paint.getColor(), + paint.usesDistanceVectorField(), + viewMatrix, + rrect, + stroke, + shaderCaps); if (op) { GrPipelineBuilder pipelineBuilder(paint, aaType); this->getOpList()->addDrawOp(pipelineBuilder, this, *clip, std::move(op)); @@ -975,8 +977,8 @@ void GrRenderTargetContext::drawShadowRRect(const GrClip& clip, // TODO: add instancing support? const GrShaderCaps* shaderCaps = fContext->caps()->shaderCaps(); - sk_sp<GrDrawOp> op = GrShadowRRectOp::Make(paint.getColor(), viewMatrix, rrect, blurRadius, - stroke, shaderCaps); + std::unique_ptr<GrDrawOp> op = GrShadowRRectOp::Make(paint.getColor(), viewMatrix, rrect, + blurRadius, stroke, shaderCaps); if (op) { GrPipelineBuilder pipelineBuilder(paint, GrAAType::kNone); this->getOpList()->addDrawOp(pipelineBuilder, this, clip, std::move(op)); @@ -998,8 +1000,9 @@ bool GrRenderTargetContext::drawFilledDRRect(const GrClip& clip, if (GrCaps::InstancedSupport::kNone != fContext->caps()->instancedSupport()) { InstancedRendering* ir = this->getOpList()->instancedRendering(); - sk_sp<GrDrawOp> op(ir->recordDRRect(origOuter, origInner, viewMatrix, paintIn.getColor(), - aa, fInstancedPipelineInfo, &aaType)); + std::unique_ptr<GrDrawOp> op(ir->recordDRRect(origOuter, origInner, viewMatrix, + paintIn.getColor(), aa, + fInstancedPipelineInfo, &aaType)); if (op) { GrPipelineBuilder pipelineBuilder(paintIn, aaType); this->getOpList()->addDrawOp(pipelineBuilder, this, clip, std::move(op)); @@ -1121,7 +1124,7 @@ void GrRenderTargetContext::drawRegion(const GrClip& clip, return this->drawPath(clip, paint, aa, viewMatrix, path, style); } - sk_sp<GrDrawOp> op = GrRegionOp::Make(paint.getColor(), viewMatrix, region); + std::unique_ptr<GrDrawOp> op = GrRegionOp::Make(paint.getColor(), viewMatrix, region); GrPipelineBuilder pipelineBuilder(paint, GrAAType::kNone); this->getOpList()->addDrawOp(pipelineBuilder, this, clip, std::move(op)); } @@ -1150,8 +1153,8 @@ void GrRenderTargetContext::drawOval(const GrClip& clip, if (GrCaps::InstancedSupport::kNone != fContext->caps()->instancedSupport() && stroke.isFillStyle()) { InstancedRendering* ir = this->getOpList()->instancedRendering(); - sk_sp<GrDrawOp> op(ir->recordOval(oval, viewMatrix, paint.getColor(), aa, - fInstancedPipelineInfo, &aaType)); + std::unique_ptr<GrDrawOp> op(ir->recordOval(oval, viewMatrix, paint.getColor(), aa, + fInstancedPipelineInfo, &aaType)); if (op) { GrPipelineBuilder pipelineBuilder(paint, aaType); this->getOpList()->addDrawOp(pipelineBuilder, this, clip, std::move(op)); @@ -1162,7 +1165,7 @@ void GrRenderTargetContext::drawOval(const GrClip& clip, aaType = this->decideAAType(aa); if (GrAAType::kCoverage == aaType) { const GrShaderCaps* shaderCaps = fContext->caps()->shaderCaps(); - sk_sp<GrDrawOp> op = + std::unique_ptr<GrDrawOp> op = GrOvalOpFactory::MakeOvalOp(paint.getColor(), viewMatrix, oval, stroke, shaderCaps); if (op) { GrPipelineBuilder pipelineBuilder(paint, aaType); @@ -1189,14 +1192,14 @@ void GrRenderTargetContext::drawArc(const GrClip& clip, GrAAType aaType = this->decideAAType(aa); if (GrAAType::kCoverage == aaType) { const GrShaderCaps* shaderCaps = fContext->caps()->shaderCaps(); - sk_sp<GrDrawOp> op = GrOvalOpFactory::MakeArcOp(paint.getColor(), - viewMatrix, - oval, - startAngle, - sweepAngle, - useCenter, - style, - shaderCaps); + std::unique_ptr<GrDrawOp> op = GrOvalOpFactory::MakeArcOp(paint.getColor(), + viewMatrix, + oval, + startAngle, + sweepAngle, + useCenter, + style, + shaderCaps); if (op) { GrPipelineBuilder pipelineBuilder(paint, aaType); this->getOpList()->addDrawOp(pipelineBuilder, this, clip, std::move(op)); @@ -1223,8 +1226,8 @@ void GrRenderTargetContext::drawImageLattice(const GrClip& clip, AutoCheckFlush acf(fDrawingManager); - sk_sp<GrDrawOp> op = GrLatticeOp::MakeNonAA(paint.getColor(), viewMatrix, imageWidth, - imageHeight, std::move(iter), dst); + std::unique_ptr<GrDrawOp> op = GrLatticeOp::MakeNonAA(paint.getColor(), viewMatrix, imageWidth, + imageHeight, std::move(iter), dst); GrPipelineBuilder pipelineBuilder(paint, GrAAType::kNone); this->getOpList()->addDrawOp(pipelineBuilder, this, clip, std::move(op)); @@ -1258,8 +1261,8 @@ void GrRenderTargetContext::drawNonAAFilledRect(const GrClip& clip, GrAAType hwOrNoneAAType) { SkASSERT(GrAAType::kCoverage != hwOrNoneAAType); SkASSERT(hwOrNoneAAType == GrAAType::kNone || this->isStencilBufferMultisampled()); - sk_sp<GrDrawOp> op = GrRectOpFactory::MakeNonAAFill(paint.getColor(), viewMatrix, rect, - localRect, localMatrix); + std::unique_ptr<GrDrawOp> op = GrRectOpFactory::MakeNonAAFill(paint.getColor(), viewMatrix, + rect, localRect, localMatrix); GrPipelineBuilder pipelineBuilder(paint, hwOrNoneAAType); if (ss) { pipelineBuilder.setUserStencil(ss); @@ -1387,7 +1390,7 @@ void GrRenderTargetContext::drawPath(const GrClip& clip, SkRect rects[2]; if (fills_as_nested_rects(viewMatrix, path, rects)) { - sk_sp<GrDrawOp> op = + std::unique_ptr<GrDrawOp> op = GrRectOpFactory::MakeAAFillNestedRects(paint.getColor(), viewMatrix, rects); if (op) { GrPipelineBuilder pipelineBuilder(paint, aaType); @@ -1401,7 +1404,7 @@ void GrRenderTargetContext::drawPath(const GrClip& clip, if (isOval && !path.isInverseFillType()) { const GrShaderCaps* shaderCaps = fContext->caps()->shaderCaps(); - sk_sp<GrDrawOp> op = GrOvalOpFactory::MakeOvalOp( + std::unique_ptr<GrDrawOp> op = GrOvalOpFactory::MakeOvalOp( paint.getColor(), viewMatrix, ovalRect, style.strokeRec(), shaderCaps); if (op) { GrPipelineBuilder pipelineBuilder(paint, aaType); @@ -1580,7 +1583,7 @@ void GrRenderTargetContext::internalDrawPath(const GrClip& clip, } void GrRenderTargetContext::addDrawOp(const GrPipelineBuilder& pipelineBuilder, const GrClip& clip, - sk_sp<GrDrawOp> op) { + std::unique_ptr<GrDrawOp> op) { ASSERT_SINGLE_OWNER RETURN_IF_ABANDONED SkDEBUGCODE(this->validate();) diff --git a/src/gpu/GrRenderTargetContextPriv.h b/src/gpu/GrRenderTargetContextPriv.h index f1548cc9fa..19ee9dafac 100644 --- a/src/gpu/GrRenderTargetContextPriv.h +++ b/src/gpu/GrRenderTargetContextPriv.h @@ -110,7 +110,7 @@ public: void testingOnly_addDrawOp(const GrPaint&, GrAAType, - sk_sp<GrDrawOp>, + std::unique_ptr<GrDrawOp>, const GrUserStencilSettings* = nullptr, bool snapToCenters = false); diff --git a/src/gpu/GrRenderTargetOpList.cpp b/src/gpu/GrRenderTargetOpList.cpp index 0e74ad1b79..9fb2dcbd1c 100644 --- a/src/gpu/GrRenderTargetOpList.cpp +++ b/src/gpu/GrRenderTargetOpList.cpp @@ -264,7 +264,8 @@ static void op_bounds(SkRect* bounds, const GrOp* op) { void GrRenderTargetOpList::addDrawOp(const GrPipelineBuilder& pipelineBuilder, GrRenderTargetContext* renderTargetContext, const GrClip& clip, - sk_sp<GrDrawOp> op) { + std::unique_ptr<GrDrawOp> + op) { // Setup clip SkRect bounds; op_bounds(&bounds, op.get()); @@ -384,14 +385,14 @@ void GrRenderTargetOpList::stencilPath(GrRenderTargetContext* renderTargetContex return; } - sk_sp<GrOp> op = GrStencilPathOp::Make(viewMatrix, - useHWAA, - path->getFillType(), - appliedClip.hasStencilClip(), - stencilAttachment->bits(), - appliedClip.scissorState(), - renderTargetContext->accessRenderTarget(), - path); + std::unique_ptr<GrOp> op = GrStencilPathOp::Make(viewMatrix, + useHWAA, + path->getFillType(), + appliedClip.hasStencilClip(), + stencilAttachment->bits(), + appliedClip.scissorState(), + renderTargetContext->accessRenderTarget(), + path); this->recordOp(std::move(op), renderTargetContext, appliedClip.clippedDrawBounds()); } @@ -408,7 +409,7 @@ void GrRenderTargetOpList::fullClear(GrRenderTargetContext* renderTargetContext, fLastFullClearOp->setColor(color); return; } - sk_sp<GrClearOp> op(GrClearOp::Make(GrFixedClip::Disabled(), color, renderTarget)); + std::unique_ptr<GrClearOp> op(GrClearOp::Make(GrFixedClip::Disabled(), color, renderTarget)); if (GrOp* clearOp = this->recordOp(std::move(op), renderTargetContext)) { // This is either the clear op we just created or another one that it combined with. fLastFullClearOp = static_cast<GrClearOp*>(clearOp); @@ -431,7 +432,7 @@ bool GrRenderTargetOpList::copySurface(GrSurface* dst, GrSurface* src, const SkIRect& srcRect, const SkIPoint& dstPoint) { - sk_sp<GrOp> op = GrCopySurfaceOp::Make(dst, src, srcRect, dstPoint); + std::unique_ptr<GrOp> op = GrCopySurfaceOp::Make(dst, src, srcRect, dstPoint); if (!op) { return false; } @@ -460,7 +461,8 @@ static void join(SkRect* out, const SkRect& a, const SkRect& b) { out->fBottom = SkTMax(a.fBottom, b.fBottom); } -GrOp* GrRenderTargetOpList::recordOp(sk_sp<GrOp> op, GrRenderTargetContext* renderTargetContext, +GrOp* GrRenderTargetOpList::recordOp(std::unique_ptr<GrOp> op, + GrRenderTargetContext* renderTargetContext, const SkRect& clippedBounds) { // TODO: Should be proxy ID. GrGpuResource::UniqueID renderTargetID = diff --git a/src/gpu/GrRenderTargetOpList.h b/src/gpu/GrRenderTargetOpList.h index a66686040b..216a3303cd 100644 --- a/src/gpu/GrRenderTargetOpList.h +++ b/src/gpu/GrRenderTargetOpList.h @@ -79,9 +79,9 @@ public: const GrCaps* caps() const { return fGpu->caps(); } void addDrawOp(const GrPipelineBuilder&, GrRenderTargetContext*, const GrClip&, - sk_sp<GrDrawOp>); + std::unique_ptr<GrDrawOp>); - void addOp(sk_sp<GrOp> op, GrRenderTargetContext* renderTargetContext) { + void addOp(std::unique_ptr<GrOp> op, GrRenderTargetContext* renderTargetContext) { this->recordOp(std::move(op), renderTargetContext); } @@ -133,13 +133,13 @@ private: // If the input op is combined with an earlier op, this returns the combined op. Otherwise, it // returns the input op. - GrOp* recordOp(sk_sp<GrOp> op, GrRenderTargetContext* renderTargetContext) { + GrOp* recordOp(std::unique_ptr<GrOp> op, GrRenderTargetContext* renderTargetContext) { SkRect bounds = op->bounds(); return this->recordOp(std::move(op), renderTargetContext, bounds); } // Variant that allows an explicit bounds (computed from the Op's bounds and a clip). - GrOp* recordOp(sk_sp<GrOp>, GrRenderTargetContext*, const SkRect& clippedBounds); + GrOp* recordOp(std::unique_ptr<GrOp>, GrRenderTargetContext*, const SkRect& clippedBounds); void forwardCombine(); @@ -155,7 +155,7 @@ private: void clearStencilClip(const GrFixedClip&, bool insideStencilMask, GrRenderTargetContext*); struct RecordedOp { - sk_sp<GrOp> fOp; + std::unique_ptr<GrOp> fOp; SkRect fClippedBounds; // TODO: Use proxy ID instead of instantiated render target ID. GrGpuResource::UniqueID fRenderTargetID; diff --git a/src/gpu/GrSWMaskHelper.cpp b/src/gpu/GrSWMaskHelper.cpp index be56ad5266..10343a35de 100644 --- a/src/gpu/GrSWMaskHelper.cpp +++ b/src/gpu/GrSWMaskHelper.cpp @@ -190,7 +190,7 @@ void GrSWMaskHelper::DrawToTargetWithShapeMask(GrTexture* texture, maskMatrix, GrSamplerParams::kNone_FilterMode)); - sk_sp<GrDrawOp> op = GrRectOpFactory::MakeNonAAFill(paint.getColor(), SkMatrix::I(), dstRect, - nullptr, &invert); + std::unique_ptr<GrDrawOp> op = GrRectOpFactory::MakeNonAAFill(paint.getColor(), SkMatrix::I(), + dstRect, nullptr, &invert); renderTargetContext->addDrawOp(pipelineBuilder, clip, std::move(op)); } diff --git a/src/gpu/GrSoftwarePathRenderer.cpp b/src/gpu/GrSoftwarePathRenderer.cpp index fc529ba51f..490d00e64a 100644 --- a/src/gpu/GrSoftwarePathRenderer.cpp +++ b/src/gpu/GrSoftwarePathRenderer.cpp @@ -77,8 +77,8 @@ void GrSoftwarePathRenderer::DrawNonAARect(GrRenderTargetContext* renderTargetCo const SkMatrix& viewMatrix, const SkRect& rect, const SkMatrix& localMatrix) { - sk_sp<GrDrawOp> op(GrRectOpFactory::MakeNonAAFill(paint.getColor(), viewMatrix, rect, nullptr, - &localMatrix)); + std::unique_ptr<GrDrawOp> op(GrRectOpFactory::MakeNonAAFill(paint.getColor(), viewMatrix, rect, + nullptr, &localMatrix)); GrPipelineBuilder pipelineBuilder(paint, GrAAType::kNone); pipelineBuilder.setUserStencil(&userStencilSettings); diff --git a/src/gpu/GrTextureOpList.cpp b/src/gpu/GrTextureOpList.cpp index 2aaa8ca200..61990ded4d 100644 --- a/src/gpu/GrTextureOpList.cpp +++ b/src/gpu/GrTextureOpList.cpp @@ -82,7 +82,7 @@ bool GrTextureOpList::copySurface(GrSurface* dst, GrSurface* src, const SkIRect& srcRect, const SkIPoint& dstPoint) { - sk_sp<GrOp> op = GrCopySurfaceOp::Make(dst, src, srcRect, dstPoint); + std::unique_ptr<GrOp> op = GrCopySurfaceOp::Make(dst, src, srcRect, dstPoint); if (!op) { return false; } @@ -95,7 +95,7 @@ bool GrTextureOpList::copySurface(GrSurface* dst, return true; } -void GrTextureOpList::recordOp(sk_sp<GrOp> op, GrGpuResource::UniqueID renderTargetID) { +void GrTextureOpList::recordOp(std::unique_ptr<GrOp> op, GrGpuResource::UniqueID renderTargetID) { // A closed GrOpList should never receive new/more ops SkASSERT(!this->isClosed()); diff --git a/src/gpu/GrTextureOpList.h b/src/gpu/GrTextureOpList.h index ccfa1fbb7e..325ab5d7dc 100644 --- a/src/gpu/GrTextureOpList.h +++ b/src/gpu/GrTextureOpList.h @@ -62,9 +62,9 @@ public: private: // The unique ID is only needed for the audit trail. This should be removed with MDB. - void recordOp(sk_sp<GrOp>, GrGpuResource::UniqueID renderTargetID); + void recordOp(std::unique_ptr<GrOp>, GrGpuResource::UniqueID renderTargetID); - SkSTArray<2, sk_sp<GrOp>, true> fRecordedOps; + SkSTArray<2, std::unique_ptr<GrOp>, true> fRecordedOps; GrGpu* fGpu; typedef GrOpList INHERITED; diff --git a/src/gpu/instanced/GLInstancedRendering.cpp b/src/gpu/instanced/GLInstancedRendering.cpp index da764b2d2e..0d2a2ddb9c 100644 --- a/src/gpu/instanced/GLInstancedRendering.cpp +++ b/src/gpu/instanced/GLInstancedRendering.cpp @@ -60,7 +60,9 @@ inline GrGLGpu* GLInstancedRendering::glGpu() const { return static_cast<GrGLGpu*>(this->gpu()); } -sk_sp<InstancedRendering::Op> GLInstancedRendering::makeOp() { return sk_sp<Op>(new GLOp(this)); } +std::unique_ptr<InstancedRendering::Op> GLInstancedRendering::makeOp() { + return std::unique_ptr<Op>(new GLOp(this)); +} void GLInstancedRendering::onBeginFlush(GrResourceProvider* rp) { // Count what there is to draw. diff --git a/src/gpu/instanced/GLInstancedRendering.h b/src/gpu/instanced/GLInstancedRendering.h index c77b61db7e..0088217bb2 100644 --- a/src/gpu/instanced/GLInstancedRendering.h +++ b/src/gpu/instanced/GLInstancedRendering.h @@ -33,7 +33,7 @@ private: GrGLGpu* glGpu() const; - sk_sp<Op> makeOp() override; + std::unique_ptr<Op> makeOp() override; void onBeginFlush(GrResourceProvider*) override; void onDraw(const GrPipeline&, const InstanceProcessor&, const Op*) override; diff --git a/src/gpu/instanced/InstancedRendering.cpp b/src/gpu/instanced/InstancedRendering.cpp index 08fdf3e7d3..52a48cb01a 100644 --- a/src/gpu/instanced/InstancedRendering.cpp +++ b/src/gpu/instanced/InstancedRendering.cpp @@ -21,30 +21,33 @@ InstancedRendering::InstancedRendering(GrGpu* gpu) fDrawPool(1024, 1024) { } -sk_sp<GrDrawOp> InstancedRendering::recordRect(const SkRect& rect, const SkMatrix& viewMatrix, - GrColor color, GrAA aa, - const GrInstancedPipelineInfo& info, - GrAAType* aaType) { +std::unique_ptr<GrDrawOp> InstancedRendering::recordRect(const SkRect& rect, + const SkMatrix& viewMatrix, GrColor color, + GrAA aa, + const GrInstancedPipelineInfo& info, + GrAAType* aaType) { return this->recordShape(ShapeType::kRect, rect, viewMatrix, color, rect, aa, info, aaType); } -sk_sp<GrDrawOp> InstancedRendering::recordRect(const SkRect& rect, const SkMatrix& viewMatrix, - GrColor color, const SkRect& localRect, GrAA aa, - const GrInstancedPipelineInfo& info, - GrAAType* aaType) { +std::unique_ptr<GrDrawOp> InstancedRendering::recordRect(const SkRect& rect, + const SkMatrix& viewMatrix, GrColor color, + const SkRect& localRect, GrAA aa, + const GrInstancedPipelineInfo& info, + GrAAType* aaType) { return this->recordShape(ShapeType::kRect, rect, viewMatrix, color, localRect, aa, info, aaType); } -sk_sp<GrDrawOp> InstancedRendering::recordRect(const SkRect& rect, const SkMatrix& viewMatrix, - GrColor color, const SkMatrix& localMatrix, GrAA aa, - const GrInstancedPipelineInfo& info, - GrAAType* aaType) { +std::unique_ptr<GrDrawOp> InstancedRendering::recordRect(const SkRect& rect, + const SkMatrix& viewMatrix, GrColor color, + const SkMatrix& localMatrix, GrAA aa, + const GrInstancedPipelineInfo& info, + GrAAType* aaType) { if (localMatrix.hasPerspective()) { return nullptr; // Perspective is not yet supported in the local matrix. } - if (sk_sp<Op> op = this->recordShape(ShapeType::kRect, rect, viewMatrix, color, rect, aa, info, - aaType)) { + if (std::unique_ptr<Op> op = this->recordShape(ShapeType::kRect, rect, viewMatrix, color, rect, + aa, info, aaType)) { op->getSingleInstance().fInfo |= kLocalMatrix_InfoFlag; op->appendParamsTexel(localMatrix.getScaleX(), localMatrix.getSkewX(), localMatrix.getTranslateX()); @@ -56,37 +59,40 @@ sk_sp<GrDrawOp> InstancedRendering::recordRect(const SkRect& rect, const SkMatri return nullptr; } -sk_sp<GrDrawOp> InstancedRendering::recordOval(const SkRect& oval, const SkMatrix& viewMatrix, - GrColor color, GrAA aa, - const GrInstancedPipelineInfo& info, - GrAAType* aaType) { +std::unique_ptr<GrDrawOp> InstancedRendering::recordOval(const SkRect& oval, + const SkMatrix& viewMatrix, GrColor color, + GrAA aa, + const GrInstancedPipelineInfo& info, + GrAAType* aaType) { return this->recordShape(ShapeType::kOval, oval, viewMatrix, color, oval, aa, info, aaType); } -sk_sp<GrDrawOp> InstancedRendering::recordRRect(const SkRRect& rrect, const SkMatrix& viewMatrix, - GrColor color, GrAA aa, - const GrInstancedPipelineInfo& info, - GrAAType* aaType) { - if (sk_sp<Op> op = this->recordShape(GetRRectShapeType(rrect), rrect.rect(), viewMatrix, color, - rrect.rect(), aa, info, aaType)) { +std::unique_ptr<GrDrawOp> InstancedRendering::recordRRect(const SkRRect& rrect, + const SkMatrix& viewMatrix, GrColor color, + GrAA aa, + const GrInstancedPipelineInfo& info, + GrAAType* aaType) { + if (std::unique_ptr<Op> op = + this->recordShape(GetRRectShapeType(rrect), rrect.rect(), viewMatrix, color, + rrect.rect(), aa, info, aaType)) { op->appendRRectParams(rrect); return std::move(op); } return nullptr; } -sk_sp<GrDrawOp> InstancedRendering::recordDRRect(const SkRRect& outer, const SkRRect& inner, - const SkMatrix& viewMatrix, GrColor color, GrAA aa, - const GrInstancedPipelineInfo& info, - GrAAType* aaType) { +std::unique_ptr<GrDrawOp> InstancedRendering::recordDRRect( + const SkRRect& outer, const SkRRect& inner, const SkMatrix& viewMatrix, GrColor color, + GrAA aa, const GrInstancedPipelineInfo& info, GrAAType* aaType) { if (inner.getType() > SkRRect::kSimple_Type) { return nullptr; // Complex inner round rects are not yet supported. } if (SkRRect::kEmpty_Type == inner.getType()) { return this->recordRRect(outer, viewMatrix, color, aa, info, aaType); } - if (sk_sp<Op> op = this->recordShape(GetRRectShapeType(outer), outer.rect(), viewMatrix, color, - outer.rect(), aa, info, aaType)) { + if (std::unique_ptr<Op> op = + this->recordShape(GetRRectShapeType(outer), outer.rect(), viewMatrix, color, + outer.rect(), aa, info, aaType)) { op->appendRRectParams(outer); ShapeType innerShapeType = GetRRectShapeType(inner); op->fInfo.fInnerShapeTypes |= GetShapeFlag(innerShapeType); @@ -98,7 +104,7 @@ sk_sp<GrDrawOp> InstancedRendering::recordDRRect(const SkRRect& outer, const SkR return nullptr; } -sk_sp<InstancedRendering::Op> InstancedRendering::recordShape( +std::unique_ptr<InstancedRendering::Op> InstancedRendering::recordShape( ShapeType type, const SkRect& bounds, const SkMatrix& viewMatrix, GrColor color, const SkRect& localRect, GrAA aa, const GrInstancedPipelineInfo& info, GrAAType* aaType) { SkASSERT(State::kRecordingDraws == fState); @@ -112,7 +118,7 @@ sk_sp<InstancedRendering::Op> InstancedRendering::recordShape( return nullptr; } - sk_sp<Op> op = this->makeOp(); + std::unique_ptr<Op> op = this->makeOp(); op->fInfo.fAntialiasMode = antialiasMode; op->fInfo.fShapeTypes = GetShapeFlag(type); op->fInfo.fCannotDiscard = !info.fCanDiscard; diff --git a/src/gpu/instanced/InstancedRendering.h b/src/gpu/instanced/InstancedRendering.h index 20d0617c96..1defcc7816 100644 --- a/src/gpu/instanced/InstancedRendering.h +++ b/src/gpu/instanced/InstancedRendering.h @@ -45,27 +45,36 @@ public: * this class before attempting to flush ops returned by it. It is invalid to record new * draws between beginFlush() and endFlush(). */ - sk_sp<GrDrawOp> SK_WARN_UNUSED_RESULT recordRect(const SkRect&, const SkMatrix&, GrColor, GrAA, - const GrInstancedPipelineInfo&, GrAAType*); - - sk_sp<GrDrawOp> SK_WARN_UNUSED_RESULT recordRect(const SkRect&, const SkMatrix&, GrColor, - const SkRect& localRect, GrAA, - const GrInstancedPipelineInfo&, GrAAType*); - - sk_sp<GrDrawOp> SK_WARN_UNUSED_RESULT recordRect(const SkRect&, const SkMatrix&, GrColor, - const SkMatrix& localMatrix, GrAA, - const GrInstancedPipelineInfo&, GrAAType*); - - sk_sp<GrDrawOp> SK_WARN_UNUSED_RESULT recordOval(const SkRect&, const SkMatrix&, GrColor, GrAA, - const GrInstancedPipelineInfo&, GrAAType*); - - sk_sp<GrDrawOp> SK_WARN_UNUSED_RESULT recordRRect(const SkRRect&, const SkMatrix&, GrColor, - GrAA, const GrInstancedPipelineInfo&, - GrAAType*); - - sk_sp<GrDrawOp> SK_WARN_UNUSED_RESULT recordDRRect(const SkRRect& outer, const SkRRect& inner, - const SkMatrix&, GrColor, GrAA, - const GrInstancedPipelineInfo&, GrAAType*); + std::unique_ptr<GrDrawOp> SK_WARN_UNUSED_RESULT recordRect(const SkRect&, const SkMatrix&, + GrColor, GrAA, + const GrInstancedPipelineInfo&, + GrAAType*); + + std::unique_ptr<GrDrawOp> SK_WARN_UNUSED_RESULT recordRect(const SkRect&, const SkMatrix&, + GrColor, const SkRect& localRect, + GrAA, const GrInstancedPipelineInfo&, + GrAAType*); + + std::unique_ptr<GrDrawOp> SK_WARN_UNUSED_RESULT recordRect(const SkRect&, const SkMatrix&, + GrColor, const SkMatrix& localMatrix, + GrAA, const GrInstancedPipelineInfo&, + GrAAType*); + + std::unique_ptr<GrDrawOp> SK_WARN_UNUSED_RESULT recordOval(const SkRect&, const SkMatrix&, + GrColor, GrAA, + const GrInstancedPipelineInfo&, + GrAAType*); + + std::unique_ptr<GrDrawOp> SK_WARN_UNUSED_RESULT recordRRect(const SkRRect&, const SkMatrix&, + GrColor, GrAA, + const GrInstancedPipelineInfo&, + GrAAType*); + + std::unique_ptr<GrDrawOp> SK_WARN_UNUSED_RESULT recordDRRect(const SkRRect& outer, + const SkRRect& inner, + const SkMatrix&, GrColor, GrAA, + const GrInstancedPipelineInfo&, + GrAAType*); /** * Compiles all recorded draws into GPU buffers and allows the client to begin flushing the @@ -175,15 +184,16 @@ private: kFlushing }; - sk_sp<Op> SK_WARN_UNUSED_RESULT recordShape(ShapeType, const SkRect& bounds, - const SkMatrix& viewMatrix, GrColor, - const SkRect& localRect, GrAA aa, - const GrInstancedPipelineInfo&, GrAAType*); + std::unique_ptr<Op> SK_WARN_UNUSED_RESULT recordShape(ShapeType, const SkRect& bounds, + const SkMatrix& viewMatrix, GrColor, + const SkRect& localRect, GrAA aa, + const GrInstancedPipelineInfo&, + GrAAType*); bool selectAntialiasMode(const SkMatrix& viewMatrix, GrAA aa, const GrInstancedPipelineInfo&, GrAAType*, AntialiasMode*); - virtual sk_sp<Op> makeOp() = 0; + virtual std::unique_ptr<Op> makeOp() = 0; const sk_sp<GrGpu> fGpu; State fState; diff --git a/src/gpu/ops/GrAAConvexPathRenderer.cpp b/src/gpu/ops/GrAAConvexPathRenderer.cpp index 2d25ff5131..38e60c7c1c 100644 --- a/src/gpu/ops/GrAAConvexPathRenderer.cpp +++ b/src/gpu/ops/GrAAConvexPathRenderer.cpp @@ -735,8 +735,9 @@ static sk_sp<GrGeometryProcessor> create_fill_gp(bool tweakAlphaForCoverage, class AAConvexPathOp final : public GrMeshDrawOp { public: DEFINE_OP_CLASS_ID - static sk_sp<GrDrawOp> Make(GrColor color, const SkMatrix& viewMatrix, const SkPath& path) { - return sk_sp<GrDrawOp>(new AAConvexPathOp(color, viewMatrix, path)); + static std::unique_ptr<GrDrawOp> Make(GrColor color, const SkMatrix& viewMatrix, + const SkPath& path) { + return std::unique_ptr<GrDrawOp>(new AAConvexPathOp(color, viewMatrix, path)); } const char* name() const override { return "AAConvexPathOp"; } @@ -989,7 +990,8 @@ bool GrAAConvexPathRenderer::onDrawPath(const DrawPathArgs& args) { SkPath path; args.fShape->asPath(&path); - sk_sp<GrDrawOp> op = AAConvexPathOp::Make(args.fPaint->getColor(), *args.fViewMatrix, path); + std::unique_ptr<GrDrawOp> op = + AAConvexPathOp::Make(args.fPaint->getColor(), *args.fViewMatrix, path); GrPipelineBuilder pipelineBuilder(*args.fPaint, args.fAAType); pipelineBuilder.setUserStencil(args.fUserStencilSettings); diff --git a/src/gpu/ops/GrAADistanceFieldPathRenderer.cpp b/src/gpu/ops/GrAADistanceFieldPathRenderer.cpp index b97d35ee16..a21d40bc73 100644 --- a/src/gpu/ops/GrAADistanceFieldPathRenderer.cpp +++ b/src/gpu/ops/GrAADistanceFieldPathRenderer.cpp @@ -126,11 +126,12 @@ public: using ShapeCache = SkTDynamicHash<ShapeData, ShapeData::Key>; using ShapeDataList = GrAADistanceFieldPathRenderer::ShapeDataList; - static sk_sp<GrDrawOp> Make(GrColor color, const GrShape& shape, const SkMatrix& viewMatrix, - GrDrawOpAtlas* atlas, ShapeCache* shapeCache, - ShapeDataList* shapeList, bool gammaCorrect) { - return sk_sp<GrDrawOp>(new AADistanceFieldPathOp(color, shape, viewMatrix, atlas, - shapeCache, shapeList, gammaCorrect)); + static std::unique_ptr<GrDrawOp> Make(GrColor color, const GrShape& shape, + const SkMatrix& viewMatrix, GrDrawOpAtlas* atlas, + ShapeCache* shapeCache, ShapeDataList* shapeList, + bool gammaCorrect) { + return std::unique_ptr<GrDrawOp>(new AADistanceFieldPathOp( + color, shape, viewMatrix, atlas, shapeCache, shapeList, gammaCorrect)); } const char* name() const override { return "AADistanceFieldPathOp"; } @@ -521,9 +522,9 @@ bool GrAADistanceFieldPathRenderer::onDrawPath(const DrawPathArgs& args) { } } - sk_sp<GrDrawOp> op = AADistanceFieldPathOp::Make(args.fPaint->getColor(), *args.fShape, - *args.fViewMatrix, fAtlas.get(), &fShapeCache, - &fShapeList, args.fGammaCorrect); + std::unique_ptr<GrDrawOp> op = AADistanceFieldPathOp::Make( + args.fPaint->getColor(), *args.fShape, *args.fViewMatrix, fAtlas.get(), &fShapeCache, + &fShapeList, args.fGammaCorrect); GrPipelineBuilder pipelineBuilder(*args.fPaint, args.fAAType); pipelineBuilder.setUserStencil(args.fUserStencilSettings); diff --git a/src/gpu/ops/GrAAFillRectOp.cpp b/src/gpu/ops/GrAAFillRectOp.cpp index 0158d60917..2189d86246 100644 --- a/src/gpu/ops/GrAAFillRectOp.cpp +++ b/src/gpu/ops/GrAAFillRectOp.cpp @@ -343,34 +343,35 @@ private: namespace GrAAFillRectOp { -sk_sp<GrDrawOp> Make(GrColor color, - const SkMatrix& viewMatrix, - const SkRect& rect, - const SkRect& devRect) { - return sk_sp<GrDrawOp>(new AAFillRectOp(color, viewMatrix, rect, devRect, nullptr)); +std::unique_ptr<GrDrawOp> Make(GrColor color, + const SkMatrix& viewMatrix, + const SkRect& rect, + const SkRect& devRect) { + return std::unique_ptr<GrDrawOp>(new AAFillRectOp(color, viewMatrix, rect, devRect, nullptr)); } -sk_sp<GrDrawOp> Make(GrColor color, - const SkMatrix& viewMatrix, - const SkMatrix& localMatrix, - const SkRect& rect, - const SkRect& devRect) { - return sk_sp<GrDrawOp>(new AAFillRectOp(color, viewMatrix, rect, devRect, &localMatrix)); +std::unique_ptr<GrDrawOp> Make(GrColor color, + const SkMatrix& viewMatrix, + const SkMatrix& localMatrix, + const SkRect& rect, + const SkRect& devRect) { + return std::unique_ptr<GrDrawOp>( + new AAFillRectOp(color, viewMatrix, rect, devRect, &localMatrix)); } -sk_sp<GrDrawOp> Make(GrColor color, - const SkMatrix& viewMatrix, - const SkMatrix& localMatrix, - const SkRect& rect) { +std::unique_ptr<GrDrawOp> Make(GrColor color, + const SkMatrix& viewMatrix, + const SkMatrix& localMatrix, + const SkRect& rect) { SkRect devRect; viewMatrix.mapRect(&devRect, rect); return Make(color, viewMatrix, localMatrix, rect, devRect); } -sk_sp<GrDrawOp> MakeWithLocalRect(GrColor color, - const SkMatrix& viewMatrix, - const SkRect& rect, - const SkRect& localRect) { +std::unique_ptr<GrDrawOp> MakeWithLocalRect(GrColor color, + const SkMatrix& viewMatrix, + const SkRect& rect, + const SkRect& localRect) { SkRect devRect; viewMatrix.mapRect(&devRect, rect); SkMatrix localMatrix; diff --git a/src/gpu/ops/GrAAFillRectOp.h b/src/gpu/ops/GrAAFillRectOp.h index b611ff98f8..ff9844ea79 100644 --- a/src/gpu/ops/GrAAFillRectOp.h +++ b/src/gpu/ops/GrAAFillRectOp.h @@ -16,26 +16,26 @@ class SkMatrix; struct SkRect; namespace GrAAFillRectOp { -sk_sp<GrDrawOp> Make(GrColor color, - const SkMatrix& viewMatrix, - const SkRect& rect, - const SkRect& devRect); - -sk_sp<GrDrawOp> Make(GrColor color, - const SkMatrix& viewMatrix, - const SkMatrix& localMatrix, - const SkRect& rect); - -sk_sp<GrDrawOp> Make(GrColor color, - const SkMatrix& viewMatrix, - const SkMatrix& localMatrix, - const SkRect& rect, - const SkRect& devRect); - -sk_sp<GrDrawOp> MakeWithLocalRect(GrColor color, - const SkMatrix& viewMatrix, - const SkRect& rect, - const SkRect& localRect); +std::unique_ptr<GrDrawOp> Make(GrColor color, + const SkMatrix& viewMatrix, + const SkRect& rect, + const SkRect& devRect); + +std::unique_ptr<GrDrawOp> Make(GrColor color, + const SkMatrix& viewMatrix, + const SkMatrix& localMatrix, + const SkRect& rect); + +std::unique_ptr<GrDrawOp> Make(GrColor color, + const SkMatrix& viewMatrix, + const SkMatrix& localMatrix, + const SkRect& rect, + const SkRect& devRect); + +std::unique_ptr<GrDrawOp> MakeWithLocalRect(GrColor color, + const SkMatrix& viewMatrix, + const SkRect& rect, + const SkRect& localRect); }; #endif diff --git a/src/gpu/ops/GrAAHairLinePathRenderer.cpp b/src/gpu/ops/GrAAHairLinePathRenderer.cpp index affef55877..6edef91008 100644 --- a/src/gpu/ops/GrAAHairLinePathRenderer.cpp +++ b/src/gpu/ops/GrAAHairLinePathRenderer.cpp @@ -679,18 +679,18 @@ class AAHairlineOp final : public GrMeshDrawOp { public: DEFINE_OP_CLASS_ID - static sk_sp<GrDrawOp> Make(GrColor color, - const SkMatrix& viewMatrix, - const SkPath& path, - const GrStyle& style, - const SkIRect& devClipBounds) { + static std::unique_ptr<GrDrawOp> Make(GrColor color, + const SkMatrix& viewMatrix, + const SkPath& path, + const GrStyle& style, + const SkIRect& devClipBounds) { SkScalar hairlineCoverage; uint8_t newCoverage = 0xff; if (GrPathRenderer::IsStrokeHairlineOrEquivalent(style, viewMatrix, &hairlineCoverage)) { newCoverage = SkScalarRoundToInt(hairlineCoverage * 0xff); } - return sk_sp<GrDrawOp>( + return std::unique_ptr<GrDrawOp>( new AAHairlineOp(color, newCoverage, viewMatrix, path, devClipBounds)); } @@ -956,8 +956,8 @@ bool GrAAHairLinePathRenderer::onDrawPath(const DrawPathArgs& args) { &devClipBounds); SkPath path; args.fShape->asPath(&path); - sk_sp<GrDrawOp> op = AAHairlineOp::Make(args.fPaint->getColor(), *args.fViewMatrix, path, - args.fShape->style(), devClipBounds); + std::unique_ptr<GrDrawOp> op = AAHairlineOp::Make(args.fPaint->getColor(), *args.fViewMatrix, + path, args.fShape->style(), devClipBounds); GrPipelineBuilder pipelineBuilder(*args.fPaint, args.fAAType); pipelineBuilder.setUserStencil(args.fUserStencilSettings); args.fRenderTargetContext->addDrawOp(pipelineBuilder, *args.fClip, std::move(op)); diff --git a/src/gpu/ops/GrAALinearizingConvexPathRenderer.cpp b/src/gpu/ops/GrAALinearizingConvexPathRenderer.cpp index b96e90ae62..aa46ed3ac6 100644 --- a/src/gpu/ops/GrAALinearizingConvexPathRenderer.cpp +++ b/src/gpu/ops/GrAALinearizingConvexPathRenderer.cpp @@ -126,15 +126,15 @@ static sk_sp<GrGeometryProcessor> create_fill_gp(bool tweakAlphaForCoverage, class AAFlatteningConvexPathOp final : public GrMeshDrawOp { public: DEFINE_OP_CLASS_ID - static sk_sp<GrDrawOp> Make(GrColor color, - const SkMatrix& viewMatrix, - const SkPath& path, - SkScalar strokeWidth, - SkStrokeRec::Style style, - SkPaint::Join join, - SkScalar miterLimit) { - return sk_sp<GrDrawOp>(new AAFlatteningConvexPathOp(color, viewMatrix, path, strokeWidth, - style, join, miterLimit)); + static std::unique_ptr<GrDrawOp> Make(GrColor color, + const SkMatrix& viewMatrix, + const SkPath& path, + SkScalar strokeWidth, + SkStrokeRec::Style style, + SkPaint::Join join, + SkScalar miterLimit) { + return std::unique_ptr<GrDrawOp>(new AAFlatteningConvexPathOp( + color, viewMatrix, path, strokeWidth, style, join, miterLimit)); } const char* name() const override { return "AAFlatteningConvexPathOp"; } @@ -353,7 +353,7 @@ bool GrAALinearizingConvexPathRenderer::onDrawPath(const DrawPathArgs& args) { SkPaint::Join join = fill ? SkPaint::Join::kMiter_Join : stroke.getJoin(); SkScalar miterLimit = stroke.getMiter(); - sk_sp<GrDrawOp> op = + std::unique_ptr<GrDrawOp> op = AAFlatteningConvexPathOp::Make(args.fPaint->getColor(), *args.fViewMatrix, path, strokeWidth, stroke.getStyle(), join, miterLimit); diff --git a/src/gpu/ops/GrAAStrokeRectOp.cpp b/src/gpu/ops/GrAAStrokeRectOp.cpp index 1c700599db..1ececb356a 100644 --- a/src/gpu/ops/GrAAStrokeRectOp.cpp +++ b/src/gpu/ops/GrAAStrokeRectOp.cpp @@ -125,8 +125,8 @@ public: fMiterStroke = true; } - static sk_sp<GrDrawOp> Make(GrColor color, const SkMatrix& viewMatrix, const SkRect& rect, - const SkStrokeRec& stroke) { + static std::unique_ptr<GrDrawOp> Make(GrColor color, const SkMatrix& viewMatrix, + const SkRect& rect, const SkStrokeRec& stroke) { bool isMiter; if (!allowed_stroke(stroke, &isMiter)) { return nullptr; @@ -140,7 +140,7 @@ public: info.fColor = color; op->setBounds(info.fDevOutside, HasAABloat::kYes, IsZeroArea::kNo); op->fViewMatrix = viewMatrix; - return sk_sp<GrDrawOp>(op); + return std::unique_ptr<GrDrawOp>(op); } const char* name() const override { return "AAStrokeRect"; } @@ -565,17 +565,17 @@ void AAStrokeRectOp::generateAAStrokeRectGeometry(void* vertices, namespace GrAAStrokeRectOp { -sk_sp<GrDrawOp> MakeFillBetweenRects(GrColor color, - const SkMatrix& viewMatrix, - const SkRect& devOutside, - const SkRect& devInside) { - return sk_sp<GrDrawOp>(new AAStrokeRectOp(color, viewMatrix, devOutside, devInside)); +std::unique_ptr<GrDrawOp> MakeFillBetweenRects(GrColor color, + const SkMatrix& viewMatrix, + const SkRect& devOutside, + const SkRect& devInside) { + return std::unique_ptr<GrDrawOp>(new AAStrokeRectOp(color, viewMatrix, devOutside, devInside)); } -sk_sp<GrDrawOp> Make(GrColor color, - const SkMatrix& viewMatrix, - const SkRect& rect, - const SkStrokeRec& stroke) { +std::unique_ptr<GrDrawOp> Make(GrColor color, + const SkMatrix& viewMatrix, + const SkRect& rect, + const SkStrokeRec& stroke) { return AAStrokeRectOp::Make(color, viewMatrix, rect, stroke); } } diff --git a/src/gpu/ops/GrAAStrokeRectOp.h b/src/gpu/ops/GrAAStrokeRectOp.h index fe8f55c00a..d9f830ecb1 100644 --- a/src/gpu/ops/GrAAStrokeRectOp.h +++ b/src/gpu/ops/GrAAStrokeRectOp.h @@ -18,15 +18,15 @@ class SkStrokeRec; namespace GrAAStrokeRectOp { -sk_sp<GrDrawOp> MakeFillBetweenRects(GrColor color, - const SkMatrix& viewMatrix, - const SkRect& devOutside, - const SkRect& devInside); +std::unique_ptr<GrDrawOp> MakeFillBetweenRects(GrColor color, + const SkMatrix& viewMatrix, + const SkRect& devOutside, + const SkRect& devInside); -sk_sp<GrDrawOp> Make(GrColor color, - const SkMatrix& viewMatrix, - const SkRect& rect, - const SkStrokeRec& stroke); +std::unique_ptr<GrDrawOp> Make(GrColor color, + const SkMatrix& viewMatrix, + const SkRect& rect, + const SkStrokeRec& stroke); } #endif diff --git a/src/gpu/ops/GrAnalyticRectOp.cpp b/src/gpu/ops/GrAnalyticRectOp.cpp index 01e9e33d74..52934ff9c7 100644 --- a/src/gpu/ops/GrAnalyticRectOp.cpp +++ b/src/gpu/ops/GrAnalyticRectOp.cpp @@ -376,12 +376,13 @@ private: typedef GrMeshDrawOp INHERITED; }; -sk_sp<GrDrawOp> GrAnalyticRectOp::Make(GrColor color, - const SkMatrix& viewMatrix, - const SkRect& rect, - const SkRect& croppedRect, - const SkRect& bounds) { - return sk_sp<GrDrawOp>(new AnalyticRectOp(color, viewMatrix, rect, croppedRect, bounds)); +std::unique_ptr<GrDrawOp> GrAnalyticRectOp::Make(GrColor color, + const SkMatrix& viewMatrix, + const SkRect& rect, + const SkRect& croppedRect, + const SkRect& bounds) { + return std::unique_ptr<GrDrawOp>( + new AnalyticRectOp(color, viewMatrix, rect, croppedRect, bounds)); } #ifdef GR_TEST_UTILS @@ -392,7 +393,8 @@ DRAW_OP_TEST_DEFINE(AnalyticRectOp) { SkRect rect = GrTest::TestSquare(random); SkRect croppedRect = GrTest::TestSquare(random); SkRect bounds = GrTest::TestSquare(random); - return sk_sp<GrDrawOp>(new AnalyticRectOp(color, viewMatrix, rect, croppedRect, bounds)); + return std::unique_ptr<GrDrawOp>( + new AnalyticRectOp(color, viewMatrix, rect, croppedRect, bounds)); } #endif diff --git a/src/gpu/ops/GrAnalyticRectOp.h b/src/gpu/ops/GrAnalyticRectOp.h index 77d17ed7c7..126687950c 100644 --- a/src/gpu/ops/GrAnalyticRectOp.h +++ b/src/gpu/ops/GrAnalyticRectOp.h @@ -27,11 +27,11 @@ struct SkRect; */ class GrAnalyticRectOp { public: - static sk_sp<GrDrawOp> Make(GrColor color, - const SkMatrix& viewMatrix, - const SkRect& rect, - const SkRect& croppedRect, - const SkRect& bounds); + static std::unique_ptr<GrDrawOp> Make(GrColor color, + const SkMatrix& viewMatrix, + const SkRect& rect, + const SkRect& croppedRect, + const SkRect& bounds); }; #endif // GrAnalyticRectOp_DEFINED diff --git a/src/gpu/ops/GrAtlasTextOp.h b/src/gpu/ops/GrAtlasTextOp.h index 961c4fb0e8..ef724770c1 100644 --- a/src/gpu/ops/GrAtlasTextOp.h +++ b/src/gpu/ops/GrAtlasTextOp.h @@ -17,6 +17,12 @@ class GrAtlasTextOp final : public GrMeshDrawOp { public: DEFINE_OP_CLASS_ID + ~GrAtlasTextOp() override { + for (int i = 0; i < fGeoCount; i++) { + fGeoData[i].fBlob->unref(); + } + } + static const int kVerticesPerGlyph = GrAtlasTextBlob::kVerticesPerGlyph; static const int kIndicesPerGlyph = 6; @@ -31,9 +37,9 @@ public: GrColor fColor; }; - static sk_sp<GrAtlasTextOp> MakeBitmap(GrMaskFormat maskFormat, int glyphCount, - GrAtlasGlyphCache* fontCache) { - sk_sp<GrAtlasTextOp> op(new GrAtlasTextOp); + static std::unique_ptr<GrAtlasTextOp> MakeBitmap(GrMaskFormat maskFormat, int glyphCount, + GrAtlasGlyphCache* fontCache) { + std::unique_ptr<GrAtlasTextOp> op(new GrAtlasTextOp); op->fFontCache = fontCache; switch (maskFormat) { @@ -55,11 +61,11 @@ public: return op; } - static sk_sp<GrAtlasTextOp> MakeDistanceField( + static std::unique_ptr<GrAtlasTextOp> MakeDistanceField( int glyphCount, GrAtlasGlyphCache* fontCache, const GrDistanceFieldAdjustTable* distanceAdjustTable, bool useGammaCorrectDistanceTable, SkColor filteredColor, bool isLCD, bool useBGR) { - sk_sp<GrAtlasTextOp> op(new GrAtlasTextOp); + std::unique_ptr<GrAtlasTextOp> op(new GrAtlasTextOp); op->fFontCache = fontCache; op->fMaskType = isLCD ? kLCDDistanceField_MaskType : kGrayscaleDistanceField_MaskType; @@ -108,12 +114,6 @@ private: GrAtlasTextOp() : INHERITED(ClassID()) {} // initialized in factory functions. - ~GrAtlasTextOp() { - for (int i = 0; i < fGeoCount; i++) { - fGeoData[i].fBlob->unref(); - } - } - GrMaskFormat maskFormat() const { switch (fMaskType) { case kLCDCoverageMask_MaskType: diff --git a/src/gpu/ops/GrClearOp.h b/src/gpu/ops/GrClearOp.h index 81371884d8..b40b615b2e 100644 --- a/src/gpu/ops/GrClearOp.h +++ b/src/gpu/ops/GrClearOp.h @@ -19,17 +19,18 @@ class GrClearOp final : public GrOp { public: DEFINE_OP_CLASS_ID - static sk_sp<GrClearOp> Make(const GrFixedClip& clip, GrColor color, GrRenderTarget* rt) { - sk_sp<GrClearOp> op(new GrClearOp(clip, color, rt)); + static std::unique_ptr<GrClearOp> Make(const GrFixedClip& clip, GrColor color, + GrRenderTarget* rt) { + std::unique_ptr<GrClearOp> op(new GrClearOp(clip, color, rt)); if (!op->fRenderTarget) { return nullptr; // The clip did not contain any pixels within the render target. } return op; } - static sk_sp<GrClearOp> Make(const SkIRect& rect, GrColor color, GrRenderTarget* rt, - bool fullScreen) { - return sk_sp<GrClearOp>(new GrClearOp(rect, color, rt, fullScreen)); + static std::unique_ptr<GrClearOp> Make(const SkIRect& rect, GrColor color, GrRenderTarget* rt, + bool fullScreen) { + return std::unique_ptr<GrClearOp>(new GrClearOp(rect, color, rt, fullScreen)); } const char* name() const override { return "Clear"; } diff --git a/src/gpu/ops/GrClearStencilClipOp.h b/src/gpu/ops/GrClearStencilClipOp.h index 7f3f68a70b..afbd72ddbf 100644 --- a/src/gpu/ops/GrClearStencilClipOp.h +++ b/src/gpu/ops/GrClearStencilClipOp.h @@ -19,8 +19,9 @@ class GrClearStencilClipOp final : public GrOp { public: DEFINE_OP_CLASS_ID - static sk_sp<GrOp> Make(const GrFixedClip& clip, bool insideStencilMask, GrRenderTarget* rt) { - return sk_sp<GrOp>(new GrClearStencilClipOp(clip, insideStencilMask, rt)); + static std::unique_ptr<GrOp> Make(const GrFixedClip& clip, bool insideStencilMask, + GrRenderTarget* rt) { + return std::unique_ptr<GrOp>(new GrClearStencilClipOp(clip, insideStencilMask, rt)); } const char* name() const override { return "ClearStencilClip"; } diff --git a/src/gpu/ops/GrCopySurfaceOp.cpp b/src/gpu/ops/GrCopySurfaceOp.cpp index 3283517efe..87c490b110 100644 --- a/src/gpu/ops/GrCopySurfaceOp.cpp +++ b/src/gpu/ops/GrCopySurfaceOp.cpp @@ -58,8 +58,8 @@ bool GrCopySurfaceOp::ClipSrcRectAndDstPoint(const GrSurface* dst, return !clippedSrcRect->isEmpty(); } -sk_sp<GrOp> GrCopySurfaceOp::Make(GrSurface* dst, GrSurface* src, const SkIRect& srcRect, - const SkIPoint& dstPoint) { +std::unique_ptr<GrOp> GrCopySurfaceOp::Make(GrSurface* dst, GrSurface* src, const SkIRect& srcRect, + const SkIPoint& dstPoint) { SkASSERT(dst); SkASSERT(src); if (GrPixelConfigIsSint(dst->config()) != GrPixelConfigIsSint(src->config())) { @@ -74,5 +74,5 @@ sk_sp<GrOp> GrCopySurfaceOp::Make(GrSurface* dst, GrSurface* src, const SkIRect& if (!ClipSrcRectAndDstPoint(dst, src, srcRect, dstPoint, &clippedSrcRect, &clippedDstPoint)) { return nullptr; } - return sk_sp<GrOp>(new GrCopySurfaceOp(dst, src, clippedSrcRect, clippedDstPoint)); + return std::unique_ptr<GrOp>(new GrCopySurfaceOp(dst, src, clippedSrcRect, clippedDstPoint)); } diff --git a/src/gpu/ops/GrCopySurfaceOp.h b/src/gpu/ops/GrCopySurfaceOp.h index 1f4fbfa8a9..e74b7e5111 100644 --- a/src/gpu/ops/GrCopySurfaceOp.h +++ b/src/gpu/ops/GrCopySurfaceOp.h @@ -27,8 +27,8 @@ public: SkIRect* clippedSrcRect, SkIPoint* clippedDstPoint); - static sk_sp<GrOp> Make(GrSurface* dst, GrSurface* src, const SkIRect& srcRect, - const SkIPoint& dstPoint); + static std::unique_ptr<GrOp> Make(GrSurface* dst, GrSurface* src, const SkIRect& srcRect, + const SkIPoint& dstPoint); const char* name() const override { return "CopySurface"; } diff --git a/src/gpu/ops/GrDashLinePathRenderer.cpp b/src/gpu/ops/GrDashLinePathRenderer.cpp index 10e4342224..e381165644 100644 --- a/src/gpu/ops/GrDashLinePathRenderer.cpp +++ b/src/gpu/ops/GrDashLinePathRenderer.cpp @@ -45,7 +45,7 @@ bool GrDashLinePathRenderer::onDrawPath(const DrawPathArgs& args) { } SkPoint pts[2]; SkAssertResult(args.fShape->asLine(pts, nullptr)); - sk_sp<GrDrawOp> op = GrDashOp::MakeDashLineOp( + std::unique_ptr<GrDrawOp> op = GrDashOp::MakeDashLineOp( args.fPaint->getColor(), *args.fViewMatrix, pts, aaMode, args.fShape->style()); if (!op) { return false; diff --git a/src/gpu/ops/GrDashOp.cpp b/src/gpu/ops/GrDashOp.cpp index 8a9dfe88a7..5ff3230b8c 100644 --- a/src/gpu/ops/GrDashOp.cpp +++ b/src/gpu/ops/GrDashOp.cpp @@ -252,9 +252,9 @@ public: SkScalar fPerpendicularScale; }; - static sk_sp<GrDrawOp> Make(const LineData& geometry, GrColor color, SkPaint::Cap cap, - AAMode aaMode, bool fullDash) { - return sk_sp<GrDrawOp>(new DashOp(geometry, color, cap, aaMode, fullDash)); + static std::unique_ptr<GrDrawOp> Make(const LineData& geometry, GrColor color, SkPaint::Cap cap, + AAMode aaMode, bool fullDash) { + return std::unique_ptr<GrDrawOp>(new DashOp(geometry, color, cap, aaMode, fullDash)); } const char* name() const override { return "DashOp"; } @@ -688,11 +688,11 @@ private: typedef GrMeshDrawOp INHERITED; }; -sk_sp<GrDrawOp> GrDashOp::MakeDashLineOp(GrColor color, - const SkMatrix& viewMatrix, - const SkPoint pts[2], - AAMode aaMode, - const GrStyle& style) { +std::unique_ptr<GrDrawOp> GrDashOp::MakeDashLineOp(GrColor color, + const SkMatrix& viewMatrix, + const SkPoint pts[2], + AAMode aaMode, + const GrStyle& style) { SkASSERT(GrDashOp::CanDrawDashLine(pts, style, viewMatrix)); const SkScalar* intervals = style.dashIntervals(); SkScalar phase = style.dashPhase(); diff --git a/src/gpu/ops/GrDashOp.h b/src/gpu/ops/GrDashOp.h index ff04f91af5..2f4a30f18d 100644 --- a/src/gpu/ops/GrDashOp.h +++ b/src/gpu/ops/GrDashOp.h @@ -23,8 +23,8 @@ enum class AAMode { }; static const int kAAModeCnt = static_cast<int>(AAMode::kCoverageWithMSAA) + 1; -sk_sp<GrDrawOp> MakeDashLineOp(GrColor, const SkMatrix& viewMatrix, const SkPoint pts[2], AAMode, - const GrStyle& style); +std::unique_ptr<GrDrawOp> MakeDashLineOp(GrColor, const SkMatrix& viewMatrix, const SkPoint pts[2], + AAMode, const GrStyle& style); bool CanDrawDashLine(const SkPoint pts[2], const GrStyle& style, const SkMatrix& viewMatrix); } diff --git a/src/gpu/ops/GrDefaultPathRenderer.cpp b/src/gpu/ops/GrDefaultPathRenderer.cpp index 47c7adacad..c20a3d54dc 100644 --- a/src/gpu/ops/GrDefaultPathRenderer.cpp +++ b/src/gpu/ops/GrDefaultPathRenderer.cpp @@ -98,11 +98,11 @@ class DefaultPathOp final : public GrMeshDrawOp { public: DEFINE_OP_CLASS_ID - static sk_sp<GrDrawOp> Make(GrColor color, const SkPath& path, SkScalar tolerance, - uint8_t coverage, const SkMatrix& viewMatrix, bool isHairline, - const SkRect& devBounds) { - return sk_sp<GrDrawOp>(new DefaultPathOp(color, path, tolerance, coverage, viewMatrix, - isHairline, devBounds)); + static std::unique_ptr<GrDrawOp> Make(GrColor color, const SkPath& path, SkScalar tolerance, + uint8_t coverage, const SkMatrix& viewMatrix, + bool isHairline, const SkRect& devBounds) { + return std::unique_ptr<GrDrawOp>(new DefaultPathOp(color, path, tolerance, coverage, + viewMatrix, isHairline, devBounds)); } const char* name() const override { return "DefaultPathOp"; } @@ -555,8 +555,8 @@ bool GrDefaultPathRenderer::internalDrawPath(GrRenderTargetContext* renderTarget } const SkMatrix& viewM = (reverse && viewMatrix.hasPerspective()) ? SkMatrix::I() : viewMatrix; - sk_sp<GrDrawOp> op(GrRectOpFactory::MakeNonAAFill(paint.getColor(), viewM, bounds, - nullptr, &localMatrix)); + std::unique_ptr<GrDrawOp> op(GrRectOpFactory::MakeNonAAFill( + paint.getColor(), viewM, bounds, nullptr, &localMatrix)); SkASSERT(GrDrawFace::kBoth == drawFace[p]); GrPipelineBuilder pipelineBuilder(paint, aaType); @@ -564,7 +564,7 @@ bool GrDefaultPathRenderer::internalDrawPath(GrRenderTargetContext* renderTarget pipelineBuilder.setUserStencil(passes[p]); renderTargetContext->addDrawOp(pipelineBuilder, clip, std::move(op)); } else { - sk_sp<GrDrawOp> op = + std::unique_ptr<GrDrawOp> op = DefaultPathOp::Make(paint.getColor(), path, srcSpaceTol, newCoverage, viewMatrix, isHairline, devBounds); GrPipelineBuilder pipelineBuilder(paint, aaType); diff --git a/src/gpu/ops/GrDiscardOp.h b/src/gpu/ops/GrDiscardOp.h index 6923be2a49..f9be33d729 100644 --- a/src/gpu/ops/GrDiscardOp.h +++ b/src/gpu/ops/GrDiscardOp.h @@ -16,7 +16,9 @@ class GrDiscardOp final : public GrOp { public: DEFINE_OP_CLASS_ID - static sk_sp<GrOp> Make(GrRenderTarget* rt) { return sk_sp<GrOp>(new GrDiscardOp(rt)); } + static std::unique_ptr<GrOp> Make(GrRenderTarget* rt) { + return std::unique_ptr<GrOp>(new GrDiscardOp(rt)); + } const char* name() const override { return "Discard"; } diff --git a/src/gpu/ops/GrDrawAtlasOp.h b/src/gpu/ops/GrDrawAtlasOp.h index ec21162e26..60158e0c6a 100644 --- a/src/gpu/ops/GrDrawAtlasOp.h +++ b/src/gpu/ops/GrDrawAtlasOp.h @@ -16,10 +16,10 @@ class GrDrawAtlasOp final : public GrMeshDrawOp { public: DEFINE_OP_CLASS_ID - static sk_sp<GrDrawOp> Make(GrColor color, const SkMatrix& viewMatrix, int spriteCount, - const SkRSXform* xforms, const SkRect* rects, - const SkColor* colors) { - return sk_sp<GrDrawOp>( + static std::unique_ptr<GrDrawOp> Make(GrColor color, const SkMatrix& viewMatrix, + int spriteCount, const SkRSXform* xforms, + const SkRect* rects, const SkColor* colors) { + return std::unique_ptr<GrDrawOp>( new GrDrawAtlasOp(color, viewMatrix, spriteCount, xforms, rects, colors)); } diff --git a/src/gpu/ops/GrDrawPathOp.h b/src/gpu/ops/GrDrawPathOp.h index 95cbc7e439..b34f15e3bf 100644 --- a/src/gpu/ops/GrDrawPathOp.h +++ b/src/gpu/ops/GrDrawPathOp.h @@ -61,8 +61,9 @@ class GrDrawPathOp final : public GrDrawPathOpBase { public: DEFINE_OP_CLASS_ID - static sk_sp<GrDrawOp> Make(const SkMatrix& viewMatrix, GrColor color, const GrPath* path) { - return sk_sp<GrDrawOp>(new GrDrawPathOp(viewMatrix, color, path)); + static std::unique_ptr<GrDrawOp> Make(const SkMatrix& viewMatrix, GrColor color, + const GrPath* path) { + return std::unique_ptr<GrDrawOp>(new GrDrawPathOp(viewMatrix, color, path)); } const char* name() const override { return "DrawPath"; } @@ -91,7 +92,7 @@ public: DEFINE_OP_CLASS_ID - struct InstanceData : public SkNoncopyable { + struct InstanceData : private ::SkNoncopyable { public: static InstanceData* Alloc(TransformType transformType, int reserveCnt) { int transformSize = GrPathRendering::PathTransformSize(transformType); @@ -150,11 +151,12 @@ public: SkDEBUGCODE(int fReserveCnt;) }; - static sk_sp<GrDrawOp> Make(const SkMatrix& viewMatrix, SkScalar scale, SkScalar x, SkScalar y, - GrColor color, GrPathRendering::FillType fill, GrPathRange* range, - const InstanceData* instanceData, const SkRect& bounds) { - return sk_sp<GrDrawOp>(new GrDrawPathRangeOp(viewMatrix, scale, x, y, color, fill, range, - instanceData, bounds)); + static std::unique_ptr<GrDrawOp> Make(const SkMatrix& viewMatrix, SkScalar scale, SkScalar x, + SkScalar y, GrColor color, GrPathRendering::FillType fill, + GrPathRange* range, const InstanceData* instanceData, + const SkRect& bounds) { + return std::unique_ptr<GrDrawOp>(new GrDrawPathRangeOp(viewMatrix, scale, x, y, color, fill, + range, instanceData, bounds)); } const char* name() const override { return "DrawPathRange"; } diff --git a/src/gpu/ops/GrDrawVerticesOp.h b/src/gpu/ops/GrDrawVerticesOp.h index 2c1580d4e5..b0697f4f3b 100644 --- a/src/gpu/ops/GrDrawVerticesOp.h +++ b/src/gpu/ops/GrDrawVerticesOp.h @@ -22,14 +22,14 @@ class GrDrawVerticesOp final : public GrMeshDrawOp { public: DEFINE_OP_CLASS_ID - static sk_sp<GrDrawOp> Make(GrColor color, GrPrimitiveType primitiveType, - const SkMatrix& viewMatrix, const SkPoint* positions, - int vertexCount, const uint16_t* indices, int indexCount, - const GrColor* colors, const SkPoint* localCoords, - const SkRect& bounds) { - return sk_sp<GrDrawOp>(new GrDrawVerticesOp(color, primitiveType, viewMatrix, positions, - vertexCount, indices, indexCount, colors, - localCoords, bounds)); + static std::unique_ptr<GrDrawOp> Make(GrColor color, GrPrimitiveType primitiveType, + const SkMatrix& viewMatrix, const SkPoint* positions, + int vertexCount, const uint16_t* indices, int indexCount, + const GrColor* colors, const SkPoint* localCoords, + const SkRect& bounds) { + return std::unique_ptr<GrDrawOp>( + new GrDrawVerticesOp(color, primitiveType, viewMatrix, positions, vertexCount, + indices, indexCount, colors, localCoords, bounds)); } const char* name() const override { return "DrawVerticesOp"; } diff --git a/src/gpu/ops/GrLatticeOp.cpp b/src/gpu/ops/GrLatticeOp.cpp index af83aa629d..e3881ba7ef 100644 --- a/src/gpu/ops/GrLatticeOp.cpp +++ b/src/gpu/ops/GrLatticeOp.cpp @@ -176,9 +176,10 @@ private: }; namespace GrLatticeOp { -sk_sp<GrDrawOp> MakeNonAA(GrColor color, const SkMatrix& viewMatrix, int imageWidth, - int imageHeight, std::unique_ptr<SkLatticeIter> iter, const SkRect& dst) { - return sk_sp<GrDrawOp>( +std::unique_ptr<GrDrawOp> MakeNonAA(GrColor color, const SkMatrix& viewMatrix, int imageWidth, + int imageHeight, std::unique_ptr<SkLatticeIter> iter, + const SkRect& dst) { + return std::unique_ptr<GrDrawOp>( new NonAALatticeOp(color, viewMatrix, imageWidth, imageHeight, std::move(iter), dst)); } }; diff --git a/src/gpu/ops/GrLatticeOp.h b/src/gpu/ops/GrLatticeOp.h index 2908461a29..2ed3b9c6f6 100644 --- a/src/gpu/ops/GrLatticeOp.h +++ b/src/gpu/ops/GrLatticeOp.h @@ -17,8 +17,9 @@ class SkMatrix; struct SkRect; namespace GrLatticeOp { -sk_sp<GrDrawOp> MakeNonAA(GrColor color, const SkMatrix& viewMatrix, int imageWidth, - int imageHeight, std::unique_ptr<SkLatticeIter> iter, const SkRect& dst); +std::unique_ptr<GrDrawOp> MakeNonAA(GrColor color, const SkMatrix& viewMatrix, int imageWidth, + int imageHeight, std::unique_ptr<SkLatticeIter> iter, + const SkRect& dst); }; #endif diff --git a/src/gpu/ops/GrMSAAPathRenderer.cpp b/src/gpu/ops/GrMSAAPathRenderer.cpp index 1a73ca20a7..0774fdbc1a 100644 --- a/src/gpu/ops/GrMSAAPathRenderer.cpp +++ b/src/gpu/ops/GrMSAAPathRenderer.cpp @@ -217,8 +217,8 @@ private: class MSAAPathOp final : public GrMeshDrawOp { public: DEFINE_OP_CLASS_ID - static sk_sp<GrDrawOp> Make(GrColor color, const SkPath& path, const SkMatrix& viewMatrix, - const SkRect& devBounds) { + static std::unique_ptr<GrDrawOp> Make(GrColor color, const SkPath& path, + const SkMatrix& viewMatrix, const SkRect& devBounds) { int contourCount; int maxLineVertices; int maxQuadVertices; @@ -229,8 +229,8 @@ public: return nullptr; } - return sk_sp<GrDrawOp>(new MSAAPathOp(color, path, viewMatrix, devBounds, maxLineVertices, - maxQuadVertices, isIndexed)); + return std::unique_ptr<GrDrawOp>(new MSAAPathOp( + color, path, viewMatrix, devBounds, maxLineVertices, maxQuadVertices, isIndexed)); } const char* name() const override { return "MSAAPathOp"; } @@ -663,15 +663,16 @@ bool GrMSAAPathRenderer::internalDrawPath(GrRenderTargetContext* renderTargetCon } const SkMatrix& viewM = (reverse && viewMatrix.hasPerspective()) ? SkMatrix::I() : viewMatrix; - sk_sp<GrDrawOp> op(GrRectOpFactory::MakeNonAAFill(paint.getColor(), viewM, bounds, - nullptr, &localMatrix)); + std::unique_ptr<GrDrawOp> op(GrRectOpFactory::MakeNonAAFill( + paint.getColor(), viewM, bounds, nullptr, &localMatrix)); GrPipelineBuilder pipelineBuilder(paint, aaType); pipelineBuilder.setUserStencil(passes[p]); renderTargetContext->addDrawOp(pipelineBuilder, clip, std::move(op)); } else { - sk_sp<GrDrawOp> op = MSAAPathOp::Make(paint.getColor(), path, viewMatrix, devBounds); + std::unique_ptr<GrDrawOp> op = + MSAAPathOp::Make(paint.getColor(), path, viewMatrix, devBounds); if (!op) { return false; } diff --git a/src/gpu/ops/GrNonAAFillRectOp.cpp b/src/gpu/ops/GrNonAAFillRectOp.cpp index afef8e6ba3..26bee83cc6 100644 --- a/src/gpu/ops/GrNonAAFillRectOp.cpp +++ b/src/gpu/ops/GrNonAAFillRectOp.cpp @@ -188,12 +188,13 @@ private: namespace GrNonAAFillRectOp { -sk_sp<GrDrawOp> Make(GrColor color, - const SkMatrix& viewMatrix, - const SkRect& rect, - const SkRect* localRect, - const SkMatrix* localMatrix) { - return sk_sp<GrDrawOp>(new NonAAFillRectOp(color, viewMatrix, rect, localRect, localMatrix)); +std::unique_ptr<GrDrawOp> Make(GrColor color, + const SkMatrix& viewMatrix, + const SkRect& rect, + const SkRect* localRect, + const SkMatrix* localMatrix) { + return std::unique_ptr<GrDrawOp>( + new NonAAFillRectOp(color, viewMatrix, rect, localRect, localMatrix)); } }; diff --git a/src/gpu/ops/GrNonAAFillRectOp.h b/src/gpu/ops/GrNonAAFillRectOp.h index 3d983e15f1..e699221fa3 100644 --- a/src/gpu/ops/GrNonAAFillRectOp.h +++ b/src/gpu/ops/GrNonAAFillRectOp.h @@ -17,17 +17,17 @@ struct SkRect; namespace GrNonAAFillRectOp { -sk_sp<GrDrawOp> Make(GrColor color, - const SkMatrix& viewMatrix, - const SkRect& rect, - const SkRect* localRect, - const SkMatrix* localMatrix); +std::unique_ptr<GrDrawOp> Make(GrColor color, + const SkMatrix& viewMatrix, + const SkRect& rect, + const SkRect* localRect, + const SkMatrix* localMatrix); -sk_sp<GrDrawOp> MakeWithPerspective(GrColor color, - const SkMatrix& viewMatrix, - const SkRect& rect, - const SkRect* localRect, - const SkMatrix* localMatrix); +std::unique_ptr<GrDrawOp> MakeWithPerspective(GrColor color, + const SkMatrix& viewMatrix, + const SkRect& rect, + const SkRect* localRect, + const SkMatrix* localMatrix); }; #endif diff --git a/src/gpu/ops/GrNonAAFillRectPerspectiveOp.cpp b/src/gpu/ops/GrNonAAFillRectPerspectiveOp.cpp index 9b6a857fea..10053fe577 100644 --- a/src/gpu/ops/GrNonAAFillRectPerspectiveOp.cpp +++ b/src/gpu/ops/GrNonAAFillRectPerspectiveOp.cpp @@ -230,12 +230,12 @@ private: namespace GrNonAAFillRectOp { -sk_sp<GrDrawOp> MakeWithPerspective(GrColor color, - const SkMatrix& viewMatrix, - const SkRect& rect, - const SkRect* localRect, - const SkMatrix* localMatrix) { - return sk_sp<GrDrawOp>( +std::unique_ptr<GrDrawOp> MakeWithPerspective(GrColor color, + const SkMatrix& viewMatrix, + const SkRect& rect, + const SkRect* localRect, + const SkMatrix* localMatrix) { + return std::unique_ptr<GrDrawOp>( new NonAAFillRectPerspectiveOp(color, viewMatrix, rect, localRect, localMatrix)); } }; diff --git a/src/gpu/ops/GrNonAAStrokeRectOp.cpp b/src/gpu/ops/GrNonAAStrokeRectOp.cpp index 160024131e..3f63a91877 100644 --- a/src/gpu/ops/GrNonAAStrokeRectOp.cpp +++ b/src/gpu/ops/GrNonAAStrokeRectOp.cpp @@ -62,8 +62,9 @@ public: return string; } - static sk_sp<GrDrawOp> Make(GrColor color, const SkMatrix& viewMatrix, const SkRect& rect, - const SkStrokeRec& stroke, bool snapToPixelCenters) { + static std::unique_ptr<GrDrawOp> Make(GrColor color, const SkMatrix& viewMatrix, + const SkRect& rect, const SkStrokeRec& stroke, + bool snapToPixelCenters) { if (!allowed_stroke(stroke)) { return nullptr; } @@ -94,7 +95,7 @@ public: } else { op->setTransformedBounds(bounds, op->fViewMatrix, HasAABloat::kNo, IsZeroArea::kNo); } - return sk_sp<GrDrawOp>(op); + return std::unique_ptr<GrDrawOp>(op); } private: @@ -184,11 +185,11 @@ private: namespace GrNonAAStrokeRectOp { -sk_sp<GrDrawOp> Make(GrColor color, - const SkMatrix& viewMatrix, - const SkRect& rect, - const SkStrokeRec& stroke, - bool snapToPixelCenters) { +std::unique_ptr<GrDrawOp> Make(GrColor color, + const SkMatrix& viewMatrix, + const SkRect& rect, + const SkStrokeRec& stroke, + bool snapToPixelCenters) { return NonAAStrokeRectOp::Make(color, viewMatrix, rect, stroke, snapToPixelCenters); } } diff --git a/src/gpu/ops/GrNonAAStrokeRectOp.h b/src/gpu/ops/GrNonAAStrokeRectOp.h index 1e067fa9ea..9c46f40f7a 100644 --- a/src/gpu/ops/GrNonAAStrokeRectOp.h +++ b/src/gpu/ops/GrNonAAStrokeRectOp.h @@ -18,11 +18,11 @@ class SkMatrix; namespace GrNonAAStrokeRectOp { -sk_sp<GrDrawOp> Make(GrColor color, - const SkMatrix& viewMatrix, - const SkRect& rect, - const SkStrokeRec&, - bool snapToPixelCenters); +std::unique_ptr<GrDrawOp> Make(GrColor color, + const SkMatrix& viewMatrix, + const SkRect& rect, + const SkStrokeRec&, + bool snapToPixelCenters); } #endif diff --git a/src/gpu/ops/GrOp.h b/src/gpu/ops/GrOp.h index 87748f52f8..3a37ad53dd 100644 --- a/src/gpu/ops/GrOp.h +++ b/src/gpu/ops/GrOp.h @@ -56,7 +56,7 @@ class GrOpFlushState; return kClassID; \ } -class GrOp : public GrNonAtomicRef<GrOp> { +class GrOp : private SkNoncopyable { public: GrOp(uint32_t classID); virtual ~GrOp(); diff --git a/src/gpu/ops/GrOvalOpFactory.cpp b/src/gpu/ops/GrOvalOpFactory.cpp index 5a9a077101..a01402071a 100644 --- a/src/gpu/ops/GrOvalOpFactory.cpp +++ b/src/gpu/ops/GrOvalOpFactory.cpp @@ -613,9 +613,9 @@ public: SkScalar fSweepAngleRadians; bool fUseCenter; }; - static sk_sp<GrDrawOp> Make(GrColor color, const SkMatrix& viewMatrix, SkPoint center, - SkScalar radius, const GrStyle& style, - const ArcParams* arcParams = nullptr) { + static std::unique_ptr<GrDrawOp> Make(GrColor color, const SkMatrix& viewMatrix, SkPoint center, + SkScalar radius, const GrStyle& style, + const ArcParams* arcParams = nullptr) { SkASSERT(circle_stays_circle(viewMatrix)); const SkStrokeRec& stroke = style.strokeRec(); if (style.hasPathEffect()) { @@ -672,7 +672,7 @@ public: outerRadius += SK_ScalarHalf; innerRadius -= SK_ScalarHalf; bool stroked = isStrokeOnly && innerRadius > 0.0f; - sk_sp<CircleOp> op(new CircleOp()); + std::unique_ptr<CircleOp> op(new CircleOp()); op->fViewMatrixIfUsingLocalCoords = viewMatrix; // This makes every point fully inside the intersection plane. @@ -1148,8 +1148,8 @@ private: class EllipseOp : public GrMeshDrawOp { public: DEFINE_OP_CLASS_ID - static sk_sp<GrDrawOp> Make(GrColor color, const SkMatrix& viewMatrix, const SkRect& ellipse, - const SkStrokeRec& stroke) { + static std::unique_ptr<GrDrawOp> Make(GrColor color, const SkMatrix& viewMatrix, + const SkRect& ellipse, const SkStrokeRec& stroke) { SkASSERT(viewMatrix.rectStaysRect()); // do any matrix crunching before we reset the draw state for device coords @@ -1208,7 +1208,7 @@ public: yRadius += scaledStroke.fY; } - sk_sp<EllipseOp> op(new EllipseOp()); + std::unique_ptr<EllipseOp> op(new EllipseOp()); op->fGeoData.emplace_back( Geometry{color, xRadius, yRadius, innerXRadius, innerYRadius, SkRect::MakeLTRB(center.fX - xRadius, center.fY - yRadius, @@ -1370,10 +1370,10 @@ class DIEllipseOp : public GrMeshDrawOp { public: DEFINE_OP_CLASS_ID - static sk_sp<GrDrawOp> Make(GrColor color, - const SkMatrix& viewMatrix, - const SkRect& ellipse, - const SkStrokeRec& stroke) { + static std::unique_ptr<GrDrawOp> Make(GrColor color, + const SkMatrix& viewMatrix, + const SkRect& ellipse, + const SkStrokeRec& stroke) { SkPoint center = SkPoint::Make(ellipse.centerX(), ellipse.centerY()); SkScalar xRadius = SkScalarHalf(ellipse.width()); SkScalar yRadius = SkScalarHalf(ellipse.height()); @@ -1430,7 +1430,7 @@ public: SkScalar geoDx = SK_ScalarHalf / SkScalarSqrt(a * a + c * c); SkScalar geoDy = SK_ScalarHalf / SkScalarSqrt(b * b + d * d); - sk_sp<DIEllipseOp> op(new DIEllipseOp()); + std::unique_ptr<DIEllipseOp> op(new DIEllipseOp()); op->fGeoData.emplace_back(Geometry{ viewMatrix, color, xRadius, yRadius, innerXRadius, innerYRadius, geoDx, geoDy, dieStyle, @@ -2054,9 +2054,9 @@ public: // If devStrokeWidths values are <= 0 indicates then fill only. Otherwise, strokeOnly indicates // whether the rrect is only stroked or stroked and filled. - static sk_sp<GrDrawOp> Make(GrColor color, const SkMatrix& viewMatrix, const SkRect& devRect, - float devXRadius, float devYRadius, SkVector devStrokeWidths, - bool strokeOnly) { + static std::unique_ptr<GrDrawOp> Make(GrColor color, const SkMatrix& viewMatrix, + const SkRect& devRect, float devXRadius, float devYRadius, + SkVector devStrokeWidths, bool strokeOnly) { SkASSERT(devXRadius > 0.5); SkASSERT(devYRadius > 0.5); SkASSERT((devStrokeWidths.fX > 0) == (devStrokeWidths.fY > 0)); @@ -2101,7 +2101,7 @@ public: bounds.outset(devStrokeWidths.fX, devStrokeWidths.fY); } - sk_sp<EllipticalRRectOp> op(new EllipticalRRectOp()); + std::unique_ptr<EllipticalRRectOp> op(new EllipticalRRectOp()); op->fStroked = stroked; op->fViewMatrixIfUsingLocalCoords = viewMatrix; op->setBounds(bounds, HasAABloat::kYes, IsZeroArea::kNo); @@ -2266,11 +2266,11 @@ private: typedef GrMeshDrawOp INHERITED; }; -static sk_sp<GrDrawOp> make_rrect_op(GrColor color, - bool needsDistance, - const SkMatrix& viewMatrix, - const SkRRect& rrect, - const SkStrokeRec& stroke) { +static std::unique_ptr<GrDrawOp> make_rrect_op(GrColor color, + bool needsDistance, + const SkMatrix& viewMatrix, + const SkRRect& rrect, + const SkStrokeRec& stroke) { SkASSERT(viewMatrix.rectStaysRect()); SkASSERT(rrect.isSimple()); SkASSERT(!rrect.isOval()); @@ -2328,8 +2328,8 @@ static sk_sp<GrDrawOp> make_rrect_op(GrColor color, // if the corners are circles, use the circle renderer if (isCircular) { - return sk_sp<GrDrawOp>(new CircularRRectOp(color, needsDistance, viewMatrix, bounds, - xRadius, scaledStroke.fX, isStrokeOnly)); + return std::unique_ptr<GrDrawOp>(new CircularRRectOp( + color, needsDistance, viewMatrix, bounds, xRadius, scaledStroke.fX, isStrokeOnly)); // otherwise we use the ellipse renderer } else { return EllipticalRRectOp::Make(color, viewMatrix, bounds, xRadius, yRadius, scaledStroke, @@ -2337,12 +2337,12 @@ static sk_sp<GrDrawOp> make_rrect_op(GrColor color, } } -sk_sp<GrDrawOp> GrOvalOpFactory::MakeRRectOp(GrColor color, - bool needsDistance, - const SkMatrix& viewMatrix, - const SkRRect& rrect, - const SkStrokeRec& stroke, - const GrShaderCaps* shaderCaps) { +std::unique_ptr<GrDrawOp> GrOvalOpFactory::MakeRRectOp(GrColor color, + bool needsDistance, + const SkMatrix& viewMatrix, + const SkRRect& rrect, + const SkStrokeRec& stroke, + const GrShaderCaps* shaderCaps) { if (rrect.isOval()) { return MakeOvalOp(color, viewMatrix, rrect.getBounds(), stroke, shaderCaps); } @@ -2356,11 +2356,11 @@ sk_sp<GrDrawOp> GrOvalOpFactory::MakeRRectOp(GrColor color, /////////////////////////////////////////////////////////////////////////////// -sk_sp<GrDrawOp> GrOvalOpFactory::MakeOvalOp(GrColor color, - const SkMatrix& viewMatrix, - const SkRect& oval, - const SkStrokeRec& stroke, - const GrShaderCaps* shaderCaps) { +std::unique_ptr<GrDrawOp> GrOvalOpFactory::MakeOvalOp(GrColor color, + const SkMatrix& viewMatrix, + const SkRect& oval, + const SkStrokeRec& stroke, + const GrShaderCaps* shaderCaps) { // we can draw circles SkScalar width = oval.width(); if (SkScalarNearlyEqual(width, oval.height()) && circle_stays_circle(viewMatrix)) { @@ -2383,10 +2383,11 @@ sk_sp<GrDrawOp> GrOvalOpFactory::MakeOvalOp(GrColor color, /////////////////////////////////////////////////////////////////////////////// -sk_sp<GrDrawOp> GrOvalOpFactory::MakeArcOp(GrColor color, const SkMatrix& viewMatrix, - const SkRect& oval, SkScalar startAngle, - SkScalar sweepAngle, bool useCenter, - const GrStyle& style, const GrShaderCaps* shaderCaps) { +std::unique_ptr<GrDrawOp> GrOvalOpFactory::MakeArcOp(GrColor color, const SkMatrix& viewMatrix, + const SkRect& oval, SkScalar startAngle, + SkScalar sweepAngle, bool useCenter, + const GrStyle& style, + const GrShaderCaps* shaderCaps) { SkASSERT(!oval.isEmpty()); SkASSERT(sweepAngle); SkScalar width = oval.width(); @@ -2429,8 +2430,8 @@ DRAW_OP_TEST_DEFINE(CircleOp) { arcParamsTmp.fUseCenter = random->nextBool(); arcParams = &arcParamsTmp; } - sk_sp<GrDrawOp> op = CircleOp::Make(color, viewMatrix, center, radius, - GrStyle(stroke, nullptr), arcParams); + std::unique_ptr<GrDrawOp> op = CircleOp::Make(color, viewMatrix, center, radius, + GrStyle(stroke, nullptr), arcParams); if (op) { return op; } diff --git a/src/gpu/ops/GrOvalOpFactory.h b/src/gpu/ops/GrOvalOpFactory.h index dfe7ebf37f..0ddcc9b44b 100644 --- a/src/gpu/ops/GrOvalOpFactory.h +++ b/src/gpu/ops/GrOvalOpFactory.h @@ -24,26 +24,26 @@ class SkStrokeRec; */ class GrOvalOpFactory { public: - static sk_sp<GrDrawOp> MakeOvalOp(GrColor, - const SkMatrix& viewMatrix, - const SkRect& oval, - const SkStrokeRec& stroke, - const GrShaderCaps* shaderCaps); - static sk_sp<GrDrawOp> MakeRRectOp(GrColor, - bool needsDistance, - const SkMatrix& viewMatrix, - const SkRRect& rrect, - const SkStrokeRec& stroke, - const GrShaderCaps* shaderCaps); + static std::unique_ptr<GrDrawOp> MakeOvalOp(GrColor, + const SkMatrix& viewMatrix, + const SkRect& oval, + const SkStrokeRec& stroke, + const GrShaderCaps* shaderCaps); + static std::unique_ptr<GrDrawOp> MakeRRectOp(GrColor, + bool needsDistance, + const SkMatrix& viewMatrix, + const SkRRect& rrect, + const SkStrokeRec& stroke, + const GrShaderCaps* shaderCaps); - static sk_sp<GrDrawOp> MakeArcOp(GrColor, - const SkMatrix& viewMatrix, - const SkRect& oval, - SkScalar startAngle, - SkScalar sweepAngle, - bool useCenter, - const GrStyle&, - const GrShaderCaps* shaderCaps); + static std::unique_ptr<GrDrawOp> MakeArcOp(GrColor, + const SkMatrix& viewMatrix, + const SkRect& oval, + SkScalar startAngle, + SkScalar sweepAngle, + bool useCenter, + const GrStyle&, + const GrShaderCaps* shaderCaps); }; #endif // GrOvalOpFactory_DEFINED diff --git a/src/gpu/ops/GrPLSPathRenderer.cpp b/src/gpu/ops/GrPLSPathRenderer.cpp index 47c54d721a..637b4b7c09 100644 --- a/src/gpu/ops/GrPLSPathRenderer.cpp +++ b/src/gpu/ops/GrPLSPathRenderer.cpp @@ -766,8 +766,9 @@ bool GrPLSPathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const { class PLSPathOp final : public GrMeshDrawOp { public: DEFINE_OP_CLASS_ID - static sk_sp<GrDrawOp> Make(GrColor color, const SkPath& path, const SkMatrix& viewMatrix) { - return sk_sp<GrDrawOp>(new PLSPathOp(color, path, viewMatrix)); + static std::unique_ptr<GrDrawOp> Make(GrColor color, const SkPath& path, + const SkMatrix& viewMatrix) { + return std::unique_ptr<GrDrawOp>(new PLSPathOp(color, path, viewMatrix)); } const char* name() const override { return "PLSPathOp"; } @@ -931,7 +932,8 @@ bool GrPLSPathRenderer::onDrawPath(const DrawPathArgs& args) { SkPath path; args.fShape->asPath(&path); - sk_sp<GrDrawOp> op = PLSPathOp::Make(args.fPaint->getColor(), path, *args.fViewMatrix); + std::unique_ptr<GrDrawOp> op = + PLSPathOp::Make(args.fPaint->getColor(), path, *args.fViewMatrix); GrPipelineBuilder pipelineBuilder(*args.fPaint, args.fAAType); pipelineBuilder.setUserStencil(args.fUserStencilSettings); diff --git a/src/gpu/ops/GrRectOpFactory.cpp b/src/gpu/ops/GrRectOpFactory.cpp index fd73624254..5c8d3449dc 100644 --- a/src/gpu/ops/GrRectOpFactory.cpp +++ b/src/gpu/ops/GrRectOpFactory.cpp @@ -13,9 +13,9 @@ namespace GrRectOpFactory { -sk_sp<GrDrawOp> MakeAAFillNestedRects(GrColor color, - const SkMatrix& viewMatrix, - const SkRect rects[2]) { +std::unique_ptr<GrDrawOp> MakeAAFillNestedRects(GrColor color, + const SkMatrix& viewMatrix, + const SkRect rects[2]) { SkASSERT(viewMatrix.rectStaysRect()); SkASSERT(!rects[0].isEmpty() && !rects[1].isEmpty()); diff --git a/src/gpu/ops/GrRectOpFactory.h b/src/gpu/ops/GrRectOpFactory.h index 90263a00df..3f4200835b 100644 --- a/src/gpu/ops/GrRectOpFactory.h +++ b/src/gpu/ops/GrRectOpFactory.h @@ -27,11 +27,11 @@ class SkStrokeRec; */ namespace GrRectOpFactory { -inline sk_sp<GrDrawOp> MakeNonAAFill(GrColor color, - const SkMatrix& viewMatrix, - const SkRect& rect, - const SkRect* localRect, - const SkMatrix* localMatrix) { +inline std::unique_ptr<GrDrawOp> MakeNonAAFill(GrColor color, + const SkMatrix& viewMatrix, + const SkRect& rect, + const SkRect* localRect, + const SkMatrix* localMatrix) { if (viewMatrix.hasPerspective() || (localMatrix && localMatrix->hasPerspective())) { return GrNonAAFillRectOp::MakeWithPerspective(color, viewMatrix, rect, localRect, localMatrix); @@ -40,11 +40,11 @@ inline sk_sp<GrDrawOp> MakeNonAAFill(GrColor color, } } -inline sk_sp<GrDrawOp> MakeAAFill(const GrPaint& paint, - const SkMatrix& viewMatrix, - const SkRect& rect, - const SkRect& croppedRect, - const SkRect& devRect) { +inline std::unique_ptr<GrDrawOp> MakeAAFill(const GrPaint& paint, + const SkMatrix& viewMatrix, + const SkRect& rect, + const SkRect& croppedRect, + const SkRect& devRect) { if (!paint.usesDistanceVectorField()) { return GrAAFillRectOp::Make(paint.getColor(), viewMatrix, croppedRect, devRect); } else { @@ -52,31 +52,32 @@ inline sk_sp<GrDrawOp> MakeAAFill(const GrPaint& paint, } } -inline sk_sp<GrDrawOp> MakeAAFill(GrColor color, - const SkMatrix& viewMatrix, - const SkMatrix& localMatrix, - const SkRect& rect, - const SkRect& devRect) { +inline std::unique_ptr<GrDrawOp> MakeAAFill(GrColor color, + const SkMatrix& viewMatrix, + const SkMatrix& localMatrix, + const SkRect& rect, + const SkRect& devRect) { return GrAAFillRectOp::Make(color, viewMatrix, localMatrix, rect, devRect); } -inline sk_sp<GrDrawOp> MakeNonAAStroke(GrColor color, - const SkMatrix& viewMatrix, - const SkRect& rect, - const SkStrokeRec& strokeRec, - bool snapToPixelCenters) { +inline std::unique_ptr<GrDrawOp> MakeNonAAStroke(GrColor color, + const SkMatrix& viewMatrix, + const SkRect& rect, + const SkStrokeRec& strokeRec, + bool snapToPixelCenters) { return GrNonAAStrokeRectOp::Make(color, viewMatrix, rect, strokeRec, snapToPixelCenters); } -inline sk_sp<GrDrawOp> MakeAAStroke(GrColor color, - const SkMatrix& viewMatrix, - const SkRect& rect, - const SkStrokeRec& stroke) { +inline std::unique_ptr<GrDrawOp> MakeAAStroke(GrColor color, + const SkMatrix& viewMatrix, + const SkRect& rect, + const SkStrokeRec& stroke) { return GrAAStrokeRectOp::Make(color, viewMatrix, rect, stroke); } // First rect is outer; second rect is inner -sk_sp<GrDrawOp> MakeAAFillNestedRects(GrColor, const SkMatrix& viewMatrix, const SkRect rects[2]); +std::unique_ptr<GrDrawOp> MakeAAFillNestedRects(GrColor, const SkMatrix& viewMatrix, + const SkRect rects[2]); }; #endif diff --git a/src/gpu/ops/GrRegionOp.cpp b/src/gpu/ops/GrRegionOp.cpp index 4d45d80032..7fbdd75ab0 100644 --- a/src/gpu/ops/GrRegionOp.cpp +++ b/src/gpu/ops/GrRegionOp.cpp @@ -154,7 +154,7 @@ private: namespace GrRegionOp { -sk_sp<GrDrawOp> Make(GrColor color, const SkMatrix& viewMatrix, const SkRegion& region) { - return sk_sp<GrDrawOp>(new RegionOp(color, viewMatrix, region)); +std::unique_ptr<GrDrawOp> Make(GrColor color, const SkMatrix& viewMatrix, const SkRegion& region) { + return std::unique_ptr<GrDrawOp>(new RegionOp(color, viewMatrix, region)); } } diff --git a/src/gpu/ops/GrRegionOp.h b/src/gpu/ops/GrRegionOp.h index 24230604ba..e4b8f3e4fd 100644 --- a/src/gpu/ops/GrRegionOp.h +++ b/src/gpu/ops/GrRegionOp.h @@ -16,7 +16,7 @@ class SkMatrix; class SkRegion; namespace GrRegionOp { -sk_sp<GrDrawOp> Make(GrColor color, const SkMatrix& viewMatrix, const SkRegion& region); +std::unique_ptr<GrDrawOp> Make(GrColor color, const SkMatrix& viewMatrix, const SkRegion& region); } #endif diff --git a/src/gpu/ops/GrShadowRRectOp.cpp b/src/gpu/ops/GrShadowRRectOp.cpp index b5829f4ba0..1882aad47d 100755 --- a/src/gpu/ops/GrShadowRRectOp.cpp +++ b/src/gpu/ops/GrShadowRRectOp.cpp @@ -67,8 +67,9 @@ class ShadowCircleOp final : public GrMeshDrawOp { public: DEFINE_OP_CLASS_ID - static sk_sp<GrDrawOp> Make(GrColor color, const SkMatrix& viewMatrix, SkPoint center, - SkScalar radius, SkScalar blurRadius, const GrStyle& style) { + static std::unique_ptr<GrDrawOp> Make(GrColor color, const SkMatrix& viewMatrix, SkPoint center, + SkScalar radius, SkScalar blurRadius, + const GrStyle& style) { SkASSERT(viewMatrix.isSimilarity()); const SkStrokeRec& stroke = style.strokeRec(); if (style.hasPathEffect()) { @@ -108,7 +109,7 @@ public: outerRadius += SK_ScalarHalf; innerRadius -= SK_ScalarHalf; bool stroked = isStrokeOnly && innerRadius > 0.0f; - sk_sp<ShadowCircleOp> op(new ShadowCircleOp()); + std::unique_ptr<ShadowCircleOp> op(new ShadowCircleOp()); op->fViewMatrixIfUsingLocalCoords = viewMatrix; SkRect devBounds = SkRect::MakeLTRB(center.fX - outerRadius, center.fY - outerRadius, @@ -826,12 +827,12 @@ private: /////////////////////////////////////////////////////////////////////////////// -sk_sp<GrDrawOp> make_shadow_circle_op(GrColor color, - const SkMatrix& viewMatrix, - const SkRect& oval, - SkScalar blurRadius, - const SkStrokeRec& stroke, - const GrShaderCaps* shaderCaps) { +std::unique_ptr<GrDrawOp> make_shadow_circle_op(GrColor color, + const SkMatrix& viewMatrix, + const SkRect& oval, + SkScalar blurRadius, + const SkStrokeRec& stroke, + const GrShaderCaps* shaderCaps) { // we can only draw circles SkScalar width = oval.width(); SkASSERT(SkScalarNearlyEqual(width, oval.height()) && viewMatrix.isSimilarity()); @@ -840,11 +841,11 @@ sk_sp<GrDrawOp> make_shadow_circle_op(GrColor color, GrStyle(stroke, nullptr)); } -static sk_sp<GrDrawOp> make_shadow_rrect_op(GrColor color, - const SkMatrix& viewMatrix, - const SkRRect& rrect, - SkScalar blurRadius, - const SkStrokeRec& stroke) { +static std::unique_ptr<GrDrawOp> make_shadow_rrect_op(GrColor color, + const SkMatrix& viewMatrix, + const SkRRect& rrect, + SkScalar blurRadius, + const SkStrokeRec& stroke) { SkASSERT(viewMatrix.rectStaysRect()); SkASSERT(rrect.isSimple()); SkASSERT(!rrect.isOval()); @@ -897,17 +898,17 @@ static sk_sp<GrDrawOp> make_shadow_rrect_op(GrColor color, return nullptr; } - return sk_sp<GrDrawOp>(new ShadowCircularRRectOp(color, viewMatrix, bounds, xRadius, blurRadius, - scaledStroke.fX, isStrokeOnly)); + return std::unique_ptr<GrDrawOp>(new ShadowCircularRRectOp( + color, viewMatrix, bounds, xRadius, blurRadius, scaledStroke.fX, isStrokeOnly)); } namespace GrShadowRRectOp { -sk_sp<GrDrawOp> Make(GrColor color, - const SkMatrix& viewMatrix, - const SkRRect& rrect, - const SkScalar blurRadius, - const SkStrokeRec& stroke, - const GrShaderCaps* shaderCaps) { +std::unique_ptr<GrDrawOp> Make(GrColor color, + const SkMatrix& viewMatrix, + const SkRRect& rrect, + const SkScalar blurRadius, + const SkStrokeRec& stroke, + const GrShaderCaps* shaderCaps) { if (rrect.isOval()) { return make_shadow_circle_op(color, viewMatrix, rrect.getBounds(), blurRadius, stroke, shaderCaps); @@ -940,8 +941,8 @@ DRAW_OP_TEST_DEFINE(ShadowCircleOp) { SkScalar radius = circle.width() / 2.f; SkStrokeRec stroke = GrTest::TestStrokeRec(random); SkScalar blurRadius = random->nextSScalar1() * 72.f; - sk_sp<GrDrawOp> op = ShadowCircleOp::Make(color, viewMatrix, center, radius, blurRadius, - GrStyle(stroke, nullptr)); + std::unique_ptr<GrDrawOp> op = ShadowCircleOp::Make(color, viewMatrix, center, radius, + blurRadius, GrStyle(stroke, nullptr)); if (op) { return op; } diff --git a/src/gpu/ops/GrShadowRRectOp.h b/src/gpu/ops/GrShadowRRectOp.h index 3508cb8fab..50e0102c1a 100755 --- a/src/gpu/ops/GrShadowRRectOp.h +++ b/src/gpu/ops/GrShadowRRectOp.h @@ -19,9 +19,9 @@ class SkStrokeRec; namespace GrShadowRRectOp { -sk_sp<GrDrawOp> Make(GrColor, const SkMatrix& viewMatrix, const SkRRect& rrect, - const SkScalar blurRadius, const SkStrokeRec& stroke, - const GrShaderCaps* shaderCaps); +std::unique_ptr<GrDrawOp> Make(GrColor, const SkMatrix& viewMatrix, const SkRRect& rrect, + const SkScalar blurRadius, const SkStrokeRec& stroke, + const GrShaderCaps* shaderCaps); } #endif diff --git a/src/gpu/ops/GrStencilAndCoverPathRenderer.cpp b/src/gpu/ops/GrStencilAndCoverPathRenderer.cpp index 16765e0bac..5a83e0e6f4 100644 --- a/src/gpu/ops/GrStencilAndCoverPathRenderer.cpp +++ b/src/gpu/ops/GrStencilAndCoverPathRenderer.cpp @@ -112,8 +112,8 @@ bool GrStencilAndCoverPathRenderer::onDrawPath(const DrawPathArgs& args) { } const SkMatrix& viewM = viewMatrix.hasPerspective() ? SkMatrix::I() : viewMatrix; - sk_sp<GrDrawOp> coverOp(GrRectOpFactory::MakeNonAAFill(args.fPaint->getColor(), viewM, - bounds, nullptr, &invert)); + std::unique_ptr<GrDrawOp> coverOp(GrRectOpFactory::MakeNonAAFill( + args.fPaint->getColor(), viewM, bounds, nullptr, &invert)); // fake inverse with a stencil and cover args.fRenderTargetContext->priv().stencilPath(*args.fClip, args.fAAType, viewMatrix, @@ -154,7 +154,8 @@ bool GrStencilAndCoverPathRenderer::onDrawPath(const DrawPathArgs& args) { 0xffff>() ); - sk_sp<GrDrawOp> op = GrDrawPathOp::Make(viewMatrix, args.fPaint->getColor(), path.get()); + std::unique_ptr<GrDrawOp> op = + GrDrawPathOp::Make(viewMatrix, args.fPaint->getColor(), path.get()); GrPipelineBuilder pipelineBuilder(*args.fPaint, args.fAAType); pipelineBuilder.setUserStencil(&kCoverPass); diff --git a/src/gpu/ops/GrStencilPathOp.h b/src/gpu/ops/GrStencilPathOp.h index 03dc7ee067..f21b524f2f 100644 --- a/src/gpu/ops/GrStencilPathOp.h +++ b/src/gpu/ops/GrStencilPathOp.h @@ -19,16 +19,17 @@ class GrStencilPathOp final : public GrOp { public: DEFINE_OP_CLASS_ID - static sk_sp<GrOp> Make(const SkMatrix& viewMatrix, - bool useHWAA, - GrPathRendering::FillType fillType, - bool hasStencilClip, - int numStencilBits, - const GrScissorState& scissor, - GrRenderTarget* renderTarget, - const GrPath* path) { - return sk_sp<GrOp>(new GrStencilPathOp(viewMatrix, useHWAA, fillType, hasStencilClip, - numStencilBits, scissor, renderTarget, path)); + static std::unique_ptr<GrOp> Make(const SkMatrix& viewMatrix, + bool useHWAA, + GrPathRendering::FillType fillType, + bool hasStencilClip, + int numStencilBits, + const GrScissorState& scissor, + GrRenderTarget* renderTarget, + const GrPath* path) { + return std::unique_ptr<GrOp>(new GrStencilPathOp(viewMatrix, useHWAA, fillType, + hasStencilClip, numStencilBits, scissor, + renderTarget, path)); } const char* name() const override { return "StencilPathOp"; } diff --git a/src/gpu/ops/GrTessellatingPathRenderer.cpp b/src/gpu/ops/GrTessellatingPathRenderer.cpp index 7774798b1f..81a982ca20 100644 --- a/src/gpu/ops/GrTessellatingPathRenderer.cpp +++ b/src/gpu/ops/GrTessellatingPathRenderer.cpp @@ -160,12 +160,12 @@ class TessellatingPathOp final : public GrMeshDrawOp { public: DEFINE_OP_CLASS_ID - static sk_sp<GrDrawOp> Make(const GrColor& color, - const GrShape& shape, - const SkMatrix& viewMatrix, - SkIRect devClipBounds, - bool antiAlias) { - return sk_sp<GrDrawOp>( + static std::unique_ptr<GrDrawOp> Make(const GrColor& color, + const GrShape& shape, + const SkMatrix& viewMatrix, + SkIRect devClipBounds, + bool antiAlias) { + return std::unique_ptr<GrDrawOp>( new TessellatingPathOp(color, shape, viewMatrix, devClipBounds, antiAlias)); } @@ -358,11 +358,11 @@ bool GrTessellatingPathRenderer::onDrawPath(const DrawPathArgs& args) { args.fClip->getConservativeBounds(args.fRenderTargetContext->width(), args.fRenderTargetContext->height(), &clipBoundsI); - sk_sp<GrDrawOp> op = TessellatingPathOp::Make(args.fPaint->getColor(), - *args.fShape, - *args.fViewMatrix, - clipBoundsI, - GrAAType::kCoverage == args.fAAType); + std::unique_ptr<GrDrawOp> op = TessellatingPathOp::Make(args.fPaint->getColor(), + *args.fShape, + *args.fViewMatrix, + clipBoundsI, + GrAAType::kCoverage == args.fAAType); GrPipelineBuilder pipelineBuilder(*args.fPaint, args.fAAType); pipelineBuilder.setUserStencil(args.fUserStencilSettings); args.fRenderTargetContext->addDrawOp(pipelineBuilder, *args.fClip, std::move(op)); diff --git a/src/gpu/text/GrAtlasTextBlob.cpp b/src/gpu/text/GrAtlasTextBlob.cpp index 9aca37a436..d4e4f5ffb4 100644 --- a/src/gpu/text/GrAtlasTextBlob.cpp +++ b/src/gpu/text/GrAtlasTextBlob.cpp @@ -254,7 +254,7 @@ bool GrAtlasTextBlob::mustRegenerate(const SkPaint& paint, return false; } -inline sk_sp<GrDrawOp> GrAtlasTextBlob::makeOp( +inline std::unique_ptr<GrDrawOp> GrAtlasTextBlob::makeOp( const Run::SubRunInfo& info, int glyphCount, int run, int subRun, const SkMatrix& viewMatrix, SkScalar x, SkScalar y, GrColor color, const SkPaint& skPaint, const SkSurfaceProps& props, const GrDistanceFieldAdjustTable* distanceAdjustTable, @@ -268,7 +268,7 @@ inline sk_sp<GrDrawOp> GrAtlasTextBlob::makeOp( subRunColor = color; } - sk_sp<GrAtlasTextOp> op; + std::unique_ptr<GrAtlasTextOp> op; if (info.drawAsDistanceFields()) { SkColor filteredColor; SkColorFilter* colorFilter = skPaint.getColorFilter(); @@ -313,9 +313,9 @@ void GrAtlasTextBlob::flushRun(GrRenderTargetContext* rtc, const GrPaint& grPain GrColor color = grPaint.getColor(); - sk_sp<GrDrawOp> op(this->makeOp(info, glyphCount, run, subRun, viewMatrix, x, y, color, - skPaint, props, distanceAdjustTable, rtc->isGammaCorrect(), - cache)); + std::unique_ptr<GrDrawOp> op(this->makeOp(info, glyphCount, run, subRun, viewMatrix, x, y, + color, skPaint, props, distanceAdjustTable, + rtc->isGammaCorrect(), cache)); GrPipelineBuilder pipelineBuilder(grPaint, GrAAType::kNone); rtc->addDrawOp(pipelineBuilder, clip, std::move(op)); @@ -451,12 +451,10 @@ void GrAtlasTextBlob::flushThrowaway(GrContext* context, this->flushBigGlyphs(context, rtc, clip, skPaint, viewMatrix, x, y, clipBounds); } -sk_sp<GrDrawOp> GrAtlasTextBlob::test_makeOp(int glyphCount, int run, int subRun, - const SkMatrix& viewMatrix, SkScalar x, SkScalar y, - GrColor color, const SkPaint& skPaint, - const SkSurfaceProps& props, - const GrDistanceFieldAdjustTable* distanceAdjustTable, - GrAtlasGlyphCache* cache) { +std::unique_ptr<GrDrawOp> GrAtlasTextBlob::test_makeOp( + int glyphCount, int run, int subRun, const SkMatrix& viewMatrix, SkScalar x, SkScalar y, + GrColor color, const SkPaint& skPaint, const SkSurfaceProps& props, + const GrDistanceFieldAdjustTable* distanceAdjustTable, GrAtlasGlyphCache* cache) { const GrAtlasTextBlob::Run::SubRunInfo& info = fRuns[run].fSubRunInfo[subRun]; return this->makeOp(info, glyphCount, run, subRun, viewMatrix, x, y, color, skPaint, props, distanceAdjustTable, false, cache); diff --git a/src/gpu/text/GrAtlasTextBlob.h b/src/gpu/text/GrAtlasTextBlob.h index 9b3f59c834..340b52a41b 100644 --- a/src/gpu/text/GrAtlasTextBlob.h +++ b/src/gpu/text/GrAtlasTextBlob.h @@ -279,11 +279,12 @@ public: //////////////////////////////////////////////////////////////////////////////////////////////// // Internal test methods - sk_sp<GrDrawOp> test_makeOp(int glyphCount, int run, int subRun, const SkMatrix& viewMatrix, - SkScalar x, SkScalar y, GrColor color, const SkPaint& skPaint, - const SkSurfaceProps& props, - const GrDistanceFieldAdjustTable* distanceAdjustTable, - GrAtlasGlyphCache* cache); + std::unique_ptr<GrDrawOp> test_makeOp(int glyphCount, int run, int subRun, + const SkMatrix& viewMatrix, SkScalar x, SkScalar y, + GrColor color, const SkPaint& skPaint, + const SkSurfaceProps& props, + const GrDistanceFieldAdjustTable* distanceAdjustTable, + GrAtlasGlyphCache* cache); private: GrAtlasTextBlob() @@ -500,11 +501,13 @@ private: Run* run, Run::SubRunInfo* info, SkAutoGlyphCache*, int glyphCount, size_t vertexStride, GrColor color, SkScalar transX, SkScalar transY) const; - inline sk_sp<GrDrawOp> makeOp(const Run::SubRunInfo& info, int glyphCount, int run, int subRun, - const SkMatrix& viewMatrix, SkScalar x, SkScalar y, GrColor color, - const SkPaint& skPaint, const SkSurfaceProps& props, - const GrDistanceFieldAdjustTable* distanceAdjustTable, - bool useGammaCorrectDistanceTable, GrAtlasGlyphCache* cache); + inline std::unique_ptr<GrDrawOp> makeOp(const Run::SubRunInfo& info, int glyphCount, int run, + int subRun, const SkMatrix& viewMatrix, SkScalar x, + SkScalar y, GrColor color, const SkPaint& skPaint, + const SkSurfaceProps& props, + const GrDistanceFieldAdjustTable* distanceAdjustTable, + bool useGammaCorrectDistanceTable, + GrAtlasGlyphCache* cache); struct BigGlyph { BigGlyph(const SkPath& path, SkScalar vx, SkScalar vy, SkScalar scale, bool treatAsBMP) diff --git a/src/gpu/text/GrStencilAndCoverTextContext.cpp b/src/gpu/text/GrStencilAndCoverTextContext.cpp index e3ad1a7b3e..e58b082db9 100644 --- a/src/gpu/text/GrStencilAndCoverTextContext.cpp +++ b/src/gpu/text/GrStencilAndCoverTextContext.cpp @@ -633,10 +633,10 @@ void GrStencilAndCoverTextContext::TextRun::draw(GrContext* ctx, const SkRect bounds = SkRect::MakeIWH(renderTargetContext->width(), renderTargetContext->height()); - sk_sp<GrDrawOp> op = GrDrawPathRangeOp::Make(viewMatrix, fTextRatio, fTextInverseRatio * x, - fTextInverseRatio * y, grPaint.getColor(), - GrPathRendering::kWinding_FillType, - glyphs.get(), fInstanceData.get(), bounds); + std::unique_ptr<GrDrawOp> op = GrDrawPathRangeOp::Make( + viewMatrix, fTextRatio, fTextInverseRatio * x, fTextInverseRatio * y, + grPaint.getColor(), GrPathRendering::kWinding_FillType, glyphs.get(), + fInstanceData.get(), bounds); // The run's "font" overrides the anti-aliasing of the passed in SkPaint! GrAAType aaType = GrAAType::kNone; |