Revert "Notify RTC when OpsTask is closed so it can drop ownership"

This reverts commit 198393b2de5d9632a84773034485cf486d57d3db.

Reason for revert: android crash

Original change's description:
> Notify RTC when OpsTask is closed so it can drop ownership
> 
> Change-Id: I95d32ed89447995541f33bf80730876ce9c0747a
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/284519
> Reviewed-by: Greg Daniel <egdaniel@google.com>
> Commit-Queue: Brian Salomon <bsalomon@google.com>

TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com

Change-Id: I5133fa1b8f90182864ffbee3b60bfd5781dc16bd
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/284728
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/GrOpsTask.cpp b/src/gpu/GrOpsTask.cpp
index c5f52fb..7f26afc 100644
--- a/src/gpu/GrOpsTask.cpp
+++ b/src/gpu/GrOpsTask.cpp
@@ -10,7 +10,6 @@
 #include "include/private/GrRecordingContext.h"
 #include "src/core/SkExchange.h"
 #include "src/core/SkRectPriv.h"
-#include "src/core/SkScopeExit.h"
 #include "src/core/SkTraceEvent.h"
 #include "src/gpu/GrAuditTrail.h"
 #include "src/gpu/GrCaps.h"
@@ -40,10 +39,6 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 
-GrOpsTaskClosedObserver::~GrOpsTaskClosedObserver() = default;
-
-////////////////////////////////////////////////////////////////////////////////
-
 static inline bool can_reorder(const SkRect& a, const SkRect& b) { return !GrRectsOverlap(a, b); }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -364,6 +359,7 @@
         : GrRenderTask(std::move(view))
         , fArenas(arenas)
         , fAuditTrail(auditTrail)
+        , fLastClipStackGenID(SK_InvalidUniqueID)
         SkDEBUGCODE(, fNumClips(0)) {
     fTargetView.proxy()->setLastRenderTask(this);
 }
@@ -878,12 +874,6 @@
 GrRenderTask::ExpectedOutcome GrOpsTask::onMakeClosed(
         const GrCaps& caps, SkIRect* targetUpdateBounds) {
     this->forwardCombine(caps);
-    SkScopeExit triggerObserver([&] {
-        if (fClosedObserver) {
-            fClosedObserver->wasClosed(*this);
-            fClosedObserver = nullptr;
-        }
-    });
     if (!this->isNoOp()) {
         GrSurfaceProxy* proxy = fTargetView.proxy();
         SkRect clippedContentBounds = proxy->getBoundsRect();
diff --git a/src/gpu/GrOpsTask.h b/src/gpu/GrOpsTask.h
index bcc751d..737d541 100644
--- a/src/gpu/GrOpsTask.h
+++ b/src/gpu/GrOpsTask.h
@@ -33,13 +33,6 @@
 class GrGpuBuffer;
 class GrRenderTargetProxy;
 
-/** Observer is notified when a GrOpsTask is closed. */
-class GrOpsTaskClosedObserver {
-public:
-    virtual ~GrOpsTaskClosedObserver() = 0;
-    virtual void wasClosed(const GrOpsTask& task) = 0;
-};
-
 class GrOpsTask : public GrRenderTask {
 private:
     using DstProxyView = GrXferProcessor::DstProxyView;
@@ -52,9 +45,6 @@
 
     GrOpsTask* asOpsTask() override { return this; }
 
-    /** Each OpsTask supports a single observer at a time. */
-    void setClosedObserver(GrOpsTaskClosedObserver* observer) { fClosedObserver = observer; }
-
     bool isEmpty() const { return fOpChains.empty(); }
 
     /**
@@ -295,19 +285,18 @@
     // into the owning DDL.
     GrRecordingContext::Arenas fArenas;
     GrAuditTrail*              fAuditTrail;
-    GrOpsTaskClosedObserver*   fClosedObserver = nullptr;
 
     GrLoadOp fColorLoadOp = GrLoadOp::kLoad;
     SkPMColor4f fLoadClearColor = SK_PMColor4fTRANSPARENT;
     StencilContent fInitialStencilContent = StencilContent::kDontCare;
     bool fMustPreserveStencil = false;
 
-    uint32_t fLastClipStackGenID = SK_InvalidUniqueID;
+    uint32_t fLastClipStackGenID;
     SkIRect fLastDevClipBounds;
     int fLastClipNumAnalyticFPs;
 
     // We must track if we have a wait op so that we don't delete the op when we have a full clear.
-    bool fHasWaitOp = false;
+    bool fHasWaitOp = false;;
 
     // For ops/opsTask we have mean: 5 stdDev: 28
     SkSTArray<25, OpChain, true> fOpChains;
diff --git a/src/gpu/GrRenderTargetContext.cpp b/src/gpu/GrRenderTargetContext.cpp
index 4c8ba6a..f3f6d23 100644
--- a/src/gpu/GrRenderTargetContext.cpp
+++ b/src/gpu/GrRenderTargetContext.cpp
@@ -398,9 +398,6 @@
 
 GrRenderTargetContext::~GrRenderTargetContext() {
     ASSERT_SINGLE_OWNER
-    if (fOpsTask) {
-        fOpsTask->setClosedObserver(nullptr);
-    }
 }
 
 inline GrAAType GrRenderTargetContext::chooseAAType(GrAA aa) {
@@ -426,7 +423,7 @@
     ASSERT_SINGLE_OWNER
     SkDEBUGCODE(this->validate();)
 
-    if (!fOpsTask) {
+    if (!fOpsTask || fOpsTask->isClosed()) {
         sk_sp<GrOpsTask> newOpsTask =
                 this->drawingManager()->newOpsTask(this->writeSurfaceView(), fManagedOpsTask);
         if (fOpsTask && fNumStencilSamples > 0) {
@@ -437,10 +434,9 @@
             // values?
             newOpsTask->setInitialStencilContent(GrOpsTask::StencilContent::kPreserved);
         }
-        newOpsTask->setClosedObserver(this);
         fOpsTask = std::move(newOpsTask);
     }
-    SkASSERT(!fOpsTask->isClosed());
+
     return fOpsTask.get();
 }
 
@@ -2658,8 +2654,3 @@
             SkRect::Make(clippedSrcRect));
     return true;
 }
-
-void GrRenderTargetContext::wasClosed(const GrOpsTask& task) {
-    SkASSERT(&task == fOpsTask.get());
-    fOpsTask.reset();
-}
diff --git a/src/gpu/GrRenderTargetContext.h b/src/gpu/GrRenderTargetContext.h
index 53e0e5c..c7f11cb 100644
--- a/src/gpu/GrRenderTargetContext.h
+++ b/src/gpu/GrRenderTargetContext.h
@@ -57,7 +57,7 @@
 /**
  * A helper object to orchestrate commands (draws, etc...) for GrSurfaces that are GrRenderTargets.
  */
-class GrRenderTargetContext : public GrSurfaceContext, public GrOpsTaskClosedObserver {
+class GrRenderTargetContext : public GrSurfaceContext {
 public:
     static std::unique_ptr<GrRenderTargetContext> Make(
             GrRecordingContext*, GrColorType, sk_sp<SkColorSpace>, sk_sp<GrSurfaceProxy>,
@@ -580,8 +580,6 @@
 
     GrTextTarget* textTarget() { return fTextTarget.get(); }
 
-    void wasClosed(const GrOpsTask& task) override;
-
 #if GR_TEST_UTILS
     bool testingOnly_IsInstantiated() const { return this->asSurfaceProxy()->isInstantiated(); }
     void testingOnly_SetPreserveOpsOnFullClear() { fPreserveOpsOnFullClear_TestingOnly = true; }