Store GrSurfaceProxyView on shadow ops.

Bug: skia:9556
Change-Id: I04a5a44a6483c3e4d70b84b1d7df7ea9db6d44d7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/258814
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
diff --git a/src/gpu/effects/GrShadowGeoProc.cpp b/src/gpu/effects/GrShadowGeoProc.cpp
index a1c4c54..a914dda 100644
--- a/src/gpu/effects/GrShadowGeoProc.cpp
+++ b/src/gpu/effects/GrShadowGeoProc.cpp
@@ -7,6 +7,7 @@
 
 #include "src/gpu/effects/GrShadowGeoProc.h"
 
+#include "src/gpu/GrSurfaceProxyView.h"
 #include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h"
 #include "src/gpu/glsl/GrGLSLGeometryProcessor.h"
 #include "src/gpu/glsl/GrGLSLUniformHandler.h"
@@ -61,16 +62,16 @@
 
 ///////////////////////////////////////////////////////////////////////////////
 
-GrRRectShadowGeoProc::GrRRectShadowGeoProc(const GrTextureProxy* lut)
+GrRRectShadowGeoProc::GrRRectShadowGeoProc(const GrSurfaceProxyView& lutView)
         : INHERITED(kGrRRectShadowGeoProc_ClassID) {
     fInPosition = {"inPosition", kFloat2_GrVertexAttribType, kFloat2_GrSLType};
     fInColor = {"inColor", kUByte4_norm_GrVertexAttribType, kHalf4_GrSLType};
     fInShadowParams = {"inShadowParams", kFloat3_GrVertexAttribType, kHalf3_GrSLType};
     this->setVertexAttributes(&fInPosition, 3);
 
-    SkASSERT(lut);
-    fLUTTextureSampler.reset(GrSamplerState::ClampBilerp(), lut->backendFormat(),
-                             lut->textureSwizzle());
+    SkASSERT(lutView.proxy());
+    fLUTTextureSampler.reset(GrSamplerState::ClampBilerp(), lutView.proxy()->backendFormat(),
+                             lutView.swizzle());
     this->setTextureSamplerCnt(1);
 }
 
@@ -84,7 +85,11 @@
 
 #if GR_TEST_UTILS
 GrGeometryProcessor* GrRRectShadowGeoProc::TestCreate(GrProcessorTestData* d) {
-    return GrRRectShadowGeoProc::Make(d->allocator(),
-                                      d->textureProxy(GrProcessorUnitTest::kAlphaTextureIdx).get());
+    sk_sp<GrSurfaceProxy> proxy = d->textureProxy(GrProcessorUnitTest::kAlphaTextureIdx);
+    GrSurfaceOrigin origin = proxy->origin();
+    const GrSwizzle& swizzle = proxy->textureSwizzle();
+    GrSurfaceProxyView view(std::move(proxy), origin, swizzle);
+
+    return GrRRectShadowGeoProc::Make(d->allocator(), view);
 }
 #endif
diff --git a/src/gpu/effects/GrShadowGeoProc.h b/src/gpu/effects/GrShadowGeoProc.h
index 1b9b49b..b103c86 100644
--- a/src/gpu/effects/GrShadowGeoProc.h
+++ b/src/gpu/effects/GrShadowGeoProc.h
@@ -13,6 +13,7 @@
 #include "src/gpu/GrProcessor.h"
 
 class GrGLRRectShadowGeoProc;
+class GrSurfaceProxyView;
 
 /**
  * The output color of this effect is a coverage mask for a rrect shadow,
@@ -20,8 +21,8 @@
  */
 class GrRRectShadowGeoProc : public GrGeometryProcessor {
 public:
-    static GrGeometryProcessor* Make(SkArenaAlloc* arena, const GrTextureProxy* lut) {
-        return arena->make<GrRRectShadowGeoProc>(lut);
+    static GrGeometryProcessor* Make(SkArenaAlloc* arena, const GrSurfaceProxyView& lutView) {
+        return arena->make<GrRRectShadowGeoProc>(lutView);
     }
 
     const char* name() const override { return "RRectShadow"; }
@@ -38,7 +39,7 @@
 private:
     friend class ::SkArenaAlloc; // for access to ctor
 
-    GrRRectShadowGeoProc(const GrTextureProxy* lut);
+    GrRRectShadowGeoProc(const GrSurfaceProxyView& lutView);
 
     const TextureSampler& onTextureSampler(int i) const override { return fLUTTextureSampler; }
 
@@ -54,5 +55,4 @@
     typedef GrGeometryProcessor INHERITED;
 };
 
-
 #endif
diff --git a/src/gpu/ops/GrShadowRRectOp.cpp b/src/gpu/ops/GrShadowRRectOp.cpp
index 6a4bbab..a9e7b72 100644
--- a/src/gpu/ops/GrShadowRRectOp.cpp
+++ b/src/gpu/ops/GrShadowRRectOp.cpp
@@ -192,9 +192,9 @@
     // An insetWidth > 1/2 rect width or height indicates a simple fill.
     ShadowCircularRRectOp(GrColor color, const SkRect& devRect,
                           float devRadius, bool isCircle, float blurRadius, float insetWidth,
-                          sk_sp<GrTextureProxy> falloffProxy)
+                          GrSurfaceProxyView falloffView)
             : INHERITED(ClassID())
-            , fFalloffProxy(falloffProxy) {
+            , fFalloffView(std::move(falloffView)) {
         SkRect bounds = devRect;
         SkASSERT(insetWidth > 0);
         SkScalar innerRadius = 0.0f;
@@ -541,7 +541,7 @@
     void onPrepareDraws(Target* target) override {
         // Setup geometry processor
         GrGeometryProcessor* gp = GrRRectShadowGeoProc::Make(target->allocator(),
-                                                             fFalloffProxy.get());
+                                                             fFalloffView);
 
         int instanceCount = fGeoData.count();
         SkASSERT(sizeof(CircleVertex) == gp->vertexStride());
@@ -593,7 +593,7 @@
         }
 
         auto fixedDynamicState = target->makeFixedDynamicState(1);
-        fixedDynamicState->fPrimitiveProcessorTextures[0] = fFalloffProxy.get();
+        fixedDynamicState->fPrimitiveProcessorTextures[0] = fFalloffView.proxy();
 
         GrMesh* mesh = target->allocMesh(GrPrimitiveType::kTriangles);
         mesh->setIndexed(std::move(indexBuffer), fIndexCount, firstIndex, 0, fVertCount - 1,
@@ -619,13 +619,13 @@
     }
 
     void visitProxies(const VisitProxyFunc& func) const override {
-        func(fFalloffProxy.get(), GrMipMapped(false));
+        func(fFalloffView.proxy(), GrMipMapped(false));
     }
 
     SkSTArray<1, Geometry, true> fGeoData;
     int fVertCount;
     int fIndexCount;
-    sk_sp<GrTextureProxy> fFalloffProxy;
+    GrSurfaceProxyView fFalloffView;
 
     typedef GrMeshDrawOp INHERITED;
 };
@@ -691,6 +691,10 @@
     if (!falloffTexture) {
         return nullptr;
     }
+    GrSwizzle swizzle = context->priv().caps()->getTextureSwizzle(falloffTexture->backendFormat(),
+                                                                  GrColorType::kAlpha_8);
+
+    GrSurfaceProxyView falloffView(std::move(falloffTexture), kTopLeft_GrSurfaceOrigin, swizzle);
 
     // Do any matrix crunching before we reset the draw state for device coords.
     const SkRect& rrectBounds = rrect.getBounds();
@@ -714,7 +718,7 @@
                                                  rrect.isOval(),
                                                  blurWidth,
                                                  scaledInsetWidth,
-                                                 std::move(falloffTexture));
+                                                 std::move(falloffView));
 }
 }