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/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