add API for Op creation
Introduce three calls on GrOp: Make, MakeWithExtraMemory,
and MakeWithProcessorSet. Instead of returning
unique_ptr<GrOp>, they return a type of GrOp::OpOwner.
GrOp::OpOwner safely deletes the op when it goes out
of scope for either new/delete or GrOpMemoryPool
allocations.
In order to make the code easier to refactor, I
eliminated MakeArg from the helpers.
Change-Id: Icfd697906f3147a8734575d08bd7195e7517383a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/323778
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Herb Derby <herb@google.com>
diff --git a/samplecode/SampleCCPRGeometry.cpp b/samplecode/SampleCCPRGeometry.cpp
index a75f6fb..d918c18 100644
--- a/samplecode/SampleCCPRGeometry.cpp
+++ b/samplecode/SampleCCPRGeometry.cpp
@@ -222,15 +222,13 @@
auto ctx = canvas->recordingContext();
SkASSERT(ctx);
- GrOpMemoryPool* pool = ctx->priv().opMemoryPool();
-
int width = this->width();
int height = this->height();
auto ccbuff = GrRenderTargetContext::Make(
ctx, GrColorType::kAlpha_F16, nullptr, SkBackingFit::kApprox, {width, height});
SkASSERT(ccbuff);
ccbuff->clear(SK_PMColor4fTRANSPARENT);
- ccbuff->priv().testingOnly_addDrawOp(pool->allocate<DrawCoverageCountOp>(this));
+ ccbuff->priv().testingOnly_addDrawOp(GrOp::Make<DrawCoverageCountOp>(ctx, this));
// Visualize coverage count in main canvas.
GrPaint paint;