Lift TextureSampler's proxy to SurfaceProxy

Now that the UniformHandlers can accept SurfaceProxies directly, there's
no need to have the restricted type on TextureSampler anymore. This will
make them one step closer to compatibility with GrSurfaceProxyView.

While making these changes, several effects performed their own source
coord normalization by peeking the texture. I updated these to just
use the proxy's backing store dimensions.

Bug: skia:9556
Change-Id: I97183e8453b7a3db86cd90d614c8c959b3707abb
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/255978
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
diff --git a/src/effects/SkTableColorFilter.cpp b/src/effects/SkTableColorFilter.cpp
index 601da8f..576fac6 100644
--- a/src/effects/SkTableColorFilter.cpp
+++ b/src/effects/SkTableColorFilter.cpp
@@ -264,7 +264,7 @@
 
     bool onIsEqual(const GrFragmentProcessor&) const override { return true; }
 
-    ColorTableEffect(sk_sp<GrTextureProxy> proxy)
+    ColorTableEffect(sk_sp<GrSurfaceProxy> proxy)
             : INHERITED(kColorTableEffect_ClassID,
                         kNone_OptimizationFlags) // Not bothering with table-specific optimizations.
             , fTextureSampler(std::move(proxy)) {
diff --git a/src/effects/imagefilters/SkDisplacementMapEffect.cpp b/src/effects/imagefilters/SkDisplacementMapEffect.cpp
index 8b4284d..f18072b 100644
--- a/src/effects/imagefilters/SkDisplacementMapEffect.cpp
+++ b/src/effects/imagefilters/SkDisplacementMapEffect.cpp
@@ -648,11 +648,11 @@
 void GrGLDisplacementMapEffect::onSetData(const GrGLSLProgramDataManager& pdman,
                                           const GrFragmentProcessor& proc) {
     const GrDisplacementMapEffect& displacementMap = proc.cast<GrDisplacementMapEffect>();
-    GrTextureProxy* proxy = displacementMap.textureSampler(1).proxy();
-    GrTexture* colorTex = proxy->peekTexture();
+    GrSurfaceProxy* proxy = displacementMap.textureSampler(1).proxy();
+    SkISize texDimensions = proxy->backingStoreDimensions();
 
-    SkScalar scaleX = displacementMap.scale().fX / colorTex->width();
-    SkScalar scaleY = displacementMap.scale().fY / colorTex->height();
+    SkScalar scaleX = displacementMap.scale().fX / texDimensions.width();
+    SkScalar scaleY = displacementMap.scale().fY / texDimensions.height();
     pdman.set2f(fScaleUni, SkScalarToFloat(scaleX),
                 proxy->origin() == kTopLeft_GrSurfaceOrigin ?
                 SkScalarToFloat(scaleY) : SkScalarToFloat(-scaleY));
diff --git a/src/effects/imagefilters/SkLightingImageFilter.cpp b/src/effects/imagefilters/SkLightingImageFilter.cpp
index 43d32dc..e18e7ab 100644
--- a/src/effects/imagefilters/SkLightingImageFilter.cpp
+++ b/src/effects/imagefilters/SkLightingImageFilter.cpp
@@ -1840,11 +1840,11 @@
         fLight = lighting.light()->createGLLight();
     }
 
-    GrTextureProxy* proxy = lighting.textureSampler(0).proxy();
-    GrTexture* texture = proxy->peekTexture();
+    GrSurfaceProxy* proxy = lighting.textureSampler(0).proxy();
+    SkISize textureDims = proxy->backingStoreDimensions();
 
     float ySign = proxy->origin() == kTopLeft_GrSurfaceOrigin ? -1.0f : 1.0f;
-    pdman.set2f(fImageIncrementUni, 1.0f / texture->width(), ySign / texture->height());
+    pdman.set2f(fImageIncrementUni, 1.0f / textureDims.width(), ySign / textureDims.height());
     pdman.set1f(fSurfaceScaleUni, lighting.surfaceScale());
     sk_sp<SkImageFilterLight> transformedLight(
             lighting.light()->transform(lighting.filterMatrix()));
diff --git a/src/gpu/GrCoordTransform.h b/src/gpu/GrCoordTransform.h
index d592c21..db32671 100644
--- a/src/gpu/GrCoordTransform.h
+++ b/src/gpu/GrCoordTransform.h
@@ -34,7 +34,7 @@
      * Create a transformation that maps [0, 1] to a proxy's boundaries. The proxy origin also
      * implies whether a y-reversal should be performed.
      */
-    GrCoordTransform(GrTextureProxy* proxy) {
+    GrCoordTransform(GrSurfaceProxy* proxy) {
         SkASSERT(proxy);
         SkDEBUGCODE(fInProcessor = false);
         this->reset(SkMatrix::I(), proxy);
@@ -44,7 +44,7 @@
      * Create a transformation from a matrix. The proxy origin also implies whether a y-reversal
      * should be performed.
      */
-    GrCoordTransform(const SkMatrix& m, GrTextureProxy* proxy) {
+    GrCoordTransform(const SkMatrix& m, GrSurfaceProxy* proxy) {
         SkASSERT(proxy);
         SkDEBUGCODE(fInProcessor = false);
         this->reset(m, proxy);
@@ -93,7 +93,7 @@
     }
 
     const SkMatrix& getMatrix() const { return fMatrix; }
-    const GrTextureProxy* proxy() const { return fProxy; }
+    const GrSurfaceProxy* proxy() const { return fProxy; }
     bool normalize() const { return fNormalize; }
     bool reverseY() const { return fReverseY; }
 
@@ -108,12 +108,12 @@
     }
 
 private:
-    void reset(const SkMatrix& m, GrTextureProxy* proxy = nullptr) {
+    void reset(const SkMatrix& m, GrSurfaceProxy* proxy = nullptr) {
         SkASSERT(!fInProcessor);
 
         fMatrix = m;
         fProxy = proxy;
-        fNormalize = proxy && proxy->textureType() != GrTextureType::kRectangle;
+        fNormalize = proxy && proxy->backendFormat().textureType() != GrTextureType::kRectangle;
         fReverseY = proxy && kBottomLeft_GrSurfaceOrigin == proxy->origin();
         fComputeInVertexShader = true;
     }
@@ -124,7 +124,7 @@
     bool operator!=(const GrCoordTransform& that) const;
 
     SkMatrix                fMatrix;
-    const GrTextureProxy*   fProxy;
+    const GrSurfaceProxy*   fProxy;
     bool                    fNormalize;
     bool                    fReverseY;
     bool                    fComputeInVertexShader;
diff --git a/src/gpu/GrFragmentProcessor.cpp b/src/gpu/GrFragmentProcessor.cpp
index 1e1f2e4..933bc01 100644
--- a/src/gpu/GrFragmentProcessor.cpp
+++ b/src/gpu/GrFragmentProcessor.cpp
@@ -418,14 +418,17 @@
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-GrFragmentProcessor::TextureSampler::TextureSampler(sk_sp<GrTextureProxy> proxy,
+GrFragmentProcessor::TextureSampler::TextureSampler(sk_sp<GrSurfaceProxy> proxy,
                                                     const GrSamplerState& samplerState) {
     this->reset(std::move(proxy), samplerState);
 }
 
-void GrFragmentProcessor::TextureSampler::reset(sk_sp<GrTextureProxy> proxy,
+void GrFragmentProcessor::TextureSampler::reset(sk_sp<GrSurfaceProxy> proxy,
                                                 const GrSamplerState& samplerState) {
+    SkASSERT(proxy->asTextureProxy());
     fProxy = std::move(proxy);
     fSamplerState = samplerState;
-    fSamplerState.setFilterMode(SkTMin(samplerState.filter(), this->proxy()->highestFilterMode()));
+    fSamplerState.setFilterMode(
+            SkTMin(samplerState.filter(),
+                   GrTextureProxy::HighestFilterMode(fProxy->backendFormat().textureType())));
 }
diff --git a/src/gpu/GrFragmentProcessor.h b/src/gpu/GrFragmentProcessor.h
index 275d471..9188081 100644
--- a/src/gpu/GrFragmentProcessor.h
+++ b/src/gpu/GrFragmentProcessor.h
@@ -430,11 +430,11 @@
             : fProxy(that.fProxy)
             , fSamplerState(that.fSamplerState) {}
 
-    TextureSampler(sk_sp<GrTextureProxy>, const GrSamplerState& = GrSamplerState::ClampNearest());
+    TextureSampler(sk_sp<GrSurfaceProxy>, const GrSamplerState& = GrSamplerState::ClampNearest());
 
     TextureSampler& operator=(const TextureSampler&) = delete;
 
-    void reset(sk_sp<GrTextureProxy>, const GrSamplerState&);
+    void reset(sk_sp<GrSurfaceProxy>, const GrSamplerState&);
 
     bool operator==(const TextureSampler& that) const {
         return this->proxy()->underlyingUniqueID() == that.proxy()->underlyingUniqueID() &&
@@ -451,14 +451,14 @@
         return fProxy->peekTexture();
     }
 
-    GrTextureProxy* proxy() const { return fProxy.get(); }
+    GrSurfaceProxy* proxy() const { return fProxy.get(); }
     const GrSamplerState& samplerState() const { return fSamplerState; }
     const GrSwizzle& swizzle() const { return this->proxy()->textureSwizzle(); }
 
     bool isInitialized() const { return SkToBool(fProxy.get()); }
 
 private:
-    sk_sp<GrTextureProxy> fProxy;
+    sk_sp<GrSurfaceProxy> fProxy;
     GrSamplerState        fSamplerState;
 };
 
diff --git a/src/gpu/GrTextureProxy.cpp b/src/gpu/GrTextureProxy.cpp
index eb5b8bb..26d95ab 100644
--- a/src/gpu/GrTextureProxy.cpp
+++ b/src/gpu/GrTextureProxy.cpp
@@ -130,11 +130,6 @@
     fTextureProxy->fDeferredUploader.reset();
 }
 
-GrSamplerState::Filter GrTextureProxy::highestFilterMode() const {
-    return this->hasRestrictedSampling() ? GrSamplerState::Filter::kBilerp
-                                         : GrSamplerState::Filter::kMipMap;
-}
-
 GrMipMapped GrTextureProxy::mipMapped() const {
     if (this->isInstantiated()) {
         return this->peekTexture()->texturePriv().mipMapped();
@@ -147,6 +142,11 @@
                                   this->proxyMipMapped(), !this->priv().isExact());
 }
 
+GrSamplerState::Filter GrTextureProxy::HighestFilterMode(GrTextureType textureType) {
+    return GrTextureTypeHasRestrictedSampling(textureType) ? GrSamplerState::Filter::kBilerp
+                                                           : GrSamplerState::Filter::kMipMap;
+}
+
 bool GrTextureProxy::ProxiesAreCompatibleAsDynamicState(const GrSurfaceProxy* first,
                                                         const GrSurfaceProxy* second) {
     // In order to be compatible, the proxies should also have the same texture type, but since
diff --git a/src/gpu/GrTextureProxy.h b/src/gpu/GrTextureProxy.h
index 8461016..8c23a58 100644
--- a/src/gpu/GrTextureProxy.h
+++ b/src/gpu/GrTextureProxy.h
@@ -26,8 +26,6 @@
     // Actually instantiate the backing texture, if necessary
     bool instantiate(GrResourceProvider*) override;
 
-    GrSamplerState::Filter highestFilterMode() const;
-
     // If we are instantiated and have a target, return the mip state of that target. Otherwise
     // returns the proxy's mip state from creation time. This is useful for lazy proxies which may
     // claim to not need mips at creation time, but the instantiation happens to give us a mipped
@@ -60,6 +58,9 @@
         return GrTextureTypeHasRestrictedSampling(this->textureType());
     }
 
+    // Returns the highest allowed filter mode for a given texture type
+    static GrSamplerState::Filter HighestFilterMode(const GrTextureType textureType);
+
     // Returns true if the passed in proxies can be used as dynamic state together when flushing
     // draws to the gpu. This accepts GrSurfaceProxy since the information needed is defined on
     // that type, but this function exists in GrTextureProxy because it's only relevant when the
diff --git a/src/gpu/effects/GrAlphaThresholdFragmentProcessor.fp b/src/gpu/effects/GrAlphaThresholdFragmentProcessor.fp
index cab332b..d9d1933 100644
--- a/src/gpu/effects/GrAlphaThresholdFragmentProcessor.fp
+++ b/src/gpu/effects/GrAlphaThresholdFragmentProcessor.fp
@@ -18,7 +18,7 @@
 }
 
 @make {
-    static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> mask,
+    static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrSurfaceProxy> mask,
                                                      float innerThreshold,
                                                      float outerThreshold,
                                                      const SkIRect& bounds) {
diff --git a/src/gpu/effects/GrBicubicEffect.cpp b/src/gpu/effects/GrBicubicEffect.cpp
index d78cb74..973ef45 100644
--- a/src/gpu/effects/GrBicubicEffect.cpp
+++ b/src/gpu/effects/GrBicubicEffect.cpp
@@ -145,24 +145,24 @@
 void GrGLBicubicEffect::onSetData(const GrGLSLProgramDataManager& pdman,
                                   const GrFragmentProcessor& processor) {
     const GrBicubicEffect& bicubicEffect = processor.cast<GrBicubicEffect>();
-    GrTextureProxy* proxy = processor.textureSampler(0).proxy();
-    GrTexture* texture = proxy->peekTexture();
+    GrSurfaceProxy* proxy = processor.textureSampler(0).proxy();
+    SkISize textureDims = proxy->backingStoreDimensions();
 
     float dims[4] = {0, 0, 0, 0};
     if (bicubicEffect.direction() != GrBicubicEffect::Direction::kY) {
-        dims[0] = 1.0f / texture->width();
-        dims[2] = texture->width();
+        dims[0] = 1.0f / textureDims.width();
+        dims[2] = textureDims.width();
     }
     if (bicubicEffect.direction() != GrBicubicEffect::Direction::kX) {
-        dims[1] = 1.0f / texture->height();
-        dims[3] = texture->height();
+        dims[1] = 1.0f / textureDims.height();
+        dims[3] = textureDims.height();
     }
     pdman.set4fv(fDimensions, 1, dims);
     fDomain.setData(pdman, bicubicEffect.domain(), proxy,
                     processor.textureSampler(0).samplerState());
 }
 
-GrBicubicEffect::GrBicubicEffect(sk_sp<GrTextureProxy> proxy, const SkMatrix& matrix,
+GrBicubicEffect::GrBicubicEffect(sk_sp<GrSurfaceProxy> proxy, const SkMatrix& matrix,
                                  const SkRect& domain, const GrSamplerState::WrapMode wrapModes[2],
                                  GrTextureDomain::Mode modeX, GrTextureDomain::Mode modeY,
                                  Direction direction, SkAlphaType alphaType)
diff --git a/src/gpu/effects/GrBicubicEffect.h b/src/gpu/effects/GrBicubicEffect.h
index 71e8fcf..319f1d9 100644
--- a/src/gpu/effects/GrBicubicEffect.h
+++ b/src/gpu/effects/GrBicubicEffect.h
@@ -44,7 +44,7 @@
     /**
      * Create a Mitchell filter effect with specified texture matrix with clamp wrap mode.
      */
-    static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy,
+    static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrSurfaceProxy> proxy,
                                                      const SkMatrix& matrix,
                                                      Direction direction,
                                                      SkAlphaType alphaType) {
@@ -57,7 +57,7 @@
     /**
      * Create a Mitchell filter effect with specified texture matrix and x/y tile modes.
      */
-    static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy,
+    static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrSurfaceProxy> proxy,
                                                      const SkMatrix& matrix,
                                                      const GrSamplerState::WrapMode wrapModes[2],
                                                      Direction direction,
@@ -73,7 +73,7 @@
      * supports providing modes for the texture domain explicitly, in the event that it should
      * override the behavior of the sampler's tile mode (e.g. clamp to border unsupported).
      */
-    static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy,
+    static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrSurfaceProxy> proxy,
                                                      const SkMatrix& matrix,
                                                      const GrSamplerState::WrapMode wrapModes[2],
                                                      GrTextureDomain::Mode modeX,
@@ -96,7 +96,7 @@
     /**
      * Create a Mitchell filter effect with a texture matrix and a domain.
      */
-    static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy,
+    static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrSurfaceProxy> proxy,
                                                      const SkMatrix& matrix,
                                                      const SkRect& domain,
                                                      Direction direction,
@@ -118,7 +118,7 @@
                                  GrSamplerState::Filter* filterMode);
 
 private:
-    GrBicubicEffect(sk_sp<GrTextureProxy>, const SkMatrix& matrix, const SkRect& domain,
+    GrBicubicEffect(sk_sp<GrSurfaceProxy>, const SkMatrix& matrix, const SkRect& domain,
                     const GrSamplerState::WrapMode wrapModes[2], GrTextureDomain::Mode modeX,
                     GrTextureDomain::Mode modeY, Direction direction, SkAlphaType);
     explicit GrBicubicEffect(const GrBicubicEffect&);
diff --git a/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp b/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp
index dd6e7c5..231c1b6 100644
--- a/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp
+++ b/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp
@@ -211,7 +211,7 @@
 }
 
 GrGaussianConvolutionFragmentProcessor::GrGaussianConvolutionFragmentProcessor(
-        sk_sp<GrTextureProxy> proxy,
+        sk_sp<GrSurfaceProxy> proxy,
         SkAlphaType alphaType,
         Direction direction,
         int radius,
diff --git a/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.h b/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.h
index b329b1d..205b981 100644
--- a/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.h
+++ b/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.h
@@ -22,7 +22,7 @@
     enum class Direction { kX, kY };
 
     /// Convolve with a Gaussian kernel
-    static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy,
+    static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrSurfaceProxy> proxy,
                                                      SkAlphaType alphaType,
                                                      Direction dir,
                                                      int halfWidth,
@@ -72,7 +72,7 @@
 
 private:
     /// Convolve with a Gaussian kernel
-    GrGaussianConvolutionFragmentProcessor(sk_sp<GrTextureProxy>, SkAlphaType alphaType, Direction,
+    GrGaussianConvolutionFragmentProcessor(sk_sp<GrSurfaceProxy>, SkAlphaType alphaType, Direction,
                                            int halfWidth, float gaussianSigma,
                                            GrTextureDomain::Mode mode, int bounds[2]);
 
diff --git a/src/gpu/effects/GrMatrixConvolutionEffect.cpp b/src/gpu/effects/GrMatrixConvolutionEffect.cpp
index 86df7a0..1f70a53 100644
--- a/src/gpu/effects/GrMatrixConvolutionEffect.cpp
+++ b/src/gpu/effects/GrMatrixConvolutionEffect.cpp
@@ -125,13 +125,13 @@
 void GrGLMatrixConvolutionEffect::onSetData(const GrGLSLProgramDataManager& pdman,
                                             const GrFragmentProcessor& processor) {
     const GrMatrixConvolutionEffect& conv = processor.cast<GrMatrixConvolutionEffect>();
-    GrTextureProxy* proxy = conv.textureSampler(0).proxy();
-    GrTexture* texture = proxy->peekTexture();
+    GrSurfaceProxy* proxy = conv.textureSampler(0).proxy();
+    SkISize textureDims = proxy->backingStoreDimensions();
 
     float imageIncrement[2];
     float ySign = proxy->origin() == kTopLeft_GrSurfaceOrigin ? 1.0f : -1.0f;
-    imageIncrement[0] = 1.0f / texture->width();
-    imageIncrement[1] = ySign / texture->height();
+    imageIncrement[0] = 1.0f / textureDims.width();
+    imageIncrement[1] = ySign / textureDims.height();
     pdman.set2fv(fImageIncrementUni, 1, imageIncrement);
     pdman.set2fv(fKernelOffsetUni, 1, conv.kernelOffset());
     int kernelCount = conv.kernelSize().width() * conv.kernelSize().height();
@@ -143,7 +143,7 @@
     fDomain.setData(pdman, conv.domain(), proxy, conv.textureSampler(0).samplerState());
 }
 
-GrMatrixConvolutionEffect::GrMatrixConvolutionEffect(sk_sp<GrTextureProxy> srcProxy,
+GrMatrixConvolutionEffect::GrMatrixConvolutionEffect(sk_sp<GrSurfaceProxy> srcProxy,
                                                      const SkIRect& srcBounds,
                                                      const SkISize& kernelSize,
                                                      const SkScalar* kernel,
diff --git a/src/gpu/effects/GrMatrixConvolutionEffect.h b/src/gpu/effects/GrMatrixConvolutionEffect.h
index 212d5c0..ac36de2 100644
--- a/src/gpu/effects/GrMatrixConvolutionEffect.h
+++ b/src/gpu/effects/GrMatrixConvolutionEffect.h
@@ -16,7 +16,7 @@
 
 class GrMatrixConvolutionEffect : public GrFragmentProcessor {
 public:
-    static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> srcProxy,
+    static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrSurfaceProxy> srcProxy,
                                                      const SkIRect& srcBounds,
                                                      const SkISize& kernelSize,
                                                      const SkScalar* kernel,
@@ -57,7 +57,7 @@
 private:
     // srcProxy is the texture that is going to be convolved
     // srcBounds is the subset of 'srcProxy' that will be used (e.g., for clamp mode)
-    GrMatrixConvolutionEffect(sk_sp<GrTextureProxy> srcProxy,
+    GrMatrixConvolutionEffect(sk_sp<GrSurfaceProxy> srcProxy,
                               const SkIRect& srcBounds,
                               const SkISize& kernelSize,
                               const SkScalar* kernel,
diff --git a/src/gpu/effects/GrSimpleTextureEffect.fp b/src/gpu/effects/GrSimpleTextureEffect.fp
index c86af4b..cf4dd31 100644
--- a/src/gpu/effects/GrSimpleTextureEffect.fp
+++ b/src/gpu/effects/GrSimpleTextureEffect.fp
@@ -22,7 +22,7 @@
 }
 
 @make {
-    static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy,
+    static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrSurfaceProxy> proxy,
                                                      SkAlphaType alphaType,
                                                      const SkMatrix& matrix) {
         return std::unique_ptr<GrFragmentProcessor>(
@@ -31,7 +31,7 @@
     }
 
     /* clamp mode */
-    static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy,
+    static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrSurfaceProxy> proxy,
                                                      SkAlphaType alphaType,
                                                      const SkMatrix& matrix,
                                                      GrSamplerState::Filter filter) {
@@ -40,7 +40,7 @@
                                       GrSamplerState(GrSamplerState::WrapMode::kClamp, filter)));
      }
 
-    static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy,
+    static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrSurfaceProxy> proxy,
                                                      SkAlphaType alphaType,
                                                      const SkMatrix& matrix,
                                                      const GrSamplerState& p) {
diff --git a/src/gpu/effects/GrTextureDomain.cpp b/src/gpu/effects/GrTextureDomain.cpp
index 10fa17f..80907fe 100644
--- a/src/gpu/effects/GrTextureDomain.cpp
+++ b/src/gpu/effects/GrTextureDomain.cpp
@@ -21,7 +21,7 @@
 
 #include <utility>
 
-GrTextureDomain::GrTextureDomain(GrTextureProxy* proxy, const SkRect& domain, Mode modeX,
+GrTextureDomain::GrTextureDomain(GrSurfaceProxy* proxy, const SkRect& domain, Mode modeX,
                                  Mode modeY, int index)
     : fModeX(modeX)
     , fModeY(modeY)
@@ -179,7 +179,7 @@
 
 void GrTextureDomain::GLDomain::setData(const GrGLSLProgramDataManager& pdman,
                                         const GrTextureDomain& textureDomain,
-                                        GrTextureProxy* proxy,
+                                        GrSurfaceProxy* proxy,
                                         const GrSamplerState& sampler) {
     GrTexture* tex = proxy->peekTexture();
     SkASSERT(fHasMode && textureDomain.modeX() == fModeX && textureDomain.modeY() == fModeY);
@@ -194,7 +194,7 @@
         SkScalar decalFilterWeight = sampler.filter() == GrSamplerState::Filter::kNearest ?
                 SK_ScalarHalf : 1.0f;
         SkScalar wInv, hInv, h;
-        if (proxy->textureType() == GrTextureType::kRectangle) {
+        if (proxy->backendFormat().textureType() == GrTextureType::kRectangle) {
             wInv = hInv = 1.f;
             h = tex->height();
 
@@ -219,7 +219,7 @@
             SkScalarToFloat(textureDomain.domain().fBottom * hInv)
         };
 
-        if (proxy->textureType() == GrTextureType::kRectangle) {
+        if (proxy->backendFormat().textureType() == GrTextureType::kRectangle) {
             SkASSERT(values[0] >= 0.0f && values[0] <= proxy->width());
             SkASSERT(values[1] >= 0.0f && values[1] <= proxy->height());
             SkASSERT(values[2] >= 0.0f && values[2] <= proxy->width());
@@ -251,7 +251,7 @@
 ///////////////////////////////////////////////////////////////////////////////
 
 std::unique_ptr<GrFragmentProcessor> GrTextureDomainEffect::Make(
-        sk_sp<GrTextureProxy> proxy,
+        sk_sp<GrSurfaceProxy> proxy,
         SkAlphaType srcAlphaType,
         const SkMatrix& matrix,
         const SkRect& domain,
@@ -261,7 +261,7 @@
                 GrSamplerState(GrSamplerState::WrapMode::kClamp, filterMode));
 }
 
-std::unique_ptr<GrFragmentProcessor> GrTextureDomainEffect::Make(sk_sp<GrTextureProxy> proxy,
+std::unique_ptr<GrFragmentProcessor> GrTextureDomainEffect::Make(sk_sp<GrSurfaceProxy> proxy,
                                                                  SkAlphaType srcAlphaType,
                                                                  const SkMatrix& matrix,
                                                                  const SkRect& domain,
@@ -276,7 +276,7 @@
             std::move(proxy), srcAlphaType, matrix, domain, modeX, modeY, sampler));
 }
 
-GrTextureDomainEffect::GrTextureDomainEffect(sk_sp<GrTextureProxy> proxy,
+GrTextureDomainEffect::GrTextureDomainEffect(sk_sp<GrSurfaceProxy> proxy,
                                              SkAlphaType srcAlphaType,
                                              const SkMatrix& matrix,
                                              const SkRect& domain,
@@ -335,7 +335,7 @@
                        const GrFragmentProcessor& fp) override {
             const GrTextureDomainEffect& tde = fp.cast<GrTextureDomainEffect>();
             const GrTextureDomain& domain = tde.fTextureDomain;
-            GrTextureProxy* proxy = tde.textureSampler(0).proxy();
+            GrSurfaceProxy* proxy = tde.textureSampler(0).proxy();
 
             fGLDomain.setData(pdman, domain, proxy, tde.textureSampler(0).samplerState());
         }
@@ -389,13 +389,13 @@
 
 ///////////////////////////////////////////////////////////////////////////////
 std::unique_ptr<GrFragmentProcessor> GrDeviceSpaceTextureDecalFragmentProcessor::Make(
-        sk_sp<GrTextureProxy> proxy, const SkIRect& subset, const SkIPoint& deviceSpaceOffset) {
+        sk_sp<GrSurfaceProxy> proxy, const SkIRect& subset, const SkIPoint& deviceSpaceOffset) {
     return std::unique_ptr<GrFragmentProcessor>(new GrDeviceSpaceTextureDecalFragmentProcessor(
             std::move(proxy), subset, deviceSpaceOffset));
 }
 
 GrDeviceSpaceTextureDecalFragmentProcessor::GrDeviceSpaceTextureDecalFragmentProcessor(
-        sk_sp<GrTextureProxy> proxy, const SkIRect& subset, const SkIPoint& deviceSpaceOffset)
+        sk_sp<GrSurfaceProxy> proxy, const SkIRect& subset, const SkIPoint& deviceSpaceOffset)
         : INHERITED(kGrDeviceSpaceTextureDecalFragmentProcessor_ClassID,
                     kCompatibleWithCoverageAsAlpha_OptimizationFlag)
         , fTextureSampler(proxy, GrSamplerState::ClampNearest())
@@ -450,13 +450,13 @@
                        const GrFragmentProcessor& fp) override {
             const GrDeviceSpaceTextureDecalFragmentProcessor& dstdfp =
                     fp.cast<GrDeviceSpaceTextureDecalFragmentProcessor>();
-            GrTextureProxy* proxy = dstdfp.textureSampler(0).proxy();
-            GrTexture* texture = proxy->peekTexture();
+            GrSurfaceProxy* proxy = dstdfp.textureSampler(0).proxy();
+            SkISize textureDims = proxy->backingStoreDimensions();
 
             fGLDomain.setData(pdman, dstdfp.fTextureDomain, proxy,
                               dstdfp.textureSampler(0).samplerState());
-            float iw = 1.f / texture->width();
-            float ih = 1.f / texture->height();
+            float iw = 1.f / textureDims.width();
+            float ih = 1.f / textureDims.height();
             float scaleAndTransData[4] = {
                 iw, ih,
                 -dstdfp.fDeviceSpaceOffset.fX * iw, -dstdfp.fDeviceSpaceOffset.fY * ih
diff --git a/src/gpu/effects/GrTextureDomain.h b/src/gpu/effects/GrTextureDomain.h
index ff13619..1361c4d 100644
--- a/src/gpu/effects/GrTextureDomain.h
+++ b/src/gpu/effects/GrTextureDomain.h
@@ -53,7 +53,7 @@
      * @param index     Pass a value >= 0 if using multiple texture domains in the same effect.
      *                  It is used to keep inserted variables from causing name collisions.
      */
-    GrTextureDomain(GrTextureProxy*, const SkRect& domain, Mode modeX, Mode modeY, int index = -1);
+    GrTextureDomain(GrSurfaceProxy*, const SkRect& domain, Mode modeX, Mode modeY, int index = -1);
 
     GrTextureDomain(const GrTextureDomain&) = default;
 
@@ -143,7 +143,7 @@
          * texture domain. The rectangle is automatically adjusted to account for the texture's
          * origin.
          */
-        void setData(const GrGLSLProgramDataManager&, const GrTextureDomain&, GrTextureProxy*,
+        void setData(const GrGLSLProgramDataManager&, const GrTextureDomain&, GrSurfaceProxy*,
                      const GrSamplerState& sampler);
 
         enum {
@@ -187,14 +187,14 @@
  */
 class GrTextureDomainEffect : public GrFragmentProcessor {
 public:
-    static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy>,
+    static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrSurfaceProxy>,
                                                      SkAlphaType srcAlphaType,
                                                      const SkMatrix&,
                                                      const SkRect& domain,
                                                      GrTextureDomain::Mode mode,
                                                      GrSamplerState::Filter filterMode);
 
-    static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy>,
+    static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrSurfaceProxy>,
                                                      SkAlphaType srcAlphaType,
                                                      const SkMatrix&,
                                                      const SkRect& domain,
@@ -224,7 +224,7 @@
     GrTextureDomain fTextureDomain;
     TextureSampler fTextureSampler;
 
-    GrTextureDomainEffect(sk_sp<GrTextureProxy>,
+    GrTextureDomainEffect(sk_sp<GrSurfaceProxy>,
                           SkAlphaType srcAlphaType,
                           const SkMatrix&,
                           const SkRect& domain,
@@ -249,7 +249,7 @@
 
 class GrDeviceSpaceTextureDecalFragmentProcessor : public GrFragmentProcessor {
 public:
-    static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy>,
+    static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrSurfaceProxy>,
                                                      const SkIRect& subset,
                                                      const SkIPoint& deviceSpaceOffset);
 
@@ -274,7 +274,7 @@
     GrTextureDomain fTextureDomain;
     SkIPoint fDeviceSpaceOffset;
 
-    GrDeviceSpaceTextureDecalFragmentProcessor(sk_sp<GrTextureProxy>,
+    GrDeviceSpaceTextureDecalFragmentProcessor(sk_sp<GrSurfaceProxy>,
                                                const SkIRect&, const SkIPoint&);
     GrDeviceSpaceTextureDecalFragmentProcessor(const GrDeviceSpaceTextureDecalFragmentProcessor&);
 
diff --git a/src/gpu/effects/generated/GrAlphaThresholdFragmentProcessor.h b/src/gpu/effects/generated/GrAlphaThresholdFragmentProcessor.h
index 730054b..112e72a 100644
--- a/src/gpu/effects/generated/GrAlphaThresholdFragmentProcessor.h
+++ b/src/gpu/effects/generated/GrAlphaThresholdFragmentProcessor.h
@@ -18,7 +18,7 @@
 public:
     inline OptimizationFlags optFlags(float outerThreshold);
 
-    static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> mask,
+    static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrSurfaceProxy> mask,
                                                      float innerThreshold,
                                                      float outerThreshold,
                                                      const SkIRect& bounds) {
@@ -34,7 +34,7 @@
     float outerThreshold;
 
 private:
-    GrAlphaThresholdFragmentProcessor(sk_sp<GrTextureProxy> mask, float innerThreshold,
+    GrAlphaThresholdFragmentProcessor(sk_sp<GrSurfaceProxy> mask, float innerThreshold,
                                       float outerThreshold, const SkIRect& bounds)
             : INHERITED(kGrAlphaThresholdFragmentProcessor_ClassID, kNone_OptimizationFlags)
             , maskCoordTransform(
diff --git a/src/gpu/effects/generated/GrCircleBlurFragmentProcessor.h b/src/gpu/effects/generated/GrCircleBlurFragmentProcessor.h
index 93d2403..a3221ec 100644
--- a/src/gpu/effects/generated/GrCircleBlurFragmentProcessor.h
+++ b/src/gpu/effects/generated/GrCircleBlurFragmentProcessor.h
@@ -28,7 +28,7 @@
 
 private:
     GrCircleBlurFragmentProcessor(SkRect circleRect, float textureRadius, float solidRadius,
-                                  sk_sp<GrTextureProxy> blurProfileSampler)
+                                  sk_sp<GrSurfaceProxy> blurProfileSampler)
             : INHERITED(kGrCircleBlurFragmentProcessor_ClassID,
                         (OptimizationFlags)kCompatibleWithCoverageAsAlpha_OptimizationFlag)
             , circleRect(circleRect)
diff --git a/src/gpu/effects/generated/GrMagnifierEffect.h b/src/gpu/effects/generated/GrMagnifierEffect.h
index cb0d005..c7e3013 100644
--- a/src/gpu/effects/generated/GrMagnifierEffect.h
+++ b/src/gpu/effects/generated/GrMagnifierEffect.h
@@ -16,7 +16,7 @@
 #include "src/gpu/GrFragmentProcessor.h"
 class GrMagnifierEffect : public GrFragmentProcessor {
 public:
-    static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> src, SkIRect bounds,
+    static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrSurfaceProxy> src, SkIRect bounds,
                                                      SkRect srcRect, float xInvZoom, float yInvZoom,
                                                      float xInvInset, float yInvInset) {
         return std::unique_ptr<GrFragmentProcessor>(new GrMagnifierEffect(
@@ -35,7 +35,7 @@
     float yInvInset;
 
 private:
-    GrMagnifierEffect(sk_sp<GrTextureProxy> src, SkIRect bounds, SkRect srcRect, float xInvZoom,
+    GrMagnifierEffect(sk_sp<GrSurfaceProxy> src, SkIRect bounds, SkRect srcRect, float xInvZoom,
                       float yInvZoom, float xInvInset, float yInvInset)
             : INHERITED(kGrMagnifierEffect_ClassID, kNone_OptimizationFlags)
             , srcCoordTransform(SkMatrix::I(), src.get())
diff --git a/src/gpu/effects/generated/GrRRectBlurEffect.h b/src/gpu/effects/generated/GrRRectBlurEffect.h
index 9a3ff66..9aad281 100644
--- a/src/gpu/effects/generated/GrRRectBlurEffect.h
+++ b/src/gpu/effects/generated/GrRRectBlurEffect.h
@@ -117,7 +117,7 @@
 
 private:
     GrRRectBlurEffect(float sigma, SkRect rect, float cornerRadius,
-                      sk_sp<GrTextureProxy> ninePatchSampler)
+                      sk_sp<GrSurfaceProxy> ninePatchSampler)
             : INHERITED(kGrRRectBlurEffect_ClassID,
                         (OptimizationFlags)kCompatibleWithCoverageAsAlpha_OptimizationFlag)
             , sigma(sigma)
diff --git a/src/gpu/effects/generated/GrRectBlurEffect.h b/src/gpu/effects/generated/GrRectBlurEffect.h
index b0c86bd..9b81d5f 100644
--- a/src/gpu/effects/generated/GrRectBlurEffect.h
+++ b/src/gpu/effects/generated/GrRectBlurEffect.h
@@ -116,7 +116,7 @@
     bool isFast;
 
 private:
-    GrRectBlurEffect(SkRect rect, sk_sp<GrTextureProxy> integral, float invSixSigma, bool isFast,
+    GrRectBlurEffect(SkRect rect, sk_sp<GrSurfaceProxy> integral, float invSixSigma, bool isFast,
                      GrSamplerState samplerParams)
             : INHERITED(kGrRectBlurEffect_ClassID,
                         (OptimizationFlags)kCompatibleWithCoverageAsAlpha_OptimizationFlag)
diff --git a/src/gpu/effects/generated/GrSimpleTextureEffect.h b/src/gpu/effects/generated/GrSimpleTextureEffect.h
index db087eb..bdc11da 100644
--- a/src/gpu/effects/generated/GrSimpleTextureEffect.h
+++ b/src/gpu/effects/generated/GrSimpleTextureEffect.h
@@ -16,7 +16,7 @@
 #include "src/gpu/GrFragmentProcessor.h"
 class GrSimpleTextureEffect : public GrFragmentProcessor {
 public:
-    static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy,
+    static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrSurfaceProxy> proxy,
                                                      SkAlphaType alphaType,
                                                      const SkMatrix& matrix) {
         return std::unique_ptr<GrFragmentProcessor>(
@@ -26,7 +26,7 @@
     }
 
     /* clamp mode */
-    static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy,
+    static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrSurfaceProxy> proxy,
                                                      SkAlphaType alphaType,
                                                      const SkMatrix& matrix,
                                                      GrSamplerState::Filter filter) {
@@ -35,7 +35,7 @@
                 GrSamplerState(GrSamplerState::WrapMode::kClamp, filter)));
     }
 
-    static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy,
+    static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrSurfaceProxy> proxy,
                                                      SkAlphaType alphaType,
                                                      const SkMatrix& matrix,
                                                      const GrSamplerState& p) {
@@ -50,7 +50,7 @@
     SkMatrix44 matrix;
 
 private:
-    GrSimpleTextureEffect(sk_sp<GrTextureProxy> image, SkMatrix44 matrix, SkAlphaType alphaType,
+    GrSimpleTextureEffect(sk_sp<GrSurfaceProxy> image, SkMatrix44 matrix, SkAlphaType alphaType,
                           GrSamplerState samplerParams)
             : INHERITED(kGrSimpleTextureEffect_ClassID,
                         (OptimizationFlags)ModulateForSamplerOptFlags(
diff --git a/src/gpu/gradients/generated/GrTextureGradientColorizer.h b/src/gpu/gradients/generated/GrTextureGradientColorizer.h
index e15558e..9ed5d3e 100644
--- a/src/gpu/gradients/generated/GrTextureGradientColorizer.h
+++ b/src/gpu/gradients/generated/GrTextureGradientColorizer.h
@@ -16,7 +16,7 @@
 #include "src/gpu/GrFragmentProcessor.h"
 class GrTextureGradientColorizer : public GrFragmentProcessor {
 public:
-    static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> gradient) {
+    static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrSurfaceProxy> gradient) {
         return std::unique_ptr<GrFragmentProcessor>(new GrTextureGradientColorizer(gradient));
     }
     GrTextureGradientColorizer(const GrTextureGradientColorizer& src);
@@ -25,7 +25,7 @@
     TextureSampler gradient;
 
 private:
-    GrTextureGradientColorizer(sk_sp<GrTextureProxy> gradient)
+    GrTextureGradientColorizer(sk_sp<GrSurfaceProxy> gradient)
             : INHERITED(kGrTextureGradientColorizer_ClassID, kNone_OptimizationFlags)
             , gradient(std::move(gradient), GrSamplerState::ClampBilerp()) {
         this->setTextureSamplerCnt(1);
diff --git a/src/gpu/ops/GrTextureOp.cpp b/src/gpu/ops/GrTextureOp.cpp
index 4fe05cb..73f1f55 100644
--- a/src/gpu/ops/GrTextureOp.cpp
+++ b/src/gpu/ops/GrTextureOp.cpp
@@ -974,7 +974,7 @@
         paint.setColor4f(color);
         paint.setXPFactory(SkBlendMode_AsXPFactory(blendMode));
 
-        GrTextureProxy* proxy = proxyView.asTextureProxy();
+        GrSurfaceProxy* proxy = proxyView.proxy();
         std::unique_ptr<GrFragmentProcessor> fp;
         if (domain) {
             // Update domain to match what GrTextureOp would do for bilerp, but don't do any
diff --git a/src/sksl/SkSLHCodeGenerator.cpp b/src/sksl/SkSLHCodeGenerator.cpp
index 31cc890..6c41e74 100644
--- a/src/sksl/SkSLHCodeGenerator.cpp
+++ b/src/sksl/SkSLHCodeGenerator.cpp
@@ -66,7 +66,7 @@
     } else if (type == *context.fFloat4x4_Type || type == *context.fHalf4x4_Type) {
         return Layout::CType::kSkMatrix44;
     } else if (type.kind() == Type::kSampler_Kind) {
-        return Layout::CType::kGrTextureProxy;
+        return Layout::CType::kGrSurfaceProxy;
     } else if (type == *context.fFragmentProcessor_Type) {
         return Layout::CType::kGrFragmentProcessor;
     }
diff --git a/src/sksl/ir/SkSLLayout.h b/src/sksl/ir/SkSLLayout.h
index dfc6ae4..24c7431 100644
--- a/src/sksl/ir/SkSLLayout.h
+++ b/src/sksl/ir/SkSLLayout.h
@@ -95,7 +95,7 @@
         kSkIPoint,
         kSkMatrix,
         kSkMatrix44,
-        kGrTextureProxy,
+        kGrSurfaceProxy,
         kGrFragmentProcessor,
     };
 
@@ -177,8 +177,8 @@
                 return "SkMatrix";
             case CType::kSkMatrix44:
                 return "SkMatrix44";
-            case CType::kGrTextureProxy:
-                return "sk_sp<GrTextureProxy>";
+            case CType::kGrSurfaceProxy:
+                return "sk_sp<GrSurfaceProxy>";
             case CType::kGrFragmentProcessor:
                 return "std::unique_ptr<GrFragmentProcessor>";
             default: