Delete unused GrTextureOpList.

In a follow up CL I will be merging GrRenderTargetOpList and GrOpList
since we no longer have need for that separation.

Change-Id: I267ead3beeceaece504968ca69165c425d38f761
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/236337
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
diff --git a/gn/gpu.gni b/gn/gpu.gni
index bf17651..b37ab4f 100644
--- a/gn/gpu.gni
+++ b/gn/gpu.gni
@@ -223,8 +223,6 @@
   "$_src/gpu/GrTextureContext.h",
   "$_src/gpu/GrTextureMaker.cpp",
   "$_src/gpu/GrTextureMaker.h",
-  "$_src/gpu/GrTextureOpList.cpp",
-  "$_src/gpu/GrTextureOpList.h",
   "$_src/gpu/GrTexturePriv.h",
   "$_src/gpu/GrTextureProducer.cpp",
   "$_src/gpu/GrTextureProducer.h",
diff --git a/src/gpu/GrDrawingManager.cpp b/src/gpu/GrDrawingManager.cpp
index 2437ee7..3a5e750 100644
--- a/src/gpu/GrDrawingManager.cpp
+++ b/src/gpu/GrDrawingManager.cpp
@@ -27,7 +27,6 @@
 #include "src/gpu/GrSoftwarePathRenderer.h"
 #include "src/gpu/GrSurfaceProxyPriv.h"
 #include "src/gpu/GrTextureContext.h"
-#include "src/gpu/GrTextureOpList.h"
 #include "src/gpu/GrTexturePriv.h"
 #include "src/gpu/GrTextureProxy.h"
 #include "src/gpu/GrTextureProxyPriv.h"
@@ -660,27 +659,6 @@
     return opList;
 }
 
-sk_sp<GrTextureOpList> GrDrawingManager::newTextureOpList(sk_sp<GrTextureProxy> textureProxy) {
-    SkDEBUGCODE(this->validate());
-    SkASSERT(fContext);
-
-    this->closeRenderTasksForNewRenderTask(textureProxy.get());
-
-    sk_sp<GrTextureOpList> opList(new GrTextureOpList(fContext->priv().refOpMemoryPool(),
-                                                      textureProxy,
-                                                      fContext->priv().auditTrail()));
-
-    SkASSERT(textureProxy->getLastRenderTask() == opList.get());
-
-    fDAG.add(opList);
-    if (!fDAG.sortingRenderTasks() || !fReduceOpListSplitting) {
-        fActiveOpList = opList.get();
-    }
-
-    SkDEBUGCODE(this->validate());
-    return opList;
-}
-
 GrRenderTask* GrDrawingManager::newTextureResolveRenderTask(
         sk_sp<GrTextureProxy> textureProxy, GrTextureResolveFlags flags, const GrCaps& caps) {
     // Unlike in the "new opList" cases, we do not want to close the active opList, nor (if we are
diff --git a/src/gpu/GrDrawingManager.h b/src/gpu/GrDrawingManager.h
index af833fc..6b5fc1d 100644
--- a/src/gpu/GrDrawingManager.h
+++ b/src/gpu/GrDrawingManager.h
@@ -28,7 +28,6 @@
 class GrRenderTargetOpList;
 class GrSoftwarePathRenderer;
 class GrTextureContext;
-class GrTextureOpList;
 class SkDeferredDisplayList;
 
 class GrDrawingManager {
@@ -50,7 +49,6 @@
     // A managed opList is controlled by the drawing manager (i.e., sorted & flushed with the
     // others). An unmanaged one is created and used by the onFlushCallback.
     sk_sp<GrRenderTargetOpList> newRTOpList(sk_sp<GrRenderTargetProxy>, bool managedOpList);
-    sk_sp<GrTextureOpList> newTextureOpList(sk_sp<GrTextureProxy>);
 
     // Create a new, specialized, render task that will regenerate mipmap levels and/or resolve
     // MSAA (depending on GrTextureResolveFlags). This method will add the new render task to the
diff --git a/src/gpu/GrRenderTargetContext.h b/src/gpu/GrRenderTargetContext.h
index 93a5b39..aa3281d 100644
--- a/src/gpu/GrRenderTargetContext.h
+++ b/src/gpu/GrRenderTargetContext.h
@@ -622,7 +622,7 @@
                          ReadPixelsContext context);
 
     GrRenderTargetOpList* getRTOpList();
-    GrOpList* getOpList() override;
+    GrOpList* getOpList();
 
     std::unique_ptr<GrTextTarget> fTextTarget;
     sk_sp<GrRenderTargetProxy> fRenderTargetProxy;
diff --git a/src/gpu/GrRenderTargetOpList.cpp b/src/gpu/GrRenderTargetOpList.cpp
index 4c8bf05..2d7c2c9 100644
--- a/src/gpu/GrRenderTargetOpList.cpp
+++ b/src/gpu/GrRenderTargetOpList.cpp
@@ -639,7 +639,6 @@
                            SkDEBUGCODE(, fTarget.get() == p));
     };
     for (const OpChain& recordedOp : fOpChains) {
-        // only diff from the GrTextureOpList version
         recordedOp.visitProxies(gather);
 
         // Even though the op may have been (re)moved we still need to increment the op count to
diff --git a/src/gpu/GrRenderTask.h b/src/gpu/GrRenderTask.h
index 044817a..7b2c776 100644
--- a/src/gpu/GrRenderTask.h
+++ b/src/gpu/GrRenderTask.h
@@ -18,7 +18,6 @@
 class GrOpList;
 class GrRenderTargetOpList;
 class GrResourceAllocator;
-class GrTextureOpList;
 
 // This class abstracts a task that targets a single GrSurfaceProxy, participates in the
 // GrDrawingManager's DAG, and implements the onExecute method to modify its target proxy's
@@ -55,11 +54,6 @@
     uint32_t uniqueID() const { return fUniqueID; }
 
     /*
-     * Safely cast this GrRenderTask to a GrTextureOpList (if possible).
-     */
-    virtual GrTextureOpList* asTextureOpList() { return nullptr; }
-
-    /*
      * Safely cast this GrRenderTask to a GrRenderTargetOpList (if possible).
      */
     virtual GrRenderTargetOpList* asRenderTargetOpList() { return nullptr; }
diff --git a/src/gpu/GrSurfaceContext.h b/src/gpu/GrSurfaceContext.h
index eb94a25..6bbeb72 100644
--- a/src/gpu/GrSurfaceContext.h
+++ b/src/gpu/GrSurfaceContext.h
@@ -110,7 +110,6 @@
     GrDrawingManager* drawingManager();
     const GrDrawingManager* drawingManager() const;
 
-    virtual GrOpList* getOpList() = 0;
     SkDEBUGCODE(virtual void validate() const = 0;)
 
     SkDEBUGCODE(GrSingleOwner* singleOwner();)
diff --git a/src/gpu/GrSurfaceProxy.cpp b/src/gpu/GrSurfaceProxy.cpp
index b1f4ebf..f9ec3c0 100644
--- a/src/gpu/GrSurfaceProxy.cpp
+++ b/src/gpu/GrSurfaceProxy.cpp
@@ -306,10 +306,6 @@
     return fLastRenderTask ? fLastRenderTask->asRenderTargetOpList() : nullptr;
 }
 
-GrTextureOpList* GrSurfaceProxy::getLastTextureOpList() {
-    return fLastRenderTask ? fLastRenderTask->asTextureOpList() : nullptr;
-}
-
 int GrSurfaceProxy::worstCaseWidth() const {
     SkASSERT(LazyState::kFully != this->lazyInstantiationState());
     if (fTarget) {
diff --git a/src/gpu/GrSurfaceProxy.h b/src/gpu/GrSurfaceProxy.h
index 6447396..4c78019 100644
--- a/src/gpu/GrSurfaceProxy.h
+++ b/src/gpu/GrSurfaceProxy.h
@@ -25,7 +25,6 @@
 class GrResourceProvider;
 class GrSurfaceContext;
 class GrSurfaceProxyPriv;
-class GrTextureOpList;
 class GrTextureProxy;
 
 // This is basically SkRefCntBase except Ganesh uses internalGetProxyRefCnt for more than asserts.
@@ -283,7 +282,6 @@
     GrRenderTask* getLastRenderTask() { return fLastRenderTask; }
 
     GrRenderTargetOpList* getLastRenderTargetOpList();
-    GrTextureOpList* getLastTextureOpList();
 
     /**
      * Retrieves the amount of GPU memory that will be or currently is used by this resource
diff --git a/src/gpu/GrTextureContext.cpp b/src/gpu/GrTextureContext.cpp
index a04d84a..1372a20 100644
--- a/src/gpu/GrTextureContext.cpp
+++ b/src/gpu/GrTextureContext.cpp
@@ -10,7 +10,6 @@
 #include "src/gpu/GrAuditTrail.h"
 #include "src/gpu/GrContextPriv.h"
 #include "src/gpu/GrDrawingManager.h"
-#include "src/gpu/GrTextureOpList.h"
 
 #define ASSERT_SINGLE_OWNER \
     SkDEBUGCODE(GrSingleOwner::AutoEnforce debug_SingleOwner(this->singleOwner());)
@@ -22,8 +21,7 @@
                                    SkAlphaType alphaType,
                                    sk_sp<SkColorSpace> colorSpace)
         : GrSurfaceContext(context, colorType, alphaType, std::move(colorSpace))
-        , fTextureProxy(std::move(textureProxy))
-        , fOpList(sk_ref_sp(fTextureProxy->getLastTextureOpList())) {
+        , fTextureProxy(std::move(textureProxy)) {
     SkDEBUGCODE(this->validate();)
 }
 
@@ -31,10 +29,6 @@
 void GrTextureContext::validate() const {
     SkASSERT(fTextureProxy);
     fTextureProxy->validate(fContext);
-
-    if (fOpList && !fOpList->isClosed()) {
-        SkASSERT(fTextureProxy->getLastRenderTask() == fOpList.get());
-    }
 }
 #endif
 
@@ -53,14 +47,3 @@
     SkASSERT(!fTextureProxy->asRenderTargetProxy());
     return nullptr;
 }
-
-GrOpList* GrTextureContext::getOpList() {
-    ASSERT_SINGLE_OWNER
-    SkDEBUGCODE(this->validate();)
-
-    if (!fOpList || fOpList->isClosed()) {
-        fOpList = this->drawingManager()->newTextureOpList(fTextureProxy);
-    }
-
-    return fOpList.get();
-}
diff --git a/src/gpu/GrTextureContext.h b/src/gpu/GrTextureContext.h
index ac9a43c..626c2d3 100644
--- a/src/gpu/GrTextureContext.h
+++ b/src/gpu/GrTextureContext.h
@@ -9,7 +9,6 @@
 #define GrTextureContext_DEFINED
 
 #include "src/gpu/GrSurfaceContext.h"
-#include "src/gpu/GrTextureOpList.h"
 #include "src/gpu/GrTextureProxy.h"
 
 class GrContext;
@@ -50,14 +49,8 @@
 private:
     friend class GrDrawingManager; // for ctor
 
-    GrOpList* getOpList() override;
-
     sk_sp<GrTextureProxy>  fTextureProxy;
 
-    // In MDB-mode the GrOpList can be closed by some other renderTargetContext that has picked
-    // it up. For this reason, the GrOpList should only ever be accessed via 'getOpList'.
-    sk_sp<GrTextureOpList> fOpList;
-
     typedef GrSurfaceContext INHERITED;
 };
 
diff --git a/src/gpu/GrTextureOpList.cpp b/src/gpu/GrTextureOpList.cpp
deleted file mode 100644
index 2498af5..0000000
--- a/src/gpu/GrTextureOpList.cpp
+++ /dev/null
@@ -1,227 +0,0 @@
-/*
- * Copyright 2016 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "src/gpu/GrTextureOpList.h"
-
-#include "include/gpu/GrContext.h"
-#include "include/private/GrRecordingContext.h"
-#include "src/core/SkStringUtils.h"
-#include "src/gpu/GrAuditTrail.h"
-#include "src/gpu/GrContextPriv.h"
-#include "src/gpu/GrGpu.h"
-#include "src/gpu/GrMemoryPool.h"
-#include "src/gpu/GrRecordingContextPriv.h"
-#include "src/gpu/GrResourceAllocator.h"
-#include "src/gpu/GrTexturePriv.h"
-#include "src/gpu/GrTextureProxy.h"
-
-////////////////////////////////////////////////////////////////////////////////
-
-GrTextureOpList::GrTextureOpList(sk_sp<GrOpMemoryPool> opMemoryPool,
-                                 sk_sp<GrTextureProxy> proxy,
-                                 GrAuditTrail* auditTrail)
-        : INHERITED(std::move(opMemoryPool), std::move(proxy), auditTrail) {
-    SkASSERT(fOpMemoryPool);
-    SkASSERT(!fTarget->readOnly());
-    fTarget->setLastRenderTask(this);
-}
-
-void GrTextureOpList::deleteOp(int index) {
-    SkASSERT(index >= 0 && index < fRecordedOps.count());
-    fOpMemoryPool->release(std::move(fRecordedOps[index]));
-}
-
-void GrTextureOpList::deleteOps() {
-    for (int i = 0; i < fRecordedOps.count(); ++i) {
-        if (fRecordedOps[i]) {
-            fOpMemoryPool->release(std::move(fRecordedOps[i]));
-        }
-    }
-    fRecordedOps.reset();
-    fOpMemoryPool = nullptr;
-}
-
-GrTextureOpList::~GrTextureOpList() {
-    this->deleteOps();
-}
-
-////////////////////////////////////////////////////////////////////////////////
-
-#ifdef SK_DEBUG
-void GrTextureOpList::dump(bool printDependencies) const {
-    INHERITED::dump(printDependencies);
-
-    SkDebugf("ops (%d):\n", fRecordedOps.count());
-    for (int i = 0; i < fRecordedOps.count(); ++i) {
-        if (!fRecordedOps[i]) {
-            SkDebugf("%d: <failed instantiation>\n", i);
-        } else {
-            SkDebugf("*******************************\n");
-            SkDebugf("%d: %s\n", i, fRecordedOps[i]->name());
-            SkString str = fRecordedOps[i]->dumpInfo();
-            SkDebugf("%s\n", str.c_str());
-            const SkRect& clippedBounds = fRecordedOps[i]->bounds();
-            SkDebugf("ClippedBounds: [L: %.2f, T: %.2f, R: %.2f, B: %.2f]\n",
-                     clippedBounds.fLeft, clippedBounds.fTop, clippedBounds.fRight,
-                     clippedBounds.fBottom);
-        }
-    }
-}
-
-#endif
-
-void GrTextureOpList::onPrepare(GrOpFlushState* flushState) {
-    SkASSERT(fTarget->peekTexture());
-    SkASSERT(this->isClosed());
-
-    // Loop over the ops that haven't yet generated their geometry
-    for (int i = 0; i < fRecordedOps.count(); ++i) {
-        if (fRecordedOps[i]) {
-            SkASSERT(fRecordedOps[i]->isChainHead());
-            GrOpFlushState::OpArgs opArgs = {
-                fRecordedOps[i].get(),
-                nullptr,
-                nullptr,
-                GrSwizzle(),
-                GrXferProcessor::DstProxy()
-            };
-            flushState->setOpArgs(&opArgs);
-            fRecordedOps[i]->prepare(flushState);
-            flushState->setOpArgs(nullptr);
-        }
-    }
-}
-
-bool GrTextureOpList::onExecute(GrOpFlushState* flushState) {
-    if (fRecordedOps.empty()) {
-        return false;
-    }
-
-    SkASSERT(fTarget->peekTexture());
-
-    GrGpuTextureCommandBuffer* commandBuffer(
-                         flushState->gpu()->getCommandBuffer(fTarget->peekTexture(),
-                                                             fTarget->origin()));
-    flushState->setCommandBuffer(commandBuffer);
-
-    for (int i = 0; i < fRecordedOps.count(); ++i) {
-        if (!fRecordedOps[i]) {
-            continue;
-        }
-        SkASSERT(fRecordedOps[i]->isChainHead());
-        GrOpFlushState::OpArgs opArgs = {
-            fRecordedOps[i].get(),
-            nullptr,
-            nullptr,
-            GrSwizzle(),
-            GrXferProcessor::DstProxy()
-        };
-        flushState->setOpArgs(&opArgs);
-        fRecordedOps[i]->execute(flushState, fRecordedOps[i].get()->bounds());
-        flushState->setOpArgs(nullptr);
-    }
-
-    flushState->gpu()->submit(commandBuffer);
-    flushState->setCommandBuffer(nullptr);
-
-    return true;
-}
-
-void GrTextureOpList::endFlush() {
-    this->deleteOps();
-    INHERITED::endFlush();
-}
-
-////////////////////////////////////////////////////////////////////////////////
-
-void GrTextureOpList::handleInternalAllocationFailure() {
-    bool hasUninstantiatedProxy = false;
-    auto checkInstantiation = [&hasUninstantiatedProxy](GrSurfaceProxy* p, GrMipMapped) {
-        if (!p->isInstantiated()) {
-            hasUninstantiatedProxy = true;
-        }
-    };
-    for (int i = 0; i < fRecordedOps.count(); ++i) {
-        const GrOp* op = fRecordedOps[i].get(); // only diff from the GrRenderTargetOpList version
-        hasUninstantiatedProxy = false;
-        if (op) {
-            op->visitProxies(checkInstantiation);
-        }
-        if (hasUninstantiatedProxy) {
-            // When instantiation of the proxy fails we drop the Op
-            this->deleteOp(i);
-        }
-    }
-}
-
-bool GrTextureOpList::onIsUsed(GrSurfaceProxy* proxyToCheck) const {
-    bool used = false;
-
-    auto visit = [ proxyToCheck, &used ] (GrSurfaceProxy* p, GrMipMapped) {
-        if (p == proxyToCheck) {
-            used = true;
-        }
-    };
-    for (int i = 0; i < fRecordedOps.count(); ++i) {
-        const GrOp* op = fRecordedOps[i].get();
-        if (op) {
-            op->visitProxies(visit);
-        }
-    }
-
-    return used;
-}
-
-void GrTextureOpList::gatherProxyIntervals(GrResourceAllocator* alloc) const {
-
-    // Add the interval for all the writes to this opList's target
-    if (fRecordedOps.count()) {
-        unsigned int cur = alloc->curOp();
-
-        alloc->addInterval(fTarget.get(), cur, cur+fRecordedOps.count()-1,
-                           GrResourceAllocator::ActualUse::kYes);
-    } else {
-        // This can happen if there is a loadOp (e.g., a clear) but no other draws. In this case we
-        // still need to add an interval for the destination so we create a fake op# for
-        // the missing clear op.
-        alloc->addInterval(fTarget.get(), alloc->curOp(), alloc->curOp(),
-                           GrResourceAllocator::ActualUse::kYes);
-        alloc->incOps();
-    }
-
-    auto gather = [ alloc SkDEBUGCODE(, this) ] (GrSurfaceProxy* p, GrMipMapped) {
-        alloc->addInterval(p, alloc->curOp(), alloc->curOp(), GrResourceAllocator::ActualUse::kYes
-                           SkDEBUGCODE(, p == fTarget.get()));
-    };
-    for (int i = 0; i < fRecordedOps.count(); ++i) {
-        const GrOp* op = fRecordedOps[i].get(); // only diff from the GrRenderTargetOpList version
-        if (op) {
-            op->visitProxies(gather);
-        }
-
-        // Even though the op may have been (re)moved we still need to increment the op count to
-        // keep all the math consistent.
-        alloc->incOps();
-    }
-}
-
-void GrTextureOpList::recordOp(std::unique_ptr<GrOp> op) {
-    SkASSERT(fTarget);
-    // A closed GrOpList should never receive new/more ops
-    SkASSERT(!this->isClosed());
-
-    GR_AUDIT_TRAIL_ADD_OP(fAuditTrail, op.get(), fTarget->uniqueID());
-    GrOP_INFO("Re-Recording (%s, opID: %u)\n"
-        "\tBounds LRTB (%f, %f, %f, %f)\n",
-        op->name(),
-        op->uniqueID(),
-        op->bounds().fLeft, op->bounds().fRight,
-        op->bounds().fTop, op->bounds().fBottom);
-    GrOP_INFO(SkTabString(op->dumpInfo(), 1).c_str());
-
-    fRecordedOps.emplace_back(std::move(op));
-}
diff --git a/src/gpu/GrTextureOpList.h b/src/gpu/GrTextureOpList.h
deleted file mode 100644
index 4b578b6..0000000
--- a/src/gpu/GrTextureOpList.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright 2016 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef GrTexureOpList_DEFINED
-#define GrTexureOpList_DEFINED
-
-#include "include/gpu/GrGpuResource.h"
-#include "src/gpu/GrOpList.h"
-#include "src/gpu/GrSurfaceProxy.h"
-
-#include "include/private/SkTArray.h"
-
-class GrAuditTrail;
-class GrGpu;
-class GrOp;
-class GrTextureProxy;
-struct SkIPoint;
-struct SkIRect;
-
-class GrTextureOpList final : public GrOpList {
-public:
-    GrTextureOpList(sk_sp<GrOpMemoryPool>, sk_sp<GrTextureProxy>, GrAuditTrail*);
-    ~GrTextureOpList() override;
-
-    /**
-     * Empties the draw buffer of any queued ops.
-     */
-    void endFlush() override;
-
-    /**
-     * Together these two functions flush all queued ops to GrGpuCommandBuffer. The return value
-     * of executeOps() indicates whether any commands were actually issued to the GPU.
-     */
-    void onPrepare(GrOpFlushState* flushState) override;
-    bool onExecute(GrOpFlushState* flushState) override;
-
-    GrTextureOpList* asTextureOpList() override { return this; }
-
-    SkDEBUGCODE(void dump(bool printDependencies) const override;)
-
-private:
-    bool onIsUsed(GrSurfaceProxy*) const override;
-
-    void deleteOp(int index);
-    void deleteOps();
-
-    void handleInternalAllocationFailure() override;
-
-    void gatherProxyIntervals(GrResourceAllocator*) const override;
-
-    void recordOp(std::unique_ptr<GrOp>);
-
-    ExpectedOutcome onMakeClosed(const GrCaps&) override {
-        return (fRecordedOps.empty()) ?
-                ExpectedOutcome::kTargetUnchanged : ExpectedOutcome::kTargetDirty;
-    }
-
-    // The memory for the ops in 'fOpChains' is actually stored in 'fOpMemoryPool'
-    SkSTArray<2, std::unique_ptr<GrOp>, true> fRecordedOps;
-
-    typedef GrOpList INHERITED;
-};
-
-#endif
diff --git a/src/gpu/GrTextureProxy.h b/src/gpu/GrTextureProxy.h
index 5611a5d..986975b 100644
--- a/src/gpu/GrTextureProxy.h
+++ b/src/gpu/GrTextureProxy.h
@@ -15,7 +15,6 @@
 class GrDeferredProxyUploader;
 class GrProxyProvider;
 class GrResourceProvider;
-class GrTextureOpList;
 class GrTextureProxyPriv;
 
 // This class delays the acquisition of textures until they are actually required