Add flag to force purge resources from cache as soon as possible.

Bug: skia:
Change-Id: Ibd636b9e1bf932033c3161c862523f841cb85e79
Reviewed-on: https://skia-review.googlesource.com/c/171005
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
diff --git a/src/gpu/mtl/GrMtlTexture.mm b/src/gpu/mtl/GrMtlTexture.mm
index 7dd6f59..5825ed6 100644
--- a/src/gpu/mtl/GrMtlTexture.mm
+++ b/src/gpu/mtl/GrMtlTexture.mm
@@ -27,12 +27,13 @@
                            Wrapped,
                            const GrSurfaceDesc& desc,
                            id<MTLTexture> texture,
-                           GrMipMapsStatus mipMapsStatus)
+                           GrMipMapsStatus mipMapsStatus,
+                           bool purgeImmediately)
         : GrSurface(gpu, desc)
         , INHERITED(gpu, desc, GrTextureType::k2D, mipMapsStatus)
         , fTexture(texture) {
     SkASSERT((GrMipMapsStatus::kNotAllocated == mipMapsStatus) == (1 == texture.mipmapLevelCount));
-    this->registerWithCacheWrapped();
+    this->registerWithCacheWrapped(purgeImmediately);
 }
 
 GrMtlTexture::GrMtlTexture(GrMtlGpu* gpu,
@@ -61,7 +62,8 @@
 
 sk_sp<GrMtlTexture> GrMtlTexture::MakeWrappedTexture(GrMtlGpu* gpu,
                                                      const GrSurfaceDesc& desc,
-                                                     id<MTLTexture> texture) {
+                                                     id<MTLTexture> texture,
+                                                     bool purgeImmediately) {
     if (desc.fSampleCnt > 1) {
         SkASSERT(false); // Currently we don't support msaa
         return nullptr;
@@ -70,7 +72,8 @@
     SkASSERT(MTLTextureUsageShaderRead & texture.usage);
     GrMipMapsStatus mipMapsStatus = texture.mipmapLevelCount > 1 ? GrMipMapsStatus::kValid
                                                                  : GrMipMapsStatus::kNotAllocated;
-    return sk_sp<GrMtlTexture>(new GrMtlTexture(gpu, kWrapped, desc, texture, mipMapsStatus));
+    return sk_sp<GrMtlTexture>(new GrMtlTexture(gpu, kWrapped, desc, texture, mipMapsStatus,
+                                                purgeImmediately));
 }
 
 GrMtlTexture::~GrMtlTexture() {