Commit d54a103e authored by Jacob DeWitt's avatar Jacob DeWitt Committed by Commit Bot

Add XRPose interface and make XRViewerPose extend it.

Bug: 922200
Change-Id: I3ce9fcbcfee18e98f82f08393c8cae6230b6e84e
Reviewed-on: https://chromium-review.googlesource.com/c/1471301
Commit-Queue: Jacob DeWitt <jacde@chromium.org>
Reviewed-by: default avatarBrandon Jones <bajones@chromium.org>
Reviewed-by: default avatarJeremy Roman <jbroman@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#632754}
parent fe5c01de
...@@ -459,6 +459,7 @@ modules_idl_files = ...@@ -459,6 +459,7 @@ modules_idl_files =
"xr/xr_input_source.idl", "xr/xr_input_source.idl",
"xr/xr_input_source_event.idl", "xr/xr_input_source_event.idl",
"xr/xr_layer.idl", "xr/xr_layer.idl",
"xr/xr_pose.idl",
"xr/xr_presentation_context.idl", "xr/xr_presentation_context.idl",
"xr/xr_ray.idl", "xr/xr_ray.idl",
"xr/xr_reference_space.idl", "xr/xr_reference_space.idl",
......
...@@ -28,6 +28,8 @@ blink_modules_sources("xr") { ...@@ -28,6 +28,8 @@ blink_modules_sources("xr") {
"xr_input_source_event.h", "xr_input_source_event.h",
"xr_layer.cc", "xr_layer.cc",
"xr_layer.h", "xr_layer.h",
"xr_pose.cc",
"xr_pose.h",
"xr_presentation_context.cc", "xr_presentation_context.cc",
"xr_presentation_context.h", "xr_presentation_context.h",
"xr_ray.cc", "xr_ray.cc",
......
// Copyright 2019 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 "third_party/blink/renderer/modules/xr/xr_pose.h"
#include "third_party/blink/renderer/modules/xr/xr_rigid_transform.h"
namespace blink {
XRPose::XRPose(std::unique_ptr<TransformationMatrix> pose_model_matrix,
bool emulated_position)
: transform_(
MakeGarbageCollected<XRRigidTransform>(std::move(pose_model_matrix))),
emulated_position_(emulated_position) {}
void XRPose::Trace(blink::Visitor* visitor) {
visitor->Trace(transform_);
ScriptWrappable::Trace(visitor);
}
} // namespace blink
// Copyright 2019 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 THIRD_PARTY_BLINK_RENDERER_MODULES_XR_XR_POSE_H_
#define THIRD_PARTY_BLINK_RENDERER_MODULES_XR_XR_POSE_H_
#include <utility>
#include "third_party/blink/renderer/platform/bindings/script_wrappable.h"
#include "third_party/blink/renderer/platform/heap/handle.h"
#include "third_party/blink/renderer/platform/transforms/transformation_matrix.h"
namespace blink {
class XRRigidTransform;
class XRPose : public ScriptWrappable {
DEFINE_WRAPPERTYPEINFO();
public:
XRPose(std::unique_ptr<TransformationMatrix>, bool);
~XRPose() override = default;
XRRigidTransform* transform() const { return transform_; }
bool emulatedPosition() const { return emulated_position_; }
void Trace(blink::Visitor*) override;
protected:
Member<XRRigidTransform> transform_;
private:
bool emulated_position_;
};
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_MODULES_XR_XR_POSE_H_
// Copyright 2019 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.
// https://immersive-web.github.io/webxr/#xrpose-interface
[
SecureContext,
Exposed=Window,
OriginTrialEnabled=WebXR
] interface XRPose {
readonly attribute XRRigidTransform transform;
readonly attribute boolean emulatedPosition;
};
...@@ -149,9 +149,15 @@ class XRSession final : public EventTargetWithInlineData, ...@@ -149,9 +149,15 @@ class XRSession final : public EventTargetWithInlineData,
void OnPoseReset(); void OnPoseReset();
const device::mojom::blink::VRDisplayInfoPtr& GetVRDisplayInfo() { const device::mojom::blink::VRDisplayInfoPtr& GetVRDisplayInfo() const {
return display_info_; return display_info_;
} }
// TODO(jacde): Update the mojom to deliver this per-frame.
bool EmulatedPosition() const {
return !display_info_->capabilities->hasPosition;
}
bool External() const { return is_external_; } bool External() const { return is_external_; }
// Incremented every time display_info_ is changed, so that other objects that // Incremented every time display_info_ is changed, so that other objects that
// depend on it can know when they need to update. // depend on it can know when they need to update.
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
#include "third_party/blink/renderer/modules/xr/xr_rigid_transform.h" #include "third_party/blink/renderer/modules/xr/xr_rigid_transform.h"
#include "third_party/blink/renderer/modules/xr/xr_session.h" #include "third_party/blink/renderer/modules/xr/xr_session.h"
#include "third_party/blink/renderer/modules/xr/xr_utils.h"
#include "third_party/blink/renderer/modules/xr/xr_view.h" #include "third_party/blink/renderer/modules/xr/xr_view.h"
namespace blink { namespace blink {
...@@ -14,9 +13,7 @@ namespace blink { ...@@ -14,9 +13,7 @@ namespace blink {
XRViewerPose::XRViewerPose( XRViewerPose::XRViewerPose(
XRSession* session, XRSession* session,
std::unique_ptr<TransformationMatrix> pose_model_matrix) std::unique_ptr<TransformationMatrix> pose_model_matrix)
: session_(session), : XRPose(std::move(pose_model_matrix), session->EmulatedPosition()) {
transform_(MakeGarbageCollected<XRRigidTransform>(
std::move(pose_model_matrix))) {
// Can only update views with an invertible matrix. // Can only update views with an invertible matrix.
TransformationMatrix inv_pose_matrix = transform_->InverseMatrix(); TransformationMatrix inv_pose_matrix = transform_->InverseMatrix();
...@@ -30,10 +27,8 @@ XRViewerPose::XRViewerPose( ...@@ -30,10 +27,8 @@ XRViewerPose::XRViewerPose(
} }
void XRViewerPose::Trace(blink::Visitor* visitor) { void XRViewerPose::Trace(blink::Visitor* visitor) {
visitor->Trace(session_);
visitor->Trace(transform_);
visitor->Trace(views_); visitor->Trace(views_);
ScriptWrappable::Trace(visitor); XRPose::Trace(visitor);
} }
} // namespace blink } // namespace blink
...@@ -5,33 +5,27 @@ ...@@ -5,33 +5,27 @@
#ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_XR_XR_VIEWER_POSE_H_ #ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_XR_XR_VIEWER_POSE_H_
#define THIRD_PARTY_BLINK_RENDERER_MODULES_XR_XR_VIEWER_POSE_H_ #define THIRD_PARTY_BLINK_RENDERER_MODULES_XR_XR_VIEWER_POSE_H_
#include <utility> #include "third_party/blink/renderer/modules/xr/xr_pose.h"
#include "third_party/blink/renderer/core/typed_arrays/dom_typed_array.h" #include "third_party/blink/renderer/core/typed_arrays/dom_typed_array.h"
#include "third_party/blink/renderer/platform/bindings/script_wrappable.h"
#include "third_party/blink/renderer/platform/heap/handle.h"
#include "third_party/blink/renderer/platform/transforms/transformation_matrix.h"
namespace blink { namespace blink {
class XRRigidTransform;
class XRSession; class XRSession;
class XRView; class XRView;
class XRViewerPose final : public ScriptWrappable { class XRViewerPose final : public XRPose {
DEFINE_WRAPPERTYPEINFO(); DEFINE_WRAPPERTYPEINFO();
public: public:
XRViewerPose(XRSession*, std::unique_ptr<TransformationMatrix>); XRViewerPose(XRSession*, std::unique_ptr<TransformationMatrix>);
~XRViewerPose() override = default;
XRRigidTransform* transform() const { return transform_; }
const HeapVector<Member<XRView>>& views() const { return views_; } const HeapVector<Member<XRView>>& views() const { return views_; }
void Trace(blink::Visitor*) override; void Trace(blink::Visitor*) override;
private: private:
const Member<XRSession> session_;
Member<XRRigidTransform> transform_;
HeapVector<Member<XRView>> views_; HeapVector<Member<XRView>> views_;
}; };
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
SecureContext, SecureContext,
Exposed=Window, Exposed=Window,
OriginTrialEnabled=WebXR OriginTrialEnabled=WebXR
] interface XRViewerPose { ] interface XRViewerPose : XRPose {
readonly attribute XRRigidTransform transform;
readonly attribute FrozenArray<XRView> views; readonly attribute FrozenArray<XRView> views;
}; };
This is a testharness.js-based test. This is a testharness.js-based test.
Found 214 tests; 188 PASS, 26 FAIL, 0 TIMEOUT, 0 NOTRUN. Found 214 tests; 198 PASS, 16 FAIL, 0 TIMEOUT, 0 NOTRUN.
PASS idl_test setup PASS idl_test setup
PASS Partial interface Navigator: original interface defined PASS Partial interface Navigator: original interface defined
PASS Partial dictionary WebGLContextAttributes: original dictionary defined PASS Partial dictionary WebGLContextAttributes: original dictionary defined
...@@ -133,18 +133,18 @@ PASS XRRay interface: existence and properties of interface prototype object's @ ...@@ -133,18 +133,18 @@ PASS XRRay interface: existence and properties of interface prototype object's @
PASS XRRay interface: attribute origin PASS XRRay interface: attribute origin
PASS XRRay interface: attribute direction PASS XRRay interface: attribute direction
PASS XRRay interface: attribute matrix PASS XRRay interface: attribute matrix
FAIL XRPose interface: existence and properties of interface object assert_own_property: self does not have own property "XRPose" expected property "XRPose" missing PASS XRPose interface: existence and properties of interface object
FAIL XRPose interface object length assert_own_property: self does not have own property "XRPose" expected property "XRPose" missing PASS XRPose interface object length
FAIL XRPose interface object name assert_own_property: self does not have own property "XRPose" expected property "XRPose" missing PASS XRPose interface object name
FAIL XRPose interface: existence and properties of interface prototype object assert_own_property: self does not have own property "XRPose" expected property "XRPose" missing PASS XRPose interface: existence and properties of interface prototype object
FAIL XRPose interface: existence and properties of interface prototype object's "constructor" property assert_own_property: self does not have own property "XRPose" expected property "XRPose" missing PASS XRPose interface: existence and properties of interface prototype object's "constructor" property
FAIL XRPose interface: existence and properties of interface prototype object's @@unscopables property assert_own_property: self does not have own property "XRPose" expected property "XRPose" missing PASS XRPose interface: existence and properties of interface prototype object's @@unscopables property
FAIL XRPose interface: attribute transform assert_own_property: self does not have own property "XRPose" expected property "XRPose" missing PASS XRPose interface: attribute transform
FAIL XRPose interface: attribute emulatedPosition assert_own_property: self does not have own property "XRPose" expected property "XRPose" missing PASS XRPose interface: attribute emulatedPosition
FAIL XRViewerPose interface: existence and properties of interface object assert_own_property: self does not have own property "XRPose" expected property "XRPose" missing PASS XRViewerPose interface: existence and properties of interface object
PASS XRViewerPose interface object length PASS XRViewerPose interface object length
PASS XRViewerPose interface object name PASS XRViewerPose interface object name
FAIL XRViewerPose interface: existence and properties of interface prototype object assert_own_property: self does not have own property "XRPose" expected property "XRPose" missing PASS XRViewerPose interface: existence and properties of interface prototype object
PASS XRViewerPose interface: existence and properties of interface prototype object's "constructor" property PASS XRViewerPose interface: existence and properties of interface prototype object's "constructor" property
PASS XRViewerPose interface: existence and properties of interface prototype object's @@unscopables property PASS XRViewerPose interface: existence and properties of interface prototype object's @@unscopables property
PASS XRViewerPose interface: attribute views PASS XRViewerPose interface: attribute views
......
...@@ -10469,6 +10469,11 @@ interface XRInputSourceEvent : Event ...@@ -10469,6 +10469,11 @@ interface XRInputSourceEvent : Event
interface XRLayer interface XRLayer
attribute @@toStringTag attribute @@toStringTag
method constructor method constructor
interface XRPose
attribute @@toStringTag
getter emulatedPosition
getter transform
method constructor
interface XRPresentationContext interface XRPresentationContext
attribute @@toStringTag attribute @@toStringTag
getter canvas getter canvas
...@@ -10546,9 +10551,8 @@ interface XRView ...@@ -10546,9 +10551,8 @@ interface XRView
getter transform getter transform
getter viewMatrix getter viewMatrix
method constructor method constructor
interface XRViewerPose interface XRViewerPose : XRPose
attribute @@toStringTag attribute @@toStringTag
getter transform
getter views getter views
method constructor method constructor
interface XRViewport interface XRViewport
......
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