Migrate GrSurfaceContext readPixels to take direct context

After this lands we'll proceed up the stack and add the direct
context requirement to the public API and SkImage.

Bug: skia:104662
Change-Id: I4b2d779a7fcd65eec68e631757821ac8e136ddba
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/309044
Commit-Queue: Adlai Holler <adlai@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
diff --git a/src/gpu/GrSurfaceContext.cpp b/src/gpu/GrSurfaceContext.cpp
index 5e51da4..8a0a0d4 100644
--- a/src/gpu/GrSurfaceContext.cpp
+++ b/src/gpu/GrSurfaceContext.cpp
@@ -132,14 +132,14 @@
 }
 #endif
 
-bool GrSurfaceContext::readPixels(const GrImageInfo& origDstInfo, void* dst, size_t rowBytes,
-                                  SkIPoint pt, GrDirectContext* direct) {
+bool GrSurfaceContext::readPixels(GrDirectContext* dContext, const GrImageInfo& origDstInfo,
+                                  void* dst, size_t rowBytes, SkIPoint pt) {
     ASSERT_SINGLE_OWNER
     RETURN_FALSE_IF_ABANDONED
     SkDEBUGCODE(this->validate();)
     GR_AUDIT_TRAIL_AUTO_FRAME(this->auditTrail(), "GrSurfaceContext::readPixels");
 
-    if (!direct && !(direct = fContext->asDirectContext())) {
+    if (!dContext) {
         return false;
     }
 
@@ -165,7 +165,7 @@
     }
 
     // MDB TODO: delay this instantiation until later in the method
-    if (!srcProxy->instantiate(direct->priv().resourceProvider())) {
+    if (!srcProxy->instantiate(dContext->priv().resourceProvider())) {
         return false;
     }
 
@@ -183,7 +183,7 @@
          needColorConversion = flags.linearize || flags.gamut_transform || flags.encode,
          premul              = flags.premul;
 
-    const GrCaps* caps = direct->priv().caps();
+    const GrCaps* caps = dContext->priv().caps();
     bool srcIsCompressed = caps->isFormatCompressed(srcSurface->backendFormat());
     // This is the getImageData equivalent to the canvas2D putImageData fast path. We probably don't
     // care so much about getImageData performance. However, in order to ensure putImageData/
@@ -200,7 +200,7 @@
                             (srcColorType == GrColorType::kRGBA_8888 ||
                              srcColorType == GrColorType::kBGRA_8888) &&
                             defaultRGBAFormat.isValid() &&
-                            direct->priv().validPMUPMConversionExists();
+                            dContext->priv().validPMUPMConversionExists();
 
     auto readFlag = caps->surfaceSupportsReadPixels(srcSurface);
     if (readFlag == GrCaps::SurfaceReadPixelsSupport::kUnsupported) {
@@ -213,7 +213,7 @@
         sk_sp<SkColorSpace> cs = canvas2DFastPath ? nullptr : this->colorInfo().refColorSpace();
 
         auto tempCtx = GrRenderTargetContext::Make(
-                direct, colorType, std::move(cs), SkBackingFit::kApprox, dstInfo.dimensions(),
+                dContext, colorType, std::move(cs), SkBackingFit::kApprox, dstInfo.dimensions(),
                 1, GrMipmapped::kNo, GrProtected::kNo, kTopLeft_GrSurfaceOrigin);
         if (!tempCtx) {
             return false;
@@ -221,7 +221,7 @@
 
         std::unique_ptr<GrFragmentProcessor> fp;
         if (canvas2DFastPath) {
-            fp = direct->priv().createPMToUPMEffect(
+            fp = dContext->priv().createPMToUPMEffect(
                     GrTextureEffect::Make(this->readSurfaceView(), this->colorInfo().alphaType()));
             if (dstInfo.colorType() == GrColorType::kBGRA_8888) {
                 fp = GrFragmentProcessor::SwizzleOutput(std::move(fp), GrSwizzle::BGRA());
@@ -246,7 +246,7 @@
                 SkRect::MakeWH(dstInfo.width(), dstInfo.height()),
                 SkRect::MakeXYWH(pt.fX, pt.fY, dstInfo.width(), dstInfo.height()));
 
-        return tempCtx->readPixels(dstInfo, dst, rowBytes, {0, 0}, direct);
+        return tempCtx->readPixels(dContext, dstInfo, dst, rowBytes, {0, 0});
     }
 
     bool flip = this->origin() == kBottomLeft_GrSurfaceOrigin;
@@ -276,11 +276,11 @@
         pt.fY = flip ? srcSurface->height() - pt.fY - dstInfo.height() : pt.fY;
     }
 
-    direct->priv().flushSurface(srcProxy);
-    direct->submit();
-    if (!direct->priv().getGpu()->readPixels(srcSurface, pt.fX, pt.fY, dstInfo.width(),
-                                             dstInfo.height(), this->colorInfo().colorType(),
-                                             supportedRead.fColorType, readDst, readRB)) {
+    dContext->priv().flushSurface(srcProxy);
+    dContext->submit();
+    if (!dContext->priv().getGpu()->readPixels(srcSurface, pt.fX, pt.fY, dstInfo.width(),
+                                               dstInfo.height(), this->colorInfo().colorType(),
+                                               supportedRead.fColorType, readDst, readRB)) {
         return false;
     }
 
@@ -290,14 +290,14 @@
     return true;
 }
 
-bool GrSurfaceContext::writePixels(const GrImageInfo& origSrcInfo, const void* src, size_t rowBytes,
-                                   SkIPoint pt, GrDirectContext* direct) {
+bool GrSurfaceContext::writePixels(GrDirectContext* dContext, const GrImageInfo& origSrcInfo,
+                                   const void* src, size_t rowBytes, SkIPoint pt) {
     ASSERT_SINGLE_OWNER
     RETURN_FALSE_IF_ABANDONED
     SkDEBUGCODE(this->validate();)
     GR_AUDIT_TRAIL_AUTO_FRAME(this->auditTrail(), "GrSurfaceContext::writePixels");
 
-    if (!direct && !(direct = fContext->asDirectContext())) {
+    if (!dContext) {
         return false;
     }
 
@@ -326,7 +326,7 @@
         return false;
     }
 
-    if (!dstProxy->instantiate(direct->priv().resourceProvider())) {
+    if (!dstProxy->instantiate(dContext->priv().resourceProvider())) {
         return false;
     }
 
@@ -344,7 +344,7 @@
          needColorConversion = flags.linearize || flags.gamut_transform || flags.encode,
          premul              = flags.premul;
 
-    const GrCaps* caps = direct->priv().caps();
+    const GrCaps* caps = dContext->priv().caps();
 
     auto rgbaDefaultFormat = caps->getDefaultBackendFormat(GrColorType::kRGBA_8888,
                                                            GrRenderable::kNo);
@@ -359,7 +359,7 @@
                             (dstColorType == GrColorType::kRGBA_8888 ||
                              dstColorType == GrColorType::kBGRA_8888) &&
                             rgbaDefaultFormat.isValid() &&
-                            direct->priv().validPMUPMConversionExists();
+                            dContext->priv().validPMUPMConversionExists();
 
     if (!caps->surfaceSupportsWritePixels(dstSurface) || canvas2DFastPath) {
         GrColorType colorType;
@@ -388,14 +388,14 @@
         // targets we will use top left and otherwise we will make the origins match.
         GrSurfaceOrigin tempOrigin =
                 this->asRenderTargetContext() ? kTopLeft_GrSurfaceOrigin : this->origin();
-        auto tempProxy = direct->priv().proxyProvider()->createProxy(
+        auto tempProxy = dContext->priv().proxyProvider()->createProxy(
                 format, srcInfo.dimensions(), GrRenderable::kNo, 1, GrMipmapped::kNo,
                 SkBackingFit::kApprox, SkBudgeted::kYes, GrProtected::kNo);
         if (!tempProxy) {
             return false;
         }
         GrSurfaceProxyView tempView(tempProxy, tempOrigin, tempReadSwizzle);
-        GrSurfaceContext tempCtx(direct, tempView, colorType, alphaType,
+        GrSurfaceContext tempCtx(dContext, tempView, colorType, alphaType,
                                  this->colorInfo().refColorSpace());
 
         // In the fast path we always write the srcData to the temp context as though it were RGBA.
@@ -405,14 +405,14 @@
         if (canvas2DFastPath) {
             srcInfo = srcInfo.makeColorType(GrColorType::kRGBA_8888);
         }
-        if (!tempCtx.writePixels(srcInfo, src, rowBytes, {0, 0}, direct)) {
+        if (!tempCtx.writePixels(dContext, srcInfo, src, rowBytes, {0, 0})) {
             return false;
         }
 
         if (this->asRenderTargetContext()) {
             std::unique_ptr<GrFragmentProcessor> fp;
             if (canvas2DFastPath) {
-                fp = direct->priv().createUPMToPMEffect(
+                fp = dContext->priv().createUPMToPMEffect(
                         GrTextureEffect::Make(std::move(tempView), alphaType));
                 // Important: check the original src color type here!
                 if (origSrcInfo.colorType() == GrColorType::kBGRA_8888) {
@@ -471,42 +471,41 @@
     // giving the drawing manager the chance of skipping the flush (i.e., by passing in the
     // destination proxy)
     // TODO: should this policy decision just be moved into the drawing manager?
-    direct->priv().flushSurface(caps->preferVRAMUseOverFlushes() ? dstProxy : nullptr);
+    dContext->priv().flushSurface(caps->preferVRAMUseOverFlushes() ? dstProxy : nullptr);
 
-    return direct->priv().getGpu()->writePixels(dstSurface, pt.fX, pt.fY, srcInfo.width(),
-                                                srcInfo.height(), this->colorInfo().colorType(),
-                                                srcColorType, src, rowBytes);
+    return dContext->priv().getGpu()->writePixels(dstSurface, pt.fX, pt.fY, srcInfo.width(),
+                                                  srcInfo.height(), this->colorInfo().colorType(),
+                                                  srcColorType, src, rowBytes);
 }
 
-void GrSurfaceContext::asyncRescaleAndReadPixels(const SkImageInfo& info,
+void GrSurfaceContext::asyncRescaleAndReadPixels(GrDirectContext* dContext,
+                                                 const SkImageInfo& info,
                                                  const SkIRect& srcRect,
                                                  RescaleGamma rescaleGamma,
                                                  SkFilterQuality rescaleQuality,
                                                  ReadPixelsCallback callback,
-                                                 ReadPixelsContext context) {
-    auto direct = fContext->asDirectContext();
-
+                                                 ReadPixelsContext callbackContext) {
     // We implement this by rendering and we don't currently support rendering kUnpremul.
     if (info.alphaType() == kUnpremul_SkAlphaType) {
-        callback(context, nullptr);
+        callback(callbackContext, nullptr);
         return;
     }
-    if (!direct) {
-        callback(context, nullptr);
+    if (!dContext) {
+        callback(callbackContext, nullptr);
         return;
     }
     auto rt = this->asRenderTargetProxy();
     if (rt && rt->wrapsVkSecondaryCB()) {
-        callback(context, nullptr);
+        callback(callbackContext, nullptr);
         return;
     }
     if (rt && rt->framebufferOnly()) {
-        callback(context, nullptr);
+        callback(callbackContext, nullptr);
         return;
     }
     auto dstCT = SkColorTypeToGrColorType(info.colorType());
     if (dstCT == GrColorType::kUnknown) {
-        callback(context, nullptr);
+        callback(callbackContext, nullptr);
         return;
     }
     bool needsRescale = srcRect.width() != info.width() || srcRect.height() != info.height();
@@ -521,7 +520,7 @@
                                                                backendFormatOfFinalContext, dstCT);
     // Fail if we can't read from the source surface's color type.
     if (readInfo.fColorType == GrColorType::kUnknown) {
-        callback(context, nullptr);
+        callback(callbackContext, nullptr);
         return;
     }
     // Fail if read color type does not have all of dstCT's color channels and those missing color
@@ -530,7 +529,7 @@
     uint32_t legalReadChannels = GrColorTypeChannelFlags(readInfo.fColorType);
     uint32_t srcChannels = GrColorTypeChannelFlags(this->colorInfo().colorType());
     if ((~legalReadChannels & dstChannels) & srcChannels) {
-        callback(context, nullptr);
+        callback(callbackContext, nullptr);
         return;
     }
 
@@ -541,7 +540,7 @@
         tempRTC = this->rescale(info, kTopLeft_GrSurfaceOrigin, srcRect, rescaleGamma,
                                 rescaleQuality);
         if (!tempRTC) {
-            callback(context, nullptr);
+            callback(callbackContext, nullptr);
             return;
         }
         SkASSERT(SkColorSpace::Equals(tempRTC->colorInfo().colorSpace(), info.colorSpace()));
@@ -562,18 +561,18 @@
                         GrSurfaceProxyView::Copy(fContext, texProxyView, GrMipmapped::kNo, srcRect,
                                                  SkBackingFit::kApprox, SkBudgeted::kNo);
                 if (!texProxyView) {
-                    callback(context, nullptr);
+                    callback(callbackContext, nullptr);
                     return;
                 }
                 SkASSERT(texProxyView.asTextureProxy());
                 srcRectToDraw = SkRect::MakeWH(srcRect.width(), srcRect.height());
             }
-            tempRTC = GrRenderTargetContext::Make(direct, this->colorInfo().colorType(),
+            tempRTC = GrRenderTargetContext::Make(dContext, this->colorInfo().colorType(),
                                                   info.refColorSpace(), SkBackingFit::kApprox,
                                                   srcRect.size(), 1, GrMipmapped::kNo,
                                                   GrProtected::kNo, kTopLeft_GrSurfaceOrigin);
             if (!tempRTC) {
-                callback(context, nullptr);
+                callback(callbackContext, nullptr);
                 return;
             }
             tempRTC->drawTexture(nullptr,
@@ -594,8 +593,8 @@
         }
     }
     auto rtc = tempRTC ? tempRTC.get() : this;
-    return rtc->asyncReadPixels(SkIRect::MakeXYWH(x, y, info.width(), info.height()),
-                                info.colorType(), callback, context);
+    return rtc->asyncReadPixels(dContext, SkIRect::MakeXYWH(x, y, info.width(), info.height()),
+                                info.colorType(), callback, callbackContext);
 }
 
 class GrSurfaceContext::AsyncReadResult : public SkImage::AsyncReadResult {
@@ -664,21 +663,20 @@
     uint32_t fInboxID;
 };
 
-void GrSurfaceContext::asyncReadPixels(const SkIRect& rect,
+void GrSurfaceContext::asyncReadPixels(GrDirectContext* dContext,
+                                       const SkIRect& rect,
                                        SkColorType colorType,
                                        ReadPixelsCallback callback,
-                                       ReadPixelsContext context) {
+                                       ReadPixelsContext callbackContext) {
     SkASSERT(rect.fLeft >= 0 && rect.fRight <= this->width());
     SkASSERT(rect.fTop >= 0 && rect.fBottom <= this->height());
 
-    if (this->asSurfaceProxy()->isProtected() == GrProtected::kYes) {
-        callback(context, nullptr);
+    if (!dContext || this->asSurfaceProxy()->isProtected() == GrProtected::kYes) {
+        callback(callbackContext, nullptr);
         return;
     }
 
-    auto directContext = fContext->asDirectContext();
-    SkASSERT(directContext);
-    auto mappedBufferManager = directContext->priv().clientMappedBufferManager();
+    auto mappedBufferManager = dContext->priv().clientMappedBufferManager();
 
     auto transferResult = this->transferPixels(SkColorTypeToGrColorType(colorType), rect);
 
@@ -690,11 +688,12 @@
         SkPixmap pm(ii, data.get(), ii.minRowBytes());
         result->addCpuPlane(std::move(data), pm.rowBytes());
 
-        if (!this->readPixels(ii, pm.writable_addr(), pm.rowBytes(), {rect.fLeft, rect.fTop})) {
-            callback(context, nullptr);
+        SkIPoint pt{rect.fLeft, rect.fTop};
+        if (!this->readPixels(dContext, ii, pm.writable_addr(), pm.rowBytes(), pt)) {
+            callback(callbackContext, nullptr);
             return;
         }
-        callback(context, std::move(result));
+        callback(callbackContext, std::move(result));
         return;
     }
 
@@ -710,7 +709,7 @@
     // explicit flush from the caller. We'd have to have a way to defer attaching the finish
     // callback to GrGpu until after the next flush that flushes our op list, though.
     auto* finishContext = new FinishContext{callback,
-                                            context,
+                                            callbackContext,
                                             rect.size(),
                                             colorType,
                                             mappedBufferManager,
@@ -732,35 +731,35 @@
     this->flush(SkSurface::BackendSurfaceAccess::kNoAccess, flushInfo, nullptr);
 }
 
-void GrSurfaceContext::asyncRescaleAndReadPixelsYUV420(SkYUVColorSpace yuvColorSpace,
+void GrSurfaceContext::asyncRescaleAndReadPixelsYUV420(GrDirectContext* dContext,
+                                                       SkYUVColorSpace yuvColorSpace,
                                                        sk_sp<SkColorSpace> dstColorSpace,
                                                        const SkIRect& srcRect,
                                                        SkISize dstSize,
                                                        RescaleGamma rescaleGamma,
                                                        SkFilterQuality rescaleQuality,
                                                        ReadPixelsCallback callback,
-                                                       ReadPixelsContext context) {
+                                                       ReadPixelsContext callbackContext) {
     SkASSERT(srcRect.fLeft >= 0 && srcRect.fRight <= this->width());
     SkASSERT(srcRect.fTop >= 0 && srcRect.fBottom <= this->height());
     SkASSERT(!dstSize.isZero());
     SkASSERT((dstSize.width() % 2 == 0) && (dstSize.height() % 2 == 0));
 
-    auto direct = fContext->asDirectContext();
-    if (!direct) {
-        callback(context, nullptr);
+    if (!dContext) {
+        callback(callbackContext, nullptr);
         return;
     }
     auto rt = this->asRenderTargetProxy();
     if (rt && rt->wrapsVkSecondaryCB()) {
-        callback(context, nullptr);
+        callback(callbackContext, nullptr);
         return;
     }
     if (rt && rt->framebufferOnly()) {
-        callback(context, nullptr);
+        callback(callbackContext, nullptr);
         return;
     }
     if (this->asSurfaceProxy()->isProtected() == GrProtected::kYes) {
-        callback(context, nullptr);
+        callback(callbackContext, nullptr);
         return;
     }
     int x = srcRect.fLeft;
@@ -775,7 +774,7 @@
         auto tempRTC = this->rescale(info, kTopLeft_GrSurfaceOrigin, srcRect, rescaleGamma,
                                      rescaleQuality);
         if (!tempRTC) {
-            callback(context, nullptr);
+            callback(callbackContext, nullptr);
             return;
         }
         SkASSERT(SkColorSpace::Equals(tempRTC->colorInfo().colorSpace(), info.colorSpace()));
@@ -789,7 +788,7 @@
                                                srcRect, SkBackingFit::kApprox, SkBudgeted::kYes);
             if (!srcView) {
                 // If we can't get a texture copy of the contents then give up.
-                callback(context, nullptr);
+                callback(callbackContext, nullptr);
                 return;
             }
             SkASSERT(srcView.asTextureProxy());
@@ -802,10 +801,10 @@
         if (xform) {
             SkRect srcRectToDraw = SkRect::MakeXYWH(x, y, srcRect.width(), srcRect.height());
             auto tempRTC = GrRenderTargetContext::Make(
-                    direct, this->colorInfo().colorType(), dstColorSpace, SkBackingFit::kApprox,
+                    dContext, this->colorInfo().colorType(), dstColorSpace, SkBackingFit::kApprox,
                     dstSize, 1, GrMipmapped::kNo, GrProtected::kNo, kTopLeft_GrSurfaceOrigin);
             if (!tempRTC) {
-                callback(context, nullptr);
+                callback(callbackContext, nullptr);
                 return;
             }
             tempRTC->drawTexture(nullptr,
@@ -829,18 +828,18 @@
     }
 
     auto yRTC = GrRenderTargetContext::MakeWithFallback(
-            direct, GrColorType::kAlpha_8, dstColorSpace, SkBackingFit::kApprox, dstSize, 1,
+            dContext, GrColorType::kAlpha_8, dstColorSpace, SkBackingFit::kApprox, dstSize, 1,
             GrMipmapped::kNo, GrProtected::kNo, kTopLeft_GrSurfaceOrigin);
     int halfW = dstSize.width() /2;
     int halfH = dstSize.height()/2;
     auto uRTC = GrRenderTargetContext::MakeWithFallback(
-            direct, GrColorType::kAlpha_8, dstColorSpace, SkBackingFit::kApprox, {halfW, halfH}, 1,
-            GrMipmapped::kNo, GrProtected::kNo, kTopLeft_GrSurfaceOrigin);
+            dContext, GrColorType::kAlpha_8, dstColorSpace, SkBackingFit::kApprox, {halfW, halfH},
+            1, GrMipmapped::kNo, GrProtected::kNo, kTopLeft_GrSurfaceOrigin);
     auto vRTC = GrRenderTargetContext::MakeWithFallback(
-            direct, GrColorType::kAlpha_8, dstColorSpace, SkBackingFit::kApprox, {halfW, halfH}, 1,
-            GrMipmapped::kNo, GrProtected::kNo, kTopLeft_GrSurfaceOrigin);
+            dContext, GrColorType::kAlpha_8, dstColorSpace, SkBackingFit::kApprox, {halfW, halfH},
+            1, GrMipmapped::kNo, GrProtected::kNo, kTopLeft_GrSurfaceOrigin);
     if (!yRTC || !uRTC || !vRTC) {
-        callback(context, nullptr);
+        callback(callbackContext, nullptr);
         return;
     }
 
@@ -874,7 +873,7 @@
         yTransfer = yRTC->transferPixels(GrColorType::kAlpha_8,
                                          SkIRect::MakeWH(yRTC->width(), yRTC->height()));
         if (!yTransfer.fTransferBuffer) {
-            callback(context, nullptr);
+            callback(callbackContext, nullptr);
             return;
         }
     }
@@ -899,7 +898,7 @@
         uTransfer = uRTC->transferPixels(GrColorType::kAlpha_8,
                                          SkIRect::MakeWH(uRTC->width(), uRTC->height()));
         if (!uTransfer.fTransferBuffer) {
-            callback(context, nullptr);
+            callback(callbackContext, nullptr);
             return;
         }
     }
@@ -923,7 +922,7 @@
         vTransfer = vRTC->transferPixels(GrColorType::kAlpha_8,
                                          SkIRect::MakeWH(vRTC->width(), vRTC->height()));
         if (!vTransfer.fTransferBuffer) {
-            callback(context, nullptr);
+            callback(callbackContext, nullptr);
             return;
         }
     }
@@ -936,17 +935,17 @@
         std::unique_ptr<char[]> y(new char[yRB * yInfo.height()]);
         std::unique_ptr<char[]> u(new char[uvRB*uvInfo.height()]);
         std::unique_ptr<char[]> v(new char[uvRB*uvInfo.height()]);
-        if (!yRTC->readPixels(yInfo,  y.get(), yRB,  {0, 0}, direct) ||
-            !uRTC->readPixels(uvInfo, u.get(), uvRB, {0, 0}, direct) ||
-            !vRTC->readPixels(uvInfo, v.get(), uvRB, {0, 0}, direct)) {
-            callback(context, nullptr);
+        if (!yRTC->readPixels(dContext, yInfo,  y.get(), yRB,  {0, 0}) ||
+            !uRTC->readPixels(dContext, uvInfo, u.get(), uvRB, {0, 0}) ||
+            !vRTC->readPixels(dContext, uvInfo, v.get(), uvRB, {0, 0})) {
+            callback(callbackContext, nullptr);
             return;
         }
-        auto result = std::make_unique<AsyncReadResult>(direct->priv().contextID());
+        auto result = std::make_unique<AsyncReadResult>(dContext->priv().contextID());
         result->addCpuPlane(std::move(y), yRB );
         result->addCpuPlane(std::move(u), uvRB);
         result->addCpuPlane(std::move(v), uvRB);
-        callback(context, std::move(result));
+        callback(callbackContext, std::move(result));
         return;
     }
 
@@ -963,8 +962,8 @@
     // explicit flush from the caller. We'd have to have a way to defer attaching the finish
     // callback to GrGpu until after the next flush that flushes our op list, though.
     auto* finishContext = new FinishContext{callback,
-                                            context,
-                                            direct->priv().clientMappedBufferManager(),
+                                            callbackContext,
+                                            dContext->priv().clientMappedBufferManager(),
                                             dstSize,
                                             std::move(yTransfer),
                                             std::move(uTransfer),
diff --git a/src/gpu/GrSurfaceContext.h b/src/gpu/GrSurfaceContext.h
index 4645630..6a6ef4f 100644
--- a/src/gpu/GrSurfaceContext.h
+++ b/src/gpu/GrSurfaceContext.h
@@ -75,30 +75,35 @@
 
     /**
      * Reads a rectangle of pixels from the render target context.
+     * @param dContext      The direct context to use
      * @param dstInfo       image info for the destination
      * @param dst           destination pixels for the read
      * @param rowBytes      bytes in a row of 'dst'
      * @param srcPt         offset w/in the surface context from which to read
-     * @param direct        The direct context to use. If null will use our GrRecordingContext if it
      *                      is a GrDirectContext and fail otherwise.
      */
-    bool readPixels(const GrImageInfo& dstInfo, void* dst, size_t rowBytes, SkIPoint srcPt,
-                    GrDirectContext* direct = nullptr);
+    bool readPixels(GrDirectContext* dContext,
+                    const GrImageInfo& dstInfo,
+                    void* dst,
+                    size_t rowBytes,
+                    SkIPoint srcPt);
 
     using ReadPixelsCallback = SkImage::ReadPixelsCallback;
     using ReadPixelsContext  = SkImage::ReadPixelsContext;
     using RescaleGamma       = SkImage::RescaleGamma;
 
     // GPU implementation for SkImage:: and SkSurface::asyncRescaleAndReadPixels.
-    void asyncRescaleAndReadPixels(const SkImageInfo& info,
+    void asyncRescaleAndReadPixels(GrDirectContext*,
+                                   const SkImageInfo& info,
                                    const SkIRect& srcRect,
                                    RescaleGamma rescaleGamma,
                                    SkFilterQuality rescaleQuality,
                                    ReadPixelsCallback callback,
-                                   ReadPixelsContext context);
+                                   ReadPixelsContext callbackContext);
 
     // GPU implementation for SkImage:: and SkSurface::asyncRescaleAndReadPixelsYUV420.
-    void asyncRescaleAndReadPixelsYUV420(SkYUVColorSpace yuvColorSpace,
+    void asyncRescaleAndReadPixelsYUV420(GrDirectContext*,
+                                         SkYUVColorSpace yuvColorSpace,
                                          sk_sp<SkColorSpace> dstColorSpace,
                                          const SkIRect& srcRect,
                                          SkISize dstSize,
@@ -110,15 +115,17 @@
     /**
      * Writes a rectangle of pixels [srcInfo, srcBuffer, srcRowbytes] into the
      * renderTargetContext at the specified position.
+     * @param dContext      The direct context to use
      * @param srcInfo       image info for the source pixels
      * @param src           source for the write
      * @param rowBytes      bytes in a row of 'src'
      * @param dstPt         offset w/in the surface context at which to write
-     * @param direct        The direct context to use. If null will use our GrRecordingContext if it
-     *                      is a GrDirectContext and fail otherwise.
      */
-    bool writePixels(const GrImageInfo& srcInfo, const void* src, size_t rowBytes, SkIPoint dstPt,
-                     GrDirectContext* direct = nullptr);
+    bool writePixels(GrDirectContext* dContext,
+                     const GrImageInfo& srcInfo,
+                     const void* src,
+                     size_t rowBytes,
+                     SkIPoint dstPt);
 
     GrSurfaceProxy* asSurfaceProxy() { return fReadView.proxy(); }
     const GrSurfaceProxy* asSurfaceProxy() const { return fReadView.proxy(); }
@@ -204,10 +211,11 @@
     PixelTransferResult transferPixels(GrColorType colorType, const SkIRect& rect);
 
     // The async read step of asyncRescaleAndReadPixels()
-    void asyncReadPixels(const SkIRect& rect,
-                         SkColorType colorType,
-                         ReadPixelsCallback callback,
-                         ReadPixelsContext context);
+    void asyncReadPixels(GrDirectContext*,
+                         const SkIRect& srcRect,
+                         SkColorType,
+                         ReadPixelsCallback,
+                         ReadPixelsContext);
 
 private:
     friend class GrSurfaceProxy; // for copy
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index c316910..9a86673 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -183,21 +183,26 @@
 bool SkGpuDevice::onReadPixels(const SkPixmap& pm, int x, int y) {
     ASSERT_SINGLE_OWNER
 
-    if (!SkImageInfoValidConversion(pm.info(), this->imageInfo())) {
+    // Context TODO: Elevate direct context requirement to public API
+    auto dContext = fContext->asDirectContext();
+    if (!dContext || !SkImageInfoValidConversion(pm.info(), this->imageInfo())) {
         return false;
     }
 
-    return fRenderTargetContext->readPixels(pm.info(), pm.writable_addr(), pm.rowBytes(), {x, y});
+    return fRenderTargetContext->readPixels(dContext, pm.info(), pm.writable_addr(), pm.rowBytes(),
+                                            {x, y});
 }
 
 bool SkGpuDevice::onWritePixels(const SkPixmap& pm, int x, int y) {
     ASSERT_SINGLE_OWNER
 
-    if (!SkImageInfoValidConversion(this->imageInfo(), pm.info())) {
+    // Context TODO: Elevate direct context requirement to public API
+    auto dContext = fContext->asDirectContext();
+    if (!dContext || !SkImageInfoValidConversion(this->imageInfo(), pm.info())) {
         return false;
     }
 
-    return fRenderTargetContext->writePixels(pm.info(), pm.addr(), pm.rowBytes(), {x, y});
+    return fRenderTargetContext->writePixels(dContext, pm.info(), pm.addr(), pm.rowBytes(), {x, y});
 }
 
 bool SkGpuDevice::onAccessPixels(SkPixmap* pmap) {
diff --git a/src/gpu/effects/generated/GrConfigConversionEffect.cpp b/src/gpu/effects/generated/GrConfigConversionEffect.cpp
index 4e38451..5f1a8b7 100644
--- a/src/gpu/effects/generated/GrConfigConversionEffect.cpp
+++ b/src/gpu/effects/generated/GrConfigConversionEffect.cpp
@@ -81,7 +81,7 @@
 }
 #endif
 
-bool GrConfigConversionEffect::TestForPreservingPMConversions(GrDirectContext* context) {
+bool GrConfigConversionEffect::TestForPreservingPMConversions(GrDirectContext* dContext) {
     static constexpr int kSize = 256;
     static constexpr GrColorType kColorType = GrColorType::kRGBA_8888;
     SkAutoTMalloc<uint32_t> data(kSize * kSize * 3);
@@ -107,9 +107,9 @@
     const SkImageInfo ii =
             SkImageInfo::Make(kSize, kSize, kRGBA_8888_SkColorType, kPremul_SkAlphaType);
 
-    auto readRTC = GrRenderTargetContext::Make(context, kColorType, nullptr, SkBackingFit::kExact,
+    auto readRTC = GrRenderTargetContext::Make(dContext, kColorType, nullptr, SkBackingFit::kExact,
                                                {kSize, kSize});
-    auto tempRTC = GrRenderTargetContext::Make(context, kColorType, nullptr, SkBackingFit::kExact,
+    auto tempRTC = GrRenderTargetContext::Make(dContext, kColorType, nullptr, SkBackingFit::kExact,
                                                {kSize, kSize});
     if (!readRTC || !readRTC->asTextureProxy() || !tempRTC) {
         return false;
@@ -125,7 +125,7 @@
     bitmap.installPixels(ii, srcData, 4 * kSize);
     bitmap.setImmutable();
 
-    GrBitmapTextureMaker maker(context, bitmap, GrImageTexGenPolicy::kNew_Uncached_Budgeted);
+    GrBitmapTextureMaker maker(dContext, bitmap, GrImageTexGenPolicy::kNew_Uncached_Budgeted);
     auto dataView = maker.view(GrMipmapped::kNo);
     if (!dataView) {
         return false;
@@ -144,7 +144,7 @@
     paint1.setPorterDuffXPFactory(SkBlendMode::kSrc);
 
     readRTC->fillRectToRect(nullptr, std::move(paint1), GrAA::kNo, SkMatrix::I(), kRect, kRect);
-    if (!readRTC->readPixels(ii, firstRead, 0, {0, 0})) {
+    if (!readRTC->readPixels(dContext, ii, firstRead, 0, {0, 0})) {
         return false;
     }
 
@@ -168,7 +168,7 @@
 
     readRTC->fillRectToRect(nullptr, std::move(paint3), GrAA::kNo, SkMatrix::I(), kRect, kRect);
 
-    if (!readRTC->readPixels(ii, secondRead, 0, {0, 0})) {
+    if (!readRTC->readPixels(dContext, ii, secondRead, 0, {0, 0})) {
         return false;
     }
 
diff --git a/src/gpu/text/GrAtlasManager.cpp b/src/gpu/text/GrAtlasManager.cpp
index e50c6ea..1272953 100644
--- a/src/gpu/text/GrAtlasManager.cpp
+++ b/src/gpu/text/GrAtlasManager.cpp
@@ -219,27 +219,26 @@
   * Write the contents of the surface proxy to a PNG. Returns true if successful.
   * @param filename      Full path to desired file
   */
-static bool save_pixels(GrDirectContext* context, GrSurfaceProxyView view, GrColorType colorType,
+static bool save_pixels(GrDirectContext* dContext, GrSurfaceProxyView view, GrColorType colorType,
                         const char* filename) {
     if (!view.proxy()) {
         return false;
     }
 
-    SkImageInfo ii =
-            SkImageInfo::Make(view.proxy()->dimensions(), kRGBA_8888_SkColorType,
-                              kPremul_SkAlphaType);
+    auto ii = SkImageInfo::Make(view.proxy()->dimensions(), kRGBA_8888_SkColorType,
+                                kPremul_SkAlphaType);
     SkBitmap bm;
     if (!bm.tryAllocPixels(ii)) {
         return false;
     }
 
-    auto sContext = GrSurfaceContext::Make(context, std::move(view), colorType,
+    auto sContext = GrSurfaceContext::Make(dContext, std::move(view), colorType,
                                            kUnknown_SkAlphaType, nullptr);
     if (!sContext || !sContext->asTextureProxy()) {
         return false;
     }
 
-    bool result = sContext->readPixels(ii, bm.getPixels(), bm.rowBytes(), {0, 0});
+    bool result = sContext->readPixels(dContext, ii, bm.getPixels(), bm.rowBytes(), {0, 0});
     if (!result) {
         SkDebugf("------ failed to read pixels for %s\n", filename);
         return false;
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp
index 532ffa4..18dc428 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -126,14 +126,21 @@
                                               SkFilterQuality rescaleQuality,
                                               ReadPixelsCallback callback,
                                               ReadPixelsContext context) {
+    auto dContext = fContext->asDirectContext();
+    if (!dContext) {
+        // DDL TODO: buffer up the readback so it occurs when the DDL is drawn?
+        callback(context, nullptr);
+        return;
+    }
     GrColorType ct = SkColorTypeToGrColorType(this->colorType());
-    auto ctx = GrSurfaceContext::Make(fContext.get(), fView, ct, this->alphaType(),
+    auto ctx = GrSurfaceContext::Make(dContext, fView, ct, this->alphaType(),
                                       this->refColorSpace());
     if (!ctx) {
         callback(context, nullptr);
         return;
     }
-    ctx->asyncRescaleAndReadPixels(info, srcRect, rescaleGamma, rescaleQuality, callback, context);
+    ctx->asyncRescaleAndReadPixels(dContext, info, srcRect, rescaleGamma, rescaleQuality,
+                                   callback, context);
 }
 
 void SkImage_Gpu::onAsyncRescaleAndReadPixelsYUV420(SkYUVColorSpace yuvColorSpace,
@@ -144,14 +151,21 @@
                                                     SkFilterQuality rescaleQuality,
                                                     ReadPixelsCallback callback,
                                                     ReadPixelsContext context) {
+    auto dContext = fContext->asDirectContext();
+    if (!dContext) {
+        // DDL TODO: buffer up the readback so it occurs when the DDL is drawn?
+        callback(context, nullptr);
+        return;
+    }
     GrColorType ct = SkColorTypeToGrColorType(this->colorType());
-    auto ctx = GrSurfaceContext::Make(fContext.get(), fView, ct, this->alphaType(),
+    auto ctx = GrSurfaceContext::Make(dContext, fView, ct, this->alphaType(),
                                       this->refColorSpace());
     if (!ctx) {
         callback(context, nullptr);
         return;
     }
-    ctx->asyncRescaleAndReadPixelsYUV420(yuvColorSpace,
+    ctx->asyncRescaleAndReadPixelsYUV420(dContext,
+                                         yuvColorSpace,
                                          std::move(dstColorSpace),
                                          srcRect,
                                          dstSize,
@@ -665,13 +679,13 @@
         return nullptr;
     }
 
-    auto direct = GrAsDirectContext(context);
-    if (!direct) {
+    auto dContext = GrAsDirectContext(context);
+    if (!dContext) {
         SkDebugf("Direct context required\n");
         return nullptr;
     }
 
-    GrBackendFormat backendFormat = GrAHardwareBufferUtils::GetBackendFormat(direct,
+    GrBackendFormat backendFormat = GrAHardwareBufferUtils::GetBackendFormat(dContext,
                                                                              hardwareBuffer,
                                                                              bufferDesc.format,
                                                                              true);
@@ -685,7 +699,7 @@
     GrAHardwareBufferUtils::TexImageCtx deleteImageCtx = nullptr;
 
     GrBackendTexture backendTexture =
-            GrAHardwareBufferUtils::MakeBackendTexture(direct, hardwareBuffer,
+            GrAHardwareBufferUtils::MakeBackendTexture(dContext, hardwareBuffer,
                                                        bufferDesc.width, bufferDesc.height,
                                                        &deleteImageProc, &updateImageProc,
                                                        &deleteImageCtx, false, backendFormat, true);
@@ -702,7 +716,7 @@
 
     GrColorType grColorType = SkColorTypeToGrColorType(colorType);
 
-    GrProxyProvider* proxyProvider = direct->priv().proxyProvider();
+    GrProxyProvider* proxyProvider = dContext->priv().proxyProvider();
     if (!proxyProvider) {
         return nullptr;
     }
@@ -717,26 +731,26 @@
     sk_sp<SkColorSpace> cs = pixmap.refColorSpace();
     SkAlphaType at =  pixmap.alphaType();
 
-    GrSwizzle swizzle = direct->priv().caps()->getReadSwizzle(backendFormat, grColorType);
+    GrSwizzle swizzle = dContext->priv().caps()->getReadSwizzle(backendFormat, grColorType);
     GrSurfaceProxyView view(std::move(proxy), surfaceOrigin, swizzle);
-    sk_sp<SkImage> image = sk_make_sp<SkImage_Gpu>(sk_ref_sp(direct), kNeedNewImageUniqueID, view,
+    sk_sp<SkImage> image = sk_make_sp<SkImage_Gpu>(sk_ref_sp(dContext), kNeedNewImageUniqueID, view,
                                                    colorType, at, cs);
     if (!image) {
         return nullptr;
     }
 
-    GrDrawingManager* drawingManager = direct->priv().drawingManager();
+    GrDrawingManager* drawingManager = dContext->priv().drawingManager();
     if (!drawingManager) {
         return nullptr;
     }
 
-    GrSurfaceContext surfaceContext(direct, std::move(view),
+    GrSurfaceContext surfaceContext(dContext, std::move(view),
                                     SkColorTypeToGrColorType(pixmap.colorType()),
                                     pixmap.alphaType(), cs);
 
     SkImageInfo srcInfo = SkImageInfo::Make(bufferDesc.width, bufferDesc.height, colorType, at,
                                             std::move(cs));
-    surfaceContext.writePixels(srcInfo, pixmap.addr(0, 0), pixmap.rowBytes(), {0, 0});
+    surfaceContext.writePixels(dContext, srcInfo, pixmap.addr(0, 0), pixmap.rowBytes(), {0, 0});
 
     GrSurfaceProxy* p[1] = {surfaceContext.asSurfaceProxy()};
     drawingManager->flush(p, 1, SkSurface::BackendSurfaceAccess::kNoAccess, {}, nullptr);
diff --git a/src/image/SkImage_GpuBase.cpp b/src/image/SkImage_GpuBase.cpp
index 8d545d4..95c4897 100644
--- a/src/image/SkImage_GpuBase.cpp
+++ b/src/image/SkImage_GpuBase.cpp
@@ -86,8 +86,8 @@
 //////////////////////////////////////////////////////////////////////////////////////////////////
 
 bool SkImage_GpuBase::getROPixels(SkBitmap* dst, CachingHint chint) const {
-    auto direct = fContext->asDirectContext();
-    if (!direct) {
+    auto dContext = fContext->asDirectContext();
+    if (!dContext) {
         // DDL TODO: buffer up the readback so it occurs when the DDL is drawn?
         return false;
     }
@@ -112,18 +112,19 @@
         }
     }
 
-    const GrSurfaceProxyView* view = this->view(direct);
+    const GrSurfaceProxyView* view = this->view(dContext);
     SkASSERT(view);
     GrColorType grColorType = SkColorTypeAndFormatToGrColorType(
             fContext->priv().caps(), this->colorType(), view->proxy()->backendFormat());
 
-    auto sContext = GrSurfaceContext::Make(direct, *view, grColorType, this->alphaType(),
+    auto sContext = GrSurfaceContext::Make(dContext, *view, grColorType, this->alphaType(),
                                            this->refColorSpace());
     if (!sContext) {
         return false;
     }
 
-    if (!sContext->readPixels(pmap.info(), pmap.writable_addr(), pmap.rowBytes(), {0, 0})) {
+    if (!sContext->readPixels(dContext, pmap.info(), pmap.writable_addr(), pmap.rowBytes(),
+                              {0, 0})) {
         return false;
     }
 
@@ -157,8 +158,8 @@
 
 bool SkImage_GpuBase::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRB,
                                    int srcX, int srcY, CachingHint) const {
-    auto direct = fContext->asDirectContext();
-    if (!direct) {
+    auto dContext = fContext->asDirectContext();
+    if (!dContext) {
         // DDL TODO: buffer up the readback so it occurs when the DDL is drawn?
         return false;
     }
@@ -167,18 +168,18 @@
         return false;
     }
 
-    const GrSurfaceProxyView* view = this->view(direct);
+    const GrSurfaceProxyView* view = this->view(dContext);
     SkASSERT(view);
     GrColorType grColorType = SkColorTypeAndFormatToGrColorType(
-            fContext->priv().caps(), this->colorType(), view->proxy()->backendFormat());
+            dContext->priv().caps(), this->colorType(), view->proxy()->backendFormat());
 
-    auto sContext = GrSurfaceContext::Make(direct, *view, grColorType, this->alphaType(),
+    auto sContext = GrSurfaceContext::Make(dContext, *view, grColorType, this->alphaType(),
                                            this->refColorSpace());
     if (!sContext) {
         return false;
     }
 
-    return sContext->readPixels(dstInfo, dstPixels, dstRB, {srcX, srcY});
+    return sContext->readPixels(dContext, dstInfo, dstPixels, dstRB, {srcX, srcY});
 }
 
 GrSurfaceProxyView SkImage_GpuBase::refView(GrRecordingContext* context,
diff --git a/src/image/SkSurface_Gpu.cpp b/src/image/SkSurface_Gpu.cpp
index 2a36fc0..f95ff0e 100644
--- a/src/image/SkSurface_Gpu.cpp
+++ b/src/image/SkSurface_Gpu.cpp
@@ -148,7 +148,13 @@
                                                 ReadPixelsCallback callback,
                                                 ReadPixelsContext context) {
     auto* rtc = this->fDevice->accessRenderTargetContext();
-    rtc->asyncRescaleAndReadPixels(info, srcRect, rescaleGamma, rescaleQuality, callback, context);
+    // Context TODO: Elevate direct context requirement to public API.
+    auto dContext = rtc->priv().recordingContext()->asDirectContext();
+    if (!dContext) {
+        return;
+    }
+    rtc->asyncRescaleAndReadPixels(dContext, info, srcRect, rescaleGamma, rescaleQuality,
+                                   callback, context);
 }
 
 void SkSurface_Gpu::onAsyncRescaleAndReadPixelsYUV420(SkYUVColorSpace yuvColorSpace,
@@ -160,7 +166,13 @@
                                                       ReadPixelsCallback callback,
                                                       ReadPixelsContext context) {
     auto* rtc = this->fDevice->accessRenderTargetContext();
-    rtc->asyncRescaleAndReadPixelsYUV420(yuvColorSpace,
+    // Context TODO: Elevate direct context requirement to public API.
+    auto dContext = rtc->priv().recordingContext()->asDirectContext();
+    if (!dContext) {
+        return;
+    }
+    rtc->asyncRescaleAndReadPixelsYUV420(dContext,
+                                         yuvColorSpace,
                                          std::move(dstColorSpace),
                                          srcRect,
                                          dstSize,
diff --git a/tests/ClearTest.cpp b/tests/ClearTest.cpp
index 9b171fd..4cfd4f3 100644
--- a/tests/ClearTest.cpp
+++ b/tests/ClearTest.cpp
@@ -29,8 +29,8 @@
 #include <cstdint>
 #include <memory>
 
-static bool check_rect(GrRenderTargetContext* rtc, const SkIRect& rect, uint32_t expectedValue,
-                       uint32_t* actualValue, int* failX, int* failY) {
+static bool check_rect(GrDirectContext* dContext, GrRenderTargetContext* rtc, const SkIRect& rect,
+                       uint32_t expectedValue, uint32_t* actualValue, int* failX, int* failY) {
     int w = rect.width();
     int h = rect.height();
 
@@ -40,7 +40,7 @@
     readback.alloc(dstInfo);
 
     readback.erase(~expectedValue);
-    if (!rtc->readPixels(readback.info(), readback.writable_addr(), readback.rowBytes(),
+    if (!rtc->readPixels(dContext, readback.info(), readback.writable_addr(), readback.rowBytes(),
                          {rect.fLeft, rect.fTop})) {
         return false;
     }
@@ -64,7 +64,7 @@
             rContext, GrColorType::kRGBA_8888, nullptr, SkBackingFit::kExact, {w, h});
 }
 
-static void clear_op_test(skiatest::Reporter* reporter, GrRecordingContext* rContext) {
+static void clear_op_test(skiatest::Reporter* reporter, GrDirectContext* dContext) {
     static const int kW = 10;
     static const int kH = 10;
 
@@ -95,90 +95,94 @@
     static const SkPMColor4f kColor1f = SkPMColor4f::FromBytes_RGBA(kColor1);
     static const SkPMColor4f kColor2f = SkPMColor4f::FromBytes_RGBA(kColor2);
 
-    rtContext = newRTC(rContext, kW, kH);
+    rtContext = newRTC(dContext, kW, kH);
     SkASSERT(rtContext);
 
     // Check a full clear
     rtContext->clear(fullRect, kColor1f);
-    if (!check_rect(rtContext.get(), fullRect, kColor1, &actualValue, &failX, &failY)) {
+    if (!check_rect(dContext, rtContext.get(), fullRect, kColor1, &actualValue, &failX, &failY)) {
         ERRORF(reporter, "Expected 0x%08x but got 0x%08x at (%d, %d).", kColor1, actualValue,
                failX, failY);
     }
 
-    rtContext = newRTC(rContext, kW, kH);
+    rtContext = newRTC(dContext, kW, kH);
     SkASSERT(rtContext);
 
     // Check two full clears, same color
     rtContext->clear(fullRect, kColor1f);
     rtContext->clear(fullRect, kColor1f);
-    if (!check_rect(rtContext.get(), fullRect, kColor1, &actualValue, &failX, &failY)) {
+    if (!check_rect(dContext, rtContext.get(), fullRect, kColor1, &actualValue, &failX, &failY)) {
         ERRORF(reporter, "Expected 0x%08x but got 0x%08x at (%d, %d).", kColor1, actualValue,
                failX, failY);
     }
 
-    rtContext = newRTC(rContext, kW, kH);
+    rtContext = newRTC(dContext, kW, kH);
     SkASSERT(rtContext);
 
     // Check two full clears, different colors
     rtContext->clear(fullRect, kColor1f);
     rtContext->clear(fullRect, kColor2f);
-    if (!check_rect(rtContext.get(), fullRect, kColor2, &actualValue, &failX, &failY)) {
+    if (!check_rect(dContext, rtContext.get(), fullRect, kColor2, &actualValue, &failX, &failY)) {
         ERRORF(reporter, "Expected 0x%08x but got 0x%08x at (%d, %d).", kColor2, actualValue,
                failX, failY);
     }
 
-    rtContext = newRTC(rContext, kW, kH);
+    rtContext = newRTC(dContext, kW, kH);
     SkASSERT(rtContext);
 
     // Test a full clear followed by a same color inset clear
     rtContext->clear(fullRect, kColor1f);
     rtContext->clear(mid1Rect, kColor1f);
-    if (!check_rect(rtContext.get(), fullRect, kColor1, &actualValue, &failX, &failY)) {
+    if (!check_rect(dContext, rtContext.get(), fullRect, kColor1, &actualValue, &failX, &failY)) {
         ERRORF(reporter, "Expected 0x%08x but got 0x%08x at (%d, %d).", kColor1, actualValue,
                failX, failY);
     }
 
-    rtContext = newRTC(rContext, kW, kH);
+    rtContext = newRTC(dContext, kW, kH);
     SkASSERT(rtContext);
 
     // Test a inset clear followed by same color full clear
     rtContext->clear(mid1Rect, kColor1f);
     rtContext->clear(fullRect, kColor1f);
-    if (!check_rect(rtContext.get(), fullRect, kColor1, &actualValue, &failX, &failY)) {
+    if (!check_rect(dContext, rtContext.get(), fullRect, kColor1, &actualValue, &failX, &failY)) {
         ERRORF(reporter, "Expected 0x%08x but got 0x%08x at (%d, %d).", kColor1, actualValue,
                failX, failY);
     }
 
-    rtContext = newRTC(rContext, kW, kH);
+    rtContext = newRTC(dContext, kW, kH);
     SkASSERT(rtContext);
 
     // Test a full clear followed by a different color inset clear
     rtContext->clear(fullRect, kColor1f);
     rtContext->clear(mid1Rect, kColor2f);
-    if (!check_rect(rtContext.get(), mid1Rect, kColor2, &actualValue, &failX, &failY)) {
+    if (!check_rect(dContext, rtContext.get(), mid1Rect, kColor2, &actualValue, &failX, &failY)) {
         ERRORF(reporter, "Expected 0x%08x but got 0x%08x at (%d, %d).", kColor2, actualValue,
                failX, failY);
     }
-    if (!check_rect(rtContext.get(), outerLeftEdge, kColor1, &actualValue, &failX, &failY) ||
-        !check_rect(rtContext.get(), outerTopEdge, kColor1, &actualValue, &failX, &failY) ||
-        !check_rect(rtContext.get(), outerRightEdge, kColor1, &actualValue, &failX, &failY) ||
-        !check_rect(rtContext.get(), outerBottomEdge, kColor1, &actualValue, &failX, &failY)) {
+    if (!check_rect(
+            dContext, rtContext.get(), outerLeftEdge, kColor1, &actualValue, &failX, &failY) ||
+        !check_rect(
+            dContext, rtContext.get(), outerTopEdge, kColor1, &actualValue, &failX, &failY) ||
+        !check_rect(
+            dContext, rtContext.get(), outerRightEdge, kColor1, &actualValue, &failX, &failY) ||
+        !check_rect(
+            dContext, rtContext.get(), outerBottomEdge, kColor1, &actualValue, &failX, &failY)) {
         ERRORF(reporter, "Expected 0x%08x but got 0x%08x at (%d, %d).", kColor1, actualValue,
                failX, failY);
     }
 
-    rtContext = newRTC(rContext, kW, kH);
+    rtContext = newRTC(dContext, kW, kH);
     SkASSERT(rtContext);
 
     // Test a inset clear followed by a different full clear
     rtContext->clear(mid1Rect, kColor2f);
     rtContext->clear(fullRect, kColor1f);
-    if (!check_rect(rtContext.get(), fullRect, kColor1, &actualValue, &failX, &failY)) {
+    if (!check_rect(dContext, rtContext.get(), fullRect, kColor1, &actualValue, &failX, &failY)) {
         ERRORF(reporter, "Expected 0x%08x but got 0x%08x at (%d, %d).", kColor1, actualValue,
                failX, failY);
     }
 
-    rtContext = newRTC(rContext, kW, kH);
+    rtContext = newRTC(dContext, kW, kH);
     SkASSERT(rtContext);
 
     // Check three nested clears from largest to smallest where outermost and innermost are same
@@ -186,40 +190,52 @@
     rtContext->clear(fullRect, kColor1f);
     rtContext->clear(mid1Rect, kColor2f);
     rtContext->clear(mid2Rect, kColor1f);
-    if (!check_rect(rtContext.get(), mid2Rect, kColor1, &actualValue, &failX, &failY)) {
+    if (!check_rect(dContext, rtContext.get(), mid2Rect, kColor1, &actualValue, &failX, &failY)) {
         ERRORF(reporter, "Expected 0x%08x but got 0x%08x at (%d, %d).", kColor1, actualValue,
                failX, failY);
     }
-    if (!check_rect(rtContext.get(), innerLeftEdge, kColor2, &actualValue, &failX, &failY) ||
-        !check_rect(rtContext.get(), innerTopEdge, kColor2, &actualValue, &failX, &failY) ||
-        !check_rect(rtContext.get(), innerRightEdge, kColor2, &actualValue, &failX, &failY) ||
-        !check_rect(rtContext.get(), innerBottomEdge, kColor2, &actualValue, &failX, &failY)) {
+    if (!check_rect(
+            dContext, rtContext.get(), innerLeftEdge, kColor2, &actualValue, &failX, &failY) ||
+        !check_rect(
+            dContext, rtContext.get(), innerTopEdge, kColor2, &actualValue, &failX, &failY) ||
+        !check_rect(
+            dContext, rtContext.get(), innerRightEdge, kColor2, &actualValue, &failX, &failY) ||
+        !check_rect(
+            dContext, rtContext.get(), innerBottomEdge, kColor2, &actualValue, &failX, &failY)) {
         ERRORF(reporter, "Expected 0x%08x but got 0x%08x at (%d, %d).", kColor2, actualValue,
                failX, failY);
     }
-    if (!check_rect(rtContext.get(), outerLeftEdge, kColor1, &actualValue, &failX, &failY) ||
-        !check_rect(rtContext.get(), outerTopEdge, kColor1, &actualValue, &failX, &failY) ||
-        !check_rect(rtContext.get(), outerRightEdge, kColor1, &actualValue, &failX, &failY) ||
-        !check_rect(rtContext.get(), outerBottomEdge, kColor1, &actualValue, &failX, &failY)) {
+    if (!check_rect(
+            dContext, rtContext.get(), outerLeftEdge, kColor1, &actualValue, &failX, &failY) ||
+        !check_rect(
+            dContext, rtContext.get(), outerTopEdge, kColor1, &actualValue, &failX, &failY) ||
+        !check_rect(
+            dContext, rtContext.get(), outerRightEdge, kColor1, &actualValue, &failX, &failY) ||
+        !check_rect(
+            dContext, rtContext.get(), outerBottomEdge, kColor1, &actualValue, &failX, &failY)) {
         ERRORF(reporter, "Expected 0x%08x but got 0x%08x at (%d, %d).", kColor1, actualValue,
                failX, failY);
     }
 
-    rtContext = newRTC(rContext, kW, kH);
+    rtContext = newRTC(dContext, kW, kH);
     SkASSERT(rtContext);
 
     // Swap the order of the second two clears in the above test.
     rtContext->clear(fullRect, kColor1f);
     rtContext->clear(mid2Rect, kColor1f);
     rtContext->clear(mid1Rect, kColor2f);
-    if (!check_rect(rtContext.get(), mid1Rect, kColor2, &actualValue, &failX, &failY)) {
+    if (!check_rect(dContext, rtContext.get(), mid1Rect, kColor2, &actualValue, &failX, &failY)) {
         ERRORF(reporter, "Expected 0x%08x but got 0x%08x at (%d, %d).", kColor2, actualValue,
                failX, failY);
     }
-    if (!check_rect(rtContext.get(), outerLeftEdge, kColor1, &actualValue, &failX, &failY) ||
-        !check_rect(rtContext.get(), outerTopEdge, kColor1, &actualValue, &failX, &failY) ||
-        !check_rect(rtContext.get(), outerRightEdge, kColor1, &actualValue, &failX, &failY) ||
-        !check_rect(rtContext.get(), outerBottomEdge, kColor1, &actualValue, &failX, &failY)) {
+    if (!check_rect(
+            dContext, rtContext.get(), outerLeftEdge, kColor1, &actualValue, &failX, &failY) ||
+        !check_rect(
+            dContext, rtContext.get(), outerTopEdge, kColor1, &actualValue, &failX, &failY) ||
+        !check_rect(
+            dContext, rtContext.get(), outerRightEdge, kColor1, &actualValue, &failX, &failY) ||
+        !check_rect(
+            dContext, rtContext.get(), outerBottomEdge, kColor1, &actualValue, &failX, &failY)) {
         ERRORF(reporter, "Expected 0x%08x but got 0x%08x at (%d, %d).", kColor1, actualValue,
                failX, failY);
     }
diff --git a/tests/CopySurfaceTest.cpp b/tests/CopySurfaceTest.cpp
index 58ca6cc..061893a 100644
--- a/tests/CopySurfaceTest.cpp
+++ b/tests/CopySurfaceTest.cpp
@@ -31,7 +31,7 @@
 #include <utility>
 
 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(CopySurface, reporter, ctxInfo) {
-    auto direct = ctxInfo.directContext();
+    auto dContext = ctxInfo.directContext();
 
     static const int kW = 10;
     static const int kH = 10;
@@ -79,10 +79,10 @@
                         for (const SkIPoint& dstPoint : kDstPoints) {
                             for (const SkImageInfo& ii: kImageInfos) {
                                 auto src = sk_gpu_test::MakeTextureProxyFromData(
-                                        direct, sRenderable, sOrigin, ii, srcPixels.get(),
+                                        dContext, sRenderable, sOrigin, ii, srcPixels.get(),
                                         kRowBytes);
                                 auto dst = sk_gpu_test::MakeTextureProxyFromData(
-                                        direct, dRenderable, dOrigin, ii, dstPixels.get(),
+                                        dContext, dRenderable, dOrigin, ii, dstPixels.get(),
                                         kRowBytes);
 
                                 // Should always work if the color type is RGBA, but may not work
@@ -94,7 +94,7 @@
                                         continue;
                                     }
                                 } else {
-                                    if (!direct->defaultBackendFormat(
+                                    if (!dContext->defaultBackendFormat(
                                             kBGRA_8888_SkColorType, GrRenderable::kNo).isValid()) {
                                         continue;
                                     }
@@ -106,10 +106,10 @@
                                 }
 
                                 GrColorType grColorType = SkColorTypeToGrColorType(ii.colorType());
-                                GrSwizzle dstSwizzle = direct->priv().caps()->getReadSwizzle(
+                                GrSwizzle dstSwizzle = dContext->priv().caps()->getReadSwizzle(
                                         dst->backendFormat(), grColorType);
                                 GrSurfaceProxyView dstView(std::move(dst), dOrigin, dstSwizzle);
-                                auto dstContext = GrSurfaceContext::Make(direct,
+                                auto dstContext = GrSurfaceContext::Make(dContext,
                                                                          std::move(dstView),
                                                                          grColorType,
                                                                          ii.alphaType(), nullptr);
@@ -119,7 +119,7 @@
                                     result = dstContext->testCopy(src.get(), srcRect, dstPoint);
                                 } else if (dRenderable == GrRenderable::kYes) {
                                     SkASSERT(dstContext->asRenderTargetContext());
-                                    GrSwizzle srcSwizzle = direct->priv().caps()->getReadSwizzle(
+                                    GrSwizzle srcSwizzle = dContext->priv().caps()->getReadSwizzle(
                                         src->backendFormat(), grColorType);
                                     GrSurfaceProxyView view(std::move(src), sOrigin, srcSwizzle);
                                     result = dstContext->asRenderTargetContext()->blitTexture(
@@ -168,7 +168,8 @@
                                 }
 
                                 sk_memset32(read.get(), 0, kW * kH);
-                                if (!dstContext->readPixels(ii, read.get(), kRowBytes, {0, 0})) {
+                                if (!dstContext->readPixels(
+                                        dContext, ii, read.get(), kRowBytes, {0, 0})) {
                                     ERRORF(reporter, "Error calling readPixels");
                                     continue;
                                 }
diff --git a/tests/DefaultPathRendererTest.cpp b/tests/DefaultPathRendererTest.cpp
index cef653b..5ca463b 100644
--- a/tests/DefaultPathRendererTest.cpp
+++ b/tests/DefaultPathRendererTest.cpp
@@ -39,14 +39,15 @@
     options->fGpuPathRenderers = GpuPathRenderers::kNone;
 }
 
-static SkBitmap read_back(GrRenderTargetContext* rtc, int width, int height) {
+static SkBitmap read_back(GrDirectContext* dContext, GrRenderTargetContext* rtc,
+                          int width, int height) {
 
     SkImageInfo dstII = SkImageInfo::MakeN32Premul(width, height);
 
     SkBitmap bm;
     bm.allocPixels(dstII);
 
-    rtc->readPixels(dstII, bm.getAddr(0, 0), bm.rowBytes(), {0, 0});
+    rtc->readPixels(dContext, dstII, bm.getAddr(0, 0), bm.rowBytes(), {0, 0});
 
     return bm;
 }
@@ -74,7 +75,7 @@
 // When the bug manifests the GrDefaultPathRenderer/GrMSAAPathRenderer is/was leaving the stencil
 // buffer outside of the first content rect in a bad state and the second draw would be incorrect.
 
-static void run_test(GrRecordingContext* rContext, skiatest::Reporter* reporter) {
+static void run_test(GrDirectContext* dContext, skiatest::Reporter* reporter) {
     SkPath invPath = make_path(SkRect::MakeXYWH(0, 0, kBigSize, kBigSize),
                                kBigSize/2-1, SkPathFillType::kInverseWinding);
     SkPath path = make_path(SkRect::MakeXYWH(0, 0, kBigSize, kBigSize),
@@ -84,7 +85,7 @@
 
     {
         auto rtc = GrRenderTargetContext::Make(
-            rContext, GrColorType::kRGBA_8888, nullptr, SkBackingFit::kApprox,
+            dContext, GrColorType::kRGBA_8888, nullptr, SkBackingFit::kApprox,
             {kBigSize/2 + 1, kBigSize/2 + 1});
 
         rtc->clear(SK_PMColor4fBLACK);
@@ -103,7 +104,7 @@
 
     {
         auto rtc = GrRenderTargetContext::Make(
-            rContext, GrColorType::kRGBA_8888, nullptr, SkBackingFit::kExact, {kBigSize, kBigSize});
+            dContext, GrColorType::kRGBA_8888, nullptr, SkBackingFit::kExact, {kBigSize, kBigSize});
 
         rtc->clear(SK_PMColor4fBLACK);
 
@@ -116,7 +117,7 @@
         rtc->drawPath(nullptr, std::move(paint), GrAA::kNo,
                       SkMatrix::I(), path, style);
 
-        SkBitmap bm = read_back(rtc.get(), kBigSize, kBigSize);
+        SkBitmap bm = read_back(dContext, rtc.get(), kBigSize, kBigSize);
 
         bool correct = true;
         for (int y = kBigSize/2+1; y < kBigSize-kPad-1 && correct; ++y) {
diff --git a/tests/EGLImageTest.cpp b/tests/EGLImageTest.cpp
index 1f16fb4..d1e75a8 100644
--- a/tests/EGLImageTest.cpp
+++ b/tests/EGLImageTest.cpp
@@ -82,7 +82,7 @@
 
     ///////////////////////////////// CONTEXT 1 ///////////////////////////////////
 
-    // Use GL Context 1 to create a texture unknown to the GrDirectContext.
+    // Use GL Context 1 to create a texture unknown to context 0.
     context1->flushAndSubmit();
     static const int kSize = 100;
 
@@ -196,10 +196,10 @@
         }
     }
 
-    TestReadPixels(reporter, surfaceContext.get(), pixels.get(), "EGLImageTest-read");
+    TestReadPixels(reporter, context0, surfaceContext.get(), pixels.get(), "EGLImageTest-read");
 
-    // We should not be able to write to a EXTERNAL texture
-    TestWritePixels(reporter, surfaceContext.get(), false, "EGLImageTest-write");
+    // We should not be able to write to an EXTERNAL texture
+    TestWritePixels(reporter, context0, surfaceContext.get(), false, "EGLImageTest-write");
 
     // Only test RT-config
     // TODO: why do we always need to draw to copy from an external texture?
diff --git a/tests/FloatingPointTextureTest.cpp b/tests/FloatingPointTextureTest.cpp
index 8ddaa70..0017c8f 100644
--- a/tests/FloatingPointTextureTest.cpp
+++ b/tests/FloatingPointTextureTest.cpp
@@ -28,7 +28,7 @@
 static const int DEV_W = 100, DEV_H = 100;
 
 template <typename T>
-void runFPTest(skiatest::Reporter* reporter, GrDirectContext* context,
+void runFPTest(skiatest::Reporter* reporter, GrDirectContext* dContext,
                T min, T max, T epsilon, T maxInt,
                int arraySize, GrColorType colorType) {
     if (0 != arraySize % 4) {
@@ -50,7 +50,7 @@
 
     for (auto origin : {kTopLeft_GrSurfaceOrigin, kBottomLeft_GrSurfaceOrigin}) {
         auto fpProxy = sk_gpu_test::MakeTextureProxyFromData(
-                context, GrRenderable::kYes, origin,
+                dContext, GrRenderable::kYes, origin,
                 {colorType, kPremul_SkAlphaType, nullptr, DEV_W, DEV_H},
                 controlPixelData.begin(), 0);
         // Floating point textures are NOT supported everywhere
@@ -58,15 +58,16 @@
             continue;
         }
 
-        GrSwizzle swizzle = context->priv().caps()->getReadSwizzle(fpProxy->backendFormat(),
-                                                                   colorType);
+        GrSwizzle swizzle = dContext->priv().caps()->getReadSwizzle(fpProxy->backendFormat(),
+                                                                    colorType);
         GrSurfaceProxyView view(std::move(fpProxy), origin, swizzle);
-        auto sContext = GrSurfaceContext::Make(context, std::move(view), colorType,
+        auto sContext = GrSurfaceContext::Make(dContext, std::move(view), colorType,
                                                kPremul_SkAlphaType, nullptr);
         REPORTER_ASSERT(reporter, sContext);
 
-        bool result = sContext->readPixels({colorType, kPremul_SkAlphaType, nullptr, DEV_W, DEV_H},
-                                           readBuffer.begin(), 0, {0, 0}, context);
+        bool result = sContext->readPixels(dContext,
+                                           {colorType, kPremul_SkAlphaType, nullptr, DEV_W, DEV_H},
+                                           readBuffer.begin(), 0, {0, 0});
         REPORTER_ASSERT(reporter, result);
         REPORTER_ASSERT(reporter,
                         0 == memcmp(readBuffer.begin(), controlPixelData.begin(), readBuffer.bytes()));
diff --git a/tests/GrMeshTest.cpp b/tests/GrMeshTest.cpp
index d860411..d0eb9a4 100644
--- a/tests/GrMeshTest.cpp
+++ b/tests/GrMeshTest.cpp
@@ -96,7 +96,7 @@
  * produce exact matches.
  */
 
-static void run_test(GrRecordingContext*, const char* testName, skiatest::Reporter*,
+static void run_test(GrDirectContext*, const char* testName, skiatest::Reporter*,
                      const std::unique_ptr<GrRenderTargetContext>&, const SkBitmap& gold,
                      std::function<void(DrawMeshHelper*)> prepareFn,
                      std::function<void(DrawMeshHelper*)> executeFn);
@@ -582,7 +582,7 @@
     return fState->opsRenderPass();
 }
 
-static void run_test(GrRecordingContext* rContext, const char* testName,
+static void run_test(GrDirectContext* dContext, const char* testName,
                      skiatest::Reporter* reporter,
                      const std::unique_ptr<GrRenderTargetContext>& rtc, const SkBitmap& gold,
                      std::function<void(DrawMeshHelper*)> prepareFn,
@@ -600,9 +600,9 @@
 
     SkAutoSTMalloc<kImageHeight * kImageWidth, uint32_t> resultPx(h * rowBytes);
     rtc->clear(SkPMColor4f::FromBytes_RGBA(0xbaaaaaad));
-    rtc->priv().testingOnly_addDrawOp(GrMeshTestOp::Make(rContext, prepareFn, executeFn));
+    rtc->priv().testingOnly_addDrawOp(GrMeshTestOp::Make(dContext, prepareFn, executeFn));
 
-    rtc->readPixels(gold.info(), resultPx, rowBytes, {0, 0});
+    rtc->readPixels(dContext, gold.info(), resultPx, rowBytes, {0, 0});
 
 #ifdef WRITE_PNG_CONTEXT_TYPE
 #define STRINGIFY(X) #X
diff --git a/tests/GrPipelineDynamicStateTest.cpp b/tests/GrPipelineDynamicStateTest.cpp
index 9aecbcf..db3c30f 100644
--- a/tests/GrPipelineDynamicStateTest.cpp
+++ b/tests/GrPipelineDynamicStateTest.cpp
@@ -184,11 +184,11 @@
 };
 
 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrPipelineDynamicStateTest, reporter, ctxInfo) {
-    auto context = ctxInfo.directContext();
-    GrResourceProvider* rp = context->priv().resourceProvider();
+    auto dContext = ctxInfo.directContext();
+    GrResourceProvider* rp = dContext->priv().resourceProvider();
 
     auto rtc = GrRenderTargetContext::Make(
-            context, GrColorType::kRGBA_8888, nullptr, SkBackingFit::kExact,
+            dContext, GrColorType::kRGBA_8888, nullptr, SkBackingFit::kExact,
             {kScreenSize, kScreenSize});
     if (!rtc) {
         ERRORF(reporter, "could not create render target context.");
@@ -230,10 +230,10 @@
     for (GrScissorTest scissorTest : {GrScissorTest::kEnabled, GrScissorTest::kDisabled}) {
         rtc->clear(SkPMColor4f::FromBytes_RGBA(0xbaaaaaad));
         rtc->priv().testingOnly_addDrawOp(
-            GrPipelineDynamicStateTestOp::Make(context, scissorTest, vbuff));
-        rtc->readPixels(SkImageInfo::Make(kScreenSize, kScreenSize,
-                                          kRGBA_8888_SkColorType, kPremul_SkAlphaType),
-                        resultPx, 4 * kScreenSize, {0, 0});
+            GrPipelineDynamicStateTestOp::Make(dContext, scissorTest, vbuff));
+        auto ii = SkImageInfo::Make(kScreenSize, kScreenSize,
+                                    kRGBA_8888_SkColorType, kPremul_SkAlphaType);
+        rtc->readPixels(dContext, ii, resultPx, 4 * kScreenSize, {0, 0});
         for (int y = 0; y < kScreenSize; ++y) {
             for (int x = 0; x < kScreenSize; ++x) {
                 int expectedColorIdx;
diff --git a/tests/GrSurfaceTest.cpp b/tests/GrSurfaceTest.cpp
index fc9bb63..198ff85 100644
--- a/tests/GrSurfaceTest.cpp
+++ b/tests/GrSurfaceTest.cpp
@@ -200,13 +200,13 @@
         if (!sk_gpu_test::GrContextFactory::IsRenderingContext(contextType)) {
             continue;
         }
-        auto context = factory.get(contextType);
-        if (!context) {
+        auto dContext = factory.get(contextType);
+        if (!dContext) {
             continue;
         }
 
-        GrProxyProvider* proxyProvider = context->priv().proxyProvider();
-        const GrCaps* caps = context->priv().caps();
+        GrProxyProvider* proxyProvider = dContext->priv().proxyProvider();
+        const GrCaps* caps = dContext->priv().caps();
 
         const std::vector<GrCaps::TestFormatColorTypeCombination>& combos =
                 caps->getTestingCombinations();
@@ -265,13 +265,14 @@
                                                                      combo.fColorType);
                             GrSurfaceProxyView view(std::move(proxy), kTopLeft_GrSurfaceOrigin,
                                                     swizzle);
-                            auto texCtx = GrSurfaceContext::Make(context, std::move(view),
+                            auto texCtx = GrSurfaceContext::Make(dContext, std::move(view),
                                                                  combo.fColorType,
                                                                  kPremul_SkAlphaType, nullptr);
 
                             readback.erase(kClearColor);
-                            if (texCtx->readPixels(readback.info(), readback.writable_addr(),
-                                                   readback.rowBytes(), {0, 0})) {
+                            if (texCtx->readPixels(
+                                    dContext, readback.info(), readback.writable_addr(),
+                                    readback.rowBytes(), {0, 0})) {
                                 for (int i = 0; i < kSize * kSize; ++i) {
                                     if (!checkColor(combo, readback.addr32()[i])) {
                                         break;
@@ -280,7 +281,7 @@
                             }
                         }
 
-                        context->priv().testingOnly_purgeAllUnlockedResources();
+                        dContext->priv().testingOnly_purgeAllUnlockedResources();
                     }
 
                     // Try creating the texture as a deferred proxy.
@@ -288,12 +289,12 @@
                         std::unique_ptr<GrSurfaceContext> surfCtx;
                         if (renderable == GrRenderable::kYes) {
                             surfCtx = GrRenderTargetContext::Make(
-                                    context, combo.fColorType, nullptr, fit,
+                                    dContext, combo.fColorType, nullptr, fit,
                                     {desc.fWidth, desc.fHeight}, 1, GrMipmapped::kNo,
                                     GrProtected::kNo, kTopLeft_GrSurfaceOrigin);
                         } else {
                             surfCtx = GrSurfaceContext::Make(
-                                    context, {desc.fWidth, desc.fHeight}, combo.fFormat,
+                                    dContext, {desc.fWidth, desc.fHeight}, combo.fFormat,
                                     GrRenderable::kNo, 1, GrMipmapped::kNo, GrProtected::kNo,
                                     kTopLeft_GrSurfaceOrigin, combo.fColorType,
                                     kUnknown_SkAlphaType, nullptr, fit, SkBudgeted::kYes);
@@ -303,7 +304,7 @@
                         }
 
                         readback.erase(kClearColor);
-                        if (surfCtx->readPixels(readback.info(), readback.writable_addr(),
+                        if (surfCtx->readPixels(dContext, readback.info(), readback.writable_addr(),
                                                 readback.rowBytes(), {0, 0})) {
                             for (int i = 0; i < kSize * kSize; ++i) {
                                 if (!checkColor(combo, readback.addr32()[i])) {
@@ -311,7 +312,7 @@
                                 }
                             }
                         }
-                        context->priv().testingOnly_purgeAllUnlockedResources();
+                        dContext->priv().testingOnly_purgeAllUnlockedResources();
                     }
                 }
             }
@@ -349,30 +350,30 @@
                     return (0xFFU << 24) | (x << 16) | (y << 8) | uint8_t((x * y) & 0xFF);
                });
 
-    auto context = context_info.directContext();
-    GrProxyProvider* proxyProvider = context->priv().proxyProvider();
+    auto dContext = context_info.directContext();
+    GrProxyProvider* proxyProvider = dContext->priv().proxyProvider();
 
     // We test both kRW in addition to kRead mostly to ensure that the calls are structured such
     // that they'd succeed if the texture wasn't kRead. We want to be sure we're failing with
     // kRead for the right reason.
     for (auto ioType : {kRead_GrIOType, kRW_GrIOType}) {
-        auto backendTex = context->createBackendTexture(&srcPixmap, 1,
-                                                        GrRenderable::kYes, GrProtected::kNo);
+        auto backendTex = dContext->createBackendTexture(&srcPixmap, 1,
+                                                         GrRenderable::kYes, GrProtected::kNo);
 
         auto proxy = proxyProvider->wrapBackendTexture(
                 backendTex, kBorrow_GrWrapOwnership, GrWrapCacheable::kNo, ioType);
-        GrSwizzle swizzle = context->priv().caps()->getReadSwizzle(proxy->backendFormat(),
-                                                                   GrColorType::kRGBA_8888);
+        GrSwizzle swizzle = dContext->priv().caps()->getReadSwizzle(proxy->backendFormat(),
+                                                                    GrColorType::kRGBA_8888);
         GrSurfaceProxyView view(proxy, kTopLeft_GrSurfaceOrigin, swizzle);
-        auto surfContext = GrSurfaceContext::Make(context, std::move(view), GrColorType::kRGBA_8888,
+        auto surfContext = GrSurfaceContext::Make(dContext, std::move(view), GrColorType::kRGBA_8888,
                                                   kPremul_SkAlphaType, nullptr);
 
         // Read pixels should work with a read-only texture.
         {
             SkAutoPixmapStorage read;
             read.alloc(srcPixmap.info());
-            auto readResult = surfContext->readPixels(srcPixmap.info(), read.writable_addr(),
-                                                      0, { 0, 0 });
+            auto readResult = surfContext->readPixels(dContext, srcPixmap.info(),
+                                                      read.writable_addr(), 0, { 0, 0 });
             REPORTER_ASSERT(reporter, readResult);
             if (readResult) {
                 comparePixels(srcPixmap, read, reporter);
@@ -383,11 +384,12 @@
         SkAutoPixmapStorage write;
         write.alloc(srcPixmap.info());
         fillPixels(&write, [&srcPixmap](int x, int y) { return ~*srcPixmap.addr32(); });
-        auto writeResult = surfContext->writePixels(srcPixmap.info(), write.addr(), 0, {0, 0});
+        auto writeResult = surfContext->writePixels(dContext, srcPixmap.info(), write.addr(),
+                                                    0, {0, 0});
         REPORTER_ASSERT(reporter, writeResult == (ioType == kRW_GrIOType));
         // Try the low level write.
-        context->flushAndSubmit();
-        auto gpuWriteResult = context->priv().getGpu()->writePixels(
+        dContext->flushAndSubmit();
+        auto gpuWriteResult = dContext->priv().getGpu()->writePixels(
                 proxy->peekTexture(), 0, 0, kSize, kSize, GrColorType::kRGBA_8888,
                 GrColorType::kRGBA_8888, write.addr32(),
                 kSize * GrColorTypeBytesPerPixel(GrColorType::kRGBA_8888));
@@ -397,7 +399,7 @@
         copySrcBitmap.installPixels(write);
         copySrcBitmap.setImmutable();
 
-        GrBitmapTextureMaker maker(context, copySrcBitmap,
+        GrBitmapTextureMaker maker(dContext, copySrcBitmap,
                                    GrImageTexGenPolicy::kNew_Uncached_Budgeted);
         auto copySrc = maker.view(GrMipmapped::kNo);
 
@@ -405,28 +407,28 @@
         auto copyResult = surfContext->testCopy(copySrc.proxy());
         REPORTER_ASSERT(reporter, copyResult == (ioType == kRW_GrIOType));
         // Try the low level copy.
-        context->flushAndSubmit();
-        auto gpuCopyResult = context->priv().getGpu()->copySurface(
+        dContext->flushAndSubmit();
+        auto gpuCopyResult = dContext->priv().getGpu()->copySurface(
                 proxy->peekSurface(), copySrc.proxy()->peekSurface(), SkIRect::MakeWH(kSize, kSize),
                 {0, 0});
         REPORTER_ASSERT(reporter, gpuCopyResult == (ioType == kRW_GrIOType));
 
         // Mip regen should not work with a read only texture.
-        if (context->priv().caps()->mipmapSupport()) {
-            DeleteBackendTexture(context, backendTex);
-            backendTex = context->createBackendTexture(
+        if (dContext->priv().caps()->mipmapSupport()) {
+            DeleteBackendTexture(dContext, backendTex);
+            backendTex = dContext->createBackendTexture(
                     kSize, kSize, kRGBA_8888_SkColorType,
                     SkColors::kTransparent, GrMipmapped::kYes, GrRenderable::kYes,
                     GrProtected::kNo);
             proxy = proxyProvider->wrapBackendTexture(backendTex, kBorrow_GrWrapOwnership,
                                                       GrWrapCacheable::kNo, ioType);
-            context->flushAndSubmit();
+            dContext->flushAndSubmit();
             proxy->peekTexture()->markMipmapsDirty();  // avoids assert in GrGpu.
             auto regenResult =
-                    context->priv().getGpu()->regenerateMipMapLevels(proxy->peekTexture());
+                    dContext->priv().getGpu()->regenerateMipMapLevels(proxy->peekTexture());
             REPORTER_ASSERT(reporter, regenResult == (ioType == kRW_GrIOType));
         }
-        DeleteBackendTexture(context, backendTex);
+        DeleteBackendTexture(dContext, backendTex);
     }
 }
 
diff --git a/tests/GrTestingBackendTextureUploadTest.cpp b/tests/GrTestingBackendTextureUploadTest.cpp
index c271861..5aa1c50 100644
--- a/tests/GrTestingBackendTextureUploadTest.cpp
+++ b/tests/GrTestingBackendTextureUploadTest.cpp
@@ -80,9 +80,10 @@
                                                  kPremul_SkAlphaType, nullptr);
     REPORTER_ASSERT(reporter, surfaceContext);
 
-    bool result = surfaceContext->readPixels({grCT, kPremul_SkAlphaType, nullptr, kWidth, kHeight},
+    bool result = surfaceContext->readPixels(dContext,
+                                             {grCT, kPremul_SkAlphaType, nullptr, kWidth, kHeight},
                                              actualPixels.writable_addr(), actualPixels.rowBytes(),
-                                             {0, 0}, dContext);
+                                             {0, 0});
 
     REPORTER_ASSERT(reporter, result);
     REPORTER_ASSERT(reporter,
diff --git a/tests/GrUploadPixelsTests.cpp b/tests/GrUploadPixelsTests.cpp
index a1294cd..e935d01 100644
--- a/tests/GrUploadPixelsTests.cpp
+++ b/tests/GrUploadPixelsTests.cpp
@@ -22,7 +22,7 @@
 
 using sk_gpu_test::GrContextFactory;
 
-void basic_texture_test(skiatest::Reporter* reporter, GrDirectContext* context, SkColorType ct,
+void basic_texture_test(skiatest::Reporter* reporter, GrDirectContext* dContext, SkColorType ct,
                         GrRenderable renderable) {
     const int kWidth = 16;
     const int kHeight = 16;
@@ -33,58 +33,58 @@
 
     auto grCT = SkColorTypeToGrColorType(ct);
     auto proxy = sk_gpu_test::MakeTextureProxyFromData(
-            context, renderable, kTopLeft_GrSurfaceOrigin,
+            dContext, renderable, kTopLeft_GrSurfaceOrigin,
             {grCT, kPremul_SkAlphaType, nullptr, kWidth, kHeight}, srcBuffer, 0);
     REPORTER_ASSERT(reporter, proxy);
     if (proxy) {
-        GrSwizzle swizzle = context->priv().caps()->getReadSwizzle(proxy->backendFormat(), grCT);
+        GrSwizzle swizzle = dContext->priv().caps()->getReadSwizzle(proxy->backendFormat(), grCT);
         GrSurfaceProxyView view(proxy, kTopLeft_GrSurfaceOrigin, swizzle);
-        auto sContext = GrSurfaceContext::Make(context, std::move(view), grCT, kPremul_SkAlphaType,
+        auto sContext = GrSurfaceContext::Make(dContext, std::move(view), grCT, kPremul_SkAlphaType,
                                                nullptr);
 
         SkImageInfo dstInfo = SkImageInfo::Make(kWidth, kHeight, ct, kPremul_SkAlphaType);
 
-        bool result = sContext->readPixels(dstInfo, dstBuffer, 0, {0, 0});
+        bool result = sContext->readPixels(dContext, dstInfo, dstBuffer, 0, {0, 0});
         REPORTER_ASSERT(reporter, result);
         REPORTER_ASSERT(reporter,
                         DoesFullBufferContainCorrectColor(srcBuffer, dstBuffer, kWidth, kHeight));
 
         dstInfo = SkImageInfo::Make(10, 2, ct, kPremul_SkAlphaType);
-        result = sContext->writePixels(dstInfo, srcBuffer, 0, {2, 10});
+        result = sContext->writePixels(dContext, dstInfo, srcBuffer, 0, {2, 10});
         REPORTER_ASSERT(reporter, result);
 
         memset(dstBuffer, 0, kWidth*kHeight*sizeof(GrColor));
 
-        result = sContext->readPixels(dstInfo, dstBuffer, 0, {2, 10});
+        result = sContext->readPixels(dContext, dstInfo, dstBuffer, 0, {2, 10});
         REPORTER_ASSERT(reporter, result);
 
         REPORTER_ASSERT(reporter, DoesFullBufferContainCorrectColor(srcBuffer, dstBuffer, 10, 2));
     }
 
     proxy = sk_gpu_test::MakeTextureProxyFromData(
-            context, renderable, kBottomLeft_GrSurfaceOrigin,
+            dContext, renderable, kBottomLeft_GrSurfaceOrigin,
             {grCT, kPremul_SkAlphaType, nullptr, kWidth, kHeight}, srcBuffer, 0);
     REPORTER_ASSERT(reporter, proxy);
     if (proxy) {
-        GrSwizzle swizzle = context->priv().caps()->getReadSwizzle(proxy->backendFormat(), grCT);
+        GrSwizzle swizzle = dContext->priv().caps()->getReadSwizzle(proxy->backendFormat(), grCT);
         GrSurfaceProxyView view(proxy, kBottomLeft_GrSurfaceOrigin, swizzle);
-        auto sContext = GrSurfaceContext::Make(context, std::move(view), grCT, kPremul_SkAlphaType,
+        auto sContext = GrSurfaceContext::Make(dContext, std::move(view), grCT, kPremul_SkAlphaType,
                                                nullptr);
 
         SkImageInfo dstInfo = SkImageInfo::Make(kWidth, kHeight, ct, kPremul_SkAlphaType);
 
-        bool result = sContext->readPixels(dstInfo, dstBuffer, 0, {0, 0});
+        bool result = sContext->readPixels(dContext, dstInfo, dstBuffer, 0, {0, 0});
         REPORTER_ASSERT(reporter, result);
         REPORTER_ASSERT(reporter,
                         DoesFullBufferContainCorrectColor(srcBuffer, dstBuffer, kWidth, kHeight));
 
         dstInfo = SkImageInfo::Make(4, 5, ct, kPremul_SkAlphaType);
-        result = sContext->writePixels(dstInfo, srcBuffer, 0, {5, 4});
+        result = sContext->writePixels(dContext, dstInfo, srcBuffer, 0, {5, 4});
         REPORTER_ASSERT(reporter, result);
 
         memset(dstBuffer, 0, kWidth*kHeight*sizeof(GrColor));
 
-        result = sContext->readPixels(dstInfo, dstBuffer, 0, {5, 4});
+        result = sContext->readPixels(dContext, dstInfo, dstBuffer, 0, {5, 4});
         REPORTER_ASSERT(reporter, result);
 
         REPORTER_ASSERT(reporter, DoesFullBufferContainCorrectColor(srcBuffer, dstBuffer, 4, 5));
diff --git a/tests/OnFlushCallbackTest.cpp b/tests/OnFlushCallbackTest.cpp
index 70f44db..568e5f2 100644
--- a/tests/OnFlushCallbackTest.cpp
+++ b/tests/OnFlushCallbackTest.cpp
@@ -564,17 +564,17 @@
 DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(OnFlushCallbackTest, reporter, ctxInfo) {
     static const int kNumViews = 3;
 
-    auto context = ctxInfo.directContext();
-    auto proxyProvider = context->priv().proxyProvider();
+    auto dContext = ctxInfo.directContext();
+    auto proxyProvider = dContext->priv().proxyProvider();
 
     AtlasObject object(reporter);
 
-    context->priv().addOnFlushCallbackObject(&object);
+    dContext->priv().addOnFlushCallbackObject(&object);
 
     GrSurfaceProxyView views[kNumViews];
     for (int i = 0; i < kNumViews; ++i) {
-        views[i] = make_upstream_image(context, &object, i * 3,
-                                       object.getAtlasView(proxyProvider, context->priv().caps()),
+        views[i] = make_upstream_image(dContext, &object, i * 3,
+                                       object.getAtlasView(proxyProvider, dContext->priv().caps()),
                                        kPremul_SkAlphaType);
     }
 
@@ -582,7 +582,7 @@
     static const int kFinalHeight = kDrawnTileSize;
 
     auto rtc = GrRenderTargetContext::Make(
-            context, GrColorType::kRGBA_8888, nullptr, SkBackingFit::kApprox,
+            dContext, GrColorType::kRGBA_8888, nullptr, SkBackingFit::kApprox,
             {kFinalWidth, kFinalHeight});
 
     rtc->clear(SK_PMColor4fWHITE);
@@ -606,11 +606,10 @@
     SkBitmap readBack;
     readBack.allocN32Pixels(kFinalWidth, kFinalHeight);
 
-    SkDEBUGCODE(bool result =) rtc->readPixels(readBack.info(), readBack.getPixels(),
-                                               readBack.rowBytes(), {0, 0});
-    SkASSERT(result);
+    SkAssertResult(rtc->readPixels(dContext, readBack.info(), readBack.getPixels(),
+                                   readBack.rowBytes(), {0, 0}));
 
-    context->priv().testingOnly_flushAndRemoveOnFlushCallbackObject(&object);
+    dContext->priv().testingOnly_flushAndRemoveOnFlushCallbackObject(&object);
 
     object.markAsDone();
 
diff --git a/tests/PackedConfigsTextureTest.cpp b/tests/PackedConfigsTextureTest.cpp
index cde1121..5530656 100644
--- a/tests/PackedConfigsTextureTest.cpp
+++ b/tests/PackedConfigsTextureTest.cpp
@@ -97,7 +97,7 @@
     }
 }
 
-static void run_test(skiatest::Reporter* reporter, GrDirectContext* context, int arraySize,
+static void run_test(skiatest::Reporter* reporter, GrDirectContext* dContext, int arraySize,
                      SkColorType colorType) {
     SkTDArray<uint16_t> controlPixelData;
     // We will read back into an 8888 buffer since 565/4444 read backs aren't supported
@@ -116,21 +116,21 @@
     for (auto origin : { kTopLeft_GrSurfaceOrigin, kBottomLeft_GrSurfaceOrigin }) {
         auto grColorType = SkColorTypeToGrColorType(colorType);
         auto proxy = sk_gpu_test::MakeTextureProxyFromData(
-                context, GrRenderable::kNo, origin,
+                dContext, GrRenderable::kNo, origin,
                 {grColorType, kPremul_SkAlphaType, nullptr, DEV_W, DEV_H},
                 controlPixelData.begin(), 0);
         SkASSERT(proxy);
 
-        GrSwizzle readSwizzle = context->priv().caps()->getReadSwizzle(proxy->backendFormat(),
-                                                                       grColorType);
+        GrSwizzle readSwizzle = dContext->priv().caps()->getReadSwizzle(proxy->backendFormat(),
+                                                                        grColorType);
 
         GrSurfaceProxyView view(std::move(proxy), origin, readSwizzle);
-        GrSurfaceContext sContext(context, std::move(view), grColorType, kPremul_SkAlphaType,
+        GrSurfaceContext sContext(dContext, std::move(view), grColorType, kPremul_SkAlphaType,
                                   nullptr);
 
-        if (!sContext.readPixels(dstInfo, readBuffer.begin(), 0, {0, 0})) {
+        if (!sContext.readPixels(dContext, dstInfo, readBuffer.begin(), 0, {0, 0})) {
             // We only require this to succeed if the format is renderable.
-            REPORTER_ASSERT(reporter, !context->colorTypeSupportedAsSurface(colorType));
+            REPORTER_ASSERT(reporter, !dContext->colorTypeSupportedAsSurface(colorType));
             return;
         }
 
diff --git a/tests/ProcessorTest.cpp b/tests/ProcessorTest.cpp
index 65398b3..f928618 100644
--- a/tests/ProcessorTest.cpp
+++ b/tests/ProcessorTest.cpp
@@ -239,13 +239,13 @@
 }
 
 // The output buffer must be the same size as the render-target context.
-void render_fp(GrRecordingContext* rContext,
+void render_fp(GrDirectContext* dContext,
                GrRenderTargetContext* rtc,
                std::unique_ptr<GrFragmentProcessor> fp,
                GrColor* outBuffer) {
-    test_draw_op(rContext, rtc, std::move(fp));
+    test_draw_op(dContext, rtc, std::move(fp));
     std::fill_n(outBuffer, rtc->width() * rtc->height(), 0);
-    rtc->readPixels(SkImageInfo::Make(rtc->width(), rtc->height(), kRGBA_8888_SkColorType,
+    rtc->readPixels(dContext, SkImageInfo::Make(rtc->width(), rtc->height(), kRGBA_8888_SkColorType,
                                       kPremul_SkAlphaType),
                     outBuffer, /*rowBytes=*/0, /*srcPt=*/{0, 0});
 }
@@ -401,15 +401,15 @@
     return BipmapToBase64DataURI(bmp, dst);
 }
 
-bool log_texture_view(GrRecordingContext* rContext, GrSurfaceProxyView src, SkString* dst) {
+bool log_texture_view(GrDirectContext* dContext, GrSurfaceProxyView src, SkString* dst) {
     SkImageInfo ii = SkImageInfo::Make(src.proxy()->dimensions(), kRGBA_8888_SkColorType,
                                        kLogAlphaType);
 
-    auto sContext = GrSurfaceContext::Make(rContext, std::move(src), GrColorType::kRGBA_8888,
+    auto sContext = GrSurfaceContext::Make(dContext, std::move(src), GrColorType::kRGBA_8888,
                                            kLogAlphaType, nullptr);
     SkBitmap bm;
     SkAssertResult(bm.tryAllocPixels(ii));
-    SkAssertResult(sContext->readPixels(ii, bm.getPixels(), bm.rowBytes(), {0, 0}));
+    SkAssertResult(sContext->readPixels(dContext, ii, bm.getPixels(), bm.rowBytes(), {0, 0}));
     return BipmapToBase64DataURI(bm, dst);
 }
 
diff --git a/tests/ReadPixelsTest.cpp b/tests/ReadPixelsTest.cpp
index 490edac..74e13da 100644
--- a/tests/ReadPixelsTest.cpp
+++ b/tests/ReadPixelsTest.cpp
@@ -387,6 +387,7 @@
 }
 
 static void test_readpixels_texture(skiatest::Reporter* reporter,
+                                    GrDirectContext* dContext,
                                     std::unique_ptr<GrSurfaceContext> sContext,
                                     const SkImageInfo& surfaceInfo) {
     for (size_t rect = 0; rect < SK_ARRAY_COUNT(gReadPixelsTestRects); ++rect) {
@@ -403,7 +404,8 @@
                 // Try doing the read directly from a non-renderable texture
                 if (startsWithPixels) {
                     fill_dst_bmp_with_init_data(&bmp);
-                    bool success = sContext->readPixels(bmp.info(), bmp.getPixels(), bmp.rowBytes(),
+                    bool success = sContext->readPixels(dContext, bmp.info(), bmp.getPixels(),
+                                                        bmp.rowBytes(),
                                                         {srcRect.fLeft, srcRect.fTop});
                     auto expectSuccess = read_should_succeed(srcRect, bmp.info(), surfaceInfo);
                     REPORTER_ASSERT(
@@ -422,7 +424,7 @@
 }
 
 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadPixels_Texture, reporter, ctxInfo) {
-    auto direct = ctxInfo.directContext();
+    auto dContext = ctxInfo.directContext();
 
     SkBitmap bmp = make_src_bitmap();
 
@@ -430,15 +432,15 @@
     for (auto origin : {kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin}) {
         for (auto renderable : {GrRenderable::kNo, GrRenderable::kYes}) {
             sk_sp<GrTextureProxy> proxy = sk_gpu_test::MakeTextureProxyFromData(
-                    direct, renderable, origin, bmp.info(), bmp.getPixels(), bmp.rowBytes());
+                    dContext, renderable, origin, bmp.info(), bmp.getPixels(), bmp.rowBytes());
             GrColorType grColorType = SkColorTypeToGrColorType(bmp.colorType());
-            GrSwizzle swizzle = direct->priv().caps()->getReadSwizzle(proxy->backendFormat(),
+            GrSwizzle swizzle = dContext->priv().caps()->getReadSwizzle(proxy->backendFormat(),
                                                                        grColorType);
             GrSurfaceProxyView view(std::move(proxy), origin, swizzle);
-            auto sContext = GrSurfaceContext::Make(direct, std::move(view),
+            auto sContext = GrSurfaceContext::Make(dContext, std::move(view),
                     grColorType, kPremul_SkAlphaType, nullptr);
             auto info = SkImageInfo::Make(DEV_W, DEV_H, kN32_SkColorType, kPremul_SkAlphaType);
-            test_readpixels_texture(reporter, std::move(sContext), info);
+            test_readpixels_texture(reporter, dContext, std::move(sContext), info);
         }
     }
 }
diff --git a/tests/ReadWriteAlphaTest.cpp b/tests/ReadWriteAlphaTest.cpp
index eefa28a..1f4fd02 100644
--- a/tests/ReadWriteAlphaTest.cpp
+++ b/tests/ReadWriteAlphaTest.cpp
@@ -48,7 +48,7 @@
 }
 
 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadWriteAlpha, reporter, ctxInfo) {
-    auto direct = ctxInfo.directContext();
+    auto dContext = ctxInfo.directContext();
 
     unsigned char alphaData[X_SIZE * Y_SIZE];
 
@@ -67,17 +67,17 @@
         SkBitmap bitmap;
         bitmap.installPixels(ii, alphaDataCopy, ii.minRowBytes());
         bitmap.setImmutable();
-        GrBitmapTextureMaker maker(direct, bitmap, GrImageTexGenPolicy::kNew_Uncached_Budgeted);
+        GrBitmapTextureMaker maker(dContext, bitmap, GrImageTexGenPolicy::kNew_Uncached_Budgeted);
         auto view = maker.view(GrMipmapped::kNo);
         if (!view.proxy()) {
             ERRORF(reporter, "Could not create alpha texture.");
             return;
         }
 
-        auto sContext = GrSurfaceContext::Make(direct, std::move(view), maker.colorType(),
+        auto sContext = GrSurfaceContext::Make(dContext, std::move(view), maker.colorType(),
                                                kPremul_SkAlphaType, nullptr);
 
-        sk_sp<SkSurface> surf(SkSurface::MakeRenderTarget(direct, SkBudgeted::kNo, ii));
+        sk_sp<SkSurface> surf(SkSurface::MakeRenderTarget(dContext, SkBudgeted::kNo, ii));
 
         // create a distinctive texture
         for (int y = 0; y < Y_SIZE; ++y) {
@@ -89,7 +89,7 @@
         for (auto rowBytes : kRowBytes) {
 
             // upload the texture (do per-rowbytes iteration because we may overwrite below).
-            bool result = sContext->writePixels(ii, alphaData, 0, {0, 0});
+            bool result = sContext->writePixels(dContext, ii, alphaData, 0, {0, 0});
             REPORTER_ASSERT(reporter, result, "Initial A8 writePixels failed");
 
             size_t nonZeroRowBytes = rowBytes ? rowBytes : X_SIZE;
@@ -99,7 +99,7 @@
             memset(readback.get(), kClearValue, bufLen);
 
             // read the texture back
-            result = sContext->readPixels(ii, readback.get(), rowBytes, {0, 0});
+            result = sContext->readPixels(dContext, ii, readback.get(), rowBytes, {0, 0});
             // We don't require reading from kAlpha_8 to be supported. TODO: At least make this work
             // when kAlpha_8 is renderable.
             if (!result) {
@@ -187,16 +187,16 @@
             auto origin = GrRenderable::kYes == renderable ? kBottomLeft_GrSurfaceOrigin
                                                            : kTopLeft_GrSurfaceOrigin;
             auto proxy = sk_gpu_test::MakeTextureProxyFromData(
-                    direct, renderable, origin,
+                    dContext, renderable, origin,
                     {info.fColorType, info.fAlphaType, nullptr, X_SIZE, Y_SIZE}, rgbaData, 0);
             if (!proxy) {
                 continue;
             }
 
-            GrSwizzle swizzle = direct->priv().caps()->getReadSwizzle(proxy->backendFormat(),
+            GrSwizzle swizzle = dContext->priv().caps()->getReadSwizzle(proxy->backendFormat(),
                                                                       info.fColorType);
             GrSurfaceProxyView view(std::move(proxy), origin, swizzle);
-            auto sContext = GrSurfaceContext::Make(direct, std::move(view), info.fColorType,
+            auto sContext = GrSurfaceContext::Make(dContext, std::move(view), info.fColorType,
                                                    kPremul_SkAlphaType, nullptr);
 
             for (auto rowBytes : kRowBytes) {
@@ -207,7 +207,8 @@
                 memset(readback.get(), kClearValue, nonZeroRowBytes * Y_SIZE);
 
                 // read the texture back
-                bool result = sContext->readPixels(dstInfo, readback.get(), rowBytes, {0, 0});
+                bool result = sContext->readPixels(dContext, dstInfo, readback.get(),
+                                                   rowBytes, {0, 0});
                 REPORTER_ASSERT(reporter, result, "8888 readPixels failed");
 
                 // make sure the original & read back versions match
diff --git a/tests/RectangleTextureTest.cpp b/tests/RectangleTextureTest.cpp
index 9c5bc72..c45dcc7 100644
--- a/tests/RectangleTextureTest.cpp
+++ b/tests/RectangleTextureTest.cpp
@@ -22,11 +22,11 @@
 #include "tools/gpu/ProxyUtils.h"
 
 // skbug.com/5932
-static void test_basic_draw_as_src(skiatest::Reporter* reporter, GrRecordingContext* context,
+static void test_basic_draw_as_src(skiatest::Reporter* reporter, GrDirectContext* dContext,
                                    GrSurfaceProxyView rectView, GrColorType colorType,
                                    SkAlphaType alphaType, uint32_t expectedPixelValues[]) {
     auto rtContext = GrRenderTargetContext::Make(
-            context, colorType, nullptr, SkBackingFit::kExact, rectView.proxy()->dimensions());
+            dContext, colorType, nullptr, SkBackingFit::kExact, rectView.proxy()->dimensions());
     for (auto filter : {GrSamplerState::Filter::kNearest, GrSamplerState::Filter::kLinear}) {
         for (auto mm : {GrSamplerState::MipmapMode::kNone, GrSamplerState::MipmapMode::kLinear}) {
             rtContext->clear(SkPMColor4f::FromBytes_RGBA(0xDDCCBBAA));
@@ -35,13 +35,14 @@
             paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
             paint.setColorFragmentProcessor(std::move(fp));
             rtContext->drawPaint(nullptr, std::move(paint), SkMatrix::I());
-            TestReadPixels(reporter, rtContext.get(), expectedPixelValues,
+            TestReadPixels(reporter, dContext, rtContext.get(), expectedPixelValues,
                            "RectangleTexture-basic-draw");
         }
     }
 }
 
-static void test_clear(skiatest::Reporter* reporter, GrSurfaceContext* rectContext) {
+static void test_clear(skiatest::Reporter* reporter, GrDirectContext* dContext,
+                       GrSurfaceContext* rectContext) {
     if (GrRenderTargetContext* rtc = rectContext->asRenderTargetContext()) {
         // Clear the whole thing.
         GrColor color0 = GrColorPackRGBA(0xA, 0xB, 0xC, 0xD);
@@ -81,12 +82,12 @@
             }
         }
 
-        TestReadPixels(reporter, rtc, expectedPixels.get(), "RectangleTexture-clear");
+        TestReadPixels(reporter, dContext, rtc, expectedPixels.get(), "RectangleTexture-clear");
     }
 }
 
 static void test_copy_to_surface(skiatest::Reporter* reporter,
-                                 GrDirectContext* context,
+                                 GrDirectContext* dContext,
                                  GrSurfaceContext* dstContext,
                                  const char* testName) {
 
@@ -102,22 +103,22 @@
     for (auto renderable : {GrRenderable::kNo, GrRenderable::kYes}) {
         auto origin = dstContext->origin();
         auto src = sk_gpu_test::MakeTextureProxyFromData(
-                context, renderable, origin,
+                dContext, renderable, origin,
                 {GrColorType::kRGBA_8888, kPremul_SkAlphaType, nullptr, dstContext->width(),
                  dstContext->height()},
                 pixels.get(), 0);
         // If this assert ever fails we can add a fallback to do copy as draw, but until then we can
         // be more restrictive.
         SkAssertResult(dstContext->testCopy(src.get()));
-        TestReadPixels(reporter, dstContext, pixels.get(), testName);
+        TestReadPixels(reporter, dContext, dstContext, pixels.get(), testName);
     }
 }
 
 #ifdef SK_GL
 DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(RectangleTexture, reporter, ctxInfo) {
-    auto direct = ctxInfo.directContext();
+    auto dContext = ctxInfo.directContext();
 
-    GrProxyProvider* proxyProvider = direct->priv().proxyProvider();
+    GrProxyProvider* proxyProvider = dContext->priv().proxyProvider();
     static const int kWidth = 16;
     static const int kHeight = 16;
 
@@ -134,16 +135,16 @@
         bool useBLOrigin = kBottomLeft_GrSurfaceOrigin == origin;
 
         auto format = GrBackendFormat::MakeGL(GR_GL_RGBA8, GR_GL_TEXTURE_RECTANGLE);
-        GrBackendTexture rectangleTex = direct->createBackendTexture(kWidth,
-                                                                     kHeight,
-                                                                     format,
-                                                                     GrMipmapped::kNo,
-                                                                     GrRenderable::kYes);
+        GrBackendTexture rectangleTex = dContext->createBackendTexture(kWidth,
+                                                                      kHeight,
+                                                                      format,
+                                                                      GrMipmapped::kNo,
+                                                                      GrRenderable::kYes);
         if (!rectangleTex.isValid()) {
             continue;
         }
 
-        if (!direct->updateBackendTexture(rectangleTex, &pm, 1, nullptr, nullptr)) {
+        if (!dContext->updateBackendTexture(rectangleTex, &pm, 1, nullptr, nullptr)) {
             continue;
         }
 
@@ -159,7 +160,7 @@
                 rectangleTex, kBorrow_GrWrapOwnership, GrWrapCacheable::kNo, kRW_GrIOType);
 
         if (!rectProxy) {
-            direct->deleteBackendTexture(rectangleTex);
+            dContext->deleteBackendTexture(rectangleTex);
             continue;
         }
 
@@ -171,31 +172,31 @@
         SkASSERT(rectProxy->hasRestrictedSampling());
         SkASSERT(rectProxy->peekTexture()->hasRestrictedSampling());
 
-        GrSwizzle swizzle = direct->priv().caps()->getReadSwizzle(rectangleTex.getBackendFormat(),
-                                                                  GrColorType::kRGBA_8888);
+        GrSwizzle swizzle = dContext->priv().caps()->getReadSwizzle(rectangleTex.getBackendFormat(),
+                                                                   GrColorType::kRGBA_8888);
         GrSurfaceProxyView view(rectProxy, origin, swizzle);
 
-        test_basic_draw_as_src(reporter, direct, view, GrColorType::kRGBA_8888,
+        test_basic_draw_as_src(reporter, dContext, view, GrColorType::kRGBA_8888,
                                kPremul_SkAlphaType, refPixels);
 
         // Test copy to both a texture and RT
-        TestCopyFromSurface(reporter, direct, rectProxy.get(), origin, GrColorType::kRGBA_8888,
+        TestCopyFromSurface(reporter, dContext, rectProxy.get(), origin, GrColorType::kRGBA_8888,
                             refPixels, "RectangleTexture-copy-from");
 
-        auto rectContext = GrSurfaceContext::Make(direct, std::move(view),
+        auto rectContext = GrSurfaceContext::Make(dContext, std::move(view),
                                                   GrColorType::kRGBA_8888, kPremul_SkAlphaType,
                                                   nullptr);
         SkASSERT(rectContext);
 
-        TestReadPixels(reporter, rectContext.get(), refPixels, "RectangleTexture-read");
+        TestReadPixels(reporter, dContext, rectContext.get(), refPixels, "RectangleTexture-read");
 
-        test_copy_to_surface(reporter, direct, rectContext.get(), "RectangleTexture-copy-to");
+        test_copy_to_surface(reporter, dContext, rectContext.get(), "RectangleTexture-copy-to");
 
-        TestWritePixels(reporter, rectContext.get(), true, "RectangleTexture-write");
+        TestWritePixels(reporter, dContext, rectContext.get(), true, "RectangleTexture-write");
 
-        test_clear(reporter, rectContext.get());
+        test_clear(reporter, dContext, rectContext.get());
 
-        direct->deleteBackendTexture(rectangleTex);
+        dContext->deleteBackendTexture(rectangleTex);
     }
 }
 #endif
diff --git a/tests/RenderTargetContextTest.cpp b/tests/RenderTargetContextTest.cpp
index 0268a89..3b02881 100644
--- a/tests/RenderTargetContextTest.cpp
+++ b/tests/RenderTargetContextTest.cpp
@@ -61,7 +61,7 @@
         SkAutoTMalloc<uint32_t> dstBuffer(kSize * kSize);
         static const size_t kRowBytes = sizeof(uint32_t) * kSize;
 
-        bool result = rtCtx->readPixels(dstInfo, dstBuffer.get(), kRowBytes, {0, 0});
+        bool result = rtCtx->readPixels(dContext, dstInfo, dstBuffer.get(), kRowBytes, {0, 0});
         REPORTER_ASSERT(reporter, result);
 
         check_instantiation_status(reporter, rtCtx.get(), true);
diff --git a/tests/SRGBReadWritePixelsTest.cpp b/tests/SRGBReadWritePixelsTest.cpp
index dbe06fa..01b4eeb 100644
--- a/tests/SRGBReadWritePixelsTest.cpp
+++ b/tests/SRGBReadWritePixelsTest.cpp
@@ -120,7 +120,9 @@
 
 typedef bool (*CheckFn) (uint32_t orig, uint32_t actual, float error);
 
-void read_and_check_pixels(skiatest::Reporter* reporter, GrSurfaceContext* context,
+void read_and_check_pixels(skiatest::Reporter* reporter,
+                           GrDirectContext* dContext,
+                           GrSurfaceContext* sContext,
                            uint32_t* origData,
                            const SkImageInfo& dstInfo, CheckFn checker, float error,
                            const char* subtestName) {
@@ -129,7 +131,7 @@
     SkAutoTMalloc<uint32_t> readData(w * h);
     memset(readData.get(), 0, sizeof(uint32_t) * w * h);
 
-    if (!context->readPixels(dstInfo, readData.get(), 0, {0, 0})) {
+    if (!sContext->readPixels(dContext, dstInfo, readData.get(), 0, {0, 0})) {
         ERRORF(reporter, "Could not read pixels for %s.", subtestName);
         return;
     }
@@ -201,16 +203,16 @@
 }
 
 static void test_write_read(Encoding contextEncoding, Encoding writeEncoding, Encoding readEncoding,
-                            float error, CheckFn check, GrRecordingContext* rContext,
+                            float error, CheckFn check, GrDirectContext* dContext,
                             skiatest::Reporter* reporter) {
-    auto surfaceContext = make_surface_context(contextEncoding, rContext, reporter);
+    auto surfaceContext = make_surface_context(contextEncoding, dContext, reporter);
     if (!surfaceContext) {
         return;
     }
     auto writeII = SkImageInfo::Make(kW, kH, kRGBA_8888_SkColorType, kPremul_SkAlphaType,
                                      encoding_as_color_space(writeEncoding));
     auto data = make_data();
-    if (!surfaceContext->writePixels(writeII, data.get(), 0, {0, 0})) {
+    if (!surfaceContext->writePixels(dContext, writeII, data.get(), 0, {0, 0})) {
         ERRORF(reporter, "Could not write %s to %s surface context.",
                encoding_as_str(writeEncoding), encoding_as_str(contextEncoding));
         return;
@@ -221,8 +223,8 @@
     SkString testName;
     testName.printf("write %s data to a %s context and read as %s.", encoding_as_str(writeEncoding),
                     encoding_as_str(contextEncoding), encoding_as_str(readEncoding));
-    read_and_check_pixels(reporter, surfaceContext.get(), data.get(), readII, check, error,
-                          testName.c_str());
+    read_and_check_pixels(reporter, dContext, surfaceContext.get(), data.get(), readII, check,
+                          error, testName.c_str());
 }
 
 // Test all combinations of writePixels/readPixels where the surface context/write source/read dst
diff --git a/tests/SurfaceTest.cpp b/tests/SurfaceTest.cpp
index 6029ff2..5a5d885 100644
--- a/tests/SurfaceTest.cpp
+++ b/tests/SurfaceTest.cpp
@@ -773,6 +773,7 @@
 }
 
 static void test_surface_context_clear(skiatest::Reporter* reporter,
+                                       GrDirectContext* dContext,
                                        GrSurfaceContext* surfaceContext, uint32_t expectedValue) {
     int w = surfaceContext->width();
     int h = surfaceContext->height();
@@ -783,8 +784,8 @@
     readback.alloc(ii);
 
     readback.erase(~expectedValue);
-    surfaceContext->readPixels(readback.info(), readback.writable_addr(), readback.rowBytes(),
-                               {0, 0});
+    surfaceContext->readPixels(dContext, readback.info(), readback.writable_addr(),
+                               readback.rowBytes(), {0, 0});
     for (int y = 0; y < h; ++y) {
         for (int x = 0; x < w; ++x) {
             uint32_t pixel = readback.addr32()[y * w + x];
@@ -805,19 +806,19 @@
 }
 
 DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SurfaceClear_Gpu, reporter, ctxInfo) {
-    auto context = ctxInfo.directContext();
+    auto dContext = ctxInfo.directContext();
     // Snaps an image from a surface and then makes a GrSurfaceContext from the image's texture.
-    auto makeImageSurfaceContext = [context](SkSurface* surface) {
+    auto makeImageSurfaceContext = [dContext](SkSurface* surface) {
         sk_sp<SkImage> i(surface->makeImageSnapshot());
         SkImage_Gpu* gpuImage = (SkImage_Gpu*)as_IB(i);
-        return GrSurfaceContext::Make(context, *gpuImage->view(context),
+        return GrSurfaceContext::Make(dContext, *gpuImage->view(dContext),
                                       SkColorTypeToGrColorType(i->colorType()), kPremul_SkAlphaType,
                                       gpuImage->refColorSpace());
     };
 
     // Test that non-wrapped RTs are created clear.
     for (auto& surface_func : {&create_gpu_surface, &create_gpu_scratch_surface}) {
-        auto surface = surface_func(context, kPremul_SkAlphaType, nullptr);
+        auto surface = surface_func(dContext, kPremul_SkAlphaType, nullptr);
         if (!surface) {
             ERRORF(reporter, "Could not create GPU SkSurface.");
             return;
@@ -827,9 +828,9 @@
             ERRORF(reporter, "Could access surface context of GPU SkSurface.");
             return;
         }
-        test_surface_context_clear(reporter, rtc, 0x0);
+        test_surface_context_clear(reporter, dContext, rtc, 0x0);
         auto imageSurfaceCtx = makeImageSurfaceContext(surface.get());
-        test_surface_context_clear(reporter, imageSurfaceCtx.get(), 0x0);
+        test_surface_context_clear(reporter, dContext, imageSurfaceCtx.get(), 0x0);
     }
 
     // Wrapped RTs are *not* supposed to clear (to allow client to partially update a surface).
@@ -837,7 +838,7 @@
     for (auto& surfaceFunc : {&create_gpu_surface_backend_texture,
                               &create_gpu_surface_backend_texture_as_render_target}) {
         GrBackendTexture backendTex;
-        auto surface = surfaceFunc(context, 1, kOrigColor, &backendTex);
+        auto surface = surfaceFunc(dContext, 1, kOrigColor, &backendTex);
         if (!surface) {
             ERRORF(reporter, "Could not create GPU SkSurface.");
             return;
@@ -847,10 +848,11 @@
             ERRORF(reporter, "Could access surface context of GPU SkSurface.");
             return;
         }
-        test_surface_context_clear(reporter, rtc, kOrigColor.toSkColor());
+        test_surface_context_clear(reporter, dContext, rtc, kOrigColor.toSkColor());
         auto imageSurfaceCtx = makeImageSurfaceContext(surface.get());
-        test_surface_context_clear(reporter, imageSurfaceCtx.get(), kOrigColor.toSkColor());
-        context->deleteBackendTexture(backendTex);
+        test_surface_context_clear(reporter, dContext, imageSurfaceCtx.get(),
+                                   kOrigColor.toSkColor());
+        dContext->deleteBackendTexture(backendTex);
     }
 }
 
diff --git a/tests/TestUtils.cpp b/tests/TestUtils.cpp
index 3ce1001..d2b9479 100644
--- a/tests/TestUtils.cpp
+++ b/tests/TestUtils.cpp
@@ -21,6 +21,7 @@
 #include "src/gpu/SkGr.h"
 
 void TestReadPixels(skiatest::Reporter* reporter,
+                    GrDirectContext* dContext,
                     GrSurfaceContext* srcContext,
                     uint32_t expectedPixelValues[],
                     const char* testName) {
@@ -30,7 +31,7 @@
 
     SkImageInfo ii = SkImageInfo::Make(srcContext->width(), srcContext->height(),
                                        kRGBA_8888_SkColorType, kPremul_SkAlphaType);
-    bool read = srcContext->readPixels(ii, pixels.get(), 0, {0, 0});
+    bool read = srcContext->readPixels(dContext, ii, pixels.get(), 0, {0, 0});
     if (!read) {
         ERRORF(reporter, "%s: Error reading from texture.", testName);
     }
@@ -45,6 +46,7 @@
 }
 
 void TestWritePixels(skiatest::Reporter* reporter,
+                     GrDirectContext* dContext,
                      GrSurfaceContext* dstContext,
                      bool expectedToWork,
                      const char* testName) {
@@ -59,7 +61,7 @@
 
     SkImageInfo ii = SkImageInfo::Make(dstContext->width(), dstContext->height(),
                                        kRGBA_8888_SkColorType, kPremul_SkAlphaType);
-    bool write = dstContext->writePixels(ii, pixels.get(), 0, {0, 0});
+    bool write = dstContext->writePixels(dContext, ii, pixels.get(), 0, {0, 0});
     if (!write) {
         if (expectedToWork) {
             ERRORF(reporter, "%s: Error writing to texture.", testName);
@@ -72,26 +74,26 @@
         return;
     }
 
-    TestReadPixels(reporter, dstContext, pixels.get(), testName);
+    TestReadPixels(reporter, dContext, dstContext, pixels.get(), testName);
 }
 
 void TestCopyFromSurface(skiatest::Reporter* reporter,
-                         GrRecordingContext* rContext,
+                         GrDirectContext* dContext,
                          GrSurfaceProxy* proxy,
                          GrSurfaceOrigin origin,
                          GrColorType colorType,
                          uint32_t expectedPixelValues[],
                          const char* testName) {
-    auto copy = GrSurfaceProxy::Copy(rContext, proxy, origin, GrMipmapped::kNo,
+    auto copy = GrSurfaceProxy::Copy(dContext, proxy, origin, GrMipmapped::kNo,
                                      SkBackingFit::kExact, SkBudgeted::kYes);
     SkASSERT(copy && copy->asTextureProxy());
-    auto swizzle = rContext->priv().caps()->getReadSwizzle(copy->backendFormat(), colorType);
+    auto swizzle = dContext->priv().caps()->getReadSwizzle(copy->backendFormat(), colorType);
     GrSurfaceProxyView view(std::move(copy), origin, swizzle);
-    auto dstContext = GrSurfaceContext::Make(rContext, std::move(view), colorType,
+    auto dstContext = GrSurfaceContext::Make(dContext, std::move(view), colorType,
                                              kPremul_SkAlphaType, nullptr);
     SkASSERT(dstContext);
 
-    TestReadPixels(reporter, dstContext.get(), expectedPixelValues, testName);
+    TestReadPixels(reporter, dContext, dstContext.get(), expectedPixelValues, testName);
 }
 
 void FillPixelData(int width, int height, GrColor* data) {
diff --git a/tests/TestUtils.h b/tests/TestUtils.h
index 64dfcf1..605aff0 100644
--- a/tests/TestUtils.h
+++ b/tests/TestUtils.h
@@ -14,17 +14,17 @@
 typedef uint32_t GrColor;
 
 // Ensure that reading back from 'srcContext' as RGBA 8888 matches 'expectedPixelValues
-void TestReadPixels(skiatest::Reporter*, GrSurfaceContext* srcContext,
+void TestReadPixels(skiatest::Reporter*, GrDirectContext*, GrSurfaceContext* srcContext,
                     uint32_t expectedPixelValues[], const char* testName);
 
 // See if trying to write RGBA 8888 pixels to 'dstContext' matches matches the
 // expectation ('expectedToWork')
-void TestWritePixels(skiatest::Reporter*, GrSurfaceContext* srcContext, bool expectedToWork,
-                     const char* testName);
+void TestWritePixels(skiatest::Reporter*, GrDirectContext*, GrSurfaceContext* srcContext,
+                     bool expectedToWork, const char* testName);
 
 // Ensure that the pixels can be copied from 'proxy' viewed as colorType, to an RGBA 8888
 // destination (both texture-backed and rendertarget-backed).
-void TestCopyFromSurface(skiatest::Reporter*, GrRecordingContext*, GrSurfaceProxy* proxy,
+void TestCopyFromSurface(skiatest::Reporter*, GrDirectContext*, GrSurfaceProxy* proxy,
                          GrSurfaceOrigin origin, GrColorType colorType,
                          uint32_t expectedPixelValues[], const char* testName);
 
diff --git a/tools/gpu/ProxyUtils.cpp b/tools/gpu/ProxyUtils.cpp
index 0bcdbbd..0c4b2e3 100644
--- a/tools/gpu/ProxyUtils.cpp
+++ b/tools/gpu/ProxyUtils.cpp
@@ -21,17 +21,17 @@
 
 namespace sk_gpu_test {
 
-sk_sp<GrTextureProxy> MakeTextureProxyFromData(GrDirectContext* direct,
+sk_sp<GrTextureProxy> MakeTextureProxyFromData(GrDirectContext* dContext,
                                                GrRenderable renderable,
                                                GrSurfaceOrigin origin,
                                                const GrImageInfo& imageInfo,
                                                const void* data,
                                                size_t rowBytes) {
-    if (direct->abandoned()) {
+    if (dContext->abandoned()) {
         return nullptr;
     }
 
-    const GrCaps* caps = direct->priv().caps();
+    const GrCaps* caps = dContext->priv().caps();
 
     const GrBackendFormat format = caps->getDefaultBackendFormat(imageInfo.colorType(), renderable);
     if (!format.isValid()) {
@@ -40,19 +40,20 @@
     GrSwizzle swizzle = caps->getReadSwizzle(format, imageInfo.colorType());
 
     sk_sp<GrTextureProxy> proxy;
-    proxy = direct->priv().proxyProvider()->createProxy(format, imageInfo.dimensions(), renderable,
-                                                        1, GrMipmapped::kNo, SkBackingFit::kExact,
-                                                        SkBudgeted::kYes, GrProtected::kNo);
+    proxy = dContext->priv().proxyProvider()->createProxy(format, imageInfo.dimensions(),
+                                                          renderable, 1, GrMipmapped::kNo,
+                                                          SkBackingFit::kExact, SkBudgeted::kYes,
+                                                          GrProtected::kNo);
     if (!proxy) {
         return nullptr;
     }
     GrSurfaceProxyView view(proxy, origin, swizzle);
-    auto sContext = GrSurfaceContext::Make(direct, std::move(view), imageInfo.colorType(),
+    auto sContext = GrSurfaceContext::Make(dContext, std::move(view), imageInfo.colorType(),
                                            imageInfo.alphaType(), imageInfo.refColorSpace());
     if (!sContext) {
         return nullptr;
     }
-    if (!sContext->writePixels(imageInfo, data, rowBytes, {0, 0}, direct)) {
+    if (!sContext->writePixels(dContext, imageInfo, data, rowBytes, {0, 0})) {
         return nullptr;
     }
     return proxy;