Revert "Remove more GrContext imports & usage"

This reverts commit dd1395526df7fa346fe9d21ef8c9b41b2c0ef748.

Reason for revert: Broke chrome roll

Original change's description:
> Remove more GrContext imports & usage
> 
> Sanity is coming soon!
> 
> Change-Id: I109ebeef9efd7dbf4d76a13e1c05df36d59affbc
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/303661
> Commit-Queue: Adlai Holler <adlai@google.com>
> Reviewed-by: Robert Phillips <robertphillips@google.com>

TBR=robertphillips@google.com,adlai@google.com

Change-Id: I20d770058d4b54193b6cd2fdc9ca5a1e09f84309
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/304056
Reviewed-by: Adlai Holler <adlai@google.com>
Commit-Queue: Adlai Holler <adlai@google.com>
diff --git a/src/gpu/GrAHardwareBufferUtils.cpp b/src/gpu/GrAHardwareBufferUtils.cpp
index f2137f3..badb8ee 100644
--- a/src/gpu/GrAHardwareBufferUtils.cpp
+++ b/src/gpu/GrAHardwareBufferUtils.cpp
@@ -19,7 +19,7 @@
 #include <GLES/gl.h>
 #include <GLES/glext.h>
 
-#include "include/gpu/GrDirectContext.h"
+#include "include/gpu/GrContext.h"
 #include "include/gpu/gl/GrGLTypes.h"
 #include "src/gpu/GrContextPriv.h"
 #include "src/gpu/gl/GrGLDefines.h"
@@ -62,13 +62,7 @@
 
 GrBackendFormat GetBackendFormat(GrContext* context, 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();
+    GrBackendApi backend = context->backend();
 
     if (backend == GrBackendApi::kOpenGL) {
         switch (bufferFormat) {
@@ -110,7 +104,7 @@
                 if (requireKnownFormat) {
                     return GrBackendFormat();
                 } else {
-                    GrVkGpu* gpu = static_cast<GrVkGpu*>(dContext->priv().getGpu());
+                    GrVkGpu* gpu = static_cast<GrVkGpu*>(context->priv().getGpu());
                     SkASSERT(gpu);
                     VkDevice device = gpu->device();
 
@@ -175,7 +169,7 @@
         // eglDestroyImageKHR will remove a ref from the AHardwareBuffer
         eglDestroyImageKHR(fDisplay, fImage);
     }
-    void rebind(GrDirectContext*);
+    void rebind(GrContext* grContext);
 
 private:
     GrGLuint    fTexID;
@@ -184,7 +178,7 @@
     GrGLuint    fTexTarget;
 };
 
-void GLTextureHelper::rebind(GrDirectContext* dContext) {
+void GLTextureHelper::rebind(GrContext* grContext) {
     glBindTexture(fTexTarget, fTexID);
     GLenum status = GL_NO_ERROR;
     if ((status = glGetError()) != GL_NO_ERROR) {
@@ -197,7 +191,7 @@
         SkDebugf("glEGLImageTargetTexture2DOES failed (%#x)", (int) status);
         return;
     }
-    dContext->resetContext(kTextureBinding_GrGLBackendState);
+    grContext->resetContext(kTextureBinding_GrGLBackendState);
 }
 
 void delete_gl_texture(void* context) {
@@ -206,18 +200,12 @@
 }
 
 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;
-    }
     GLTextureHelper* cleanupHelper = static_cast<GLTextureHelper*>(context);
-    cleanupHelper->rebind(dContext);
+    cleanupHelper->rebind(grContext);
 }
 
 static GrBackendTexture make_gl_backend_texture(
-        GrDirectContext* dContext, AHardwareBuffer* hardwareBuffer,
+        GrContext* context, AHardwareBuffer* hardwareBuffer,
         int width, int height,
         DeleteImageProc* deleteProc,
         UpdateImageProc* updateProc,
@@ -265,7 +253,7 @@
         eglDestroyImageKHR(display, image);
         return GrBackendTexture();
     }
-    dContext->resetContext(kTextureBinding_GrGLBackendState);
+    context->resetContext(kTextureBinding_GrGLBackendState);
 
     GrGLTextureInfo textureInfo;
     textureInfo.fID = texID;
@@ -307,13 +295,11 @@
 }
 
 void update_vk_image(void* context, GrContext* grContext) {
-    // CONTEXT TODO: Elevate direct context requirement to Android API.
-    SkASSERT(GrAsDirectContext(grContext));
     // no op
 }
 
 static GrBackendTexture make_vk_backend_texture(
-        GrDirectContext* dContext, AHardwareBuffer* hardwareBuffer,
+        GrContext* context, AHardwareBuffer* hardwareBuffer,
         int width, int height,
         DeleteImageProc* deleteProc,
         UpdateImageProc* updateProc,
@@ -321,8 +307,8 @@
         bool isProtectedContent,
         const GrBackendFormat& backendFormat,
         bool isRenderable) {
-    SkASSERT(dContext->backend() == GrBackendApi::kVulkan);
-    GrVkGpu* gpu = static_cast<GrVkGpu*>(dContext->priv().getGpu());
+    SkASSERT(context->backend() == GrBackendApi::kVulkan);
+    GrVkGpu* gpu = static_cast<GrVkGpu*>(context->priv().getGpu());
 
     VkPhysicalDevice physicalDevice = gpu->physicalDevice();
     VkDevice device = gpu->device();
@@ -524,8 +510,8 @@
     return equal || atStart || atEnd || inMiddle;
 }
 
-static bool can_import_protected_content(GrDirectContext* dContext) {
-    if (GrBackendApi::kOpenGL == dContext->backend()) {
+static bool can_import_protected_content(GrContext* context) {
+    if (GrBackendApi::kOpenGL == context->backend()) {
         // Only compute whether the extension is present once the first time this
         // function is called.
         static bool hasIt = can_import_protected_content_eglimpl();
@@ -542,24 +528,21 @@
                                     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()) {
+    if (context->abandoned()) {
         return GrBackendTexture();
     }
-    bool createProtectedImage = isProtectedContent && can_import_protected_content(dContext);
+    bool createProtectedImage = isProtectedContent && can_import_protected_content(context);
 
-    if (GrBackendApi::kOpenGL == dContext->backend()) {
-        return make_gl_backend_texture(dContext, hardwareBuffer, width, height, deleteProc,
+    if (GrBackendApi::kOpenGL == context->backend()) {
+        return make_gl_backend_texture(context, hardwareBuffer, width, height, deleteProc,
                                        updateProc, imageCtx, createProtectedImage, backendFormat,
                                        isRenderable);
     } else {
-        SkASSERT(GrBackendApi::kVulkan == dContext->backend());
+        SkASSERT(GrBackendApi::kVulkan == context->backend());
 #ifdef SK_VULKAN
         // Currently we don't support protected images on vulkan
         SkASSERT(!createProtectedImage);
-        return make_vk_backend_texture(dContext, hardwareBuffer, width, height, deleteProc,
+        return make_vk_backend_texture(context, hardwareBuffer, width, height, deleteProc,
                                        updateProc, imageCtx, createProtectedImage, backendFormat,
                                        isRenderable);
 #else