Enable creating protected vulkan backend

This CL allows user to indicate that they have a protected content in
GrVkBackendContext creation which results in protected CommandPool and Queue
usage.

Bug: skia:9016
Change-Id: I6a478d688b6988c2c5e5e98f18f58fb21f9d26ae
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/210067
Commit-Queue: Greg Daniel <egdaniel@google.com>
Auto-Submit: Emircan Uysaler <emircan@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
diff --git a/src/gpu/vk/GrVkCommandPool.cpp b/src/gpu/vk/GrVkCommandPool.cpp
index 22d0fbf..aae9355 100644
--- a/src/gpu/vk/GrVkCommandPool.cpp
+++ b/src/gpu/vk/GrVkCommandPool.cpp
@@ -12,17 +12,24 @@
 #include "src/gpu/vk/GrVkGpu.h"
 
 GrVkCommandPool* GrVkCommandPool::Create(const GrVkGpu* gpu) {
-    const VkCommandPoolCreateInfo cmdPoolInfo = {
-        VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO,      // sType
-        nullptr,                                         // pNext
-        VK_COMMAND_POOL_CREATE_TRANSIENT_BIT |
-        VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT, // CmdPoolCreateFlags
-        gpu->queueIndex(),                              // queueFamilyIndex
-    };
-    VkCommandPool pool;
-    GR_VK_CALL_ERRCHECK(gpu->vkInterface(), CreateCommandPool(gpu->device(), &cmdPoolInfo,
-                                                               nullptr, &pool));
-    return new GrVkCommandPool(gpu, pool);
+  VkCommandPoolCreateFlags cmdPoolCreateFlags =
+      VK_COMMAND_POOL_CREATE_TRANSIENT_BIT |
+      VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT;
+  if (gpu->protectedContext()) {
+      cmdPoolCreateFlags |= VK_COMMAND_POOL_CREATE_PROTECTED_BIT;
+  }
+
+  const VkCommandPoolCreateInfo cmdPoolInfo = {
+      VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO,  // sType
+      nullptr,                                     // pNext
+      cmdPoolCreateFlags,                          // CmdPoolCreateFlags
+      gpu->queueIndex(),                           // queueFamilyIndex
+  };
+  VkCommandPool pool;
+  GR_VK_CALL_ERRCHECK(
+      gpu->vkInterface(),
+      CreateCommandPool(gpu->device(), &cmdPoolInfo, nullptr, &pool));
+  return new GrVkCommandPool(gpu, pool);
 }
 
 GrVkCommandPool::GrVkCommandPool(const GrVkGpu* gpu, VkCommandPool commandPool)