Fix borrowed GrVkImage::Resource.

With the current system, if we wrap a given GrVkTextureInfo*, add a
command using it to the command buffer, then delete the texture, the
command buffer will unref the GrVkImage::Resource when it's done, which
will delete the VkImage and VkDeviceMemory. This subclasses
GrVkImage::Resource for those cases, and will not delete the data on
an unref.
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1824123002

Review URL: https://codereview.chromium.org/1824123002
diff --git a/src/gpu/vk/GrVkImage.cpp b/src/gpu/vk/GrVkImage.cpp
index a61d934..729c627 100644
--- a/src/gpu/vk/GrVkImage.cpp
+++ b/src/gpu/vk/GrVkImage.cpp
@@ -113,3 +113,6 @@
     VK_CALL(gpu, DestroyImage(gpu->device(), fImage, nullptr));
     VK_CALL(gpu, FreeMemory(gpu->device(), fAlloc, nullptr));
 }
+
+void GrVkImage::BorrowedResource::freeGPUData(const GrVkGpu* gpu) const {
+}
diff --git a/src/gpu/vk/GrVkImage.h b/src/gpu/vk/GrVkImage.h
index eb0f7bf..fbf80f3 100644
--- a/src/gpu/vk/GrVkImage.h
+++ b/src/gpu/vk/GrVkImage.h
@@ -41,6 +41,14 @@
         typedef GrVkResource INHERITED;
     };
 
+    // for wrapped textures
+    class BorrowedResource : public Resource {
+    public:
+        BorrowedResource(VkImage image, VkDeviceMemory alloc, Flags flags)
+            : Resource(image, alloc, flags) {}
+    private:
+        void freeGPUData(const GrVkGpu* gpu) const override;
+    };
 
     GrVkImage(const Resource* imageResource) : fResource(imageResource) {
         if (imageResource->fFlags & Resource::kLinearTiling_Flag) {
diff --git a/src/gpu/vk/GrVkRenderTarget.cpp b/src/gpu/vk/GrVkRenderTarget.cpp
index 7ff7f26..c04cca3 100644
--- a/src/gpu/vk/GrVkRenderTarget.cpp
+++ b/src/gpu/vk/GrVkRenderTarget.cpp
@@ -214,9 +214,12 @@
     GrVkImage::Resource::Flags flags = (VK_IMAGE_TILING_LINEAR == info->fImageTiling) 
                                      ? Resource::kLinearTiling_Flag : Resource::kNo_Flags;
 
-    const GrVkImage::Resource* imageResource = new GrVkImage::Resource(info->fImage,
-                                                                       info->fAlloc,
-                                                                       flags);
+    const GrVkImage::Resource* imageResource;
+    if (kBorrowed_LifeCycle == lifeCycle) {
+        imageResource = new GrVkImage::BorrowedResource(info->fImage, info->fAlloc, flags);
+    } else {
+        imageResource = new GrVkImage::Resource(info->fImage, info->fAlloc, flags);
+    }
     if (!imageResource) {
         return nullptr;
     }
@@ -227,6 +230,7 @@
     }
     // Create() will increment the refCount of the image resource if it succeeds
     imageResource->unref(gpu);
+
     return rt;
 }
 
diff --git a/src/gpu/vk/GrVkTexture.cpp b/src/gpu/vk/GrVkTexture.cpp
index a6a89df..058dfbd 100644
--- a/src/gpu/vk/GrVkTexture.cpp
+++ b/src/gpu/vk/GrVkTexture.cpp
@@ -85,9 +85,12 @@
     GrVkImage::Resource::Flags flags = (VK_IMAGE_TILING_LINEAR == info->fImageTiling)
                                      ? Resource::kLinearTiling_Flag : Resource::kNo_Flags;
 
-    const GrVkImage::Resource* imageResource = new GrVkImage::Resource(info->fImage,
-                                                                       info->fAlloc,
-                                                                       flags);
+    const GrVkImage::Resource* imageResource;
+    if (kBorrowed_LifeCycle == lifeCycle) {
+        imageResource = new GrVkImage::BorrowedResource(info->fImage, info->fAlloc, flags);
+    } else {
+        imageResource = new GrVkImage::Resource(info->fImage, info->fAlloc, flags);
+    }
     if (!imageResource) {
         return nullptr;
     }
diff --git a/src/gpu/vk/GrVkTextureRenderTarget.cpp b/src/gpu/vk/GrVkTextureRenderTarget.cpp
index fa9327c..43e213f 100644
--- a/src/gpu/vk/GrVkTextureRenderTarget.cpp
+++ b/src/gpu/vk/GrVkTextureRenderTarget.cpp
@@ -150,9 +150,12 @@
     GrVkImage::Resource::Flags flags = (VK_IMAGE_TILING_LINEAR == info->fImageTiling)
                                      ? Resource::kLinearTiling_Flag : Resource::kNo_Flags;
 
-    const GrVkImage::Resource* imageResource = new GrVkImage::Resource(info->fImage,
-                                                                       info->fAlloc,
-                                                                       flags);
+    const GrVkImage::Resource* imageResource;
+    if (kBorrowed_LifeCycle == lifeCycle) {
+        imageResource = new GrVkImage::BorrowedResource(info->fImage, info->fAlloc, flags);
+    } else {
+        imageResource = new GrVkImage::Resource(info->fImage, info->fAlloc, flags);
+    }
     if (!imageResource) {
         return nullptr;
     }
@@ -166,6 +169,5 @@
     imageResource->unref(gpu);
 
     return trt;
-
 }