Add struct to wrap all the gpu flush options.

Bug: skia:8802
Change-Id: Ia92807034a8f54067cead59e29c233f91e11f175
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/208674
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
diff --git a/include/core/SkSurface.h b/include/core/SkSurface.h
index 7e68a88..6ee09e6 100644
--- a/include/core/SkSurface.h
+++ b/include/core/SkSurface.h
@@ -710,7 +710,6 @@
     };
 
     /** Issues pending SkSurface commands to the GPU-backed API and resolves any SkSurface MSAA.
-        After issuing all commands, signalSemaphores of count numSemaphores are signaled by the GPU.
         The work that is submitted to the GPU will be dependent on the BackendSurfaceAccess that is
         passed in.
 
@@ -723,42 +722,20 @@
         the GrVkImageInfo. Additionally, if the original queue was not external or foreign the
         layout of the VkImage will be set to VK_IMAGE_LAYOUT_PRESENT_SRC_KHR.
 
-        For each GrBackendSemaphore in signalSemaphores:
-        if GrBackendSemaphore is initialized, the GPU back-end uses the semaphore as is;
-        otherwise, a new semaphore is created and initializes GrBackendSemaphore.
-
-        The caller must delete the semaphores created and returned in signalSemaphores.
-        GrBackendSemaphore can be deleted as soon as this function returns.
-
-        If the back-end API is OpenGL only uninitialized backend semaphores are supported.
-
-        If the back-end API is Vulkan semaphores may be initialized or uninitialized.
-        If uninitialized, created semaphores are valid only with the VkDevice
-        with which they were created.
+        The GrFlushInfo describes additional options to flush. Please see documentation at
+        GrFlushInfo for more info.
 
         If GrSemaphoresSubmitted::kNo is returned, the GPU back-end did not create or
         add any semaphores to signal on the GPU; the caller should not instruct the GPU
-        to wait on any of the semaphores.
+        to wait on any of the semaphores passed in the GrFlushInfo.
 
         Pending surface commands are flushed regardless of the return result.
 
-        If a finishedProc is provided, the finishedProc will be called when all work submitted to
-        the gpu from this flush call and all previous flush calls has finished on the GPU. If the
-        flush call fails due to an error and nothing ends up getting sent to the GPU, the finished
-        proc is called immediately.
-
-        @param access            type of access the call will do on the backend object after flush
-        @param flags             flush options
-        @param numSemaphores     size of signalSemaphores array
-        @param signalSemaphores  array of semaphore containers
-        @param finishedProc      proc called after gpu work from flush has finished
-        @param finishedContext   context passed into call to finishedProc
-        @return                  one of: GrSemaphoresSubmitted::kYes, GrSemaphoresSubmitted::kNo
+        @param access  type of access the call will do on the backend object after flush
+        @param info    flush options
+        @return        one of: GrSemaphoresSubmitted::kYes, GrSemaphoresSubmitted::kNo
     */
-    GrSemaphoresSubmitted flush(BackendSurfaceAccess access, GrFlushFlags flags,
-                                int numSemaphores, GrBackendSemaphore signalSemaphores[],
-                                GrGpuFinishedProc finishedProc = nullptr,
-                                GrGpuFinishedContext finishedContext = nullptr);
+    GrSemaphoresSubmitted flush(BackendSurfaceAccess access, const GrFlushInfo& info);
 
     /** The below enum and flush call are deprected
      */
diff --git a/include/gpu/GrContext.h b/include/gpu/GrContext.h
index c407830..b93e0db 100644
--- a/include/gpu/GrContext.h
+++ b/include/gpu/GrContext.h
@@ -245,45 +245,29 @@
     /**
      * Call to ensure all drawing to the context has been issued to the underlying 3D API.
      */
-    void flush();
+    void flush() {
+        this->flush(GrFlushInfo());
+    }
 
     /**
-     * Call to ensure all drawing to the context has been issued to the underlying 3D API. After
-     * issuing all commands, numSemaphore semaphores will be signaled by the gpu. The client passes
-     * in an array of numSemaphores GrBackendSemaphores. In general these GrBackendSemaphore's can
-     * be either initialized or not. If they are initialized, the backend uses the passed in
-     * semaphore. If it is not initialized, a new semaphore is created and the GrBackendSemaphore
-     * object is initialized with that semaphore.
-     *
-     * The client will own and be responsible for deleting the underlying semaphores that are stored
-     * and returned in initialized GrBackendSemaphore objects. The GrBackendSemaphore objects
-     * themselves can be deleted as soon as this function returns.
-     *
-     * If the backend API is OpenGL only uninitialized GrBackendSemaphores are supported.
-     * If the backend API is Vulkan either initialized or uninitialized semaphores are supported.
-     * If uninitialized, the semaphores which are created will be valid for use only with the
-     * VkDevice with which they were created.
+     * Call to ensure all drawing to the context has been issued to the underlying 3D API.
      *
      * If this call returns GrSemaphoresSubmitted::kNo, the GPU backend will not have created or
      * added any semaphores to signal on the GPU. Thus the client should not have the GPU wait on
-     * any of the semaphores. However, any pending commands to the context will still be flushed.
-     *
-     * If a finishedProc is provided, the finishedProc will be called when all work submitted to the
-     * gpu from this flush call and all previous flush calls has finished on the GPU. If the flush
-     * call fails due to an error and nothing ends up getting sent to the GPU, the finished proc is
-     * called immediately.
+     * any of the semaphores passed in with the GrFlushInfo. However, any pending commands to the
+     * context will still be flushed.
      */
-    GrSemaphoresSubmitted flush(GrFlushFlags flags, int numSemaphores,
-                                GrBackendSemaphore signalSemaphores[],
-                                GrGpuFinishedProc finishedProc = nullptr,
-                                GrGpuFinishedContext finishedContext = nullptr);
+    GrSemaphoresSubmitted flush(const GrFlushInfo&);
 
     /**
      * Deprecated.
      */
     GrSemaphoresSubmitted flushAndSignalSemaphores(int numSemaphores,
                                                    GrBackendSemaphore signalSemaphores[]) {
-        return this->flush(kNone_GrFlushFlags, numSemaphores, signalSemaphores);
+        GrFlushInfo info;
+        info.fNumSemaphores = numSemaphores;
+        info.fSignalSemaphores = signalSemaphores;
+        return this->flush(info);
     }
 
     // Provides access to functions that aren't part of the public API.
diff --git a/include/gpu/GrTypes.h b/include/gpu/GrTypes.h
index 74ad506..4bda9a9 100644
--- a/include/gpu/GrTypes.h
+++ b/include/gpu/GrTypes.h
@@ -12,6 +12,8 @@
 #include "SkTypes.h"
 #include "GrConfig.h"
 
+class GrBackendSemaphore;
+
 ////////////////////////////////////////////////////////////////////////////////
 
 /**
@@ -269,6 +271,32 @@
 typedef void (*GrGpuFinishedProc)(GrGpuFinishedContext finishedContext);
 
 /**
+ * Struct to supply options to flush calls.
+ *
+ * After issuing all commands, fNumSemaphore semaphores will be signaled by the gpu. The client
+ * passes in an array of fNumSemaphores GrBackendSemaphores. In general these GrBackendSemaphore's
+ * can be either initialized or not. If they are initialized, the backend uses the passed in
+ * semaphore. If it is not initialized, a new semaphore is created and the GrBackendSemaphore
+ * object is initialized with that semaphore.
+ *
+ * The client will own and be responsible for deleting the underlying semaphores that are stored
+ * and returned in initialized GrBackendSemaphore objects. The GrBackendSemaphore objects
+ * themselves can be deleted as soon as this function returns.
+ *
+ * If a finishedProc is provided, the finishedProc will be called when all work submitted to the gpu
+ * from this flush call and all previous flush calls has finished on the GPU. If the flush call
+ * fails due to an error and nothing ends up getting sent to the GPU, the finished proc is called
+ * immediately.
+ */
+struct GrFlushInfo {
+    GrFlushFlags         fFlags = kNone_GrFlushFlags;
+    int                  fNumSemaphores = 0;
+    GrBackendSemaphore*  fSignalSemaphores = nullptr;
+    GrGpuFinishedProc    fFinishedProc = nullptr;
+    GrGpuFinishedContext fFinishedContext = nullptr;
+};
+
+/**
  * Enum used as return value when flush with semaphores so the client knows whether the semaphores
  * were submitted to GPU or not.
  */
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index a2ca3d1..2f4a674 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -239,26 +239,14 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 
-void GrContext::flush() {
-    ASSERT_SINGLE_OWNER
-    RETURN_IF_ABANDONED
-
-    this->drawingManager()->flush(nullptr, SkSurface::BackendSurfaceAccess::kNoAccess,
-                                  kNone_GrFlushFlags, 0, nullptr, nullptr, nullptr);
-}
-
-GrSemaphoresSubmitted GrContext::flush(GrFlushFlags flags, int numSemaphores,
-                                       GrBackendSemaphore signalSemaphores[],
-                                       GrGpuFinishedProc finishedProc,
-                                       GrGpuFinishedContext finishedContext) {
+GrSemaphoresSubmitted GrContext::flush(const GrFlushInfo& info) {
     ASSERT_SINGLE_OWNER
     if (this->abandoned()) {
         return GrSemaphoresSubmitted::kNo;
     }
 
     return this->drawingManager()->flush(nullptr, SkSurface::BackendSurfaceAccess::kNoAccess,
-                                         flags, numSemaphores, signalSemaphores, finishedProc,
-                                         finishedContext);
+                                         info);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
diff --git a/src/gpu/GrContextPriv.cpp b/src/gpu/GrContextPriv.cpp
index 31aab9c..87a4084 100644
--- a/src/gpu/GrContextPriv.cpp
+++ b/src/gpu/GrContextPriv.cpp
@@ -195,7 +195,7 @@
     ASSERT_OWNED_PROXY_PRIV(proxy);
 
     fContext->drawingManager()->flush(proxy, SkSurface::BackendSurfaceAccess::kNoAccess,
-                                      kNone_GrFlushFlags, 0, nullptr, nullptr, nullptr);
+                                      GrFlushInfo());
 }
 
 void GrContextPriv::flushSurface(GrSurfaceProxy* proxy) {
@@ -204,8 +204,7 @@
     SkASSERT(proxy);
     ASSERT_OWNED_PROXY_PRIV(proxy);
     fContext->drawingManager()->flushSurface(proxy,
-            SkSurface::BackendSurfaceAccess::kNoAccess, kNone_GrFlushFlags, 0, nullptr,
-            nullptr, nullptr);
+            SkSurface::BackendSurfaceAccess::kNoAccess, GrFlushInfo());
 }
 
 static bool valid_premul_color_type(GrColorType ct) {
diff --git a/src/gpu/GrDrawingManager.cpp b/src/gpu/GrDrawingManager.cpp
index 214cf6c..2b831e4 100644
--- a/src/gpu/GrDrawingManager.cpp
+++ b/src/gpu/GrDrawingManager.cpp
@@ -208,39 +208,35 @@
 // MDB TODO: make use of the 'proxy' parameter.
 GrSemaphoresSubmitted GrDrawingManager::flush(GrSurfaceProxy* proxy,
                                               SkSurface::BackendSurfaceAccess access,
-                                              GrFlushFlags flags,
-                                              int numSemaphores,
-                                              GrBackendSemaphore backendSemaphores[],
-                                              GrGpuFinishedProc finishedProc,
-                                              GrGpuFinishedContext finishedContext) {
+                                              const GrFlushInfo& info) {
     GR_CREATE_TRACE_MARKER_CONTEXT("GrDrawingManager", "flush", fContext);
 
     if (fFlushing || this->wasAbandoned()) {
-        if (finishedProc) {
-            finishedProc(finishedContext);
+        if (info.fFinishedProc) {
+            info.fFinishedProc(info.fFinishedContext);
         }
         return GrSemaphoresSubmitted::kNo;
     }
 
     SkDEBUGCODE(this->validate());
 
-    if (kNone_GrFlushFlags == flags && !numSemaphores && !finishedProc &&
+    if (kNone_GrFlushFlags == info.fFlags && !info.fNumSemaphores && !info.fFinishedProc &&
             proxy && !fDAG.isUsed(proxy)) {
         return GrSemaphoresSubmitted::kNo;
     }
 
     auto direct = fContext->priv().asDirectContext();
     if (!direct) {
-        if (finishedProc) {
-            finishedProc(finishedContext);
+        if (info.fFinishedProc) {
+            info.fFinishedProc(info.fFinishedContext);
         }
         return GrSemaphoresSubmitted::kNo; // Can't flush while DDL recording
     }
 
     GrGpu* gpu = direct->priv().getGpu();
     if (!gpu) {
-        if (finishedProc) {
-            finishedProc(finishedContext);
+        if (info.fFinishedProc) {
+            info.fFinishedProc(info.fFinishedContext);
         }
         return GrSemaphoresSubmitted::kNo; // Can't flush while DDL recording
     }
@@ -363,9 +359,7 @@
     opMemoryPool->isEmpty();
 #endif
 
-    GrSemaphoresSubmitted result = gpu->finishFlush(proxy, access, flags, numSemaphores,
-                                                    backendSemaphores, finishedProc,
-                                                    finishedContext);
+    GrSemaphoresSubmitted result = gpu->finishFlush(proxy, access, info);
 
     flushState.deinstantiateProxyTracker()->deinstantiateAllProxies();
 
@@ -456,7 +450,7 @@
         (*numOpListsExecuted)++;
         if (*numOpListsExecuted >= kMaxOpListsBeforeFlush) {
             flushState->gpu()->finishFlush(nullptr, SkSurface::BackendSurfaceAccess::kNoAccess,
-                                           kNone_GrFlushFlags, 0, nullptr, nullptr, nullptr);
+                                           GrFlushInfo());
             *numOpListsExecuted = 0;
         }
     }
@@ -474,7 +468,7 @@
         (*numOpListsExecuted)++;
         if (*numOpListsExecuted >= kMaxOpListsBeforeFlush) {
             flushState->gpu()->finishFlush(nullptr, SkSurface::BackendSurfaceAccess::kNoAccess,
-                                           kNone_GrFlushFlags, 0, nullptr, nullptr, nullptr);
+                                           GrFlushInfo());
             *numOpListsExecuted = 0;
         }
     }
@@ -493,9 +487,7 @@
 }
 
 GrSemaphoresSubmitted GrDrawingManager::flushSurface(
-        GrSurfaceProxy* proxy, SkSurface::BackendSurfaceAccess access, GrFlushFlags flags,
-        int numSemaphores, GrBackendSemaphore backendSemaphores[],
-        GrGpuFinishedProc finishedProc, GrGpuFinishedContext finishedContext) {
+        GrSurfaceProxy* proxy, SkSurface::BackendSurfaceAccess access, const GrFlushInfo& info) {
     if (this->wasAbandoned()) {
         return GrSemaphoresSubmitted::kNo;
     }
@@ -515,8 +507,7 @@
     // TODO: It is important to upgrade the drawingmanager to just flushing the
     // portion of the DAG required by 'proxy' in order to restore some of the
     // semantics of this method.
-    GrSemaphoresSubmitted result = this->flush(proxy, access, flags, numSemaphores,
-                                               backendSemaphores, finishedProc, finishedContext);
+    GrSemaphoresSubmitted result = this->flush(proxy, access, info);
     if (!proxy->isInstantiated()) {
         return result;
     }
@@ -773,8 +764,7 @@
 
     auto resourceCache = direct->priv().getResourceCache();
     if (resourceCache && resourceCache->requestsFlush()) {
-        this->flush(nullptr, SkSurface::BackendSurfaceAccess::kNoAccess,
-                    kNone_GrFlushFlags, 0, nullptr, nullptr, nullptr);
+        this->flush(nullptr, SkSurface::BackendSurfaceAccess::kNoAccess, GrFlushInfo());
         resourceCache->purgeAsNeeded();
     }
 }
diff --git a/src/gpu/GrDrawingManager.h b/src/gpu/GrDrawingManager.h
index 2ed2c81..0ec6ed9 100644
--- a/src/gpu/GrDrawingManager.h
+++ b/src/gpu/GrDrawingManager.h
@@ -72,11 +72,7 @@
 
     GrSemaphoresSubmitted flushSurface(GrSurfaceProxy*,
                                        SkSurface::BackendSurfaceAccess access,
-                                       GrFlushFlags flags,
-                                       int numSemaphores,
-                                       GrBackendSemaphore backendSemaphores[],
-                                       GrGpuFinishedProc finishedProc,
-                                       GrGpuFinishedContext finishedContext);
+                                       const GrFlushInfo& info);
 
     void addOnFlushCallbackObject(GrOnFlushCallbackObject*);
 
@@ -153,11 +149,7 @@
 
     GrSemaphoresSubmitted flush(GrSurfaceProxy* proxy,
                                 SkSurface::BackendSurfaceAccess access,
-                                GrFlushFlags flags,
-                                int numSemaphores,
-                                GrBackendSemaphore backendSemaphores[],
-                                GrGpuFinishedProc finishedProc,
-                                GrGpuFinishedContext finishedContext);
+                                const GrFlushInfo&);
 
     SkDEBUGCODE(void validate() const);
 
diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp
index bba9545..27bf001 100644
--- a/src/gpu/GrGpu.cpp
+++ b/src/gpu/GrGpu.cpp
@@ -414,33 +414,29 @@
 
 GrSemaphoresSubmitted GrGpu::finishFlush(GrSurfaceProxy* proxy,
                                          SkSurface::BackendSurfaceAccess access,
-                                         GrFlushFlags flags, int numSemaphores,
-                                         GrBackendSemaphore backendSemaphores[],
-                                         GrGpuFinishedProc finishedProc,
-                                         GrGpuFinishedContext finishedContext) {
+                                         const GrFlushInfo& info) {
     this->stats()->incNumFinishFlushes();
     GrResourceProvider* resourceProvider = fContext->priv().resourceProvider();
 
     if (this->caps()->fenceSyncSupport()) {
-        for (int i = 0; i < numSemaphores; ++i) {
+        for (int i = 0; i < info.fNumSemaphores; ++i) {
             sk_sp<GrSemaphore> semaphore;
-            if (backendSemaphores[i].isInitialized()) {
+            if (info.fSignalSemaphores[i].isInitialized()) {
                 semaphore = resourceProvider->wrapBackendSemaphore(
-                        backendSemaphores[i], GrResourceProvider::SemaphoreWrapType::kWillSignal,
+                        info.fSignalSemaphores[i],
+                        GrResourceProvider::SemaphoreWrapType::kWillSignal,
                         kBorrow_GrWrapOwnership);
             } else {
                 semaphore = resourceProvider->makeSemaphore(false);
             }
             this->insertSemaphore(semaphore);
 
-            if (!backendSemaphores[i].isInitialized()) {
-                backendSemaphores[i] = semaphore->backendSemaphore();
+            if (!info.fSignalSemaphores[i].isInitialized()) {
+                info.fSignalSemaphores[i] = semaphore->backendSemaphore();
             }
         }
     }
-    this->onFinishFlush(proxy, access, flags,
-                        (numSemaphores > 0 && this->caps()->fenceSyncSupport()),
-                        finishedProc, finishedContext);
+    this->onFinishFlush(proxy, access, info);
     return this->caps()->fenceSyncSupport() ? GrSemaphoresSubmitted::kYes
                                             : GrSemaphoresSubmitted::kNo;
 }
diff --git a/src/gpu/GrGpu.h b/src/gpu/GrGpu.h
index adbe926..3e58908 100644
--- a/src/gpu/GrGpu.h
+++ b/src/gpu/GrGpu.h
@@ -304,10 +304,7 @@
     // insert any numSemaphore semaphores on the gpu and set the backendSemaphores to match the
     // inserted semaphores.
     GrSemaphoresSubmitted finishFlush(GrSurfaceProxy*, SkSurface::BackendSurfaceAccess access,
-                                      GrFlushFlags flags, int numSemaphores,
-                                      GrBackendSemaphore backendSemaphores[],
-                                      GrGpuFinishedProc finishedProc,
-                                      GrGpuFinishedContext finishedContext);
+                                      const GrFlushInfo&);
 
     virtual void submit(GrGpuCommandBuffer*) = 0;
 
@@ -549,9 +546,7 @@
                                bool canDiscardOutsideDstRect) = 0;
 
     virtual void onFinishFlush(GrSurfaceProxy*, SkSurface::BackendSurfaceAccess access,
-                               GrFlushFlags flags, bool insertedSemaphores,
-                               GrGpuFinishedProc finishedProc,
-                               GrGpuFinishedContext finishedContext) = 0;
+                               const GrFlushInfo&) = 0;
 
 #ifdef SK_ENABLE_DUMP_GPU
     virtual void onDumpJSON(SkJSONWriter*) const {}
diff --git a/src/gpu/GrRenderTargetContext.cpp b/src/gpu/GrRenderTargetContext.cpp
index 31d0ecf..224fc36 100644
--- a/src/gpu/GrRenderTargetContext.cpp
+++ b/src/gpu/GrRenderTargetContext.cpp
@@ -1740,10 +1740,8 @@
     this->getRTOpList()->addOp(std::move(op), *this->caps());
 }
 
-GrSemaphoresSubmitted GrRenderTargetContext::flush(
-        SkSurface::BackendSurfaceAccess access, GrFlushFlags flags, int numSemaphores,
-        GrBackendSemaphore backendSemaphores[], GrGpuFinishedProc finishedProc,
-        GrGpuFinishedContext finishedContext) {
+GrSemaphoresSubmitted GrRenderTargetContext::flush(SkSurface::BackendSurfaceAccess access,
+                                                   const GrFlushInfo& info) {
     ASSERT_SINGLE_OWNER
     if (fContext->priv().abandoned()) {
         return GrSemaphoresSubmitted::kNo;
@@ -1751,9 +1749,7 @@
     SkDEBUGCODE(this->validate();)
     GR_CREATE_TRACE_MARKER_CONTEXT("GrRenderTargetContext", "prepareForExternalIO", fContext);
 
-    return this->drawingManager()->flushSurface(fRenderTargetProxy.get(), access, flags,
-                                                numSemaphores, backendSemaphores,
-                                                finishedProc, finishedContext);
+    return this->drawingManager()->flushSurface(fRenderTargetProxy.get(), access, info);
 }
 
 bool GrRenderTargetContext::waitOnSemaphores(int numSemaphores,
diff --git a/src/gpu/GrRenderTargetContext.h b/src/gpu/GrRenderTargetContext.h
index c902dba..f8e113e 100644
--- a/src/gpu/GrRenderTargetContext.h
+++ b/src/gpu/GrRenderTargetContext.h
@@ -406,9 +406,7 @@
      * After this returns any pending surface IO will be issued to the backend 3D API and
      * if the surface has MSAA it will be resolved.
      */
-    GrSemaphoresSubmitted flush(SkSurface::BackendSurfaceAccess access, GrFlushFlags flags,
-                                int numSemaphores, GrBackendSemaphore backendSemaphores[],
-                                GrGpuFinishedProc finishedProc, GrGpuFinishedContext finishedContext);
+    GrSemaphoresSubmitted flush(SkSurface::BackendSurfaceAccess access, const GrFlushInfo&);
 
     /**
      *  The next time this GrRenderTargetContext is flushed, the gpu will wait on the passed in
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 0884a5d..c9d70cc 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -1631,18 +1631,14 @@
 ///////////////////////////////////////////////////////////////////////////////
 
 void SkGpuDevice::flush() {
-    this->flush(SkSurface::BackendSurfaceAccess::kNoAccess, kNone_GrFlushFlags, 0, nullptr, nullptr,
-                nullptr);
+    this->flush(SkSurface::BackendSurfaceAccess::kNoAccess, GrFlushInfo());
 }
 
-GrSemaphoresSubmitted SkGpuDevice::flush(SkSurface::BackendSurfaceAccess access, GrFlushFlags flags,
-                                         int numSemaphores, GrBackendSemaphore signalSemaphores[],
-                                         GrGpuFinishedProc finishedProc,
-                                         GrGpuFinishedContext finishedContext) {
+GrSemaphoresSubmitted SkGpuDevice::flush(SkSurface::BackendSurfaceAccess access,
+                                         const GrFlushInfo& info) {
     ASSERT_SINGLE_OWNER
 
-    return fRenderTargetContext->flush(access, flags, numSemaphores, signalSemaphores, finishedProc,
-                                       finishedContext);
+    return fRenderTargetContext->flush(access, info);
 }
 
 bool SkGpuDevice::wait(int numSemaphores, const GrBackendSemaphore* waitSemaphores) {
diff --git a/src/gpu/SkGpuDevice.h b/src/gpu/SkGpuDevice.h
index fca1b27..ad0f097 100644
--- a/src/gpu/SkGpuDevice.h
+++ b/src/gpu/SkGpuDevice.h
@@ -120,12 +120,7 @@
     sk_sp<SkSpecialImage> snapBackImage(const SkIRect&) override;
 
     void flush() override;
-    GrSemaphoresSubmitted flush(SkSurface::BackendSurfaceAccess access,
-                                GrFlushFlags flags,
-                                int numSemaphores,
-                                GrBackendSemaphore signalSemaphores[],
-                                GrGpuFinishedProc finishedProc,
-                                GrGpuFinishedContext finishedContext);
+    GrSemaphoresSubmitted flush(SkSurface::BackendSurfaceAccess access, const GrFlushInfo&);
     bool wait(int numSemaphores, const GrBackendSemaphore* waitSemaphores);
 
     bool onAccessPixels(SkPixmap*) override;
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index 148b649..d34abce 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -4275,19 +4275,18 @@
 }
 
 void GrGLGpu::onFinishFlush(GrSurfaceProxy*, SkSurface::BackendSurfaceAccess access,
-                            GrFlushFlags flags, bool insertedSemaphore,
-                            GrGpuFinishedProc finishedProc,
-                            GrGpuFinishedContext finishedContext) {
+                            const GrFlushInfo& info) {
     // If we inserted semaphores during the flush, we need to call GLFlush.
+    bool insertedSemaphore = info.fNumSemaphores > 0 && this->caps()->fenceSyncSupport();
     if (insertedSemaphore) {
         GL_CALL(Flush());
     }
-    if (flags & kSyncCpu_GrFlushFlag) {
+    if (info.fFlags & kSyncCpu_GrFlushFlag) {
         GL_CALL(Finish());
     }
     // TODO: We should have GL actually wait until the GPU has finished work on the GPU.
-    if (finishedProc) {
-        finishedProc(finishedContext);
+    if (info.fFinishedProc) {
+        info.fFinishedProc(info.fFinishedContext);
     }
 }
 
diff --git a/src/gpu/gl/GrGLGpu.h b/src/gpu/gl/GrGLGpu.h
index a85f918..cddcf06 100644
--- a/src/gpu/gl/GrGLGpu.h
+++ b/src/gpu/gl/GrGLGpu.h
@@ -293,9 +293,7 @@
     void flushBlend(const GrXferProcessor::BlendInfo& blendInfo, const GrSwizzle&);
 
     void onFinishFlush(GrSurfaceProxy*, SkSurface::BackendSurfaceAccess access,
-                       GrFlushFlags flags, bool insertedSemaphores,
-                       GrGpuFinishedProc finishedProc,
-                       GrGpuFinishedContext finishedContext) override;
+                       const GrFlushInfo&) override;
 
     bool copySurfaceAsDraw(GrSurface* dst, GrSurfaceOrigin dstOrigin,
                            GrSurface* src, GrSurfaceOrigin srcOrigin,
diff --git a/src/gpu/mock/GrMockGpu.h b/src/gpu/mock/GrMockGpu.h
index c9095fe..c080936 100644
--- a/src/gpu/mock/GrMockGpu.h
+++ b/src/gpu/mock/GrMockGpu.h
@@ -110,11 +110,9 @@
     void onResolveRenderTarget(GrRenderTarget* target) override { return; }
 
     void onFinishFlush(GrSurfaceProxy*, SkSurface::BackendSurfaceAccess access,
-                       GrFlushFlags flags, bool insertedSemaphores,
-                       GrGpuFinishedProc finishedProc,
-                       GrGpuFinishedContext finishedContext) override {
-        if (finishedProc) {
-            finishedProc(finishedContext);
+                       const GrFlushInfo& info) override {
+        if (info.fFinishedProc) {
+            info.fFinishedProc(info.fFinishedContext);
         }
     }
 
diff --git a/src/gpu/mtl/GrMtlGpu.h b/src/gpu/mtl/GrMtlGpu.h
index e806996..ba738ea 100644
--- a/src/gpu/mtl/GrMtlGpu.h
+++ b/src/gpu/mtl/GrMtlGpu.h
@@ -179,20 +179,18 @@
     void onResolveRenderTarget(GrRenderTarget* target) override { return; }
 
     void onFinishFlush(GrSurfaceProxy*, SkSurface::BackendSurfaceAccess access,
-                       GrFlushFlags flags, bool insertedSemaphores,
-                       GrGpuFinishedProc finishedProc,
-                       GrGpuFinishedContext finishedContext) override {
-        if (flags & kSyncCpu_GrFlushFlag) {
+                       const GrFlushInfo& info) override {
+        if (info.fFlags & kSyncCpu_GrFlushFlag) {
             this->submitCommandBuffer(kForce_SyncQueue);
-            if (finishedProc) {
-                finishedProc(finishedContext);
+            if (info.fFinishedProc) {
+                info.fFinishedProc(info.fFinishedContext);
             }
         } else {
             this->submitCommandBuffer(kSkip_SyncQueue);
             // TODO: support finishedProc to actually be called when the GPU is done with the work
             // and not immediately.
-            if (finishedProc) {
-                finishedProc(finishedContext);
+            if (info.fFinishedProc) {
+                info.fFinishedProc(info.fFinishedContext);
             }
         }
     }
diff --git a/src/gpu/vk/GrVkGpu.cpp b/src/gpu/vk/GrVkGpu.cpp
index 389a49a..3742fa4 100644
--- a/src/gpu/vk/GrVkGpu.cpp
+++ b/src/gpu/vk/GrVkGpu.cpp
@@ -1876,8 +1876,7 @@
 }
 
 void GrVkGpu::onFinishFlush(GrSurfaceProxy* proxy, SkSurface::BackendSurfaceAccess access,
-                            GrFlushFlags flags, bool insertedSemaphore,
-                            GrGpuFinishedProc finishedProc, GrGpuFinishedContext finishedContext) {
+                            const GrFlushInfo& info) {
     // Submit the current command buffer to the Queue. Whether we inserted semaphores or not does
     // not effect what we do here.
     if (proxy && access == SkSurface::BackendSurfaceAccess::kPresent) {
@@ -1892,10 +1891,10 @@
         }
         image->prepareForPresent(this);
     }
-    if (flags & kSyncCpu_GrFlushFlag) {
-        this->submitCommandBuffer(kForce_SyncQueue, finishedProc, finishedContext);
+    if (info.fFlags & kSyncCpu_GrFlushFlag) {
+        this->submitCommandBuffer(kForce_SyncQueue, info.fFinishedProc, info.fFinishedContext);
     } else {
-        this->submitCommandBuffer(kSkip_SyncQueue, finishedProc, finishedContext);
+        this->submitCommandBuffer(kSkip_SyncQueue, info.fFinishedProc, info.fFinishedContext);
     }
 }
 
diff --git a/src/gpu/vk/GrVkGpu.h b/src/gpu/vk/GrVkGpu.h
index f161353..7ec24ab 100644
--- a/src/gpu/vk/GrVkGpu.h
+++ b/src/gpu/vk/GrVkGpu.h
@@ -219,9 +219,8 @@
                        GrSurfaceOrigin srcOrigin, const SkIRect& srcRect,
                        const SkIPoint& dstPoint, bool canDiscardOutsideDstRect) override;
 
-    void onFinishFlush(GrSurfaceProxy*, SkSurface::BackendSurfaceAccess access, GrFlushFlags flags,
-                       bool insertedSemaphores, GrGpuFinishedProc finishedProc,
-                       GrGpuFinishedContext finishedContext) override;
+    void onFinishFlush(GrSurfaceProxy*, SkSurface::BackendSurfaceAccess access,
+                       const GrFlushInfo&) override;
 
     // Ends and submits the current command buffer to the queue and then creates a new command
     // buffer and begins it. If sync is set to kForce_SyncQueue, the function will wait for all
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp
index 7d0c0c5..c5f4915 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -654,8 +654,9 @@
                                             std::move(cs));
     texContext->writePixels(srcInfo, pixmap.addr(0, 0), pixmap.rowBytes(), 0, 0);
 
-    drawingManager->flush(proxy.get(), SkSurface::BackendSurfaceAccess::kNoAccess,
-                          kSyncCpu_GrFlushFlag, 0, nullptr, nullptr, nullptr);
+    GrFlushInfo info;
+    info.fFlags = kSyncCpu_GrFlushFlag;
+    drawingManager->flush(proxy.get(), SkSurface::BackendSurfaceAccess::kNoAccess, info);
 
     return image;
 }
diff --git a/src/image/SkSurface.cpp b/src/image/SkSurface.cpp
index c5c07dc..0b6409a 100644
--- a/src/image/SkSurface.cpp
+++ b/src/image/SkSurface.cpp
@@ -240,28 +240,29 @@
 }
 
 void SkSurface::flush() {
-    asSB(this)->onFlush(BackendSurfaceAccess::kNoAccess, kNone_GrFlushFlags, 0, nullptr,
-                        nullptr, nullptr);
+    this->flush(BackendSurfaceAccess::kNoAccess, GrFlushInfo());
 }
 
-GrSemaphoresSubmitted SkSurface::flush(BackendSurfaceAccess access, GrFlushFlags flags,
-                                       int numSemaphores, GrBackendSemaphore signalSemaphores[],
-                                       GrGpuFinishedProc finishedProc,
-                                       GrGpuFinishedContext finishedContext) {
-    return asSB(this)->onFlush(access, flags, numSemaphores, signalSemaphores, finishedProc,
-                               finishedContext);
+GrSemaphoresSubmitted SkSurface::flush(BackendSurfaceAccess access, const GrFlushInfo& flushInfo) {
+    return asSB(this)->onFlush(access, flushInfo);
 }
 
 GrSemaphoresSubmitted SkSurface::flush(BackendSurfaceAccess access, FlushFlags flags,
                                        int numSemaphores, GrBackendSemaphore signalSemaphores[]) {
     GrFlushFlags grFlags = flags == kSyncCpu_FlushFlag ? kSyncCpu_GrFlushFlag : kNone_GrFlushFlags;
-    return this->flush(access, grFlags, numSemaphores, signalSemaphores);
+    GrFlushInfo info;
+    info.fFlags = grFlags;
+    info.fNumSemaphores = numSemaphores;
+    info.fSignalSemaphores = signalSemaphores;
+    return this->flush(access, info);
 }
 
 GrSemaphoresSubmitted SkSurface::flushAndSignalSemaphores(int numSemaphores,
                                                           GrBackendSemaphore signalSemaphores[]) {
-    return asSB(this)->onFlush(BackendSurfaceAccess::kNoAccess, kNone_GrFlushFlags,
-                               numSemaphores, signalSemaphores, nullptr, nullptr);
+    GrFlushInfo info;
+    info.fNumSemaphores = numSemaphores;
+    info.fSignalSemaphores = signalSemaphores;
+    return this->flush(BackendSurfaceAccess::kNoAccess, info);
 }
 
 bool SkSurface::wait(int numSemaphores, const GrBackendSemaphore* waitSemaphores) {
diff --git a/src/image/SkSurface_Base.h b/src/image/SkSurface_Base.h
index 5b1afcc..54d58c1 100644
--- a/src/image/SkSurface_Base.h
+++ b/src/image/SkSurface_Base.h
@@ -80,11 +80,7 @@
      * Inserts the requested number of semaphores for the gpu to signal when work is complete on the
      * gpu and inits the array of GrBackendSemaphores with the signaled semaphores.
      */
-    virtual GrSemaphoresSubmitted onFlush(BackendSurfaceAccess access, GrFlushFlags flags,
-                                          int numSemaphores,
-                                          GrBackendSemaphore signalSemaphores[],
-                                          GrGpuFinishedProc finishedProc,
-                                          GrGpuFinishedContext finishedContext) {
+    virtual GrSemaphoresSubmitted onFlush(BackendSurfaceAccess access, const GrFlushInfo&) {
         return GrSemaphoresSubmitted::kNo;
     }
 
diff --git a/src/image/SkSurface_Gpu.cpp b/src/image/SkSurface_Gpu.cpp
index fce5cc8..5c3b567 100644
--- a/src/image/SkSurface_Gpu.cpp
+++ b/src/image/SkSurface_Gpu.cpp
@@ -50,8 +50,7 @@
     }
 
     // Grab the render target *after* firing notifications, as it may get switched if CoW kicks in.
-    surface->getDevice()->flush(SkSurface::BackendSurfaceAccess::kNoAccess,
-                                kNone_GrFlushFlags, 0, nullptr, nullptr, nullptr);
+    surface->getDevice()->flush(SkSurface::BackendSurfaceAccess::kNoAccess, GrFlushInfo());
     GrRenderTargetContext* rtc = surface->getDevice()->accessRenderTargetContext();
     return rtc->accessRenderTarget();
 }
@@ -158,13 +157,9 @@
     fDevice->accessRenderTargetContext()->discard();
 }
 
-GrSemaphoresSubmitted SkSurface_Gpu::onFlush(BackendSurfaceAccess access, GrFlushFlags flags,
-                                             int numSemaphores,
-                                             GrBackendSemaphore signalSemaphores[],
-                                             GrGpuFinishedProc finishedProc,
-                                             GrGpuFinishedContext finishedContext) {
-    return fDevice->flush(access, flags, numSemaphores, signalSemaphores, finishedProc,
-                          finishedContext);
+GrSemaphoresSubmitted SkSurface_Gpu::onFlush(BackendSurfaceAccess access,
+                                             const GrFlushInfo& info) {
+    return fDevice->flush(access, info);
 }
 
 bool SkSurface_Gpu::onWait(int numSemaphores, const GrBackendSemaphore* waitSemaphores) {
diff --git a/src/image/SkSurface_Gpu.h b/src/image/SkSurface_Gpu.h
index c708d22..be7532c 100644
--- a/src/image/SkSurface_Gpu.h
+++ b/src/image/SkSurface_Gpu.h
@@ -32,11 +32,7 @@
     void onWritePixels(const SkPixmap&, int x, int y) override;
     void onCopyOnWrite(ContentChangeMode) override;
     void onDiscard() override;
-    GrSemaphoresSubmitted onFlush(BackendSurfaceAccess access, GrFlushFlags flags,
-                                  int numSemaphores,
-                                  GrBackendSemaphore signalSemaphores[],
-                                  GrGpuFinishedProc finishedProc,
-                                  GrGpuFinishedContext finishedContext) override;
+    GrSemaphoresSubmitted onFlush(BackendSurfaceAccess access, const GrFlushInfo& info) override;
     bool onWait(int numSemaphores, const GrBackendSemaphore* waitSemaphores) override;
     bool onCharacterize(SkSurfaceCharacterization*) const override;
     void onDraw(SkCanvas* canvas, SkScalar x, SkScalar y, const SkPaint* paint) override;
diff --git a/tests/DefaultPathRendererTest.cpp b/tests/DefaultPathRendererTest.cpp
index 677c924..8de67d0 100644
--- a/tests/DefaultPathRendererTest.cpp
+++ b/tests/DefaultPathRendererTest.cpp
@@ -99,8 +99,7 @@
         rtc->drawPath(GrNoClip(), std::move(paint), GrAA::kNo,
                       SkMatrix::I(), invPath, style);
 
-        rtc->flush(SkSurface::BackendSurfaceAccess::kNoAccess,
-                   kNone_GrFlushFlags, 0, nullptr, nullptr, nullptr);
+        rtc->flush(SkSurface::BackendSurfaceAccess::kNoAccess, GrFlushInfo());
     }
 
     {
diff --git a/tests/GLProgramsTest.cpp b/tests/GLProgramsTest.cpp
index 9cdd113..4b230a8 100644
--- a/tests/GLProgramsTest.cpp
+++ b/tests/GLProgramsTest.cpp
@@ -313,8 +313,7 @@
         GrDrawRandomOp(&random, renderTargetContext.get(), std::move(paint));
     }
     // Flush everything, test passes if flush is successful(ie, no asserts are hit, no crashes)
-    drawingManager->flush(nullptr, SkSurface::BackendSurfaceAccess::kNoAccess,
-                          kNone_GrFlushFlags, 0, nullptr, nullptr, nullptr);
+    drawingManager->flush(nullptr, SkSurface::BackendSurfaceAccess::kNoAccess, GrFlushInfo());
 
     const GrBackendFormat format =
             context->priv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
@@ -344,7 +343,7 @@
             paint.addColorFragmentProcessor(std::move(blockFP));
             GrDrawRandomOp(&random, renderTargetContext.get(), std::move(paint));
             drawingManager->flush(nullptr, SkSurface::BackendSurfaceAccess::kNoAccess,
-                                  kNone_GrFlushFlags, 0, nullptr, nullptr, nullptr);
+                                  GrFlushInfo());
         }
     }
 
diff --git a/tests/GrFinishedFlushTest.cpp b/tests/GrFinishedFlushTest.cpp
index 6b825b1..2584113 100644
--- a/tests/GrFinishedFlushTest.cpp
+++ b/tests/GrFinishedFlushTest.cpp
@@ -30,20 +30,23 @@
     // We flush the surface first just to get rid of any discards/clears that got recorded from
     // making the surface.
     surface->flush();
-    ctx->flush(kSyncCpu_GrFlushFlag, 0, nullptr);
+    GrFlushInfo flushInfoSyncCpu;
+    flushInfoSyncCpu.fFlags = kSyncCpu_GrFlushFlag;
+    ctx->flush(flushInfoSyncCpu);
 
     int count = 0;
 
+    GrFlushInfo flushInfoFinishedProc;
+    flushInfoFinishedProc.fFinishedProc = testing_finished_proc;
+    flushInfoFinishedProc.fFinishedContext = (void*)&count;
     // There is no work on the surface so flushing should immediately call the finished proc.
-    surface->flush(SkSurface::BackendSurfaceAccess::kNoAccess, kNone_GrFlushFlags, 0, nullptr,
-                   testing_finished_proc, (void*)&count);
+    surface->flush(SkSurface::BackendSurfaceAccess::kNoAccess, flushInfoFinishedProc);
 
     REPORTER_ASSERT(reporter, count == 1);
 
     canvas->clear(SK_ColorRED);
 
-    surface->flush(SkSurface::BackendSurfaceAccess::kNoAccess, kNone_GrFlushFlags, 0, nullptr,
-                   testing_finished_proc, (void*)&count);
+    surface->flush(SkSurface::BackendSurfaceAccess::kNoAccess, flushInfoFinishedProc);
 
     bool isVulkan = ctx->backend() == GrBackendApi::kVulkan;
     if (isVulkan) {
@@ -53,12 +56,12 @@
     } else {
         REPORTER_ASSERT(reporter, count == 2);
     }
-    ctx->flush(kSyncCpu_GrFlushFlag, 0, nullptr);
+    ctx->flush(flushInfoSyncCpu);
     REPORTER_ASSERT(reporter, count == 2);
 
     // Test flushing via the GrContext
     canvas->clear(SK_ColorBLUE);
-    ctx->flush(kNone_GrFlushFlags, 0, nullptr, testing_finished_proc, (void*)&count);
+    ctx->flush(flushInfoFinishedProc);
     if (isVulkan) {
         // On Vulkan the command buffer we just submitted may or may not have finished immediately
         // so the finish proc may not have been called.
@@ -66,25 +69,25 @@
     } else {
         REPORTER_ASSERT(reporter, count == 3);
     }
-    ctx->flush(kSyncCpu_GrFlushFlag, 0, nullptr);
+    ctx->flush(flushInfoSyncCpu);
     REPORTER_ASSERT(reporter, count == 3);
 
     // There is no work on the surface so flushing should immediately call the finished proc.
-    ctx->flush(kNone_GrFlushFlags, 0, nullptr, testing_finished_proc, (void*)&count);
+    ctx->flush(flushInfoFinishedProc);
     REPORTER_ASSERT(reporter, count == 4);
 
     count = 0;
     int count2 = 0;
     canvas->clear(SK_ColorGREEN);
-    surface->flush(SkSurface::BackendSurfaceAccess::kNoAccess, kNone_GrFlushFlags, 0, nullptr,
-                   testing_finished_proc, (void*)&count);
+    surface->flush(SkSurface::BackendSurfaceAccess::kNoAccess, flushInfoFinishedProc);
     // There is no work to be flushed here so this will return immediately, but make sure the
     // finished call from this proc isn't called till the previous surface flush also is finished.
-    ctx->flush(kNone_GrFlushFlags, 0, nullptr, testing_finished_proc, (void*)&count2);
+    flushInfoFinishedProc.fFinishedContext = (void*)&count2;
+    ctx->flush(flushInfoFinishedProc);
 
     REPORTER_ASSERT(reporter, count == count2);
 
-    ctx->flush(kSyncCpu_GrFlushFlag, 0, nullptr);
+    ctx->flush(flushInfoSyncCpu);
 
     REPORTER_ASSERT(reporter, count == 1);
     REPORTER_ASSERT(reporter, count == count2);
diff --git a/tests/OnFlushCallbackTest.cpp b/tests/OnFlushCallbackTest.cpp
index 0dc14ef..54982bc 100644
--- a/tests/OnFlushCallbackTest.cpp
+++ b/tests/OnFlushCallbackTest.cpp
@@ -580,8 +580,7 @@
         rtc->drawRect(GrNoClip(), std::move(paint), GrAA::kNo, SkMatrix::I(), r);
     }
 
-    rtc->flush(SkSurface::BackendSurfaceAccess::kNoAccess, kNone_GrFlushFlags, 0, nullptr, nullptr,
-               nullptr);
+    rtc->flush(SkSurface::BackendSurfaceAccess::kNoAccess, GrFlushInfo());
 
     SkBitmap readBack;
     readBack.allocN32Pixels(kFinalWidth, kFinalHeight);
diff --git a/tests/SurfaceSemaphoreTest.cpp b/tests/SurfaceSemaphoreTest.cpp
index fd3b449..bc2d53c 100644
--- a/tests/SurfaceSemaphoreTest.cpp
+++ b/tests/SurfaceSemaphoreTest.cpp
@@ -143,10 +143,13 @@
     }
 #endif
 
+    GrFlushInfo info;
+    info.fNumSemaphores = 2;
+    info.fSignalSemaphores = semaphores.get();
     if (flushContext) {
-        mainCtx->flush(kNone_GrFlushFlags, 2, semaphores.get());
+        mainCtx->flush(info);
     } else {
-        mainSurface->flushAndSignalSemaphores(2, semaphores.get());
+        mainSurface->flush(SkSurface::BackendSurfaceAccess::kNoAccess, info);
     }
 
     sk_sp<SkImage> mainImage = mainSurface->makeImageSnapshot();
diff --git a/tests/TransferPixelsTest.cpp b/tests/TransferPixelsTest.cpp
index a9f43d5..db054ee 100644
--- a/tests/TransferPixelsTest.cpp
+++ b/tests/TransferPixelsTest.cpp
@@ -272,9 +272,10 @@
         }
         ++expectedTransferCnt;
 
+        GrFlushInfo flushInfo;
+        flushInfo.fFlags = kSyncCpu_GrFlushFlag;
         if (context->priv().caps()->mapBufferFlags() & GrCaps::kAsyncRead_MapFlag) {
-            gpu->finishFlush(nullptr, SkSurface::BackendSurfaceAccess::kNoAccess,
-                             kSyncCpu_GrFlushFlag, 0, nullptr, nullptr, nullptr);
+            gpu->finishFlush(nullptr, SkSurface::BackendSurfaceAccess::kNoAccess, flushInfo);
         }
 
         const auto* map = reinterpret_cast<const GrColor*>(buffer->map());
@@ -303,8 +304,7 @@
         ++expectedTransferCnt;
 
         if (context->priv().caps()->mapBufferFlags() & GrCaps::kAsyncRead_MapFlag) {
-            gpu->finishFlush(nullptr, SkSurface::BackendSurfaceAccess::kNoAccess,
-                             kSyncCpu_GrFlushFlag, 0, nullptr, nullptr, nullptr);
+            gpu->finishFlush(nullptr, SkSurface::BackendSurfaceAccess::kNoAccess, flushInfo);
         }
 
         map = reinterpret_cast<const GrColor*>(buffer->map());
diff --git a/tests/VkHardwareBufferTest.cpp b/tests/VkHardwareBufferTest.cpp
index 9209401..a8279cc 100644
--- a/tests/VkHardwareBufferTest.cpp
+++ b/tests/VkHardwareBufferTest.cpp
@@ -821,7 +821,10 @@
     if (!this->setupSemaphoreForSignaling(reporter, &semaphore)) {
         return false;
     }
-    GrSemaphoresSubmitted submitted = fGrContext->flush(kNone_GrFlushFlags, 1, &semaphore);
+    GrFlushInfo info;
+    info.fNumSemaphores = 1;
+    info.fSignalSemaphores = &semaphore;
+    GrSemaphoresSubmitted submitted = fGrContext->flush(info);
     if (GrSemaphoresSubmitted::kNo == submitted) {
         ERRORF(reporter, "Failing call to flush on GrContext");
         return false;
diff --git a/tools/sk_app/VulkanWindowContext.cpp b/tools/sk_app/VulkanWindowContext.cpp
index 564f115..20e5752 100644
--- a/tools/sk_app/VulkanWindowContext.cpp
+++ b/tools/sk_app/VulkanWindowContext.cpp
@@ -514,8 +514,10 @@
     GrBackendSemaphore beSemaphore;
     beSemaphore.initVulkan(backbuffer->fRenderSemaphore);
 
-    surface->flush(SkSurface::BackendSurfaceAccess::kPresent, kNone_GrFlushFlags,
-                   1, &beSemaphore);
+    GrFlushInfo info;
+    info.fNumSemaphores = 1;
+    info.fSignalSemaphores = &beSemaphore;
+    surface->flush(SkSurface::BackendSurfaceAccess::kPresent, info);
 
     // Submit present operation to present queue
     const VkPresentInfoKHR presentInfo =