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/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;
}