Commit 8923e13a authored by Robert Sesek's avatar Robert Sesek Committed by Commit Bot

Convert XR mojoms to use handle<platform>

Bug: 710376
Change-Id: Ie3a7daded109f1f943b20b5f92c1eb07ca9ca6a6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2057823Reviewed-by: default avatarIan Vollick <vollick@chromium.org>
Reviewed-by: default avatarAlexander Cooper <alcooper@chromium.org>
Commit-Queue: Robert Sesek <rsesek@chromium.org>
Cr-Commit-Position: refs/heads/master@{#742385}
parent d5738d80
......@@ -536,8 +536,9 @@ void ArCoreGl::OnTransportFrameAvailable(const gfx::Transform& uv_transform) {
webxr_->TryDeferredProcessing();
}
void ArCoreGl::SubmitFrameWithTextureHandle(int16_t frame_index,
mojo::ScopedHandle texture_handle) {
void ArCoreGl::SubmitFrameWithTextureHandle(
int16_t frame_index,
mojo::PlatformHandle texture_handle) {
NOTIMPLEMENTED();
}
......
......@@ -98,8 +98,9 @@ class ArCoreGl : public mojom::XRFrameDataProvider,
void SubmitFrame(int16_t frame_index,
const gpu::MailboxHolder& mailbox,
base::TimeDelta time_waited) override;
void SubmitFrameWithTextureHandle(int16_t frame_index,
mojo::ScopedHandle texture_handle) override;
void SubmitFrameWithTextureHandle(
int16_t frame_index,
mojo::PlatformHandle texture_handle) override;
void SubmitFrameDrawnIntoTexture(int16_t frame_index,
const gpu::SyncToken&,
base::TimeDelta time_waited) override;
......
......@@ -1121,7 +1121,7 @@ void GvrSchedulerDelegate::SubmitFrame(int16_t frame_index,
void GvrSchedulerDelegate::SubmitFrameWithTextureHandle(
int16_t frame_index,
mojo::ScopedHandle texture_handle) {
mojo::PlatformHandle texture_handle) {
NOTREACHED();
}
......
......@@ -153,8 +153,9 @@ class GvrSchedulerDelegate : public BaseSchedulerDelegate,
void SubmitFrame(int16_t frame_index,
const gpu::MailboxHolder& mailbox,
base::TimeDelta time_waited) override;
void SubmitFrameWithTextureHandle(int16_t frame_index,
mojo::ScopedHandle texture_handle) override;
void SubmitFrameWithTextureHandle(
int16_t frame_index,
mojo::PlatformHandle texture_handle) override;
void SubmitFrameDrawnIntoTexture(int16_t frame_index,
const gpu::SyncToken&,
base::TimeDelta time_waited) override;
......
......@@ -9,7 +9,6 @@
#include "content/public/common/gpu_stream_constants.h"
#include "gpu/command_buffer/client/gles2_interface.h"
#include "gpu/command_buffer/client/gles2_lib.h"
#include "mojo/public/cpp/system/platform_handle.h"
namespace vr {
......@@ -118,15 +117,13 @@ void GraphicsDelegateWin::PostRender() {
ClearContext();
}
mojo::ScopedHandle GraphicsDelegateWin::GetTexture() {
// Hand out the gpu memory buffer.
mojo::ScopedHandle handle;
if (!gpu_memory_buffer_) {
return handle;
}
mojo::PlatformHandle GraphicsDelegateWin::GetTexture() {
if (!gpu_memory_buffer_)
return {};
gfx::GpuMemoryBufferHandle gpu_handle = gpu_memory_buffer_->CloneHandle();
return mojo::WrapPlatformFile(gpu_handle.dxgi_handle.GetHandle());
return mojo::PlatformHandle(
base::win::ScopedHandle(gpu_handle.dxgi_handle.GetHandle()));
}
gfx::RectF GraphicsDelegateWin::GetLeft() {
......
......@@ -16,7 +16,7 @@
#include "gpu/command_buffer/client/gpu_memory_buffer_manager.h"
#include "gpu/command_buffer/common/context_creation_attribs.h"
#include "gpu/ipc/client/gpu_channel_host.h"
#include "mojo/public/cpp/system/handle.h"
#include "mojo/public/cpp/platform/platform_handle.h"
#include "services/viz/public/cpp/gpu/context_provider_command_buffer.h"
#include "ui/gfx/geometry/rect_f.h"
......@@ -45,7 +45,7 @@ class GraphicsDelegateWin : public GraphicsDelegate {
void Cleanup();
void PreRender();
void PostRender();
mojo::ScopedHandle GetTexture();
mojo::PlatformHandle GetTexture();
gfx::RectF GetLeft();
gfx::RectF GetRight();
void ResetMemoryBuffer();
......
......@@ -86,7 +86,7 @@ interface ImmersiveOverlay {
// Submit a frame to show in the headset. Only can be called when an overlay
// is visible. The frame will be composited on top of WebXR content.
SubmitOverlayTexture(int16 frame_id, handle texture,
SubmitOverlayTexture(int16 frame_id, handle<platform> texture,
gfx.mojom.RectF left_bounds, gfx.mojom.RectF right_bounds) =>
(bool success);
......
......@@ -792,7 +792,7 @@ interface XRPresentationProvider {
// XRPresentationTransportMethod SUBMIT_AS_TEXTURE_HANDLE
// TODO(https://crbug.com/676224): Support preprocessing of mojom files, since
// this is Windows only.
SubmitFrameWithTextureHandle(int16 frameId, handle texture);
SubmitFrameWithTextureHandle(int16 frameId, handle<platform> texture);
// XRPresentationTransportMethod DRAW_INTO_TEXTURE_MAILBOX
SubmitFrameDrawnIntoTexture(int16 frameId, gpu.mojom.SyncToken sync_token,
......
......@@ -93,7 +93,7 @@ void XRCompositorCommon::SubmitFrameDrawnIntoTexture(
void XRCompositorCommon::SubmitFrameWithTextureHandle(
int16_t frame_index,
mojo::ScopedHandle texture_handle) {
mojo::PlatformHandle texture_handle) {
TRACE_EVENT1("xr", "SubmitFrameWithTextureHandle", "frameIndex", frame_index);
webxr_has_pose_ = false;
// Tell the browser that WebXR has submitted a frame.
......@@ -115,17 +115,9 @@ void XRCompositorCommon::SubmitFrameWithTextureHandle(
pending_frame_->submit_frame_time_ = base::TimeTicks::Now();
#if defined(OS_WIN)
MojoPlatformHandle platform_handle;
platform_handle.struct_size = sizeof(platform_handle);
MojoResult result = MojoUnwrapPlatformHandle(texture_handle.release().value(),
nullptr, &platform_handle);
if (result == MOJO_RESULT_OK) {
texture_helper_.SetSourceTexture(
base::win::ScopedHandle(
reinterpret_cast<HANDLE>(platform_handle.value)),
left_webxr_bounds_, right_webxr_bounds_);
pending_frame_->webxr_submitted_ = true;
}
texture_helper_.SetSourceTexture(texture_handle.TakeHandle(),
left_webxr_bounds_, right_webxr_bounds_);
pending_frame_->webxr_submitted_ = true;
// Regardless of success - try to composite what we have.
MaybeCompositeAndSubmit();
......@@ -384,7 +376,7 @@ void XRCompositorCommon::GetEnvironmentIntegrationProvider(
void XRCompositorCommon::SubmitOverlayTexture(
int16_t frame_id,
mojo::ScopedHandle texture_handle,
mojo::PlatformHandle texture_handle,
const gfx::RectF& left_bounds,
const gfx::RectF& right_bounds,
SubmitOverlayTextureCallback overlay_submit_callback) {
......@@ -403,19 +395,9 @@ void XRCompositorCommon::SubmitOverlayTexture(
pending_frame_->waiting_for_overlay_ = false;
#if defined(OS_WIN)
MojoPlatformHandle platform_handle;
platform_handle.struct_size = sizeof(platform_handle);
MojoResult result = MojoUnwrapPlatformHandle(texture_handle.release().value(),
nullptr, &platform_handle);
if (result == MOJO_RESULT_OK) {
texture_helper_.SetOverlayTexture(
base::win::ScopedHandle(
reinterpret_cast<HANDLE>(platform_handle.value)),
left_bounds, right_bounds);
pending_frame_->overlay_submitted_ = true;
} else {
std::move(overlay_submit_callback_).Run(false);
}
texture_helper_.SetOverlayTexture(texture_handle.TakeHandle(), left_bounds,
right_bounds);
pending_frame_->overlay_submitted_ = true;
// Regardless of success - try to composite what we have.
MaybeCompositeAndSubmit();
......
......@@ -19,7 +19,7 @@
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "mojo/public/cpp/system/platform_handle.h"
#include "mojo/public/cpp/platform/platform_handle.h"
#include "ui/gfx/geometry/rect_f.h"
#if defined(OS_WIN)
......@@ -119,7 +119,7 @@ class XRCompositorCommon : public base::Thread,
const gpu::SyncToken&,
base::TimeDelta time_waited) final;
void SubmitFrameWithTextureHandle(int16_t frame_index,
mojo::ScopedHandle texture_handle) final;
mojo::PlatformHandle texture_handle) final;
void UpdateLayerBounds(int16_t frame_id,
const gfx::RectF& left_bounds,
const gfx::RectF& right_bounds,
......@@ -127,7 +127,7 @@ class XRCompositorCommon : public base::Thread,
// ImmersiveOverlay:
void SubmitOverlayTexture(int16_t frame_id,
mojo::ScopedHandle texture,
mojo::PlatformHandle texture,
const gfx::RectF& left_bounds,
const gfx::RectF& right_bounds,
SubmitOverlayTextureCallback callback) override;
......
......@@ -125,12 +125,12 @@ void XRFrameTransport::FrameSubmit(
}
// We decompose the cloned handle, and use it to create a
// mojo::ScopedHandle which will own cleanup of the handle, and will be
// mojo::PlatformHandle which will own cleanup of the handle, and will be
// passed over IPC.
gfx::GpuMemoryBufferHandle gpu_handle = gpu_memory_buffer->CloneHandle();
vr_presentation_provider->SubmitFrameWithTextureHandle(
vr_frame_id,
mojo::WrapPlatformFile(gpu_handle.dxgi_handle.GetHandle()));
vr_frame_id, mojo::PlatformHandle(base::win::ScopedHandle(
gpu_handle.dxgi_handle.GetHandle())));
#else
NOTIMPLEMENTED();
#endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment