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/tools/gpu/TestOps.cpp b/tools/gpu/TestOps.cpp
index 30331fc..64c050b 100644
--- a/tools/gpu/TestOps.cpp
+++ b/tools/gpu/TestOps.cpp
@@ -82,11 +82,11 @@
 
 class TestRectOp final : public GrMeshDrawOp {
 public:
-    static std::unique_ptr<GrDrawOp> Make(GrRecordingContext*,
-                                          GrPaint&&,
-                                          const SkRect& drawRect,
-                                          const SkRect& localRect,
-                                          const SkMatrix& localM);
+    static GrOp::Owner Make(GrRecordingContext*,
+                            GrPaint&&,
+                            const SkRect& drawRect,
+                            const SkRect& localRect,
+                            const SkMatrix& localM);
 
     const char* name() const override { return "TestRectOp"; }
 
@@ -136,17 +136,16 @@
     GrProgramInfo* fProgramInfo = nullptr;
     GrSimpleMesh*  fMesh        = nullptr;
 
-    friend class ::GrOpMemoryPool;
+    friend class ::GrOp;
 };
 
-std::unique_ptr<GrDrawOp> TestRectOp::Make(GrRecordingContext* context,
-                                           GrPaint&& paint,
-                                           const SkRect& drawRect,
-                                           const SkRect& localRect,
-                                           const SkMatrix& localM) {
-    auto* pool = context->priv().opMemoryPool();
+GrOp::Owner TestRectOp::Make(GrRecordingContext* context,
+                             GrPaint&& paint,
+                             const SkRect& drawRect,
+                             const SkRect& localRect,
+                             const SkMatrix& localM) {
     const auto* caps = context->priv().caps();
-    return pool->allocate<TestRectOp>(caps, std::move(paint), drawRect, localRect, localM);
+    return GrOp::Make<TestRectOp>(context, caps, std::move(paint), drawRect, localRect, localM);
 }
 
 GrProcessorSet::Analysis TestRectOp::finalize(const GrCaps& caps,
@@ -219,27 +218,27 @@
 
 namespace sk_gpu_test::test_ops {
 
-std::unique_ptr<GrDrawOp> MakeRect(GrRecordingContext* context,
-                                   GrPaint&& paint,
-                                   const SkRect& drawRect,
-                                   const SkRect& localRect,
-                                   const SkMatrix& localM) {
+GrOp::Owner MakeRect(GrRecordingContext* context,
+                     GrPaint&& paint,
+                     const SkRect& drawRect,
+                     const SkRect& localRect,
+                     const SkMatrix& localM) {
     return TestRectOp::Make(context, std::move(paint), drawRect, localRect, localM);
 }
 
-std::unique_ptr<GrDrawOp> MakeRect(GrRecordingContext* context,
-                                   std::unique_ptr<GrFragmentProcessor> fp,
-                                   const SkRect& drawRect,
-                                   const SkRect& localRect,
-                                   const SkMatrix& localM) {
+GrOp::Owner MakeRect(GrRecordingContext* context,
+                     std::unique_ptr<GrFragmentProcessor> fp,
+                     const SkRect& drawRect,
+                     const SkRect& localRect,
+                     const SkMatrix& localM) {
     GrPaint paint;
     paint.setColorFragmentProcessor(std::move(fp));
     return TestRectOp::Make(context, std::move(paint), drawRect, localRect, localM);
 }
 
-std::unique_ptr<GrDrawOp> MakeRect(GrRecordingContext* context,
-                                   GrPaint&& paint,
-                                   const SkRect& rect) {
+GrOp::Owner MakeRect(GrRecordingContext* context,
+                     GrPaint&& paint,
+                     const SkRect& rect) {
     return TestRectOp::Make(context, std::move(paint), rect, rect, SkMatrix::I());
 }