In GrOpFlushState, store GrOp* rather than Unique ID

This makes the comment on GrOp::uniqeID (that it's only used for audit
trail) true again. More importantly, it avoids always cycling through op
IDs, which can actually overflow. This makes Draw slightly bigger, but
saves the atomic overhead of getting a new ID for each op. Both of those
are probably too small to measure.

Bug: skia:8575
Change-Id: I6aecf0c72b85c59e8644a4574ccbeeb71997baca
Reviewed-on: https://skia-review.googlesource.com/c/173423
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
diff --git a/src/gpu/GrOpFlushState.cpp b/src/gpu/GrOpFlushState.cpp
index b531344..0b27827 100644
--- a/src/gpu/GrOpFlushState.cpp
+++ b/src/gpu/GrOpFlushState.cpp
@@ -31,9 +31,9 @@
     return fCommandBuffer->asRTCommandBuffer();
 }
 
-void GrOpFlushState::executeDrawsAndUploadsForMeshDrawOp(uint32_t opID, const SkRect& opBounds) {
+void GrOpFlushState::executeDrawsAndUploadsForMeshDrawOp(const GrOp* op, const SkRect& opBounds) {
     SkASSERT(this->rtCommandBuffer());
-    while (fCurrDraw != fDraws.end() && fCurrDraw->fOpID == opID) {
+    while (fCurrDraw != fDraws.end() && fCurrDraw->fOp == op) {
         GrDeferredUploadToken drawToken = fTokenTracker->nextTokenToFlush();
         while (fCurrUpload != fInlineUploads.end() &&
                fCurrUpload->fUploadBeforeToken == drawToken) {
@@ -124,7 +124,7 @@
     draw.fDynamicStateArrays = dynamicStateArrays;
     draw.fMeshes = meshes;
     draw.fMeshCnt = meshCnt;
-    draw.fOpID = fOpArgs->fOp->uniqueID();
+    draw.fOp = fOpArgs->fOp;
     if (firstDraw) {
         fBaseDrawToken = token;
     }
diff --git a/src/gpu/GrOpFlushState.h b/src/gpu/GrOpFlushState.h
index bb9f829..1e44935 100644
--- a/src/gpu/GrOpFlushState.h
+++ b/src/gpu/GrOpFlushState.h
@@ -40,7 +40,7 @@
     void doUpload(GrDeferredTextureUploadFn&);
 
     /** Called as ops are executed. Must be called in the same order as the ops were prepared. */
-    void executeDrawsAndUploadsForMeshDrawOp(uint32_t opID, const SkRect& opBounds);
+    void executeDrawsAndUploadsForMeshDrawOp(const GrOp* op, const SkRect& opBounds);
 
     GrGpuCommandBuffer* commandBuffer() { return fCommandBuffer; }
     // Helper function used by Ops that are only called via RenderTargetOpLists
@@ -131,8 +131,8 @@
         const GrPipeline::FixedDynamicState* fFixedDynamicState;
         const GrPipeline::DynamicStateArrays* fDynamicStateArrays;
         const GrMesh* fMeshes = nullptr;
+        const GrOp* fOp = nullptr;
         int fMeshCnt = 0;
-        uint32_t fOpID = SK_InvalidUniqueID;
     };
 
     // Storage for ops' pipelines, draws, and inline uploads.
diff --git a/src/gpu/ops/GrMeshDrawOp.cpp b/src/gpu/ops/GrMeshDrawOp.cpp
index 9d7e4a2..f5c0e39 100644
--- a/src/gpu/ops/GrMeshDrawOp.cpp
+++ b/src/gpu/ops/GrMeshDrawOp.cpp
@@ -15,7 +15,7 @@
 void GrMeshDrawOp::onPrepare(GrOpFlushState* state) { this->onPrepareDraws(state); }
 
 void GrMeshDrawOp::onExecute(GrOpFlushState* state, const SkRect& chainBounds) {
-    state->executeDrawsAndUploadsForMeshDrawOp(this->uniqueID(), chainBounds);
+    state->executeDrawsAndUploadsForMeshDrawOp(this, chainBounds);
 }
 
 //////////////////////////////////////////////////////////////////////////////