Update clearOp for split-OpList world (take 3)

It would reduce a lot of noise if the GrRenderTargetOpList kept a pointer to the GrCaps but, for now, I'm trying to shrink the GrRTOpList, not expand it.

Reland of: https://skia-review.googlesource.com/c/17323/ (Update clearOp for split-OpList world)

Change-Id: Ia61ce4d6ce245380fc9651928a46c22039fc12cf
Reviewed-on: https://skia-review.googlesource.com/18026
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
diff --git a/src/gpu/GrRenderTargetContext.cpp b/src/gpu/GrRenderTargetContext.cpp
index b05be0b..7d18448 100644
--- a/src/gpu/GrRenderTargetContext.cpp
+++ b/src/gpu/GrRenderTargetContext.cpp
@@ -200,7 +200,7 @@
         if (!op) {
             return;
         }
-        this->getOpList()->addOp(std::move(op), this);
+        this->getOpList()->addOp(std::move(op), *this->caps());
     }
 }
 
@@ -259,11 +259,11 @@
         // This path doesn't handle coalescing of full screen clears b.c. it
         // has to clear the entire render target - not just the content area.
         // It could be done but will take more finagling.
-        std::unique_ptr<GrOp> op(GrClearOp::Make(rtRect, color, fRenderTargetContext, !clearRect));
+        std::unique_ptr<GrOp> op(GrClearOp::Make(rtRect, color, !clearRect));
         if (!op) {
             return;
         }
-        fRenderTargetContext->getOpList()->addOp(std::move(op), fRenderTargetContext);
+        fRenderTargetContext->getOpList()->addOp(std::move(op), *fRenderTargetContext->caps());
     }
 }
 
@@ -307,13 +307,13 @@
 
         this->drawRect(clip, std::move(paint), GrAA::kNo, SkMatrix::I(), SkRect::Make(clearRect));
     } else if (isFull) {
-        this->getOpList()->fullClear(this, color);
+        this->getOpList()->fullClear(*this->caps(), color);
     } else {
-        std::unique_ptr<GrOp> op(GrClearOp::Make(clip, color, this));
+        std::unique_ptr<GrOp> op(GrClearOp::Make(clip, color, this->asSurfaceProxy()));
         if (!op) {
             return;
         }
-        this->getOpList()->addOp(std::move(op), this);
+        this->getOpList()->addOp(std::move(op), *this->caps());
     }
 }
 
@@ -610,7 +610,7 @@
     if (!op) {
         return;
     }
-    fRenderTargetContext->getOpList()->addOp(std::move(op), fRenderTargetContext);
+    fRenderTargetContext->getOpList()->addOp(std::move(op), *fRenderTargetContext->caps());
 }
 
 void GrRenderTargetContextPriv::stencilPath(const GrClip& clip,
@@ -668,7 +668,7 @@
         return;
     }
     op->setClippedBounds(bounds);
-    fRenderTargetContext->getOpList()->addOp(std::move(op), fRenderTargetContext);
+    fRenderTargetContext->getOpList()->addOp(std::move(op), *fRenderTargetContext->caps());
 }
 
 void GrRenderTargetContextPriv::stencilRect(const GrClip& clip,
@@ -1726,14 +1726,14 @@
         return SK_InvalidUniqueID;
     }
 
-    // This forces instantiation of the render target.
-    GrRenderTarget* rt = this->accessRenderTarget();
-    if (!rt) {
-        return SK_InvalidUniqueID;
-    }
-
     if (fixedFunctionFlags & GrDrawOp::FixedFunctionFlags::kUsesStencil ||
         appliedClip.hasStencilClip()) {
+        // This forces instantiation of the render target.
+        GrRenderTarget* rt = this->accessRenderTarget();
+        if (!rt) {
+            return SK_InvalidUniqueID;
+        }
+
         if (!fContext->resourceProvider()->attachStencilAttachment(rt)) {
             SkDebugf("ERROR creating stencil attachment. Draw skipped.\n");
             return SK_InvalidUniqueID;
@@ -1748,7 +1748,8 @@
     }
 
     op->setClippedBounds(bounds);
-    return this->getOpList()->addOp(std::move(op), this, std::move(appliedClip), dstProxy);
+    return this->getOpList()->addOp(std::move(op), *this->caps(),
+                                    std::move(appliedClip), dstProxy);
 }
 
 uint32_t GrRenderTargetContext::addLegacyMeshDrawOp(GrPipelineBuilder&& pipelineBuilder,
@@ -1811,7 +1812,7 @@
     op->addDependenciesTo(fRenderTargetProxy.get());
 
     op->setClippedBounds(bounds);
-    return this->getOpList()->addOp(std::move(op), this);
+    return this->getOpList()->addOp(std::move(op), *this->caps());
 }
 
 bool GrRenderTargetContext::setupDstProxy(GrRenderTargetProxy* rtProxy, const GrClip& clip,