Add context option to disable mipmap support

This is desired for a short term memory improvement on low memory
devices.

Bug: chromium:1138979
Change-Id: I7df41a9c4d21b7a7f62b738e6358b36dd262f77d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/327345
Commit-Queue: Kyle Charbonneau <kylechar@chromium.org>
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt
index a019c11..f3f13e2 100644
--- a/RELEASE_NOTES.txt
+++ b/RELEASE_NOTES.txt
@@ -9,6 +9,9 @@
 
   * <insert new release notes here>
 
+  * Add field to GrContextOptions to disable mipmap support even if the backend
+    supports it.
+
   * SkTPin() removed from public API.
 
   * Add new SkImageFilters::Blend factory function, in place of the now deprecated
diff --git a/include/gpu/GrContextOptions.h b/include/gpu/GrContextOptions.h
index 2372cf1..474530a 100644
--- a/include/gpu/GrContextOptions.h
+++ b/include/gpu/GrContextOptions.h
@@ -236,6 +236,11 @@
      */
     int fMaxCachedVulkanSecondaryCommandBuffers = -1;
 
+    /**
+     * If true, the caps will never support mipmaps.
+     */
+    bool fSuppressMipmapSupport = false;
+
 #if GR_TEST_UTILS
     /**
      * Private options that are only meant for testing within Skia's tools.
diff --git a/src/gpu/GrCaps.cpp b/src/gpu/GrCaps.cpp
index c6fb6cb..2181858 100644
--- a/src/gpu/GrCaps.cpp
+++ b/src/gpu/GrCaps.cpp
@@ -152,6 +152,9 @@
         fShouldInitializeTextures = true;
     }
 #endif
+    if (options.fSuppressMipmapSupport) {
+        fMipmapSupport = false;
+    }
 
     if (fMaxWindowRectangles > GrWindowRectangles::kMaxWindows) {
         SkDebugf("WARNING: capping window rectangles at %i. HW advertises support for %i.\n",
@@ -442,4 +445,3 @@
     }
     return GrDstSampleType::kAsTextureCopy;
 }
-