diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-12 14:27:29 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-13 09:35:20 +0000 |
commit | c30a6232df03e1efbd9f3b226777b07e087a1122 (patch) | |
tree | e992f45784689f373bcc38d1b79a239ebe17ee23 /chromium/device/vr | |
parent | 7b5b123ac58f58ffde0f4f6e488bcd09aa4decd3 (diff) | |
download | qtwebengine-chromium-85-based.tar.gz |
BASELINE: Update Chromium to 85.0.4183.14085-based
Change-Id: Iaa42f4680837c57725b1344f108c0196741f6057
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/device/vr')
20 files changed, 300 insertions, 25 deletions
diff --git a/chromium/device/vr/android/gvr/gvr_device_provider.cc b/chromium/device/vr/android/gvr/gvr_device_provider.cc index 7e967c15b5d..b5fd9868352 100644 --- a/chromium/device/vr/android/gvr/gvr_device_provider.cc +++ b/chromium/device/vr/android/gvr/gvr_device_provider.cc @@ -17,6 +17,7 @@ GvrDeviceProvider::~GvrDeviceProvider() = default; void GvrDeviceProvider::Initialize( base::RepeatingCallback<void(mojom::XRDeviceId, mojom::VRDisplayInfoPtr, + mojom::XRDeviceDataPtr, mojo::PendingRemote<mojom::XRRuntime>)> add_device_callback, base::RepeatingCallback<void(mojom::XRDeviceId)> remove_device_callback, @@ -32,6 +33,7 @@ void GvrDeviceProvider::Initialize( } if (vr_device_) { add_device_callback.Run(vr_device_->GetId(), vr_device_->GetVRDisplayInfo(), + vr_device_->GetDeviceData(), vr_device_->BindXRRuntime()); } initialized_ = true; diff --git a/chromium/device/vr/android/gvr/gvr_device_provider.h b/chromium/device/vr/android/gvr/gvr_device_provider.h index dcf579f60d8..aed9b3abe96 100644 --- a/chromium/device/vr/android/gvr/gvr_device_provider.h +++ b/chromium/device/vr/android/gvr/gvr_device_provider.h @@ -24,6 +24,7 @@ class DEVICE_VR_EXPORT GvrDeviceProvider : public VRDeviceProvider { void Initialize( base::RepeatingCallback<void(mojom::XRDeviceId, mojom::VRDisplayInfoPtr, + mojom::XRDeviceDataPtr, mojo::PendingRemote<mojom::XRRuntime>)> add_device_callback, base::RepeatingCallback<void(mojom::XRDeviceId)> remove_device_callback, diff --git a/chromium/device/vr/openxr/openxr_device.cc b/chromium/device/vr/openxr/openxr_device.cc index 2b7a8cf0fc9..7e2c2cc0315 100644 --- a/chromium/device/vr/openxr/openxr_device.cc +++ b/chromium/device/vr/openxr/openxr_device.cc @@ -7,8 +7,10 @@ #include <string> #include "base/bind_helpers.h" +#include "build/build_config.h" #include "device/vr/openxr/openxr_api_wrapper.h" #include "device/vr/openxr/openxr_render_loop.h" +#include "device/vr/openxr/openxr_statics.h" #include "device/vr/util/transform_utils.h" #include "mojo/public/cpp/bindings/pending_remote.h" @@ -53,10 +55,17 @@ mojom::VRDisplayInfoPtr CreateFakeVRDisplayInfo(device::mojom::XRDeviceId id) { } // namespace -OpenXrDevice::OpenXrDevice() +// OpenXrDevice must not take ownership of the OpenXrStatics passed in. +// The OpenXrStatics object is owned by IsolatedXRRuntimeProvider. +OpenXrDevice::OpenXrDevice(OpenXrStatics* openxr_statics) : VRDeviceBase(device::mojom::XRDeviceId::OPENXR_DEVICE_ID), weak_ptr_factory_(this) { - SetVRDisplayInfo(CreateFakeVRDisplayInfo(GetId())); + mojom::VRDisplayInfoPtr display_info = CreateFakeVRDisplayInfo(GetId()); + SetVRDisplayInfo(std::move(display_info)); + +#if defined(OS_WIN) + SetLuid(openxr_statics->GetLuid()); +#endif } OpenXrDevice::~OpenXrDevice() { diff --git a/chromium/device/vr/openxr/openxr_device.h b/chromium/device/vr/openxr/openxr_device.h index 5b1d1dc3b1c..237223a3318 100644 --- a/chromium/device/vr/openxr/openxr_device.h +++ b/chromium/device/vr/openxr/openxr_device.h @@ -18,13 +18,14 @@ namespace device { class OpenXrRenderLoop; +class OpenXrStatics; class DEVICE_VR_EXPORT OpenXrDevice : public VRDeviceBase, public mojom::XRSessionController, public mojom::XRCompositorHost { public: - OpenXrDevice(); + OpenXrDevice(OpenXrStatics* openxr_statics); ~OpenXrDevice() override; // VRDeviceBase diff --git a/chromium/device/vr/openxr/openxr_statics.cc b/chromium/device/vr/openxr/openxr_statics.cc index 4b6096f31ad..c10611cb143 100644 --- a/chromium/device/vr/openxr/openxr_statics.cc +++ b/chromium/device/vr/openxr/openxr_statics.cc @@ -31,4 +31,25 @@ bool OpenXrStatics::IsApiAvailable() { XR_SUCCEEDED(CreateInstance(&instance_)); } -} // namespace device
\ No newline at end of file +#if defined(OS_WIN) +// Returns the LUID of the adapter the OpenXR runtime is on. Returns {0, 0} if +// the LUID could not be determined. +LUID OpenXrStatics::GetLuid() { + if (!IsApiAvailable()) + return {0, 0}; + + XrSystemId system; + if (XR_FAILED(GetSystem(instance_, &system))) + return {0, 0}; + + XrGraphicsRequirementsD3D11KHR graphics_requirements = { + XR_TYPE_GRAPHICS_REQUIREMENTS_D3D11_KHR}; + if (XR_FAILED(xrGetD3D11GraphicsRequirementsKHR(instance_, system, + &graphics_requirements))) + return {0, 0}; + + return graphics_requirements.adapterLuid; +} +#endif + +} // namespace device diff --git a/chromium/device/vr/openxr/openxr_statics.h b/chromium/device/vr/openxr/openxr_statics.h index 0b41f576574..4663b8a41fa 100644 --- a/chromium/device/vr/openxr/openxr_statics.h +++ b/chromium/device/vr/openxr/openxr_statics.h @@ -8,6 +8,7 @@ #include <d3d11.h> #include <memory> +#include "build/build_config.h" #include "device/vr/vr_export.h" #include "third_party/openxr/src/include/openxr/openxr.h" #include "third_party/openxr/src/include/openxr/openxr_platform.h" @@ -22,10 +23,14 @@ class DEVICE_VR_EXPORT OpenXrStatics { bool IsHardwareAvailable(); bool IsApiAvailable(); +#if defined(OS_WIN) + LUID GetLuid(); +#endif + private: XrInstance instance_; }; } // namespace device -#endif // DEVICE_VR_WINDOWS_MIXED_REALITY_MIXED_REALITY_STATICS_H_
\ No newline at end of file +#endif // DEVICE_VR_WINDOWS_MIXED_REALITY_MIXED_REALITY_STATICS_H_ diff --git a/chromium/device/vr/openxr/openxr_util.h b/chromium/device/vr/openxr/openxr_util.h index ed5ed7c6e9c..80aaeae67cb 100644 --- a/chromium/device/vr/openxr/openxr_util.h +++ b/chromium/device/vr/openxr/openxr_util.h @@ -5,6 +5,7 @@ #ifndef DEVICE_VR_OPENXR_OPENXR_UTIL_H_ #define DEVICE_VR_OPENXR_OPENXR_UTIL_H_ +#include "base/logging.h" #include "third_party/openxr/src/include/openxr/openxr.h" namespace device { diff --git a/chromium/device/vr/orientation/orientation_device_provider.cc b/chromium/device/vr/orientation/orientation_device_provider.cc index 7745bc513fb..785f43288a8 100644 --- a/chromium/device/vr/orientation/orientation_device_provider.cc +++ b/chromium/device/vr/orientation/orientation_device_provider.cc @@ -22,13 +22,14 @@ VROrientationDeviceProvider::~VROrientationDeviceProvider() = default; void VROrientationDeviceProvider::Initialize( base::RepeatingCallback<void(mojom::XRDeviceId, mojom::VRDisplayInfoPtr, + mojom::XRDeviceDataPtr, mojo::PendingRemote<mojom::XRRuntime>)> add_device_callback, base::RepeatingCallback<void(mojom::XRDeviceId)> remove_device_callback, base::OnceClosure initialization_complete) { if (device_ && device_->IsAvailable()) { add_device_callback.Run(device_->GetId(), device_->GetVRDisplayInfo(), - device_->BindXRRuntime()); + device_->GetDeviceData(), device_->BindXRRuntime()); return; } @@ -55,6 +56,7 @@ void VROrientationDeviceProvider::DeviceInitialized() { // If the device successfully connected to the orientation APIs, provide it. if (device_->IsAvailable()) { add_device_callback_.Run(device_->GetId(), device_->GetVRDisplayInfo(), + device_->GetDeviceData(), device_->BindXRRuntime()); } diff --git a/chromium/device/vr/orientation/orientation_device_provider.h b/chromium/device/vr/orientation/orientation_device_provider.h index 1d6e8149a88..6d988f1cd52 100644 --- a/chromium/device/vr/orientation/orientation_device_provider.h +++ b/chromium/device/vr/orientation/orientation_device_provider.h @@ -28,6 +28,7 @@ class COMPONENT_EXPORT(VR_ORIENTATION) VROrientationDeviceProvider void Initialize( base::RepeatingCallback<void(mojom::XRDeviceId, mojom::VRDisplayInfoPtr, + mojom::XRDeviceDataPtr, mojo::PendingRemote<mojom::XRRuntime>)> add_device_callback, base::RepeatingCallback<void(mojom::XRDeviceId)> remove_device_callback, @@ -46,6 +47,7 @@ class COMPONENT_EXPORT(VR_ORIENTATION) VROrientationDeviceProvider base::RepeatingCallback<void(mojom::XRDeviceId, mojom::VRDisplayInfoPtr, + mojom::XRDeviceDataPtr, mojo::PendingRemote<mojom::XRRuntime>)> add_device_callback_; base::OnceClosure initialized_callback_; diff --git a/chromium/device/vr/orientation/orientation_device_provider_unittest.cc b/chromium/device/vr/orientation/orientation_device_provider_unittest.cc index 7f257ce8390..f40c5f35024 100644 --- a/chromium/device/vr/orientation/orientation_device_provider_unittest.cc +++ b/chromium/device/vr/orientation/orientation_device_provider_unittest.cc @@ -84,10 +84,12 @@ class VROrientationDeviceProviderTest : public testing::Test { base::RepeatingCallback<void(device::mojom::XRDeviceId, mojom::VRDisplayInfoPtr, + mojom::XRDeviceDataPtr, mojo::PendingRemote<mojom::XRRuntime> device)> DeviceAndIdCallbackFailIfCalled() { return base::BindRepeating( [](device::mojom::XRDeviceId id, mojom::VRDisplayInfoPtr, + mojom::XRDeviceDataPtr, mojo::PendingRemote<mojom::XRRuntime> device) { FAIL(); }); } @@ -98,14 +100,16 @@ class VROrientationDeviceProviderTest : public testing::Test { base::RepeatingCallback<void(device::mojom::XRDeviceId, mojom::VRDisplayInfoPtr, + mojom::XRDeviceDataPtr, mojo::PendingRemote<mojom::XRRuntime> device)> DeviceAndIdCallbackMustBeCalled(base::RunLoop* loop) { return base::BindRepeating( [](base::OnceClosure quit_closure, device::mojom::XRDeviceId id, - mojom::VRDisplayInfoPtr info, + mojom::VRDisplayInfoPtr info, mojom::XRDeviceDataPtr data, mojo::PendingRemote<mojom::XRRuntime> device) { ASSERT_TRUE(device); ASSERT_TRUE(info); + ASSERT_TRUE(data); std::move(quit_closure).Run(); }, loop->QuitClosure()); diff --git a/chromium/device/vr/public/cpp/vr_device_provider.h b/chromium/device/vr/public/cpp/vr_device_provider.h index 10c3460fb5a..f3ecf6a2d6a 100644 --- a/chromium/device/vr/public/cpp/vr_device_provider.h +++ b/chromium/device/vr/public/cpp/vr_device_provider.h @@ -23,6 +23,7 @@ class COMPONENT_EXPORT(VR_PUBLIC_CPP) VRDeviceProvider { virtual void Initialize( base::RepeatingCallback<void(mojom::XRDeviceId id, mojom::VRDisplayInfoPtr, + mojom::XRDeviceDataPtr, mojo::PendingRemote<mojom::XRRuntime>)> add_device_callback, base::RepeatingCallback<void(mojom::XRDeviceId id)> diff --git a/chromium/device/vr/public/mojom/BUILD.gn b/chromium/device/vr/public/mojom/BUILD.gn index 20a26a69965..56752b7b348 100644 --- a/chromium/device/vr/public/mojom/BUILD.gn +++ b/chromium/device/vr/public/mojom/BUILD.gn @@ -48,8 +48,13 @@ mojom_component("mojom") { mojom = "device.mojom.RgbTupleF32" cpp = "::device::RgbTupleF32" }, + { + mojom = "device.mojom.Pose" + cpp = "::device::Pose" + }, ] traits_headers = [ "//device/vr/public/mojom/vr_service_mojom_traits.h" ] + traits_public_deps = [ ":vr_public_typemaps" ] } cpp_typemaps = [ shared_cpp_typemap ] @@ -67,3 +72,21 @@ mojom_component("test_mojom") { "//ui/gfx/mojom", ] } + +component("vr_public_typemaps") { + output_name = "device_vr_public_typemaps" + + defines = [ "IS_VR_PUBLIC_TYPEMAPS_IMPL" ] + + sources = [ + "pose.cc", + "pose.h", + ] + + deps = [ + "//base:base", + "//skia", + "//ui/gfx:geometry_skia", + "//ui/gfx/geometry:geometry", + ] +} diff --git a/chromium/device/vr/public/mojom/isolated_xr_service.mojom b/chromium/device/vr/public/mojom/isolated_xr_service.mojom index 787636c99a9..12235c2a141 100644 --- a/chromium/device/vr/public/mojom/isolated_xr_service.mojom +++ b/chromium/device/vr/public/mojom/isolated_xr_service.mojom @@ -6,6 +6,8 @@ module device.mojom; import "device/vr/public/mojom/browser_test_interfaces.mojom"; import "device/vr/public/mojom/vr_service.mojom"; +[EnableIf=is_win] +import "gpu/ipc/common/luid.mojom"; import "mojo/public/mojom/base/time.mojom"; import "ui/gfx/geometry/mojom/geometry.mojom"; @@ -110,6 +112,15 @@ interface XRCompositorHost { CreateImmersiveOverlay(pending_receiver<ImmersiveOverlay> overlay); }; +// Information about a particular XR device that is available. All information +// about an available XR device should be wrapped in this struct. +// TODO(crbug.com/1090029): Wrap XRDeviceId + VRDisplayInfo in this struct +struct XRDeviceData { + [EnableIf=is_win] + // The LUID of the GPU that the device is plugged into. + gpu.mojom.Luid? luid; +}; + // Notify the browser process about a set of runtimes. The browser process // implements this interface to be notified about runtime changes from the XR // device service. @@ -118,6 +129,7 @@ interface IsolatedXRRuntimeProviderClient { // attached and become available. OnDeviceAdded(pending_remote<XRRuntime> runtime, pending_remote<XRCompositorHost> compositor_host, + XRDeviceData device_data, device.mojom.XRDeviceId device_id); // Called when runtimes become unavailable - for example if the hardware is diff --git a/chromium/device/vr/public/mojom/pose.cc b/chromium/device/vr/public/mojom/pose.cc new file mode 100644 index 00000000000..4fbf54010d3 --- /dev/null +++ b/chromium/device/vr/public/mojom/pose.cc @@ -0,0 +1,40 @@ +// Copyright 2020 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "device/vr/public/mojom/pose.h" + +#include "ui/gfx/transform_util.h" + +namespace device { + +Pose::Pose() = default; + +Pose::Pose(const gfx::Point3F& position, const gfx::Quaternion& orientation) + : position_(position), orientation_(orientation) { + gfx::DecomposedTransform decomposed_pose; + decomposed_pose.translate[0] = position.x(); + decomposed_pose.translate[1] = position.y(); + decomposed_pose.translate[2] = position.z(); + decomposed_pose.quaternion = orientation; + + other_from_this_ = gfx::ComposeTransform(decomposed_pose); +} + +base::Optional<Pose> Pose::Create(const gfx::Transform& other_from_this) { + gfx::DecomposedTransform decomposed_other_from_this; + if (!gfx::DecomposeTransform(&decomposed_other_from_this, other_from_this)) { + return base::nullopt; + } + + return Pose(gfx::Point3F(decomposed_other_from_this.translate[0], + decomposed_other_from_this.translate[1], + decomposed_other_from_this.translate[2]), + decomposed_other_from_this.quaternion); +} + +const gfx::Transform& Pose::ToTransform() const { + return other_from_this_; +} + +} // namespace device diff --git a/chromium/device/vr/public/mojom/pose.h b/chromium/device/vr/public/mojom/pose.h new file mode 100644 index 00000000000..524e7294f63 --- /dev/null +++ b/chromium/device/vr/public/mojom/pose.h @@ -0,0 +1,65 @@ +// Copyright 2020 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef DEVICE_VR_PUBLIC_MOJOM_POSE_H_ +#define DEVICE_VR_PUBLIC_MOJOM_POSE_H_ + +#include "base/component_export.h" +#include "base/optional.h" +#include "ui/gfx/geometry/point3_f.h" +#include "ui/gfx/geometry/quaternion.h" +#include "ui/gfx/transform.h" + +namespace device { + +// Pose represents some entity's position and orientation and is always +// expressed relative to some coordinate system. Alternatively, the pose can be +// viewed as a rigid transform that performs a coordinate system change from the +// coordinate system represented by the entity (i.e. coordinate system whose +// origin is equal to entity's position and whose orientation is equal to +// entity's orientation) to the coordinate system relative to which the pose is +// supposed to be expressed. +// +// If the pose represents a position of entity |entity| in coordinate space +// |coord|, it is recommended to name such a variable as |coord_from_entity|. +// In order to obtain the matrix that performs the coordinate system +// transformation, the callers can use |GetOtherFromThis()| method. The +// resulting matrix will encode coordinate system change from |entity| space to +// |coord| space. +// +// The source for the naming convention can be found here: +// https://www.sebastiansylvan.com/post/matrix_naming_convention/ +class COMPONENT_EXPORT(VR_PUBLIC_TYPEMAPS) Pose { + public: + explicit Pose(); + explicit Pose(const gfx::Point3F& position, + const gfx::Quaternion& orientation); + + // Creates a pose from transform by decomposing it. The method assumes that + // the passed in matrix represents a rigid transformation (i.e. only the + // orientation and translation components of the decomposed matrix will affect + // the result). If the matrix could not be decomposed, the method will return + // a base::nullopt. + static base::Optional<Pose> Create(const gfx::Transform& other_from_this); + + const gfx::Point3F& position() const { return position_; } + + const gfx::Quaternion& orientation() const { return orientation_; } + + // Returns the underlying matrix representation of the pose. + const gfx::Transform& ToTransform() const; + + private: + gfx::Point3F position_; + gfx::Quaternion orientation_; + + // Transformation that can be used to switch from coordinate system + // represented by this pose to other coordinate system (i.e. the coordinate + // system relative to which this pose is supposed to be expressed). + gfx::Transform other_from_this_; +}; + +} // namespace device + +#endif // DEVICE_VR_PUBLIC_MOJOM_POSE_H_ diff --git a/chromium/device/vr/public/mojom/vr_service.mojom b/chromium/device/vr/public/mojom/vr_service.mojom index 57de335d954..ee80526b2f5 100644 --- a/chromium/device/vr/public/mojom/vr_service.mojom +++ b/chromium/device/vr/public/mojom/vr_service.mojom @@ -60,6 +60,7 @@ enum XRSessionFeature { HIT_TEST = 7, LIGHT_ESTIMATION = 8, // Experimental feature. ANCHORS = 9, // Experimental feature. + CAMERA_ACCESS = 10, // Experimental feature. }; // These values are persisted to logs. Entries should not be renumbered and @@ -261,7 +262,7 @@ struct XRRay { }; struct XRHitResult { - gfx.mojom.Transform hit_matrix; + Pose mojo_from_result; // Pose of the result (aka intersection point). uint64 plane_id; // If the hit test result was computed based off of a plane, // the plane ID will be stored here. 0 signifies no plane. // TODO(https://crbug.com/657632) - make it optional once @@ -329,14 +330,14 @@ struct XRPresentationTransportOptions { bool wait_for_gpu_fence; }; -// Native origins that are reference spaces are identified by their category. -// Currently, the device needs to know about 3 reference space categories. -enum XRReferenceSpaceCategory { - LOCAL, - LOCAL_FLOOR, - VIEWER, - BOUNDED_FLOOR, - UNBOUNDED +// Native origins that are reference spaces are identified by their type. +// Used for metrics, don't remove or change values. +enum XRReferenceSpaceType { + kViewer = 0, + kLocal = 1, + kLocalFloor = 2, + kBoundedFloor = 3, + kUnbounded = 4, }; // Native origin represents a reference space that is known to the device and @@ -346,12 +347,12 @@ enum XRReferenceSpaceCategory { // XRReferenceSpaceType, XRBoundedReferenceSpace) or returns an XRSpace (for // example XRAnchor, XRPlane, XRInputSource). Native origin can be identified, // depending on its type, by the id of the entity (this is the case for planes, -// anchors and input sources), or by reference space category. +// anchors and input sources), or by reference space type. union XRNativeOriginInformation { uint32 input_source_id; uint64 plane_id; uint64 anchor_id; - XRReferenceSpaceCategory reference_space_category; + XRReferenceSpaceType reference_space_type; }; enum XRPlaneOrientation { @@ -540,8 +541,7 @@ struct XRFrameData { // The pose may be null if the device lost tracking. The XRFrameData can still // have other data, such as pass through camera image. VRPose? pose; - // TODO(https://crbug.com/838515): Is this delta since the last - // frame? OR an unspecified origin? Something else? + // Time delta from an unspecified origin. mojo_base.mojom.TimeDelta time_delta; // The buffer_holder is used for sending data imagery back and forth across // the process boundary. For application with pass through camera, it holds @@ -655,6 +655,19 @@ union RequestSessionResult { RequestSessionError failure_reason; }; +// Return value for VRService.MakeXrCompatible() to indicate whether the GPU +// process is compatible with the active VR headset. +enum XrCompatibleResult { + // Compatibility results where the GPU process was not restarted. + kAlreadyCompatible, + kNotCompatible, + + // Compatibility results where the GPU was restarted. Context lost and + // restored for existing WebGL contexts must be handled before using for XR. + kCompatibleAfterRestart, // XR compatible, GPU process was restarted. + kNotCompatibleAfterRestart, // Not XR compatible, GPU process was restarted. +}; + // Interface for requesting XRDevice interfaces and registering for // notifications that the XRDevice has changed. Implemented in the browser // process and consumed in the renderer process. @@ -681,6 +694,17 @@ interface VRService { // renderer can (and may) still decide to submit frames and that should not be // treated as illegal or clear the throttled state. SetFramesThrottled(bool throttled); + + // Request for the GPU process to be compatible with the active VR headset. + // This will trigger the initialization of the XR process if it isn't already + // initialized and then restart the GPU process if it's not using the same GPU + // as the VR headset. The Sync attribute is needed because there are two ways + // for WebXR to trigger this - WebGLRenderingContext.makeXRCompatible() + // which returns a promise and is asynchronous, and + // HTMLCanvasElement.getContext('webgl', { xrCompatible: true }) which is + // synchronous and must return a context that is already xr compatible. + [Sync] + MakeXrCompatible() => (XrCompatibleResult xr_compatible_result); }; // Any metrics that must be recorded throughout the duration of an XR session @@ -770,7 +794,11 @@ interface XREnvironmentIntegrationProvider { // ignored. UnsubscribeFromHitTest(uint64 subscription_id); - // Issues a request to create an anchor attached to a session. + // Issues a request to create a free-floating anchor (not attached to any + // particular real world entity). + // |native_origin_information| specifies native origin relative to which the + // anchor is supposed to be created. |native_origin_from_anchor| describes the + // desired pose of the newly created anchor. // |result| will contain status code of the request. |anchor_id| will be valid // only if the |result| is SUCCESS. CreateAnchor( @@ -782,11 +810,18 @@ interface XREnvironmentIntegrationProvider { // not interested in obtaining detailed error information from the device. // Issues a request to create an anchor attached to a plane. + // |native_origin_information| specifies native origin relative to which the + // anchor is supposed to be created. |native_origin_from_anchor| describes the + // desired pose of the newly created anchor. |plane_id| identifies which plane + // the anchor will be attached to. // |result| will contain status code of the request. |anchor_id| will be valid // only if the |result| is SUCCESS. - CreatePlaneAnchor(Pose plane_from_anchor, uint64 plane_id) => - (CreateAnchorResult result, uint64 anchor_id); - // TODO(https://crbug.com/657632): Ditto - make anchor_id a nullable integer.. + CreatePlaneAnchor( + XRNativeOriginInformation native_origin_information, + Pose native_origin_from_anchor, + uint64 plane_id) + => (CreateAnchorResult result, uint64 anchor_id); + // TODO(https://crbug.com/657632): Ditto - make anchor_id a nullable integer. // Detaches an existing anchor. The |anchor_id| must be a valid id of an // anchor created by one of the CreateAnchor calls, otherwise the call will be diff --git a/chromium/device/vr/public/mojom/vr_service_mojom_traits.h b/chromium/device/vr/public/mojom/vr_service_mojom_traits.h index c1967918fa2..fe0f57c63d8 100644 --- a/chromium/device/vr/public/mojom/vr_service_mojom_traits.h +++ b/chromium/device/vr/public/mojom/vr_service_mojom_traits.h @@ -5,10 +5,14 @@ #ifndef DEVICE_VR_PUBLIC_MOJOM_VR_SERVICE_MOJOM_TRAITS_H_ #define DEVICE_VR_PUBLIC_MOJOM_VR_SERVICE_MOJOM_TRAITS_H_ +#include "device/vr/public/mojom/pose.h" #include "device/vr/public/mojom/rgb_tuple_f32.h" #include "device/vr/public/mojom/rgba_tuple_f16.h" #include "device/vr/public/mojom/vr_service.mojom-shared.h" #include "mojo/public/cpp/bindings/struct_traits.h" +#include "ui/gfx/geometry/mojom/geometry_mojom_traits.h" +#include "ui/gfx/geometry/point3_f.h" +#include "ui/gfx/geometry/quaternion.h" namespace mojo { @@ -46,6 +50,33 @@ struct StructTraits<device::mojom::RgbTupleF32DataView, device::RgbTupleF32> { } }; +template <> +class StructTraits<device::mojom::PoseDataView, device::Pose> { + public: + static const gfx::Point3F& position(const device::Pose& pose) { + return pose.position(); + } + static const gfx::Quaternion& orientation(const device::Pose& pose) { + return pose.orientation(); + } + + static bool Read(device::mojom::PoseDataView pose_data, + device::Pose* out_pose) { + gfx::Point3F position; + if (!pose_data.ReadPosition(&position)) { + return false; + } + + gfx::Quaternion orientation; + if (!pose_data.ReadOrientation(&orientation)) { + return false; + } + + *out_pose = device::Pose(position, orientation); + return true; + } +}; + } // namespace mojo #endif // DEVICE_VR_PUBLIC_MOJOM_VR_SERVICE_MOJOM_TRAITS_H_ diff --git a/chromium/device/vr/test/test_hook.h b/chromium/device/vr/test/test_hook.h index c7863c1ac4c..6c2db8e236b 100644 --- a/chromium/device/vr/test/test_hook.h +++ b/chromium/device/vr/test/test_hook.h @@ -5,7 +5,7 @@ #ifndef DEVICE_VR_TEST_TEST_HOOK_H_ #define DEVICE_VR_TEST_TEST_HOOK_H_ -#include "base/logging.h" +#include "base/check.h" #include "device/vr/public/mojom/browser_test_interfaces.mojom.h" #include "ui/gfx/transform.h" diff --git a/chromium/device/vr/vr_device_base.cc b/chromium/device/vr/vr_device_base.cc index 61a6404614c..9d113bb653d 100644 --- a/chromium/device/vr/vr_device_base.cc +++ b/chromium/device/vr/vr_device_base.cc @@ -19,6 +19,10 @@ mojom::XRDeviceId VRDeviceBase::GetId() const { return id_; } +mojom::XRDeviceDataPtr VRDeviceBase::GetDeviceData() const { + return device_data_.Clone(); +} + void VRDeviceBase::PauseTracking() {} void VRDeviceBase::ResumeTracking() {} @@ -75,6 +79,15 @@ void VRDeviceBase::OnVisibilityStateChanged( listener_->OnVisibilityStateChanged(visibility_state); } +#if defined(OS_WIN) +void VRDeviceBase::SetLuid(const LUID& luid) { + if (luid.HighPart != 0 || luid.LowPart != 0) { + // Only set the LUID if it exists and is nonzero. + device_data_.luid = base::make_optional<LUID>(luid); + } +} +#endif + mojo::PendingRemote<mojom::XRRuntime> VRDeviceBase::BindXRRuntime() { DVLOG(2) << __func__; return runtime_receiver_.BindNewPipeAndPassRemote(); diff --git a/chromium/device/vr/vr_device_base.h b/chromium/device/vr/vr_device_base.h index 7a33f90385e..c16a63ca192 100644 --- a/chromium/device/vr/vr_device_base.h +++ b/chromium/device/vr/vr_device_base.h @@ -11,6 +11,7 @@ #include "base/callback.h" #include "base/component_export.h" #include "base/macros.h" +#include "build/build_config.h" #include "device/vr/public/mojom/vr_service.mojom.h" #include "device/vr/vr_device.h" #include "mojo/public/cpp/bindings/associated_remote.h" @@ -35,6 +36,7 @@ class COMPONENT_EXPORT(DEVICE_VR_BASE) VRDeviceBase : public mojom::XRRuntime { void ShutdownSession(mojom::XRRuntime::ShutdownSessionCallback) override; device::mojom::XRDeviceId GetId() const; + device::mojom::XRDeviceDataPtr GetDeviceData() const; bool HasExclusiveSession(); @@ -61,6 +63,9 @@ class COMPONENT_EXPORT(DEVICE_VR_BASE) VRDeviceBase : public mojom::XRRuntime { bool IsPresenting() { return presenting_; } // Exposed for test. void SetVRDisplayInfo(mojom::VRDisplayInfoPtr display_info); void OnVisibilityStateChanged(mojom::XRVisibilityState visibility_state); +#if defined(OS_WIN) + void SetLuid(const LUID& luid); +#endif mojom::VRDisplayInfoPtr display_info_; @@ -73,6 +78,8 @@ class COMPONENT_EXPORT(DEVICE_VR_BASE) VRDeviceBase : public mojom::XRRuntime { device::mojom::XRDeviceId id_; + device::mojom::XRDeviceData device_data_; + mojo::Receiver<mojom::XRRuntime> runtime_receiver_{this}; DISALLOW_COPY_AND_ASSIGN(VRDeviceBase); |