Update GrSurface/RenderTargetContexts to take and store GrSurfaceProxyViews.

Bug: skia:9556
Change-Id: Ie1aed1b16c237e9c9d1b582ac4ff02fdaaad238f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/263205
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
diff --git a/src/core/SkDeferredDisplayListRecorder.cpp b/src/core/SkDeferredDisplayListRecorder.cpp
index 324913d..04bbfd5 100644
--- a/src/core/SkDeferredDisplayListRecorder.cpp
+++ b/src/core/SkDeferredDisplayListRecorder.cpp
@@ -191,9 +191,11 @@
                                                             grColorType);
     SkASSERT(readSwizzle == proxy->textureSwizzle());
 
-    auto rtc = std::make_unique<GrRenderTargetContext>(fContext.get(), std::move(proxy),
-                                                       grColorType, fCharacterization.origin(),
-                                                       readSwizzle, outputSwizzle,
+    GrSurfaceProxyView readView(proxy, fCharacterization.origin(), readSwizzle);
+    GrSurfaceProxyView outputView(std::move(proxy), fCharacterization.origin(), outputSwizzle);
+
+    auto rtc = std::make_unique<GrRenderTargetContext>(fContext.get(), std::move(readView),
+                                                       std::move(outputView), grColorType,
                                                        fCharacterization.refColorSpace(),
                                                        &fCharacterization.surfaceProps());
     fSurface = SkSurface_Gpu::MakeWrappedRenderTarget(fContext.get(), std::move(rtc));
diff --git a/src/core/SkSpecialImage.cpp b/src/core/SkSpecialImage.cpp
index 227a0c2..64b0dfb 100644
--- a/src/core/SkSpecialImage.cpp
+++ b/src/core/SkSpecialImage.cpp
@@ -451,7 +451,10 @@
         if (!rec) {
             return false;
         }
-        auto sContext = GrSurfaceContext::Make(fContext, fTextureProxy, fColorType,
+        // TODO: Store a GrSurfaceProxyView on SkSpecialImage_Gpu instead of just a GrTextureProxy
+        GrSurfaceProxyView view(fTextureProxy, fTextureProxy->origin(),
+                                fTextureProxy->textureSwizzle());
+        auto sContext = GrSurfaceContext::Make(fContext, std::move(view), fColorType,
                                                this->alphaType(), fColorSpace);
         if (!sContext) {
             return false;
diff --git a/src/gpu/GrRenderTargetContext.cpp b/src/gpu/GrRenderTargetContext.cpp
index fb8bf20..63a7b14 100644
--- a/src/gpu/GrRenderTargetContext.cpp
+++ b/src/gpu/GrRenderTargetContext.cpp
@@ -153,9 +153,12 @@
     GrSwizzle readSwizzle = context->priv().caps()->getReadSwizzle(format, colorType);
     GrSwizzle outSwizzle = context->priv().caps()->getOutputSwizzle(format, colorType);
 
-    return std::make_unique<GrRenderTargetContext>(context, std::move(proxy), colorType, origin,
-                                                   readSwizzle, outSwizzle, std::move(colorSpace),
-                                                   surfaceProps, managedOps);
+    GrSurfaceProxyView readView(proxy, origin, readSwizzle);
+    GrSurfaceProxyView outputView(std::move(proxy), origin, outSwizzle);
+
+    return std::make_unique<GrRenderTargetContext>(context, std::move(readView),
+                                                   std::move(outputView), colorType,
+                                                   std::move(colorSpace), surfaceProps, managedOps);
 }
 
 std::unique_ptr<GrRenderTargetContext> GrRenderTargetContext::Make(
@@ -351,20 +354,21 @@
 // stack. When this occurs with a closed GrOpsTask, a new one will be allocated
 // when the renderTargetContext attempts to use it (via getOpsTask).
 GrRenderTargetContext::GrRenderTargetContext(GrRecordingContext* context,
-                                             sk_sp<GrSurfaceProxy> proxy,
+                                             GrSurfaceProxyView readView,
+                                             GrSurfaceProxyView outputView,
                                              GrColorType colorType,
-                                             GrSurfaceOrigin origin,
-                                             GrSwizzle readSwizzle,
-                                             GrSwizzle outSwizzle,
                                              sk_sp<SkColorSpace> colorSpace,
                                              const SkSurfaceProps* surfaceProps,
                                              bool managedOpsTask)
-        : GrSurfaceContext(context, std::move(proxy), colorType, kPremul_SkAlphaType,
-                           std::move(colorSpace), origin, readSwizzle)
-        , fOutputSwizzle(outSwizzle)
-        , fOpsTask(sk_ref_sp(fSurfaceProxy->getLastOpsTask()))
+        : GrSurfaceContext(context, std::move(readView), colorType, kPremul_SkAlphaType,
+                           std::move(colorSpace))
+        , fOutputView(std::move(outputView))
+        , fOpsTask(sk_ref_sp(this->asSurfaceProxy()->getLastOpsTask()))
         , fSurfaceProps(SkSurfacePropsCopyOrDefault(surfaceProps))
         , fManagedOpsTask(managedOpsTask) {
+    SkASSERT(this->asSurfaceProxy() == fOutputView.proxy());
+    SkASSERT(this->origin() == fOutputView.origin());
+
     fTextTarget.reset(new TextTarget(this));
     SkDEBUGCODE(this->validate();)
 }
@@ -372,7 +376,7 @@
 #ifdef SK_DEBUG
 void GrRenderTargetContext::onValidate() const {
     if (fOpsTask && !fOpsTask->isClosed()) {
-        SkASSERT(fSurfaceProxy->getLastRenderTask() == fOpsTask.get());
+        SkASSERT(fOutputView.proxy()->getLastRenderTask() == fOpsTask.get());
     }
 }
 #endif
@@ -557,7 +561,7 @@
                                       const SkMatrix& viewMatrix) {
     // Start with the render target, since that is the maximum content we could possibly fill.
     // drawFilledQuad() will automatically restrict it to clip bounds for us if possible.
-    SkRect r = fSurfaceProxy->getBoundsRect();
+    SkRect r = this->asSurfaceProxy()->getBoundsRect();
     if (!paint.numTotalFragmentProcessors()) {
         // The paint is trivial so we won't need to use local coordinates, so skip calculating the
         // inverse view matrix.
@@ -621,7 +625,7 @@
     if (stencilSettings) {
         // Must use size at which the rendertarget will ultimately be allocated so that stencil
         // buffer updates on approximately sized render targets don't get corrupted.
-        rtRect = fSurfaceProxy->backingStoreBoundsRect();
+        rtRect = this->asSurfaceProxy()->backingStoreBoundsRect();
     } else {
         // Use the logical size of the render target, which allows for "fullscreen" clears even if
         // the render target has an approximate backing fit
@@ -1694,7 +1698,7 @@
     }
     bool needsRescale = srcRect.width() != info.width() || srcRect.height() != info.height();
     auto colorTypeOfFinalContext = this->colorInfo().colorType();
-    auto backendFormatOfFinalContext = fSurfaceProxy->backendFormat();
+    auto backendFormatOfFinalContext = this->asSurfaceProxy()->backendFormat();
     if (needsRescale) {
         colorTypeOfFinalContext = dstCT;
         backendFormatOfFinalContext = this->caps()->getDefaultBackendFormat(dstCT,
@@ -1742,11 +1746,11 @@
                 callback(context, nullptr);
                 return;
             }
-            sk_sp<GrTextureProxy> texProxy = sk_ref_sp(fSurfaceProxy->asTextureProxy());
+            sk_sp<GrTextureProxy> texProxy = this->asTextureProxyRef();
             SkRect srcRectToDraw = SkRect::Make(srcRect);
             // If the src is not texturable first try to make a copy to a texture.
             if (!texProxy) {
-                texProxy = GrSurfaceProxy::Copy(fContext, fSurfaceProxy.get(),
+                texProxy = GrSurfaceProxy::Copy(fContext, this->asSurfaceProxy(),
                                                 GrMipMapped::kNo, srcRect, SkBackingFit::kApprox,
                                                 SkBudgeted::kNo);
                 if (!texProxy) {
@@ -2132,7 +2136,7 @@
     SkDEBUGCODE(this->validate();)
     GR_CREATE_TRACE_MARKER_CONTEXT("GrRenderTargetContext", "flush", fContext);
 
-    return this->drawingManager()->flushSurface(fSurfaceProxy.get(), access, info);
+    return this->drawingManager()->flushSurface(this->asSurfaceProxy(), access, info);
 }
 
 bool GrRenderTargetContext::waitOnSemaphores(int numSemaphores,
@@ -2319,7 +2323,7 @@
 
     SkDEBUGCODE(fRenderTargetContext->validate();)
 
-    return fRenderTargetContext->fSurfaceProxy->isBudgeted();
+    return fRenderTargetContext->asSurfaceProxy()->isBudgeted();
 }
 
 void GrRenderTargetContext::drawShapeUsingPathRenderer(const GrClip& clip,
@@ -2506,7 +2510,8 @@
         return false;
     }
 
-    if (this->caps()->textureBarrierSupport() && !fSurfaceProxy->requiresManualMSAAResolve()) {
+    if (this->caps()->textureBarrierSupport() &&
+        !this->asSurfaceProxy()->requiresManualMSAAResolve()) {
         if (this->asTextureProxy()) {
             // The render target is a texture, so we can read from it directly in the shader. The XP
             // will be responsible to detect this situation and request a texture barrier.
@@ -2516,7 +2521,7 @@
         }
     }
 
-    SkIRect copyRect = SkIRect::MakeSize(fSurfaceProxy->dimensions());
+    SkIRect copyRect = SkIRect::MakeSize(this->asSurfaceProxy()->dimensions());
 
     SkIRect clippedRect;
     clip.getConservativeBounds(
@@ -2530,7 +2535,7 @@
         // performance we may ignore the clip when the draw is entirely inside the clip is float
         // space but will hit pixels just outside the clip when actually rasterizing.
         clippedRect.outset(1, 1);
-        clippedRect.intersect(SkIRect::MakeSize(fSurfaceProxy->dimensions()));
+        clippedRect.intersect(SkIRect::MakeSize(this->asSurfaceProxy()->dimensions()));
     }
     SkIRect opIBounds;
     opBounds.roundOut(&opIBounds);
@@ -2560,7 +2565,7 @@
         fit = SkBackingFit::kApprox;
     }
     sk_sp<GrTextureProxy> newProxy =
-            GrSurfaceProxy::Copy(fContext, fSurfaceProxy.get(), GrMipMapped::kNo, copyRect,
+            GrSurfaceProxy::Copy(fContext, this->asSurfaceProxy(), GrMipMapped::kNo, copyRect,
                                  fit, SkBudgeted::kYes, restrictions.fRectsMustMatch);
     SkASSERT(newProxy);
 
diff --git a/src/gpu/GrRenderTargetContext.h b/src/gpu/GrRenderTargetContext.h
index f7703da..fd9ebe9 100644
--- a/src/gpu/GrRenderTargetContext.h
+++ b/src/gpu/GrRenderTargetContext.h
@@ -106,9 +106,9 @@
             GrRecordingContext*, const SkImageInfo&, const GrVkDrawableInfo&,
             const SkSurfaceProps*);
 
-    GrRenderTargetContext(GrRecordingContext*, sk_sp<GrSurfaceProxy>, GrColorType,
-                          GrSurfaceOrigin, GrSwizzle readSwizzle, GrSwizzle outSwizzle,
-                          sk_sp<SkColorSpace>, const SkSurfaceProps*, bool managedOpsTask = true);
+    GrRenderTargetContext(GrRecordingContext*, GrSurfaceProxyView readView,
+                          GrSurfaceProxyView outputView, GrColorType, sk_sp<SkColorSpace>,
+                          const SkSurfaceProps*, bool managedOpsTask = true);
 
     ~GrRenderTargetContext() override;
 
@@ -543,13 +543,13 @@
     bool wrapsVkSecondaryCB() const { return this->asRenderTargetProxy()->wrapsVkSecondaryCB(); }
     GrMipMapped mipMapped() const;
 
-    GrSurfaceProxyView outputSurfaceView() {
-        return { fSurfaceProxy, fOrigin, fOutputSwizzle };
-    }
+    // TODO: See if it makes sense for this to return a const& instead and require the callers to
+    // make a copy (which refs the proxy) if needed.
+    GrSurfaceProxyView outputSurfaceView() { return fOutputView; }
 
     // This entry point should only be called if the backing GPU object is known to be
     // instantiated.
-    GrRenderTarget* accessRenderTarget() { return fSurfaceProxy->peekRenderTarget(); }
+    GrRenderTarget* accessRenderTarget() { return this->asSurfaceProxy()->peekRenderTarget(); }
 
     GrRenderTargetContext* asRenderTargetContext() override { return this; }
 
@@ -560,7 +560,7 @@
     GrTextTarget* textTarget() { return fTextTarget.get(); }
 
 #if GR_TEST_UTILS
-    bool testingOnly_IsInstantiated() const { return fSurfaceProxy->isInstantiated(); }
+    bool testingOnly_IsInstantiated() const { return this->asSurfaceProxy()->isInstantiated(); }
     void testingOnly_SetPreserveOpsOnFullClear() { fPreserveOpsOnFullClear_TestingOnly = true; }
     GrOpsTask* testingOnly_PeekLastOpsTask() { return fOpsTask.get(); }
 #endif
@@ -683,7 +683,7 @@
 
     std::unique_ptr<GrTextTarget> fTextTarget;
 
-    GrSwizzle fOutputSwizzle;
+    GrSurfaceProxyView fOutputView;
 
     // In MDB-mode the GrOpsTask can be closed by some other renderTargetContext that has picked
     // it up. For this reason, the GrOpsTask should only ever be accessed via 'getOpsTask'.
diff --git a/src/gpu/GrRenderTargetContextPriv.h b/src/gpu/GrRenderTargetContextPriv.h
index 68cbf26..ecc5cd9 100644
--- a/src/gpu/GrRenderTargetContextPriv.h
+++ b/src/gpu/GrRenderTargetContextPriv.h
@@ -88,7 +88,7 @@
      * guaranteed to match the uniqueID of the underlying GrRenderTarget - beware!
      */
     GrSurfaceProxy::UniqueID uniqueID() const {
-        return fRenderTargetContext->fSurfaceProxy->uniqueID();
+        return fRenderTargetContext->asSurfaceProxy()->uniqueID();
     }
 
     uint32_t testingOnly_getOpsTaskID();
diff --git a/src/gpu/GrSurfaceContext.cpp b/src/gpu/GrSurfaceContext.cpp
index 6722d10..800bdba 100644
--- a/src/gpu/GrSurfaceContext.cpp
+++ b/src/gpu/GrSurfaceContext.cpp
@@ -28,7 +28,7 @@
 #define RETURN_FALSE_IF_ABANDONED  if (this->fContext->priv().abandoned()) { return false; }
 
 std::unique_ptr<GrSurfaceContext> GrSurfaceContext::Make(GrRecordingContext* context,
-                                                         sk_sp<GrSurfaceProxy> proxy,
+                                                         GrSurfaceProxyView readView,
                                                          GrColorType colorType,
                                                          SkAlphaType alphaType,
                                                          sk_sp<SkColorSpace> colorSpace) {
@@ -39,25 +39,23 @@
     if (context->priv().abandoned()) {
         return nullptr;
     }
+    GrSurfaceProxy* proxy = readView.proxy();
     SkASSERT(proxy && proxy->asTextureProxy());
 
-    // TODO: These should be passed in directly or as GrSurfaceProxyView
-    GrSurfaceOrigin origin = proxy->origin();
-    GrSwizzle readSwizzle = proxy->textureSwizzle();
-
     std::unique_ptr<GrSurfaceContext> surfaceContext;
-    if (GrRenderTargetProxy* rtProxy = proxy->asRenderTargetProxy()) {
+    if (proxy->asRenderTargetProxy()) {
         SkASSERT(kPremul_SkAlphaType == alphaType || kOpaque_SkAlphaType == alphaType);
         // Will we ever want a swizzle that is not the default output swizzle for the format and
         // colorType here? If so we will need to manually pass that in.
         GrSwizzle outSwizzle = context->priv().caps()->getOutputSwizzle(proxy->backendFormat(),
                                                                         colorType);
-        surfaceContext.reset(new GrRenderTargetContext(context, sk_ref_sp(rtProxy), colorType,
-                                                       origin, readSwizzle, outSwizzle,
+        GrSurfaceProxyView outputView(readView.proxyRef(), readView.origin(), outSwizzle);
+        surfaceContext.reset(new GrRenderTargetContext(context, std::move(readView),
+                                                       std::move(outputView), colorType,
                                                        std::move(colorSpace), nullptr));
     } else {
-        surfaceContext.reset(new GrSurfaceContext(context, std::move(proxy), colorType, alphaType,
-                                                  std::move(colorSpace), origin, readSwizzle));
+        surfaceContext.reset(new GrSurfaceContext(context, std::move(readView), colorType,
+                                                  alphaType, std::move(colorSpace)));
     }
     return surfaceContext;
 }
@@ -92,7 +90,9 @@
         return nullptr;
     }
 
-    return GrSurfaceContext::Make(context, std::move(proxy), colorType, alphaType,
+    GrSwizzle swizzle = context->priv().caps()->getReadSwizzle(format, colorType);
+    GrSurfaceProxyView view(std::move(proxy), origin, swizzle);
+    return GrSurfaceContext::Make(context, std::move(view), colorType, alphaType,
                                   std::move(colorSpace));
 }
 
@@ -102,17 +102,13 @@
 // stack. When this occurs with a closed GrOpsTask, a new one will be allocated
 // when the renderTargetContext attempts to use it (via getOpsTask).
 GrSurfaceContext::GrSurfaceContext(GrRecordingContext* context,
-                                   sk_sp<GrSurfaceProxy> proxy,
+                                   GrSurfaceProxyView readView,
                                    GrColorType colorType,
                                    SkAlphaType alphaType,
-                                   sk_sp<SkColorSpace> colorSpace,
-                                   GrSurfaceOrigin origin,
-                                   GrSwizzle readSwizzle)
+                                   sk_sp<SkColorSpace> colorSpace)
         : fContext(context)
-        , fSurfaceProxy(std::move(proxy))
-        , fOrigin(origin)
-        , fColorInfo(colorType, alphaType, std::move(colorSpace))
-        , fReadSwizzle(readSwizzle) {
+        , fReadView(std::move(readView))
+        , fColorInfo(colorType, alphaType, std::move(colorSpace)) {
     SkASSERT(!context->priv().abandoned());
 }
 
@@ -393,8 +389,9 @@
             return false;
         }
         SkASSERT(tempProxy->textureSwizzle() == tempReadSwizzle);
-        GrSurfaceContext tempCtx(direct, tempProxy, colorType, alphaType,
-                                 this->colorInfo().refColorSpace(), tempOrigin, tempReadSwizzle);
+        GrSurfaceProxyView tempView(tempProxy, tempOrigin, tempReadSwizzle);
+        GrSurfaceContext tempCtx(direct, std::move(tempView), colorType, alphaType,
+                                 this->colorInfo().refColorSpace());
 
         // In the fast path we always write the srcData to the temp context as though it were RGBA.
         // When the data is really BGRA the write will cause the R and B channels to be swapped in
@@ -732,10 +729,10 @@
 
 #ifdef SK_DEBUG
 void GrSurfaceContext::validate() const {
-    SkASSERT(fSurfaceProxy);
-    fSurfaceProxy->validate(fContext);
+    SkASSERT(fReadView.proxy());
+    fReadView.proxy()->validate(fContext);
     SkASSERT(fContext->priv().caps()->areColorTypeAndFormatCompatible(
-            this->colorInfo().colorType(), fSurfaceProxy->backendFormat()));
+            this->colorInfo().colorType(), fReadView.proxy()->backendFormat()));
 
     this->onValidate();
 }
diff --git a/src/gpu/GrSurfaceContext.h b/src/gpu/GrSurfaceContext.h
index 69edd00..4c83840 100644
--- a/src/gpu/GrSurfaceContext.h
+++ b/src/gpu/GrSurfaceContext.h
@@ -38,7 +38,8 @@
 public:
     // If the passed in GrSurfaceProxy is renderable this will return a GrRenderTargetContext,
     // otherwise it will return a GrSurfaceContext.
-    static std::unique_ptr<GrSurfaceContext> Make(GrRecordingContext*, sk_sp<GrSurfaceProxy>,
+    static std::unique_ptr<GrSurfaceContext> Make(GrRecordingContext*,
+                                                  GrSurfaceProxyView readView,
                                                   GrColorType, SkAlphaType, sk_sp<SkColorSpace>);
 
     static std::unique_ptr<GrSurfaceContext> Make(GrRecordingContext*, const SkISize& dimensions,
@@ -50,20 +51,20 @@
 
     // If it is known that the GrSurfaceProxy is not renderable, you can directly call the the ctor
     // here to make a GrSurfaceContext on the stack.
-    GrSurfaceContext(GrRecordingContext*, sk_sp<GrSurfaceProxy>, GrColorType, SkAlphaType,
-                     sk_sp<SkColorSpace>, GrSurfaceOrigin, GrSwizzle readSwizzle);
+    GrSurfaceContext(GrRecordingContext*, GrSurfaceProxyView readView, GrColorType, SkAlphaType,
+                     sk_sp<SkColorSpace>);
 
     virtual ~GrSurfaceContext() = default;
 
     const GrColorInfo& colorInfo() const { return fColorInfo; }
-    GrSurfaceOrigin origin() const { return fOrigin; }
-    const GrSwizzle& readSwizzle() const { return fReadSwizzle; }
-    GrSurfaceProxyView readSurfaceView() {
-        return { this->asSurfaceProxyRef(), fOrigin, fReadSwizzle };
-    }
+    GrSurfaceOrigin origin() const { return fReadView.origin(); }
+    GrSwizzle readSwizzle() const { return fReadView.swizzle(); }
+    // TODO: See if it makes sense for this to return a const& instead and require the callers to
+    // make a copy (which refs the proxy) if needed.
+    GrSurfaceProxyView readSurfaceView() { return fReadView; }
 
-    int width() const { return fSurfaceProxy->width(); }
-    int height() const { return fSurfaceProxy->height(); }
+    int width() const { return fReadView.proxy()->width(); }
+    int height() const { return fReadView.proxy()->height(); }
 
     const GrCaps* caps() const;
 
@@ -92,22 +93,20 @@
     bool writePixels(const GrImageInfo& srcInfo, const void* src, size_t rowBytes, SkIPoint dstPt,
                      GrContext* direct = nullptr);
 
-    GrSurfaceProxy* asSurfaceProxy() { return fSurfaceProxy.get(); }
-    const GrSurfaceProxy* asSurfaceProxy() const { return fSurfaceProxy.get(); }
-    sk_sp<GrSurfaceProxy> asSurfaceProxyRef() { return fSurfaceProxy; }
+    GrSurfaceProxy* asSurfaceProxy() { return fReadView.proxy(); }
+    const GrSurfaceProxy* asSurfaceProxy() const { return fReadView.proxy(); }
+    sk_sp<GrSurfaceProxy> asSurfaceProxyRef() { return fReadView.proxyRef(); }
 
-    GrTextureProxy* asTextureProxy() { return fSurfaceProxy->asTextureProxy(); }
-    const GrTextureProxy* asTextureProxy() const { return fSurfaceProxy->asTextureProxy(); }
-    sk_sp<GrTextureProxy> asTextureProxyRef() {
-        return sk_ref_sp(fSurfaceProxy->asTextureProxy());
-    }
+    GrTextureProxy* asTextureProxy() { return fReadView.asTextureProxy(); }
+    const GrTextureProxy* asTextureProxy() const { return fReadView.asTextureProxy(); }
+    sk_sp<GrTextureProxy> asTextureProxyRef() { return fReadView.asTextureProxyRef(); }
 
-    GrRenderTargetProxy* asRenderTargetProxy() { return fSurfaceProxy->asRenderTargetProxy(); }
+    GrRenderTargetProxy* asRenderTargetProxy() { return fReadView.asRenderTargetProxy(); }
     const GrRenderTargetProxy* asRenderTargetProxy() const {
-        return fSurfaceProxy->asRenderTargetProxy();
+        return fReadView.asRenderTargetProxy();
     }
     sk_sp<GrRenderTargetProxy> asRenderTargetProxyRef() {
-        return sk_ref_sp(fSurfaceProxy->asRenderTargetProxy());
+        return fReadView.asRenderTargetProxyRef();
     }
 
     virtual GrRenderTargetContext* asRenderTargetContext() { return nullptr; }
@@ -140,8 +139,7 @@
 
     GrRecordingContext* fContext;
 
-    sk_sp<GrSurfaceProxy>  fSurfaceProxy;
-    GrSurfaceOrigin fOrigin;
+    GrSurfaceProxyView fReadView;
 
     // The rescaling step of asyncRescaleAndReadPixels[YUV420]().
     std::unique_ptr<GrRenderTargetContext> rescale(const SkImageInfo& info, const SkIRect& srcRect,
@@ -189,7 +187,6 @@
     }
 
     GrColorInfo fColorInfo;
-    GrSwizzle fReadSwizzle;
 
     typedef SkRefCnt INHERITED;
 };
diff --git a/src/gpu/GrSurfaceProxyView.h b/src/gpu/GrSurfaceProxyView.h
index 78ea8e9..7608736 100644
--- a/src/gpu/GrSurfaceProxyView.h
+++ b/src/gpu/GrSurfaceProxyView.h
@@ -10,6 +10,7 @@
 
 #include "include/core/SkRefCnt.h"
 #include "include/gpu/GrTypes.h"
+#include "src/gpu/GrRenderTargetProxy.h"
 #include "src/gpu/GrSurfaceProxy.h"
 #include "src/gpu/GrSwizzle.h"
 
@@ -37,6 +38,8 @@
     bool operator!=(const GrSurfaceProxyView& other) const { return !(*this == other); }
 
     GrSurfaceProxy* proxy() const { return fProxy.get(); }
+    sk_sp<GrSurfaceProxy> proxyRef() const { return fProxy; }
+
     GrTextureProxy* asTextureProxy() const {
         if (!fProxy) {
             return nullptr;
@@ -44,10 +47,7 @@
         return fProxy->asTextureProxy();
     }
     sk_sp<GrTextureProxy> asTextureProxyRef() const {
-        if (!fProxy) {
-            return nullptr;
-        }
-        return sk_ref_sp<GrTextureProxy>(fProxy->asTextureProxy());
+        return sk_ref_sp<GrTextureProxy>(this->asTextureProxy());
     }
 
     GrRenderTargetProxy* asRenderTargetProxy() const {
@@ -57,8 +57,12 @@
         return fProxy->asRenderTargetProxy();
     }
 
+    sk_sp<GrRenderTargetProxy> asRenderTargetProxyRef() const {
+        return sk_ref_sp<GrRenderTargetProxy>(this->asRenderTargetProxy());
+    }
+
     GrSurfaceOrigin origin() const { return fOrigin; }
-    const GrSwizzle& swizzle() const { return fSwizzle; }
+    GrSwizzle swizzle() const { return fSwizzle; }
 
     void reset() {
         *this = {};
diff --git a/src/gpu/text/GrAtlasManager.cpp b/src/gpu/text/GrAtlasManager.cpp
index 0beb3d3..978ac45 100644
--- a/src/gpu/text/GrAtlasManager.cpp
+++ b/src/gpu/text/GrAtlasManager.cpp
@@ -83,20 +83,21 @@
   * Write the contents of the surface proxy to a PNG. Returns true if successful.
   * @param filename      Full path to desired file
   */
-static bool save_pixels(GrContext* context, GrSurfaceProxy* sProxy, GrColorType colorType,
+static bool save_pixels(GrContext* context, GrSurfaceProxyView view, GrColorType colorType,
                         const char* filename) {
-    if (!sProxy) {
+    if (!view.proxy()) {
         return false;
     }
 
     SkImageInfo ii =
-            SkImageInfo::Make(sProxy->dimensions(), kRGBA_8888_SkColorType, kPremul_SkAlphaType);
+            SkImageInfo::Make(view.proxy()->dimensions(), kRGBA_8888_SkColorType,
+                              kPremul_SkAlphaType);
     SkBitmap bm;
     if (!bm.tryAllocPixels(ii)) {
         return false;
     }
 
-    auto sContext = GrSurfaceContext::Make(context, sk_ref_sp(sProxy), colorType,
+    auto sContext = GrSurfaceContext::Make(context, std::move(view), colorType,
                                            kUnknown_SkAlphaType, nullptr);
     if (!sContext || !sContext->asTextureProxy()) {
         return false;
@@ -141,7 +142,7 @@
                 filename.printf("fontcache_%d%d%d.png", gDumpCount, i, pageIdx);
 #endif
                 auto ct = mask_format_to_gr_color_type(AtlasIndexToMaskFormat(i));
-                save_pixels(context, views[pageIdx].proxy(), ct, filename.c_str());
+                save_pixels(context, views[pageIdx], ct, filename.c_str());
             }
         }
     }
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp
index 5949c5f..ad6e4a0 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -621,9 +621,9 @@
     SkAlphaType at =  pixmap.alphaType();
 
     GrSwizzle swizzle = context->priv().caps()->getReadSwizzle(backendFormat, grColorType);
-    GrSurfaceProxyView view(proxy, surfaceOrigin, swizzle);
+    GrSurfaceProxyView view(std::move(proxy), surfaceOrigin, swizzle);
     sk_sp<SkImage> image = sk_make_sp<SkImage_Gpu>(sk_ref_sp(context), kNeedNewImageUniqueID, at,
-                                                   std::move(view), cs);
+                                                   view, cs);
     if (!image) {
         return nullptr;
     }
@@ -633,9 +633,9 @@
         return nullptr;
     }
 
-    GrSurfaceContext surfaceContext(context, std::move(proxy),
+    GrSurfaceContext surfaceContext(context, std::move(view),
                                     SkColorTypeToGrColorType(pixmap.colorType()),
-                                    pixmap.alphaType(), cs, surfaceOrigin, swizzle);
+                                    pixmap.alphaType(), cs);
 
     SkImageInfo srcInfo = SkImageInfo::Make(bufferDesc.width, bufferDesc.height, colorType, at,
                                             std::move(cs));
diff --git a/src/image/SkImage_GpuBase.cpp b/src/image/SkImage_GpuBase.cpp
index 36305f5..b2713e3 100644
--- a/src/image/SkImage_GpuBase.cpp
+++ b/src/image/SkImage_GpuBase.cpp
@@ -114,12 +114,12 @@
         }
     }
 
-    sk_sp<GrTextureProxy> texProxy = this->asTextureProxyRef(direct);
+    GrSurfaceProxyView view = this->asSurfaceProxyViewRef(direct);
     GrColorType grColorType = SkColorTypeAndFormatToGrColorType(fContext->priv().caps(),
                                                                 this->colorType(),
-                                                                texProxy->backendFormat());
+                                                                view.proxy()->backendFormat());
 
-    auto sContext = GrSurfaceContext::Make(direct, std::move(texProxy), grColorType,
+    auto sContext = GrSurfaceContext::Make(direct, std::move(view), grColorType,
                                            this->alphaType(), this->refColorSpace());
     if (!sContext) {
         return false;
@@ -175,12 +175,12 @@
         return false;
     }
 
-    sk_sp<GrTextureProxy> texProxy = this->asTextureProxyRef(direct);
+    GrSurfaceProxyView view = this->asSurfaceProxyViewRef(direct);
     GrColorType grColorType = SkColorTypeAndFormatToGrColorType(fContext->priv().caps(),
                                                                 this->colorType(),
-                                                                texProxy->backendFormat());
+                                                                view.proxy()->backendFormat());
 
-    auto sContext = GrSurfaceContext::Make(direct, std::move(texProxy), grColorType,
+    auto sContext = GrSurfaceContext::Make(direct, std::move(view), grColorType,
                                            this->alphaType(), this->refColorSpace());
     if (!sContext) {
         return false;
diff --git a/src/image/SkSurface_GpuMtl.mm b/src/image/SkSurface_GpuMtl.mm
index 5528bf2..9737a04 100644
--- a/src/image/SkSurface_GpuMtl.mm
+++ b/src/image/SkSurface_GpuMtl.mm
@@ -98,14 +98,16 @@
             false,
             GrSurfaceProxy::UseAllocator::kYes);
 
-    const GrSwizzle& readSwizzle = caps->getReadSwizzle(backendFormat, grColorType);
-    const GrSwizzle& outputSwizzle = caps->getOutputSwizzle(backendFormat, grColorType);
+    GrSwizzle readSwizzle = caps->getReadSwizzle(backendFormat, grColorType);
+    GrSwizzle outputSwizzle = caps->getOutputSwizzle(backendFormat, grColorType);
 
     SkASSERT(readSwizzle == proxy->textureSwizzle());
 
-    auto rtc = std::make_unique<GrRenderTargetContext>(context, std::move(proxy),
-                                                       grColorType, origin,
-                                                       readSwizzle, outputSwizzle,
+    GrSurfaceProxyView readView(proxy, origin, readSwizzle);
+    GrSurfaceProxyView outputView(std::move(proxy), origin, outputSwizzle);
+
+    auto rtc = std::make_unique<GrRenderTargetContext>(context, std::move(readView),
+                                                       std::move(outputView), grColorType,
                                                        colorSpace, surfaceProps);
 
     sk_sp<SkSurface> surface = SkSurface_Gpu::MakeWrappedRenderTarget(context, std::move(rtc));
@@ -186,9 +188,11 @@
 
     SkASSERT(readSwizzle == proxy->textureSwizzle());
 
-    auto rtc = std::make_unique<GrRenderTargetContext>(context, std::move(proxy),
-                                                       grColorType, origin,
-                                                       readSwizzle, outputSwizzle,
+    GrSurfaceProxyView readView(proxy, origin, readSwizzle);
+    GrSurfaceProxyView outputView(std::move(proxy), origin, outputSwizzle);
+
+    auto rtc = std::make_unique<GrRenderTargetContext>(context, std::move(readView),
+                                                       std::move(outputView), grColorType,
                                                        colorSpace, surfaceProps);
 
     sk_sp<SkSurface> surface = SkSurface_Gpu::MakeWrappedRenderTarget(context, std::move(rtc));
diff --git a/tests/CopySurfaceTest.cpp b/tests/CopySurfaceTest.cpp
index 1576fa1..e670dec 100644
--- a/tests/CopySurfaceTest.cpp
+++ b/tests/CopySurfaceTest.cpp
@@ -105,7 +105,11 @@
                                 }
 
                                 GrColorType grColorType = SkColorTypeToGrColorType(ii.colorType());
-                                auto dstContext = GrSurfaceContext::Make(context, std::move(dst),
+                                GrSwizzle dstSwizzle = context->priv().caps()->getReadSwizzle(
+                                        dst->backendFormat(), grColorType);
+                                GrSurfaceProxyView dstView(std::move(dst), dOrigin, dstSwizzle);
+                                auto dstContext = GrSurfaceContext::Make(context,
+                                                                         std::move(dstView),
                                                                          grColorType,
                                                                          ii.alphaType(), nullptr);
 
diff --git a/tests/FloatingPointTextureTest.cpp b/tests/FloatingPointTextureTest.cpp
index e302c81..72b7154 100644
--- a/tests/FloatingPointTextureTest.cpp
+++ b/tests/FloatingPointTextureTest.cpp
@@ -56,7 +56,10 @@
             continue;
         }
 
-        auto sContext = GrSurfaceContext::Make(context, std::move(fpProxy), colorType,
+        GrSwizzle swizzle = context->priv().caps()->getReadSwizzle(fpProxy->backendFormat(),
+                                                                   colorType);
+        GrSurfaceProxyView view(std::move(fpProxy), origin, swizzle);
+        auto sContext = GrSurfaceContext::Make(context, std::move(view), colorType,
                                                kPremul_SkAlphaType, nullptr);
         REPORTER_ASSERT(reporter, sContext);
 
diff --git a/tests/GrSurfaceTest.cpp b/tests/GrSurfaceTest.cpp
index e973dcd..23b0971 100644
--- a/tests/GrSurfaceTest.cpp
+++ b/tests/GrSurfaceTest.cpp
@@ -301,7 +301,11 @@
                                 {kSize, kSize}, combo.fColorType, combo.fFormat, renderable, 1,
                                 kTopLeft_GrSurfaceOrigin, fit, SkBudgeted::kYes, GrProtected::kNo);
                         if (proxy) {
-                            auto texCtx = GrSurfaceContext::Make(context, std::move(proxy),
+                            GrSwizzle swizzle = caps->getReadSwizzle(combo.fFormat,
+                                                                     combo.fColorType);
+                            GrSurfaceProxyView view(std::move(proxy), kTopLeft_GrSurfaceOrigin,
+                                                    swizzle);
+                            auto texCtx = GrSurfaceContext::Make(context, std::move(view),
                                                                  combo.fColorType,
                                                                  kPremul_SkAlphaType, nullptr);
 
@@ -399,7 +403,10 @@
                                                        kTopLeft_GrSurfaceOrigin,
                                                        kBorrow_GrWrapOwnership,
                                                        GrWrapCacheable::kNo, ioType);
-        auto surfContext = GrSurfaceContext::Make(context, proxy, GrColorType::kRGBA_8888,
+        GrSwizzle swizzle = context->priv().caps()->getReadSwizzle(proxy->backendFormat(),
+                                                                   GrColorType::kRGBA_8888);
+        GrSurfaceProxyView view(proxy, kTopLeft_GrSurfaceOrigin, swizzle);
+        auto surfContext = GrSurfaceContext::Make(context, std::move(view), GrColorType::kRGBA_8888,
                                                   kPremul_SkAlphaType, nullptr);
 
         // Read pixels should work with a read-only texture.
diff --git a/tests/GrTestingBackendTextureUploadTest.cpp b/tests/GrTestingBackendTextureUploadTest.cpp
index de9aede..884ed88 100644
--- a/tests/GrTestingBackendTextureUploadTest.cpp
+++ b/tests/GrTestingBackendTextureUploadTest.cpp
@@ -72,7 +72,9 @@
     }
     REPORTER_ASSERT(reporter, wrappedProxy);
 
-    auto surfaceContext = GrSurfaceContext::Make(context, std::move(wrappedProxy), grCT,
+    GrSwizzle swizzle = context->priv().caps()->getReadSwizzle(wrappedProxy->backendFormat(), grCT);
+    GrSurfaceProxyView view(std::move(wrappedProxy), kTopLeft_GrSurfaceOrigin, swizzle);
+    auto surfaceContext = GrSurfaceContext::Make(context, std::move(view), grCT,
                                                  kPremul_SkAlphaType, nullptr);
     REPORTER_ASSERT(reporter, surfaceContext);
 
diff --git a/tests/GrUploadPixelsTests.cpp b/tests/GrUploadPixelsTests.cpp
index 001bdb1..299693e 100644
--- a/tests/GrUploadPixelsTests.cpp
+++ b/tests/GrUploadPixelsTests.cpp
@@ -35,8 +35,10 @@
             {grCT, kPremul_SkAlphaType, nullptr, kWidth, kHeight}, srcBuffer, 0);
     REPORTER_ASSERT(reporter, proxy);
     if (proxy) {
-        auto sContext = GrSurfaceContext::Make(context, proxy, SkColorTypeToGrColorType(ct),
-                                               kPremul_SkAlphaType, nullptr);
+        GrSwizzle swizzle = context->priv().caps()->getReadSwizzle(proxy->backendFormat(), grCT);
+        GrSurfaceProxyView view(proxy, kTopLeft_GrSurfaceOrigin, swizzle);
+        auto sContext = GrSurfaceContext::Make(context, std::move(view), grCT, kPremul_SkAlphaType,
+                                               nullptr);
 
         SkImageInfo dstInfo = SkImageInfo::Make(kWidth, kHeight, ct, kPremul_SkAlphaType);
 
@@ -62,8 +64,10 @@
             {grCT, kPremul_SkAlphaType, nullptr, kWidth, kHeight}, srcBuffer, 0);
     REPORTER_ASSERT(reporter, proxy);
     if (proxy) {
-        auto sContext = GrSurfaceContext::Make(context, proxy, SkColorTypeToGrColorType(ct),
-                                               kPremul_SkAlphaType, nullptr);
+        GrSwizzle swizzle = context->priv().caps()->getReadSwizzle(proxy->backendFormat(), grCT);
+        GrSurfaceProxyView view(proxy, kBottomLeft_GrSurfaceOrigin, swizzle);
+        auto sContext = GrSurfaceContext::Make(context, std::move(view), grCT, kPremul_SkAlphaType,
+                                               nullptr);
 
         SkImageInfo dstInfo = SkImageInfo::Make(kWidth, kHeight, ct, kPremul_SkAlphaType);
 
diff --git a/tests/PackedConfigsTextureTest.cpp b/tests/PackedConfigsTextureTest.cpp
index df26fb6..9e8e5b4 100644
--- a/tests/PackedConfigsTextureTest.cpp
+++ b/tests/PackedConfigsTextureTest.cpp
@@ -123,8 +123,9 @@
         GrSwizzle readSwizzle = context->priv().caps()->getReadSwizzle(proxy->backendFormat(),
                                                                        grColorType);
 
-        GrSurfaceContext sContext(context, std::move(proxy), grColorType, kPremul_SkAlphaType,
-                                  nullptr, origin, readSwizzle);
+        GrSurfaceProxyView view(std::move(proxy), origin, readSwizzle);
+        GrSurfaceContext sContext(context, std::move(view), grColorType, kPremul_SkAlphaType,
+                                  nullptr);
 
         if (!sContext.readPixels(dstInfo, readBuffer.begin(), 0, {0, 0})) {
             // We only require this to succeed if the format is renderable.
diff --git a/tests/ProcessorTest.cpp b/tests/ProcessorTest.cpp
index 87bebcc..90d2396 100644
--- a/tests/ProcessorTest.cpp
+++ b/tests/ProcessorTest.cpp
@@ -342,9 +342,14 @@
 }
 
 bool log_texture_proxy(GrContext* context, sk_sp<GrTextureProxy> src, SkString* dst) {
-    auto sContext = GrSurfaceContext::Make(context, src, GrColorType::kRGBA_8888, kLogAlphaType,
-                                           nullptr);
     SkImageInfo ii = SkImageInfo::Make(src->dimensions(), kRGBA_8888_SkColorType, kLogAlphaType);
+
+    GrSurfaceOrigin origin = src->origin();
+    GrSwizzle swizzle = context->priv().caps()->getReadSwizzle(src->backendFormat(),
+                                                               GrColorType::kRGBA_8888);
+    GrSurfaceProxyView view(std::move(src), origin, swizzle);
+    auto sContext = GrSurfaceContext::Make(context, std::move(view), GrColorType::kRGBA_8888,
+                                           kLogAlphaType, nullptr);
     SkBitmap bm;
     SkAssertResult(bm.tryAllocPixels(ii));
     SkAssertResult(sContext->readPixels(ii, bm.getPixels(), bm.rowBytes(), {0, 0}));
diff --git a/tests/ReadPixelsTest.cpp b/tests/ReadPixelsTest.cpp
index 453f6e6..675ce44 100644
--- a/tests/ReadPixelsTest.cpp
+++ b/tests/ReadPixelsTest.cpp
@@ -426,8 +426,12 @@
         for (auto renderable : {GrRenderable::kNo, GrRenderable::kYes}) {
             sk_sp<GrTextureProxy> proxy = sk_gpu_test::MakeTextureProxyFromData(
                     context, renderable, origin, bmp.info(), bmp.getPixels(), bmp.rowBytes());
-            auto sContext = GrSurfaceContext::Make(context, std::move(proxy),
-                    SkColorTypeToGrColorType(bmp.colorType()), kPremul_SkAlphaType, nullptr);
+            GrColorType grColorType = SkColorTypeToGrColorType(bmp.colorType());
+            GrSwizzle swizzle = context->priv().caps()->getReadSwizzle(proxy->backendFormat(),
+                                                                       grColorType);
+            GrSurfaceProxyView view(std::move(proxy), origin, swizzle);
+            auto sContext = GrSurfaceContext::Make(context, std::move(view),
+                    grColorType, kPremul_SkAlphaType, nullptr);
             auto info = SkImageInfo::Make(DEV_W, DEV_H, kN32_SkColorType, kPremul_SkAlphaType);
             test_readpixels_texture(reporter, std::move(sContext), info);
         }
diff --git a/tests/ReadWriteAlphaTest.cpp b/tests/ReadWriteAlphaTest.cpp
index 31db04c..74b1271 100644
--- a/tests/ReadWriteAlphaTest.cpp
+++ b/tests/ReadWriteAlphaTest.cpp
@@ -74,7 +74,12 @@
             ERRORF(reporter, "Could not create alpha texture.");
             return;
         }
-        auto sContext = GrSurfaceContext::Make(context, std::move(proxy), GrColorType::kAlpha_8,
+
+        SkASSERT(proxy->origin() == kTopLeft_GrSurfaceOrigin);
+        GrSwizzle swizzle = context->priv().caps()->getReadSwizzle(proxy->backendFormat(),
+                                                                   GrColorType::kAlpha_8);
+        GrSurfaceProxyView view(std::move(proxy), kTopLeft_GrSurfaceOrigin, swizzle);
+        auto sContext = GrSurfaceContext::Make(context, std::move(view), GrColorType::kAlpha_8,
                                                kPremul_SkAlphaType, nullptr);
 
         sk_sp<SkSurface> surf(SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, ii));
@@ -193,7 +198,10 @@
                 continue;
             }
 
-            auto sContext = GrSurfaceContext::Make(context, std::move(proxy), info.fColorType,
+            GrSwizzle swizzle = context->priv().caps()->getReadSwizzle(proxy->backendFormat(),
+                                                                       info.fColorType);
+            GrSurfaceProxyView view(std::move(proxy), origin, swizzle);
+            auto sContext = GrSurfaceContext::Make(context, std::move(view), info.fColorType,
                                                    kPremul_SkAlphaType, nullptr);
 
             for (auto rowBytes : kRowBytes) {
diff --git a/tests/RectangleTextureTest.cpp b/tests/RectangleTextureTest.cpp
index 2eacffe..abaf04c 100644
--- a/tests/RectangleTextureTest.cpp
+++ b/tests/RectangleTextureTest.cpp
@@ -192,7 +192,10 @@
         TestCopyFromSurface(reporter, context, rectProxy.get(), GrColorType::kRGBA_8888, refPixels,
                             "RectangleTexture-copy-from");
 
-        auto rectContext = GrSurfaceContext::Make(context, std::move(rectProxy),
+        GrSwizzle swizzle = context->priv().caps()->getReadSwizzle(rectangleTex.getBackendFormat(),
+                                                                   GrColorType::kRGBA_8888);
+        GrSurfaceProxyView view(std::move(rectProxy), origin, swizzle);
+        auto rectContext = GrSurfaceContext::Make(context, std::move(view),
                                                   GrColorType::kRGBA_8888, kPremul_SkAlphaType,
                                                   nullptr);
         SkASSERT(rectContext);
diff --git a/tests/SurfaceTest.cpp b/tests/SurfaceTest.cpp
index 55b76a0..6d13d92 100644
--- a/tests/SurfaceTest.cpp
+++ b/tests/SurfaceTest.cpp
@@ -782,8 +782,7 @@
     auto makeImageSurfaceContext = [context](SkSurface* surface) {
         sk_sp<SkImage> i(surface->makeImageSnapshot());
         SkImage_Gpu* gpuImage = (SkImage_Gpu*)as_IB(i);
-        sk_sp<GrTextureProxy> proxy = gpuImage->asTextureProxyRef(context);
-        return GrSurfaceContext::Make(context, std::move(proxy),
+        return GrSurfaceContext::Make(context, gpuImage->asSurfaceProxyViewRef(context),
                                       SkColorTypeToGrColorType(i->colorType()), kPremul_SkAlphaType,
                                       gpuImage->refColorSpace());
     };
diff --git a/tests/TestUtils.cpp b/tests/TestUtils.cpp
index 3d8b11f..9e3f209 100644
--- a/tests/TestUtils.cpp
+++ b/tests/TestUtils.cpp
@@ -84,7 +84,11 @@
                                                           SkBackingFit::kExact, SkBudgeted::kYes);
     SkASSERT(dstProxy);
 
-    auto dstContext = GrSurfaceContext::Make(context, std::move(dstProxy), colorType,
+    GrSurfaceOrigin origin = dstProxy->origin();
+    GrSwizzle swizzle = context->priv().caps()->getReadSwizzle(dstProxy->backendFormat(),
+                                                               colorType);
+    GrSurfaceProxyView view(std::move(dstProxy), origin, swizzle);
+    auto dstContext = GrSurfaceContext::Make(context, std::move(view), colorType,
                                              kPremul_SkAlphaType, nullptr);
     SkASSERT(dstContext);
 
diff --git a/tools/gpu/ProxyUtils.cpp b/tools/gpu/ProxyUtils.cpp
index 0d9bf36..e537580 100644
--- a/tools/gpu/ProxyUtils.cpp
+++ b/tools/gpu/ProxyUtils.cpp
@@ -46,7 +46,9 @@
     if (!proxy) {
         return nullptr;
     }
-    auto sContext = GrSurfaceContext::Make(context, proxy, imageInfo.colorType(),
+    GrSwizzle swizzle = caps->getReadSwizzle(format, imageInfo.colorType());
+    GrSurfaceProxyView view(proxy, origin, swizzle);
+    auto sContext = GrSurfaceContext::Make(context, std::move(view), imageInfo.colorType(),
                                            imageInfo.alphaType(), imageInfo.refColorSpace());
     if (!sContext) {
         return nullptr;