During flush store GrOp draw and upload records on GrOpFlushState instead of on the ops themselves.

Bug: skia:
Change-Id: Id99267d9e7762829a3f9bebce0e92e7b97a092f8
Reviewed-on: https://skia-review.googlesource.com/66680
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/ops/GrDrawOp.h b/src/gpu/ops/GrDrawOp.h
index f4a7102..7871d9e 100644
--- a/src/gpu/ops/GrDrawOp.h
+++ b/src/gpu/ops/GrDrawOp.h
@@ -20,9 +20,6 @@
  */
 class GrDrawOp : public GrOp {
 public:
-    /** Provides GrOpFlushState with privileged access to GrDrawOp. */
-    class FlushStateAccess;
-
     GrDrawOp(uint32_t classID) : INHERITED(classID) {}
 
     /**
@@ -50,16 +47,6 @@
     virtual RequiresDstTexture finalize(const GrCaps&, const GrAppliedClip*,
                                         GrPixelConfigIsClamped) = 0;
 
-protected:
-    struct QueuedUpload {
-        QueuedUpload(GrDeferredTextureUploadFn&& upload, GrDeferredUploadToken token)
-                : fUpload(std::move(upload)), fUploadBeforeToken(token) {}
-        GrDeferredTextureUploadFn fUpload;
-        GrDeferredUploadToken fUploadBeforeToken;
-    };
-
-    SkTArray<QueuedUpload> fInlineUploads;
-
 private:
     typedef GrOp INHERITED;
 };
diff --git a/src/gpu/ops/GrMeshDrawOp.cpp b/src/gpu/ops/GrMeshDrawOp.cpp
index a00af15..0bc782c 100644
--- a/src/gpu/ops/GrMeshDrawOp.cpp
+++ b/src/gpu/ops/GrMeshDrawOp.cpp
@@ -10,8 +10,7 @@
 #include "GrOpFlushState.h"
 #include "GrResourceProvider.h"
 
-GrMeshDrawOp::GrMeshDrawOp(uint32_t classID)
-        : INHERITED(classID), fBaseDrawToken(GrDeferredUploadToken::AlreadyFlushedToken()) {}
+GrMeshDrawOp::GrMeshDrawOp(uint32_t classID) : INHERITED(classID) {}
 
 void GrMeshDrawOp::onPrepare(GrOpFlushState* state) { this->onPrepareDraws(state); }
 
@@ -57,28 +56,5 @@
 }
 
 void GrMeshDrawOp::onExecute(GrOpFlushState* state) {
-    int currUploadIdx = 0;
-    int currMeshIdx = 0;
-
-    SkASSERT(fQueuedDraws.empty() || fBaseDrawToken == state->nextTokenToFlush());
-    SkASSERT(state->rtCommandBuffer());
-
-    for (int currDrawIdx = 0; currDrawIdx < fQueuedDraws.count(); ++currDrawIdx) {
-        GrDeferredUploadToken drawToken = state->nextTokenToFlush();
-        while (currUploadIdx < fInlineUploads.count() &&
-               fInlineUploads[currUploadIdx].fUploadBeforeToken == drawToken) {
-            state->rtCommandBuffer()->inlineUpload(state, fInlineUploads[currUploadIdx++].fUpload);
-        }
-        const QueuedDraw& draw = fQueuedDraws[currDrawIdx];
-        SkASSERT(draw.fPipeline->proxy() == state->drawOpArgs().fProxy);
-        state->rtCommandBuffer()->draw(*draw.fPipeline, *draw.fGeometryProcessor.get(),
-                                       fMeshes.begin() + currMeshIdx, nullptr, draw.fMeshCnt,
-                                       this->bounds());
-        currMeshIdx += draw.fMeshCnt;
-        state->flushToken();
-    }
-    SkASSERT(currUploadIdx == fInlineUploads.count());
-    SkASSERT(currMeshIdx == fMeshes.count());
-    fQueuedDraws.reset();
-    fInlineUploads.reset();
+    state->executeDrawsAndUploadsForMeshDrawOp(this->uniqueID(), this->bounds());
 }
diff --git a/src/gpu/ops/GrMeshDrawOp.h b/src/gpu/ops/GrMeshDrawOp.h
index 232adb2..1b8831c 100644
--- a/src/gpu/ops/GrMeshDrawOp.h
+++ b/src/gpu/ops/GrMeshDrawOp.h
@@ -25,8 +25,6 @@
 public:
     /** Abstract interface that represents a destination for a GrMeshDrawOp. */
     class Target;
-    /** Provides GrOpFlushState with privileged access to GrMeshDrawOp. */
-    class FlushStateAccess;
 
 protected:
     GrMeshDrawOp(uint32_t classID);
@@ -69,27 +67,7 @@
 private:
     void onPrepare(GrOpFlushState* state) final;
     void onExecute(GrOpFlushState* state) final;
-
     virtual void onPrepareDraws(Target*) = 0;
-
-    // A set of contiguous draws that share a draw token and primitive processor. The draws all use
-    // the op's pipeline. The meshes for the draw are stored in the fMeshes array and each
-    // Queued draw uses fMeshCnt meshes from the fMeshes array. The reason for coallescing meshes
-    // that share a primitive processor into a QueuedDraw is that it allows the Gpu object to setup
-    // the shared state once and then issue draws for each mesh.
-    struct QueuedDraw {
-        int fMeshCnt = 0;
-        GrPendingProgramElement<const GrGeometryProcessor> fGeometryProcessor;
-        const GrPipeline* fPipeline;
-    };
-
-    // All draws in all the GrMeshDrawOps have implicit tokens based on the order they are enqueued
-    // globally across all ops. This is the offset of the first entry in fQueuedDraws.
-    // fQueuedDraws[i]'s token is fBaseDrawToken + i.
-    GrDeferredUploadToken fBaseDrawToken;
-    SkSTArray<4, GrMesh> fMeshes;
-    SkSTArray<4, QueuedDraw, true> fQueuedDraws;
-
     typedef GrDrawOp INHERITED;
 };
 
@@ -154,7 +132,7 @@
     /**
      * Helper that makes a pipeline targeting the op's render target that incorporates the op's
      * GrAppliedClip.
-     * */
+     */
     GrPipeline* makePipeline(uint32_t pipelineFlags, GrProcessorSet&& processorSet,
                              GrAppliedClip&& clip) {
         GrPipeline::InitArgs pipelineArgs;