summaryrefslogtreecommitdiff
path: root/chromium/device/vr/public
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/device/vr/public')
-rw-r--r--chromium/device/vr/public/cpp/vr_device_provider.h1
-rw-r--r--chromium/device/vr/public/mojom/BUILD.gn23
-rw-r--r--chromium/device/vr/public/mojom/isolated_xr_service.mojom12
-rw-r--r--chromium/device/vr/public/mojom/pose.cc40
-rw-r--r--chromium/device/vr/public/mojom/pose.h65
-rw-r--r--chromium/device/vr/public/mojom/vr_service.mojom69
-rw-r--r--chromium/device/vr/public/mojom/vr_service_mojom_traits.h31
7 files changed, 224 insertions, 17 deletions
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_