Simplify view getters on GrTextureProducer.

The only thing that affects the view returned is whether it ought to
be MIP mapped or not. So don't take a whole GrSamplerState.

The view() function won't ever change the colortype so just query
GrTextureProducer rather than having view() return a tuple.

The rest is transitively reaching through callers and callees of
GrTextureProducer::view() to only pass filter or GrMipMapped instead of
GrSamplerState. Also, some params that indicate whether MIPs are
requested are changed from bool to GrMipMapped. And some minor style
stuff (mainly de-yoda-ifying GrMipMapped checks, using
GrSurfaceProxyView operator bool()).

Change-Id: Ia184aa793cf51d42642ea3bb0521ce06da2efb10
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/274205
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/GrAHardwareBufferImageGenerator.cpp b/src/gpu/GrAHardwareBufferImageGenerator.cpp
index 936c6a9..f393c45 100644
--- a/src/gpu/GrAHardwareBufferImageGenerator.cpp
+++ b/src/gpu/GrAHardwareBufferImageGenerator.cpp
@@ -186,9 +186,10 @@
     return GrSurfaceProxyView(std::move(texProxy), fSurfaceOrigin, readSwizzle);
 }
 
-GrSurfaceProxyView GrAHardwareBufferImageGenerator::onGenerateTexture(
-        GrRecordingContext* context, const SkImageInfo& info,
-        const SkIPoint& origin, bool willNeedMipMaps) {
+GrSurfaceProxyView GrAHardwareBufferImageGenerator::onGenerateTexture(GrRecordingContext* context,
+                                                                      const SkImageInfo& info,
+                                                                      const SkIPoint& origin,
+                                                                      GrMipMapped mipMapped) {
     GrSurfaceProxyView texProxyView = this->makeView(context);
     if (!texProxyView.proxy()) {
         return {};
@@ -204,8 +205,6 @@
     // Otherwise, make a copy for the requested subset.
     SkIRect subset = SkIRect::MakeXYWH(origin.fX, origin.fY, info.width(), info.height());
 
-    GrMipMapped mipMapped = willNeedMipMaps ? GrMipMapped::kYes : GrMipMapped::kNo;
-
     GrColorType grColorType = SkColorTypeToGrColorType(this->getInfo().colorType());
     return GrSurfaceProxy::Copy(context, texProxyView.proxy(), texProxyView.origin(), grColorType,
                                 mipMapped, subset, SkBackingFit::kExact,
diff --git a/src/gpu/GrAHardwareBufferImageGenerator.h b/src/gpu/GrAHardwareBufferImageGenerator.h
index 44d33f2..aa3803c 100644
--- a/src/gpu/GrAHardwareBufferImageGenerator.h
+++ b/src/gpu/GrAHardwareBufferImageGenerator.h
@@ -42,8 +42,8 @@
 
     bool onIsValid(GrContext*) const override;
 
-    GrSurfaceProxyView onGenerateTexture(GrRecordingContext*, const SkImageInfo&,
-                                         const SkIPoint&, bool willNeedMipMaps) override;
+    GrSurfaceProxyView onGenerateTexture(GrRecordingContext*, const SkImageInfo&, const SkIPoint&,
+                                         GrMipMapped) override;
 
 private:
     GrAHardwareBufferImageGenerator(const SkImageInfo&, AHardwareBuffer*, SkAlphaType,
diff --git a/src/gpu/GrBackendTextureImageGenerator.cpp b/src/gpu/GrBackendTextureImageGenerator.cpp
index 096a17d..2a807d6 100644
--- a/src/gpu/GrBackendTextureImageGenerator.cpp
+++ b/src/gpu/GrBackendTextureImageGenerator.cpp
@@ -93,9 +93,10 @@
     refHelper->unref();
 }
 
-GrSurfaceProxyView GrBackendTextureImageGenerator::onGenerateTexture(
-        GrRecordingContext* context, const SkImageInfo& info,
-        const SkIPoint& origin, bool willNeedMipMaps) {
+GrSurfaceProxyView GrBackendTextureImageGenerator::onGenerateTexture(GrRecordingContext* context,
+                                                                     const SkImageInfo& info,
+                                                                     const SkIPoint& origin,
+                                                                     GrMipMapped mipMapped) {
     SkASSERT(context);
 
     if (context->backend() != fBackendTexture.backend()) {
@@ -144,7 +145,8 @@
 
     GrColorType grColorType = SkColorTypeToGrColorType(info.colorType());
 
-    GrMipMapped mipMapped = fBackendTexture.hasMipMaps() ? GrMipMapped::kYes : GrMipMapped::kNo;
+    GrMipMapped textureIsMipMapped = fBackendTexture.hasMipMaps() ? GrMipMapped::kYes
+                                                                  : GrMipMapped::kNo;
 
     // Ganesh assumes that, when wrapping a mipmapped backend texture from a client, that its
     // mipmaps are fully fleshed out.
@@ -155,12 +157,11 @@
 
     // Must make copies of member variables to capture in the lambda since this image generator may
     // be deleted before we actually execute the lambda.
-    sk_sp<GrTextureProxy> proxy = proxyProvider->createLazyProxy(
-            [
-              refHelper = fRefHelper, releaseProcHelper, backendTexture = fBackendTexture,
-              grColorType
-            ](GrResourceProvider * resourceProvider)
-                    ->GrSurfaceProxy::LazyCallbackResult {
+    sk_sp<GrTextureProxy> proxy =
+            proxyProvider->createLazyProxy(
+                    [refHelper = fRefHelper, releaseProcHelper, backendTexture = fBackendTexture,
+                     grColorType](GrResourceProvider* resourceProvider)
+                            -> GrSurfaceProxy::LazyCallbackResult {
                         if (refHelper->fSemaphore) {
                             resourceProvider->priv().gpu()->waitSemaphore(
                                     refHelper->fSemaphore.get());
@@ -201,22 +202,22 @@
                         return {std::move(tex), true,
                                 GrSurfaceProxy::LazyInstantiationKeyMode::kUnsynced};
                     },
-            backendFormat, fBackendTexture.dimensions(), readSwizzle, GrRenderable::kNo, 1,
-            mipMapped, mipMapsStatus, GrInternalSurfaceFlags::kReadOnly, SkBackingFit::kExact,
-            SkBudgeted::kNo, GrProtected::kNo, GrSurfaceProxy::UseAllocator::kYes);
+                    backendFormat, fBackendTexture.dimensions(), readSwizzle, GrRenderable::kNo, 1,
+                    textureIsMipMapped, mipMapsStatus, GrInternalSurfaceFlags::kReadOnly,
+                    SkBackingFit::kExact, SkBudgeted::kNo, GrProtected::kNo,
+                    GrSurfaceProxy::UseAllocator::kYes);
     if (!proxy) {
         return {};
     }
 
     if (origin.isZero() && info.dimensions() == fBackendTexture.dimensions() &&
-        (!willNeedMipMaps || GrMipMapped::kYes == proxy->mipMapped())) {
+        (mipMapped == GrMipMapped::kNo || proxy->mipMapped() == GrMipMapped::kYes)) {
         // If the caller wants the entire texture and we have the correct mip support, we're done
         return GrSurfaceProxyView(std::move(proxy), fSurfaceOrigin, readSwizzle);
     } else {
         // Otherwise, make a copy of the requested subset. Make sure our temporary is renderable,
         // because Vulkan will want to do the copy as a draw. All other copies would require a
         // layout change in Vulkan and we do not change the layout of borrowed images.
-        GrMipMapped mipMapped = willNeedMipMaps ? GrMipMapped::kYes : GrMipMapped::kNo;
         SkIRect subset = SkIRect::MakeXYWH(origin.fX, origin.fY, info.width(), info.height());
 
         return GrSurfaceProxy::Copy(
diff --git a/src/gpu/GrBackendTextureImageGenerator.h b/src/gpu/GrBackendTextureImageGenerator.h
index cef161c..283fa39 100644
--- a/src/gpu/GrBackendTextureImageGenerator.h
+++ b/src/gpu/GrBackendTextureImageGenerator.h
@@ -39,8 +39,8 @@
     // do that safely (we might be on another thread). So assume everything is fine.
     bool onIsValid(GrContext*) const override { return true; }
 
-    GrSurfaceProxyView onGenerateTexture(GrRecordingContext*, const SkImageInfo&,
-                                         const SkIPoint&, bool willNeedMipMaps) override;
+    GrSurfaceProxyView onGenerateTexture(GrRecordingContext*, const SkImageInfo&, const SkIPoint&,
+                                         GrMipMapped mipMapped) override;
     bool onTexturesAreCacheable() const override { return false; }
 
 private:
diff --git a/src/gpu/GrBitmapTextureMaker.cpp b/src/gpu/GrBitmapTextureMaker.cpp
index baff879..a32ec21 100644
--- a/src/gpu/GrBitmapTextureMaker.cpp
+++ b/src/gpu/GrBitmapTextureMaker.cpp
@@ -39,7 +39,7 @@
     }
 }
 
-GrSurfaceProxyView GrBitmapTextureMaker::refOriginalTextureProxyView(bool willBeMipped) {
+GrSurfaceProxyView GrBitmapTextureMaker::refOriginalTextureProxyView(GrMipMapped mipMapped) {
     GrProxyProvider* proxyProvider = this->context()->priv().proxyProvider();
     sk_sp<GrTextureProxy> proxy;
     GrSwizzle swizzle;
@@ -50,7 +50,7 @@
         if (proxy) {
             swizzle = this->context()->priv().caps()->getReadSwizzle(proxy->backendFormat(),
                                                                      this->colorType());
-            if (!willBeMipped || GrMipMapped::kYes == proxy->mipMapped()) {
+            if (mipMapped == GrMipMapped::kNo || proxy->mipMapped() == GrMipMapped::kYes) {
                 return GrSurfaceProxyView(std::move(proxy), kTopLeft_GrSurfaceOrigin, swizzle);
             }
         }
@@ -65,16 +65,14 @@
                 return {};
             }
             copy8888.setImmutable();
-            proxy = proxyProvider->createProxyFromBitmap(
-                    copy8888, willBeMipped ? GrMipMapped::kYes : GrMipMapped::kNo, fFit);
+            proxy = proxyProvider->createProxyFromBitmap(copy8888, mipMapped, fFit);
         } else {
-            proxy = proxyProvider->createProxyFromBitmap(
-                    fBitmap, willBeMipped ? GrMipMapped::kYes : GrMipMapped::kNo, fFit);
+            proxy = proxyProvider->createProxyFromBitmap(fBitmap, mipMapped, fFit);
         }
         if (proxy) {
             swizzle = this->context()->priv().caps()->getReadSwizzle(proxy->backendFormat(),
                                                                      this->colorType());
-            SkASSERT(!willBeMipped || GrMipMapped::kYes == proxy->mipMapped());
+            SkASSERT(mipMapped == GrMipMapped::kNo || proxy->mipMapped() == GrMipMapped::kYes);
             if (fOriginalKey.isValid()) {
                 proxyProvider->assignUniqueKeyToProxy(fOriginalKey, proxy.get());
                 GrInstallBitmapUniqueKeyInvalidator(
@@ -85,8 +83,8 @@
     }
 
     if (proxy) {
-        SkASSERT(willBeMipped);
-        SkASSERT(GrMipMapped::kNo == proxy->mipMapped());
+        SkASSERT(mipMapped == GrMipMapped::kYes);
+        SkASSERT(proxy->mipMapped() == GrMipMapped::kNo);
         SkASSERT(fOriginalKey.isValid());
         // We need a mipped proxy, but we found a proxy earlier that wasn't mipped. Thus we generate
         // a new mipped surface and copy the original proxy into the base layer. We will then let
diff --git a/src/gpu/GrBitmapTextureMaker.h b/src/gpu/GrBitmapTextureMaker.h
index 311bacb..59217d0 100644
--- a/src/gpu/GrBitmapTextureMaker.h
+++ b/src/gpu/GrBitmapTextureMaker.h
@@ -23,7 +23,7 @@
                          bool useDecal = false);
 
 private:
-    GrSurfaceProxyView refOriginalTextureProxyView(bool willBeMipped) override;
+    GrSurfaceProxyView refOriginalTextureProxyView(GrMipMapped) override;
 
     const SkBitmap     fBitmap;
     const SkBackingFit fFit;
diff --git a/src/gpu/GrBlurUtils.cpp b/src/gpu/GrBlurUtils.cpp
index 1ce1e82..cfd9657 100644
--- a/src/gpu/GrBlurUtils.cpp
+++ b/src/gpu/GrBlurUtils.cpp
@@ -153,7 +153,7 @@
 
         GrBitmapTextureMaker maker(context, bm, GrBitmapTextureMaker::Cached::kNo,
                                    SkBackingFit::kApprox);
-        std::tie(filteredMaskView, std::ignore) = maker.view(GrMipMapped::kNo);
+        filteredMaskView = maker.view(GrMipMapped::kNo);
         if (!filteredMaskView.proxy()) {
             return false;
         }
diff --git a/src/gpu/GrImageTextureMaker.cpp b/src/gpu/GrImageTextureMaker.cpp
index 892140f..97793e9 100644
--- a/src/gpu/GrImageTextureMaker.cpp
+++ b/src/gpu/GrImageTextureMaker.cpp
@@ -33,8 +33,8 @@
     GrMakeKeyFromImageID(&fOriginalKey, client->uniqueID(), SkIRect::MakeSize(this->dimensions()));
 }
 
-GrSurfaceProxyView GrImageTextureMaker::refOriginalTextureProxyView(bool willBeMipped) {
-    return fImage->lockTextureProxyView(this->context(), fOriginalKey, fCachingHint, willBeMipped);
+GrSurfaceProxyView GrImageTextureMaker::refOriginalTextureProxyView(GrMipMapped mipMapped) {
+    return fImage->lockTextureProxyView(this->context(), fOriginalKey, fCachingHint, mipMapped);
 }
 
 /////////////////////////////////////////////////////////////////////////////////////////////////
@@ -47,8 +47,8 @@
     GrMakeKeyFromImageID(&fOriginalKey, client->uniqueID(), SkIRect::MakeSize(this->dimensions()));
 }
 
-GrSurfaceProxyView GrYUVAImageTextureMaker::refOriginalTextureProxyView(bool willBeMipped) {
-    if (willBeMipped) {
+GrSurfaceProxyView GrYUVAImageTextureMaker::refOriginalTextureProxyView(GrMipMapped mipMapped) {
+    if (mipMapped == GrMipMapped::kYes) {
         return fImage->refMippedView(this->context());
     } else {
         if (const GrSurfaceProxyView* view = fImage->view(this->context())) {
diff --git a/src/gpu/GrImageTextureMaker.h b/src/gpu/GrImageTextureMaker.h
index 908e232..bd1aee7 100644
--- a/src/gpu/GrImageTextureMaker.h
+++ b/src/gpu/GrImageTextureMaker.h
@@ -22,7 +22,7 @@
                         SkImage::CachingHint chint, bool useDecal = false);
 
 private:
-    GrSurfaceProxyView refOriginalTextureProxyView(bool willBeMipped) override;
+    GrSurfaceProxyView refOriginalTextureProxyView(GrMipMapped) override;
 
     const SkImage_Lazy*     fImage;
     GrUniqueKey             fOriginalKey;
@@ -48,7 +48,7 @@
     bool hasMixedResolutions() const override { return true; }
 
 private:
-    GrSurfaceProxyView refOriginalTextureProxyView(bool willBeMipped) override;
+    GrSurfaceProxyView refOriginalTextureProxyView(GrMipMapped) override;
 
     const SkImage_GpuYUVA*  fImage;
     GrUniqueKey             fOriginalKey;
diff --git a/src/gpu/GrSWMaskHelper.cpp b/src/gpu/GrSWMaskHelper.cpp
index e7916c6..38bed95 100644
--- a/src/gpu/GrSWMaskHelper.cpp
+++ b/src/gpu/GrSWMaskHelper.cpp
@@ -104,6 +104,5 @@
     bitmap.setImmutable();
 
     GrBitmapTextureMaker maker(context, bitmap, GrBitmapTextureMaker::Cached::kNo, fit);
-    auto[textureView, ct] = maker.view(GrMipMapped::kNo);
-    return textureView;
+    return maker.view(GrMipMapped::kNo);
 }
diff --git a/src/gpu/GrTextureAdjuster.cpp b/src/gpu/GrTextureAdjuster.cpp
index 1653e66..07c080e 100644
--- a/src/gpu/GrTextureAdjuster.cpp
+++ b/src/gpu/GrTextureAdjuster.cpp
@@ -52,8 +52,7 @@
     return copyView;
 }
 
-GrSurfaceProxyView GrTextureAdjuster::onRefTextureProxyViewForParams(GrSamplerState params,
-                                                                     bool willBeMipped) {
+GrSurfaceProxyView GrTextureAdjuster::onView(GrMipMapped mipMapped) {
     if (this->context()->priv().abandoned()) {
         // The texture was abandoned.
         return {};
@@ -64,7 +63,7 @@
 
     GrTextureProxy* texProxy = fOriginal.asTextureProxy();
     SkASSERT(texProxy);
-    if (!GrGpu::IsACopyNeededForMips(this->context()->priv().caps(), texProxy, params.filter())) {
+    if (mipMapped == GrMipMapped::kNo || texProxy->mipMapped() == GrMipMapped::kYes) {
         return fOriginal;
     }
 
@@ -85,7 +84,12 @@
         FilterConstraint filterConstraint,
         bool coordsLimitedToConstraintRect,
         const GrSamplerState::Filter* filterOrNullForBicubic) {
-    GrSurfaceProxyView view = this->viewForParams(filterOrNullForBicubic);
+    GrSurfaceProxyView view;
+    if (filterOrNullForBicubic) {
+        view = this->view(*filterOrNullForBicubic);
+    } else {
+        view = this->view(GrMipMapped::kNo);
+    }
     if (!view) {
         return nullptr;
     }
diff --git a/src/gpu/GrTextureAdjuster.h b/src/gpu/GrTextureAdjuster.h
index 08ce030..61a2742 100644
--- a/src/gpu/GrTextureAdjuster.h
+++ b/src/gpu/GrTextureAdjuster.h
@@ -31,7 +31,7 @@
             const GrSamplerState::Filter* filterOrNullForBicubic) override;
 
 private:
-    GrSurfaceProxyView onRefTextureProxyViewForParams(GrSamplerState, bool willBeMipped) override;
+    GrSurfaceProxyView onView(GrMipMapped) override;
 
     GrSurfaceProxyView makeMippedCopy();
 
diff --git a/src/gpu/GrTextureMaker.cpp b/src/gpu/GrTextureMaker.cpp
index de73479..34383e1 100644
--- a/src/gpu/GrTextureMaker.cpp
+++ b/src/gpu/GrTextureMaker.cpp
@@ -14,13 +14,12 @@
 #include "src/gpu/GrRecordingContextPriv.h"
 #include "src/gpu/SkGr.h"
 
-GrSurfaceProxyView GrTextureMaker::onRefTextureProxyViewForParams(GrSamplerState params,
-                                                                  bool willBeMipped) {
+GrSurfaceProxyView GrTextureMaker::onView(GrMipMapped mipMapped) {
     if (this->width() > this->context()->priv().caps()->maxTextureSize() ||
         this->height() > this->context()->priv().caps()->maxTextureSize()) {
         return {};
     }
-    return this->refOriginalTextureProxyView(willBeMipped);
+    return this->refOriginalTextureProxyView(mipMapped);
 }
 
 std::unique_ptr<GrFragmentProcessor> GrTextureMaker::createFragmentProcessor(
@@ -41,7 +40,12 @@
         fmForDetermineDomain = &kBilerp;
     }
 
-    GrSurfaceProxyView view = this->viewForParams(filterOrNullForBicubic);
+    GrSurfaceProxyView view;
+    if (filterOrNullForBicubic) {
+        view = this->view(*filterOrNullForBicubic);
+    } else {
+        view = this->view(GrMipMapped::kNo);
+    }
     if (!view) {
         return nullptr;
     }
diff --git a/src/gpu/GrTextureMaker.h b/src/gpu/GrTextureMaker.h
index 20352f6..872a5d4 100644
--- a/src/gpu/GrTextureMaker.h
+++ b/src/gpu/GrTextureMaker.h
@@ -31,13 +31,10 @@
     /**
      *  Return the maker's "original" texture. It is the responsibility of the maker to handle any
      *  caching of the original if desired.
-     *  If "genType" argument equals AllowedTexGenType::kCheap and the texture is not trivial to
-     *  construct then refOriginalTextureProxy should return nullptr (for example if texture is made
-     *  by drawing into a render target).
      */
-    virtual GrSurfaceProxyView refOriginalTextureProxyView(bool willBeMipped) = 0;
+    virtual GrSurfaceProxyView refOriginalTextureProxyView(GrMipMapped) = 0;
 
-    GrSurfaceProxyView onRefTextureProxyViewForParams(GrSamplerState, bool willBeMipped) final;
+    GrSurfaceProxyView onView(GrMipMapped) final;
 
     typedef GrTextureProducer INHERITED;
 };
diff --git a/src/gpu/GrTextureProducer.cpp b/src/gpu/GrTextureProducer.cpp
index c40a142..62c4e9c 100644
--- a/src/gpu/GrTextureProducer.cpp
+++ b/src/gpu/GrTextureProducer.cpp
@@ -167,62 +167,25 @@
     }
 }
 
-GrSurfaceProxyView GrTextureProducer::viewForParams(
-        const GrSamplerState::Filter* filterOrNullForBicubic) {
-    GrSamplerState sampler; // Default is nearest + clamp
-    if (filterOrNullForBicubic) {
-        sampler.setFilterMode(*filterOrNullForBicubic);
-    }
-    if (fDomainNeedsDecal) {
-        // Assuming hardware support, switch to clamp-to-border instead of clamp
-        if (fContext->priv().caps()->clampToBorderSupport()) {
-            sampler.setWrapModeX(GrSamplerState::WrapMode::kClampToBorder);
-            sampler.setWrapModeY(GrSamplerState::WrapMode::kClampToBorder);
+GrSurfaceProxyView GrTextureProducer::view(GrMipMapped mipMapped) {
+    const GrCaps* caps = this->context()->priv().caps();
+    // Sanitize the MIP map request.
+    if (mipMapped == GrMipMapped::kYes) {
+        if ((this->width() == 1 && this->height() == 1) || !caps->mipMapSupport()) {
+            mipMapped = GrMipMapped::kNo;
         }
     }
-    return this->viewForParams(sampler);
-}
-
-GrSurfaceProxyView GrTextureProducer::viewForParams(GrSamplerState sampler) {
-    const GrCaps* caps = this->context()->priv().caps();
-
-    int mipCount = SkMipMap::ComputeLevelCount(this->width(), this->height());
-    bool willBeMipped = GrSamplerState::Filter::kMipMap == sampler.filter() && mipCount &&
-                        caps->mipMapSupport();
-
-    auto result = this->onRefTextureProxyViewForParams(sampler, willBeMipped);
-    if (!result) {
-        return {};
-    }
-
-    SkASSERT(result.asTextureProxy());
-
-    // Check to make sure that if we say the texture willBeMipped that the returned texture has mip
-    // maps, unless the config is not copyable.
-    SkASSERT(!willBeMipped || result.asTextureProxy()->mipMapped() == GrMipMapped::kYes ||
+    auto result = this->onView(mipMapped);
+    // Check to make sure if we requested MIPs that the returned texture has MIP maps or the format
+    // is not copyable.
+    SkASSERT(!result || mipMapped == GrMipMapped::kNo ||
+             result.asTextureProxy()->mipMapped() == GrMipMapped::kYes ||
              !caps->isFormatCopyable(result.proxy()->backendFormat()));
-
-    SkASSERT(result.proxy()->dimensions() == this->dimensions());
-
     return result;
 }
 
-std::pair<GrSurfaceProxyView, GrColorType> GrTextureProducer::view(GrMipMapped willNeedMips) {
-    GrSamplerState::Filter filter =
-            GrMipMapped::kNo == willNeedMips ? GrSamplerState::Filter::kNearest
-                                             : GrSamplerState::Filter::kMipMap;
-    GrSamplerState sampler(GrSamplerState::WrapMode::kClamp, filter);
-
-    auto result = this->viewForParams(sampler);
-
-#ifdef SK_DEBUG
-    const GrCaps* caps = this->context()->priv().caps();
-    // Check that the resulting proxy format is compatible with the GrColorType of this producer
-    SkASSERT(!result.proxy() ||
-             result.proxy()->isFormatCompressed(caps) ||
-             caps->areColorTypeAndFormatCompatible(this->colorType(),
-                                                   result.proxy()->backendFormat()));
-#endif
-
-    return {result, this->colorType()};
+GrSurfaceProxyView GrTextureProducer::view(GrSamplerState::Filter filter) {
+    auto mipMapped = filter == GrSamplerState::Filter::kMipMap ? GrMipMapped::kYes
+                                                               : GrMipMapped::kNo;
+    return this->view(mipMapped);
 }
diff --git a/src/gpu/GrTextureProducer.h b/src/gpu/GrTextureProducer.h
index 0d05a30..a3c5744 100644
--- a/src/gpu/GrTextureProducer.h
+++ b/src/gpu/GrTextureProducer.h
@@ -32,6 +32,8 @@
  */
 class GrTextureProducer : public SkNoncopyable {
 public:
+    virtual ~GrTextureProducer() {}
+
     enum FilterConstraint {
         kYes_FilterConstraint,
         kNo_FilterConstraint,
@@ -65,28 +67,19 @@
             const GrSamplerState::Filter* filterOrNullForBicubic) = 0;
 
     /**
-     *  Returns a texture that is safe for use with the params.
+     * Returns a texture view, possibly with MIP maps. The request for MIP maps may not be honored
+     * base on caps, format, and whether the texture is 1x1. A non-MIP mapped request may still
+     * receive a MIP mapped texture (if that is what is available in the cache).
      */
-    GrSurfaceProxyView viewForParams(GrSamplerState);
+    GrSurfaceProxyView view(GrMipMapped);
 
-    GrSurfaceProxyView viewForParams(const GrSamplerState::Filter* filterOrNullForBicubic);
-
-    /**
-     * Returns a texture. If willNeedMips is true then the returned texture is guaranteed to have
-     * allocated mip map levels. This can be a performance win if future draws with the texture
-     * require mip maps.
-     */
-    // TODO: Once we remove support for npot textures, we should add a flag for must support repeat
-    // wrap mode. To support that flag now would require us to support scaleAdjust array like in
-    // refTextureProxyForParams, however the current public API that uses this call does not expose
-    // that array.
-    std::pair<GrSurfaceProxyView, GrColorType> view(GrMipMapped willNeedMips);
-
-    virtual ~GrTextureProducer() {}
+    /** Helper version of above that determines MIP mapping requirement from Filter. */
+    GrSurfaceProxyView view(GrSamplerState::Filter);
 
     int width() const { return fImageInfo.width(); }
     int height() const { return fImageInfo.height(); }
     SkISize dimensions() const { return fImageInfo.dimensions(); }
+    GrColorType colorType() const { return fImageInfo.colorType(); }
     SkAlphaType alphaType() const { return fImageInfo.alphaType(); }
     SkColorSpace* colorSpace() const { return fImageInfo.colorSpace(); }
     bool isAlphaOnly() const { return GrColorTypeIsAlphaOnly(fImageInfo.colorType()); }
@@ -102,8 +95,6 @@
                       bool domainNeedsDecal)
             : fContext(context), fImageInfo(imageInfo), fDomainNeedsDecal(domainNeedsDecal) {}
 
-    GrColorType colorType() const { return fImageInfo.colorType(); }
-
     enum DomainMode {
         kNoDomain_DomainMode,
         kDomain_DomainMode,
@@ -127,8 +118,7 @@
     GrRecordingContext* context() const { return fContext; }
 
 private:
-    virtual GrSurfaceProxyView onRefTextureProxyViewForParams(GrSamplerState,
-                                                              bool willBeMipped) = 0;
+    virtual GrSurfaceProxyView onView(GrMipMapped) = 0;
 
     GrRecordingContext* fContext;
     const GrImageInfo fImageInfo;
diff --git a/src/gpu/GrYUVProvider.cpp b/src/gpu/GrYUVProvider.cpp
index 470bf2a..905bbd1 100644
--- a/src/gpu/GrYUVProvider.cpp
+++ b/src/gpu/GrYUVProvider.cpp
@@ -153,7 +153,7 @@
         bitmap.setImmutable();
 
         GrBitmapTextureMaker maker(ctx, bitmap, GrBitmapTextureMaker::Cached::kNo, fit);
-        std::tie(yuvViews[i], std::ignore) = maker.view(GrMipMapped::kNo);
+        yuvViews[i] = maker.view(GrMipMapped::kNo);
 
         if (!yuvViews[i]) {
             return {};
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 9deaff9..e98bc8e 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -699,7 +699,6 @@
                                     const SkIRect& imageRect,
                                     const SkMatrix& viewMatrix,
                                     const SkMatrix& srcToDstRect,
-                                    GrSamplerState params,
                                     const SkRect* srcRectPtr,
                                     int maxTileSize,
                                     int* tileSize,
@@ -754,7 +753,6 @@
     // If image is explicitly texture backed then we shouldn't get here.
     SkASSERT(!image->isTextureBacked());
 
-    GrSamplerState samplerState;
     bool doBicubic;
     GrSamplerState::Filter textureFilterMode = GrSkFilterQualityToGrFilterMode(
             image->width(), image->height(), quality, viewMatrix, srcToDstRect,
@@ -768,7 +766,6 @@
     } else {
         tileFilterPad = 1;
     }
-    samplerState.setFilterMode(textureFilterMode);
 
     int maxTileSize = this->caps()->maxTileSize() - 2 * tileFilterPad;
 
@@ -777,8 +774,7 @@
     SkIRect outClippedSrcRect;
 
     return this->shouldTileImageID(image->unique(), image->bounds(), viewMatrix, srcToDstRect,
-                                   samplerState, srcRectPtr, maxTileSize, &outTileSize,
-                                   &outClippedSrcRect);
+                                   srcRectPtr, maxTileSize, &outTileSize, &outClippedSrcRect);
 }
 
 // This method outsets 'iRect' by 'outset' all around and then clamps its extents to
@@ -821,7 +817,7 @@
                                   const SkMatrix& dstMatrix,
                                   const SkRect& srcRect,
                                   const SkIRect& clippedSrcIRect,
-                                  GrSamplerState params,
+                                  GrSamplerState::Filter filter,
                                   const SkPaint& origPaint,
                                   SkCanvas::SrcRectConstraint constraint,
                                   int tileSize,
@@ -864,7 +860,7 @@
                                             SkIntToScalar(iTileR.fTop));
             SkRect rectToDraw = tileR;
             dstMatrix.mapRect(&rectToDraw);
-            if (GrSamplerState::Filter::kNearest != params.filter() || bicubic) {
+            if (filter != GrSamplerState::Filter::kNearest || bicubic) {
                 SkIRect iClampRect;
 
                 if (SkCanvas::kFast_SrcRectConstraint == constraint) {
@@ -891,7 +887,7 @@
                                      viewMatrix,
                                      rectToDraw,
                                      tileR,
-                                     params,
+                                     filter,
                                      *paint,
                                      constraint,
                                      bicubic,
@@ -905,7 +901,7 @@
                                  const SkMatrix& viewMatrix,
                                  const SkRect& dstRect,
                                  const SkRect& srcRect,
-                                 GrSamplerState samplerState,
+                                 GrSamplerState::Filter filter,
                                  const SkPaint& paint,
                                  SkCanvas::SrcRectConstraint constraint,
                                  bool bicubic,
@@ -916,9 +912,10 @@
     // We should be respecting the max tile size by the time we get here.
     SkASSERT(bitmap.width() <= this->caps()->maxTileSize() &&
              bitmap.height() <= this->caps()->maxTileSize());
-    SkASSERT(!samplerState.isRepeated());
 
-    GrSurfaceProxyView view = GrRefCachedBitmapView(fContext.get(), bitmap, samplerState);
+    GrMipMapped mipMapped = filter == GrSamplerState::Filter::kMipMap ? GrMipMapped::kYes
+                                                                      : GrMipMapped::kNo;
+    GrSurfaceProxyView view = GrRefCachedBitmapView(fContext.get(), bitmap, mipMapped);
     if (!view) {
         return;
     }
@@ -937,19 +934,18 @@
         if (bicubic) {
             static constexpr auto kDir = GrBicubicEffect::Direction::kXY;
             fp = GrBicubicEffect::MakeSubset(std::move(view), srcAlphaType, texMatrix,
-                                             samplerState.wrapModeX(), samplerState.wrapModeY(),
-                                             srcRect, kDir, caps);
+                                             GrSamplerState::WrapMode::kClamp,
+                                             GrSamplerState::WrapMode::kClamp, srcRect, kDir, caps);
         } else {
-            fp = GrTextureEffect::MakeSubset(std::move(view), srcAlphaType, texMatrix,
-                                             samplerState, srcRect, caps);
+            fp = GrTextureEffect::MakeSubset(std::move(view), srcAlphaType, texMatrix, filter,
+                                             srcRect, caps);
         }
     } else if (bicubic) {
-        SkASSERT(GrSamplerState::Filter::kNearest == samplerState.filter());
+        SkASSERT(GrSamplerState::Filter::kNearest == filter);
         static constexpr auto kDir = GrBicubicEffect::Direction::kXY;
-        fp = GrBicubicEffect::Make(std::move(view), srcAlphaType, texMatrix,
-                                   samplerState.wrapModeX(), samplerState.wrapModeY(), kDir, caps);
+        fp = GrBicubicEffect::Make(std::move(view), srcAlphaType, texMatrix, kDir);
     } else {
-        fp = GrTextureEffect::Make(std::move(view), srcAlphaType, texMatrix, samplerState, caps);
+        fp = GrTextureEffect::Make(std::move(view), srcAlphaType, texMatrix, filter);
     }
 
     fp = GrColorSpaceXformEffect::Make(std::move(fp), bitmap.colorSpace(), bitmap.alphaType(),
@@ -1043,14 +1039,7 @@
     SkRect dstRect = SkRect::Make(SkIRect::MakeXYWH(left, top, subset.width(), subset.height()));
     SkRect srcRect = SkRect::Make(subset);
     if (clipImage) {
-        // Add the image as a simple texture effect applied to coverage. Accessing content outside
-        // of the clip image should behave as if it were a decal (i.e. zero coverage). However, to
-        // limit pixels touched and hardware checks, we draw the clip image geometry to get the
-        // decal effect.
-        auto filter = paint.getFilterQuality() > kNone_SkFilterQuality
-                              ? GrSamplerState::Filter::kBilerp
-                              : GrSamplerState::Filter::kNearest;
-        GrSurfaceProxyView clipView = as_IB(clipImage)->refView(this->context(), filter);
+        GrSurfaceProxyView clipView = as_IB(clipImage)->refView(this->context(), GrMipMapped::kNo);
         // Fold clip matrix into ctm
         ctm.preConcat(clipMatrix);
         SkMatrix inverseClipMatrix;
@@ -1060,7 +1049,7 @@
             GrColorType srcColorType = SkColorTypeToGrColorType(clipImage->colorType());
 
             cfp = GrTextureEffect::Make(std::move(clipView), clipImage->alphaType(),
-                                        inverseClipMatrix, filter);
+                                        inverseClipMatrix);
             if (srcColorType != GrColorType::kAlpha_8) {
                 cfp = GrFragmentProcessor::SwizzleOutput(std::move(cfp), GrSwizzle::AAAA());
             }
@@ -1142,7 +1131,6 @@
         int tileSize;
         SkIRect clippedSrcRect;
 
-        GrSamplerState sampleState;
         bool doBicubic;
         GrSamplerState::Filter textureFilterMode = GrSkFilterQualityToGrFilterMode(
                 bitmap.width(), bitmap.height(), paint.getFilterQuality(), this->localToDevice(),
@@ -1157,14 +1145,14 @@
         } else {
             tileFilterPad = 1;
         }
-        sampleState.setFilterMode(textureFilterMode);
 
         int maxTileSizeForFilter = this->caps()->maxTileSize() - 2 * tileFilterPad;
         if (this->shouldTileImageID(bitmap.getGenerationID(), bitmap.getSubset(),
-                                    this->localToDevice(), srcToDstMatrix, sampleState, src,
+                                    this->localToDevice(), srcToDstMatrix, src,
                                     maxTileSizeForFilter, &tileSize, &clippedSrcRect)) {
-            this->drawTiledBitmap(bitmap, this->localToDevice(), srcToDstMatrix, *src, clippedSrcRect,
-                                  sampleState, paint, constraint, tileSize, doBicubic);
+            this->drawTiledBitmap(bitmap, this->localToDevice(), srcToDstMatrix, *src,
+                                  clippedSrcRect, textureFilterMode, paint, constraint, tileSize,
+                                  doBicubic);
             return;
         }
     }
@@ -1343,7 +1331,7 @@
 
     auto dstColorSpace = fRenderTargetContext->colorInfo().colorSpace();
     const GrSamplerState::Filter filter = compute_lattice_filter_mode(*paint);
-    auto view = producer->viewForParams(&filter);
+    auto view = producer->view(filter);
     if (!view) {
         return;
     }
diff --git a/src/gpu/SkGpuDevice.h b/src/gpu/SkGpuDevice.h
index 7baf339..4919ad5 100644
--- a/src/gpu/SkGpuDevice.h
+++ b/src/gpu/SkGpuDevice.h
@@ -170,7 +170,6 @@
                            const SkIRect& imageRect,
                            const SkMatrix& viewMatrix,
                            const SkMatrix& srcToDstRectMatrix,
-                           GrSamplerState params,
                            const SkRect* srcRectPtr,
                            int maxTileSize,
                            int* tileSize,
@@ -192,7 +191,7 @@
                          const SkMatrix& srcToDstMatrix,
                          const SkRect& srcRect,
                          const SkIRect& clippedSrcRect,
-                         GrSamplerState params,
+                         GrSamplerState::Filter,
                          const SkPaint& paint,
                          SkCanvas::SrcRectConstraint,
                          int tileSize,
@@ -203,7 +202,7 @@
                         const SkMatrix& viewMatrix,
                         const SkRect& dstRect,
                         const SkRect& srcRect,
-                        GrSamplerState samplerState,
+                        GrSamplerState::Filter,
                         const SkPaint& paint,
                         SkCanvas::SrcRectConstraint,
                         bool bicubic,
diff --git a/src/gpu/SkGpuDevice_drawTexture.cpp b/src/gpu/SkGpuDevice_drawTexture.cpp
index 7b2b1a9..2eb7788 100644
--- a/src/gpu/SkGpuDevice_drawTexture.cpp
+++ b/src/gpu/SkGpuDevice_drawTexture.cpp
@@ -241,14 +241,14 @@
     if (attemptDrawTexture && can_use_draw_texture(paint)) {
         // We've done enough checks above to allow us to pass ClampNearest() and not check for
         // scaling adjustments.
-        auto[view, ct] = producer->view(GrMipMapped::kNo);
+        auto view = producer->view(GrMipMapped::kNo);
         if (!view) {
             return;
         }
 
-        draw_texture(rtc, clip, ctm, paint, src, dst, dstClip, aa, aaFlags, constraint,
-                     std::move(view),
-                     {ct, producer->alphaType(), sk_ref_sp(producer->colorSpace())});
+        draw_texture(
+                rtc, clip, ctm, paint, src, dst, dstClip, aa, aaFlags, constraint, std::move(view),
+                {producer->colorType(), producer->alphaType(), sk_ref_sp(producer->colorSpace())});
         return;
     }
 
@@ -537,7 +537,7 @@
             uint32_t uniqueID;
             view = image->refPinnedView(this->context(), &uniqueID);
             if (!view) {
-                view = image->refView(this->context(), GrSamplerState::Filter::kBilerp);
+                view = image->refView(this->context(), GrMipMapped::kNo);
             }
         }
 
diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp
index 0b20bb7..7222dcf 100644
--- a/src/gpu/SkGr.cpp
+++ b/src/gpu/SkGr.cpp
@@ -134,9 +134,9 @@
 }
 
 GrSurfaceProxyView GrRefCachedBitmapView(GrRecordingContext* ctx, const SkBitmap& bitmap,
-                                         GrSamplerState params) {
+                                         GrMipMapped mipMapped) {
     GrBitmapTextureMaker maker(ctx, bitmap, GrBitmapTextureMaker::Cached::kYes);
-    return maker.viewForParams(params);
+    return maker.view(mipMapped);
 }
 
 GrSurfaceProxyView GrMakeCachedBitmapProxyView(GrRecordingContext* context, const SkBitmap& bitmap,
@@ -146,8 +146,7 @@
     }
 
     GrBitmapTextureMaker maker(context, bitmap, GrBitmapTextureMaker::Cached::kYes, fit);
-    auto[view, grCT] = maker.view(GrMipMapped::kNo);
-    return view;
+    return maker.view(GrMipMapped::kNo);
 }
 
 ///////////////////////////////////////////////////////////////////////////////
diff --git a/src/gpu/SkGr.h b/src/gpu/SkGr.h
index 36daae1..bdfb31a 100644
--- a/src/gpu/SkGr.h
+++ b/src/gpu/SkGr.h
@@ -164,11 +164,12 @@
 // Texture management
 
 /**
- * Returns a view that wraps a texture representing the bitmap that is compatible with the
- * GrSamplerState. The texture is inserted into the cache (unless the bitmap is marked volatile)
- * and can be retrieved again via this function.
+ * Returns a view that wraps a texture representing the bitmap. The texture is inserted into the
+ * cache (unless the bitmap is marked volatile and can be retrieved again via this function.
+ * A MIP mapped texture may be returned even when GrMipMapped is kNo. The function will succeed
+ * with a non-MIP mapped texture if GrMipMapped is kYes but MIP mapping is not supported.
  */
-GrSurfaceProxyView GrRefCachedBitmapView(GrRecordingContext*, const SkBitmap&, GrSamplerState);
+GrSurfaceProxyView GrRefCachedBitmapView(GrRecordingContext*, const SkBitmap&, GrMipMapped);
 
 /**
  * Creates a new texture with mipmap levels and copies the baseProxy into the base layer.
diff --git a/src/gpu/effects/GrCircleBlurFragmentProcessor.fp b/src/gpu/effects/GrCircleBlurFragmentProcessor.fp
index eefb3f5..5582538 100644
--- a/src/gpu/effects/GrCircleBlurFragmentProcessor.fp
+++ b/src/gpu/effects/GrCircleBlurFragmentProcessor.fp
@@ -257,7 +257,7 @@
         bm.setImmutable();
 
         GrBitmapTextureMaker maker(context, bm);
-        auto[blurView, grCT] = maker.view(GrMipMapped::kNo);
+        auto blurView = maker.view(GrMipMapped::kNo);
         if (!blurView) {
             return {};
         }
diff --git a/src/gpu/effects/GrConfigConversionEffect.fp b/src/gpu/effects/GrConfigConversionEffect.fp
index 1ac027f..f3932f5 100644
--- a/src/gpu/effects/GrConfigConversionEffect.fp
+++ b/src/gpu/effects/GrConfigConversionEffect.fp
@@ -60,9 +60,8 @@
         bitmap.setImmutable();
 
         GrBitmapTextureMaker maker(context, bitmap);
-        auto [dataView, ct] = maker.view(GrMipMapped::kNo);
-
-        if (!dataView.proxy()) {
+        auto dataView = maker.view(GrMipMapped::kNo);
+        if (!dataView) {
             return false;
         }
 
diff --git a/src/gpu/effects/GrRectBlurEffect.fp b/src/gpu/effects/GrRectBlurEffect.fp
index 1cabeb8..667d92b 100644
--- a/src/gpu/effects/GrRectBlurEffect.fp
+++ b/src/gpu/effects/GrRectBlurEffect.fp
@@ -85,7 +85,7 @@
     bitmap.setImmutable();
 
     GrBitmapTextureMaker maker(context, bitmap);
-    auto[view, grCT] = maker.view(GrMipMapped::kNo);
+    auto view = maker.view(GrMipMapped::kNo);
     if (!view) {
         return {};
     }
diff --git a/src/gpu/effects/generated/GrCircleBlurFragmentProcessor.cpp b/src/gpu/effects/generated/GrCircleBlurFragmentProcessor.cpp
index bb6767f..d53339f 100644
--- a/src/gpu/effects/generated/GrCircleBlurFragmentProcessor.cpp
+++ b/src/gpu/effects/generated/GrCircleBlurFragmentProcessor.cpp
@@ -234,7 +234,7 @@
     bm.setImmutable();
 
     GrBitmapTextureMaker maker(context, bm);
-    auto[blurView, grCT] = maker.view(GrMipMapped::kNo);
+    auto blurView = maker.view(GrMipMapped::kNo);
     if (!blurView) {
         return {};
     }
diff --git a/src/gpu/effects/generated/GrConfigConversionEffect.h b/src/gpu/effects/generated/GrConfigConversionEffect.h
index 5e4b3ce..f6bbd62 100644
--- a/src/gpu/effects/generated/GrConfigConversionEffect.h
+++ b/src/gpu/effects/generated/GrConfigConversionEffect.h
@@ -69,9 +69,8 @@
         bitmap.setImmutable();
 
         GrBitmapTextureMaker maker(context, bitmap);
-        auto[dataView, ct] = maker.view(GrMipMapped::kNo);
-
-        if (!dataView.proxy()) {
+        auto dataView = maker.view(GrMipMapped::kNo);
+        if (!dataView) {
             return false;
         }
 
diff --git a/src/gpu/effects/generated/GrRectBlurEffect.h b/src/gpu/effects/generated/GrRectBlurEffect.h
index 6a56d9d..f7331fe 100644
--- a/src/gpu/effects/generated/GrRectBlurEffect.h
+++ b/src/gpu/effects/generated/GrRectBlurEffect.h
@@ -68,7 +68,7 @@
         bitmap.setImmutable();
 
         GrBitmapTextureMaker maker(context, bitmap);
-        auto[view, grCT] = maker.view(GrMipMapped::kNo);
+        auto view = maker.view(GrMipMapped::kNo);
         if (!view) {
             return {};
         }
diff --git a/src/gpu/ops/GrShadowRRectOp.cpp b/src/gpu/ops/GrShadowRRectOp.cpp
index 6d1a36b..71fe840 100644
--- a/src/gpu/ops/GrShadowRRectOp.cpp
+++ b/src/gpu/ops/GrShadowRRectOp.cpp
@@ -668,7 +668,7 @@
     bitmap.setImmutable();
 
     GrBitmapTextureMaker maker(context, bitmap);
-    auto[view, grCT] = maker.view(GrMipMapped::kNo);
+    auto view = maker.view(GrMipMapped::kNo);
     SkASSERT(view.origin() == kTopLeft_GrSurfaceOrigin);
 
     if (view) {