Reland "Add support for Ycbcr Conversion Samplers in vulkan."

This is a reland of 6cd74900dab22d2b616cbbeb97bef9608819beee

Original change's description:
> Add support for Ycbcr Conversion Samplers in vulkan.
> 
> The only thing missing from this CL is that we need to bake the
> ycbcr conversion samplers into the VkPipeline when we create it. As that
> is a larger change, that will be broken up into a few follow on CLs.
> 
> Currently this only supports ycbcr conversion samplers when used with
> external textures.
> 
> Bug: skia:
> Change-Id: I23e95b19469093072589ebbbfb7926ab79dcdea9
> Reviewed-on: https://skia-review.googlesource.com/c/164602
> Reviewed-by: Brian Salomon <bsalomon@google.com>
> Reviewed-by: Jim Van Verth <jvanverth@google.com>
> Commit-Queue: Greg Daniel <egdaniel@google.com>

Bug: skia:
Change-Id: I943398077775ef6396fbe5cb9196d23a29128669
Reviewed-on: https://skia-review.googlesource.com/c/173986
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
diff --git a/src/gpu/vk/GrVkImageView.cpp b/src/gpu/vk/GrVkImageView.cpp
index b737df5..342ce46 100644
--- a/src/gpu/vk/GrVkImageView.cpp
+++ b/src/gpu/vk/GrVkImageView.cpp
@@ -7,16 +7,37 @@
 
 #include "GrVkImageView.h"
 #include "GrVkGpu.h"
+#include "GrVkSamplerYcbcrConversion.h"
 #include "GrVkUtil.h"
 
-const GrVkImageView* GrVkImageView::Create(const GrVkGpu* gpu, VkImage image, VkFormat format,
-                                           Type viewType, uint32_t miplevels) {
-    VkImageView imageView;
+const GrVkImageView* GrVkImageView::Create(GrVkGpu* gpu, VkImage image, VkFormat format,
+                                           Type viewType, uint32_t miplevels,
+                                           const GrVkYcbcrConversionInfo& ycbcrInfo) {
 
+    void* pNext = nullptr;
+    VkSamplerYcbcrConversionInfo conversionInfo;
+    GrVkSamplerYcbcrConversion* ycbcrConversion = nullptr;
+
+    if (ycbcrInfo.isValid()) {
+        SkASSERT(gpu->vkCaps().supportsYcbcrConversion() && format == VK_FORMAT_UNDEFINED);
+
+        ycbcrConversion =
+                gpu->resourceProvider().findOrCreateCompatibleSamplerYcbcrConversion(ycbcrInfo);
+        if (!ycbcrConversion) {
+            return nullptr;
+        }
+
+        conversionInfo.sType = VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_INFO;
+        conversionInfo.pNext = nullptr;
+        conversionInfo.conversion = ycbcrConversion->ycbcrConversion();
+        pNext = &conversionInfo;
+    }
+
+    VkImageView imageView;
     // Create the VkImageView
     VkImageViewCreateInfo viewInfo = {
         VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,               // sType
-        NULL,                                                   // pNext
+        pNext,                                                  // pNext
         0,                                                      // flags
         image,                                                  // image
         VK_IMAGE_VIEW_TYPE_2D,                                  // viewType
@@ -37,9 +58,20 @@
         return nullptr;
     }
 
-    return new GrVkImageView(imageView);
+    return new GrVkImageView(imageView, ycbcrConversion);
 }
 
 void GrVkImageView::freeGPUData(const GrVkGpu* gpu) const {
     GR_VK_CALL(gpu->vkInterface(), DestroyImageView(gpu->device(), fImageView, nullptr));
+
+    if (fYcbcrConversion) {
+        fYcbcrConversion->unref(gpu);
+    }
 }
+
+void GrVkImageView::abandonGPUData() const {
+    if (fYcbcrConversion) {
+        fYcbcrConversion->unrefAndAbandon();
+    }
+}
+