Make deferred upload handling and draw recording be virtual interfaces implemented by GrOpFlushState.

The motivation for this is to allow other clients of GrDrawOpAtlas. Making GrMeshDrawOp::Target also be an abstract interface is somewhat incidental to this goal.

Bug: skia:
Change-Id: I0987adfa8a269aa2ca94147e933a2827d734c1cc
Reviewed-on: https://skia-review.googlesource.com/65121
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
diff --git a/src/gpu/ops/GrMeshDrawOp.cpp b/src/gpu/ops/GrMeshDrawOp.cpp
index 2e12953..a00af15 100644
--- a/src/gpu/ops/GrMeshDrawOp.cpp
+++ b/src/gpu/ops/GrMeshDrawOp.cpp
@@ -13,10 +13,7 @@
 GrMeshDrawOp::GrMeshDrawOp(uint32_t classID)
         : INHERITED(classID), fBaseDrawToken(GrDeferredUploadToken::AlreadyFlushedToken()) {}
 
-void GrMeshDrawOp::onPrepare(GrOpFlushState* state) {
-    Target target(state, this);
-    this->onPrepareDraws(&target);
-}
+void GrMeshDrawOp::onPrepare(GrOpFlushState* state) { this->onPrepareDraws(state); }
 
 void* GrMeshDrawOp::PatternHelper::init(Target* target, size_t vertexStride,
                                         const GrBuffer* indexBuffer, int verticesPerRepetition,
@@ -85,30 +82,3 @@
     fQueuedDraws.reset();
     fInlineUploads.reset();
 }
-
-//////////////////////////////////////////////////////////////////////////////
-
-void GrMeshDrawOp::Target::draw(const GrGeometryProcessor* gp, const GrPipeline* pipeline,
-                                const GrMesh& mesh) {
-    GrMeshDrawOp* op = this->meshDrawOp();
-    op->fMeshes.push_back(mesh);
-    if (!op->fQueuedDraws.empty()) {
-        // If the last draw shares a geometry processor and pipeline and there are no intervening
-        // uploads, add this mesh to it.
-        GrMeshDrawOp::QueuedDraw& lastDraw = op->fQueuedDraws.back();
-        if (lastDraw.fGeometryProcessor == gp && lastDraw.fPipeline == pipeline &&
-            (op->fInlineUploads.empty() ||
-             op->fInlineUploads.back().fUploadBeforeToken != this->nextDrawToken())) {
-            ++lastDraw.fMeshCnt;
-            return;
-        }
-    }
-    GrMeshDrawOp::QueuedDraw& draw = op->fQueuedDraws.push_back();
-    GrDeferredUploadToken token = this->state()->issueDrawToken();
-    draw.fGeometryProcessor.reset(gp);
-    draw.fPipeline = pipeline;
-    draw.fMeshCnt = 1;
-    if (op->fQueuedDraws.count() == 1) {
-        op->fBaseDrawToken = token;
-    }
-}