Replace SkImage_Base::view() and ::refView() with new asView().

Make SkImage_Gpu and SkImage_GpuYUVA have their own implementations
rather than sharing one in SkImage_GpuBase.

New function takes a GrImageTexGenPolicy to enable caller to
force a new texture to be made and choose it's budgeting status rather
than receive a cached view or a view owned by the image.

It also communicates any color type changes when converting a non-
texture image to a texture.

Bug: skia:11208
Change-Id: I6b389442bf9752276a83b21021070e3190610cd7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/361356
Reviewed-by: Greg Daniel <egdaniel@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/SkGpuDevice_drawTexture.cpp b/src/gpu/SkGpuDevice_drawTexture.cpp
index d59983a..4c3de12 100644
--- a/src/gpu/SkGpuDevice_drawTexture.cpp
+++ b/src/gpu/SkGpuDevice_drawTexture.cpp
@@ -760,13 +760,14 @@
         }
     }
 
-    if (GrSurfaceProxyView view = as_IB(image)->refView(this->recordingContext(),
-                                                        GrMipmapped(mm != SkMipmapMode::kNone))) {
+    if (auto [view, ct] = as_IB(image)->asView(this->recordingContext(),
+                                               GrMipmapped(mm != SkMipmapMode::kNone)); view) {
         // This adjuster shouldn't do anything since we already asked for mip maps if necessary.
         // TODO: Pull YUVA out of draw_texture_producer and make it work directly from a view.
+        GrColorInfo colorInfo(ct, image->alphaType(), image->refColorSpace());
         GrTextureAdjuster adjuster(fContext.get(),
                                    std::move(view),
-                                   image->imageInfo().colorInfo(),
+                                   std::move(colorInfo),
                                    image->uniqueID());
         draw_texture_producer(fContext.get(), fSurfaceDrawContext.get(), clip, matrixProvider,
                               paint, &adjuster, src, dst, dstClip, srcToDst, aa, aaFlags,
@@ -857,7 +858,7 @@
         // Extract view from image, but skip YUV images so they get processed through
         // drawImageQuad and the proper effect to dynamically sample their planes.
         if (!image->isYUVA()) {
-            view = image->refView(this->recordingContext(), GrMipmapped::kNo);
+            std::tie(view, std::ignore) = image->asView(this->recordingContext(), GrMipmapped::kNo);
             if (image->isAlphaOnly()) {
                 GrSwizzle swizzle = GrSwizzle::Concat(view.swizzle(), GrSwizzle("aaaa"));
                 view = {view.detachProxy(), view.origin(), swizzle};