Migrate more Android & SkSurface API off GrContext

Migration should be free because (1) the non-Android API is
only loosening up to GrRecordingContext and (2) the Android API
can only see GrContext through including GrDirectContext.h

Change-Id: I97aa75baba0b0969361db6eaef9f83ea94183700
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/323557
Commit-Queue: Adlai Holler <adlai@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
diff --git a/src/gpu/GrAHardwareBufferUtils.cpp b/src/gpu/GrAHardwareBufferUtils.cpp
index 0a5d24c..e086377 100644
--- a/src/gpu/GrAHardwareBufferUtils.cpp
+++ b/src/gpu/GrAHardwareBufferUtils.cpp
@@ -60,14 +60,8 @@
     }
 }
 
-GrBackendFormat GetBackendFormat(GrContext* context, AHardwareBuffer* hardwareBuffer,
+GrBackendFormat GetBackendFormat(GrDirectContext* dContext, AHardwareBuffer* hardwareBuffer,
                                  uint32_t bufferFormat, bool requireKnownFormat) {
-    // CONTEXT TODO: Elevate direct context requirement to Android API.
-    auto dContext = GrAsDirectContext(context);
-    if (!dContext) {
-        SkDEBUGFAIL("Requires direct context.");
-        return GrBackendFormat();
-    }
     GrBackendApi backend = dContext->backend();
 
     if (backend == GrBackendApi::kOpenGL) {
@@ -205,13 +199,7 @@
     delete cleanupHelper;
 }
 
-void update_gl_texture(void* context, GrContext* grContext) {
-    // CONTEXT TODO: Elevate direct context requirement to Android API.
-    auto dContext = GrAsDirectContext(grContext);
-    if (!dContext) {
-        SkDEBUGFAIL("Direct context required.");
-        return;
-    }
+void update_gl_texture(void* context, GrDirectContext* dContext) {
     GLTextureHelper* cleanupHelper = static_cast<GLTextureHelper*>(context);
     cleanupHelper->rebind(dContext);
 }
@@ -306,9 +294,7 @@
     delete cleanupHelper;
 }
 
-void update_vk_image(void* context, GrContext* grContext) {
-    // CONTEXT TODO: Elevate direct context requirement to Android API.
-    SkASSERT(GrAsDirectContext(grContext));
+void update_vk_image(void* context, GrDirectContext* dContext) {
     // no op
 }
 
@@ -539,7 +525,7 @@
     return false;
 }
 
-GrBackendTexture MakeBackendTexture(GrContext* context, AHardwareBuffer* hardwareBuffer,
+GrBackendTexture MakeBackendTexture(GrDirectContext* dContext, AHardwareBuffer* hardwareBuffer,
                                     int width, int height,
                                     DeleteImageProc* deleteProc,
                                     UpdateImageProc* updateProc,
@@ -547,8 +533,6 @@
                                     bool isProtectedContent,
                                     const GrBackendFormat& backendFormat,
                                     bool isRenderable) {
-    // CONTEXT TODO: Elevate direct context requirement to Android API.
-    auto dContext = GrAsDirectContext(context);
     SkASSERT(dContext);
     if (!dContext || dContext->abandoned()) {
         return GrBackendTexture();