Move more internal methods from GrContext to GrContextPriv (take 3)

Change-Id: Ied630e61cf95780bf85032867e6ce663e1ef9c2f
Reviewed-on: https://skia-review.googlesource.com/98000
Reviewed-by: Greg Daniel <egdaniel@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
diff --git a/src/atlastext/SkAtlasTextTarget.cpp b/src/atlastext/SkAtlasTextTarget.cpp
index 0a318e0..d80c7a4 100644
--- a/src/atlastext/SkAtlasTextTarget.cpp
+++ b/src/atlastext/SkAtlasTextTarget.cpp
@@ -183,7 +183,7 @@
     FlushInfo flushInfo;
     SkAutoGlyphCache glyphCache;
     auto& context = target->context()->internal();
-    auto* atlasGlyphCache = context.grContext()->getAtlasGlyphCache();
+    auto* atlasGlyphCache = context.grContext()->contextPriv().getAtlasGlyphCache();
     for (int i = 0; i < fGeoCount; ++i) {
         GrAtlasTextBlob::VertexRegenerator regenerator(
                 fGeoData[i].fBlob, fGeoData[i].fRun, fGeoData[i].fSubRun, fGeoData[i].fViewMatrix,
diff --git a/src/atlastext/SkInternalAtlasTextContext.cpp b/src/atlastext/SkInternalAtlasTextContext.cpp
index fba0cbc..58b8788 100644
--- a/src/atlastext/SkInternalAtlasTextContext.cpp
+++ b/src/atlastext/SkInternalAtlasTextContext.cpp
@@ -7,6 +7,7 @@
 
 #include "SkInternalAtlasTextContext.h"
 #include "GrContext.h"
+#include "GrContextPriv.h"
 #include "SkAtlasTextContext.h"
 #include "SkAtlasTextRenderer.h"
 #include "text/GrAtlasGlyphCache.h"
@@ -36,17 +37,20 @@
 
 SkInternalAtlasTextContext::~SkInternalAtlasTextContext() {
     if (fDistanceFieldAtlas.fProxy) {
-        SkASSERT(1 == fGrContext->getAtlasGlyphCache()->getAtlasPageCount(kA8_GrMaskFormat));
+#ifdef SK_DEBUG
+        auto atlasGlyphCache = fGrContext->contextPriv().getAtlasGlyphCache();
+        SkASSERT(1 == atlasGlyphCache->getAtlasPageCount(kA8_GrMaskFormat));
+#endif
         fRenderer->deleteTexture(fDistanceFieldAtlas.fTextureHandle);
     }
 }
 
 GrAtlasGlyphCache* SkInternalAtlasTextContext::atlasGlyphCache() {
-    return fGrContext->getAtlasGlyphCache();
+    return fGrContext->contextPriv().getAtlasGlyphCache();
 }
 
 GrTextBlobCache* SkInternalAtlasTextContext::textBlobCache() {
-    return fGrContext->getTextBlobCache();
+    return fGrContext->contextPriv().getTextBlobCache();
 }
 
 GrDeferredUploadToken SkInternalAtlasTextContext::addInlineUpload(
@@ -80,7 +84,7 @@
 }
 
 void SkInternalAtlasTextContext::flush() {
-    auto* atlasGlyphCache = fGrContext->getAtlasGlyphCache();
+    auto* atlasGlyphCache = fGrContext->contextPriv().getAtlasGlyphCache();
     if (!fDistanceFieldAtlas.fProxy) {
         SkASSERT(1 == atlasGlyphCache->getAtlasPageCount(kA8_GrMaskFormat));
         fDistanceFieldAtlas.fProxy = atlasGlyphCache->getProxies(kA8_GrMaskFormat)->get();
diff --git a/src/gpu/GrAHardwareBufferImageGenerator.cpp b/src/gpu/GrAHardwareBufferImageGenerator.cpp
index f9208b1..74073ad 100644
--- a/src/gpu/GrAHardwareBufferImageGenerator.cpp
+++ b/src/gpu/GrAHardwareBufferImageGenerator.cpp
@@ -147,7 +147,7 @@
 #endif
 
 sk_sp<GrTextureProxy> GrAHardwareBufferImageGenerator::makeProxy(GrContext* context) {
-    if (!context->getGpu() || kOpenGL_GrBackend != context->contextPriv().getBackend()) {
+    if (context->abandoned() || kOpenGL_GrBackend != context->contextPriv().getBackend()) {
         // Check if GrContext is not abandoned and the backend is GL.
         return nullptr;
     }
diff --git a/src/gpu/GrContextPriv.h b/src/gpu/GrContextPriv.h
index bbf67a5..2ce3947 100644
--- a/src/gpu/GrContextPriv.h
+++ b/src/gpu/GrContextPriv.h
@@ -175,6 +175,12 @@
 
     GrResourceCache* getResourceCache() { return fContext->fResourceCache; }
 
+    GrGpu* getGpu() { return fContext->fGpu.get(); }
+    const GrGpu* getGpu() const { return fContext->fGpu.get(); }
+
+    GrAtlasGlyphCache* getAtlasGlyphCache() { return fContext->fAtlasGlyphCache; }
+    GrTextBlobCache* getTextBlobCache() { return fContext->fTextBlobCache.get(); }
+
 private:
     explicit GrContextPriv(GrContext* context) : fContext(context) {}
     GrContextPriv(const GrContextPriv&); // unimpl
diff --git a/src/gpu/GrDrawingManager.cpp b/src/gpu/GrDrawingManager.cpp
index e25b33c..302da06 100644
--- a/src/gpu/GrDrawingManager.cpp
+++ b/src/gpu/GrDrawingManager.cpp
@@ -121,8 +121,9 @@
     SkASSERT(result);
 #endif
 
-    GrOpFlushState flushState(fContext->getGpu(),
-                              fContext->contextPriv().resourceProvider(),
+    GrGpu* gpu = fContext->contextPriv().getGpu();
+
+    GrOpFlushState flushState(gpu, fContext->contextPriv().resourceProvider(),
                               &fTokenTracker);
 
     GrOnFlushResourceProvider onFlushProvider(this);
@@ -193,8 +194,7 @@
 
     fOpLists.reset();
 
-    GrSemaphoresSubmitted result = fContext->getGpu()->finishFlush(numSemaphores,
-                                                                   backendSemaphores);
+    GrSemaphoresSubmitted result = gpu->finishFlush(numSemaphores, backendSemaphores);
 
     // We always have to notify the cache when it requested a flush so it can reset its state.
     if (flushed || type == GrResourceCache::FlushType::kCacheRequested) {
@@ -299,10 +299,11 @@
         return result;
     }
 
+    GrGpu* gpu = fContext->contextPriv().getGpu();
     GrSurface* surface = proxy->priv().peekSurface();
 
-    if (fContext->getGpu() && surface->asRenderTarget()) {
-        fContext->getGpu()->resolveRenderTarget(surface->asRenderTarget(), proxy->origin());
+    if (gpu && surface->asRenderTarget()) {
+        gpu->resolveRenderTarget(surface->asRenderTarget(), proxy->origin());
     }
     return result;
 }
@@ -322,10 +323,11 @@
         fOpLists.back()->makeClosed(*fContext->caps());
     }
 
-    sk_sp<GrRenderTargetOpList> opList(new GrRenderTargetOpList(
-                                                    rtp,
-                                                    fContext->contextPriv().resourceProvider(),
-                                                    fContext->getAuditTrail()));
+    auto resourceProvider = fContext->contextPriv().resourceProvider();
+
+    sk_sp<GrRenderTargetOpList> opList(new GrRenderTargetOpList(rtp,
+                                                                resourceProvider,
+                                                                fContext->getAuditTrail()));
     SkASSERT(rtp->getLastOpList() == opList.get());
 
     if (managedOpList) {
diff --git a/src/gpu/GrTextureAdjuster.cpp b/src/gpu/GrTextureAdjuster.cpp
index b307607..fbfffb3 100644
--- a/src/gpu/GrTextureAdjuster.cpp
+++ b/src/gpu/GrTextureAdjuster.cpp
@@ -75,8 +75,8 @@
         return nullptr;
     }
 
-    if (!fContext->getGpu()->isACopyNeededForTextureParams(proxy.get(), params, &copyParams,
-                                                           scaleAdjust)) {
+    GrGpu* gpu = fContext->contextPriv().getGpu();
+    if (!gpu->isACopyNeededForTextureParams(proxy.get(), params, &copyParams, scaleAdjust)) {
         return proxy;
     }
 
diff --git a/src/gpu/GrTextureMaker.cpp b/src/gpu/GrTextureMaker.cpp
index 1fc5f7a..5043675 100644
--- a/src/gpu/GrTextureMaker.cpp
+++ b/src/gpu/GrTextureMaker.cpp
@@ -28,16 +28,16 @@
         *texColorSpace = this->getColorSpace(dstColorSpace);
     }
 
+    GrGpu* gpu = fContext->contextPriv().getGpu();
     sk_sp<GrTextureProxy> original(this->refOriginalTextureProxy(willBeMipped, dstColorSpace,
                                                                  AllowedTexGenType::kCheap));
     if (original) {
-        if (!fContext->getGpu()->isACopyNeededForTextureParams(original.get(), params, &copyParams,
-                                                               scaleAdjust)) {
+        if (!gpu->isACopyNeededForTextureParams(original.get(), params, &copyParams, scaleAdjust)) {
             return original;
         }
     } else {
-        if (!fContext->getGpu()->isACopyNeededForTextureParams(this->width(), this->height(),
-                                                               params, &copyParams, scaleAdjust)) {
+        if (!gpu->isACopyNeededForTextureParams(this->width(), this->height(),
+                                                params, &copyParams, scaleAdjust)) {
             return this->refOriginalTextureProxy(willBeMipped, dstColorSpace,
                                                  AllowedTexGenType::kAny);
         }
diff --git a/src/gpu/text/GrAtlasTextBlob.cpp b/src/gpu/text/GrAtlasTextBlob.cpp
index ca671b4..9e9f58a 100644
--- a/src/gpu/text/GrAtlasTextBlob.cpp
+++ b/src/gpu/text/GrAtlasTextBlob.cpp
@@ -347,7 +347,7 @@
     }
 }
 
-void GrAtlasTextBlob::flushBigGlyphs(GrContext* context, GrTextUtils::Target* target,
+void GrAtlasTextBlob::flushBigGlyphs(GrTextUtils::Target* target,
                                      const GrClip& clip, const SkPaint& paint,
                                      const SkMatrix& viewMatrix, SkScalar x, SkScalar y,
                                      const SkIRect& clipBounds) {
@@ -366,11 +366,11 @@
     }
 }
 
-void GrAtlasTextBlob::flushBigRun(GrContext* context, GrTextUtils::Target* target,
-                                    const SkSurfaceProps& props, const SkTextBlobRunIterator& it,
-                                    const GrClip& clip, const GrTextUtils::Paint& paint,
-                                    SkDrawFilter* drawFilter, const SkMatrix& viewMatrix,
-                                    const SkIRect& clipBounds, SkScalar x, SkScalar y) {
+void GrAtlasTextBlob::flushBigRun(GrTextUtils::Target* target,
+                                  const SkSurfaceProps& props, const SkTextBlobRunIterator& it,
+                                  const GrClip& clip, const GrTextUtils::Paint& paint,
+                                  SkDrawFilter* drawFilter, const SkMatrix& viewMatrix,
+                                  const SkIRect& clipBounds, SkScalar x, SkScalar y) {
     size_t textLen = it.glyphCount() * sizeof(uint16_t);
     const SkPoint& offset = it.offset();
 
@@ -381,24 +381,24 @@
 
     switch (it.positioning()) {
         case SkTextBlob::kDefault_Positioning:
-            GrTextUtils::DrawBigText(context, target, clip, runPaint, viewMatrix,
+            GrTextUtils::DrawBigText(target, clip, runPaint, viewMatrix,
                                      (const char*)it.glyphs(), textLen, x + offset.x(),
                                      y + offset.y(), clipBounds);
             break;
         case SkTextBlob::kHorizontal_Positioning:
-            GrTextUtils::DrawBigPosText(context, target, props, clip, runPaint, viewMatrix,
+            GrTextUtils::DrawBigPosText(target, props, clip, runPaint, viewMatrix,
                                         (const char*)it.glyphs(), textLen, it.pos(), 1,
                                         SkPoint::Make(x, y + offset.y()), clipBounds);
             break;
         case SkTextBlob::kFull_Positioning:
-            GrTextUtils::DrawBigPosText(context, target, props, clip, runPaint, viewMatrix,
+            GrTextUtils::DrawBigPosText(target, props, clip, runPaint, viewMatrix,
                                         (const char*)it.glyphs(), textLen, it.pos(), 2,
                                         SkPoint::Make(x, y), clipBounds);
             break;
     }
 }
 
-void GrAtlasTextBlob::flushCached(GrContext* context, GrTextUtils::Target* target,
+void GrAtlasTextBlob::flushCached(GrAtlasGlyphCache* atlasGlyphCache, GrTextUtils::Target* target,
                                   const SkTextBlob* blob, const SkSurfaceProps& props,
                                   const GrDistanceFieldAdjustTable* distanceAdjustTable,
                                   const GrTextUtils::Paint& paint, SkDrawFilter* drawFilter,
@@ -409,19 +409,20 @@
     SkTextBlobRunIterator it(blob);
     for (int run = 0; !it.done(); it.next(), run++) {
         if (fRuns[run].fTooBigForAtlas) {
-            this->flushBigRun(context, target, props, it, clip, paint, drawFilter, viewMatrix,
+            this->flushBigRun(target, props, it, clip, paint, drawFilter, viewMatrix,
                               clipBounds, x, y);
             continue;
         }
         this->flushRun(target, clip, run, viewMatrix, x, y, paint, props, distanceAdjustTable,
-                       context->getAtlasGlyphCache());
+                       atlasGlyphCache);
     }
 
     // Now flush big glyphs
-    this->flushBigGlyphs(context, target, clip, paint, viewMatrix, x, y, clipBounds);
+    this->flushBigGlyphs(target, clip, paint, viewMatrix, x, y, clipBounds);
 }
 
-void GrAtlasTextBlob::flushThrowaway(GrContext* context, GrTextUtils::Target* target,
+void GrAtlasTextBlob::flushThrowaway(GrAtlasGlyphCache* atlasGlyphCache,
+                                     GrTextUtils::Target* target,
                                      const SkSurfaceProps& props,
                                      const GrDistanceFieldAdjustTable* distanceAdjustTable,
                                      const GrTextUtils::Paint& paint, const GrClip& clip,
@@ -429,11 +430,11 @@
                                      SkScalar x, SkScalar y) {
     for (int run = 0; run < fRunCount; run++) {
         this->flushRun(target, clip, run, viewMatrix, x, y, paint, props, distanceAdjustTable,
-                       context->getAtlasGlyphCache());
+                       atlasGlyphCache);
     }
 
     // Now flush big glyphs
-    this->flushBigGlyphs(context, target, clip, paint, viewMatrix, x, y, clipBounds);
+    this->flushBigGlyphs(target, clip, paint, viewMatrix, x, y, clipBounds);
 }
 
 std::unique_ptr<GrDrawOp> GrAtlasTextBlob::test_makeOp(
diff --git a/src/gpu/text/GrAtlasTextBlob.h b/src/gpu/text/GrAtlasTextBlob.h
index 7106f11..11cb059 100644
--- a/src/gpu/text/GrAtlasTextBlob.h
+++ b/src/gpu/text/GrAtlasTextBlob.h
@@ -194,14 +194,14 @@
                         const SkMatrix& viewMatrix, SkScalar x, SkScalar y);
 
     // flush a GrAtlasTextBlob associated with a SkTextBlob
-    void flushCached(GrContext* context, GrTextUtils::Target*, const SkTextBlob* blob,
+    void flushCached(GrAtlasGlyphCache*, GrTextUtils::Target*, const SkTextBlob* blob,
                      const SkSurfaceProps& props,
                      const GrDistanceFieldAdjustTable* distanceAdjustTable,
                      const GrTextUtils::Paint&, SkDrawFilter* drawFilter, const GrClip& clip,
                      const SkMatrix& viewMatrix, const SkIRect& clipBounds, SkScalar x, SkScalar y);
 
     // flush a throwaway GrAtlasTextBlob *not* associated with an SkTextBlob
-    void flushThrowaway(GrContext* context, GrTextUtils::Target*, const SkSurfaceProps& props,
+    void flushThrowaway(GrAtlasGlyphCache*, GrTextUtils::Target*, const SkSurfaceProps& props,
                         const GrDistanceFieldAdjustTable* distanceAdjustTable,
                         const GrTextUtils::Paint& paint, const GrClip& clip,
                         const SkMatrix& viewMatrix, const SkIRect& clipBounds, SkScalar x,
@@ -294,11 +294,11 @@
                          const GrDistanceFieldAdjustTable* distanceAdjustTable,
                          GrAtlasGlyphCache* cache);
 
-    void flushBigGlyphs(GrContext* context, GrTextUtils::Target*, const GrClip& clip,
+    void flushBigGlyphs(GrTextUtils::Target*, const GrClip& clip,
                         const SkPaint& paint, const SkMatrix& viewMatrix, SkScalar x, SkScalar y,
                         const SkIRect& clipBounds);
 
-    void flushBigRun(GrContext* context, GrTextUtils::Target*, const SkSurfaceProps& props,
+    void flushBigRun(GrTextUtils::Target*, const SkSurfaceProps& props,
                      const SkTextBlobRunIterator& it, const GrClip& clip,
                      const GrTextUtils::Paint& paint, SkDrawFilter* drawFilter,
                      const SkMatrix& viewMatrix, const SkIRect& clipBounds, SkScalar x,
diff --git a/src/gpu/text/GrAtlasTextContext.cpp b/src/gpu/text/GrAtlasTextContext.cpp
index 3578154..946bf13 100644
--- a/src/gpu/text/GrAtlasTextContext.cpp
+++ b/src/gpu/text/GrAtlasTextContext.cpp
@@ -6,6 +6,7 @@
  */
 #include "GrAtlasTextContext.h"
 #include "GrContext.h"
+#include "GrContextPriv.h"
 #include "GrTextBlobCache.h"
 #include "SkDistanceFieldGen.h"
 #include "SkDraw.h"
@@ -121,7 +122,9 @@
                       drawFilter);
     uint32_t scalerContextFlags = ComputeScalerContextFlags(target->colorSpaceInfo());
 
-    GrTextBlobCache* cache = context->getTextBlobCache();
+    auto atlasGlyphCache = context->contextPriv().getAtlasGlyphCache();
+    GrTextBlobCache* textBlobCache = context->contextPriv().getTextBlobCache();
+
     if (canCache) {
         bool hasLCD = HasLCD(blob);
 
@@ -141,7 +144,7 @@
         key.fHasBlur = SkToBool(mf);
         key.fCanonicalColor = canonicalColor;
         key.fScalerContextFlags = scalerContextFlags;
-        cacheBlob = cache->find(key);
+        cacheBlob = textBlobCache->find(key);
     }
 
     GrTextUtils::Paint paint(&skPaint, &target->colorSpaceInfo());
@@ -150,21 +153,21 @@
             // We have to remake the blob because changes may invalidate our masks.
             // TODO we could probably get away reuse most of the time if the pointer is unique,
             // but we'd have to clear the subrun information
-            cache->remove(cacheBlob.get());
-            cacheBlob = cache->makeCachedBlob(blob, key, blurRec, skPaint);
-            this->regenerateTextBlob(cacheBlob.get(), context->getAtlasGlyphCache(),
+            textBlobCache->remove(cacheBlob.get());
+            cacheBlob = textBlobCache->makeCachedBlob(blob, key, blurRec, skPaint);
+            this->regenerateTextBlob(cacheBlob.get(), atlasGlyphCache,
                                      *context->caps()->shaderCaps(), paint, scalerContextFlags,
                                      viewMatrix, props, blob, x, y, drawFilter);
         } else {
-            cache->makeMRU(cacheBlob.get());
+            textBlobCache->makeMRU(cacheBlob.get());
 
             if (CACHE_SANITY_CHECK) {
                 int glyphCount = 0;
                 int runCount = 0;
                 GrTextBlobCache::BlobGlyphCount(&glyphCount, &runCount, blob);
-                sk_sp<GrAtlasTextBlob> sanityBlob(cache->makeBlob(glyphCount, runCount));
+                sk_sp<GrAtlasTextBlob> sanityBlob(textBlobCache->makeBlob(glyphCount, runCount));
                 sanityBlob->setupKey(key, blurRec, skPaint);
-                this->regenerateTextBlob(sanityBlob.get(), context->getAtlasGlyphCache(),
+                this->regenerateTextBlob(sanityBlob.get(), atlasGlyphCache,
                                          *context->caps()->shaderCaps(), paint, scalerContextFlags,
                                          viewMatrix, props, blob, x, y, drawFilter);
                 GrAtlasTextBlob::AssertEqual(*sanityBlob, *cacheBlob);
@@ -172,16 +175,16 @@
         }
     } else {
         if (canCache) {
-            cacheBlob = cache->makeCachedBlob(blob, key, blurRec, skPaint);
+            cacheBlob = textBlobCache->makeCachedBlob(blob, key, blurRec, skPaint);
         } else {
-            cacheBlob = cache->makeBlob(blob);
+            cacheBlob = textBlobCache->makeBlob(blob);
         }
-        this->regenerateTextBlob(cacheBlob.get(), context->getAtlasGlyphCache(),
+        this->regenerateTextBlob(cacheBlob.get(), atlasGlyphCache,
                                  *context->caps()->shaderCaps(), paint, scalerContextFlags,
                                  viewMatrix, props, blob, x, y, drawFilter);
     }
 
-    cacheBlob->flushCached(context, target, blob, props, fDistanceAdjustTable.get(), paint,
+    cacheBlob->flushCached(atlasGlyphCache, target, blob, props, fDistanceAdjustTable.get(), paint,
                            drawFilter, clip, viewMatrix, clipBounds, x, y);
 }
 
@@ -318,23 +321,27 @@
     if (context->abandoned()) {
         return;
     }
+
+    auto atlasGlyphCache = context->contextPriv().getAtlasGlyphCache();
+    auto textBlobCache = context->contextPriv().getTextBlobCache();
+
     GrTextUtils::Paint paint(&skPaint, &target->colorSpaceInfo());
-    if (this->canDraw(context->getAtlasGlyphCache(), skPaint, viewMatrix, props,
+    if (this->canDraw(atlasGlyphCache, skPaint, viewMatrix, props,
                       *context->caps()->shaderCaps())) {
         sk_sp<GrAtlasTextBlob> blob(
-                this->makeDrawTextBlob(context->getTextBlobCache(), context->getAtlasGlyphCache(),
+                this->makeDrawTextBlob(textBlobCache, atlasGlyphCache,
                                        *context->caps()->shaderCaps(), paint,
                                        ComputeScalerContextFlags(target->colorSpaceInfo()),
                                        viewMatrix, props, text, byteLength, x, y));
         if (blob) {
-            blob->flushThrowaway(context, target, props, fDistanceAdjustTable.get(), paint, clip,
-                                 viewMatrix, regionClipBounds, x, y);
+            blob->flushThrowaway(atlasGlyphCache, target, props, fDistanceAdjustTable.get(), paint,
+                                 clip, viewMatrix, regionClipBounds, x, y);
         }
         return;
     }
 
     // fall back to drawing as a path or scaled glyph
-    GrTextUtils::DrawBigText(context, target, clip, paint, viewMatrix, text, byteLength, x, y,
+    GrTextUtils::DrawBigText(target, clip, paint, viewMatrix, text, byteLength, x, y,
                              regionClipBounds);
 }
 
@@ -347,22 +354,27 @@
     GrTextUtils::Paint paint(&skPaint, &target->colorSpaceInfo());
     if (context->abandoned()) {
         return;
-    } else if (this->canDraw(context->getAtlasGlyphCache(), skPaint, viewMatrix, props,
-                             *context->caps()->shaderCaps())) {
+    }
+
+    auto atlasGlyphCache = context->contextPriv().getAtlasGlyphCache();
+    auto textBlobCache = context->contextPriv().getTextBlobCache();
+
+    if (this->canDraw(atlasGlyphCache, skPaint, viewMatrix, props,
+                      *context->caps()->shaderCaps())) {
         sk_sp<GrAtlasTextBlob> blob(this->makeDrawPosTextBlob(
-                context->getTextBlobCache(), context->getAtlasGlyphCache(),
+                textBlobCache, atlasGlyphCache,
                 *context->caps()->shaderCaps(), paint,
                 ComputeScalerContextFlags(target->colorSpaceInfo()), viewMatrix, props, text,
                 byteLength, pos, scalarsPerPosition, offset));
         if (blob) {
-            blob->flushThrowaway(context, target, props, fDistanceAdjustTable.get(), paint, clip,
-                                 viewMatrix, regionClipBounds, offset.fX, offset.fY);
+            blob->flushThrowaway(atlasGlyphCache, target, props, fDistanceAdjustTable.get(), paint,
+                                 clip, viewMatrix, regionClipBounds, offset.fX, offset.fY);
         }
         return;
     }
 
     // fall back to drawing as a path or scaled glyph
-    GrTextUtils::DrawBigPosText(context, target, props, clip, paint, viewMatrix, text,
+    GrTextUtils::DrawBigPosText(target, props, clip, paint, viewMatrix, text,
                                 byteLength, pos, scalarsPerPosition, offset, regionClipBounds);
 }
 
@@ -835,16 +847,18 @@
     SkScalar x = SkIntToScalar(xInt);
     SkScalar y = SkIntToScalar(yInt);
 
+    auto atlasGlyphCache = context->contextPriv().getAtlasGlyphCache();
+
     // right now we don't handle textblobs, nor do we handle drawPosText. Since we only intend to
     // test the text op with this unit test, that is okay.
     sk_sp<GrAtlasTextBlob> blob(gTextContext->makeDrawTextBlob(
-            context->getTextBlobCache(), context->getAtlasGlyphCache(),
+            context->contextPriv().getTextBlobCache(), atlasGlyphCache,
             *context->caps()->shaderCaps(), utilsPaint,
             GrAtlasTextContext::kTextBlobOpScalerContextFlags, viewMatrix, gSurfaceProps, text,
             static_cast<size_t>(textLen), x, y));
 
     return blob->test_makeOp(textLen, 0, 0, viewMatrix, x, y, utilsPaint, gSurfaceProps,
-                             gTextContext->dfAdjustTable(), context->getAtlasGlyphCache(),
+                             gTextContext->dfAdjustTable(), atlasGlyphCache,
                              rtc->textTarget());
 }
 
diff --git a/src/gpu/text/GrTextUtils.cpp b/src/gpu/text/GrTextUtils.cpp
index 47585f7..d354619 100644
--- a/src/gpu/text/GrTextUtils.cpp
+++ b/src/gpu/text/GrTextUtils.cpp
@@ -78,7 +78,7 @@
            paint.isFakeBoldText() || paint.getStyle() != SkPaint::kFill_Style;
 }
 
-void GrTextUtils::DrawBigText(GrContext* context, GrTextUtils::Target* target,
+void GrTextUtils::DrawBigText(GrTextUtils::Target* target,
                               const GrClip& clip, const SkPaint& paint,
                               const SkMatrix& viewMatrix, const char text[], size_t byteLength,
                               SkScalar x, SkScalar y, const SkIRect& clipBounds) {
@@ -104,7 +104,7 @@
     }
 }
 
-void GrTextUtils::DrawBigPosText(GrContext* context, GrTextUtils::Target* target,
+void GrTextUtils::DrawBigPosText(GrTextUtils::Target* target,
                                  const SkSurfaceProps& props, const GrClip& clip,
                                  const SkPaint& origPaint, const SkMatrix& viewMatrix,
                                  const char text[], size_t byteLength, const SkScalar pos[],
diff --git a/src/gpu/text/GrTextUtils.h b/src/gpu/text/GrTextUtils.h
index 3b1968d..252cd7c 100644
--- a/src/gpu/text/GrTextUtils.h
+++ b/src/gpu/text/GrTextUtils.h
@@ -129,17 +129,17 @@
     static bool ShouldDisableLCD(const SkPaint& paint);
 
     // Functions for drawing large text either as paths or (for color emoji) as scaled glyphs
-    static void DrawBigText(GrContext*, GrTextUtils::Target*, const GrClip& clip,
-                               const SkPaint& paint, const SkMatrix& viewMatrix, const char text[],
-                               size_t byteLength, SkScalar x, SkScalar y,
-                               const SkIRect& clipBounds);
+    static void DrawBigText(GrTextUtils::Target*, const GrClip& clip,
+                            const SkPaint& paint, const SkMatrix& viewMatrix, const char text[],
+                            size_t byteLength, SkScalar x, SkScalar y,
+                            const SkIRect& clipBounds);
 
-    static void DrawBigPosText(GrContext* context, GrTextUtils::Target*,
-                                  const SkSurfaceProps& props, const GrClip& clip,
-                                  const SkPaint& paint, const SkMatrix& viewMatrix,
-                                  const char text[], size_t byteLength, const SkScalar pos[],
-                                  int scalarsPerPosition, const SkPoint& offset,
-                                  const SkIRect& clipBounds);
+    static void DrawBigPosText(GrTextUtils::Target*,
+                               const SkSurfaceProps& props, const GrClip& clip,
+                               const SkPaint& paint, const SkMatrix& viewMatrix,
+                               const char text[], size_t byteLength, const SkScalar pos[],
+                               int scalarsPerPosition, const SkPoint& offset,
+                               const SkIRect& clipBounds);
 };
 
 #endif
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp
index bffbb0e..fe4c2b9 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -590,7 +590,8 @@
     // Flush any writes or uploads
     context->contextPriv().prepareSurfaceForExternalIO(proxy.get());
 
-    sk_sp<GrSemaphore> sema = context->getGpu()->prepareTextureForCrossContextUsage(texture.get());
+    GrGpu* gpu = context->contextPriv().getGpu();
+    sk_sp<GrSemaphore> sema = gpu->prepareTextureForCrossContextUsage(texture.get());
 
     auto gen = GrBackendTextureImageGenerator::Make(std::move(texture), proxy->origin(),
                                                     std::move(sema), codecImage->alphaType(),
@@ -625,8 +626,9 @@
 
     // Flush any writes or uploads
     context->contextPriv().prepareSurfaceForExternalIO(proxy.get());
+    GrGpu* gpu = context->contextPriv().getGpu();
 
-    sk_sp<GrSemaphore> sema = context->getGpu()->prepareTextureForCrossContextUsage(texture.get());
+    sk_sp<GrSemaphore> sema = gpu->prepareTextureForCrossContextUsage(texture.get());
 
     auto gen = GrBackendTextureImageGenerator::Make(std::move(texture), proxy->origin(),
                                                     std::move(sema), pixmap.alphaType(),