Add SkSurface flush call that takes a GrBackendSurfaceMutableState.

This new api will eventually replace the version that takes an

SkSurface::BackendAccess.
Change-Id: I48cd013725e14027f386b0b111223459944ac44a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/295567
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
diff --git a/src/gpu/GrDrawingManager.cpp b/src/gpu/GrDrawingManager.cpp
index 046c1c0..fb962f3 100644
--- a/src/gpu/GrDrawingManager.cpp
+++ b/src/gpu/GrDrawingManager.cpp
@@ -208,8 +208,12 @@
 }
 
 // MDB TODO: make use of the 'proxy' parameter.
-bool GrDrawingManager::flush(GrSurfaceProxy* proxies[], int numProxies,
-        SkSurface::BackendSurfaceAccess access, const GrFlushInfo& info) {
+bool GrDrawingManager::flush(
+        GrSurfaceProxy* proxies[],
+        int numProxies,
+        SkSurface::BackendSurfaceAccess access,
+        const GrFlushInfo& info,
+        const GrBackendSurfaceMutableState* newState) {
     SkASSERT(numProxies >= 0);
     SkASSERT(!numProxies || proxies);
     GR_CREATE_TRACE_MARKER_CONTEXT("GrDrawingManager", "flush", fContext);
@@ -227,7 +231,7 @@
     SkDEBUGCODE(this->validate());
 
     if (kNone_GrFlushFlags == info.fFlags && !info.fNumSemaphores && !info.fFinishedProc &&
-            access == SkSurface::BackendSurfaceAccess::kNoAccess) {
+            access == SkSurface::BackendSurfaceAccess::kNoAccess && !newState) {
         bool canSkip = numProxies > 0;
         for (int i = 0; i < numProxies && canSkip; ++i) {
             canSkip = !fDAG.isUsed(proxies[i]) && !this->isDDLTarget(proxies[i]);
@@ -386,7 +390,7 @@
     opMemoryPool->isEmpty();
 #endif
 
-    gpu->executeFlushInfo(proxies, numProxies, access, info);
+    gpu->executeFlushInfo(proxies, numProxies, access, info, newState);
 
     // Give the cache a chance to purge resources that become purgeable due to flushing.
     if (flushed) {
@@ -549,9 +553,12 @@
     }
 }
 
-GrSemaphoresSubmitted GrDrawingManager::flushSurfaces(GrSurfaceProxy* proxies[], int numProxies,
-                                                      SkSurface::BackendSurfaceAccess access,
-                                                      const GrFlushInfo& info) {
+GrSemaphoresSubmitted GrDrawingManager::flushSurfaces(
+        GrSurfaceProxy* proxies[],
+        int numProxies,
+        SkSurface::BackendSurfaceAccess access,
+        const GrFlushInfo& info,
+        const GrBackendSurfaceMutableState* newState) {
     if (this->wasAbandoned()) {
         if (info.fSubmittedProc) {
             info.fSubmittedProc(info.fSubmittedContext, false);
@@ -583,7 +590,7 @@
     // TODO: It is important to upgrade the drawingmanager to just flushing the
     // portion of the DAG required by 'proxies' in order to restore some of the
     // semantics of this method.
-    bool didFlush = this->flush(proxies, numProxies, access, info);
+    bool didFlush = this->flush(proxies, numProxies, access, info, newState);
     for (int i = 0; i < numProxies; ++i) {
         resolve_and_mipmap(gpu, proxies[i]);
     }
@@ -981,7 +988,8 @@
 
     auto resourceCache = direct->priv().getResourceCache();
     if (resourceCache && resourceCache->requestsFlush()) {
-        if (this->flush(nullptr, 0, SkSurface::BackendSurfaceAccess::kNoAccess, GrFlushInfo())) {
+        if (this->flush(nullptr, 0, SkSurface::BackendSurfaceAccess::kNoAccess, GrFlushInfo(),
+                        nullptr)) {
             this->submitToGpu(false);
         }
         resourceCache->purgeAsNeeded();