Switch SkImage_Base asTextureProxyRef to return view instead.

Bug: skia:9556
Change-Id: Ibcdf187021c22290013d99d8684f891576046052
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/268937
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
diff --git a/gm/image_pict.cpp b/gm/image_pict.cpp
index a51a99f..28e0bac 100644
--- a/gm/image_pict.cpp
+++ b/gm/image_pict.cpp
@@ -189,7 +189,7 @@
         SkASSERT(ctx);
         SkASSERT(ctx == fCtx.get());
 
-        if (!fView.proxy()) {
+        if (!fView) {
             return {};
         }
 
@@ -273,9 +273,9 @@
     }
 
     static void draw_as_tex(SkCanvas* canvas, SkImage* image, SkScalar x, SkScalar y) {
-        sk_sp<GrTextureProxy> proxy(as_IB(image)->asTextureProxyRef(
-                canvas->getGrContext(), GrSamplerState::Filter::kBilerp, nullptr));
-        if (!proxy) {
+        GrSurfaceProxyView view = as_IB(image)->refView(canvas->getGrContext(),
+                                                        GrSamplerState::Filter::kBilerp, nullptr);
+        if (!view) {
             // show placeholder if we have no texture
             SkPaint paint;
             paint.setStyle(SkPaint::kStroke_Style);
@@ -287,12 +287,6 @@
             return;
         }
 
-        // TODO: The asTextureProxyRef which takes a sampler and adjust needs to return a
-        // GrSurfaceProxyView instead. For now we just grab the info off the proxy.
-        GrSurfaceOrigin origin = proxy->origin();
-        const GrSwizzle& swizzle = proxy->textureSwizzle();
-        GrSurfaceProxyView view(std::move(proxy), origin, swizzle);
-
         // No API to draw a GrTexture directly, so we cheat and create a private image subclass
         sk_sp<SkImage> texImage(new SkImage_Gpu(sk_ref_sp(canvas->getGrContext()),
                                                 image->uniqueID(), std::move(view),
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 3daafbf..0f5d4fb 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -1006,7 +1006,7 @@
 
     SkASSERT(result->isTextureBacked());
     GrSurfaceProxyView view = result->view(this->context());
-    if (!view.proxy()) {
+    if (!view) {
         return;
     }
 
@@ -1050,21 +1050,17 @@
         auto filter = paint.getFilterQuality() > kNone_SkFilterQuality
                               ? GrSamplerState::Filter::kBilerp
                               : GrSamplerState::Filter::kNearest;
-        sk_sp<GrTextureProxy> clipProxy =
-                as_IB(clipImage)->asTextureProxyRef(this->context(), filter, nullptr);
+        GrSurfaceProxyView clipView = as_IB(clipImage)->refView(this->context(), filter, nullptr);
         // Fold clip matrix into ctm
         ctm.preConcat(clipMatrix);
         SkMatrix inverseClipMatrix;
 
         std::unique_ptr<GrFragmentProcessor> cfp;
-        if (clipProxy && ctm.invert(&inverseClipMatrix)) {
+        if (clipView && ctm.invert(&inverseClipMatrix)) {
             GrColorType srcColorType = SkColorTypeToGrColorType(clipImage->colorType());
 
-            GrSurfaceOrigin origin = clipProxy->origin();
-            GrSwizzle swizzle = clipProxy->textureSwizzle();
-            GrSurfaceProxyView view(std::move(clipProxy), origin, swizzle);
-            cfp = GrTextureEffect::Make(std::move(view), clipImage->alphaType(), inverseClipMatrix,
-                                        filter);
+            cfp = GrTextureEffect::Make(std::move(clipView), clipImage->alphaType(),
+                                        inverseClipMatrix, filter);
             if (srcColorType != GrColorType::kAlpha_8) {
                 cfp = GrFragmentProcessor::SwizzleOutput(std::move(cfp), GrSwizzle::AAAA());
             }
@@ -1180,7 +1176,7 @@
     // TODO: this makes a tight copy of 'bitmap' but it doesn't have to be (given SkSpecialImage's
     // semantics). Since this is cached we would have to bake the fit into the cache key though.
     auto view = GrMakeCachedBitmapProxyView(fContext.get(), bitmap);
-    if (!view.proxy()) {
+    if (!view) {
         return nullptr;
     }
 
@@ -1246,7 +1242,7 @@
                                     subset,
                                     SkBackingFit::kApprox,
                                     SkBudgeted::kYes);     // Always budgeted
-        if (!view.proxy()) {
+        if (!view) {
             return nullptr;
         }
 
@@ -1348,7 +1344,7 @@
     auto dstColorSpace = fRenderTargetContext->colorInfo().colorSpace();
     const GrSamplerState::Filter filter = compute_lattice_filter_mode(*paint);
     auto view = producer->viewForParams(&filter, nullptr);
-    if (!view.proxy()) {
+    if (!view) {
         return;
     }
     auto csxf = GrColorSpaceXform::Make(producer->colorSpace(), producer->alphaType(),
diff --git a/src/gpu/SkGpuDevice_drawTexture.cpp b/src/gpu/SkGpuDevice_drawTexture.cpp
index c68c79a..4eb9e3e 100644
--- a/src/gpu/SkGpuDevice_drawTexture.cpp
+++ b/src/gpu/SkGpuDevice_drawTexture.cpp
@@ -540,13 +540,7 @@
             uint32_t uniqueID;
             view = image->refPinnedView(this->context(), &uniqueID);
             if (!view) {
-                auto proxy = image->asTextureProxyRef(
-                        this->context(), GrSamplerState::Filter::kBilerp, nullptr);
-                if (proxy) {
-                    GrSurfaceOrigin origin = proxy->origin();
-                    const GrSwizzle& swizzle = proxy->textureSwizzle();
-                    view = GrSurfaceProxyView(std::move(proxy), origin, swizzle);
-                }
+                view = image->refView(this->context(), GrSamplerState::Filter::kBilerp, nullptr);
             }
         }
 
diff --git a/src/gpu/vk/GrVkGpu.cpp b/src/gpu/vk/GrVkGpu.cpp
index 85b199b..03a8685 100644
--- a/src/gpu/vk/GrVkGpu.cpp
+++ b/src/gpu/vk/GrVkGpu.cpp
@@ -2166,17 +2166,17 @@
             continue;
         }
         SkImage_GpuBase* gpuImage = static_cast<SkImage_GpuBase*>(as_IB(image));
-        sk_sp<GrTextureProxy> proxy = gpuImage->asTextureProxyRef(this->getContext());
-        SkASSERT(proxy);
+        const GrSurfaceProxyView* view = gpuImage->view(this->getContext());
+        SkASSERT(view && *view);
 
-        if (!proxy->isInstantiated()) {
+        if (!view->proxy()->isInstantiated()) {
             auto resourceProvider = this->getContext()->priv().resourceProvider();
-            if (!proxy->instantiate(resourceProvider)) {
+            if (!view->proxy()->instantiate(resourceProvider)) {
                 continue;
             }
         }
 
-        GrTexture* tex = proxy->peekTexture();
+        GrTexture* tex = view->proxy()->peekTexture();
         if (!tex) {
             continue;
         }
diff --git a/src/image/SkImage_Base.h b/src/image/SkImage_Base.h
index 332884b..a4abb60 100644
--- a/src/image/SkImage_Base.h
+++ b/src/image/SkImage_Base.h
@@ -57,7 +57,6 @@
     // will return nullptr unless the YUVA planes have been converted to RGBA in which case
     // that single backing proxy will be returned.
     virtual GrTextureProxy* peekProxy() const { return nullptr; }
-    virtual sk_sp<GrTextureProxy> asTextureProxyRef(GrRecordingContext*) const { return nullptr; }
 
     // If it exists, this returns a pointer to the GrSurfaceProxyView of image. The caller does not
     // own the returned view and must copy it if they want to gain a ref to the internal proxy.
@@ -65,8 +64,8 @@
     // this call will flatten a SkImage_GpuYUV to a single texture.
     virtual const GrSurfaceProxyView* view(GrRecordingContext*) const { return nullptr; }
 
-    virtual sk_sp<GrTextureProxy> asTextureProxyRef(GrRecordingContext*, GrSamplerState,
-                                                    SkScalar scaleAdjust[2]) const = 0;
+    virtual GrSurfaceProxyView refView(GrRecordingContext*, GrSamplerState,
+                                       SkScalar scaleAdjust[2]) const = 0;
     virtual GrSurfaceProxyView refPinnedView(GrRecordingContext*, uint32_t* uniqueID) const {
         return {};
     }
diff --git a/src/image/SkImage_Gpu.h b/src/image/SkImage_Gpu.h
index d153a18..1237d82 100644
--- a/src/image/SkImage_Gpu.h
+++ b/src/image/SkImage_Gpu.h
@@ -32,9 +32,6 @@
     GrTextureProxy* peekProxy() const override {
         return fView.asTextureProxy();
     }
-    sk_sp<GrTextureProxy> asTextureProxyRef(GrRecordingContext*) const override {
-        return fView.asTextureProxyRef();
-    }
 
     const GrSurfaceProxyView* view(GrRecordingContext* context) const override {
         if (!fView.proxy()) {
diff --git a/src/image/SkImage_GpuBase.cpp b/src/image/SkImage_GpuBase.cpp
index c998de1..6502979 100644
--- a/src/image/SkImage_GpuBase.cpp
+++ b/src/image/SkImage_GpuBase.cpp
@@ -189,17 +189,16 @@
     return sContext->readPixels(dstInfo, dstPixels, dstRB, {srcX, srcY});
 }
 
-sk_sp<GrTextureProxy> SkImage_GpuBase::asTextureProxyRef(GrRecordingContext* context,
-                                                         GrSamplerState params,
-                                                         SkScalar scaleAdjust[2]) const {
+GrSurfaceProxyView SkImage_GpuBase::refView(GrRecordingContext* context, GrSamplerState params,
+                                            SkScalar scaleAdjust[2]) const {
     if (!context || !fContext->priv().matches(context)) {
         SkASSERT(0);
-        return nullptr;
+        return {};
     }
 
     GrTextureAdjuster adjuster(fContext.get(), *this->view(context), this->imageInfo().colorInfo(),
                                this->uniqueID());
-    return adjuster.viewForParams(params, scaleAdjust).asTextureProxyRef();
+    return adjuster.viewForParams(params, scaleAdjust);
 }
 
 GrBackendTexture SkImage_GpuBase::onGetBackendTexture(bool flushPendingGrContextIO,
@@ -210,8 +209,9 @@
         return GrBackendTexture(); // invalid
     }
 
-    sk_sp<GrTextureProxy> proxy = this->asTextureProxyRef(direct);
-    SkASSERT(proxy);
+    const GrSurfaceProxyView* view = this->view(direct);
+    SkASSERT(view && *view);
+    GrSurfaceProxy* proxy = view->proxy();
 
     if (!proxy->isInstantiated()) {
         auto resourceProvider = direct->priv().resourceProvider();
@@ -224,7 +224,7 @@
     GrTexture* texture = proxy->peekTexture();
     if (texture) {
         if (flushPendingGrContextIO) {
-            direct->priv().flushSurface(proxy.get());
+            direct->priv().flushSurface(proxy);
         }
         if (origin) {
             *origin = proxy->origin();
@@ -246,14 +246,14 @@
         return nullptr;
     }
 
-    sk_sp<GrTextureProxy> refProxy = this->asTextureProxyRef(direct);
-    SkASSERT(refProxy && !refProxy->isInstantiated());
+    const GrSurfaceProxyView* view = this->view(direct);
+    SkASSERT(view && *view && !view->proxy()->isInstantiated());
 
-    if (!refProxy->instantiate(direct->priv().resourceProvider())) {
+    if (!view->proxy()->instantiate(direct->priv().resourceProvider())) {
         return nullptr;
     }
 
-    return refProxy->peekTexture();
+    return view->proxy()->peekTexture();
 }
 
 bool SkImage_GpuBase::onIsValid(GrContext* context) const {
diff --git a/src/image/SkImage_GpuBase.h b/src/image/SkImage_GpuBase.h
index db5a26f..6337ff1 100644
--- a/src/image/SkImage_GpuBase.h
+++ b/src/image/SkImage_GpuBase.h
@@ -28,14 +28,8 @@
     bool onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRB,
                       int srcX, int srcY, CachingHint) const override;
 
-    sk_sp<GrTextureProxy> asTextureProxyRef(GrRecordingContext* context) const override {
-        // we shouldn't end up calling this
-        SkASSERT(false);
-        return this->INHERITED::asTextureProxyRef(context);
-    }
-
-    sk_sp<GrTextureProxy> asTextureProxyRef(GrRecordingContext*, GrSamplerState,
-                                            SkScalar scaleAdjust[2]) const final;
+    GrSurfaceProxyView refView(GrRecordingContext*, GrSamplerState,
+                               SkScalar scaleAdjust[2]) const final;
 
     GrSurfaceProxyView refPinnedView(GrRecordingContext* context, uint32_t* uniqueID) const final {
         *uniqueID = this->uniqueID();
diff --git a/src/image/SkImage_GpuYUVA.cpp b/src/image/SkImage_GpuYUVA.cpp
index 8184384..57217c4 100644
--- a/src/image/SkImage_GpuYUVA.cpp
+++ b/src/image/SkImage_GpuYUVA.cpp
@@ -169,11 +169,6 @@
     }
 }
 
-sk_sp<GrTextureProxy> SkImage_GpuYUVA::asTextureProxyRef(GrRecordingContext* context) const {
-    this->flattenToRGB(context);
-    return fRGBView.asTextureProxyRef();
-}
-
 GrSurfaceProxyView SkImage_GpuYUVA::refMippedView(GrRecordingContext* context) const {
     // if invalid or already has miplevels
     this->flattenToRGB(context);
diff --git a/src/image/SkImage_GpuYUVA.h b/src/image/SkImage_GpuYUVA.h
index 8e2ab35..914a1fc 100644
--- a/src/image/SkImage_GpuYUVA.h
+++ b/src/image/SkImage_GpuYUVA.h
@@ -33,7 +33,6 @@
     // This returns the single backing proxy if the YUV channels have already been flattened but
     // nullptr if they have not.
     GrTextureProxy* peekProxy() const override;
-    sk_sp<GrTextureProxy> asTextureProxyRef(GrRecordingContext*) const override;
 
     const GrSurfaceProxyView* view(GrRecordingContext* context) const override;
 
diff --git a/src/image/SkImage_Lazy.cpp b/src/image/SkImage_Lazy.cpp
index 49d0650..abf5547 100644
--- a/src/image/SkImage_Lazy.cpp
+++ b/src/image/SkImage_Lazy.cpp
@@ -238,15 +238,14 @@
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
 #if SK_SUPPORT_GPU
-sk_sp<GrTextureProxy> SkImage_Lazy::asTextureProxyRef(GrRecordingContext* context,
-                                                      GrSamplerState params,
-                                                      SkScalar scaleAdjust[2]) const {
+GrSurfaceProxyView SkImage_Lazy::refView(GrRecordingContext* context, GrSamplerState params,
+                                         SkScalar scaleAdjust[2]) const {
     if (!context) {
-        return nullptr;
+        return {};
     }
 
     GrImageTextureMaker textureMaker(context, this, kAllow_CachingHint);
-    return textureMaker.viewForParams(params, scaleAdjust).asTextureProxyRef();
+    return textureMaker.viewForParams(params, scaleAdjust);
 }
 #endif
 
diff --git a/src/image/SkImage_Lazy.h b/src/image/SkImage_Lazy.h
index afbd28c..224eaf0 100644
--- a/src/image/SkImage_Lazy.h
+++ b/src/image/SkImage_Lazy.h
@@ -42,9 +42,8 @@
     bool onReadPixels(const SkImageInfo&, void*, size_t, int srcX, int srcY,
                       CachingHint) const override;
 #if SK_SUPPORT_GPU
-    sk_sp<GrTextureProxy> asTextureProxyRef(GrRecordingContext*,
-                                            GrSamplerState,
-                                            SkScalar scaleAdjust[2]) const override;
+    GrSurfaceProxyView refView(GrRecordingContext*, GrSamplerState,
+                               SkScalar scaleAdjust[2]) const override;
     sk_sp<SkCachedData> getPlanes(SkYUVASizeInfo*, SkYUVAIndex[4],
                                   SkYUVColorSpace*, const void* planes[4]) override;
 #endif
diff --git a/src/image/SkImage_Raster.cpp b/src/image/SkImage_Raster.cpp
index f2fc42e..9e573a1 100644
--- a/src/image/SkImage_Raster.cpp
+++ b/src/image/SkImage_Raster.cpp
@@ -73,13 +73,14 @@
                    uint32_t id = kNeedNewImageUniqueID);
     ~SkImage_Raster() override;
 
-    bool onReadPixels(const SkImageInfo&, void*, size_t, int srcX, int srcY, CachingHint) const override;
+    bool onReadPixels(const SkImageInfo&, void*, size_t, int srcX, int srcY,
+                      CachingHint) const override;
     bool onPeekPixels(SkPixmap*) const override;
     const SkBitmap* onPeekBitmap() const override { return &fBitmap; }
 
 #if SK_SUPPORT_GPU
-    sk_sp<GrTextureProxy> asTextureProxyRef(GrRecordingContext*, GrSamplerState,
-                                            SkScalar scaleAdjust[2]) const override;
+    GrSurfaceProxyView refView(GrRecordingContext*, GrSamplerState,
+                               SkScalar scaleAdjust[2]) const override;
 #endif
 
     bool getROPixels(SkBitmap*, CachingHint) const override;
@@ -167,21 +168,20 @@
 }
 
 #if SK_SUPPORT_GPU
-sk_sp<GrTextureProxy> SkImage_Raster::asTextureProxyRef(GrRecordingContext* context,
-                                                        GrSamplerState params,
-                                                        SkScalar scaleAdjust[2]) const {
+GrSurfaceProxyView SkImage_Raster::refView(GrRecordingContext* context, GrSamplerState params,
+                                           SkScalar scaleAdjust[2]) const {
     if (!context) {
-        return nullptr;
+        return {};
     }
 
     uint32_t uniqueID;
     if (GrSurfaceProxyView view = this->refPinnedView(context, &uniqueID)) {
         GrTextureAdjuster adjuster(context, std::move(view), fBitmap.info().colorInfo(),
                                    fPinnedUniqueID);
-        return adjuster.viewForParams(params, scaleAdjust).asTextureProxyRef();
+        return adjuster.viewForParams(params, scaleAdjust);
     }
 
-    return GrRefCachedBitmapView(context, fBitmap, params, scaleAdjust).asTextureProxyRef();
+    return GrRefCachedBitmapView(context, fBitmap, params, scaleAdjust);
 }
 #endif
 
diff --git a/src/shaders/SkImageShader.cpp b/src/shaders/SkImageShader.cpp
index dfb0bce..f82772c 100755
--- a/src/shaders/SkImageShader.cpp
+++ b/src/shaders/SkImageShader.cpp
@@ -214,16 +214,11 @@
             args.fContext->priv().options().fSharpenMipmappedTextures, &doBicubic);
     GrSamplerState samplerState(wrapModes, textureFilterMode);
     SkScalar scaleAdjust[2] = { 1.0f, 1.0f };
-    sk_sp<GrTextureProxy> proxy(as_IB(fImage)->asTextureProxyRef(args.fContext, samplerState,
-                                                                 scaleAdjust));
-    if (!proxy) {
+    GrSurfaceProxyView view = as_IB(fImage)->refView(args.fContext, samplerState, scaleAdjust);
+    if (!view) {
         return nullptr;
     }
 
-    GrSurfaceOrigin origin = proxy->origin();
-    GrSwizzle swizzle = proxy->textureSwizzle();
-    GrSurfaceProxyView view(std::move(proxy), origin, swizzle);
-
     SkAlphaType srcAlphaType = fImage->alphaType();
 
     lmInverse.postScale(scaleAdjust[0], scaleAdjust[1]);
diff --git a/tests/GLBackendSurfaceTest.cpp b/tests/GLBackendSurfaceTest.cpp
index 96a839c..0f1af77 100644
--- a/tests/GLBackendSurfaceTest.cpp
+++ b/tests/GLBackendSurfaceTest.cpp
@@ -63,10 +63,10 @@
                                      kRGBA_8888_SkColorType, kPremul_SkAlphaType, nullptr);
     REPORTER_ASSERT(reporter, wrappedImage);
 
-    sk_sp<GrTextureProxy> texProxy = as_IB(wrappedImage)->asTextureProxyRef(context);
-    REPORTER_ASSERT(reporter, texProxy.get());
-    REPORTER_ASSERT(reporter, texProxy->isInstantiated());
-    auto texture = static_cast<GrGLTexture*>(texProxy->peekTexture());
+    const GrSurfaceProxyView* view = as_IB(wrappedImage)->view(context);
+    REPORTER_ASSERT(reporter, view);
+    REPORTER_ASSERT(reporter, view->proxy()->isInstantiated());
+    auto texture = static_cast<GrGLTexture*>(view->proxy()->peekTexture());
     REPORTER_ASSERT(reporter, texture);
     auto parameters = texture->parameters();
     REPORTER_ASSERT(reporter, parameters);
diff --git a/tests/GrMipMappedTest.cpp b/tests/GrMipMappedTest.cpp
index a7b8fd8..8d15582 100644
--- a/tests/GrMipMappedTest.cpp
+++ b/tests/GrMipMappedTest.cpp
@@ -66,7 +66,13 @@
                                                  kRGBA_8888_SkColorType,
                                                  kPremul_SkAlphaType, nullptr,
                                                  nullptr, nullptr);
-                proxy = as_IB(image)->asTextureProxyRef(context);
+                const GrSurfaceProxyView* view = as_IB(image)->view(context);
+                REPORTER_ASSERT(reporter, view);
+                if (!view) {
+                    context->deleteBackendTexture(backendTex);
+                    return;
+                }
+                proxy = view->asTextureProxyRef();
             }
             REPORTER_ASSERT(reporter, proxy);
             if (!proxy) {
diff --git a/tests/ImageTest.cpp b/tests/ImageTest.cpp
index 181a795..a2c70c1 100644
--- a/tests/ImageTest.cpp
+++ b/tests/ImageTest.cpp
@@ -966,44 +966,42 @@
             sk_sp<SkImage> refImg(imageMaker(ctx));
 
             // Any context should be able to borrow the texture at this point
-            sk_sp<GrTextureProxy> proxy = as_IB(refImg)->asTextureProxyRef(
-                    ctx, GrSamplerState::Filter::kNearest, nullptr);
-            REPORTER_ASSERT(reporter, proxy);
+            GrSurfaceProxyView view =
+                    as_IB(refImg)->refView(ctx, GrSamplerState::Filter::kNearest, nullptr);
+            REPORTER_ASSERT(reporter, view);
 
             // But once it's borrowed, no other context should be able to borrow
             otherTestContext->makeCurrent();
-            sk_sp<GrTextureProxy> otherProxy = as_IB(refImg)->asTextureProxyRef(
-                    otherCtx, GrSamplerState::Filter::kNearest, nullptr);
-            REPORTER_ASSERT(reporter, !otherProxy);
+            GrSurfaceProxyView otherView =
+                    as_IB(refImg)->refView(otherCtx, GrSamplerState::Filter::kNearest, nullptr);
+            REPORTER_ASSERT(reporter, !otherView);
 
             // Original context (that's already borrowing) should be okay
             testContext->makeCurrent();
-            sk_sp<GrTextureProxy> proxySecondRef = as_IB(refImg)->asTextureProxyRef(
-                    ctx, GrSamplerState::Filter::kNearest, nullptr);
-            REPORTER_ASSERT(reporter, proxySecondRef);
+            GrSurfaceProxyView viewSecondRef =
+                    as_IB(refImg)->refView(ctx, GrSamplerState::Filter::kNearest, nullptr);
+            REPORTER_ASSERT(reporter, viewSecondRef);
 
             // Release first ref from the original context
-            proxy.reset(nullptr);
+            view.reset();
 
             // We released one proxy but not the other from the current borrowing context. Make sure
             // a new context is still not able to borrow the texture.
             otherTestContext->makeCurrent();
-            otherProxy = as_IB(refImg)->asTextureProxyRef(
-                    otherCtx, GrSamplerState::Filter::kNearest, nullptr);
-            REPORTER_ASSERT(reporter, !otherProxy);
+            otherView = as_IB(refImg)->refView(otherCtx, GrSamplerState::Filter::kNearest, nullptr);
+            REPORTER_ASSERT(reporter, !otherView);
 
             // Release second ref from the original context
             testContext->makeCurrent();
-            proxySecondRef.reset(nullptr);
+            viewSecondRef.reset();
 
             // Now we should be able to borrow the texture from the other context
             otherTestContext->makeCurrent();
-            otherProxy = as_IB(refImg)->asTextureProxyRef(
-                    otherCtx, GrSamplerState::Filter::kNearest, nullptr);
-            REPORTER_ASSERT(reporter, otherProxy);
+            otherView = as_IB(refImg)->refView(otherCtx, GrSamplerState::Filter::kNearest, nullptr);
+            REPORTER_ASSERT(reporter, otherView);
 
             // Release everything
-            otherProxy.reset(nullptr);
+            otherView.reset();
             refImg.reset(nullptr);
         }
     }
@@ -1040,9 +1038,9 @@
             sk_sp<SkImage> image = SkImage::MakeCrossContextFromPixmap(ctx, pixmap, false);
             REPORTER_ASSERT(reporter, image);
 
-            sk_sp<GrTextureProxy> proxy =
-                    as_IB(image)->asTextureProxyRef(ctx, GrSamplerState::Filter::kNearest, nullptr);
-            REPORTER_ASSERT(reporter, proxy);
+            GrSurfaceProxyView view =
+                    as_IB(image)->refView(ctx, GrSamplerState::Filter::kNearest, nullptr);
+            REPORTER_ASSERT(reporter, view);
 
             bool expectAlpha = kAlpha_8_SkColorType == ct;
             GrColorType grCT = SkColorTypeToGrColorType(image->colorType());
@@ -1432,7 +1430,7 @@
     REPORTER_ASSERT(reporter, static_cast<SkImage_GpuYUVA*>(as_IB(i2.get()))->isTextureBacked());
 
     // Flatten it and repeat.
-    as_IB(i2.get())->asTextureProxyRef(c);
+    as_IB(i2.get())->view(c);
     REPORTER_ASSERT(reporter,
                     static_cast<SkImage_GpuYUVA*>(as_IB(i2.get()))->testingOnly_IsFlattened());
     REPORTER_ASSERT(reporter, static_cast<SkImage_GpuYUVA*>(as_IB(i2.get()))->isTextureBacked());
@@ -1454,7 +1452,7 @@
     // make the YUVA planes from backend textures rather than pixmaps that GrContext must upload.
     // Calling numFlushes rebases the flush count from here.
     numFlushes();
-    as_IB(i2.get())->asTextureProxyRef(c);
+    as_IB(i2.get())->view(c);
     REPORTER_ASSERT(reporter,
                     static_cast<SkImage_GpuYUVA*>(as_IB(i2.get()))->testingOnly_IsFlattened());
     REPORTER_ASSERT(reporter, static_cast<SkImage_GpuYUVA*>(as_IB(i2.get()))->isTextureBacked());
diff --git a/tests/VkBackendSurfaceTest.cpp b/tests/VkBackendSurfaceTest.cpp
index 58a2b9c..edd80f5 100644
--- a/tests/VkBackendSurfaceTest.cpp
+++ b/tests/VkBackendSurfaceTest.cpp
@@ -67,10 +67,10 @@
                                                            kPremul_SkAlphaType, nullptr);
     REPORTER_ASSERT(reporter, wrappedImage.get());
 
-    sk_sp<GrTextureProxy> texProxy = as_IB(wrappedImage)->asTextureProxyRef(context);
-    REPORTER_ASSERT(reporter, texProxy.get());
-    REPORTER_ASSERT(reporter, texProxy->isInstantiated());
-    GrTexture* texture = texProxy->peekTexture();
+    const GrSurfaceProxyView* view = as_IB(wrappedImage)->view(context);
+    REPORTER_ASSERT(reporter, view);
+    REPORTER_ASSERT(reporter, view->proxy()->isInstantiated());
+    GrTexture* texture = view->proxy()->peekTexture();
     REPORTER_ASSERT(reporter, texture);
 
     // Verify that modifying the layout via the GrVkTexture is reflected in the GrBackendTexture