Fix a gpu couple tests to use views.

Bug: skia:9556
Change-Id: I1e3a1e900c9f25f249df45a0388fe63743a3bcfb
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/270068
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
diff --git a/tests/ProcessorTest.cpp b/tests/ProcessorTest.cpp
index 2b52fbb..d6a876c 100644
--- a/tests/ProcessorTest.cpp
+++ b/tests/ProcessorTest.cpp
@@ -232,13 +232,11 @@
 void test_draw_op(GrContext* context,
                   GrRenderTargetContext* rtc,
                   std::unique_ptr<GrFragmentProcessor> fp,
-                  sk_sp<GrTextureProxy> inputDataProxy,
+                  GrSurfaceProxyView inputDataView,
                   SkAlphaType inputAlphaType) {
     GrPaint paint;
-    GrSurfaceOrigin origin = inputDataProxy->origin();
-    GrSwizzle swizzle = inputDataProxy->textureSwizzle();
-    GrSurfaceProxyView view(std::move(inputDataProxy), origin, swizzle);
-    paint.addColorFragmentProcessor(GrTextureEffect::Make(std::move(view), inputAlphaType));
+    paint.addColorFragmentProcessor(GrTextureEffect::Make(std::move(inputDataView),
+                                                          inputAlphaType));
     paint.addColorFragmentProcessor(std::move(fp));
     paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
 
@@ -247,13 +245,14 @@
     rtc->priv().testingOnly_addDrawOp(std::move(op));
 }
 
-// This assumes that the output buffer will be the same size as inputDataProxy
+// This assumes that the output buffer will be the same size as inputDataView
 void render_fp(GrContext* context, GrRenderTargetContext* rtc, GrFragmentProcessor* fp,
-               sk_sp<GrTextureProxy> inputDataProxy, SkAlphaType inputAlphaType, GrColor* buffer) {
+               GrSurfaceProxyView inputDataView, SkAlphaType inputAlphaType, GrColor* buffer) {
     // test_draw_op needs to take ownership of an FP, so give it a clone that it can own
-    test_draw_op(context, rtc, fp->clone(), inputDataProxy, inputAlphaType);
-    memset(buffer, 0x0, sizeof(GrColor) * inputDataProxy->width() * inputDataProxy->height());
-    rtc->readPixels(SkImageInfo::Make(inputDataProxy->dimensions(), kRGBA_8888_SkColorType,
+    test_draw_op(context, rtc, fp->clone(), inputDataView, inputAlphaType);
+    memset(buffer, 0x0,
+           sizeof(GrColor) * inputDataView.proxy()->width() * inputDataView.proxy()->height());
+    rtc->readPixels(SkImageInfo::Make(inputDataView.proxy()->dimensions(), kRGBA_8888_SkColorType,
                                       kPremul_SkAlphaType),
                     buffer, 0, {0, 0});
 }
@@ -317,8 +316,8 @@
 
 // Creates a texture of premul colors used as the output of the fragment processor that precedes
 // the fragment processor under test. Color values are those provided by input_texel_color().
-sk_sp<GrTextureProxy> make_input_texture(GrRecordingContext* context, int width, int height,
-                                         SkScalar delta) {
+GrSurfaceProxyView make_input_texture(GrRecordingContext* context, int width, int height,
+                                      SkScalar delta) {
     GrColor* data = new GrColor[width * height];
     for (int y = 0; y < width; ++y) {
         for (int x = 0; x < height; ++x) {
@@ -333,7 +332,7 @@
     bitmap.setImmutable();
     GrBitmapTextureMaker maker(context, bitmap);
     auto[view, grCT] = maker.view(GrMipMapped::kNo);
-    return view.asTextureProxyRef();
+    return view;
 }
 
 // We tag logged  data as unpremul to avoid conversion when encoding as  PNG. The input texture
@@ -350,14 +349,11 @@
     return BipmapToBase64DataURI(bmp, dst);
 }
 
-bool log_texture_proxy(GrContext* context, sk_sp<GrTextureProxy> src, SkString* dst) {
-    SkImageInfo ii = SkImageInfo::Make(src->dimensions(), kRGBA_8888_SkColorType, kLogAlphaType);
+bool log_texture_view(GrContext* context, GrSurfaceProxyView src, SkString* dst) {
+    SkImageInfo ii = SkImageInfo::Make(src.proxy()->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,
+    auto sContext = GrSurfaceContext::Make(context, std::move(src), GrColorType::kRGBA_8888,
                                            kLogAlphaType, nullptr);
     SkBitmap bm;
     SkAssertResult(bm.tryAllocPixels(ii));
@@ -683,7 +679,7 @@
                 if (!loggedFirstFailure) {
                     // Print with ERRORF to make sure the encoded image is output
                     SkString input;
-                    log_texture_proxy(context, inputTexture1, &input);
+                    log_texture_view(context, inputTexture1, &input);
                     SkString output;
                     log_pixels(readData1.get(), kRenderSize, &output);
                     ERRORF(reporter, "Input image: %s\n\n"
@@ -707,7 +703,7 @@
                 }
                 if (!loggedFirstWarning) {
                     SkString input;
-                    log_texture_proxy(context, inputTexture1, &input);
+                    log_texture_view(context, inputTexture1, &input);
                     SkString output;
                     log_pixels(readData1.get(), kRenderSize, &output);
                     INFOF(reporter, "Input image: %s\n\n"
@@ -821,7 +817,7 @@
                                                           kRGBA_8888_SkColorType,
                                                           kUnpremul_SkAlphaType);
                             SkString input, orig, clone;
-                            if (log_texture_proxy(context, inputTexture, &input) &&
+                            if (log_texture_view(context, inputTexture, &input) &&
                                 log_pixels(readData1.get(), kRenderSize, &orig) &&
                                 log_pixels(readData2.get(), kRenderSize, &clone)) {
                                 ERRORF(reporter,
diff --git a/tests/RectangleTextureTest.cpp b/tests/RectangleTextureTest.cpp
index 7ca4a00..845bee8 100644
--- a/tests/RectangleTextureTest.cpp
+++ b/tests/RectangleTextureTest.cpp
@@ -28,19 +28,16 @@
 
 // skbug.com/5932
 static void test_basic_draw_as_src(skiatest::Reporter* reporter, GrContext* context,
-                                   sk_sp<GrTextureProxy> rectProxy, GrColorType colorType,
+                                   GrSurfaceProxyView rectView, GrColorType colorType,
                                    SkAlphaType alphaType, uint32_t expectedPixelValues[]) {
     auto rtContext = GrRenderTargetContext::Make(
-            context, colorType, nullptr, SkBackingFit::kExact, rectProxy->dimensions());
-    GrSurfaceOrigin origin = rectProxy->origin();
-    GrSwizzle swizzle = rectProxy->textureSwizzle();
-    GrSurfaceProxyView view(std::move(rectProxy), origin, swizzle);
+            context, colorType, nullptr, SkBackingFit::kExact, rectView.proxy()->dimensions());
     for (auto filter : {GrSamplerState::Filter::kNearest,
                         GrSamplerState::Filter::kBilerp,
                         GrSamplerState::Filter::kMipMap}) {
         rtContext->clear(nullptr, SkPMColor4f::FromBytes_RGBA(0xDDCCBBAA),
                          GrRenderTargetContext::CanClearFullscreen::kYes);
-        auto fp = GrTextureEffect::Make(view, alphaType, SkMatrix::I(), filter);
+        auto fp = GrTextureEffect::Make(rectView, alphaType, SkMatrix::I(), filter);
         GrPaint paint;
         paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
         paint.addColorFragmentProcessor(std::move(fp));
@@ -188,16 +185,17 @@
         SkASSERT(rectProxy->hasRestrictedSampling());
         SkASSERT(rectProxy->peekTexture()->texturePriv().hasRestrictedSampling());
 
-        test_basic_draw_as_src(reporter, context, rectProxy, GrColorType::kRGBA_8888,
+        GrSwizzle swizzle = context->priv().caps()->getReadSwizzle(rectangleTex.getBackendFormat(),
+                                                                   GrColorType::kRGBA_8888);
+        GrSurfaceProxyView view(rectProxy, origin, swizzle);
+
+        test_basic_draw_as_src(reporter, context, view, GrColorType::kRGBA_8888,
                                kPremul_SkAlphaType, refPixels);
 
         // Test copy to both a texture and RT
         TestCopyFromSurface(reporter, context, rectProxy.get(), origin, GrColorType::kRGBA_8888,
                             refPixels, "RectangleTexture-copy-from");
 
-        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);