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/gm/clockwise.cpp b/gm/clockwise.cpp
index b9311f7..6013dcb 100644
--- a/gm/clockwise.cpp
+++ b/gm/clockwise.cpp
@@ -137,10 +137,9 @@
public:
DEFINE_OP_CLASS_ID
- static std::unique_ptr<GrDrawOp> Make(GrRecordingContext* context,
- bool readSkFragCoord, int y = 0) {
- GrOpMemoryPool* pool = context->priv().opMemoryPool();
- return pool->allocate<ClockwiseTestOp>(readSkFragCoord, y);
+ static GrOp::Owner Make(GrRecordingContext* context,
+ bool readSkFragCoord, int y = 0) {
+ return GrOp::Make<ClockwiseTestOp>(context, readSkFragCoord, y);
}
private:
@@ -235,7 +234,7 @@
// guaranteed to have the same lifetime as the program info.
GrProgramInfo* fProgramInfo = nullptr;
- friend class ::GrOpMemoryPool; // for ctor
+ friend class ::GrOp; // for ctor
using INHERITED = GrDrawOp;
};