Add more general flush call to GrContext.

This is to match the current features of SkSurface::flush and to prepare
for adding additional features to flush.

Bug: skia:8802
Change-Id: I5d68272e1277b416af357e6ffaf426841ceda943
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/207301
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
diff --git a/include/core/SkSurface.h b/include/core/SkSurface.h
index 6f4d885..48ec1f6 100644
--- a/include/core/SkSurface.h
+++ b/include/core/SkSurface.h
@@ -713,12 +713,6 @@
         kPresent,   //!< back-end surface will be used for presenting to screen
     };
 
-    enum FlushFlags {
-        kNone_FlushFlags = 0,
-        // flush will wait till all submitted GPU work is finished before returning.
-        kSyncCpu_FlushFlag = 0x1,
-    };
-
     /** 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
@@ -758,35 +752,21 @@
         @param signalSemaphores  array of semaphore containers
         @return                  one of: GrSemaphoresSubmitted::kYes, GrSemaphoresSubmitted::kNo
     */
+    GrSemaphoresSubmitted flush(BackendSurfaceAccess access, GrFlushFlags flags,
+                                int numSemaphores, GrBackendSemaphore signalSemaphores[]);
+
+    /** The below enum and flush call are deprected
+     */
+
+    enum FlushFlags {
+        kNone_FlushFlags = 0,
+        // flush will wait till all submitted GPU work is finished before returning.
+        kSyncCpu_FlushFlag = 0x1,
+    };
     GrSemaphoresSubmitted flush(BackendSurfaceAccess access, FlushFlags flags,
                                 int numSemaphores, GrBackendSemaphore signalSemaphores[]);
 
-    /** Issues pending SkSurface commands to the GPU-backed API and resolves any SkSurface MSAA.
-        After issuing all commands, signalSemaphores of count numSemaphores semaphores
-        are signaled by the GPU.
-
-        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.
-
-        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.
-
-        Pending surface commands are flushed regardless of the return result.
-
-        @param numSemaphores     size of signalSemaphores array
-        @param signalSemaphores  array of semaphore containers
-        @return                  one of: GrSemaphoresSubmitted::kYes, GrSemaphoresSubmitted::kNo
+    /** Deprecated.
     */
     GrSemaphoresSubmitted flushAndSignalSemaphores(int numSemaphores,
                                                    GrBackendSemaphore signalSemaphores[]);
diff --git a/include/gpu/GrContext.h b/include/gpu/GrContext.h
index 72aa9c8..4869746 100644
--- a/include/gpu/GrContext.h
+++ b/include/gpu/GrContext.h
@@ -268,8 +268,16 @@
      * 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.
      */
+    GrSemaphoresSubmitted flush(GrFlushFlags flags, int numSemaphores,
+                                GrBackendSemaphore signalSemaphores[]);
+
+    /**
+     * Deprecated.
+     */
     GrSemaphoresSubmitted flushAndSignalSemaphores(int numSemaphores,
-                                                   GrBackendSemaphore signalSemaphores[]);
+                                                   GrBackendSemaphore signalSemaphores[]) {
+        return this->flush(kNone_GrFlushFlags, numSemaphores, signalSemaphores);
+    }
 
     // Provides access to functions that aren't part of the public API.
     GrContextPriv priv();
diff --git a/include/gpu/GrTypes.h b/include/gpu/GrTypes.h
index 5005d57..1d9ae7c 100644
--- a/include/gpu/GrTypes.h
+++ b/include/gpu/GrTypes.h
@@ -259,6 +259,12 @@
  */
 static const uint32_t kAll_GrBackendState = 0xffffffff;
 
+enum GrFlushFlags {
+    kNone_GrFlushFlags = 0,
+    // flush will wait till all submitted GPU work is finished before returning.
+    kSyncCpu_GrFlushFlag = 0x1,
+};
+
 /**
  * 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 c73f9ca..075ac00 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -244,19 +244,18 @@
     RETURN_IF_ABANDONED
 
     this->drawingManager()->flush(nullptr, SkSurface::BackendSurfaceAccess::kNoAccess,
-                                  SkSurface::kNone_FlushFlags, 0, nullptr);
+                                  kNone_GrFlushFlags, 0, nullptr);
 }
 
-GrSemaphoresSubmitted GrContext::flushAndSignalSemaphores(int numSemaphores,
-                                                          GrBackendSemaphore signalSemaphores[]) {
+GrSemaphoresSubmitted GrContext::flush(GrFlushFlags flags, int numSemaphores,
+                                       GrBackendSemaphore signalSemaphores[]) {
     ASSERT_SINGLE_OWNER
     if (this->abandoned()) {
         return GrSemaphoresSubmitted::kNo;
     }
 
     return this->drawingManager()->flush(nullptr, SkSurface::BackendSurfaceAccess::kNoAccess,
-                                         SkSurface::kNone_FlushFlags, numSemaphores,
-                                         signalSemaphores);
+                                         flags, numSemaphores, signalSemaphores);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
diff --git a/src/gpu/GrContextPriv.cpp b/src/gpu/GrContextPriv.cpp
index c8aa4d3..f545e90 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,
-                                      SkSurface::kNone_FlushFlags, 0, nullptr);
+                                      kNone_GrFlushFlags, 0, nullptr);
 }
 
 void GrContextPriv::prepareSurfaceForExternalIO(GrSurfaceProxy* proxy) {
@@ -204,7 +204,7 @@
     SkASSERT(proxy);
     ASSERT_OWNED_PROXY_PRIV(proxy);
     fContext->drawingManager()->prepareSurfaceForExternalIO(proxy,
-            SkSurface::BackendSurfaceAccess::kNoAccess, SkSurface::kNone_FlushFlags, 0, nullptr);
+            SkSurface::BackendSurfaceAccess::kNoAccess, kNone_GrFlushFlags, 0, nullptr);
 }
 
 static bool valid_premul_color_type(GrColorType ct) {
diff --git a/src/gpu/GrDrawingManager.cpp b/src/gpu/GrDrawingManager.cpp
index 897c473..7904d75 100644
--- a/src/gpu/GrDrawingManager.cpp
+++ b/src/gpu/GrDrawingManager.cpp
@@ -208,7 +208,7 @@
 // MDB TODO: make use of the 'proxy' parameter.
 GrSemaphoresSubmitted GrDrawingManager::flush(GrSurfaceProxy* proxy,
                                               SkSurface::BackendSurfaceAccess access,
-                                              SkSurface::FlushFlags flags,
+                                              GrFlushFlags flags,
                                               int numSemaphores,
                                               GrBackendSemaphore backendSemaphores[]) {
     GR_CREATE_TRACE_MARKER_CONTEXT("GrDrawingManager", "flush", fContext);
@@ -219,7 +219,7 @@
 
     SkDEBUGCODE(this->validate());
 
-    if (SkSurface::kNone_FlushFlags == flags && !numSemaphores && proxy && !fDAG.isUsed(proxy)) {
+    if (kNone_GrFlushFlags == flags && !numSemaphores && proxy && !fDAG.isUsed(proxy)) {
         return GrSemaphoresSubmitted::kNo;
     }
 
@@ -442,7 +442,7 @@
         (*numOpListsExecuted)++;
         if (*numOpListsExecuted >= kMaxOpListsBeforeFlush) {
             flushState->gpu()->finishFlush(nullptr, SkSurface::BackendSurfaceAccess::kNoAccess,
-                                           SkSurface::kNone_FlushFlags, 0, nullptr);
+                                           kNone_GrFlushFlags, 0, nullptr);
             *numOpListsExecuted = 0;
         }
     }
@@ -460,7 +460,7 @@
         (*numOpListsExecuted)++;
         if (*numOpListsExecuted >= kMaxOpListsBeforeFlush) {
             flushState->gpu()->finishFlush(nullptr, SkSurface::BackendSurfaceAccess::kNoAccess,
-                                           SkSurface::kNone_FlushFlags, 0, nullptr);
+                                           kNone_GrFlushFlags, 0, nullptr);
             *numOpListsExecuted = 0;
         }
     }
@@ -479,7 +479,7 @@
 }
 
 GrSemaphoresSubmitted GrDrawingManager::prepareSurfaceForExternalIO(
-        GrSurfaceProxy* proxy, SkSurface::BackendSurfaceAccess access, SkSurface::FlushFlags flags,
+        GrSurfaceProxy* proxy, SkSurface::BackendSurfaceAccess access, GrFlushFlags flags,
         int numSemaphores, GrBackendSemaphore backendSemaphores[]) {
     if (this->wasAbandoned()) {
         return GrSemaphoresSubmitted::kNo;
@@ -759,7 +759,7 @@
     auto resourceCache = direct->priv().getResourceCache();
     if (resourceCache && resourceCache->requestsFlush()) {
         this->flush(nullptr, SkSurface::BackendSurfaceAccess::kNoAccess,
-                    SkSurface::kNone_FlushFlags, 0, nullptr);
+                    kNone_GrFlushFlags, 0, nullptr);
         resourceCache->purgeAsNeeded();
     }
 }
diff --git a/src/gpu/GrDrawingManager.h b/src/gpu/GrDrawingManager.h
index 157a6c6..d3b8ac1 100644
--- a/src/gpu/GrDrawingManager.h
+++ b/src/gpu/GrDrawingManager.h
@@ -74,7 +74,7 @@
 
     GrSemaphoresSubmitted prepareSurfaceForExternalIO(GrSurfaceProxy*,
                                                       SkSurface::BackendSurfaceAccess access,
-                                                      SkSurface::FlushFlags flags,
+                                                      GrFlushFlags flags,
                                                       int numSemaphores,
                                                       GrBackendSemaphore backendSemaphores[]);
 
@@ -153,7 +153,7 @@
 
     GrSemaphoresSubmitted flush(GrSurfaceProxy* proxy,
                                 SkSurface::BackendSurfaceAccess access,
-                                SkSurface::FlushFlags flags,
+                                GrFlushFlags flags,
                                 int numSemaphores,
                                 GrBackendSemaphore backendSemaphores[]);
 
diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp
index 7145f74..c20b255 100644
--- a/src/gpu/GrGpu.cpp
+++ b/src/gpu/GrGpu.cpp
@@ -420,7 +420,7 @@
 
 GrSemaphoresSubmitted GrGpu::finishFlush(GrSurfaceProxy* proxy,
                                          SkSurface::BackendSurfaceAccess access,
-                                         SkSurface::FlushFlags flags, int numSemaphores,
+                                         GrFlushFlags flags, int numSemaphores,
                                          GrBackendSemaphore backendSemaphores[]) {
     this->stats()->incNumFinishFlushes();
     GrResourceProvider* resourceProvider = fContext->priv().resourceProvider();
diff --git a/src/gpu/GrGpu.h b/src/gpu/GrGpu.h
index 5ffcf38..e44e74c 100644
--- a/src/gpu/GrGpu.h
+++ b/src/gpu/GrGpu.h
@@ -303,7 +303,7 @@
     // insert any numSemaphore semaphores on the gpu and set the backendSemaphores to match the
     // inserted semaphores.
     GrSemaphoresSubmitted finishFlush(GrSurfaceProxy*, SkSurface::BackendSurfaceAccess access,
-                                      SkSurface::FlushFlags flags, int numSemaphores,
+                                      GrFlushFlags flags, int numSemaphores,
                                       GrBackendSemaphore backendSemaphores[]);
 
     virtual void submit(GrGpuCommandBuffer*) = 0;
@@ -547,7 +547,7 @@
                                bool canDiscardOutsideDstRect) = 0;
 
     virtual void onFinishFlush(GrSurfaceProxy*, SkSurface::BackendSurfaceAccess access,
-                               SkSurface::FlushFlags flags, bool insertedSemaphores) = 0;
+                               GrFlushFlags flags, bool insertedSemaphores) = 0;
 
 #ifdef SK_ENABLE_DUMP_GPU
     virtual void onDumpJSON(SkJSONWriter*) const {}
diff --git a/src/gpu/GrRenderTargetContext.cpp b/src/gpu/GrRenderTargetContext.cpp
index c4db904..05241d6 100644
--- a/src/gpu/GrRenderTargetContext.cpp
+++ b/src/gpu/GrRenderTargetContext.cpp
@@ -1735,7 +1735,7 @@
 }
 
 GrSemaphoresSubmitted GrRenderTargetContext::prepareForExternalIO(
-        SkSurface::BackendSurfaceAccess access, SkSurface::FlushFlags flags, int numSemaphores,
+        SkSurface::BackendSurfaceAccess access, GrFlushFlags flags, int numSemaphores,
         GrBackendSemaphore backendSemaphores[]) {
     ASSERT_SINGLE_OWNER
     if (fContext->priv().abandoned()) {
diff --git a/src/gpu/GrRenderTargetContext.h b/src/gpu/GrRenderTargetContext.h
index 6d649f7..c4ef529 100644
--- a/src/gpu/GrRenderTargetContext.h
+++ b/src/gpu/GrRenderTargetContext.h
@@ -407,7 +407,7 @@
      * if the surface has MSAA it will be resolved.
      */
     GrSemaphoresSubmitted prepareForExternalIO(SkSurface::BackendSurfaceAccess access,
-                                               SkSurface::FlushFlags flags, int numSemaphores,
+                                               GrFlushFlags flags, int numSemaphores,
                                                GrBackendSemaphore backendSemaphores[]);
 
     /**
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 12af310..9f05af7 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -1628,11 +1628,11 @@
 
 void SkGpuDevice::flush() {
     this->flushAndSignalSemaphores(SkSurface::BackendSurfaceAccess::kNoAccess,
-                                   SkSurface::kNone_FlushFlags, 0, nullptr);
+                                   kNone_GrFlushFlags, 0, nullptr);
 }
 
 GrSemaphoresSubmitted SkGpuDevice::flushAndSignalSemaphores(SkSurface::BackendSurfaceAccess access,
-                                                            SkSurface::FlushFlags flags,
+                                                            GrFlushFlags flags,
                                                             int numSemaphores,
                                                             GrBackendSemaphore signalSemaphores[]) {
     ASSERT_SINGLE_OWNER
diff --git a/src/gpu/SkGpuDevice.h b/src/gpu/SkGpuDevice.h
index 21072a6..e36286b 100644
--- a/src/gpu/SkGpuDevice.h
+++ b/src/gpu/SkGpuDevice.h
@@ -121,7 +121,7 @@
 
     void flush() override;
     GrSemaphoresSubmitted flushAndSignalSemaphores(SkSurface::BackendSurfaceAccess access,
-                                                   SkSurface::FlushFlags flags,
+                                                   GrFlushFlags flags,
                                                    int numSemaphores,
                                                    GrBackendSemaphore signalSemaphores[]);
     bool wait(int numSemaphores, const GrBackendSemaphore* waitSemaphores);
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index 1d2d7c9..506d06a 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -4307,12 +4307,12 @@
 }
 
 void GrGLGpu::onFinishFlush(GrSurfaceProxy*, SkSurface::BackendSurfaceAccess access,
-                            SkSurface::FlushFlags flags, bool insertedSemaphore) {
+                            GrFlushFlags flags, bool insertedSemaphore) {
     // If we inserted semaphores during the flush, we need to call GLFlush.
     if (insertedSemaphore) {
         GL_CALL(Flush());
     }
-    if (flags & SkSurface::kSyncCpu_FlushFlag) {
+    if (flags & kSyncCpu_GrFlushFlag) {
         GL_CALL(Finish());
     }
 }
diff --git a/src/gpu/gl/GrGLGpu.h b/src/gpu/gl/GrGLGpu.h
index 8d4da15..b6d6609 100644
--- a/src/gpu/gl/GrGLGpu.h
+++ b/src/gpu/gl/GrGLGpu.h
@@ -294,7 +294,7 @@
     void flushBlend(const GrXferProcessor::BlendInfo& blendInfo, const GrSwizzle&);
 
     void onFinishFlush(GrSurfaceProxy*, SkSurface::BackendSurfaceAccess access,
-                       SkSurface::FlushFlags flags, bool insertedSemaphores) override;
+                       GrFlushFlags flags, bool insertedSemaphores) 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 317ac6e..56c40ae 100644
--- a/src/gpu/mock/GrMockGpu.h
+++ b/src/gpu/mock/GrMockGpu.h
@@ -111,7 +111,7 @@
     void onResolveRenderTarget(GrRenderTarget* target) override { return; }
 
     void onFinishFlush(GrSurfaceProxy*, SkSurface::BackendSurfaceAccess access,
-                       SkSurface::FlushFlags flags, bool insertedSemaphores) override {}
+                       GrFlushFlags flags, bool insertedSemaphores) override {}
 
     GrStencilAttachment* createStencilAttachmentForRenderTarget(const GrRenderTarget*,
                                                                 int width,
diff --git a/src/gpu/mtl/GrMtlGpu.h b/src/gpu/mtl/GrMtlGpu.h
index ddf9364..18736eb 100644
--- a/src/gpu/mtl/GrMtlGpu.h
+++ b/src/gpu/mtl/GrMtlGpu.h
@@ -182,8 +182,8 @@
     void onResolveRenderTarget(GrRenderTarget* target) override { return; }
 
     void onFinishFlush(GrSurfaceProxy*, SkSurface::BackendSurfaceAccess access,
-                       SkSurface::FlushFlags flags, bool insertedSemaphores) override {
-        if (flags & SkSurface::kSyncCpu_FlushFlag) {
+                       GrFlushFlags flags, bool insertedSemaphores) override {
+        if (flags & kSyncCpu_GrFlushFlag) {
             this->submitCommandBuffer(kForce_SyncQueue);
         } else {
             this->submitCommandBuffer(kSkip_SyncQueue);
diff --git a/src/gpu/vk/GrVkGpu.cpp b/src/gpu/vk/GrVkGpu.cpp
index f12a1a8..e1032b5 100644
--- a/src/gpu/vk/GrVkGpu.cpp
+++ b/src/gpu/vk/GrVkGpu.cpp
@@ -1883,7 +1883,7 @@
 }
 
 void GrVkGpu::onFinishFlush(GrSurfaceProxy* proxy, SkSurface::BackendSurfaceAccess access,
-                            SkSurface::FlushFlags flags, bool insertedSemaphore) {
+                            GrFlushFlags flags, bool insertedSemaphore) {
     // 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) {
@@ -1898,7 +1898,7 @@
         }
         image->prepareForPresent(this);
     }
-    if (flags & SkSurface::kSyncCpu_FlushFlag) {
+    if (flags & kSyncCpu_GrFlushFlag) {
         this->submitCommandBuffer(kForce_SyncQueue);
     } else {
         this->submitCommandBuffer(kSkip_SyncQueue);
diff --git a/src/gpu/vk/GrVkGpu.h b/src/gpu/vk/GrVkGpu.h
index 007ac17..963016f 100644
--- a/src/gpu/vk/GrVkGpu.h
+++ b/src/gpu/vk/GrVkGpu.h
@@ -220,8 +220,8 @@
                        GrSurfaceOrigin srcOrigin, const SkIRect& srcRect,
                        const SkIPoint& dstPoint, bool canDiscardOutsideDstRect) override;
 
-    void onFinishFlush(GrSurfaceProxy*, SkSurface::BackendSurfaceAccess access,
-                       SkSurface::FlushFlags flags, bool insertedSemaphores) override;
+    void onFinishFlush(GrSurfaceProxy*, SkSurface::BackendSurfaceAccess access, GrFlushFlags flags,
+                       bool insertedSemaphores) 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 1e8d2c0..1c67013 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -655,7 +655,7 @@
     texContext->writePixels(srcInfo, pixmap.addr(0, 0), pixmap.rowBytes(), 0, 0);
 
     drawingManager->flush(proxy.get(), SkSurface::BackendSurfaceAccess::kNoAccess,
-                          SkSurface::kSyncCpu_FlushFlag, 0, nullptr);
+                          kSyncCpu_GrFlushFlag, 0, nullptr);
 
     return image;
 }
diff --git a/src/image/SkSurface.cpp b/src/image/SkSurface.cpp
index df694a4..d7a05ee 100644
--- a/src/image/SkSurface.cpp
+++ b/src/image/SkSurface.cpp
@@ -244,17 +244,23 @@
 }
 
 void SkSurface::flush() {
-    asSB(this)->onFlush(BackendSurfaceAccess::kNoAccess, kNone_FlushFlags, 0, nullptr);
+    asSB(this)->onFlush(BackendSurfaceAccess::kNoAccess, kNone_GrFlushFlags, 0, nullptr);
 }
 
-GrSemaphoresSubmitted SkSurface::flush(BackendSurfaceAccess access, FlushFlags flags,
+GrSemaphoresSubmitted SkSurface::flush(BackendSurfaceAccess access, GrFlushFlags flags,
                                        int numSemaphores, GrBackendSemaphore signalSemaphores[]) {
     return asSB(this)->onFlush(access, flags, numSemaphores, signalSemaphores);
 }
 
+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);
+}
+
 GrSemaphoresSubmitted SkSurface::flushAndSignalSemaphores(int numSemaphores,
                                                           GrBackendSemaphore signalSemaphores[]) {
-    return asSB(this)->onFlush(BackendSurfaceAccess::kNoAccess, kNone_FlushFlags,
+    return asSB(this)->onFlush(BackendSurfaceAccess::kNoAccess, kNone_GrFlushFlags,
                                numSemaphores, signalSemaphores);
 }
 
diff --git a/src/image/SkSurface_Base.h b/src/image/SkSurface_Base.h
index f1096df..0e3cd95 100644
--- a/src/image/SkSurface_Base.h
+++ b/src/image/SkSurface_Base.h
@@ -80,7 +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, FlushFlags flags,
+    virtual GrSemaphoresSubmitted onFlush(BackendSurfaceAccess access, GrFlushFlags flags,
                                           int numSemaphores,
                                           GrBackendSemaphore signalSemaphores[]) {
         return GrSemaphoresSubmitted::kNo;
diff --git a/src/image/SkSurface_Gpu.cpp b/src/image/SkSurface_Gpu.cpp
index 3c72f41..c0c4042 100644
--- a/src/image/SkSurface_Gpu.cpp
+++ b/src/image/SkSurface_Gpu.cpp
@@ -51,7 +51,7 @@
 
     // Grab the render target *after* firing notifications, as it may get switched if CoW kicks in.
     surface->getDevice()->flushAndSignalSemaphores(SkSurface::BackendSurfaceAccess::kNoAccess,
-                                                   SkSurface::kNone_FlushFlags, 0, nullptr);
+                                                   kNone_GrFlushFlags, 0, nullptr);
     GrRenderTargetContext* rtc = surface->getDevice()->accessRenderTargetContext();
     return rtc->accessRenderTarget();
 }
@@ -158,7 +158,7 @@
     fDevice->accessRenderTargetContext()->discard();
 }
 
-GrSemaphoresSubmitted SkSurface_Gpu::onFlush(BackendSurfaceAccess access, FlushFlags flags,
+GrSemaphoresSubmitted SkSurface_Gpu::onFlush(BackendSurfaceAccess access, GrFlushFlags flags,
                                              int numSemaphores,
                                              GrBackendSemaphore signalSemaphores[]) {
     return fDevice->flushAndSignalSemaphores(access, flags, numSemaphores, signalSemaphores);
diff --git a/src/image/SkSurface_Gpu.h b/src/image/SkSurface_Gpu.h
index 4c2b5f3..13b79c6 100644
--- a/src/image/SkSurface_Gpu.h
+++ b/src/image/SkSurface_Gpu.h
@@ -32,7 +32,8 @@
     void onWritePixels(const SkPixmap&, int x, int y) override;
     void onCopyOnWrite(ContentChangeMode) override;
     void onDiscard() override;
-    GrSemaphoresSubmitted onFlush(BackendSurfaceAccess access, FlushFlags flags, int numSemaphores,
+    GrSemaphoresSubmitted onFlush(BackendSurfaceAccess access, GrFlushFlags flags,
+                                  int numSemaphores,
                                   GrBackendSemaphore signalSemaphores[]) override;
     bool onWait(int numSemaphores, const GrBackendSemaphore* waitSemaphores) override;
     bool onCharacterize(SkSurfaceCharacterization*) const override;
diff --git a/tests/DefaultPathRendererTest.cpp b/tests/DefaultPathRendererTest.cpp
index b365dba..7475729 100644
--- a/tests/DefaultPathRendererTest.cpp
+++ b/tests/DefaultPathRendererTest.cpp
@@ -100,7 +100,7 @@
                       SkMatrix::I(), invPath, style);
 
         rtc->prepareForExternalIO(SkSurface::BackendSurfaceAccess::kNoAccess,
-                                  SkSurface::kNone_FlushFlags, 0, nullptr);
+                                  kNone_GrFlushFlags, 0, nullptr);
     }
 
     {
diff --git a/tests/GLProgramsTest.cpp b/tests/GLProgramsTest.cpp
index 7eb580c..78d3749 100644
--- a/tests/GLProgramsTest.cpp
+++ b/tests/GLProgramsTest.cpp
@@ -314,7 +314,7 @@
     }
     // Flush everything, test passes if flush is successful(ie, no asserts are hit, no crashes)
     drawingManager->flush(nullptr, SkSurface::BackendSurfaceAccess::kNoAccess,
-                          SkSurface::kNone_FlushFlags, 0, nullptr);
+                          kNone_GrFlushFlags, 0, nullptr);
 
     const GrBackendFormat format =
             context->priv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
@@ -344,7 +344,7 @@
             paint.addColorFragmentProcessor(std::move(blockFP));
             GrDrawRandomOp(&random, renderTargetContext.get(), std::move(paint));
             drawingManager->flush(nullptr, SkSurface::BackendSurfaceAccess::kNoAccess,
-                                  SkSurface::kNone_FlushFlags, 0, nullptr);
+                                  kNone_GrFlushFlags, 0, nullptr);
         }
     }
 
diff --git a/tests/OnFlushCallbackTest.cpp b/tests/OnFlushCallbackTest.cpp
index d1d912d..3c97842 100644
--- a/tests/OnFlushCallbackTest.cpp
+++ b/tests/OnFlushCallbackTest.cpp
@@ -581,7 +581,7 @@
     }
 
     rtc->prepareForExternalIO(SkSurface::BackendSurfaceAccess::kNoAccess,
-                              SkSurface::kNone_FlushFlags, 0, nullptr);
+                              kNone_GrFlushFlags, 0, nullptr);
 
     SkBitmap readBack;
     readBack.allocN32Pixels(kFinalWidth, kFinalHeight);
diff --git a/tests/SurfaceSemaphoreTest.cpp b/tests/SurfaceSemaphoreTest.cpp
index ccb05ff..fd3b449 100644
--- a/tests/SurfaceSemaphoreTest.cpp
+++ b/tests/SurfaceSemaphoreTest.cpp
@@ -144,7 +144,7 @@
 #endif
 
     if (flushContext) {
-        mainCtx->flushAndSignalSemaphores(2, semaphores.get());
+        mainCtx->flush(kNone_GrFlushFlags, 2, semaphores.get());
     } else {
         mainSurface->flushAndSignalSemaphores(2, semaphores.get());
     }
diff --git a/tests/TransferPixelsTest.cpp b/tests/TransferPixelsTest.cpp
index e43af8f..bb0a936 100644
--- a/tests/TransferPixelsTest.cpp
+++ b/tests/TransferPixelsTest.cpp
@@ -279,7 +279,7 @@
 
         // TODO(bsalomon): caps to know if the map() is synchronous and skip the flush if so.
         gpu->finishFlush(nullptr, SkSurface::BackendSurfaceAccess::kNoAccess,
-                         SkSurface::kSyncCpu_FlushFlag, 0, nullptr);
+                         kSyncCpu_GrFlushFlag, 0, nullptr);
 
         const auto* map = reinterpret_cast<const GrColor*>(buffer->map());
         REPORTER_ASSERT(reporter, map);
@@ -308,7 +308,7 @@
 
         // TODO(bsalomon): caps to know if the map() is synchronous and skip the flush if so.
         gpu->finishFlush(nullptr, SkSurface::BackendSurfaceAccess::kNoAccess,
-                         SkSurface::kSyncCpu_FlushFlag, 0, nullptr);
+                         kSyncCpu_GrFlushFlag, 0, nullptr);
 
         map = reinterpret_cast<const GrColor*>(buffer->map());
         REPORTER_ASSERT(reporter, map);
diff --git a/tests/VkHardwareBufferTest.cpp b/tests/VkHardwareBufferTest.cpp
index 4fa4b88..9209401 100644
--- a/tests/VkHardwareBufferTest.cpp
+++ b/tests/VkHardwareBufferTest.cpp
@@ -821,9 +821,9 @@
     if (!this->setupSemaphoreForSignaling(reporter, &semaphore)) {
         return false;
     }
-    GrSemaphoresSubmitted submitted = fGrContext->flushAndSignalSemaphores(1, &semaphore);
+    GrSemaphoresSubmitted submitted = fGrContext->flush(kNone_GrFlushFlags, 1, &semaphore);
     if (GrSemaphoresSubmitted::kNo == submitted) {
-        ERRORF(reporter, "Failing call to flushAndSignalSemaphores on SkSurface");
+        ERRORF(reporter, "Failing call to flush on GrContext");
         return false;
     }
     SkASSERT(semaphore.isInitialized());
diff --git a/tools/sk_app/VulkanWindowContext.cpp b/tools/sk_app/VulkanWindowContext.cpp
index 7d2b811..564f115 100644
--- a/tools/sk_app/VulkanWindowContext.cpp
+++ b/tools/sk_app/VulkanWindowContext.cpp
@@ -514,7 +514,7 @@
     GrBackendSemaphore beSemaphore;
     beSemaphore.initVulkan(backbuffer->fRenderSemaphore);
 
-    surface->flush(SkSurface::BackendSurfaceAccess::kPresent, SkSurface::kNone_FlushFlags,
+    surface->flush(SkSurface::BackendSurfaceAccess::kPresent, kNone_GrFlushFlags,
                    1, &beSemaphore);
 
     // Submit present operation to present queue