Add SkBudgeted parameter to SkImage::makeTextureImage().

Also strengthens/adds some guarantees about this function:
* Always returns the same image if the original is texture-backed and
compatible with GrMipMapped (WRT HW MIP support)
* If a new texture backed image is returned it is always an uncached
texture that is not shared with another image or owned by an image
generator.

Adds a GrImageTexGenPolicy that allows control through image/bitmap
GrTextureProducers of whether a new texture must be made and whether
that texture should be budgeted or not.

Increases unit test coverage of this API.

Bug: skia:8669

Change-Id: Ifc0681856114a08fc8cfc57ca83d22efb1c1f166
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/274938
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/SkGpuDevice_drawTexture.cpp b/src/gpu/SkGpuDevice_drawTexture.cpp
index 4f86c19..0b880e3 100644
--- a/src/gpu/SkGpuDevice_drawTexture.cpp
+++ b/src/gpu/SkGpuDevice_drawTexture.cpp
@@ -569,8 +569,7 @@
                 SkASSERT(tmpB.width() <= context->priv().caps()->maxTileSize() &&
                          tmpB.height() <= context->priv().caps()->maxTileSize());
 
-                GrBitmapTextureMaker tileProducer(context, tmpB, GrBitmapTextureMaker::Cached::kYes,
-                                                  SkBackingFit::kExact);
+                GrBitmapTextureMaker tileProducer(context, tmpB, GrImageTexGenPolicy::kDraw);
 
                 GrQuadAAFlags aaFlags = GrQuadAAFlags::kNone;
                 if (aa == GrAA::kYes) {
@@ -719,7 +718,7 @@
     // Lazily generated images must get drawn as a texture producer that handles the final
     // texture creation.
     if (image->isLazyGenerated()) {
-        GrImageTextureMaker maker(fContext.get(), image, SkImage::kAllow_CachingHint);
+        GrImageTextureMaker maker(fContext.get(), image, GrImageTexGenPolicy::kDraw);
         draw_texture_producer(fContext.get(), fRenderTargetContext.get(), clip, ctm, paint,
                               &maker, src, dst, dstClip, srcToDst, aa, aaFlags, constraint,
                               wrapMode, fm, doBicubic);
@@ -728,8 +727,7 @@
 
     SkBitmap bm;
     if (as_IB(image)->getROPixels(&bm)) {
-        GrBitmapTextureMaker maker(fContext.get(), bm, GrBitmapTextureMaker::Cached::kYes,
-                                   SkBackingFit::kExact);
+        GrBitmapTextureMaker maker(fContext.get(), bm, GrImageTexGenPolicy::kDraw);
         draw_texture_producer(fContext.get(), fRenderTargetContext.get(), clip, ctm, paint,
                               &maker, src, dst, dstClip, srcToDst, aa, aaFlags, constraint,
                               wrapMode, fm, doBicubic);