Zero copy video path for webview.
1. This CL implements a zero copy path for video playback on
webview.
2. It is enabled only when AImageReader is supported.
3. Added a finch flag to roll out this feature via finch.
4. Currently it is implemented and enabled only for MCVD.
[email protected]
Bug: 1091945
Change-Id: I7b6a2cd71c0c82d0eaff08fbbac0cfa60ccfcd7a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2294347
Commit-Queue: vikas soni <[email protected]>
Reviewed-by: Frank Liberato <[email protected]>
Reviewed-by: Khushal <[email protected]>
Cr-Commit-Position: refs/heads/master@{#795870}
diff --git a/gpu/ipc/shared_image_interface_in_process.cc b/gpu/ipc/shared_image_interface_in_process.cc
index 2fb5642..5c9734a 100644
--- a/gpu/ipc/shared_image_interface_in_process.cc
+++ b/gpu/ipc/shared_image_interface_in_process.cc
@@ -308,6 +308,49 @@
sync_point_client_state_->ReleaseFenceSync(sync_token.release_count());
}
+#if defined(OS_ANDROID)
+Mailbox SharedImageInterfaceInProcess::CreateSharedImageWithAHB(
+ const Mailbox& in_mailbox,
+ uint32_t usage,
+ const SyncToken& sync_token) {
+ auto out_mailbox = Mailbox::GenerateForSharedImage();
+ {
+ base::AutoLock lock(lock_);
+ // Note: we enqueue the task under the lock to guarantee monotonicity of
+ // the release ids as seen by the service. Unretained is safe because
+ // SharedImageInterfaceInProcess synchronizes with the GPU thread at
+ // destruction time, cancelling tasks, before |this| is destroyed.
+ ScheduleGpuTask(
+ base::BindOnce(
+ &SharedImageInterfaceInProcess::CreateSharedImageWithAHBOnGpuThread,
+ base::Unretained(this), out_mailbox, in_mailbox, usage,
+ MakeSyncToken(next_fence_sync_release_++)),
+ {sync_token});
+ }
+ return out_mailbox;
+}
+
+void SharedImageInterfaceInProcess::CreateSharedImageWithAHBOnGpuThread(
+ const Mailbox& out_mailbox,
+ const Mailbox& in_mailbox,
+ uint32_t usage,
+ const SyncToken& sync_token) {
+ DCHECK_CALLED_ON_VALID_SEQUENCE(gpu_sequence_checker_);
+ if (!MakeContextCurrent())
+ return;
+
+ if (!shared_image_factory_ ||
+ !shared_image_factory_->CreateSharedImageWithAHB(out_mailbox, in_mailbox,
+ usage)) {
+ // Signal errors by losing the command buffer.
+ command_buffer_helper_->SetError();
+ return;
+ }
+ mailbox_manager_->PushTextureUpdates(sync_token);
+ sync_point_client_state_->ReleaseFenceSync(sync_token.release_count());
+}
+#endif
+
SharedImageInterface::SwapChainMailboxes
SharedImageInterfaceInProcess::CreateSwapChain(
viz::ResourceFormat format,