Remove all internal uses of (and deprecate) SkSurface::getContext

We are replacing GrContext with the GrDirectContext/GrRecordingContext
pair. This starts making that change visible to clients (and weaning
Skia off of GrContext).

Change-Id: I00cc9bf208499984de855a1646229bd7557fc925
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/300706
Reviewed-by: Adlai Holler <adlai@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt
index 0f6433b..4a6b126 100644
--- a/RELEASE_NOTES.txt
+++ b/RELEASE_NOTES.txt
@@ -23,6 +23,14 @@
   * Added SkImage:asyncRescaleAndReadPixels and SkImage::asyncRescaleAndReadPixelsYUV420
     https://review.skia.org/299281
 
+  * Ganesh is moving towards replacing GrContext with the GrDirectContext/GrRecordingContext
+    pair. GrDirectContexts have _direct_ access to the GPU and are very similar to the old
+    GrContext. GrRecordingContexts are less powerful contexts that lack GPU access but provided
+    context-like utilities during DDL recording. SkSurfaces and SkCanvas will now only return
+    GrRecordingContexts. Clients requiring context features that need GPU access can then
+    check (via GrRecordingContext::asDirectContext) if the available recording context is actually
+    a direct context.
+
 * * *
 
 Milestone 85
diff --git a/gm/asyncrescaleandread.cpp b/gm/asyncrescaleandread.cpp
index f61ec15..2e04d27 100644
--- a/gm/asyncrescaleandread.cpp
+++ b/gm/asyncrescaleandread.cpp
@@ -12,7 +12,7 @@
 #include "include/core/SkRect.h"
 #include "include/core/SkSurface.h"
 #include "include/core/SkYUVAIndex.h"
-#include "include/gpu/GrContext.h"
+#include "include/gpu/GrDirectContext.h"
 #include "include/gpu/GrRecordingContext.h"
 #include "src/core/SkAutoPixmapStorage.h"
 #include "src/core/SkConvertPixels.h"
@@ -292,9 +292,12 @@
     SkPaint paint;
     canvas->drawImage(image.get(), 0, 0);
 
+    auto direct = surface->recordingContext() ? surface->recordingContext()->asDirectContext()
+                                              : nullptr;
+
     SkScopeExit scopeExit;
     auto yuvImage = do_read_and_scale_yuv(
-            surface, surface->getContext(), kRec601_SkYUVColorSpace, SkIRect::MakeWH(400, 300),
+            surface, direct, kRec601_SkYUVColorSpace, SkIRect::MakeWH(400, 300),
             {400, 300}, SkImage::RescaleGamma::kSrc, kNone_SkFilterQuality, &scopeExit);
 
     canvas->clear(SK_ColorWHITE);
diff --git a/include/core/SkSurface.h b/include/core/SkSurface.h
index a665bb2..1488a16 100644
--- a/include/core/SkSurface.h
+++ b/include/core/SkSurface.h
@@ -525,14 +525,18 @@
     */
     void notifyContentWillChange(ContentChangeMode mode);
 
-    /** Returns the GPU context of the GPU surface.
-
-        @return  GPU context, if available; nullptr otherwise
+    /** Deprecated.
+        This functionality is now achieved via:
+           GrRecordingContext* recordingContext = surface->recordingContext();
+           GrDirectContext* directContext = recordingContext->asDirectContext();
+        Where 'recordingContext' could be null if 'surface' is not GPU backed and
+        'directContext' could be null if the calling code is in the midst of DDL recording.
     */
     GrContext* getContext();
 
-    /**
-     * Experimental. SkSurfaces can actually only guarantee a GrRecordingContext.
+    /** Returns the recording context being used by the SkSurface.
+
+        @return the recording context, if available; nullptr otherwise
      */
     GrRecordingContext* recordingContext();
 
diff --git a/src/image/SkSurface.cpp b/src/image/SkSurface.cpp
index 62020e5..849475d 100644
--- a/src/image/SkSurface.cpp
+++ b/src/image/SkSurface.cpp
@@ -72,7 +72,7 @@
     }
 }
 
-GrContext* SkSurface_Base::onGetContext() {
+GrContext* SkSurface_Base::onGetContext_deprecated() {
     return nullptr;
 }
 
@@ -333,7 +333,7 @@
 }
 
 GrContext* SkSurface::getContext() {
-    return asSB(this)->onGetContext();
+    return asSB(this)->onGetContext_deprecated();
 }
 
 GrRecordingContext* SkSurface::recordingContext() {
diff --git a/src/image/SkSurface_Base.h b/src/image/SkSurface_Base.h
index 3803e1f..b4d1fc4 100644
--- a/src/image/SkSurface_Base.h
+++ b/src/image/SkSurface_Base.h
@@ -20,7 +20,7 @@
     SkSurface_Base(const SkImageInfo&, const SkSurfaceProps*);
     virtual ~SkSurface_Base();
 
-    virtual GrContext* onGetContext();
+    virtual GrContext* onGetContext_deprecated();
     virtual GrRecordingContext* onGetRecordingContext();
 
     virtual GrBackendTexture onGetBackendTexture(BackendHandleAccess);
diff --git a/src/image/SkSurface_Gpu.cpp b/src/image/SkSurface_Gpu.cpp
index f2f55e8..036622f 100644
--- a/src/image/SkSurface_Gpu.cpp
+++ b/src/image/SkSurface_Gpu.cpp
@@ -11,6 +11,7 @@
 #include "include/core/SkDeferredDisplayList.h"
 #include "include/core/SkSurfaceCharacterization.h"
 #include "include/gpu/GrBackendSurface.h"
+#include "include/gpu/GrDirectContext.h"
 #include "include/gpu/GrRecordingContext.h"
 #include "src/core/SkImagePriv.h"
 #include "src/core/SkScopeExit.h"
@@ -39,7 +40,7 @@
 SkSurface_Gpu::~SkSurface_Gpu() {
 }
 
-GrContext* SkSurface_Gpu::onGetContext() {
+GrContext* SkSurface_Gpu::onGetContext_deprecated() {
     return fDevice->context();
 }
 
@@ -755,6 +756,7 @@
             SkASSERT(deleteImageProc);
             deleteImageProc(deleteImageCtx);
         }
+
         return surface;
     } else {
         return nullptr;
@@ -764,8 +766,11 @@
 
 void SkSurface::flushAndSubmit() {
     this->flush(BackendSurfaceAccess::kNoAccess, GrFlushInfo());
-    if (this->getContext()) {
-        this->getContext()->submit();
+
+    auto direct = this->recordingContext() ? this->recordingContext()->asDirectContext()
+                                           : nullptr;
+    if (direct) {
+        direct->submit();
     }
 }
 
diff --git a/src/image/SkSurface_Gpu.h b/src/image/SkSurface_Gpu.h
index fe83ee1..73f5f60 100644
--- a/src/image/SkSurface_Gpu.h
+++ b/src/image/SkSurface_Gpu.h
@@ -25,7 +25,7 @@
     static sk_sp<SkSurface> MakeWrappedRenderTarget(GrContext*,
                                                     std::unique_ptr<GrRenderTargetContext>);
 
-    GrContext* onGetContext() override;
+    GrContext* onGetContext_deprecated() override;
     GrRecordingContext* onGetRecordingContext() override;
 
     GrBackendTexture onGetBackendTexture(BackendHandleAccess) override;
diff --git a/tests/ReadPixelsTest.cpp b/tests/ReadPixelsTest.cpp
index b418d2c..b75747b 100644
--- a/tests/ReadPixelsTest.cpp
+++ b/tests/ReadPixelsTest.cpp
@@ -954,15 +954,18 @@
     auto reader = std::function<GpuReadSrcFn<Surface>>([](const Surface& surface,
                                                           const SkIVector& offset,
                                                           const SkPixmap& pixels) {
+        auto direct = surface->recordingContext()->asDirectContext();
+        SkASSERT(direct);
+
         AsyncContext context;
         auto rect = SkIRect::MakeSize(pixels.dimensions()).makeOffset(offset);
 
         // Rescale quality and linearity don't matter since we're doing a non-scaling readback.
         surface->asyncRescaleAndReadPixels(pixels.info(), rect, SkImage::RescaleGamma::kSrc,
                                            kNone_SkFilterQuality, async_callback, &context);
-        surface->getContext()->submit();
+        direct->submit();
         while (!context.fCalled) {
-            surface->getCanvas()->getGrContext()->checkAsyncWorkCompletion();
+            direct->checkAsyncWorkCompletion();
         }
         if (!context.fResult) {
             return GpuReadResult::kFail;
@@ -1111,16 +1114,16 @@
             }
             for (bool yuv : {false, true}) {
                 sk_gpu_test::GrContextFactory factory(options);
-                auto context = factory.get(type);
-                if (!context) {
+                auto direct = factory.get(type);
+                if (!direct) {
                     continue;
                 }
                 // This test is only meaningful for contexts that support transfer buffers for
                 // reads.
-                if (!context->priv().caps()->transferFromSurfaceToBufferSupport()) {
+                if (!direct->priv().caps()->transferFromSurfaceToBufferSupport()) {
                     continue;
                 }
-                auto surf = SkSurface::MakeRenderTarget(context, SkBudgeted::kYes, ii, 1, nullptr);
+                auto surf = SkSurface::MakeRenderTarget(direct, SkBudgeted::kYes, ii, 1, nullptr);
                 if (!surf) {
                     continue;
                 }
@@ -1135,9 +1138,9 @@
                                                     kNone_SkFilterQuality, &async_callback,
                                                     &cbContext);
                 }
-                surf->getContext()->submit();
+                direct->submit();
                 while (!cbContext.fCalled) {
-                    context->checkAsyncWorkCompletion();
+                    direct->checkAsyncWorkCompletion();
                 }
                 if (!cbContext.fResult) {
                     ERRORF(reporter, "Callback failed on %s. is YUV: %d",
diff --git a/tests/VkProtectedContextTest.cpp b/tests/VkProtectedContextTest.cpp
index db30f8b..e796c13 100644
--- a/tests/VkProtectedContextTest.cpp
+++ b/tests/VkProtectedContextTest.cpp
@@ -22,18 +22,18 @@
 #include "tools/gpu/GrContextFactory.h"
 #include "tools/gpu/vk/VkTestHelper.h"
 
-static sk_sp<SkSurface> create_protected_sksurface(GrContext* context,
+static sk_sp<SkSurface> create_protected_sksurface(GrDirectContext* direct,
                                                    skiatest::Reporter* reporter) {
     const int kW = 8;
     const int kH = 8;
-    GrBackendTexture backendTex = context->createBackendTexture(
+    GrBackendTexture backendTex = direct->createBackendTexture(
         kW, kH, kRGBA_8888_SkColorType, GrMipMapped::kNo, GrRenderable::kYes, GrProtected::kYes);
     REPORTER_ASSERT(reporter, backendTex.isValid());
     REPORTER_ASSERT(reporter, backendTex.isProtected());
 
     SkSurfaceProps surfaceProps = SkSurfaceProps(0, SkSurfaceProps::kLegacyFontHost_InitType);
     sk_sp<SkSurface> surface = SkSurface::MakeFromBackendTexture(
-        context, backendTex, kTopLeft_GrSurfaceOrigin, 1,
+        direct, backendTex, kTopLeft_GrSurfaceOrigin, 1,
         kRGBA_8888_SkColorType, nullptr, &surfaceProps);
     REPORTER_ASSERT(reporter, surface);
     return surface;
@@ -56,12 +56,12 @@
     if (!protectedTestHelper->init()) {
         return;
     }
-    REPORTER_ASSERT(reporter, protectedTestHelper->grContext() != nullptr);
+    REPORTER_ASSERT(reporter, protectedTestHelper->directContext() != nullptr);
 
     const int kW = 8;
     const int kH = 8;
     GrBackendTexture backendTex =
-        protectedTestHelper->grContext()->createBackendTexture(
+        protectedTestHelper->directContext()->createBackendTexture(
             kW, kH, kRGBA_8888_SkColorType, GrMipMapped::kNo, GrRenderable::kNo,
             GrProtected::kYes);
     REPORTER_ASSERT(reporter, backendTex.isValid());
@@ -69,11 +69,11 @@
 
     SkSurfaceProps surfaceProps = SkSurfaceProps(0, SkSurfaceProps::kLegacyFontHost_InitType);
     sk_sp<SkSurface> surface = SkSurface::MakeFromBackendTextureAsRenderTarget(
-        protectedTestHelper->grContext(), backendTex, kTopLeft_GrSurfaceOrigin, 1,
+        protectedTestHelper->directContext(), backendTex, kTopLeft_GrSurfaceOrigin, 1,
         kRGBA_8888_SkColorType, nullptr, &surfaceProps);
     REPORTER_ASSERT(reporter, surface);
 
-    protectedTestHelper->grContext()->deleteBackendTexture(backendTex);
+    protectedTestHelper->directContext()->deleteBackendTexture(backendTex);
 }
 
 DEF_GPUTEST(VkProtectedContext_CreateNonprotectedTextureInProtectedContext, reporter, options) {
@@ -81,12 +81,12 @@
     if (!protectedTestHelper->init()) {
         return;
     }
-    REPORTER_ASSERT(reporter, protectedTestHelper->grContext() != nullptr);
+    REPORTER_ASSERT(reporter, protectedTestHelper->directContext() != nullptr);
 
     const int kW = 8;
     const int kH = 8;
     GrBackendTexture backendTex =
-        protectedTestHelper->grContext()->createBackendTexture(
+        protectedTestHelper->directContext()->createBackendTexture(
             kW, kH, kRGBA_8888_SkColorType, GrMipMapped::kNo, GrRenderable::kNo,
             GrProtected::kNo);
     REPORTER_ASSERT(reporter, !backendTex.isValid());
@@ -97,12 +97,12 @@
     if (!protectedTestHelper->init()) {
         return;
     }
-    REPORTER_ASSERT(reporter, protectedTestHelper->grContext() != nullptr);
+    REPORTER_ASSERT(reporter, protectedTestHelper->directContext() != nullptr);
 
     const int kW = 8;
     const int kH = 8;
     GrBackendTexture backendTex =
-        protectedTestHelper->grContext()->createBackendTexture(
+        protectedTestHelper->directContext()->createBackendTexture(
             kW, kH, kRGBA_8888_SkColorType, GrMipMapped::kNo, GrRenderable::kNo,
             GrProtected::kYes);
     REPORTER_ASSERT(reporter, !backendTex.isValid());
@@ -113,13 +113,13 @@
     if (!protectedTestHelper->init()) {
         return;
     }
-    REPORTER_ASSERT(reporter, protectedTestHelper->grContext() != nullptr);
+    REPORTER_ASSERT(reporter, protectedTestHelper->directContext() != nullptr);
 
-    auto surface = create_protected_sksurface(protectedTestHelper->grContext(), reporter);
+    auto surface = create_protected_sksurface(protectedTestHelper->directContext(), reporter);
     REPORTER_ASSERT(reporter, surface);
     REPORTER_ASSERT(reporter, !surface->readPixels(SkImageInfo(), nullptr, 8, 0, 0));
 
-    protectedTestHelper->grContext()->deleteBackendTexture(
+    protectedTestHelper->directContext()->deleteBackendTexture(
         surface->getBackendTexture(SkSurface::kFlushRead_BackendHandleAccess));
 }
 
@@ -143,9 +143,9 @@
     if (!protectedTestHelper->init()) {
         return;
     }
-    REPORTER_ASSERT(reporter, protectedTestHelper->grContext() != nullptr);
+    REPORTER_ASSERT(reporter, protectedTestHelper->directContext() != nullptr);
 
-    auto surface = create_protected_sksurface(protectedTestHelper->grContext(), reporter);
+    auto surface = create_protected_sksurface(protectedTestHelper->directContext(), reporter);
     REPORTER_ASSERT(reporter, surface);
     AsyncContext cbContext;
     const auto image_info = SkImageInfo::Make(10, 10, kRGBA_8888_SkColorType, kPremul_SkAlphaType,
@@ -154,13 +154,13 @@
                                              image_info.bounds(), image_info.dimensions(),
                                              SkSurface::RescaleGamma::kSrc, kNone_SkFilterQuality,
                                              &async_callback, &cbContext);
-    surface->getContext()->submit();
+    protectedTestHelper->directContext()->submit();
     while (!cbContext.fCalled) {
         surface->getCanvas()->getGrContext()->checkAsyncWorkCompletion();
     }
     REPORTER_ASSERT(reporter, !cbContext.fResult);
 
-    protectedTestHelper->grContext()->deleteBackendTexture(
+    protectedTestHelper->directContext()->deleteBackendTexture(
         surface->getBackendTexture(SkSurface::kFlushRead_BackendHandleAccess));
 }
 
@@ -169,9 +169,9 @@
     if (!protectedTestHelper->init()) {
         return;
     }
-    REPORTER_ASSERT(reporter, protectedTestHelper->grContext() != nullptr);
+    REPORTER_ASSERT(reporter, protectedTestHelper->directContext() != nullptr);
 
-    auto surface = create_protected_sksurface(protectedTestHelper->grContext(), reporter);
+    auto surface = create_protected_sksurface(protectedTestHelper->directContext(), reporter);
     REPORTER_ASSERT(reporter, surface);
     SkCanvas* canvas = surface->getCanvas();
     REPORTER_ASSERT(reporter, canvas);
@@ -180,8 +180,8 @@
     canvas->drawRect(SkRect::MakeWH(4, 4), paint);
 
     surface->flush();
-    surface->getContext()->submit(true);
-    protectedTestHelper->grContext()->deleteBackendTexture(
+    protectedTestHelper->directContext()->submit(true);
+    protectedTestHelper->directContext()->deleteBackendTexture(
         surface->getBackendTexture(SkSurface::kFlushRead_BackendHandleAccess));
 }
 
@@ -190,9 +190,9 @@
     if (!protectedTestHelper->init()) {
         return;
     }
-    REPORTER_ASSERT(reporter, protectedTestHelper->grContext() != nullptr);
+    REPORTER_ASSERT(reporter, protectedTestHelper->directContext() != nullptr);
 
-    auto surface = create_protected_sksurface(protectedTestHelper->grContext(), reporter);
+    auto surface = create_protected_sksurface(protectedTestHelper->directContext(), reporter);
     REPORTER_ASSERT(reporter, surface);
     SkCanvas* canvas = surface->getCanvas();
     REPORTER_ASSERT(reporter, canvas);
@@ -202,8 +202,8 @@
     canvas->drawRect(SkRect::MakeWH(4, 4), paint);
 
     surface->flush();
-    surface->getContext()->submit(true);
-    protectedTestHelper->grContext()->deleteBackendTexture(
+    protectedTestHelper->directContext()->submit(true);
+    protectedTestHelper->directContext()->deleteBackendTexture(
         surface->getBackendTexture(SkSurface::kFlushRead_BackendHandleAccess));
 }
 
@@ -212,9 +212,9 @@
     if (!protectedTestHelper->init()) {
         return;
     }
-    REPORTER_ASSERT(reporter, protectedTestHelper->grContext() != nullptr);
+    REPORTER_ASSERT(reporter, protectedTestHelper->directContext() != nullptr);
 
-    auto surface = create_protected_sksurface(protectedTestHelper->grContext(), reporter);
+    auto surface = create_protected_sksurface(protectedTestHelper->directContext(), reporter);
     REPORTER_ASSERT(reporter, surface);
     SkCanvas* canvas = surface->getCanvas();
     REPORTER_ASSERT(reporter, canvas);
@@ -224,8 +224,8 @@
     canvas->drawRect(SkRect::MakeWH(4, 4), paint);
 
     surface->flush();
-    surface->getContext()->submit(true);
-    protectedTestHelper->grContext()->deleteBackendTexture(
+    protectedTestHelper->directContext()->submit(true);
+    protectedTestHelper->directContext()->deleteBackendTexture(
         surface->getBackendTexture(SkSurface::kFlushRead_BackendHandleAccess));
 }
 
@@ -234,9 +234,9 @@
     if (!protectedTestHelper->init()) {
         return;
     }
-    REPORTER_ASSERT(reporter, protectedTestHelper->grContext() != nullptr);
+    REPORTER_ASSERT(reporter, protectedTestHelper->directContext() != nullptr);
 
-    auto surface = create_protected_sksurface(protectedTestHelper->grContext(), reporter);
+    auto surface = create_protected_sksurface(protectedTestHelper->directContext(), reporter);
     REPORTER_ASSERT(reporter, surface);
     SkCanvas* canvas = surface->getCanvas();
     REPORTER_ASSERT(reporter, canvas);
@@ -248,8 +248,8 @@
     canvas->drawRect(SkRect::MakeWH(4, 4), paint);
 
     surface->flush();
-    surface->getContext()->submit(true);
-    protectedTestHelper->grContext()->deleteBackendTexture(
+    protectedTestHelper->directContext()->submit(true);
+    protectedTestHelper->directContext()->deleteBackendTexture(
         surface->getBackendTexture(SkSurface::kFlushRead_BackendHandleAccess));
 }
 
@@ -258,9 +258,9 @@
     if (!protectedTestHelper->init()) {
         return;
     }
-    REPORTER_ASSERT(reporter, protectedTestHelper->grContext() != nullptr);
+    REPORTER_ASSERT(reporter, protectedTestHelper->directContext() != nullptr);
 
-    auto surface = create_protected_sksurface(protectedTestHelper->grContext(), reporter);
+    auto surface = create_protected_sksurface(protectedTestHelper->directContext(), reporter);
     REPORTER_ASSERT(reporter, surface);
     SkCanvas* canvas = surface->getCanvas();
     REPORTER_ASSERT(reporter, canvas);
@@ -272,8 +272,8 @@
     canvas->drawPath(SkPath().moveTo(4, 4).lineTo(6, 6), paint);
 
     surface->flush();
-    surface->getContext()->submit(true);
-    protectedTestHelper->grContext()->deleteBackendTexture(
+    protectedTestHelper->directContext()->submit(true);
+    protectedTestHelper->directContext()->deleteBackendTexture(
         surface->getBackendTexture(SkSurface::kFlushRead_BackendHandleAccess));
 }
 
@@ -282,9 +282,9 @@
     if (!protectedTestHelper->init()) {
         return;
     }
-    REPORTER_ASSERT(reporter, protectedTestHelper->grContext() != nullptr);
+    REPORTER_ASSERT(reporter, protectedTestHelper->directContext() != nullptr);
 
-    auto surface = create_protected_sksurface(protectedTestHelper->grContext(), reporter);
+    auto surface = create_protected_sksurface(protectedTestHelper->directContext(), reporter);
     REPORTER_ASSERT(reporter, surface);
     SkCanvas* canvas = surface->getCanvas();
     REPORTER_ASSERT(reporter, canvas);
@@ -295,8 +295,8 @@
     canvas->restore();
 
     surface->flush();
-    surface->getContext()->submit(true);
-    protectedTestHelper->grContext()->deleteBackendTexture(
+    protectedTestHelper->directContext()->submit(true);
+    protectedTestHelper->directContext()->deleteBackendTexture(
         surface->getBackendTexture(SkSurface::kFlushRead_BackendHandleAccess));
 }
 
@@ -306,16 +306,16 @@
     if (!protectedTestHelper->init()) {
         return;
     }
-    REPORTER_ASSERT(reporter, protectedTestHelper->grContext() != nullptr);
+    REPORTER_ASSERT(reporter, protectedTestHelper->directContext() != nullptr);
 
     // Create protected image.
-    auto surface1 = create_protected_sksurface(protectedTestHelper->grContext(), reporter);
+    auto surface1 = create_protected_sksurface(protectedTestHelper->directContext(), reporter);
     REPORTER_ASSERT(reporter, surface1);
     auto image = surface1->makeImageSnapshot();
     REPORTER_ASSERT(reporter, image);
 
     // Create protected canvas.
-    auto surface2 = create_protected_sksurface(protectedTestHelper->grContext(), reporter);
+    auto surface2 = create_protected_sksurface(protectedTestHelper->directContext(), reporter);
     REPORTER_ASSERT(reporter, surface2);
     SkCanvas* canvas = surface2->getCanvas();
     REPORTER_ASSERT(reporter, canvas);
@@ -323,12 +323,12 @@
     canvas->drawImage(image, 0, 0);
 
     surface1->flush();
-    surface1->getContext()->submit(true);
-    protectedTestHelper->grContext()->deleteBackendTexture(
+    protectedTestHelper->directContext()->submit(true);
+    protectedTestHelper->directContext()->deleteBackendTexture(
         surface1->getBackendTexture(SkSurface::kFlushRead_BackendHandleAccess));
     surface2->flush();
-    surface2->getContext()->submit(true);
-    protectedTestHelper->grContext()->deleteBackendTexture(
+    protectedTestHelper->directContext()->submit(true);
+    protectedTestHelper->directContext()->deleteBackendTexture(
         surface2->getBackendTexture(SkSurface::kFlushRead_BackendHandleAccess));
 }
 
@@ -342,9 +342,9 @@
     if (!protectedTestHelper->init()) {
         return;
     }
-    REPORTER_ASSERT(reporter, protectedTestHelper->grContext() != nullptr);
+    REPORTER_ASSERT(reporter, protectedTestHelper->directContext() != nullptr);
 
-    DDLMakeRenderTargetTestImpl(protectedTestHelper->grContext(), reporter);
+    DDLMakeRenderTargetTestImpl(protectedTestHelper->directContext(), reporter);
 }
 
 void DDLSurfaceCharacterizationTestImpl(GrContext* context, skiatest::Reporter* reporter);
@@ -354,9 +354,9 @@
     if (!protectedTestHelper->init()) {
         return;
     }
-    REPORTER_ASSERT(reporter, protectedTestHelper->grContext() != nullptr);
+    REPORTER_ASSERT(reporter, protectedTestHelper->directContext() != nullptr);
 
-    DDLSurfaceCharacterizationTestImpl(protectedTestHelper->grContext(), reporter);
+    DDLSurfaceCharacterizationTestImpl(protectedTestHelper->directContext(), reporter);
 }
 
 #endif  // SK_SUPPORT_GPU && defined(SK_VULKAN)
diff --git a/tests/VkYcbcrSamplerTest.cpp b/tests/VkYcbcrSamplerTest.cpp
index 1a57d8b..c526086 100644
--- a/tests/VkYcbcrSamplerTest.cpp
+++ b/tests/VkYcbcrSamplerTest.cpp
@@ -34,7 +34,7 @@
         return;
     }
 
-    VkYcbcrSamplerHelper ycbcrHelper(testHelper.grContext());
+    VkYcbcrSamplerHelper ycbcrHelper(testHelper.directContext());
     if (!ycbcrHelper.isYCbCrSupported()) {
         return;
     }
@@ -44,7 +44,7 @@
         return;
     }
 
-    sk_sp<SkImage> srcImage = SkImage::MakeFromTexture(testHelper.grContext(),
+    sk_sp<SkImage> srcImage = SkImage::MakeFromTexture(testHelper.directContext(),
                                                        ycbcrHelper.backendTexture(),
                                                        kTopLeft_GrSurfaceOrigin,
                                                        kRGB_888x_SkColorType,
@@ -56,7 +56,7 @@
     }
 
     sk_sp<SkSurface> surface = SkSurface::MakeRenderTarget(
-            testHelper.grContext(), SkBudgeted::kNo,
+            testHelper.directContext(), SkBudgeted::kNo,
             SkImageInfo::Make(kImageWidth, kImageHeight, kN32_SkColorType, kPremul_SkAlphaType));
     if (!surface) {
         ERRORF(reporter, "Failed to create target SkSurface");
@@ -123,12 +123,12 @@
         return;
     }
 
-    VkYcbcrSamplerHelper ycbcrHelper(testHelper.grContext());
+    VkYcbcrSamplerHelper ycbcrHelper(testHelper.directContext());
     if (!ycbcrHelper.isYCbCrSupported()) {
         return;
     }
 
-    GrBackendTexture texture = testHelper.grContext()->createBackendTexture(
+    GrBackendTexture texture = testHelper.directContext()->createBackendTexture(
             kImageWidth, kImageHeight, GrBackendFormat::MakeVk(VK_FORMAT_G8_B8R8_2PLANE_420_UNORM),
             GrMipMapped::kNo, GrRenderable::kNo, GrProtected::kNo);
     if (texture.isValid()) {
diff --git a/tools/gpu/vk/VkTestHelper.cpp b/tools/gpu/vk/VkTestHelper.cpp
index f1a02a4..d7e3616 100644
--- a/tools/gpu/vk/VkTestHelper.cpp
+++ b/tools/gpu/vk/VkTestHelper.cpp
@@ -10,7 +10,7 @@
 #ifdef SK_VULKAN
 
 #include "include/core/SkSurface.h"
-#include "include/gpu/GrContext.h"
+#include "include/gpu/GrDirectContext.h"
 #include "tools/gpu/vk/VkTestUtils.h"
 
 #define ACQUIRE_INST_VK_PROC(name)                                                           \
@@ -77,8 +77,12 @@
     ACQUIRE_DEVICE_VK_PROC(FlushMappedMemoryRanges)
     ACQUIRE_DEVICE_VK_PROC(GetImageSubresourceLayout)
 
-    fGrContext = GrContext::MakeVulkan(fBackendContext);
-    if (!fGrContext) {
+    // CONTEXT TODO: MakeVulkan should return an sk_sp<GrDirectContext>
+    auto tmp = GrContext::MakeVulkan(fBackendContext);
+    if (tmp) {
+        fDirectContext = sk_ref_sp<GrDirectContext>(tmp->asDirectContext());
+    }
+    if (!fDirectContext) {
         return false;
     }
 
@@ -86,7 +90,7 @@
 }
 
 void VkTestHelper::cleanup() {
-    fGrContext.reset();
+    fDirectContext.reset();
 
     fBackendContext.fMemoryAllocator.reset();
     if (fDevice != VK_NULL_HANDLE) {
diff --git a/tools/gpu/vk/VkTestHelper.h b/tools/gpu/vk/VkTestHelper.h
index 965885a..9fc11e4 100644
--- a/tools/gpu/vk/VkTestHelper.h
+++ b/tools/gpu/vk/VkTestHelper.h
@@ -16,7 +16,7 @@
 #include "include/gpu/vk/GrVkBackendContext.h"
 #include "include/gpu/vk/GrVkExtensions.h"
 
-class GrContext;
+class GrDirectContext;
 class SkSurface;
 
 #define DECLARE_VK_PROC(name) PFN_vk##name fVk##name
@@ -31,7 +31,7 @@
 
     bool init();
 
-    GrContext* grContext() { return fGrContext.get(); }
+    GrDirectContext* directContext() { return fDirectContext.get(); }
 
 private:
     void cleanup();
@@ -62,7 +62,7 @@
     VkDebugReportCallbackEXT fDebugCallback = VK_NULL_HANDLE;
     PFN_vkDestroyDebugReportCallbackEXT fDestroyDebugCallback = nullptr;
     GrVkBackendContext fBackendContext;
-    sk_sp<GrContext> fGrContext;
+    sk_sp<GrDirectContext> fDirectContext;
 };
 
 #undef DECLARE_VK_PROC
diff --git a/tools/sk_app/VulkanWindowContext.cpp b/tools/sk_app/VulkanWindowContext.cpp
index 970c67e..02284c9 100644
--- a/tools/sk_app/VulkanWindowContext.cpp
+++ b/tools/sk_app/VulkanWindowContext.cpp
@@ -11,7 +11,7 @@
 #include "include/core/SkSurface.h"
 #include "include/gpu/GrBackendSemaphore.h"
 #include "include/gpu/GrBackendSurface.h"
-#include "include/gpu/GrContext.h"
+#include "include/gpu/GrDirectContext.h"
 #include "src/core/SkAutoMalloc.h"
 
 #include "include/gpu/vk/GrVkExtensions.h"
@@ -530,7 +530,7 @@
     info.fSignalSemaphores = &beSemaphore;
     GrBackendSurfaceMutableState presentState(VK_IMAGE_LAYOUT_PRESENT_SRC_KHR, fPresentQueueIndex);
     surface->flush(info, &presentState);
-    surface->getContext()->submit();
+    surface->recordingContext()->asDirectContext()->submit();
 
     // Submit present operation to present queue
     const VkPresentInfoKHR presentInfo =