Update GrSurfaceProxy::Copy to return a view.

Additionally this changes updates GrRenderTargetContext drawTexture to take
a view. This was done since there were a bunch of places where the result
of the copy goes straight to the drawTexture call.

Bug: skia:9556
Change-Id: If7094eb51ed343620011d03b86d603e3c6289c17
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/267856
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
diff --git a/tests/GrMipMappedTest.cpp b/tests/GrMipMappedTest.cpp
index facc9fa..7a24853 100644
--- a/tests/GrMipMappedTest.cpp
+++ b/tests/GrMipMappedTest.cpp
@@ -338,25 +338,23 @@
     surface->flush();
 }
 
-// Create a new render target and draw 'mipmapProxy' into it using the provided 'filter'.
+// Create a new render target and draw 'mipmapView' into it using the provided 'filter'.
 static std::unique_ptr<GrRenderTargetContext> draw_mipmap_into_new_render_target(
         GrRecordingContext* context, GrProxyProvider* proxyProvider, GrColorType colorType,
-        SkAlphaType alphaType, sk_sp<GrTextureProxy> mipmapProxy, GrSamplerState::Filter filter) {
+        SkAlphaType alphaType, GrSurfaceProxyView mipmapView, GrSamplerState::Filter filter) {
     GrSurfaceDesc desc;
     desc.fWidth = 1;
     desc.fHeight = 1;
-    GrSwizzle swizzle = context->priv().caps()->getReadSwizzle(mipmapProxy->backendFormat(),
-                                                               colorType);
     sk_sp<GrSurfaceProxy> renderTarget = proxyProvider->createProxy(
-            mipmapProxy->backendFormat(), desc, swizzle, GrRenderable::kYes, 1,
-            kTopLeft_GrSurfaceOrigin, GrMipMapped::kNo, SkBackingFit::kApprox, SkBudgeted::kYes,
+            mipmapView.proxy()->backendFormat(), desc, mipmapView.swizzle(), GrRenderable::kYes, 1,
+            mipmapView.origin(), GrMipMapped::kNo, SkBackingFit::kApprox, SkBudgeted::kYes,
             GrProtected::kNo);
 
     auto rtc = GrRenderTargetContext::Make(
             context, colorType, nullptr, std::move(renderTarget), kTopLeft_GrSurfaceOrigin,
             nullptr);
 
-    rtc->drawTexture(GrNoClip(), mipmapProxy, colorType, alphaType, filter, SkBlendMode::kSrcOver,
+    rtc->drawTexture(GrNoClip(), std::move(mipmapView), alphaType, filter, SkBlendMode::kSrcOver,
                      {1,1,1,1}, SkRect::MakeWH(4, 4), SkRect::MakeWH(1,1), GrAA::kYes,
                      GrQuadAAFlags::kAll, SkCanvas::kFast_SrcRectConstraint, SkMatrix::I(),
                      nullptr);
@@ -417,9 +415,11 @@
         // Mipmaps don't get marked dirty until makeClosed().
         REPORTER_ASSERT(reporter, !mipmapProxy->mipMapsAreDirty());
 
+        GrSurfaceProxyView mipmapView(mipmapProxy, kTopLeft_GrSurfaceOrigin, swizzle);
+
         // Draw the dirty mipmap texture into a render target.
         auto rtc1 = draw_mipmap_into_new_render_target(context.get(), proxyProvider, colorType,
-                                                       alphaType, mipmapProxy, Filter::kMipMap);
+                                                       alphaType, mipmapView, Filter::kMipMap);
 
         // Mipmaps should have gotten marked dirty during makeClosed, then marked clean again as
         // soon as a GrTextureResolveRenderTask was inserted. The way we know they were resolved is
@@ -433,7 +433,7 @@
 
         // Draw the now-clean mipmap texture into a second target.
         auto rtc2 = draw_mipmap_into_new_render_target(context.get(), proxyProvider, colorType,
-                                                       alphaType, mipmapProxy, Filter::kMipMap);
+                                                       alphaType, mipmapView, Filter::kMipMap);
 
         // Make sure the mipmap texture still has the same regen task.
         REPORTER_ASSERT(reporter, mipmapProxy->getLastRenderTask() == initialMipmapRegenTask);
@@ -460,7 +460,7 @@
 
         // Draw the dirty mipmap texture into a render target, but don't do mipmap filtering.
         rtc1 = draw_mipmap_into_new_render_target(context.get(), proxyProvider, colorType,
-                                                  alphaType, mipmapProxy, Filter::kBilerp);
+                                                  alphaType, mipmapView, Filter::kBilerp);
 
         // Mipmaps should have gotten marked dirty during makeClosed() when adding the dependency.
         // Since the last draw did not use mips, they will not have been regenerated and should
@@ -473,7 +473,8 @@
 
         // Draw the stil-dirty mipmap texture into a second target with mipmap filtering.
         rtc2 = draw_mipmap_into_new_render_target(context.get(), proxyProvider, colorType,
-                                                  alphaType, mipmapProxy, Filter::kMipMap);
+                                                  alphaType, std::move(mipmapView),
+                                                  Filter::kMipMap);
 
         // Make sure the mipmap texture now has a new last render task that regenerates the mips,
         // and that the mipmaps are now clean.