In Vk DeferredLayerUpdater make sure we releause buffers to foreign queue.

For Vulkan we need to make sure that when we draw AHBs we must
transition them to and from the foreign queue so that the producer is
able to write new data to them and we are able to see the new writes.

Test: Manual running of Lens app
Bug: 178773035
Change-Id: I807709d2b671bf5a01a82237f3b5838734f0d978
diff --git a/libs/hwui/AutoBackendTextureRelease.cpp b/libs/hwui/AutoBackendTextureRelease.cpp
index 33264d5..ef5eacb 100644
--- a/libs/hwui/AutoBackendTextureRelease.cpp
+++ b/libs/hwui/AutoBackendTextureRelease.cpp
@@ -89,5 +89,27 @@
     }
 }
 
+void AutoBackendTextureRelease::releaseQueueOwnership(GrDirectContext* context) {
+    if (!context) {
+        return;
+    }
+
+    LOG_ALWAYS_FATAL_IF(Properties::getRenderPipelineType() != RenderPipelineType::SkiaVulkan);
+    if (mBackendTexture.isValid()) {
+        // Passing in VK_IMAGE_LAYOUT_UNDEFINED means we keep the old layout.
+        GrBackendSurfaceMutableState newState(VK_IMAGE_LAYOUT_UNDEFINED,
+                                              VK_QUEUE_FAMILY_FOREIGN_EXT);
+
+        // The unref for this ref happens in the releaseProc passed into setBackendTextureState. The
+        // releaseProc callback will be made when the work to set the new state has finished on the
+        // gpu.
+        ref();
+        // Note that we don't have an explicit call to set the backend texture back onto the
+        // graphics queue when we use the VkImage again. Internally, Skia will notice that the image
+        // is not on the graphics queue and will do the transition automatically.
+        context->setBackendTextureState(mBackendTexture, newState, nullptr, releaseProc, this);
+    }
+}
+
 } /* namespace uirenderer */
 } /* namespace android */