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 =
"xr/xr_input_source.idl",
"xr/xr_input_source_event.idl",
"xr/xr_layer.idl",
"xr/xr_pose.idl",
"xr/xr_presentation_context.idl",
"xr/xr_ray.idl",
"xr/xr_reference_space.idl",
......
......@@ -28,6 +28,8 @@ blink_modules_sources("xr") {
"xr_input_source_event.h",
"xr_layer.cc",
"xr_layer.h",
"xr_pose.cc",
"xr_pose.h",
"xr_presentation_context.cc",
"xr_presentation_context.h",
"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,
void OnPoseReset();
const device::mojom::blink::VRDisplayInfoPtr& GetVRDisplayInfo() {
const device::mojom::blink::VRDisplayInfoPtr& GetVRDisplayInfo() const {
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_; }
// Incremented every time display_info_ is changed, so that other objects that
// depend on it can know when they need to update.
......
......@@ -6,7 +6,6 @@
#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_utils.h"
#include "third_party/blink/renderer/modules/xr/xr_view.h"
namespace blink {
......@@ -14,9 +13,7 @@ namespace blink {
XRViewerPose::XRViewerPose(
XRSession* session,
std::unique_ptr<TransformationMatrix> pose_model_matrix)
: session_(session),
transform_(MakeGarbageCollected<XRRigidTransform>(
std::move(pose_model_matrix))) {
: XRPose(std::move(pose_model_matrix), session->EmulatedPosition()) {
// Can only update views with an invertible matrix.
TransformationMatrix inv_pose_matrix = transform_->InverseMatrix();
......@@ -30,10 +27,8 @@ XRViewerPose::XRViewerPose(
}
void XRViewerPose::Trace(blink::Visitor* visitor) {
visitor->Trace(session_);
visitor->Trace(transform_);
visitor->Trace(views_);
ScriptWrappable::Trace(visitor);
XRPose::Trace(visitor);
}
} // namespace blink
......@@ -5,33 +5,27 @@
#ifndef 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/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 XRSession;
class XRView;
class XRViewerPose final : public ScriptWrappable {
class XRViewerPose final : public XRPose {
DEFINE_WRAPPERTYPEINFO();
public:
XRViewerPose(XRSession*, std::unique_ptr<TransformationMatrix>);
~XRViewerPose() override = default;
XRRigidTransform* transform() const { return transform_; }
const HeapVector<Member<XRView>>& views() const { return views_; }
void Trace(blink::Visitor*) override;
private:
const Member<XRSession> session_;
Member<XRRigidTransform> transform_;
HeapVector<Member<XRView>> views_;
};
......
......@@ -8,7 +8,6 @@
SecureContext,
Exposed=Window,
OriginTrialEnabled=WebXR
] interface XRViewerPose {
readonly attribute XRRigidTransform transform;
] interface XRViewerPose : XRPose {
readonly attribute FrozenArray<XRView> views;
};
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 Partial interface Navigator: original interface defined
PASS Partial dictionary WebGLContextAttributes: original dictionary defined
......@@ -133,18 +133,18 @@ PASS XRRay interface: existence and properties of interface prototype object's @
PASS XRRay interface: attribute origin
PASS XRRay interface: attribute direction
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
FAIL XRPose interface object length assert_own_property: self does not have own property "XRPose" expected property "XRPose" missing
FAIL XRPose interface object name assert_own_property: self does not have own property "XRPose" expected property "XRPose" missing
FAIL XRPose interface: existence and properties of interface prototype object assert_own_property: self does not have own property "XRPose" expected property "XRPose" missing
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
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
FAIL XRPose interface: attribute transform assert_own_property: self does not have own property "XRPose" expected property "XRPose" missing
FAIL XRPose interface: attribute emulatedPosition assert_own_property: self does not have own property "XRPose" expected property "XRPose" missing
FAIL XRViewerPose 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
PASS XRPose interface object length
PASS XRPose interface object name
PASS XRPose interface: existence and properties of interface prototype object
PASS XRPose interface: existence and properties of interface prototype object's "constructor" property
PASS XRPose interface: existence and properties of interface prototype object's @@unscopables property
PASS XRPose interface: attribute transform
PASS XRPose interface: attribute emulatedPosition
PASS XRViewerPose interface: existence and properties of interface object
PASS XRViewerPose interface object length
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 @@unscopables property
PASS XRViewerPose interface: attribute views
......
......@@ -10469,6 +10469,11 @@ interface XRInputSourceEvent : Event
interface XRLayer
attribute @@toStringTag
method constructor
interface XRPose
attribute @@toStringTag
getter emulatedPosition
getter transform
method constructor
interface XRPresentationContext
attribute @@toStringTag
getter canvas
......@@ -10546,9 +10551,8 @@ interface XRView
getter transform
getter viewMatrix
method constructor
interface XRViewerPose
interface XRViewerPose : XRPose
attribute @@toStringTag
getter transform
getter views
method constructor
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