Plumb GrContext everywhere

There is no good way to split the monster CL up. This breaks out
the GrContext plumbing but doesn't use it.

Change-Id: I90856d428d372bcec3f8821e6364667b367927d4
Reviewed-on: https://skia-review.googlesource.com/133382
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
diff --git a/gm/convexpolyeffect.cpp b/gm/convexpolyeffect.cpp
index fa48e7b..8f8d1b4 100644
--- a/gm/convexpolyeffect.cpp
+++ b/gm/convexpolyeffect.cpp
@@ -11,6 +11,7 @@
 
 #include "GrContext.h"
 #include "GrDefaultGeoProcFactory.h"
+#include "GrMemoryPool.h"
 #include "GrOpFlushState.h"
 #include "GrPathUtils.h"
 #include "GrRenderTargetContextPriv.h"
@@ -41,7 +42,9 @@
 public:
     DEFINE_OP_CLASS_ID
 
-    static std::unique_ptr<GrDrawOp> Make(GrPaint&& paint, const SkRect& rect) {
+    static std::unique_ptr<GrDrawOp> Make(GrContext* context,
+                                          GrPaint&& paint,
+                                          const SkRect& rect) {
         return std::unique_ptr<GrDrawOp>(new PolyBoundsOp(std::move(paint), rect));
     }
 
@@ -61,6 +64,8 @@
     }
 
 private:
+    friend class ::GrOpMemoryPool; // for ctor
+
     PolyBoundsOp(GrPaint&& paint, const SkRect& rect)
             : INHERITED(ClassID())
             , fColor(paint.getColor())
@@ -181,6 +186,11 @@
             return;
         }
 
+        GrContext* context = canvas->getGrContext();
+        if (!context) {
+            return;
+        }
+
         SkScalar y = 0;
         constexpr SkScalar kDX = 12.f;
         for (PathList::Iter iter(fPaths, PathList::Iter::kHead_IterStart);
@@ -206,7 +216,7 @@
                 grPaint.addCoverageFragmentProcessor(std::move(fp));
 
                 std::unique_ptr<GrDrawOp> op =
-                        PolyBoundsOp::Make(std::move(grPaint), p.getBounds());
+                        PolyBoundsOp::Make(context, std::move(grPaint), p.getBounds());
                 renderTargetContext->priv().testingOnly_addDrawOp(std::move(op));
 
                 x += SkScalarCeilToScalar(path->getBounds().width() + kDX);
@@ -245,7 +255,8 @@
                 grPaint.setXPFactory(GrPorterDuffXPFactory::Get(SkBlendMode::kSrc));
                 grPaint.addCoverageFragmentProcessor(std::move(fp));
 
-                std::unique_ptr<GrDrawOp> op = PolyBoundsOp::Make(std::move(grPaint), rect);
+                std::unique_ptr<GrDrawOp> op = PolyBoundsOp::Make(context, std::move(grPaint),
+                                                                  rect);
                 renderTargetContext->priv().testingOnly_addDrawOp(std::move(op));
 
                 x += SkScalarCeilToScalar(rect.width() + kDX);