Remove image usage type enum. Use GrTextureParams instead.

BUG=skia:

Review URL: https://codereview.chromium.org/1404433002
diff --git a/src/core/SkBitmapProcShader.cpp b/src/core/SkBitmapProcShader.cpp
index 3dd528d..70f692a 100644
--- a/src/core/SkBitmapProcShader.cpp
+++ b/src/core/SkBitmapProcShader.cpp
@@ -392,7 +392,7 @@
             GrSkFilterQualityToGrFilterMode(filterQuality, viewM, this->getLocalMatrix(),
                                             &doBicubic);
     GrTextureParams params(tm, textureFilterMode);
-    SkAutoTUnref<GrTexture> texture(GrRefCachedBitmapTexture(context, fRawBitmap, &params));
+    SkAutoTUnref<GrTexture> texture(GrRefCachedBitmapTexture(context, fRawBitmap, params));
 
     if (!texture) {
         SkErrorInternals::SetError( kInternalError_SkError,
diff --git a/src/core/SkImageCacherator.cpp b/src/core/SkImageCacherator.cpp
index 03e358a..5c0d054 100644
--- a/src/core/SkImageCacherator.cpp
+++ b/src/core/SkImageCacherator.cpp
@@ -18,7 +18,7 @@
 #include "GrContext.h"
 #include "GrGpuResourcePriv.h"
 #include "GrResourceKey.h"
-#include "GrTextureAccess.h"
+#include "GrTextureParams.h"
 #include "GrYUVProvider.h"
 #include "SkGr.h"
 #include "SkGrPriv.h"
@@ -140,7 +140,7 @@
     {
         ScopedGenerator generator(this);
         SkIRect subset = SkIRect::MakeXYWH(fOrigin.x(), fOrigin.y(), fInfo.width(), fInfo.height());
-        tex.reset(generator->generateTexture(nullptr, kUntiled_SkImageUsageType, &subset));
+        tex.reset(generator->generateTexture(nullptr, GrTextureParams::ClampNoFilter(), &subset));
     }
     if (!tex) {
         bitmap->reset();
@@ -212,12 +212,12 @@
  *  We have a 5 ways to try to return a texture (in sorted order)
  *
  *  1. Check the cache for a pre-existing one
- *  2. Ask the genreator to natively create one
+ *  2. Ask the generator to natively create one
  *  3. Ask the generator to return a compressed form that the GPU might support
  *  4. Ask the generator to return YUV planes, which the GPU can convert
  *  5. Ask the generator to return RGB(A) data, which the GPU can convert
  */
-GrTexture* SkImageCacherator::lockUnstretchedTexture(GrContext* ctx, SkImageUsageType usage,
+GrTexture* SkImageCacherator::lockUnstretchedTexture(GrContext* ctx, const GrTextureParams& params,
                                                      const SkImage* client) {
     // textures (at least the texture-key) only support 16bit dimensions, so abort early
     // if we're too big.
@@ -227,7 +227,7 @@
 
     GrUniqueKey key;
     GrMakeKeyFromImageID(&key, fUniqueID, SkIRect::MakeWH(fInfo.width(), fInfo.height()),
-                         *ctx->caps(), usage);
+                         *ctx->caps(), params);
 
     // 1. Check the cache for a pre-existing one
     if (GrTexture* tex = ctx->textureProvider()->findAndRefTextureByUniqueKey(key)) {
@@ -238,7 +238,7 @@
     {
         ScopedGenerator generator(this);
         SkIRect subset = SkIRect::MakeXYWH(fOrigin.x(), fOrigin.y(), fInfo.width(), fInfo.height());
-        if (GrTexture* tex = generator->generateTexture(ctx, usage, &subset)) {
+        if (GrTexture* tex = generator->generateTexture(ctx, params, &subset)) {
             return set_key_and_return(tex, key);
         }
     }
@@ -267,7 +267,7 @@
     // 5. Ask the generator to return RGB(A) data, which the GPU can convert
     SkBitmap bitmap;
     if (this->tryLockAsBitmap(&bitmap, client)) {
-        return GrRefCachedBitmapTexture(ctx, bitmap, usage);
+        return GrRefCachedBitmapTexture(ctx, bitmap, params);
     }
     return nullptr;
 }
@@ -278,11 +278,11 @@
 
 class Cacherator_GrTextureMaker : public GrTextureMaker {
 public:
-    Cacherator_GrTextureMaker(SkImageCacherator* cacher, SkImageUsageType usage,
+    Cacherator_GrTextureMaker(SkImageCacherator* cacher, const GrTextureParams& params,
                               const SkImage* client, const GrUniqueKey& unstretchedKey)
         : INHERITED(cacher->info().width(), cacher->info().height())
         , fCacher(cacher)
-        , fUsage(usage)
+        , fParams(params)
         , fClient(client)
         , fUnstretchedKey(unstretchedKey)
     {}
@@ -293,7 +293,7 @@
 //    GrTexture* onGenerateStretchedTexture(GrContext*, const SkGrStretch&) override;
 
     GrTexture* onRefUnstretchedTexture(GrContext* ctx) override {
-        return fCacher->lockUnstretchedTexture(ctx, fUsage, fClient);
+        return fCacher->lockUnstretchedTexture(ctx, fParams, fClient);
     }
 
     bool onMakeStretchedKey(const SkGrStretch& stretch, GrUniqueKey* stretchedKey) override {
@@ -312,14 +312,14 @@
 
 private:
     SkImageCacherator*      fCacher;
-    const SkImageUsageType  fUsage;
+    const GrTextureParams&  fParams;
     const SkImage*          fClient;
     const GrUniqueKey       fUnstretchedKey;
 
     typedef GrTextureMaker INHERITED;
 };
 
-GrTexture* SkImageCacherator::lockAsTexture(GrContext* ctx, SkImageUsageType usage,
+GrTexture* SkImageCacherator::lockAsTexture(GrContext* ctx, const GrTextureParams& params,
                                             const SkImage* client) {
     if (!ctx) {
         return nullptr;
@@ -328,14 +328,14 @@
     GrUniqueKey key;
     GrMakeKeyFromImageID(&key, this->uniqueID(),
                          SkIRect::MakeWH(this->info().width(), this->info().height()),
-                         *ctx->caps(), usage);
+                         *ctx->caps(), params);
 
-    return Cacherator_GrTextureMaker(this, usage, client, key).refCachedTexture(ctx, usage);
+    return Cacherator_GrTextureMaker(this, params, client, key).refCachedTexture(ctx, params);
 }
 
 #else
 
-GrTexture* SkImageCacherator::lockAsTexture(GrContext* ctx, SkImageUsageType usage,
+GrTexture* SkImageCacherator::lockAsTexture(GrContext* ctx, const GrTextureParams&,
                                             const SkImage* client) {
     return nullptr;
 }
diff --git a/src/core/SkImageCacherator.h b/src/core/SkImageCacherator.h
index c5c6549..1d00117 100644
--- a/src/core/SkImageCacherator.h
+++ b/src/core/SkImageCacherator.h
@@ -13,6 +13,7 @@
 #include "SkTemplates.h"
 
 class GrContext;
+class GrTextureParams; 
 class SkBitmap;
 class SkImage;
 
@@ -45,7 +46,7 @@
      *
      *  The caller is responsible for calling texture->unref() when they are done.
      */
-    GrTexture* lockAsTexture(GrContext*, SkImageUsageType, const SkImage* client);
+    GrTexture* lockAsTexture(GrContext*, const GrTextureParams&, const SkImage* client);
 
     /**
      *  If the underlying src naturally is represented by an encoded blob (in SkData), this returns
@@ -59,7 +60,7 @@
     bool generateBitmap(SkBitmap*);
     bool tryLockAsBitmap(SkBitmap*, const SkImage*);
 #if SK_SUPPORT_GPU
-    GrTexture* lockUnstretchedTexture(GrContext*, SkImageUsageType, const SkImage* client);
+    GrTexture* lockUnstretchedTexture(GrContext*, const GrTextureParams&, const SkImage* client);
 #endif
 
     class ScopedGenerator {
diff --git a/src/core/SkImageFilter.cpp b/src/core/SkImageFilter.cpp
index 2920714..4ad7f0e 100644
--- a/src/core/SkImageFilter.cpp
+++ b/src/core/SkImageFilter.cpp
@@ -464,7 +464,8 @@
                 if (kUnknown_SkColorType == info.colorType()) {
                     return false;
                 }
-                SkAutoTUnref<GrTexture> resultTex(GrRefCachedBitmapTexture(context, *result, nullptr));
+                SkAutoTUnref<GrTexture> resultTex(
+                    GrRefCachedBitmapTexture(context, *result,GrTextureParams::ClampNoFilter()));
                 result->setPixelRef(new SkGrPixelRef(info, resultTex))->unref();
             }
             return true;
diff --git a/src/core/SkImageGenerator.cpp b/src/core/SkImageGenerator.cpp
index 187b460..98a4014 100644
--- a/src/core/SkImageGenerator.cpp
+++ b/src/core/SkImageGenerator.cpp
@@ -104,12 +104,12 @@
     return this->onGetYUV8Planes(sizes, planes, rowBytes);
 }
 
-GrTexture* SkImageGenerator::generateTexture(GrContext* ctx, SkImageUsageType usage,
+GrTexture* SkImageGenerator::generateTexture(GrContext* ctx, const GrTextureParams& params,
                                              const SkIRect* subset) {
     if (subset && !SkIRect::MakeWH(fInfo.width(), fInfo.height()).contains(*subset)) {
         return nullptr;
     }
-    return this->onGenerateTexture(ctx, usage, subset);
+    return this->onGenerateTexture(ctx, params, subset);
 }
 
 /////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/core/SkLightingShader.cpp b/src/core/SkLightingShader.cpp
index 6121f215..16441aa 100644
--- a/src/core/SkLightingShader.cpp
+++ b/src/core/SkLightingShader.cpp
@@ -382,7 +382,7 @@
     // TODO: support other tile modes
     GrTextureParams diffParams(kClamp_TileMode, diffFilterMode);
     SkAutoTUnref<GrTexture> diffuseTexture(GrRefCachedBitmapTexture(context,
-                                                                    fDiffuseMap, &diffParams));
+                                                                    fDiffuseMap, diffParams));
     if (!diffuseTexture) {
         SkErrorInternals::SetError(kInternalError_SkError, "Couldn't convert bitmap to texture.");
         return nullptr;
@@ -390,7 +390,7 @@
 
     GrTextureParams normParams(kClamp_TileMode, normFilterMode);
     SkAutoTUnref<GrTexture> normalTexture(GrRefCachedBitmapTexture(context,
-                                                                   fNormalMap, &normParams));
+                                                                   fNormalMap, normParams));
     if (!normalTexture) {
         SkErrorInternals::SetError(kInternalError_SkError, "Couldn't convert bitmap to texture.");
         return nullptr;
diff --git a/src/core/SkPictureImageGenerator.cpp b/src/core/SkPictureImageGenerator.cpp
index 13d3cc8..a27291f 100644
--- a/src/core/SkPictureImageGenerator.cpp
+++ b/src/core/SkPictureImageGenerator.cpp
@@ -22,7 +22,7 @@
     bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, SkPMColor ctable[],
                      int* ctableCount) override;
 #if SK_SUPPORT_GPU
-    GrTexture* onGenerateTexture(GrContext*, SkImageUsageType, const SkIRect*) override;
+    GrTexture* onGenerateTexture(GrContext*, const GrTextureParams&, const SkIRect*) override;
 #endif
 
 private:
@@ -88,7 +88,7 @@
 #if SK_SUPPORT_GPU
 #include "GrTexture.h"
 
-GrTexture* SkPictureImageGenerator::onGenerateTexture(GrContext* ctx, SkImageUsageType usage,
+GrTexture* SkPictureImageGenerator::onGenerateTexture(GrContext* ctx, const GrTextureParams&,
                                                       const SkIRect* subset) {
     const SkImageInfo& info = this->getInfo();
     SkImageInfo surfaceInfo = subset ? info.makeWH(subset->width(), subset->height()) : info;
diff --git a/src/effects/SkPerlinNoiseShader.cpp b/src/effects/SkPerlinNoiseShader.cpp
index 86463f6..481d160 100644
--- a/src/effects/SkPerlinNoiseShader.cpp
+++ b/src/effects/SkPerlinNoiseShader.cpp
@@ -943,9 +943,11 @@
     SkPerlinNoiseShader::PaintingData* paintingData =
             new PaintingData(fTileSize, fSeed, fBaseFrequencyX, fBaseFrequencyY, matrix);
     SkAutoTUnref<GrTexture> permutationsTexture(
-        GrRefCachedBitmapTexture(context, paintingData->getPermutationsBitmap(), nullptr));
+        GrRefCachedBitmapTexture(context, paintingData->getPermutationsBitmap(),
+                                 GrTextureParams::ClampNoFilter()));
     SkAutoTUnref<GrTexture> noiseTexture(
-        GrRefCachedBitmapTexture(context, paintingData->getNoiseBitmap(), nullptr));
+        GrRefCachedBitmapTexture(context, paintingData->getNoiseBitmap(),
+                                 GrTextureParams::ClampNoFilter()));
 
     SkMatrix m = viewM;
     m.setTranslateX(-localMatrix.getTranslateX() + SK_Scalar1);
diff --git a/src/effects/SkTableColorFilter.cpp b/src/effects/SkTableColorFilter.cpp
index f0ed7b4..8f1a4d7 100644
--- a/src/effects/SkTableColorFilter.cpp
+++ b/src/effects/SkTableColorFilter.cpp
@@ -475,8 +475,7 @@
     SkAutoTUnref<GrTexture> texture;
     if (-1 == row) {
         atlas = nullptr;
-        // Passing params=nullptr because this effect does no tiling or filtering.
-        texture.reset(GrRefCachedBitmapTexture(context, bitmap, nullptr));
+        texture.reset(GrRefCachedBitmapTexture(context, bitmap, GrTextureParams::ClampNoFilter()));
     } else {
         texture.reset(SkRef(atlas->getTexture()));
     }
diff --git a/src/effects/gradients/SkGradientShader.cpp b/src/effects/gradients/SkGradientShader.cpp
index 88d650c..a96e09d 100644
--- a/src/effects/gradients/SkGradientShader.cpp
+++ b/src/effects/gradients/SkGradientShader.cpp
@@ -1132,7 +1132,7 @@
             fCoordTransform.reset(kCoordSet, matrix, fAtlas->getTexture(), params.filterMode());
             fTextureAccess.reset(fAtlas->getTexture(), params);
         } else {
-            SkAutoTUnref<GrTexture> texture(GrRefCachedBitmapTexture(ctx, bitmap, &params));
+            SkAutoTUnref<GrTexture> texture(GrRefCachedBitmapTexture(ctx, bitmap, params));
             if (!texture) {
                 return;
             }
diff --git a/src/gpu/GrTextureMaker.h b/src/gpu/GrTextureMaker.h
index 1cbf63a..47141bd 100644
--- a/src/gpu/GrTextureMaker.h
+++ b/src/gpu/GrTextureMaker.h
@@ -24,8 +24,7 @@
     int width() const { return fWidth; }
     int height() const { return fHeight; }
 
-    GrTexture* refCachedTexture(GrContext*, SkImageUsageType);
-    GrTexture* refCachedTexture(GrContext*, const GrTextureParams*);
+    GrTexture* refCachedTexture(GrContext*, const GrTextureParams&);
 
 protected:
     /**
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 9d129d5..4d15059 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -90,7 +90,7 @@
 
     AutoBitmapTexture(GrContext* context,
                       const SkBitmap& bitmap,
-                      const GrTextureParams* params,
+                      const GrTextureParams& params,
                       GrTexture** texture) {
         SkASSERT(texture);
         *texture = this->set(context, bitmap, params);
@@ -98,7 +98,7 @@
 
     GrTexture* set(GrContext* context,
                    const SkBitmap& bitmap,
-                   const GrTextureParams* params) {
+                   const GrTextureParams& params) {
         // Either get the texture directly from the bitmap, or else use the cache and
         // remember to unref it.
         if (GrTexture* bmpTexture = bitmap.getTexture()) {
@@ -765,7 +765,7 @@
     }
 
     // if the entire image/bitmap is already in our cache then no reason to tile it
-    if (GrIsImageInCache(fContext, imageID, imageRect, nullptr, &params)) {
+    if (GrIsImageInCache(fContext, imageID, imageRect, nullptr, params)) {
         return false;
     }
 
@@ -983,7 +983,7 @@
 
     // Setup texture to wrap bitmap
     GrTextureParams params(tm, textureFilterMode);
-    SkAutoTUnref<GrTexture> texture(GrRefCachedBitmapTexture(context, *bitmapPtr, &params));
+    SkAutoTUnref<GrTexture> texture(GrRefCachedBitmapTexture(context, *bitmapPtr, params));
 
     if (!texture) {
         SkErrorInternals::SetError(kInternalError_SkError,
@@ -1288,7 +1288,7 @@
              bitmap.height() <= fContext->caps()->maxTextureSize());
 
     GrTexture* texture;
-    AutoBitmapTexture abt(fContext, bitmap, &params, &texture);
+    AutoBitmapTexture abt(fContext, bitmap, params, &texture);
     if (nullptr == texture) {
         return;
     }
@@ -1419,8 +1419,8 @@
     int h = bitmap.height();
 
     GrTexture* texture;
-    // draw sprite uses the default texture params
-    AutoBitmapTexture abt(fContext, bitmap, nullptr, &texture);
+    // draw sprite neither filters nor tiles.
+    AutoBitmapTexture abt(fContext, bitmap, GrTextureParams::ClampNoFilter(), &texture);
     if (!texture) {
         return;
     }
@@ -1621,7 +1621,7 @@
     GrTexture* texture;
     // We assume here that the filter will not attempt to tile the src. Otherwise, this cache lookup
     // must be pushed upstack.
-    AutoBitmapTexture abt(fContext, src, nullptr, &texture);
+    AutoBitmapTexture abt(fContext, src, GrTextureParams::ClampNoFilter(), &texture);
     if (!texture) {
         return false;
     }
@@ -1631,7 +1631,8 @@
 }
 
 static bool wrap_as_bm(GrContext* ctx, const SkImage* image, SkBitmap* bm) {
-    SkAutoTUnref<GrTexture> tex(as_IB(image)->asTextureRef(ctx, kUntiled_SkImageUsageType));
+    // TODO: It is wrong to assume these texture params here.
+    SkAutoTUnref<GrTexture> tex(as_IB(image)->asTextureRef(ctx, GrTextureParams::ClampNoFilter()));
     if (tex) {
         GrWrapTextureInBitmap(tex, image->width(), image->height(), image->isOpaque(), bm);
         return true;
diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp
index 8f9555a..ce4af0b 100644
--- a/src/gpu/SkGr.cpp
+++ b/src/gpu/SkGr.cpp
@@ -38,33 +38,6 @@
 #  include "etc1.h"
 #endif
 
-bool GrTextureUsageSupported(const GrCaps& caps, int width, int height, SkImageUsageType usage) {
-    if (caps.npotTextureTileSupport()) {
-        return true;
-    }
-    const bool is_pow2 = SkIsPow2(width) && SkIsPow2(height);
-    return is_pow2 || kUntiled_SkImageUsageType == usage;
-}
-
-GrTextureParams GrImageUsageToTextureParams(SkImageUsageType usage) {
-    // Just need a params that will trigger the correct cache key / etc, since the usage doesn't
-    // tell us the specifics about filter level or specific tiling.
-
-    const SkShader::TileMode tiles[] = {
-        SkShader::kClamp_TileMode,      // kUntiled_SkImageUsageType
-        SkShader::kRepeat_TileMode,     // kTiled_Unfiltered_SkImageUsageType
-        SkShader::kRepeat_TileMode,     // kTiled_Filtered_SkImageUsageType
-    };
-
-    const GrTextureParams::FilterMode filters[] = {
-        GrTextureParams::kNone_FilterMode,      // kUntiled_SkImageUsageType
-        GrTextureParams::kNone_FilterMode,      // kTiled_Unfiltered_SkImageUsageType
-        GrTextureParams::kBilerp_FilterMode,    // kTiled_Filtered_SkImageUsageType
-    };
-
-    return GrTextureParams(tiles[usage], filters[usage]);
-}
-
 /*  Fill out buffer with the compressed format Ganesh expects from a colortable
  based bitmap. [palette (colortable) + indices].
 
@@ -124,35 +97,31 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 
-static void get_stretch(const GrContext* ctx, int width, int height,
-                        const GrTextureParams* params, SkGrStretch* stretch) {
+static void get_stretch(const GrCaps& caps, int width, int height,
+                        const GrTextureParams& params, SkGrStretch* stretch) {
     stretch->fType = SkGrStretch::kNone_Type;
     bool doStretch = false;
-    if (params && params->isTiled() && !ctx->caps()->npotTextureTileSupport() &&
+    if (params.isTiled() && !caps.npotTextureTileSupport() &&
         (!SkIsPow2(width) || !SkIsPow2(height))) {
         doStretch = true;
-        stretch->fWidth  = GrNextPow2(SkTMax(width, ctx->caps()->minTextureSize()));
-        stretch->fHeight = GrNextPow2(SkTMax(height, ctx->caps()->minTextureSize()));
-    } else if (width < ctx->caps()->minTextureSize() || height < ctx->caps()->minTextureSize()) {
+        stretch->fWidth  = GrNextPow2(SkTMax(width, caps.minTextureSize()));
+        stretch->fHeight = GrNextPow2(SkTMax(height, caps.minTextureSize()));
+    } else if (width < caps.minTextureSize() || height < caps.minTextureSize()) {
         // The small texture issues appear to be with tiling. Hence it seems ok to scale them
         // up using the GPU. If issues persist we may need to CPU-stretch.
         doStretch = true;
-        stretch->fWidth = SkTMax(width, ctx->caps()->minTextureSize());
-        stretch->fHeight = SkTMax(height, ctx->caps()->minTextureSize());
+        stretch->fWidth = SkTMax(width, caps.minTextureSize());
+        stretch->fHeight = SkTMax(height, caps.minTextureSize());
     }
     if (doStretch) {
-        if (params) {
-            switch(params->filterMode()) {
-                case GrTextureParams::kNone_FilterMode:
-                    stretch->fType = SkGrStretch::kNearest_Type;
-                    break;
-                case GrTextureParams::kBilerp_FilterMode:
-                case GrTextureParams::kMipMap_FilterMode:
-                    stretch->fType = SkGrStretch::kBilerp_Type;
-                    break;
-            }
-        } else {
-            stretch->fType = SkGrStretch::kBilerp_Type;
+        switch(params.filterMode()) {
+            case GrTextureParams::kNone_FilterMode:
+                stretch->fType = SkGrStretch::kNearest_Type;
+                break;
+            case GrTextureParams::kBilerp_FilterMode:
+            case GrTextureParams::kMipMap_FilterMode:
+                stretch->fType = SkGrStretch::kBilerp_Type;
+                break;
         }
     } else {
         stretch->fWidth  = -1;
@@ -190,26 +159,16 @@
 }
 
 void GrMakeKeyFromImageID(GrUniqueKey* key, uint32_t imageID, const SkIRect& subset,
-                          const GrCaps& caps, SkImageUsageType usage) {
-    const SkGrStretch::Type stretches[] = {
-        SkGrStretch::kNone_Type,        // kUntiled_SkImageUsageType
-        SkGrStretch::kNearest_Type,     // kTiled_Unfiltered_SkImageUsageType
-        SkGrStretch::kBilerp_Type,      // kTiled_Filtered_SkImageUsageType
-    };
-
-    if (!GrTextureUsageSupported(caps, subset.width(), subset.height(), usage)) {
+                          const GrCaps& caps, const GrTextureParams& params) {
+    SkGrStretch stretch;
+    get_stretch(caps, subset.width(), subset.height(), params, &stretch);
+    if (SkGrStretch::kNone_Type != stretch.fType) {
         GrUniqueKey tmpKey;
         make_unstretched_key(&tmpKey, imageID, subset);
-
-        SkGrStretch stretch;
-        stretch.fType = stretches[usage];
-        stretch.fWidth = SkNextPow2(subset.width());
-        stretch.fHeight = SkNextPow2(subset.height());
         if (!GrMakeStretchedKey(tmpKey, stretch, key)) {
-            goto UNSTRETCHED;
+            *key = tmpKey;
         }
     } else {
-        UNSTRETCHED:
         make_unstretched_key(key, imageID, subset);
     }
 }
@@ -519,9 +478,9 @@
 }
 
 bool GrIsImageInCache(const GrContext* ctx, uint32_t imageID, const SkIRect& subset,
-                      GrTexture* nativeTexture, const GrTextureParams* params) {
+                      GrTexture* nativeTexture, const GrTextureParams& params) {
     SkGrStretch stretch;
-    get_stretch(ctx, subset.width(), subset.height(), params, &stretch);
+    get_stretch(*ctx->caps(), subset.width(), subset.height(), params, &stretch);
 
     // Handle the case where the bitmap/image is explicitly texture backed.
     if (nativeTexture) {
@@ -593,19 +552,10 @@
 };
 
 GrTexture* GrRefCachedBitmapTexture(GrContext* ctx, const SkBitmap& bitmap,
-                                    const GrTextureParams* params) {
+                                    const GrTextureParams& params) {
     return Bitmap_GrTextureMaker(bitmap).refCachedTexture(ctx, params);
 }
 
-// TODO: make this be the canonical signature, and turn the version that takes GrTextureParams*
-//       into a wrapper that contains the inverse of these tables.
-GrTexture* GrRefCachedBitmapTexture(GrContext* ctx,
-                                    const SkBitmap& bitmap,
-                                    SkImageUsageType usage) {
-    GrTextureParams params = GrImageUsageToTextureParams(usage);
-    return GrRefCachedBitmapTexture(ctx, bitmap, &params);
-}
-
 ///////////////////////////////////////////////////////////////////////////////
 
 // alphatype is ignore for now, but if GrPixelConfig is expanded to encompass
@@ -928,14 +878,9 @@
 
 ////////////////////////////////////////////////////////////////////////////////////////////////
 
-GrTexture* GrTextureMaker::refCachedTexture(GrContext* ctx, SkImageUsageType usage) {
-    GrTextureParams params = GrImageUsageToTextureParams(usage);
-    return this->refCachedTexture(ctx, &params);
-}
-
-GrTexture* GrTextureMaker::refCachedTexture(GrContext* ctx, const GrTextureParams* params) {
+GrTexture* GrTextureMaker::refCachedTexture(GrContext* ctx, const GrTextureParams& params) {
     SkGrStretch stretch;
-    get_stretch(ctx, this->width(), this->height(), params, &stretch);
+    get_stretch(*ctx->caps(), this->width(), this->height(), params, &stretch);
 
     if (SkGrStretch::kNone_Type == stretch.fType) {
         return this->onRefUnstretchedTexture(ctx);
diff --git a/src/gpu/SkGrPriv.h b/src/gpu/SkGrPriv.h
index 88bee5c..6c9f731 100644
--- a/src/gpu/SkGrPriv.h
+++ b/src/gpu/SkGrPriv.h
@@ -10,8 +10,8 @@
 
 #include "GrTypes.h"
 #include "GrBlend.h"
-#include "GrTextureAccess.h"
 #include "SkImageInfo.h"
+#include "SkMatrix.h"
 #include "SkXfermode.h"
 
 class GrCaps;
@@ -19,9 +19,11 @@
 class GrFragmentProcessor;
 class GrPaint;
 class GrTexture;
+class GrTextureParams;
 class GrUniqueKey;
+class SkData;
 class SkPaint;
-class SkMatrix;
+class SkPixelRef;
 struct SkIRect;
 
 struct SkGrStretch {
@@ -34,8 +36,6 @@
     int fHeight;
 };
 
-GrTextureParams GrImageUsageToTextureParams(SkImageUsageType);
-
 /**
  *  Our key includes the offset, width, and height so that bitmaps created by extractSubset()
  *  are unique.
@@ -48,7 +48,7 @@
  *  Note: width/height must fit in 16bits for this impl.
  */
 void GrMakeKeyFromImageID(GrUniqueKey* key, uint32_t imageID, const SkIRect& imageBounds,
-                          const GrCaps&, SkImageUsageType);
+                          const GrCaps&, const GrTextureParams&);
 
 /**
  *  Given an "unstretched" key, and a stretch rec, produce a stretched key.
@@ -98,8 +98,6 @@
 
 //////////////////////////////////////////////////////////////////////////////
 
-bool GrTextureUsageSupported(const GrCaps&, int width, int height, SkImageUsageType);
-
 GrSurfaceDesc GrImageInfoToSurfaceDesc(const SkImageInfo&);
 
 bool GrPixelConfig2ColorAndProfileType(GrPixelConfig, SkColorType*, SkColorProfileType*);
@@ -117,7 +115,7 @@
                                                  const void** outStartOfDataToUpload);
 
 bool GrIsImageInCache(const GrContext* ctx, uint32_t imageID, const SkIRect& subset,
-                      GrTexture* nativeTexture, const GrTextureParams*);
+                      GrTexture* nativeTexture, const GrTextureParams&);
 
 GrTexture* GrCreateTextureForPixels(GrContext*, const GrUniqueKey& optionalKey, GrSurfaceDesc,
                                     SkPixelRef* pixelRefForInvalidationNotificationOrNull,
diff --git a/src/image/SkImageShader.cpp b/src/image/SkImageShader.cpp
index cf613e8..56af179 100644
--- a/src/image/SkImageShader.cpp
+++ b/src/image/SkImageShader.cpp
@@ -113,17 +113,7 @@
     GrTextureParams::FilterMode textureFilterMode =
     GrSkFilterQualityToGrFilterMode(filterQuality, viewM, this->getLocalMatrix(), &doBicubic);
     GrTextureParams params(tm, textureFilterMode);
-
-    SkImageUsageType usageType;
-    if (kClamp_TileMode == fTileModeX && kClamp_TileMode == fTileModeY) {
-        usageType = kUntiled_SkImageUsageType;
-    } else if (GrTextureParams::kNone_FilterMode == textureFilterMode) {
-        usageType = kTiled_Unfiltered_SkImageUsageType;
-    } else {
-        usageType = kTiled_Filtered_SkImageUsageType;
-    }
-
-    SkAutoTUnref<GrTexture> texture(as_IB(fImage)->asTextureRef(context, usageType));
+    SkAutoTUnref<GrTexture> texture(as_IB(fImage)->asTextureRef(context, params));
     if (!texture) {
         return nullptr;
     }
diff --git a/src/image/SkImage_Base.h b/src/image/SkImage_Base.h
index 20df0bc..7819e9c 100644
--- a/src/image/SkImage_Base.h
+++ b/src/image/SkImage_Base.h
@@ -14,6 +14,8 @@
 
 #include <new>
 
+class GrTextureParams;
+
 enum {
     kNeedNewImageUniqueID = 0
 };
@@ -36,7 +38,7 @@
     virtual bool getROPixels(SkBitmap*) const = 0;
 
     // Caller must call unref when they are done.
-    virtual GrTexture* asTextureRef(GrContext*, SkImageUsageType) const = 0;
+    virtual GrTexture* asTextureRef(GrContext*, const GrTextureParams&) const = 0;
 
     virtual SkImage* onNewSubset(const SkIRect&) const = 0;
 
diff --git a/src/image/SkImage_Generator.cpp b/src/image/SkImage_Generator.cpp
index 5ce552c..3465289 100644
--- a/src/image/SkImage_Generator.cpp
+++ b/src/image/SkImage_Generator.cpp
@@ -27,7 +27,7 @@
     bool isOpaque() const override { return fCache->info().isOpaque(); }
     SkImage* onNewSubset(const SkIRect&) const override;
     bool getROPixels(SkBitmap*) const override;
-    GrTexture* asTextureRef(GrContext*, SkImageUsageType) const override;
+    GrTexture* asTextureRef(GrContext*, const GrTextureParams&) const override;
     bool onIsLazyGenerated() const override { return true; }
 
 private:
@@ -59,8 +59,8 @@
     return fCache->lockAsBitmap(bitmap, this);
 }
 
-GrTexture* SkImage_Generator::asTextureRef(GrContext* ctx, SkImageUsageType usage) const {
-    return fCache->lockAsTexture(ctx, usage, this);
+GrTexture* SkImage_Generator::asTextureRef(GrContext* ctx, const GrTextureParams& params) const {
+    return fCache->lockAsTexture(ctx, params, this);
 }
 
 SkImage* SkImage_Generator::onNewSubset(const SkIRect& subset) const {
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp
index 72b98cd..ccb27ee 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -109,8 +109,8 @@
     typedef GrTextureMaker INHERITED;
 };
 
-GrTexture* SkImage_Gpu::asTextureRef(GrContext* ctx, SkImageUsageType usage) const {
-    return Texture_GrTextureMaker(this, fTexture).refCachedTexture(ctx, usage);
+GrTexture* SkImage_Gpu::asTextureRef(GrContext* ctx, const GrTextureParams& params) const {
+    return Texture_GrTextureMaker(this, fTexture).refCachedTexture(ctx, params);
 }
 
 bool SkImage_Gpu::isOpaque() const {
diff --git a/src/image/SkImage_Gpu.h b/src/image/SkImage_Gpu.h
index 8bfdfa7..530c044 100644
--- a/src/image/SkImage_Gpu.h
+++ b/src/image/SkImage_Gpu.h
@@ -36,7 +36,7 @@
     }
 
     bool getROPixels(SkBitmap*) const override;
-    GrTexture* asTextureRef(GrContext* ctx, SkImageUsageType usage) const override;
+    GrTexture* asTextureRef(GrContext* ctx, const GrTextureParams& params) const override;
     SkImage* onNewSubset(const SkIRect&) const override;
 
     GrTexture* peekTexture() const override { return fTexture; }
diff --git a/src/image/SkImage_Raster.cpp b/src/image/SkImage_Raster.cpp
index b6c62e8..b78818d 100644
--- a/src/image/SkImage_Raster.cpp
+++ b/src/image/SkImage_Raster.cpp
@@ -70,7 +70,7 @@
     const void* onPeekPixels(SkImageInfo*, size_t* /*rowBytes*/) const override;
     SkData* onRefEncoded() const override;
     bool getROPixels(SkBitmap*) const override;
-    GrTexture* asTextureRef(GrContext*, SkImageUsageType) const override;
+    GrTexture* asTextureRef(GrContext*, const GrTextureParams&) const override;
     SkImage* onNewSubset(const SkIRect&) const override;
 
     // exposed for SkSurface_Raster via SkNewImageFromPixelRef
@@ -167,7 +167,7 @@
     return true;
 }
 
-GrTexture* SkImage_Raster::asTextureRef(GrContext* ctx, SkImageUsageType usage) const {
+GrTexture* SkImage_Raster::asTextureRef(GrContext* ctx, const GrTextureParams& params) const {
 #if SK_SUPPORT_GPU
     if (!ctx) {
         return nullptr;
@@ -182,12 +182,12 @@
     GrUniqueKey key;
     GrMakeKeyFromImageID(&key, fBitmap.getGenerationID(),
                          SkIRect::MakeWH(fBitmap.width(), fBitmap.height()),
-                         *ctx->caps(), usage);
+                         *ctx->caps(), params);
 
     if (GrTexture* tex = ctx->textureProvider()->findAndRefTextureByUniqueKey(key)) {
         return tex;
     }
-    return GrRefCachedBitmapTexture(ctx, fBitmap, usage);
+    return GrRefCachedBitmapTexture(ctx, fBitmap, params);
 #endif
     
     return nullptr;
diff --git a/src/utils/SkImageGeneratorUtils.cpp b/src/utils/SkImageGeneratorUtils.cpp
index 42a0fe5..8202dbe 100644
--- a/src/utils/SkImageGeneratorUtils.cpp
+++ b/src/utils/SkImageGeneratorUtils.cpp
@@ -56,7 +56,8 @@
     {}
 
 protected:
-    GrTexture* onGenerateTexture(GrContext* ctx, SkImageUsageType, const SkIRect* subset) override {
+    GrTexture* onGenerateTexture(GrContext* ctx, const GrTextureParams&,
+                                 const SkIRect* subset) override {
         if (ctx) {
             SkASSERT(ctx == fCtx.get());
         }
@@ -112,7 +113,8 @@
         return fImage->readPixels(info, pixels, rowBytes, 0, 0);
     }
 
-    GrTexture* onGenerateTexture(GrContext* ctx, SkImageUsageType, const SkIRect* subset) override {
+    GrTexture* onGenerateTexture(GrContext* ctx, const GrTextureParams&,
+                                 const SkIRect* subset) override {
         // waiting on https://code.google.com/p/skia/issues/detail?id=4233
         return nullptr;
     }