Skip to content

Commit

Permalink
Update skia vulkan usages to use getBackendRenderTarget. (flutter#4982)
Browse files Browse the repository at this point in the history
* Update vulkan_swampchain.cc to use getBackendRenderTarget.

The use of getRenderTargetHandle on SkSurface is being removed so switch over to the new API of getBackendRenderTarget.

* Update vulkan_swapchain.cc

* Update vulkan_surface_producer.cc
  • Loading branch information
egdaniel authored and brianosman committed Apr 12, 2018
1 parent c83d1ef commit 69d9590
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
15 changes: 10 additions & 5 deletions content_handler/vulkan_surface_producer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -149,17 +149,22 @@ bool VulkanSurfaceProducer::TransitionSurfacesToExternal(
if (!command_buffer->Begin())
return false;

GrVkImageInfo* imageInfo;
vk_surface->GetSkiaSurface()->getRenderTargetHandle(
reinterpret_cast<GrBackendObject*>(&imageInfo),
GrBackendRenderTarget backendRT = vk_surface->GetSkiaSurface()->getBackendRenderTarget(
SkSurface::kFlushRead_BackendHandleAccess);
if (!backendRT.isValid()) {
return false;
}
GrVkImageInfo imageInfo;
if(!backendRT.getVkImageInfo(&imageInfo)) {
return false;
}

VkImageMemoryBarrier image_barrier = {
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,
.pNext = nullptr,
.srcAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
.dstAccessMask = 0,
.oldLayout = imageInfo->fImageLayout,
.oldLayout = imageInfo.fImageLayout,
.newLayout = VK_IMAGE_LAYOUT_GENERAL,
.srcQueueFamilyIndex = 0,
.dstQueueFamilyIndex = VK_QUEUE_FAMILY_EXTERNAL_KHR,
Expand All @@ -175,7 +180,7 @@ bool VulkanSurfaceProducer::TransitionSurfacesToExternal(
1, &image_barrier))
return false;

imageInfo->updateImageLayout(image_barrier.newLayout);
backendRT.setVkImageLayout(image_barrier.newLayout);

if (!command_buffer->End())
return false;
Expand Down
13 changes: 6 additions & 7 deletions vulkan/vulkan_swapchain.cc
Original file line number Diff line number Diff line change
Expand Up @@ -460,16 +460,15 @@ VulkanSwapchain::AcquireResult VulkanSwapchain::AcquireSurface() {
FXL_DLOG(INFO) << "Could not access surface at the image index.";
return error;
}

GrVkImageInfo* image_info = nullptr;
if (!surface->getRenderTargetHandle(
reinterpret_cast<GrBackendObject*>(&image_info),
SkSurface::kFlushRead_BackendHandleAccess)) {
FXL_DLOG(INFO) << "Could not get render target handle.";

GrBackendRenderTarget backendRT = surface->getBackendRenderTarget(
SkSurface::kFlushRead_BackendHandleAccess);
if (!backendRT.isValid()) {
FXL_DLOG(INFO) << "Could not get backend render target.";
return error;
}
backendRT.setVkImageLayout(destination_image_layout);

image_info->updateImageLayout(destination_image_layout);
current_image_index_ = next_image_index;

return {AcquireStatus::Success, surface};
Expand Down

0 comments on commit 69d9590

Please sign in to comment.