Elevate the target list of Ganesh tasks to base class

A follow up CL will use the availability of this information - the full
list of targets of a GrRenderTask – to enable faster storage of the
lastRenderTask association for a given surface proxy in a given drawing
manager.

Bug: skia:10320
Change-Id: I3eb3276b483a7f09481774896a024172b73a4c84
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/296729
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Adlai Holler <adlai@google.com>
diff --git a/src/gpu/GrTextureResolveRenderTask.cpp b/src/gpu/GrTextureResolveRenderTask.cpp
index 79e1531..1a915ba 100644
--- a/src/gpu/GrTextureResolveRenderTask.cpp
+++ b/src/gpu/GrTextureResolveRenderTask.cpp
@@ -14,19 +14,12 @@
 #include "src/gpu/GrResourceAllocator.h"
 #include "src/gpu/GrTexturePriv.h"
 
-void GrTextureResolveRenderTask::disown(GrDrawingManager* drawingMgr) {
-    for (const auto& resolve : fResolves) {
-        drawingMgr->setLastRenderTask(resolve.fProxy.get(), nullptr);
-    }
-    GrRenderTask::disown(drawingMgr);
-}
-
 void GrTextureResolveRenderTask::addProxy(GrDrawingManager* drawingMgr,
                                           sk_sp<GrSurfaceProxy> proxyRef,
                                           GrSurfaceProxy::ResolveFlags flags,
                                           const GrCaps& caps) {
-    fResolves.emplace_back(std::move(proxyRef), flags);
-    GrSurfaceProxy* proxy = fResolves.back().fProxy.get();
+    Resolve& resolve = fResolves.emplace_back(flags);
+    GrSurfaceProxy* proxy = proxyRef.get();
 
     // Ensure the last render task that operated on the proxy is closed. That's where msaa and
     // mipmaps should have been marked dirty.
@@ -38,7 +31,7 @@
         GrRenderTargetProxy* renderTargetProxy = proxy->asRenderTargetProxy();
         SkASSERT(renderTargetProxy);
         SkASSERT(renderTargetProxy->isMSAADirty());
-        fResolves.back().fMSAAResolveRect = renderTargetProxy->msaaDirtyRect();
+        resolve.fMSAAResolveRect = renderTargetProxy->msaaDirtyRect();
         renderTargetProxy->markMSAAResolved();
     }
 
@@ -53,7 +46,7 @@
     // generating mipmap levels and/or resolving MSAA.
     this->addDependency(drawingMgr, proxy, GrMipMapped::kNo,
                         GrTextureResolveManager(nullptr), caps);
-    drawingMgr->setLastRenderTask(proxy, this);
+    this->addTarget(drawingMgr, GrSurfaceProxyView(std::move(proxyRef)));
 }
 
 void GrTextureResolveRenderTask::gatherProxyIntervals(GrResourceAllocator* alloc) const {
@@ -61,8 +54,9 @@
     // fEndOfOpsTaskOpIndices will remain in sync. We create fake op#'s to capture the fact that we
     // manipulate the resolve proxies.
     auto fakeOp = alloc->curOp();
-    for (const auto& resolve : fResolves) {
-        alloc->addInterval(resolve.fProxy.get(), fakeOp, fakeOp,
+    SkASSERT(fResolves.count() == this->numTargets());
+    for (const GrSurfaceProxyView& target : fTargets) {
+        alloc->addInterval(target.proxy(), fakeOp, fakeOp,
                            GrResourceAllocator::ActualUse::kYes);
     }
     alloc->incOps();
@@ -70,9 +64,11 @@
 
 bool GrTextureResolveRenderTask::onExecute(GrOpFlushState* flushState) {
     // Resolve all msaa back-to-back, before regenerating mipmaps.
-    for (const auto& resolve : fResolves) {
+    SkASSERT(fResolves.count() == this->numTargets());
+    for (int i = 0; i < fResolves.count(); ++i) {
+        const Resolve& resolve = fResolves[i];
         if (GrSurfaceProxy::ResolveFlags::kMSAA & resolve.fFlags) {
-            GrSurfaceProxy* proxy = resolve.fProxy.get();
+            GrSurfaceProxy* proxy = this->target(i).proxy();
             // peekRenderTarget might be null if there was an instantiation error.
             if (GrRenderTarget* renderTarget = proxy->peekRenderTarget()) {
                 flushState->gpu()->resolveRenderTarget(renderTarget, resolve.fMSAAResolveRect,
@@ -81,10 +77,11 @@
         }
     }
     // Regenerate all mipmaps back-to-back.
-    for (const auto& resolve : fResolves) {
+    for (int i = 0; i < fResolves.count(); ++i) {
+        const Resolve& resolve = fResolves[i];
         if (GrSurfaceProxy::ResolveFlags::kMipMaps & resolve.fFlags) {
             // peekTexture might be null if there was an instantiation error.
-            GrTexture* texture = resolve.fProxy->peekTexture();
+            GrTexture* texture = this->target(i).proxy()->peekTexture();
             if (texture && texture->texturePriv().mipMapsAreDirty()) {
                 flushState->gpu()->regenerateMipMapLevels(texture);
                 SkASSERT(!texture->texturePriv().mipMapsAreDirty());
@@ -96,9 +93,5 @@
 }
 
 #ifdef SK_DEBUG
-void GrTextureResolveRenderTask::visitProxies_debugOnly(const GrOp::VisitProxyFunc& fn) const {
-    for (const auto& resolve : fResolves) {
-        fn(resolve.fProxy.get(), GrMipMapped::kNo);
-    }
-}
+void GrTextureResolveRenderTask::visitProxies_debugOnly(const GrOp::VisitProxyFunc& fn) const {}
 #endif