Reland "Implement submit API to GrContext."

This reverts commit 9ee15d7b57075e2f8a533cfc9516aff0611a0ef3.

Reason for revert: relanding with fixes

Original change's description:
> Revert "Implement submit API to GrContext."
> 
> This reverts commit 40f288c72e4e836a2316cc058b5bb3aea92bde3f.
> 
> Reason for revert: canvaskit breaking for some reason???
> 
> Original change's description:
> > Implement submit API to GrContext.
> > 
> > Change-Id: Ib813d42abb5f63e2ecdbf245d416658143853288
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/289033
> > Commit-Queue: Greg Daniel <egdaniel@google.com>
> > Reviewed-by: Brian Salomon <bsalomon@google.com>
> 
> TBR=egdaniel@google.com,bsalomon@google.com,penghuang@chromium.org,vasilyt@chromium.org
> 
> Change-Id: Iee6c8342cccc601edf64ea011f1303e5d72559a9
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/290917
> Reviewed-by: Greg Daniel <egdaniel@google.com>
> Commit-Queue: Greg Daniel <egdaniel@google.com>

TBR=egdaniel@google.com,bsalomon@google.com,penghuang@chromium.org,vasilyt@chromium.org

# Not skipping CQ checks because this is a reland.

Change-Id: I5203676f88893cbbaba685301b8a713b40396b48
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/290960
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index 291c434..88307ba 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -319,21 +319,26 @@
         return GrSemaphoresSubmitted::kNo;
     }
 
-    bool submitted = false;
-    if (this->drawingManager()->flush(nullptr, 0, SkSurface::BackendSurfaceAccess::kNoAccess,
-                                      info, externalRequests)) {
-        bool forceSync = SkToBool(info.fFlags & kSyncCpu_GrFlushFlag);
-        submitted = this->drawingManager()->submitToGpu(forceSync);
-    }
+    bool flushed = this->drawingManager()->flush(
+            nullptr, 0, SkSurface::BackendSurfaceAccess::kNoAccess, info, externalRequests);
 
-    if (!submitted || (!this->priv().caps()->semaphoreSupport() && info.fNumSemaphores)) {
+    if (!flushed || (!this->priv().caps()->semaphoreSupport() && info.fNumSemaphores)) {
         return GrSemaphoresSubmitted::kNo;
     }
     return GrSemaphoresSubmitted::kYes;
 }
 
-bool GrContext::submit(bool syncToCpu) {
-    return true;
+bool GrContext::submit(bool syncCpu) {
+    ASSERT_SINGLE_OWNER
+    if (this->abandoned()) {
+        return false;
+    }
+
+    if (!fGpu) {
+        return false;
+    }
+
+    return fGpu->submitToGpu(syncCpu);
 }
 
 ////////////////////////////////////////////////////////////////////////////////