Move internal calls from GrContext to GrContextPriv

A mechanical bulk move just to get these out of the public API.

TBR=bsalomon@google.com
Change-Id: I813efbd54a09dd448275697c0e50947753a5cfd3
Reviewed-on: https://skia-review.googlesource.com/112262
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
diff --git a/bench/ImageCacheBudgetBench.cpp b/bench/ImageCacheBudgetBench.cpp
index 12e5790..a6ee430 100644
--- a/bench/ImageCacheBudgetBench.cpp
+++ b/bench/ImageCacheBudgetBench.cpp
@@ -14,6 +14,7 @@
 #if SK_SUPPORT_GPU
 
 #include "GrContext.h"
+#include "GrContextPriv.h"
 
 /** These benchmarks were designed to measure changes to GrResourceCache's replacement policy */
 
@@ -46,7 +47,7 @@
     GrContext* context =  canvas->getGrContext();
     SkASSERT(context);
     context->flush();
-    context->purgeAllUnlockedResources();
+    context->contextPriv().purgeAllUnlockedResources_ForTesting();
     sk_sp<SkImage> image;
     make_images(&image, 1);
     draw_image(canvas, image.get());
@@ -55,7 +56,7 @@
     context->getResourceCacheUsage(&baselineCount, nullptr);
     baselineCount -= 1; // for the image's textures.
     context->setResourceCacheLimits(baselineCount + approxImagesInBudget, 1 << 30);
-    context->purgeAllUnlockedResources();
+    context->contextPriv().purgeAllUnlockedResources_ForTesting();
 }
 
 //////////////////////////////////////////////////////////////////////////////
diff --git a/bench/SKPBench.cpp b/bench/SKPBench.cpp
index 4fbb1bb..1391b40 100644
--- a/bench/SKPBench.cpp
+++ b/bench/SKPBench.cpp
@@ -163,13 +163,13 @@
 static void draw_pic_for_stats(SkCanvas* canvas, GrContext* context, const SkPicture* picture,
                                SkTArray<SkString>* keys, SkTArray<double>* values,
                                const char* tag) {
-    context->resetGpuStats();
+    context->contextPriv().resetGpuStats();
     canvas->drawPicture(picture);
     canvas->flush();
 
     int offset = keys->count();
-    context->dumpGpuStatsKeyValuePairs(keys, values);
-    context->dumpCacheStatsKeyValuePairs(keys, values);
+    context->contextPriv().dumpGpuStatsKeyValuePairs(keys, values);
+    context->contextPriv().dumpCacheStatsKeyValuePairs(keys, values);
 
     // append tag, but only to new tags
     for (int i = offset; i < keys->count(); i++, offset++) {
diff --git a/bench/nanobench.cpp b/bench/nanobench.cpp
index f7f0bff..2246fbb 100644
--- a/bench/nanobench.cpp
+++ b/bench/nanobench.cpp
@@ -60,6 +60,7 @@
 #if SK_SUPPORT_GPU
     #include "gl/GrGLDefines.h"
     #include "GrCaps.h"
+    #include "GrContextPriv.h"
     #include "GrContextFactory.h"
     #include "gl/GrGLUtil.h"
     #include "SkGr.h"
@@ -230,8 +231,8 @@
     }
 
     void dumpStats() override {
-        this->contextInfo.grContext()->printCacheStats();
-        this->contextInfo.grContext()->printGpuStats();
+        this->contextInfo.grContext()->contextPriv().printCacheStats();
+        this->contextInfo.grContext()->contextPriv().printGpuStats();
     }
 };
 
diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp
index 149138d..b845637 100644
--- a/dm/DMSrcSink.cpp
+++ b/dm/DMSrcSink.cpp
@@ -71,6 +71,10 @@
     #include "SkXMLWriter.h"
 #endif
 
+#if SK_SUPPORT_GPU
+#include "GrContextPriv.h"
+#endif
+
 DEFINE_bool(multiPage, false, "For document-type backends, render the source"
             " into multiple pages");
 DEFINE_bool(RAW_threading, true, "Allow RAW decodes to run on multiple threads?");
@@ -1655,8 +1659,10 @@
     }
     canvas->flush();
     if (FLAGS_gpuStats) {
-        canvas->getGrContext()->dumpCacheStats(log);
-        canvas->getGrContext()->dumpGpuStats(log);
+#if SK_SUPPORT_GPU
+        canvas->getGrContext()->contextPriv().dumpCacheStats(log);
+        canvas->getGrContext()->contextPriv().dumpGpuStats(log);
+#endif
     }
     if (info.colorType() == kRGB_565_SkColorType || info.colorType() == kARGB_4444_SkColorType) {
         // We don't currently support readbacks into these formats on the GPU backend. Convert to
diff --git a/gm/fontcache.cpp b/gm/fontcache.cpp
index f7a1313..6c99700 100644
--- a/gm/fontcache.cpp
+++ b/gm/fontcache.cpp
@@ -13,6 +13,7 @@
 #if SK_SUPPORT_GPU
 
 #include "GrContext.h"
+#include "GrContextPriv.h"
 #include "GrContextOptions.h"
 #include "SkCanvas.h"
 #include "SkGraphics.h"
@@ -74,7 +75,7 @@
         static const bool kShowAtlas = false;
         if (kShowAtlas) {
             if (auto ctx = canvas->getGrContext()) {
-                auto img = ctx->getFontAtlasImage_ForTesting(kA8_GrMaskFormat);
+                auto img = ctx->contextPriv().getFontAtlasImage_ForTesting(kA8_GrMaskFormat);
                 canvas->drawImage(img, 0, 0);
             }
         }
diff --git a/gm/windowrectangles.cpp b/gm/windowrectangles.cpp
index 08fee7b..931a154 100644
--- a/gm/windowrectangles.cpp
+++ b/gm/windowrectangles.cpp
@@ -199,7 +199,8 @@
     const int padRight = (kDeviceRect.right() - kCoverRect.right()) / 2;
     const int padBottom = (kDeviceRect.bottom() - kCoverRect.bottom()) / 2;
     sk_sp<GrRenderTargetContext> maskRTC(
-        ctx->makeDeferredRenderTargetContextWithFallback(SkBackingFit::kExact,
+        ctx->contextPriv().makeDeferredRenderTargetContextWithFallback(
+                                                         SkBackingFit::kExact,
                                                          kCoverRect.width() + padRight,
                                                          kCoverRect.height() + padBottom,
                                                          kAlpha_8_GrPixelConfig, nullptr));
diff --git a/include/gpu/GrContext.h b/include/gpu/GrContext.h
index 6578638..bbd43df 100644
--- a/include/gpu/GrContext.h
+++ b/include/gpu/GrContext.h
@@ -187,13 +187,6 @@
     virtual void freeGpuResources();
 
     /**
-     * Purge all the unlocked resources from the cache.
-     * This entry point is mainly meant for timing texture uploads
-     * and is not defined in normal builds of Skia.
-     */
-    void purgeAllUnlockedResources();
-
-    /**
      * Purge GPU resources that haven't been used in the past 'msNotUsed' milliseconds or are
      * otherwise marked for deletion, regardless of whether the context is under budget.
      */
@@ -239,38 +232,6 @@
      */
     int maxSurfaceSampleCountForColorType(SkColorType) const;
 
-    /*
-     * Create a new render target context backed by a deferred-style
-     * GrRenderTargetProxy. We guarantee that "asTextureProxy" will succeed for
-     * renderTargetContexts created via this entry point.
-     */
-    sk_sp<GrRenderTargetContext> makeDeferredRenderTargetContext(
-                                                 SkBackingFit fit,
-                                                 int width, int height,
-                                                 GrPixelConfig config,
-                                                 sk_sp<SkColorSpace> colorSpace,
-                                                 int sampleCnt = 1,
-                                                 GrMipMapped = GrMipMapped::kNo,
-                                                 GrSurfaceOrigin origin = kBottomLeft_GrSurfaceOrigin,
-                                                 const SkSurfaceProps* surfaceProps = nullptr,
-                                                 SkBudgeted = SkBudgeted::kYes);
-    /*
-     * This method will attempt to create a renderTargetContext that has, at least, the number of
-     * channels and precision per channel as requested in 'config' (e.g., A8 and 888 can be
-     * converted to 8888). It may also swizzle the channels (e.g., BGRA -> RGBA).
-     * SRGB-ness will be preserved.
-     */
-    sk_sp<GrRenderTargetContext> makeDeferredRenderTargetContextWithFallback(
-                                                 SkBackingFit fit,
-                                                 int width, int height,
-                                                 GrPixelConfig config,
-                                                 sk_sp<SkColorSpace> colorSpace,
-                                                 int sampleCnt = 1,
-                                                 GrMipMapped = GrMipMapped::kNo,
-                                                 GrSurfaceOrigin origin = kBottomLeft_GrSurfaceOrigin,
-                                                 const SkSurfaceProps* surfaceProps = nullptr,
-                                                 SkBudgeted budgeted = SkBudgeted::kYes);
-
     ///////////////////////////////////////////////////////////////////////////
     // Misc.
 
@@ -308,53 +269,14 @@
      */
     uint32_t uniqueID() { return fUniqueID; }
 
-    ///////////////////////////////////////////////////////////////////////////
-    // Functions intended for internal use only.
-    bool abandoned() const;
-
-    /** Reset GPU stats */
-    void resetGpuStats() const ;
-
-    /** Prints cache stats to the string if GR_CACHE_STATS == 1. */
-    void dumpCacheStats(SkString*) const;
-    void dumpCacheStatsKeyValuePairs(SkTArray<SkString>* keys, SkTArray<double>* values) const;
-    void printCacheStats() const;
-
-    /** Prints GPU stats to the string if GR_GPU_STATS == 1. */
-    void dumpGpuStats(SkString*) const;
-    void dumpGpuStatsKeyValuePairs(SkTArray<SkString>* keys, SkTArray<double>* values) const;
-    void printGpuStats() const;
-
-    /** Returns a string with detailed information about the context & GPU, in JSON format. */
-    SkString dump() const;
-
-    /** Specify the TextBlob cache limit. If the current cache exceeds this limit it will purge.
-        this is for testing only */
-    void setTextBlobCacheLimit_ForTesting(size_t bytes);
-
-    /** Specify the sizes of the GrAtlasTextContext atlases.  The configs pointer below should be
-        to an array of 3 entries */
-    void setTextContextAtlasSizes_ForTesting(const GrDrawOpAtlasConfig* configs);
-
-    /** Enumerates all cached GPU resources and dumps their memory to traceMemoryDump. */
-    void dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const;
-
-    /** Get pointer to atlas texture for given mask format. Note that this wraps an
-        actively mutating texture in an SkImage. This could yield unexpected results
-        if it gets cached or used more generally. */
-    sk_sp<SkImage> getFontAtlasImage_ForTesting(GrMaskFormat format, unsigned int index = 0);
-
-    GrAuditTrail* getAuditTrail() { return &fAuditTrail; }
-
-    GrContextOptions::PersistentCache* getPersistentCache() { return fPersistentCache; }
-
-    /** This is only useful for debug purposes */
-    SkDEBUGCODE(GrSingleOwner* debugSingleOwner() const { return &fSingleOwner; } )
-
     // Provides access to functions that aren't part of the public API.
     GrContextPriv contextPriv();
     const GrContextPriv contextPriv() const;
 
+    /** Enumerates all cached GPU resources and dumps their memory to traceMemoryDump. */
+    // Chrome is using this!
+    void dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const;
+
 protected:
     GrContext(GrBackend, int32_t id = SK_InvalidGenID);
 
diff --git a/samplecode/SampleAnimatedText.cpp b/samplecode/SampleAnimatedText.cpp
index f93ceca..71f3b87 100644
--- a/samplecode/SampleAnimatedText.cpp
+++ b/samplecode/SampleAnimatedText.cpp
@@ -19,6 +19,7 @@
 
 #if SK_SUPPORT_GPU
 #include "GrContext.h"
+#include "GrContextPriv.h"
 #endif
 
 SkRandom gRand;
@@ -103,8 +104,8 @@
 #if SK_SUPPORT_GPU
         GrContext* grContext = canvas->getGrContext();
         if (grContext) {
-            sk_sp<SkImage> image =
-                        grContext->getFontAtlasImage_ForTesting(GrMaskFormat::kA8_GrMaskFormat);
+            sk_sp<SkImage> image = grContext->contextPriv().getFontAtlasImage_ForTesting(
+                                                                GrMaskFormat::kA8_GrMaskFormat);
             canvas->drawImageRect(image,
                                   SkRect::MakeXYWH(512.0f, 10.0f, 512.0f, 512.0f), &paint);
         }
diff --git a/samplecode/SampleChineseFling.cpp b/samplecode/SampleChineseFling.cpp
index 76222e9..05e0218 100644
--- a/samplecode/SampleChineseFling.cpp
+++ b/samplecode/SampleChineseFling.cpp
@@ -17,6 +17,7 @@
 
 #if SK_SUPPORT_GPU
 #include "GrContext.h"
+#include "GrContextPriv.h"
 #endif
 
 static void make_paint(SkPaint* paint, sk_sp<SkTypeface> typeface) {
@@ -173,16 +174,20 @@
             GrContext* grContext = canvas->getGrContext();
             if (grContext) {
                 sk_sp<SkImage> image =
-                grContext->getFontAtlasImage_ForTesting(GrMaskFormat::kA8_GrMaskFormat, 0);
+                grContext->contextPriv().getFontAtlasImage_ForTesting(
+                                                            GrMaskFormat::kA8_GrMaskFormat, 0);
                 canvas->drawImageRect(image,
                                       SkRect::MakeXYWH(10.0f, 10.0f, 512.0f, 512.0), &paint);
-                image = grContext->getFontAtlasImage_ForTesting(GrMaskFormat::kA8_GrMaskFormat, 1);
+                image = grContext->contextPriv().getFontAtlasImage_ForTesting(
+                                                            GrMaskFormat::kA8_GrMaskFormat, 1);
                 canvas->drawImageRect(image,
                                       SkRect::MakeXYWH(522.0f, 10.0f, 512.f, 512.0f), &paint);
-                image = grContext->getFontAtlasImage_ForTesting(GrMaskFormat::kA8_GrMaskFormat, 2);
+                image = grContext->contextPriv().getFontAtlasImage_ForTesting(
+                                                            GrMaskFormat::kA8_GrMaskFormat, 2);
                 canvas->drawImageRect(image,
                                       SkRect::MakeXYWH(10.0f, 522.0f, 512.0f, 512.0f), &paint);
-                image = grContext->getFontAtlasImage_ForTesting(GrMaskFormat::kA8_GrMaskFormat, 3);
+                image = grContext->contextPriv().getFontAtlasImage_ForTesting(
+                                                            GrMaskFormat::kA8_GrMaskFormat, 3);
                 canvas->drawImageRect(image,
                                       SkRect::MakeXYWH(522.0f, 522.0f, 512.0f, 512.0f), &paint);
             }
diff --git a/src/core/SkGpuBlurUtils.cpp b/src/core/SkGpuBlurUtils.cpp
index 755e8da..b42bb04 100644
--- a/src/core/SkGpuBlurUtils.cpp
+++ b/src/core/SkGpuBlurUtils.cpp
@@ -250,8 +250,8 @@
         // We shouldn't be scaling because this is a small size blur
         SkASSERT((1 == scaleFactorX) && (1 == scaleFactorY));
 
-        dstRenderTargetContext = context->makeDeferredRenderTargetContext(fit, width, height,
-                                                                          config, colorSpace);
+        dstRenderTargetContext = context->contextPriv().makeDeferredRenderTargetContext(
+                fit, width, height, config, colorSpace);
         if (!dstRenderTargetContext) {
             return nullptr;
         }
@@ -272,7 +272,7 @@
         SkIRect dstRect(srcRect);
         shrink_irect_by_2(&dstRect, i < scaleFactorX, i < scaleFactorY);
 
-        dstRenderTargetContext = context->makeDeferredRenderTargetContext(
+        dstRenderTargetContext = context->contextPriv().makeDeferredRenderTargetContext(
                                                                 fit,
                                                                 SkTMin(dstRect.fRight, width),
                                                                 SkTMin(dstRect.fBottom, height),
@@ -327,7 +327,8 @@
         }
 
         SkASSERT(srcRect.width() <= width && srcRect.height() <= height);
-        dstRenderTargetContext = context->makeDeferredRenderTargetContext(fit, srcRect.width(),
+        dstRenderTargetContext = context->contextPriv().makeDeferredRenderTargetContext(
+                                                                          fit, srcRect.width(),
                                                                           srcRect.height(),
                                                                           config, colorSpace);
         if (!dstRenderTargetContext) {
@@ -362,7 +363,8 @@
         }
 
         SkASSERT(srcRect.width() <= width && srcRect.height() <= height);
-        dstRenderTargetContext = context->makeDeferredRenderTargetContext(fit, srcRect.width(),
+        dstRenderTargetContext = context->contextPriv().makeDeferredRenderTargetContext(
+                                                                          fit, srcRect.width(),
                                                                           srcRect.height(),
                                                                           config, colorSpace);
         if (!dstRenderTargetContext) {
@@ -394,7 +396,7 @@
         SkIRect dstRect(srcRect);
         scale_irect(&dstRect, scaleFactorX, scaleFactorY);
 
-        dstRenderTargetContext = context->makeDeferredRenderTargetContext(
+        dstRenderTargetContext = context->contextPriv().makeDeferredRenderTargetContext(
                                                                 fit, SkTMin(dstRect.width(), width),
                                                                 SkTMin(dstRect.height(), height),
                                                                 config, colorSpace);
diff --git a/src/core/SkImageFilter.cpp b/src/core/SkImageFilter.cpp
index b2220a7..ae3b53a 100644
--- a/src/core/SkImageFilter.cpp
+++ b/src/core/SkImageFilter.cpp
@@ -302,8 +302,10 @@
 
     sk_sp<SkColorSpace> colorSpace = sk_ref_sp(outputProperties.colorSpace());
     GrPixelConfig config = GrRenderableConfigForColorSpace(colorSpace.get());
-    sk_sp<GrRenderTargetContext> renderTargetContext(context->makeDeferredRenderTargetContext(
-        SkBackingFit::kApprox, bounds.width(), bounds.height(), config, std::move(colorSpace)));
+    sk_sp<GrRenderTargetContext> renderTargetContext(
+        context->contextPriv().makeDeferredRenderTargetContext(
+                                SkBackingFit::kApprox, bounds.width(), bounds.height(),
+                                config, std::move(colorSpace)));
     if (!renderTargetContext) {
         return nullptr;
     }
diff --git a/src/core/SkSpecialSurface.cpp b/src/core/SkSpecialSurface.cpp
index ef78a3e..19a149f 100644
--- a/src/core/SkSpecialSurface.cpp
+++ b/src/core/SkSpecialSurface.cpp
@@ -171,8 +171,9 @@
         return nullptr;
     }
 
-    sk_sp<GrRenderTargetContext> renderTargetContext(context->makeDeferredRenderTargetContext(
-        SkBackingFit::kApprox, width, height, config, std::move(colorSpace)));
+    sk_sp<GrRenderTargetContext> renderTargetContext(
+        context->contextPriv().makeDeferredRenderTargetContext(
+                SkBackingFit::kApprox, width, height, config, std::move(colorSpace)));
     if (!renderTargetContext) {
         return nullptr;
     }
diff --git a/src/effects/SkAlphaThresholdFilter.cpp b/src/effects/SkAlphaThresholdFilter.cpp
index a9052f8..f275961 100644
--- a/src/effects/SkAlphaThresholdFilter.cpp
+++ b/src/effects/SkAlphaThresholdFilter.cpp
@@ -106,8 +106,10 @@
                                                                     const SkMatrix& inMatrix,
                                                                     const SkIRect& bounds) const {
 
-    sk_sp<GrRenderTargetContext> rtContext(context->makeDeferredRenderTargetContextWithFallback(
-        SkBackingFit::kApprox, bounds.width(), bounds.height(), kAlpha_8_GrPixelConfig, nullptr));
+    sk_sp<GrRenderTargetContext> rtContext(
+        context->contextPriv().makeDeferredRenderTargetContextWithFallback(
+            SkBackingFit::kApprox, bounds.width(), bounds.height(), kAlpha_8_GrPixelConfig,
+            nullptr));
     if (!rtContext) {
         return nullptr;
     }
diff --git a/src/effects/SkArithmeticImageFilter.cpp b/src/effects/SkArithmeticImageFilter.cpp
index d78550a..4bb3c0b 100644
--- a/src/effects/SkArithmeticImageFilter.cpp
+++ b/src/effects/SkArithmeticImageFilter.cpp
@@ -345,7 +345,8 @@
 
     paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
 
-    sk_sp<GrRenderTargetContext> renderTargetContext(context->makeDeferredRenderTargetContext(
+    sk_sp<GrRenderTargetContext> renderTargetContext(
+        context->contextPriv().makeDeferredRenderTargetContext(
             SkBackingFit::kApprox, bounds.width(), bounds.height(),
             GrRenderableConfigForColorSpace(outputProperties.colorSpace()),
             sk_ref_sp(outputProperties.colorSpace())));
diff --git a/src/effects/SkDisplacementMapEffect.cpp b/src/effects/SkDisplacementMapEffect.cpp
index ce7fe34..bb51b88 100644
--- a/src/effects/SkDisplacementMapEffect.cpp
+++ b/src/effects/SkDisplacementMapEffect.cpp
@@ -306,7 +306,7 @@
         matrix.setTranslate(-SkIntToScalar(colorBounds.x()), -SkIntToScalar(colorBounds.y()));
 
         sk_sp<GrRenderTargetContext> renderTargetContext(
-            context->makeDeferredRenderTargetContext(SkBackingFit::kApprox,
+            context->contextPriv().makeDeferredRenderTargetContext(SkBackingFit::kApprox,
                                                      bounds.width(), bounds.height(),
                                                      GrRenderableConfigForColorSpace(colorSpace),
                                                      sk_ref_sp(colorSpace)));
diff --git a/src/effects/SkLightingImageFilter.cpp b/src/effects/SkLightingImageFilter.cpp
index 98b0a13..7a1c535 100644
--- a/src/effects/SkLightingImageFilter.cpp
+++ b/src/effects/SkLightingImageFilter.cpp
@@ -466,7 +466,9 @@
     sk_sp<GrTextureProxy> inputProxy(input->asTextureProxyRef(context));
     SkASSERT(inputProxy);
 
-    sk_sp<GrRenderTargetContext> renderTargetContext(context->makeDeferredRenderTargetContext(
+
+    sk_sp<GrRenderTargetContext> renderTargetContext(
+        context->contextPriv().makeDeferredRenderTargetContext(
                                 SkBackingFit::kApprox, offsetBounds.width(), offsetBounds.height(),
                                 GrRenderableConfigForColorSpace(outputProperties.colorSpace()),
                                 sk_ref_sp(outputProperties.colorSpace())));
diff --git a/src/effects/SkMorphologyImageFilter.cpp b/src/effects/SkMorphologyImageFilter.cpp
index 67a681d..f5da7ac 100644
--- a/src/effects/SkMorphologyImageFilter.cpp
+++ b/src/effects/SkMorphologyImageFilter.cpp
@@ -497,8 +497,9 @@
     SkASSERT(radius.width() > 0 || radius.height() > 0);
 
     if (radius.fWidth > 0) {
-        sk_sp<GrRenderTargetContext> dstRTContext(context->makeDeferredRenderTargetContext(
-            SkBackingFit::kApprox, rect.width(), rect.height(), config, colorSpace));
+        sk_sp<GrRenderTargetContext> dstRTContext(
+            context->contextPriv().makeDeferredRenderTargetContext(
+                SkBackingFit::kApprox, rect.width(), rect.height(), config, colorSpace));
         if (!dstRTContext) {
             return nullptr;
         }
@@ -515,8 +516,9 @@
         srcRect = dstRect;
     }
     if (radius.fHeight > 0) {
-        sk_sp<GrRenderTargetContext> dstRTContext(context->makeDeferredRenderTargetContext(
-            SkBackingFit::kApprox, rect.width(), rect.height(), config, colorSpace));
+        sk_sp<GrRenderTargetContext> dstRTContext(
+            context->contextPriv().makeDeferredRenderTargetContext(
+                SkBackingFit::kApprox, rect.width(), rect.height(), config, colorSpace));
         if (!dstRTContext) {
             return nullptr;
         }
diff --git a/src/effects/SkXfermodeImageFilter.cpp b/src/effects/SkXfermodeImageFilter.cpp
index 42fb249..f1f8396 100644
--- a/src/effects/SkXfermodeImageFilter.cpp
+++ b/src/effects/SkXfermodeImageFilter.cpp
@@ -333,7 +333,8 @@
 
     paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
 
-    sk_sp<GrRenderTargetContext> renderTargetContext(context->makeDeferredRenderTargetContext(
+    sk_sp<GrRenderTargetContext> renderTargetContext(
+        context->contextPriv().makeDeferredRenderTargetContext(
                                     SkBackingFit::kApprox, bounds.width(), bounds.height(),
                                     GrRenderableConfigForColorSpace(outputProperties.colorSpace()),
                                     sk_ref_sp(outputProperties.colorSpace())));
diff --git a/src/gpu/GrAHardwareBufferImageGenerator.cpp b/src/gpu/GrAHardwareBufferImageGenerator.cpp
index 085d27a..be6a8d0 100644
--- a/src/gpu/GrAHardwareBufferImageGenerator.cpp
+++ b/src/gpu/GrAHardwareBufferImageGenerator.cpp
@@ -147,7 +147,8 @@
 #endif
 
 sk_sp<GrTextureProxy> GrAHardwareBufferImageGenerator::makeProxy(GrContext* context) {
-    if (context->abandoned() || kOpenGL_GrBackend != context->contextPriv().getBackend()) {
+    if (context->contextPriv().abandoned() ||
+        kOpenGL_GrBackend != context->contextPriv().getBackend()) {
         // Check if GrContext is not abandoned and the backend is GL.
         return nullptr;
     }
diff --git a/src/gpu/GrBackendTextureImageGenerator.cpp b/src/gpu/GrBackendTextureImageGenerator.cpp
index aafa3a2..73f19b0 100644
--- a/src/gpu/GrBackendTextureImageGenerator.cpp
+++ b/src/gpu/GrBackendTextureImageGenerator.cpp
@@ -189,7 +189,8 @@
             colorSpace = SkColorSpace::MakeSRGB();
         }
 
-        sk_sp<GrRenderTargetContext> rtContext(context->makeDeferredRenderTargetContext(
+        sk_sp<GrRenderTargetContext> rtContext(
+            context->contextPriv().makeDeferredRenderTargetContext(
                 SkBackingFit::kExact, info.width(), info.height(), proxy->config(),
                 std::move(colorSpace), 1, mipMapped, proxy->origin(), nullptr, SkBudgeted::kYes));
 
diff --git a/src/gpu/GrBlurUtils.cpp b/src/gpu/GrBlurUtils.cpp
index fb8977e..0bddd5c 100644
--- a/src/gpu/GrBlurUtils.cpp
+++ b/src/gpu/GrBlurUtils.cpp
@@ -110,9 +110,10 @@
         sampleCnt = 1;
     }
 
-    sk_sp<GrRenderTargetContext> rtContext(context->makeDeferredRenderTargetContextWithFallback(
-        SkBackingFit::kApprox, maskRect.width(), maskRect.height(), kAlpha_8_GrPixelConfig, nullptr,
-        sampleCnt));
+    sk_sp<GrRenderTargetContext> rtContext(
+        context->contextPriv().makeDeferredRenderTargetContextWithFallback(
+            SkBackingFit::kApprox, maskRect.width(), maskRect.height(), kAlpha_8_GrPixelConfig,
+            nullptr, sampleCnt));
     if (!rtContext) {
         return nullptr;
     }
diff --git a/src/gpu/GrClipStackClip.cpp b/src/gpu/GrClipStackClip.cpp
index 179573e..28bf34b 100644
--- a/src/gpu/GrClipStackClip.cpp
+++ b/src/gpu/GrClipStackClip.cpp
@@ -337,12 +337,12 @@
         return proxy;
     }
 
-    sk_sp<GrRenderTargetContext> rtc(context->makeDeferredRenderTargetContextWithFallback(
-                                                                             SkBackingFit::kApprox,
-                                                                             reducedClip.width(),
-                                                                             reducedClip.height(),
-                                                                             kAlpha_8_GrPixelConfig,
-                                                                             nullptr));
+    sk_sp<GrRenderTargetContext> rtc(
+        context->contextPriv().makeDeferredRenderTargetContextWithFallback(SkBackingFit::kApprox,
+                                                                           reducedClip.width(),
+                                                                           reducedClip.height(),
+                                                                           kAlpha_8_GrPixelConfig,
+                                                                           nullptr));
     if (!rtc) {
         return nullptr;
     }
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index 627f20a..d29a173 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -961,7 +961,8 @@
             colorSpace = SkColorSpace::MakeSRGB();
         }
         sk_sp<GrRenderTargetContext> tempRTC =
-                fContext->makeDeferredRenderTargetContext(tempDrawInfo.fTempSurfaceFit,
+                fContext->contextPriv().makeDeferredRenderTargetContext(
+                                                          tempDrawInfo.fTempSurfaceFit,
                                                           tempDrawInfo.fTempSurfaceDesc.fWidth,
                                                           tempDrawInfo.fTempSurfaceDesc.fHeight,
                                                           tempDrawInfo.fTempSurfaceDesc.fConfig,
@@ -1334,7 +1335,7 @@
     }
 }
 
-sk_sp<GrRenderTargetContext> GrContext::makeDeferredRenderTargetContextWithFallback(
+sk_sp<GrRenderTargetContext> GrContextPriv::makeDeferredRenderTargetContextWithFallback(
                                                                  SkBackingFit fit,
                                                                  int width, int height,
                                                                  GrPixelConfig config,
@@ -1345,7 +1346,7 @@
                                                                  const SkSurfaceProps* surfaceProps,
                                                                  SkBudgeted budgeted) {
     SkASSERT(sampleCnt > 0);
-    if (0 == this->caps()->getRenderTargetSampleCount(sampleCnt, config)) {
+    if (0 == fContext->caps()->getRenderTargetSampleCount(sampleCnt, config)) {
         config = GrPixelConfigFallback(config);
     }
 
@@ -1354,7 +1355,7 @@
                                                  budgeted);
 }
 
-sk_sp<GrRenderTargetContext> GrContext::makeDeferredRenderTargetContext(
+sk_sp<GrRenderTargetContext> GrContextPriv::makeDeferredRenderTargetContext(
                                                         SkBackingFit fit,
                                                         int width, int height,
                                                         GrPixelConfig config,
@@ -1378,18 +1379,18 @@
 
     sk_sp<GrTextureProxy> rtp;
     if (GrMipMapped::kNo == mipMapped) {
-        rtp = fProxyProvider->createProxy(desc, origin, fit, budgeted);
+        rtp = fContext->fProxyProvider->createProxy(desc, origin, fit, budgeted);
     } else {
-        rtp = fProxyProvider->createMipMapProxy(desc, origin, budgeted);
+        rtp = fContext->fProxyProvider->createMipMapProxy(desc, origin, budgeted);
     }
     if (!rtp) {
         return nullptr;
     }
 
     sk_sp<GrRenderTargetContext> renderTargetContext(
-        fDrawingManager->makeRenderTargetContext(std::move(rtp),
-                                                 std::move(colorSpace),
-                                                 surfaceProps));
+        fContext->fDrawingManager->makeRenderTargetContext(std::move(rtp),
+                                                           std::move(colorSpace),
+                                                           surfaceProps));
     if (!renderTargetContext) {
         return nullptr;
     }
@@ -1399,9 +1400,9 @@
     return renderTargetContext;
 }
 
-bool GrContext::abandoned() const {
-    ASSERT_SINGLE_OWNER
-    return fDrawingManager->wasAbandoned();
+bool GrContextPriv::abandoned() const {
+    ASSERT_SINGLE_OWNER_PRIV
+    return fContext->fDrawingManager->wasAbandoned();
 }
 
 std::unique_ptr<GrFragmentProcessor> GrContext::createPMToUPMEffect(
@@ -1470,7 +1471,6 @@
 }
 
 //////////////////////////////////////////////////////////////////////////////
-
 void GrContext::dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const {
     ASSERT_SINGLE_OWNER
     fResourceCache->dumpMemoryStatistics(traceMemoryDump);
@@ -1478,7 +1478,7 @@
 
 //////////////////////////////////////////////////////////////////////////////
 
-SkString GrContext::dump() const {
+SkString GrContextPriv::dump() const {
     SkDynamicMemoryWStream stream;
     SkJSONWriter writer(&stream, SkJSONWriter::Mode::kPretty);
     writer.beginObject();
@@ -1493,13 +1493,13 @@
     GR_STATIC_ASSERT(1 == kOpenGL_GrBackend);
     GR_STATIC_ASSERT(2 == kVulkan_GrBackend);
     GR_STATIC_ASSERT(3 == kMock_GrBackend);
-    writer.appendString("backend", kBackendStr[fBackend]);
+    writer.appendString("backend", kBackendStr[fContext->fBackend]);
 
     writer.appendName("caps");
-    fCaps->dumpJSON(&writer);
+    fContext->fCaps->dumpJSON(&writer);
 
     writer.appendName("gpu");
-    fGpu->dumpJSON(&writer);
+    fContext->fGpu->dumpJSON(&writer);
 
     // Flush JSON to the memory stream
     writer.endObject();
diff --git a/src/gpu/GrContextPriv.h b/src/gpu/GrContextPriv.h
index 0db572c..ebfe51a 100644
--- a/src/gpu/GrContextPriv.h
+++ b/src/gpu/GrContextPriv.h
@@ -204,6 +204,84 @@
     void moveOpListsToDDL(SkDeferredDisplayList*);
     void copyOpListsFromDDL(const SkDeferredDisplayList*, GrRenderTargetProxy* newDest);
 
+    /**
+     * Purge all the unlocked resources from the cache.
+     * This entry point is mainly meant for timing texture uploads
+     * and is not defined in normal builds of Skia.
+     */
+    void purgeAllUnlockedResources_ForTesting();
+
+
+    /*
+     * Create a new render target context backed by a deferred-style
+     * GrRenderTargetProxy. We guarantee that "asTextureProxy" will succeed for
+     * renderTargetContexts created via this entry point.
+     */
+    sk_sp<GrRenderTargetContext> makeDeferredRenderTargetContext(
+                                                 SkBackingFit fit,
+                                                 int width, int height,
+                                                 GrPixelConfig config,
+                                                 sk_sp<SkColorSpace> colorSpace,
+                                                 int sampleCnt = 1,
+                                                 GrMipMapped = GrMipMapped::kNo,
+                                                 GrSurfaceOrigin origin = kBottomLeft_GrSurfaceOrigin,
+                                                 const SkSurfaceProps* surfaceProps = nullptr,
+                                                 SkBudgeted = SkBudgeted::kYes);
+    /*
+     * This method will attempt to create a renderTargetContext that has, at least, the number of
+     * channels and precision per channel as requested in 'config' (e.g., A8 and 888 can be
+     * converted to 8888). It may also swizzle the channels (e.g., BGRA -> RGBA).
+     * SRGB-ness will be preserved.
+     */
+    sk_sp<GrRenderTargetContext> makeDeferredRenderTargetContextWithFallback(
+                                                 SkBackingFit fit,
+                                                 int width, int height,
+                                                 GrPixelConfig config,
+                                                 sk_sp<SkColorSpace> colorSpace,
+                                                 int sampleCnt = 1,
+                                                 GrMipMapped = GrMipMapped::kNo,
+                                                 GrSurfaceOrigin origin = kBottomLeft_GrSurfaceOrigin,
+                                                 const SkSurfaceProps* surfaceProps = nullptr,
+                                                 SkBudgeted budgeted = SkBudgeted::kYes);
+
+    bool abandoned() const;
+
+    /** Reset GPU stats */
+    void resetGpuStats() const ;
+
+    /** Prints cache stats to the string if GR_CACHE_STATS == 1. */
+    void dumpCacheStats(SkString*) const;
+    void dumpCacheStatsKeyValuePairs(SkTArray<SkString>* keys, SkTArray<double>* values) const;
+    void printCacheStats() const;
+
+    /** Prints GPU stats to the string if GR_GPU_STATS == 1. */
+    void dumpGpuStats(SkString*) const;
+    void dumpGpuStatsKeyValuePairs(SkTArray<SkString>* keys, SkTArray<double>* values) const;
+    void printGpuStats() const;
+
+    /** Returns a string with detailed information about the context & GPU, in JSON format. */
+    SkString dump() const;
+
+    /** Specify the TextBlob cache limit. If the current cache exceeds this limit it will purge.
+        this is for testing only */
+    void setTextBlobCacheLimit_ForTesting(size_t bytes);
+
+    /** Specify the sizes of the GrAtlasTextContext atlases.  The configs pointer below should be
+        to an array of 3 entries */
+    void setTextContextAtlasSizes_ForTesting(const GrDrawOpAtlasConfig* configs);
+
+    /** Get pointer to atlas texture for given mask format. Note that this wraps an
+        actively mutating texture in an SkImage. This could yield unexpected results
+        if it gets cached or used more generally. */
+    sk_sp<SkImage> getFontAtlasImage_ForTesting(GrMaskFormat format, unsigned int index = 0);
+
+    GrAuditTrail* getAuditTrail() { return &fContext->fAuditTrail; }
+
+    GrContextOptions::PersistentCache* getPersistentCache() { return fContext->fPersistentCache; }
+
+    /** This is only useful for debug purposes */
+    SkDEBUGCODE(GrSingleOwner* debugSingleOwner() const { return &fContext->fSingleOwner; } )
+
 private:
     explicit GrContextPriv(GrContext* context) : fContext(context) {}
     GrContextPriv(const GrContextPriv&); // unimpl
diff --git a/src/gpu/GrDrawingManager.cpp b/src/gpu/GrDrawingManager.cpp
index de6722f..62db98e 100644
--- a/src/gpu/GrDrawingManager.cpp
+++ b/src/gpu/GrDrawingManager.cpp
@@ -386,9 +386,10 @@
 
     auto resourceProvider = fContext->contextPriv().resourceProvider();
 
-    sk_sp<GrRenderTargetOpList> opList(new GrRenderTargetOpList(rtp,
-                                                                resourceProvider,
-                                                                fContext->getAuditTrail()));
+    sk_sp<GrRenderTargetOpList> opList(new GrRenderTargetOpList(
+                                                        rtp,
+                                                        resourceProvider,
+                                                        fContext->contextPriv().getAuditTrail()));
     SkASSERT(rtp->getLastOpList() == opList.get());
 
     if (managedOpList) {
@@ -410,7 +411,7 @@
 
     sk_sp<GrTextureOpList> opList(new GrTextureOpList(fContext->contextPriv().resourceProvider(),
                                                       textureProxy,
-                                                      fContext->getAuditTrail()));
+                                                      fContext->contextPriv().getAuditTrail()));
 
     SkASSERT(textureProxy->getLastOpList() == opList.get());
 
@@ -482,11 +483,12 @@
 
     sk_sp<GrRenderTargetProxy> rtp(sk_ref_sp(sProxy->asRenderTargetProxy()));
 
-    return sk_sp<GrRenderTargetContext>(new GrRenderTargetContext(fContext, this, std::move(rtp),
-                                                                  std::move(colorSpace),
-                                                                  surfaceProps,
-                                                                  fContext->getAuditTrail(),
-                                                                  fSingleOwner, managedOpList));
+    return sk_sp<GrRenderTargetContext>(new GrRenderTargetContext(
+                                                        fContext, this, std::move(rtp),
+                                                        std::move(colorSpace),
+                                                        surfaceProps,
+                                                        fContext->contextPriv().getAuditTrail(),
+                                                        fSingleOwner, managedOpList));
 }
 
 sk_sp<GrTextureContext> GrDrawingManager::makeTextureContext(sk_sp<GrSurfaceProxy> sProxy,
@@ -509,6 +511,6 @@
 
     return sk_sp<GrTextureContext>(new GrTextureContext(fContext, this, std::move(textureProxy),
                                                         std::move(colorSpace),
-                                                        fContext->getAuditTrail(),
+                                                        fContext->contextPriv().getAuditTrail(),
                                                         fSingleOwner));
 }
diff --git a/src/gpu/GrTextureProducer.cpp b/src/gpu/GrTextureProducer.cpp
index f1c8c8d..feee9dd 100644
--- a/src/gpu/GrTextureProducer.cpp
+++ b/src/gpu/GrTextureProducer.cpp
@@ -28,7 +28,8 @@
     if (GrPixelConfigIsSRGB(inputProxy->config())) {
         colorSpace = SkColorSpace::MakeSRGB();
     }
-    sk_sp<GrRenderTargetContext> copyRTC = context->makeDeferredRenderTargetContextWithFallback(
+    sk_sp<GrRenderTargetContext> copyRTC =
+        context->contextPriv().makeDeferredRenderTargetContextWithFallback(
             SkBackingFit::kExact, dstRect.width(), dstRect.height(), inputProxy->config(),
             std::move(colorSpace), 1, mipMapped, inputProxy->origin());
     if (!copyRTC) {
diff --git a/src/gpu/GrTracing.h b/src/gpu/GrTracing.h
index d4a49fd..6a8ded7 100644
--- a/src/gpu/GrTracing.h
+++ b/src/gpu/GrTracing.h
@@ -16,7 +16,7 @@
  * Context level GrTracing macros, classname and op are const char*, context is GrContext
  */
 #define GR_CREATE_TRACE_MARKER_CONTEXT(classname, op, context)               \
-    GR_AUDIT_TRAIL_AUTO_FRAME(context->getAuditTrail(), classname "::" op);  \
+    GR_AUDIT_TRAIL_AUTO_FRAME(context->contextPriv().getAuditTrail(), classname "::" op);  \
     TRACE_EVENT0("skia.gpu", classname "::" op);
 
 #endif
diff --git a/src/gpu/GrYUVProvider.cpp b/src/gpu/GrYUVProvider.cpp
index 01d46f6..bd66dba 100644
--- a/src/gpu/GrYUVProvider.cpp
+++ b/src/gpu/GrYUVProvider.cpp
@@ -116,7 +116,8 @@
         colorSpace = SkColorSpace::MakeSRGB();
     }
     // TODO: investigate preallocating mip maps here
-    sk_sp<GrRenderTargetContext> renderTargetContext(ctx->makeDeferredRenderTargetContext(
+    sk_sp<GrRenderTargetContext> renderTargetContext(
+        ctx->contextPriv().makeDeferredRenderTargetContext(
             SkBackingFit::kExact, desc.fWidth, desc.fHeight, desc.fConfig, std::move(colorSpace),
             desc.fSampleCnt, GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin));
     if (!renderTargetContext) {
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 2722292..e7ba14e 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -54,7 +54,7 @@
 #if SK_SUPPORT_GPU
 
 #define ASSERT_SINGLE_OWNER \
-    SkDEBUGCODE(GrSingleOwner::AutoEnforce debug_SingleOwner(fContext->debugSingleOwner());)
+SkDEBUGCODE(GrSingleOwner::AutoEnforce debug_SingleOwner(fContext->contextPriv().debugSingleOwner());)
 
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -164,7 +164,7 @@
     }
     // This method is used to create SkGpuDevice's for SkSurface_Gpus. In this case
     // they need to be exact.
-    return context->makeDeferredRenderTargetContext(
+    return context->contextPriv().makeDeferredRenderTargetContext(
                                     SkBackingFit::kExact,
                                     origInfo.width(), origInfo.height(),
                                     config, origInfo.refColorSpace(), sampleCount,
@@ -1048,7 +1048,7 @@
     ASSERT_SINGLE_OWNER
     GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawSprite", fContext.get());
 
-    if (fContext->abandoned()) {
+    if (fContext->contextPriv().abandoned()) {
         return;
     }
 
@@ -1720,7 +1720,7 @@
         config = kRGBA_8888_GrPixelConfig;
     }
 
-    sk_sp<GrRenderTargetContext> rtc(fContext->makeDeferredRenderTargetContext(
+    sk_sp<GrRenderTargetContext> rtc(fContext->contextPriv().makeDeferredRenderTargetContext(
             fit, cinfo.fInfo.width(), cinfo.fInfo.height(), config,
             fRenderTargetContext->colorSpaceInfo().refColorSpace(),
             fRenderTargetContext->numStencilSamples(), GrMipMapped::kNo,
diff --git a/src/gpu/effects/GrConfigConversionEffect.h b/src/gpu/effects/GrConfigConversionEffect.h
index 40bbc97..0b5a205 100644
--- a/src/gpu/effects/GrConfigConversionEffect.h
+++ b/src/gpu/effects/GrConfigConversionEffect.h
@@ -46,9 +46,9 @@
         const SkImageInfo ii =
                 SkImageInfo::Make(kSize, kSize, kRGBA_8888_SkColorType, kPremul_SkAlphaType);
 
-        sk_sp<GrRenderTargetContext> readRTC(context->makeDeferredRenderTargetContext(
+        sk_sp<GrRenderTargetContext> readRTC(context->contextPriv().makeDeferredRenderTargetContext(
                 SkBackingFit::kExact, kSize, kSize, kConfig, nullptr));
-        sk_sp<GrRenderTargetContext> tempRTC(context->makeDeferredRenderTargetContext(
+        sk_sp<GrRenderTargetContext> tempRTC(context->contextPriv().makeDeferredRenderTargetContext(
                 SkBackingFit::kExact, kSize, kSize, kConfig, nullptr));
         if (!readRTC || !readRTC->asTextureProxy() || !tempRTC) {
             return false;
diff --git a/src/gpu/effects/GrRRectBlurEffect.h b/src/gpu/effects/GrRRectBlurEffect.h
index 7ba02c7..0e63a92 100644
--- a/src/gpu/effects/GrRRectBlurEffect.h
+++ b/src/gpu/effects/GrRRectBlurEffect.h
@@ -52,7 +52,8 @@
                 proxyProvider->findOrCreateProxyByUniqueKey(key, kBottomLeft_GrSurfaceOrigin));
         if (!mask) {
             // TODO: this could be approx but the texture coords will need to be updated
-            sk_sp<GrRenderTargetContext> rtc(context->makeDeferredRenderTargetContextWithFallback(
+            sk_sp<GrRenderTargetContext> rtc(
+                context->contextPriv().makeDeferredRenderTargetContextWithFallback(
                     SkBackingFit::kExact, size.fWidth, size.fHeight, kAlpha_8_GrPixelConfig,
                     nullptr));
             if (!rtc) {
diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.cpp b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
index ed6386b..7ca7506 100644
--- a/src/gpu/gl/builders/GrGLProgramBuilder.cpp
+++ b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
@@ -46,9 +46,10 @@
     // uniforms, varyings, textures, etc
     GrGLProgramBuilder builder(gpu, pipeline, primProc, desc);
 
-    if (gpu->getContext()->getPersistentCache() && gpu->glCaps().programBinarySupport()) {
+    auto persistentCache = gpu->getContext()->contextPriv().getPersistentCache();
+    if (persistentCache && gpu->glCaps().programBinarySupport()) {
         sk_sp<SkData> key = SkData::MakeWithoutCopy(desc->asKey(), desc->keyLength());
-        builder.fCached = gpu->getContext()->getPersistentCache()->load(*key);
+        builder.fCached = persistentCache->load(*key);
         // the eventual end goal is to completely skip emitAndInstallProcs on a cache hit, but it's
         // doing necessary setup in addition to generating the SkSL code. Currently we are only able
         // to skip the SkSL->GLSL step on a cache hit.
@@ -141,7 +142,7 @@
     }
 
     if (this->gpu()->glCaps().programBinarySupport() &&
-        this->gpu()->getContext()->getPersistentCache()) {
+        this->gpu()->getContext()->contextPriv().getPersistentCache()) {
         GL_CALL(ProgramParameteri(programID, GR_GL_PROGRAM_BINARY_RETRIEVABLE_HINT, GR_GL_TRUE));
     }
 
@@ -267,7 +268,7 @@
     this->resolveProgramResourceLocations(programID);
 
     this->cleanupShaders(shadersToDelete);
-    if (!cached && this->gpu()->getContext()->getPersistentCache() &&
+    if (!cached && this->gpu()->getContext()->contextPriv().getPersistentCache() &&
         fGpu->glCaps().programBinarySupport()) {
         GrGLsizei length = 0;
         GL_CALL(GetProgramiv(programID, GL_PROGRAM_BINARY_LENGTH, &length));
@@ -285,8 +286,8 @@
             memcpy(data.get() + offset, &binaryFormat, sizeof(binaryFormat));
             offset += sizeof(binaryFormat);
             memcpy(data.get() + offset, binary.get(), length);
-            this->gpu()->getContext()->getPersistentCache()->store(*key,
-                                                  *SkData::MakeWithoutCopy(data.get(), dataLength));
+            this->gpu()->getContext()->contextPriv().getPersistentCache()->store(
+                                            *key, *SkData::MakeWithoutCopy(data.get(), dataLength));
         }
     }
     return this->createProgram(programID);
diff --git a/src/gpu/text/GrAtlasTextContext.cpp b/src/gpu/text/GrAtlasTextContext.cpp
index 4a10e10..6ebd02c 100644
--- a/src/gpu/text/GrAtlasTextContext.cpp
+++ b/src/gpu/text/GrAtlasTextContext.cpp
@@ -103,7 +103,7 @@
                                       const SkTextBlob* blob, SkScalar x, SkScalar y,
                                       SkDrawFilter* drawFilter, const SkIRect& clipBounds) {
     // If we have been abandoned, then don't draw
-    if (context->abandoned()) {
+    if (context->contextPriv().abandoned()) {
         return;
     }
 
@@ -317,7 +317,7 @@
                                   const SkMatrix& viewMatrix, const SkSurfaceProps& props,
                                   const char text[], size_t byteLength, SkScalar x, SkScalar y,
                                   const SkIRect& regionClipBounds) {
-    if (context->abandoned()) {
+    if (context->contextPriv().abandoned()) {
         return;
     }
 
@@ -344,7 +344,7 @@
                                      int scalarsPerPosition, const SkPoint& offset,
                                      const SkIRect& regionClipBounds) {
     GrTextUtils::Paint paint(&skPaint, &target->colorSpaceInfo());
-    if (context->abandoned()) {
+    if (context->contextPriv().abandoned()) {
         return;
     }
 
@@ -939,7 +939,7 @@
     }
 
     // Setup dummy SkPaint / GrPaint / GrRenderTargetContext
-    sk_sp<GrRenderTargetContext> rtc(context->makeDeferredRenderTargetContext(
+    sk_sp<GrRenderTargetContext> rtc(context->contextPriv().makeDeferredRenderTargetContext(
         SkBackingFit::kApprox, 1024, 1024, kRGBA_8888_GrPixelConfig, nullptr));
 
     SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random);
diff --git a/src/image/SkImage.cpp b/src/image/SkImage.cpp
index 2337a36..7b90d6e 100644
--- a/src/image/SkImage.cpp
+++ b/src/image/SkImage.cpp
@@ -164,7 +164,7 @@
 }
 
 bool SkImage::isValid(GrContext* context) const {
-    if (context && context->abandoned()) {
+    if (context && context->contextPriv().abandoned()) {
         return false;
     }
     return as_IB(this)->onIsValid(context);
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp
index 1ce53c6..0ba3f03 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -441,9 +441,10 @@
     const int height = yuvSizes[0].fHeight;
 
     // Needs to be a render target in order to draw to it for the yuv->rgb conversion.
-    sk_sp<GrRenderTargetContext> renderTargetContext(ctx->makeDeferredRenderTargetContext(
-            SkBackingFit::kExact, width, height, kRGBA_8888_GrPixelConfig,
-            std::move(imageColorSpace), 1, GrMipMapped::kNo, origin));
+    sk_sp<GrRenderTargetContext> renderTargetContext(
+            ctx->contextPriv().makeDeferredRenderTargetContext(
+                                SkBackingFit::kExact, width, height, kRGBA_8888_GrPixelConfig,
+                                std::move(imageColorSpace), 1, GrMipMapped::kNo, origin));
     if (!renderTargetContext) {
         return nullptr;
     }
@@ -766,8 +767,10 @@
         return sk_ref_sp(const_cast<SkImage_Gpu*>(this));
     }
 
-    sk_sp<GrRenderTargetContext> renderTargetContext(fContext->makeDeferredRenderTargetContext(
-        SkBackingFit::kExact, this->width(), this->height(), kRGBA_8888_GrPixelConfig, nullptr));
+    sk_sp<GrRenderTargetContext> renderTargetContext(
+            fContext->contextPriv().makeDeferredRenderTargetContext(
+                                            SkBackingFit::kExact, this->width(), this->height(),
+                                            kRGBA_8888_GrPixelConfig, nullptr));
     if (!renderTargetContext) {
         return nullptr;
     }
@@ -794,7 +797,7 @@
 
 bool SkImage_Gpu::onIsValid(GrContext* context) const {
     // The base class has already checked that context isn't abandoned (if it's not nullptr)
-    if (fContext->abandoned()) {
+    if (fContext->contextPriv().abandoned()) {
         return false;
     }
 
diff --git a/tests/ClearTest.cpp b/tests/ClearTest.cpp
index 7424c5a..429b9e1 100644
--- a/tests/ClearTest.cpp
+++ b/tests/ClearTest.cpp
@@ -42,8 +42,9 @@
 }
 
 sk_sp<GrRenderTargetContext> newRTC(GrContext* context, int w, int h) {
-    return context->makeDeferredRenderTargetContext(SkBackingFit::kExact, w, h,
-                                                    kRGBA_8888_GrPixelConfig, nullptr);
+    return context->contextPriv().makeDeferredRenderTargetContext(
+                                                                SkBackingFit::kExact, w, h,
+                                                                kRGBA_8888_GrPixelConfig, nullptr);
 }
 
 static void clear_op_test(skiatest::Reporter* reporter, GrContext* context) {
diff --git a/tests/DefaultPathRendererTest.cpp b/tests/DefaultPathRendererTest.cpp
index 1764611..155d6a7 100644
--- a/tests/DefaultPathRendererTest.cpp
+++ b/tests/DefaultPathRendererTest.cpp
@@ -68,7 +68,8 @@
     GrStyle style(SkStrokeRec::kFill_InitStyle);
 
     {
-        auto rtc =  ctx->makeDeferredRenderTargetContext(SkBackingFit::kApprox,
+        auto rtc =  ctx->contextPriv().makeDeferredRenderTargetContext(
+                                                         SkBackingFit::kApprox,
                                                          kBigSize/2+1, kBigSize/2+1,
                                                          kRGBA_8888_GrPixelConfig, nullptr);
 
@@ -88,7 +89,8 @@
     }
 
     {
-        auto rtc = ctx->makeDeferredRenderTargetContext(SkBackingFit::kExact, kBigSize, kBigSize,
+        auto rtc = ctx->contextPriv().makeDeferredRenderTargetContext(
+                                                        SkBackingFit::kExact, kBigSize, kBigSize,
                                                         kRGBA_8888_GrPixelConfig, nullptr);
 
         rtc->clear(nullptr, GrColorPackRGBA(0x0, 0x0, 0x0, 0xFF),
diff --git a/tests/GLProgramsTest.cpp b/tests/GLProgramsTest.cpp
index 1384e38..e3639fb 100644
--- a/tests/GLProgramsTest.cpp
+++ b/tests/GLProgramsTest.cpp
@@ -155,15 +155,15 @@
     // Above could be 0 if msaa isn't supported.
     sampleCnt = SkTMax(1, sampleCnt);
 
-    sk_sp<GrRenderTargetContext> renderTargetContext(context->makeDeferredRenderTargetContext(
-                                                                           SkBackingFit::kExact,
-                                                                           kRenderTargetWidth,
-                                                                           kRenderTargetHeight,
-                                                                           kRGBA_8888_GrPixelConfig,
-                                                                           nullptr,
-                                                                           sampleCnt,
-                                                                           GrMipMapped::kNo,
-                                                                           origin));
+    sk_sp<GrRenderTargetContext> renderTargetContext(
+        context->contextPriv().makeDeferredRenderTargetContext(SkBackingFit::kExact,
+                                                               kRenderTargetWidth,
+                                                               kRenderTargetHeight,
+                                                               kRGBA_8888_GrPixelConfig,
+                                                               nullptr,
+                                                               sampleCnt,
+                                                               GrMipMapped::kNo,
+                                                               origin));
     return renderTargetContext;
 }
 
@@ -318,12 +318,12 @@
     drawingManager->flush(nullptr);
 
     // Validate that GrFPs work correctly without an input.
-    sk_sp<GrRenderTargetContext> renderTargetContext(context->makeDeferredRenderTargetContext(
-                                                                           SkBackingFit::kExact,
-                                                                           kRenderTargetWidth,
-                                                                           kRenderTargetHeight,
-                                                                           kRGBA_8888_GrPixelConfig,
-                                                                           nullptr));
+    sk_sp<GrRenderTargetContext> renderTargetContext(
+                 context->contextPriv().makeDeferredRenderTargetContext(SkBackingFit::kExact,
+                                                                        kRenderTargetWidth,
+                                                                        kRenderTargetHeight,
+                                                                        kRGBA_8888_GrPixelConfig,
+                                                                        nullptr));
     if (!renderTargetContext) {
         SkDebugf("Could not allocate a renderTargetContext");
         return false;
diff --git a/tests/GrCCPRTest.cpp b/tests/GrCCPRTest.cpp
index cba94b4..2a51c1b 100644
--- a/tests/GrCCPRTest.cpp
+++ b/tests/GrCCPRTest.cpp
@@ -59,7 +59,8 @@
     CCPRPathDrawer(GrContext* ctx, skiatest::Reporter* reporter)
             : fCtx(ctx)
             , fCCPR(fCtx->contextPriv().drawingManager()->getCoverageCountingPathRenderer())
-            , fRTC(fCtx->makeDeferredRenderTargetContext(SkBackingFit::kExact, kCanvasSize,
+            , fRTC(fCtx->contextPriv().makeDeferredRenderTargetContext(
+                                                         SkBackingFit::kExact, kCanvasSize,
                                                          kCanvasSize, kRGBA_8888_GrPixelConfig,
                                                          nullptr)) {
         if (!fCCPR) {
diff --git a/tests/GrContextFactoryTest.cpp b/tests/GrContextFactoryTest.cpp
index 29f6836..bebfd4d 100644
--- a/tests/GrContextFactoryTest.cpp
+++ b/tests/GrContextFactoryTest.cpp
@@ -166,7 +166,7 @@
 
 DEF_GPUTEST_FOR_ALL_CONTEXTS(GrContextDump, reporter, ctxInfo) {
     // Ensure that GrContext::dump doesn't assert (which is possible, if the JSON code is wrong)
-    SkString result = ctxInfo.grContext()->dump();
+    SkString result = ctxInfo.grContext()->contextPriv().dump();
     REPORTER_ASSERT(reporter, !result.isEmpty());
 }
 
diff --git a/tests/GrMeshTest.cpp b/tests/GrMeshTest.cpp
index acac61b..80788dd 100644
--- a/tests/GrMeshTest.cpp
+++ b/tests/GrMeshTest.cpp
@@ -82,8 +82,8 @@
 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrMeshTest, reporter, ctxInfo) {
     GrContext* const context = ctxInfo.grContext();
 
-    sk_sp<GrRenderTargetContext> rtc(
-        context->makeDeferredRenderTargetContext(SkBackingFit::kExact, kImageWidth, kImageHeight,
+    sk_sp<GrRenderTargetContext> rtc(context->contextPriv().makeDeferredRenderTargetContext(
+                                                 SkBackingFit::kExact, kImageWidth, kImageHeight,
                                                  kRGBA_8888_GrPixelConfig, nullptr));
     if (!rtc) {
         ERRORF(reporter, "could not create render target context.");
diff --git a/tests/GrPipelineDynamicStateTest.cpp b/tests/GrPipelineDynamicStateTest.cpp
index f715684..7db0d94 100644
--- a/tests/GrPipelineDynamicStateTest.cpp
+++ b/tests/GrPipelineDynamicStateTest.cpp
@@ -148,8 +148,8 @@
     GrContext* const context = ctxInfo.grContext();
     GrResourceProvider* rp = context->contextPriv().resourceProvider();
 
-    sk_sp<GrRenderTargetContext> rtc(
-        context->makeDeferredRenderTargetContext(SkBackingFit::kExact, kScreenSize, kScreenSize,
+    sk_sp<GrRenderTargetContext> rtc(context->contextPriv().makeDeferredRenderTargetContext(
+                                                 SkBackingFit::kExact, kScreenSize, kScreenSize,
                                                  kRGBA_8888_GrPixelConfig, nullptr));
     if (!rtc) {
         ERRORF(reporter, "could not create render target context.");
diff --git a/tests/GrSurfaceTest.cpp b/tests/GrSurfaceTest.cpp
index daef511..18c0275 100644
--- a/tests/GrSurfaceTest.cpp
+++ b/tests/GrSurfaceTest.cpp
@@ -197,7 +197,7 @@
                             texCtx->writePixels(info, data.get(), 0, 0, 0);
                         }
                     }
-                    context->purgeAllUnlockedResources();
+                    context->contextPriv().purgeAllUnlockedResources_ForTesting();
 
                     // Try creating the texture as a deferred proxy.
                     for (int i = 0; i < 2; ++i) {
@@ -224,7 +224,7 @@
                             surfCtx->writePixels(info, data.get(), 0, 0, 0);
                         }
                     }
-                    context->purgeAllUnlockedResources();
+                    context->contextPriv().purgeAllUnlockedResources_ForTesting();
                 }
             }
         }
diff --git a/tests/LazyProxyTest.cpp b/tests/LazyProxyTest.cpp
index da83dcb..9253678 100644
--- a/tests/LazyProxyTest.cpp
+++ b/tests/LazyProxyTest.cpp
@@ -187,12 +187,12 @@
     for (bool nullTexture : {false, true}) {
         LazyProxyTest test(reporter);
         ctx->contextPriv().addOnFlushCallbackObject(&test);
-        sk_sp<GrRenderTargetContext> rtc =
-                ctx->makeDeferredRenderTargetContext(SkBackingFit::kExact, 100, 100,
-                                                     kRGBA_8888_GrPixelConfig, nullptr);
+        sk_sp<GrRenderTargetContext> rtc = ctx->contextPriv().makeDeferredRenderTargetContext(
+                                                             SkBackingFit::kExact, 100, 100,
+                                                             kRGBA_8888_GrPixelConfig, nullptr);
         REPORTER_ASSERT(reporter, rtc);
-        sk_sp<GrRenderTargetContext> mockAtlas =
-                ctx->makeDeferredRenderTargetContext(SkBackingFit::kExact, 10, 10,
+        sk_sp<GrRenderTargetContext> mockAtlas = ctx->contextPriv().makeDeferredRenderTargetContext(
+                                                     SkBackingFit::kExact, 10, 10,
                                                      kAlpha_half_GrPixelConfig, nullptr);
         REPORTER_ASSERT(reporter, mockAtlas);
         rtc->priv().testingOnly_addDrawOp(LazyProxyTest::Clip(&test, mockAtlas->asTextureProxy()),
@@ -316,8 +316,8 @@
     GrResourceProvider* resourceProvider = ctx->contextPriv().resourceProvider();
     GrProxyProvider* proxyProvider = ctx->contextPriv().proxyProvider();
     for (bool failInstantiation : {false, true}) {
-        sk_sp<GrRenderTargetContext> rtc =
-                ctx->makeDeferredRenderTargetContext(SkBackingFit::kExact, 100, 100,
+        sk_sp<GrRenderTargetContext> rtc = ctx->contextPriv().makeDeferredRenderTargetContext(
+                                                     SkBackingFit::kExact, 100, 100,
                                                      kRGBA_8888_GrPixelConfig, nullptr);
         REPORTER_ASSERT(reporter, rtc);
 
diff --git a/tests/OnFlushCallbackTest.cpp b/tests/OnFlushCallbackTest.cpp
index 5cd3bcd..73ac5f1 100644
--- a/tests/OnFlushCallbackTest.cpp
+++ b/tests/OnFlushCallbackTest.cpp
@@ -421,7 +421,7 @@
 // This creates an off-screen rendertarget whose ops which eventually pull from the atlas.
 static sk_sp<GrTextureProxy> make_upstream_image(GrContext* context, AtlasObject* object, int start,
                                                  sk_sp<GrTextureProxy> atlasProxy) {
-    sk_sp<GrRenderTargetContext> rtc(context->makeDeferredRenderTargetContext(
+    sk_sp<GrRenderTargetContext> rtc(context->contextPriv().makeDeferredRenderTargetContext(
                                                                       SkBackingFit::kApprox,
                                                                       3*kDrawnTileSize,
                                                                       kDrawnTileSize,
@@ -535,7 +535,7 @@
     static const int kFinalWidth = 6*kDrawnTileSize;
     static const int kFinalHeight = kDrawnTileSize;
 
-    sk_sp<GrRenderTargetContext> rtc(context->makeDeferredRenderTargetContext(
+    sk_sp<GrRenderTargetContext> rtc(context->contextPriv().makeDeferredRenderTargetContext(
                                                                       SkBackingFit::kApprox,
                                                                       kFinalWidth,
                                                                       kFinalHeight,
diff --git a/tests/PathRendererCacheTests.cpp b/tests/PathRendererCacheTests.cpp
index 19197b0..f8c95b3 100644
--- a/tests/PathRendererCacheTests.cpp
+++ b/tests/PathRendererCacheTests.cpp
@@ -79,7 +79,7 @@
     ctx->setResourceCacheLimits(100, 8000000);
     GrResourceCache* cache = ctx->contextPriv().getResourceCache();
 
-    sk_sp<GrRenderTargetContext> rtc(ctx->makeDeferredRenderTargetContext(
+    sk_sp<GrRenderTargetContext> rtc(ctx->contextPriv().makeDeferredRenderTargetContext(
             SkBackingFit::kApprox, 800, 800, kRGBA_8888_GrPixelConfig, nullptr, 1, GrMipMapped::kNo,
             kTopLeft_GrSurfaceOrigin));
     if (!rtc) {
diff --git a/tests/PrimitiveProcessorTest.cpp b/tests/PrimitiveProcessorTest.cpp
index 089d6ce..b5f508b 100644
--- a/tests/PrimitiveProcessorTest.cpp
+++ b/tests/PrimitiveProcessorTest.cpp
@@ -115,10 +115,10 @@
     GrGpu* gpu = context->contextPriv().getGpu();
 #endif
 
-    sk_sp<GrRenderTargetContext> renderTargetContext(context->makeDeferredRenderTargetContext(
-                                                                     SkBackingFit::kApprox,
-                                                                     1, 1, kRGBA_8888_GrPixelConfig,
-                                                                     nullptr));
+    sk_sp<GrRenderTargetContext> renderTargetContext(
+            context->contextPriv().makeDeferredRenderTargetContext(SkBackingFit::kApprox,
+                                                                   1, 1, kRGBA_8888_GrPixelConfig,
+                                                                   nullptr));
     if (!renderTargetContext) {
         ERRORF(reporter, "Could not create render target context.");
         return;
@@ -129,7 +129,7 @@
         return;
     }
     context->flush();
-    context->resetGpuStats();
+    context->contextPriv().resetGpuStats();
 #if GR_GPU_STATS
     REPORTER_ASSERT(reporter, gpu->stats()->numDraws() == 0);
     REPORTER_ASSERT(reporter, gpu->stats()->numFailedDraws() == 0);
@@ -145,7 +145,7 @@
     REPORTER_ASSERT(reporter, gpu->stats()->numDraws() == 1);
     REPORTER_ASSERT(reporter, gpu->stats()->numFailedDraws() == 0);
 #endif
-    context->resetGpuStats();
+    context->contextPriv().resetGpuStats();
     renderTargetContext->priv().testingOnly_addDrawOp(Op::Make(attribCnt + 1));
     context->flush();
 #if GR_GPU_STATS
diff --git a/tests/ProcessorTest.cpp b/tests/ProcessorTest.cpp
index aea5208..2694bca 100644
--- a/tests/ProcessorTest.cpp
+++ b/tests/ProcessorTest.cpp
@@ -168,7 +168,8 @@
     for (bool makeClone : {false, true}) {
         for (int parentCnt = 0; parentCnt < 2; parentCnt++) {
             sk_sp<GrRenderTargetContext> renderTargetContext(
-                    context->makeDeferredRenderTargetContext(SkBackingFit::kApprox, 1, 1,
+                    context->contextPriv().makeDeferredRenderTargetContext(
+                                                             SkBackingFit::kApprox, 1, 1,
                                                              kRGBA_8888_GrPixelConfig, nullptr));
             {
                 bool texelBufferSupport = context->caps()->shaderCaps()->texelBufferSupport();
@@ -365,7 +366,7 @@
 
     // Make the destination context for the test.
     static constexpr int kRenderSize = 256;
-    sk_sp<GrRenderTargetContext> rtc = context->makeDeferredRenderTargetContext(
+    sk_sp<GrRenderTargetContext> rtc = context->contextPriv().makeDeferredRenderTargetContext(
             SkBackingFit::kExact, kRenderSize, kRenderSize, kRGBA_8888_GrPixelConfig, nullptr);
 
     sk_sp<GrTextureProxy> proxies[2];
@@ -497,7 +498,7 @@
 
     // Make the destination context for the test.
     static constexpr int kRenderSize = 1024;
-    sk_sp<GrRenderTargetContext> rtc = context->makeDeferredRenderTargetContext(
+    sk_sp<GrRenderTargetContext> rtc = context->contextPriv().makeDeferredRenderTargetContext(
             SkBackingFit::kExact, kRenderSize, kRenderSize, kRGBA_8888_GrPixelConfig, nullptr);
 
     sk_sp<GrTextureProxy> proxies[2];
diff --git a/tests/RectangleTextureTest.cpp b/tests/RectangleTextureTest.cpp
index 8994f56..08cedd0 100644
--- a/tests/RectangleTextureTest.cpp
+++ b/tests/RectangleTextureTest.cpp
@@ -22,8 +22,8 @@
 // skbug.com/5932
 static void test_basic_draw_as_src(skiatest::Reporter* reporter, GrContext* context,
                                    sk_sp<GrTextureProxy> rectProxy, uint32_t expectedPixelValues[]) {
-    sk_sp<GrRenderTargetContext> rtContext(
-            context->makeDeferredRenderTargetContext(SkBackingFit::kExact, rectProxy->width(),
+    sk_sp<GrRenderTargetContext> rtContext(context->contextPriv().makeDeferredRenderTargetContext(
+                                                     SkBackingFit::kExact, rectProxy->width(),
                                                      rectProxy->height(), rectProxy->config(),
                                                      nullptr));
     for (auto filter : {GrSamplerState::Filter::kNearest,
diff --git a/tests/ResourceCacheTest.cpp b/tests/ResourceCacheTest.cpp
index 55f4f85..2ceb567 100644
--- a/tests/ResourceCacheTest.cpp
+++ b/tests/ResourceCacheTest.cpp
@@ -1465,7 +1465,7 @@
         };
 
         // ensure all are purged before the next
-        context->purgeAllUnlockedResources();
+        context->contextPriv().purgeAllUnlockedResources_ForTesting();
         REPORTER_ASSERT(reporter, 0 == cache->getBudgetedResourceCount());
         REPORTER_ASSERT(reporter, 0 == cache->getPurgeableBytes());
 
diff --git a/tests/SRGBMipMapTest.cpp b/tests/SRGBMipMapTest.cpp
index 466aad2..91294de 100644
--- a/tests/SRGBMipMapTest.cpp
+++ b/tests/SRGBMipMapTest.cpp
@@ -136,10 +136,14 @@
 
     // Create two render target contexts (L32 and S32)
     sk_sp<SkColorSpace> srgbColorSpace = SkColorSpace::MakeSRGB();
-    sk_sp<GrRenderTargetContext> l32RenderTargetContext = context->makeDeferredRenderTargetContext(
-        SkBackingFit::kExact, rtS, rtS, kRGBA_8888_GrPixelConfig, nullptr);
-    sk_sp<GrRenderTargetContext> s32RenderTargetContext = context->makeDeferredRenderTargetContext(
-        SkBackingFit::kExact, rtS, rtS, kSRGBA_8888_GrPixelConfig, std::move(srgbColorSpace));
+    sk_sp<GrRenderTargetContext> l32RenderTargetContext =
+            context->contextPriv().makeDeferredRenderTargetContext(
+                                        SkBackingFit::kExact, rtS, rtS,
+                                        kRGBA_8888_GrPixelConfig, nullptr);
+    sk_sp<GrRenderTargetContext> s32RenderTargetContext =
+            context->contextPriv().makeDeferredRenderTargetContext(
+                                        SkBackingFit::kExact, rtS, rtS,
+                                        kSRGBA_8888_GrPixelConfig, std::move(srgbColorSpace));
 
     SkRect rect = SkRect::MakeWH(SkIntToScalar(rtS), SkIntToScalar(rtS));
     GrNoClip noClip;
diff --git a/tests/TessellatingPathRendererTests.cpp b/tests/TessellatingPathRendererTests.cpp
index f6304f5..4513917 100644
--- a/tests/TessellatingPathRendererTests.cpp
+++ b/tests/TessellatingPathRendererTests.cpp
@@ -485,7 +485,7 @@
 
 DEF_GPUTEST_FOR_ALL_CONTEXTS(TessellatingPathRendererTests, reporter, ctxInfo) {
     GrContext* ctx = ctxInfo.grContext();
-    sk_sp<GrRenderTargetContext> rtc(ctx->makeDeferredRenderTargetContext(
+    sk_sp<GrRenderTargetContext> rtc(ctx->contextPriv().makeDeferredRenderTargetContext(
             SkBackingFit::kApprox, 800, 800, kRGBA_8888_GrPixelConfig, nullptr, 1, GrMipMapped::kNo,
             kTopLeft_GrSurfaceOrigin));
     if (!rtc) {
diff --git a/tests/TextBlobCacheTest.cpp b/tests/TextBlobCacheTest.cpp
index bd74301..4d606c9 100644
--- a/tests/TextBlobCacheTest.cpp
+++ b/tests/TextBlobCacheTest.cpp
@@ -25,6 +25,7 @@
 
 #if SK_SUPPORT_GPU
 #include "GrContext.h"
+#include "GrContextPriv.h"
 #include "GrTest.h"
 
 static void draw(SkCanvas* canvas, int redraw, const SkTArray<sk_sp<SkTextBlob>>& blobs) {
@@ -54,7 +55,7 @@
     // configure our context for maximum stressing of cache and atlas
     if (stressTest) {
         GrTest::SetupAlwaysEvictAtlas(context);
-        context->setTextBlobCacheLimit_ForTesting(0);
+        context->contextPriv().setTextBlobCacheLimit_ForTesting(0);
     }
 
     SkImageInfo info = SkImageInfo::Make(kWidth, kHeight, kN32_SkColorType, kPremul_SkAlphaType);
diff --git a/tests/TextureProxyTest.cpp b/tests/TextureProxyTest.cpp
index 8d0df6f..0c93977 100644
--- a/tests/TextureProxyTest.cpp
+++ b/tests/TextureProxyTest.cpp
@@ -232,7 +232,7 @@
     REPORTER_ASSERT(reporter, 1 == cache->getResourceCount());
 
     textureImg = nullptr;
-    context->purgeAllUnlockedResources();
+    context->contextPriv().purgeAllUnlockedResources_ForTesting();
 
     REPORTER_ASSERT(reporter, 0 == proxyProvider->numUniqueKeyProxies_TestOnly());
     REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
@@ -271,7 +271,7 @@
     REPORTER_ASSERT(reporter, 1 == cache->getResourceCount());
 
     proxy = nullptr;
-    context->purgeAllUnlockedResources();
+    context->contextPriv().purgeAllUnlockedResources_ForTesting();
 
     REPORTER_ASSERT(reporter, 0 == proxyProvider->numUniqueKeyProxies_TestOnly());
     REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
diff --git a/tools/debugger/SkDebugCanvas.cpp b/tools/debugger/SkDebugCanvas.cpp
index 0bfd85f..d2dddb8 100644
--- a/tools/debugger/SkDebugCanvas.cpp
+++ b/tools/debugger/SkDebugCanvas.cpp
@@ -363,7 +363,7 @@
 #if SK_SUPPORT_GPU
     GrContext* ctx = canvas->getGrContext();
     if (ctx) {
-        at = ctx->getAuditTrail();
+        at = ctx->contextPriv().getAuditTrail();
     }
 #endif
     return at;
diff --git a/tools/gpu/GrTest.cpp b/tools/gpu/GrTest.cpp
index 241bbc2..3e9f73a 100644
--- a/tools/gpu/GrTest.cpp
+++ b/tools/gpu/GrTest.cpp
@@ -51,7 +51,7 @@
     configs[kARGB_GrMaskFormat].fPlotWidth = dim;
     configs[kARGB_GrMaskFormat].fPlotHeight = dim;
 
-    context->setTextContextAtlasSizes_ForTesting(configs);
+    context->contextPriv().setTextContextAtlasSizes_ForTesting(configs);
 }
 
 GrBackendTexture CreateBackendTexture(GrBackend backend, int width, int height,
@@ -89,12 +89,12 @@
     return fRenderTargetProxy->isWrapped_ForTesting();
 }
 
-void GrContext::setTextBlobCacheLimit_ForTesting(size_t bytes) {
-    fTextBlobCache->setBudget(bytes);
+void GrContextPriv::setTextBlobCacheLimit_ForTesting(size_t bytes) {
+    fContext->fTextBlobCache->setBudget(bytes);
 }
 
-void GrContext::setTextContextAtlasSizes_ForTesting(const GrDrawOpAtlasConfig* configs) {
-    GrAtlasManager* atlasManager = this->contextPriv().getFullAtlasManager();
+void GrContextPriv::setTextContextAtlasSizes_ForTesting(const GrDrawOpAtlasConfig* configs) {
+    GrAtlasManager* atlasManager = this->getFullAtlasManager();
     if (atlasManager) {
         atlasManager->setAtlasSizes_ForTesting(configs);
     }
@@ -102,56 +102,56 @@
 
 ///////////////////////////////////////////////////////////////////////////////
 
-void GrContext::purgeAllUnlockedResources() {
-    fResourceCache->purgeAllUnlocked();
+void GrContextPriv::purgeAllUnlockedResources_ForTesting() {
+    fContext->fResourceCache->purgeAllUnlocked();
 }
 
-void GrContext::resetGpuStats() const {
+void GrContextPriv::resetGpuStats() const {
 #if GR_GPU_STATS
-    fGpu->stats()->reset();
+    fContext->fGpu->stats()->reset();
 #endif
 }
 
-void GrContext::dumpCacheStats(SkString* out) const {
+void GrContextPriv::dumpCacheStats(SkString* out) const {
 #if GR_CACHE_STATS
-    fResourceCache->dumpStats(out);
+    fContext->fResourceCache->dumpStats(out);
 #endif
 }
 
-void GrContext::dumpCacheStatsKeyValuePairs(SkTArray<SkString>* keys,
-                                            SkTArray<double>* values) const {
+void GrContextPriv::dumpCacheStatsKeyValuePairs(SkTArray<SkString>* keys,
+                                                SkTArray<double>* values) const {
 #if GR_CACHE_STATS
-    fResourceCache->dumpStatsKeyValuePairs(keys, values);
+    fContext->fResourceCache->dumpStatsKeyValuePairs(keys, values);
 #endif
 }
 
-void GrContext::printCacheStats() const {
+void GrContextPriv::printCacheStats() const {
     SkString out;
     this->dumpCacheStats(&out);
     SkDebugf("%s", out.c_str());
 }
 
-void GrContext::dumpGpuStats(SkString* out) const {
+void GrContextPriv::dumpGpuStats(SkString* out) const {
 #if GR_GPU_STATS
-    return fGpu->stats()->dump(out);
+    return fContext->fGpu->stats()->dump(out);
 #endif
 }
 
-void GrContext::dumpGpuStatsKeyValuePairs(SkTArray<SkString>* keys,
-                                          SkTArray<double>* values) const {
+void GrContextPriv::dumpGpuStatsKeyValuePairs(SkTArray<SkString>* keys,
+                                              SkTArray<double>* values) const {
 #if GR_GPU_STATS
-    return fGpu->stats()->dumpKeyValuePairs(keys, values);
+    return fContext->fGpu->stats()->dumpKeyValuePairs(keys, values);
 #endif
 }
 
-void GrContext::printGpuStats() const {
+void GrContextPriv::printGpuStats() const {
     SkString out;
     this->dumpGpuStats(&out);
     SkDebugf("%s", out.c_str());
 }
 
-sk_sp<SkImage> GrContext::getFontAtlasImage_ForTesting(GrMaskFormat format, unsigned int index) {
-    auto restrictedAtlasManager = this->contextPriv().getRestrictedAtlasManager();
+sk_sp<SkImage> GrContextPriv::getFontAtlasImage_ForTesting(GrMaskFormat format, unsigned int index) {
+    auto restrictedAtlasManager = this->getRestrictedAtlasManager();
 
     unsigned int numProxies;
     const sk_sp<GrTextureProxy>* proxies = restrictedAtlasManager->getProxies(format, &numProxies);
@@ -160,7 +160,7 @@
     }
 
     SkASSERT(proxies[index]->priv().isExact());
-    sk_sp<SkImage> image(new SkImage_Gpu(this, kNeedNewImageUniqueID, kPremul_SkAlphaType,
+    sk_sp<SkImage> image(new SkImage_Gpu(fContext, kNeedNewImageUniqueID, kPremul_SkAlphaType,
                                          proxies[index], nullptr, SkBudgeted::kNo));
     return image;
 }