Add a factory to any GrOp-derived class that lacked one

All GrOp-derived classes are going to have allocate their memory in a GrMemoryPool.

Change-Id: Ifa410b05eecd9b68c39dcc15dd4298d617204c13
Reviewed-on: https://skia-review.googlesource.com/132828
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
diff --git a/src/gpu/ccpr/GrCCAtlas.cpp b/src/gpu/ccpr/GrCCAtlas.cpp
index da4138f..afa82c4 100644
--- a/src/gpu/ccpr/GrCCAtlas.cpp
+++ b/src/gpu/ccpr/GrCCAtlas.cpp
@@ -9,6 +9,7 @@
 
 #include "GrClip.h"
 #include "GrOnFlushResourceProvider.h"
+#include "GrSurfaceContextPriv.h"
 #include "GrRectanizer_skyline.h"
 #include "GrRenderTargetContext.h"
 #include "GrTextureProxy.h"
@@ -54,14 +55,12 @@
 public:
     DEFINE_OP_CLASS_ID
 
-    DrawCoverageCountOp(sk_sp<const GrCCPathParser> parser, CoverageCountBatchID batchID,
-                        const SkISize& drawBounds)
-            : INHERITED(ClassID())
-            , fParser(std::move(parser))
-            , fBatchID(batchID)
-            , fDrawBounds(drawBounds) {
-        this->setBounds(SkRect::MakeIWH(fDrawBounds.width(), fDrawBounds.height()),
-                        GrOp::HasAABloat::kNo, GrOp::IsZeroArea::kNo);
+    static std::unique_ptr<GrDrawOp> Make(GrContext* context,
+                                          sk_sp<const GrCCPathParser> parser,
+                                          CoverageCountBatchID batchID,
+                                          const SkISize& drawBounds) {
+        return std::unique_ptr<GrDrawOp>(new DrawCoverageCountOp(std::move(parser),
+                                                                 batchID, drawBounds));
     }
 
     // GrDrawOp interface.
@@ -77,6 +76,16 @@
     }
 
 private:
+    DrawCoverageCountOp(sk_sp<const GrCCPathParser> parser, CoverageCountBatchID batchID,
+                        const SkISize& drawBounds)
+            : INHERITED(ClassID())
+            , fParser(std::move(parser))
+            , fBatchID(batchID)
+            , fDrawBounds(drawBounds) {
+        this->setBounds(SkRect::MakeIWH(fDrawBounds.width(), fDrawBounds.height()),
+                        GrOp::HasAABloat::kNo, GrOp::IsZeroArea::kNo);
+    }
+
     const sk_sp<const GrCCPathParser> fParser;
     const CoverageCountBatchID fBatchID;
     const SkISize fDrawBounds;
@@ -160,8 +169,12 @@
     SkIRect clearRect = SkIRect::MakeSize(fDrawBounds);
     rtc->clear(&clearRect, 0, GrRenderTargetContext::CanClearFullscreen::kYes);
 
-    auto op = skstd::make_unique<DrawCoverageCountOp>(std::move(parser), fCoverageCountBatchID,
-                                                      fDrawBounds);
+    GrContext* context = rtc->surfPriv().getContext();
+
+    std::unique_ptr<GrDrawOp> op = DrawCoverageCountOp::Make(context,
+                                                             std::move(parser),
+                                                             fCoverageCountBatchID,
+                                                             fDrawBounds);
     rtc->addDrawOp(GrNoClip(), std::move(op));
 
     fTextureProxy = sk_ref_sp(rtc->asTextureProxy());