Commit 6f98a629 authored by Piotr Bialecki's avatar Piotr Bialecki Committed by Chromium LUCI CQ

ARCore planes: remove unnecessary interfaces

Removes plane detection state, world tracking state and world
information since the general approach of the APIs that we are adding
seems to just add additional entries to XRFrame / XRSession directly,
w/o the layer of indirection. The spec also contains a mechanism of
detecting whether a feature has been enabled through integration with
permissions API - this makes the tracking states unnecessary, since
they were only needed to communicate exactly that.

Change-Id: I36298b05019f87f0de47c992fc29fef987e6e192
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2540575
Commit-Queue: Piotr Bialecki <bialpio@chromium.org>
Reviewed-by: default avatarAlexander Cooper <alcooper@chromium.org>
Cr-Commit-Position: refs/heads/master@{#832015}
parent 18c14a13
......@@ -2197,8 +2197,6 @@ generated_interface_sources_in_modules = [
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_xr_light_probe.h",
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_xr_plane.cc",
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_xr_plane.h",
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_xr_plane_detection_state.cc",
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_xr_plane_detection_state.h",
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_xr_plane_set.cc",
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_xr_plane_set.h",
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_xr_pose.cc",
......@@ -2235,10 +2233,6 @@ generated_interface_sources_in_modules = [
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_xr_webgl_binding.h",
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_xr_webgl_layer.cc",
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_xr_webgl_layer.h",
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_xr_world_information.cc",
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_xr_world_information.h",
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_xr_world_tracking_state.cc",
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_xr_world_tracking_state.h",
]
generated_namespace_sources_in_modules = []
......
......@@ -1001,7 +1001,6 @@ static_idl_files_in_modules = get_path_info(
"//third_party/blink/renderer/modules/xr/xr_light_probe.idl",
"//third_party/blink/renderer/modules/xr/xr_light_probe_init.idl",
"//third_party/blink/renderer/modules/xr/xr_plane.idl",
"//third_party/blink/renderer/modules/xr/xr_plane_detection_state.idl",
"//third_party/blink/renderer/modules/xr/xr_plane_set.idl",
"//third_party/blink/renderer/modules/xr/xr_pose.idl",
"//third_party/blink/renderer/modules/xr/xr_ray.idl",
......@@ -1029,8 +1028,6 @@ static_idl_files_in_modules = get_path_info(
"//third_party/blink/renderer/modules/xr/xr_webgl_context.idl",
"//third_party/blink/renderer/modules/xr/xr_webgl_layer.idl",
"//third_party/blink/renderer/modules/xr/xr_webgl_layer_init.idl",
"//third_party/blink/renderer/modules/xr/xr_world_information.idl",
"//third_party/blink/renderer/modules/xr/xr_world_tracking_state.idl",
],
"abspath")
......
......@@ -56,8 +56,8 @@ blink_modules_sources("xr") {
"xr_object_space.h",
"xr_plane.cc",
"xr_plane.h",
"xr_plane_detection_state.cc",
"xr_plane_detection_state.h",
"xr_plane_manager.cc",
"xr_plane_manager.h",
"xr_plane_set.cc",
"xr_plane_set.h",
"xr_pose.cc",
......@@ -101,10 +101,6 @@ blink_modules_sources("xr") {
"xr_webgl_layer.cc",
"xr_webgl_layer.h",
"xr_webgl_rendering_context.h",
"xr_world_information.cc",
"xr_world_information.h",
"xr_world_tracking_state.cc",
"xr_world_tracking_state.h",
]
deps = [
......
......@@ -20,7 +20,6 @@ modules_idl_files = [
"xr_light_estimate.idl",
"xr_light_probe.idl",
"xr_plane.idl",
"xr_plane_detection_state.idl",
"xr_plane_set.idl",
"xr_pose.idl",
"xr_ray.idl",
......@@ -41,8 +40,6 @@ modules_idl_files = [
"xr_viewport.idl",
"xr_webgl_binding.idl",
"xr_webgl_layer.idl",
"xr_world_information.idl",
"xr_world_tracking_state.idl",
]
modules_callback_function_idl_files = [ "xr_frame_request_callback.idl" ]
......
......@@ -9,12 +9,12 @@
#include "third_party/blink/renderer/modules/xr/xr_input_source.h"
#include "third_party/blink/renderer/modules/xr/xr_light_estimate.h"
#include "third_party/blink/renderer/modules/xr/xr_light_probe.h"
#include "third_party/blink/renderer/modules/xr/xr_plane_set.h"
#include "third_party/blink/renderer/modules/xr/xr_reference_space.h"
#include "third_party/blink/renderer/modules/xr/xr_session.h"
#include "third_party/blink/renderer/modules/xr/xr_transient_input_hit_test_source.h"
#include "third_party/blink/renderer/modules/xr/xr_view.h"
#include "third_party/blink/renderer/modules/xr/xr_viewer_pose.h"
#include "third_party/blink/renderer/modules/xr/xr_world_information.h"
#include "third_party/blink/renderer/platform/bindings/exception_state.h"
namespace blink {
......@@ -46,8 +46,7 @@ const char kCannotObtainNativeOrigin[] =
} // namespace
XRFrame::XRFrame(XRSession* session, XRWorldInformation* world_information)
: world_information_(world_information), session_(session) {}
XRFrame::XRFrame(XRSession* session) : session_(session) {}
XRViewerPose* XRFrame::getViewerPose(XRReferenceSpace* reference_space,
ExceptionState& exception_state) {
......@@ -102,6 +101,27 @@ XRAnchorSet* XRFrame::trackedAnchors() const {
return session_->TrackedAnchors();
}
XRPlaneSet* XRFrame::detectedPlanes(ExceptionState& exception_state) const {
DVLOG(3) << __func__;
if (!session_->IsFeatureEnabled(
device::mojom::XRSessionFeature::PLANE_DETECTION)) {
DVLOG(2) << __func__
<< ": plane detection feature not enabled on a session";
exception_state.ThrowDOMException(DOMExceptionCode::kNotSupportedError,
XRSession::kPlanesFeatureNotSupported);
return {};
}
if (!is_active_) {
exception_state.ThrowDOMException(DOMExceptionCode::kInvalidStateError,
kInactiveFrame);
return nullptr;
}
return session_->GetDetectedPlanes();
}
XRLightEstimate* XRFrame::getLightEstimate(
XRLightProbe* light_probe,
ExceptionState& exception_state) const {
......@@ -354,7 +374,6 @@ HeapVector<Member<XRImageTrackingResult>> XRFrame::getImageTrackingResults(
void XRFrame::Trace(Visitor* visitor) const {
visitor->Trace(session_);
visitor->Trace(world_information_);
ScriptWrappable::Trace(visitor);
}
......
......@@ -26,6 +26,7 @@ class XRImageTrackingResult;
class XRInputSource;
class XRLightEstimate;
class XRLightProbe;
class XRPlaneSet;
class XRPose;
class XRReferenceSpace;
class XRRigidTransform;
......@@ -35,24 +36,23 @@ class XRTransientInputHitTestResult;
class XRTransientInputHitTestSource;
class XRView;
class XRViewerPose;
class XRWorldInformation;
class XRFrame final : public ScriptWrappable {
DEFINE_WRAPPERTYPEINFO();
public:
explicit XRFrame(XRSession* session, XRWorldInformation* world_information);
explicit XRFrame(XRSession* session);
XRSession* session() const { return session_; }
XRViewerPose* getViewerPose(XRReferenceSpace*, ExceptionState&);
XRPose* getPose(XRSpace*, XRSpace*, ExceptionState&);
XRWorldInformation* worldInformation() const { return world_information_; }
XRAnchorSet* trackedAnchors() const;
XRLightEstimate* getLightEstimate(XRLightProbe*, ExceptionState&) const;
XRDepthInformation* getDepthInformation(
XRView* view,
ExceptionState& exception_state) const;
XRPlaneSet* detectedPlanes(ExceptionState& exception_state) const;
void Trace(Visitor*) const override;
......@@ -97,8 +97,6 @@ class XRFrame final : public ScriptWrappable {
XRSpace* space,
ExceptionState& exception_state);
Member<XRWorldInformation> world_information_;
const Member<XRSession> session_;
// Frames are only active during callbacks. getPose and getViewerPose should
......
......@@ -10,10 +10,6 @@
] interface XRFrame {
[SameObject] readonly attribute XRSession session;
// More details about the real-world understanding APIs can be found here:
// https://github.com/immersive-web/real-world-geometry/blob/master/plane-detection-explainer.md
[RuntimeEnabled=WebXRPlaneDetection] readonly attribute XRWorldInformation worldInformation;
[RuntimeEnabled=WebXRAnchors]
readonly attribute XRAnchorSet trackedAnchors;
[RuntimeEnabled=WebXRAnchors, CallWith=ScriptState, RaisesException, MeasureAs=XRFrameCreateAnchor]
......@@ -35,4 +31,9 @@
[RuntimeEnabled=WebXRImageTracking, RaisesException]
FrozenArray<XRImageTrackingResult> getImageTrackingResults();
// More details about the real-world understanding APIs can be found here:
// https://github.com/immersive-web/real-world-geometry/blob/master/plane-detection-explainer.md
[RuntimeEnabled=WebXRPlaneDetection, RaisesException]
readonly attribute XRPlaneSet? detectedPlanes;
};
......@@ -14,12 +14,10 @@
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/imagebitmap/image_bitmap.h"
#include "third_party/blink/renderer/core/loader/document_loader.h"
#include "third_party/blink/renderer/modules/xr/xr_plane_detection_state.h"
#include "third_party/blink/renderer/modules/xr/xr_session.h"
#include "third_party/blink/renderer/modules/xr/xr_system.h"
#include "third_party/blink/renderer/modules/xr/xr_viewport.h"
#include "third_party/blink/renderer/modules/xr/xr_webgl_layer.h"
#include "third_party/blink/renderer/modules/xr/xr_world_tracking_state.h"
#include "third_party/blink/renderer/platform/graphics/gpu/xr_frame_transport.h"
#include "third_party/blink/renderer/platform/instrumentation/tracing/trace_event.h"
#include "third_party/blink/renderer/platform/transforms/transformation_matrix.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.
#include "third_party/blink/renderer/modules/xr/xr_plane_detection_state.h"
namespace blink {
XRPlaneDetectionState::XRPlaneDetectionState(bool enabled)
: enabled_(enabled) {}
} // 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_PLANE_DETECTION_STATE_H_
#define THIRD_PARTY_BLINK_RENDERER_MODULES_XR_XR_PLANE_DETECTION_STATE_H_
#include "third_party/blink/renderer/platform/bindings/script_wrappable.h"
#include "third_party/blink/renderer/platform/bindings/script_wrappable.h"
namespace blink {
class XRPlaneDetectionState : public ScriptWrappable {
DEFINE_WRAPPERTYPEINFO();
public:
explicit XRPlaneDetectionState(bool enabled);
bool enabled() const { return enabled_; }
private:
bool enabled_;
};
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_MODULES_XR_XR_PLANE_DETECTION_STATE_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.
// More details about the plane detection API can be found here:
// https://github.com/immersive-web/real-world-geometry/blob/master/plane-detection-explainer.md
[
SecureContext,
Exposed=Window,
RuntimeEnabled=WebXRPlaneDetection
]
interface XRPlaneDetectionState {
readonly attribute boolean enabled;
};
// Copyright 2019 The Chromium Authors. All rights reserved.
// 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 "third_party/blink/renderer/modules/xr/xr_world_information.h"
#include "third_party/blink/renderer/modules/xr/xr_plane_manager.h"
#include "base/trace_event/trace_event.h"
#include "third_party/blink/renderer/modules/xr/xr_session.h"
#include "third_party/blink/renderer/modules/xr/xr_plane.h"
#include "third_party/blink/renderer/modules/xr/xr_plane_set.h"
namespace blink {
XRWorldInformation::XRWorldInformation(XRSession* session)
XRPlaneManager::XRPlaneManager(base::PassKey<XRSession> pass_key,
XRSession* session)
: session_(session) {}
void XRWorldInformation::Trace(Visitor* visitor) const {
visitor->Trace(plane_ids_to_planes_);
visitor->Trace(session_);
ScriptWrappable::Trace(visitor);
}
XRPlaneSet* XRWorldInformation::detectedPlanes() const {
DVLOG(3) << __func__;
HeapHashSet<Member<XRPlane>> result;
if (is_detected_planes_null_)
return nullptr;
for (auto& plane_id_and_plane : plane_ids_to_planes_) {
result.insert(plane_id_and_plane.value);
}
return MakeGarbageCollected<XRPlaneSet>(result);
}
void XRWorldInformation::ProcessPlaneInformation(
void XRPlaneManager::ProcessPlaneInformation(
const device::mojom::blink::XRPlaneDetectionData* detected_planes_data,
double timestamp) {
TRACE_EVENT0("xr", __FUNCTION__);
......@@ -79,11 +60,10 @@ void XRWorldInformation::ProcessPlaneInformation(
// Then, copy over the planes that were not updated but are still present.
for (const auto& plane_id : detected_planes_data->all_planes_ids) {
auto it_updated = updated_planes.find(plane_id);
// If the plane was already updated, there is nothing to do as it was
// already moved to |updated_planes|. Otherwise just copy it over as-is.
if (it_updated == updated_planes.end()) {
// already moved to |updated_planes|. If it's not updated, just copy it over
// as-is.
if (!base::Contains(updated_planes, plane_id)) {
auto it = plane_ids_to_planes_.find(plane_id);
DCHECK(it != plane_ids_to_planes_.end());
updated_planes.insert(plane_id, it->value);
......@@ -93,4 +73,21 @@ void XRWorldInformation::ProcessPlaneInformation(
plane_ids_to_planes_.swap(updated_planes);
}
XRPlaneSet* XRPlaneManager::GetDetectedPlanes() const {
if (is_detected_planes_null_)
return nullptr;
HeapHashSet<Member<XRPlane>> result;
for (auto& plane_id_and_plane : plane_ids_to_planes_) {
result.insert(plane_id_and_plane.value);
}
return MakeGarbageCollected<XRPlaneSet>(result);
}
void XRPlaneManager::Trace(Visitor* visitor) const {
visitor->Trace(session_);
visitor->Trace(plane_ids_to_planes_);
}
} // namespace blink
// 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 THIRD_PARTY_BLINK_RENDERER_MODULES_XR_XR_PLANE_MANAGER_H_
#define THIRD_PARTY_BLINK_RENDERER_MODULES_XR_XR_PLANE_MANAGER_H_
#include "base/types/pass_key.h"
#include "third_party/blink/renderer/modules/xr/xr_session.h"
#include "third_party/blink/renderer/platform/heap/handle.h"
namespace blink {
class XRPlaneSet;
// Helper class, used to separate the code related to plane processing out of
// XRSession.
class XRPlaneManager : public GarbageCollected<XRPlaneManager> {
public:
explicit XRPlaneManager(base::PassKey<XRSession> pass_key,
XRSession* session);
void ProcessPlaneInformation(
const device::mojom::blink::XRPlaneDetectionData* detected_planes_data,
double timestamp);
XRPlaneSet* GetDetectedPlanes() const;
void Trace(Visitor* visitor) const;
private:
Member<XRSession> session_;
bool is_detected_planes_null_ = true;
HeapHashMap<uint64_t, Member<XRPlane>> plane_ids_to_planes_;
};
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_MODULES_XR_XR_PLANE_MANAGER_H_
......@@ -13,6 +13,7 @@
#include "base/auto_reset.h"
#include "base/metrics/histogram_macros.h"
#include "base/numerics/ranges.h"
#include "base/types/pass_key.h"
#include "services/metrics/public/cpp/ukm_builders.h"
#include "third_party/blink/renderer/bindings/core/v8/script_promise_resolver.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_xr_frame_request_callback.h"
......@@ -40,7 +41,7 @@
#include "third_party/blink/renderer/modules/xr/xr_input_source_event.h"
#include "third_party/blink/renderer/modules/xr/xr_input_sources_change_event.h"
#include "third_party/blink/renderer/modules/xr/xr_light_probe.h"
#include "third_party/blink/renderer/modules/xr/xr_plane.h"
#include "third_party/blink/renderer/modules/xr/xr_plane_manager.h"
#include "third_party/blink/renderer/modules/xr/xr_ray.h"
#include "third_party/blink/renderer/modules/xr/xr_reference_space.h"
#include "third_party/blink/renderer/modules/xr/xr_render_state.h"
......@@ -51,8 +52,6 @@
#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_webgl_layer.h"
#include "third_party/blink/renderer/modules/xr/xr_world_information.h"
#include "third_party/blink/renderer/modules/xr/xr_world_tracking_state.h"
#include "third_party/blink/renderer/platform/bindings/enumeration_base.h"
#include "third_party/blink/renderer/platform/bindings/v8_throw_exception.h"
#include "third_party/blink/renderer/platform/geometry/float_point_3d.h"
......@@ -241,6 +240,7 @@ constexpr char XRSession::kNoRigidTransformSpecified[];
constexpr char XRSession::kUnableToRetrieveMatrix[];
constexpr char XRSession::kNoSpaceSpecified[];
constexpr char XRSession::kAnchorsFeatureNotSupported[];
constexpr char XRSession::kPlanesFeatureNotSupported[];
class XRSession::XRSessionResizeObserverDelegate final
: public ResizeObserver::Delegate {
......@@ -322,8 +322,10 @@ XRSession::XRSession(
mode_(mode),
environment_integration_(
mode == device::mojom::blink::XRSessionMode::kImmersiveAr),
world_information_(MakeGarbageCollected<XRWorldInformation>(this)),
enabled_features_(std::move(enabled_features)),
plane_manager_(
MakeGarbageCollected<XRPlaneManager>(base::PassKey<XRSession>{},
this)),
input_sources_(MakeGarbageCollected<XRInputSourceArray>()),
client_receiver_(this, xr->GetExecutionContext()),
input_receiver_(this, xr->GetExecutionContext()),
......@@ -347,9 +349,6 @@ XRSession::XRSession(
device_config->default_framebuffer_scale, kMinDefaultFramebufferScale,
kMaxDefaultFramebufferScale);
world_tracking_state_ = MakeGarbageCollected<XRWorldTrackingState>(
IsFeatureEnabled(device::mojom::XRSessionFeature::PLANE_DETECTION));
DVLOG(2) << __func__
<< ": supports_viewport_scaling_=" << supports_viewport_scaling_;
......@@ -1123,6 +1122,16 @@ void XRSession::ProcessAnchorsData(
<< " anchors that have not been updated";
}
void XRSession::ProcessPlaneInformation(
const device::mojom::blink::XRPlaneDetectionData* detected_planes_data,
double timestamp) {
plane_manager_->ProcessPlaneInformation(detected_planes_data, timestamp);
}
XRPlaneSet* XRSession::GetDetectedPlanes() const {
return plane_manager_->GetDetectedPlanes();
}
void XRSession::CleanUpUnusedHitTestSources() {
auto unused_hit_test_source_ids = GetIdsOfUnusedHitTestSources(
hit_test_source_ids_to_hit_test_sources_, hit_test_source_ids_);
......@@ -1747,8 +1756,7 @@ void XRSession::UpdateWorldUnderstandingStateForFrame(
const device::mojom::blink::XRFrameDataPtr& frame_data) {
// Update objects that might change on per-frame basis.
if (frame_data) {
world_information_->ProcessPlaneInformation(
frame_data->detected_planes_data.get(), timestamp);
ProcessPlaneInformation(frame_data->detected_planes_data.get(), timestamp);
ProcessAnchorsData(frame_data->anchors_data.get(), timestamp);
ProcessHitTestData(frame_data->hit_test_subscription_results.get());
ProcessDepthData(std::move(frame_data->depth_data));
......@@ -1760,7 +1768,7 @@ void XRSession::UpdateWorldUnderstandingStateForFrame(
world_light_probe_->ProcessLightEstimationData(light_data, timestamp);
}
} else {
world_information_->ProcessPlaneInformation(nullptr, timestamp);
ProcessPlaneInformation(nullptr, timestamp);
ProcessAnchorsData(nullptr, timestamp);
ProcessHitTestData(nullptr);
ProcessDepthData(nullptr);
......@@ -1936,8 +1944,7 @@ base::Optional<TransformationMatrix> XRSession::GetMojoFrom(
XRFrame* XRSession::CreatePresentationFrame() {
DVLOG(2) << __func__;
XRFrame* presentation_frame =
MakeGarbageCollected<XRFrame>(this, world_information_);
XRFrame* presentation_frame = MakeGarbageCollected<XRFrame>(this);
return presentation_frame;
}
......@@ -2287,8 +2294,6 @@ bool XRSession::HasPendingActivity() const {
void XRSession::Trace(Visitor* visitor) const {
visitor->Trace(xr_);
visitor->Trace(render_state_);
visitor->Trace(world_tracking_state_);
visitor->Trace(world_information_);
visitor->Trace(world_light_probe_);
visitor->Trace(pending_render_state_);
visitor->Trace(end_session_resolver_);
......@@ -2303,6 +2308,7 @@ void XRSession::Trace(Visitor* visitor) const {
visitor->Trace(create_anchor_promises_);
visitor->Trace(request_hit_test_source_promises_);
visitor->Trace(reference_spaces_);
visitor->Trace(plane_manager_);
visitor->Trace(anchor_ids_to_anchors_);
visitor->Trace(anchor_ids_to_pending_anchor_promises_);
visitor->Trace(prev_base_layer_);
......
......@@ -48,6 +48,8 @@ class XRHitTestOptionsInit;
class XRHitTestSource;
class XRImageTrackingResult;
class XRLightProbe;
class XRPlaneSet;
class XRPlaneManager;
class XRReferenceSpace;
class XRRenderState;
class XRRenderStateInit;
......@@ -58,8 +60,6 @@ class XRTransientInputHitTestOptionsInit;
class XRTransientInputHitTestSource;
class XRViewData;
class XRWebGLLayer;
class XRWorldInformation;
class XRWorldTrackingState;
using XRSessionFeatureSet = HashSet<device::mojom::XRSessionFeature>;
......@@ -80,6 +80,8 @@ class XRSession final
static constexpr char kNoSpaceSpecified[] = "No XRSpace specified.";
static constexpr char kAnchorsFeatureNotSupported[] =
"Anchors feature is not supported by the session.";
static constexpr char kPlanesFeatureNotSupported[] =
"Plane detection feature is not supported by the session.";
// Runs all the video.requestVideoFrameCallback() callbacks associated with
// one HTMLVideoElement. |double| is the |high_res_now_ms|, derived from
......@@ -122,7 +124,6 @@ class XRSession final
XRDOMOverlayState* domOverlayState() const { return dom_overlay_state_; }
const String visibilityState() const;
XRRenderState* renderState() const { return render_state_; }
XRWorldTrackingState* worldTrackingState() { return world_tracking_state_; }
// ARCore by default returns textures in RGBA half-float HDR format and no
// other runtimes support reflection mapping, so just return this until we
......@@ -337,6 +338,8 @@ class XRSession final
XRDepthInformation* GetDepthInformation() const;
XRPlaneSet* GetDetectedPlanes() const;
// Creates presentation frame based on current state of the session.
// State currently used in XRFrame creation is mojo_from_viewer_ and
// world_information_. The created XRFrame also stores a reference to this
......@@ -430,6 +433,10 @@ class XRSession final
const device::mojom::blink::XRAnchorsData* tracked_anchors_data,
double timestamp);
void ProcessPlaneInformation(
const device::mojom::blink::XRPlaneDetectionData* detected_planes_data,
double timestamp);
void CleanUpUnusedHitTestSources();
void ProcessHitTestData(
......@@ -458,8 +465,7 @@ class XRSession final
XRVisibilityState visibility_state_ = XRVisibilityState::VISIBLE;
String visibility_state_string_;
Member<XRRenderState> render_state_;
Member<XRWorldTrackingState> world_tracking_state_;
Member<XRWorldInformation> world_information_;
Member<XRLightProbe> world_light_probe_;
HeapVector<Member<XRRenderStateInit>> pending_render_state_;
......@@ -534,6 +540,8 @@ class XRSession final
HashSet<uint64_t> hit_test_source_ids_;
HashSet<uint64_t> hit_test_source_for_transient_input_ids_;
Member<XRPlaneManager> plane_manager_;
uint32_t view_parameters_id_ = 0;
HeapVector<Member<XRViewData>> views_;
Vector<device::mojom::blink::VREyeParametersPtr> pending_view_parameters_;
......
......@@ -68,9 +68,6 @@ enum XRReflectionFormat {
long requestAnimationFrame(XRFrameRequestCallback callback);
void cancelAnimationFrame(long handle);
// https://github.com/immersive-web/real-world-geometry/blob/master/plane-detection-explainer.md
[RuntimeEnabled=WebXRPlaneDetection] readonly attribute XRWorldTrackingState worldTrackingState;
[CallWith=ScriptState, Measure, RaisesException] Promise<void> end();
// https://github.com/immersive-web/hit-test/blob/master/hit-testing-explainer.md
......
// 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_WORLD_INFORMATION_H_
#define THIRD_PARTY_BLINK_RENDERER_MODULES_XR_XR_WORLD_INFORMATION_H_
#include "device/vr/public/mojom/vr_service.mojom-blink-forward.h"
#include "third_party/blink/renderer/modules/xr/xr_plane.h"
#include "third_party/blink/renderer/modules/xr/xr_plane_set.h"
namespace blink {
class XRSession;
class XRWorldInformation : public ScriptWrappable {
DEFINE_WRAPPERTYPEINFO();
public:
XRWorldInformation(XRSession* session);
// Returns set of detected planes. Returns null if plane detection is
// disabled.
XRPlaneSet* detectedPlanes() const;
void Trace(Visitor* visitor) const override;
// Applies changes to the stored plane information based on the contents of
// the received frame data. This will update the contents of
// plane_ids_to_planes_.
void ProcessPlaneInformation(
const device::mojom::blink::XRPlaneDetectionData* detected_planes_data,
double timestamp);
private:
// Signifies if we should return null from `detectedPlanes()`.
// This is the case if we have a freshly constructed instance, or if our
// last `ProcessPlaneInformation()` was called with base::nullopt.
bool is_detected_planes_null_ = true;
HeapHashMap<uint64_t, Member<XRPlane>> plane_ids_to_planes_;
Member<XRSession> session_;
};
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_MODULES_XR_XR_WORLD_INFORMATION_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.
// More details about the real-world understanding APIs can be found here:
// https://github.com/immersive-web/real-world-geometry/blob/master/plane-detection-explainer.md
[
SecureContext,
Exposed=Window,
RuntimeEnabled=WebXRPlaneDetection
]
interface XRWorldInformation {
readonly attribute XRPlaneSet? detectedPlanes;
};
// 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_world_tracking_state.h"
#include "third_party/blink/renderer/modules/xr/xr_plane_detection_state.h"
namespace blink {
XRWorldTrackingState::XRWorldTrackingState(bool plane_detection_enabled)
: plane_detection_state_(MakeGarbageCollected<XRPlaneDetectionState>(
plane_detection_enabled)) {}
void XRWorldTrackingState::Trace(Visitor* visitor) const {
visitor->Trace(plane_detection_state_);
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_WORLD_TRACKING_STATE_H_
#define THIRD_PARTY_BLINK_RENDERER_MODULES_XR_XR_WORLD_TRACKING_STATE_H_
#include "third_party/blink/renderer/platform/bindings/script_wrappable.h"
#include "third_party/blink/renderer/platform/heap/handle.h"
namespace blink {
class XRPlaneDetectionState;
class XRWorldTrackingState : public ScriptWrappable {
DEFINE_WRAPPERTYPEINFO();
public:
explicit XRWorldTrackingState(bool plane_detection_enabled);
XRPlaneDetectionState* planeDetectionState() const {
return plane_detection_state_;
}
void Trace(Visitor* visitor) const override;
private:
Member<XRPlaneDetectionState> plane_detection_state_;
};
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_MODULES_XR_XR_WORLD_TRACKING_STATE_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.
// More details about the real-world understanding APIs can be found here:
// https://github.com/immersive-web/real-world-geometry/blob/master/plane-detection-explainer.md
[
SecureContext,
Exposed=Window,
RuntimeEnabled=WebXRPlaneDetection
]
interface XRWorldTrackingState {
readonly attribute XRPlaneDetectionState planeDetectionState;
};
......@@ -10446,9 +10446,9 @@ interface XRDepthInformation
method getDepth
interface XRFrame
attribute @@toStringTag
getter detectedPlanes
getter session
getter trackedAnchors
getter worldInformation
method constructor
method createAnchor
method getDepthInformation
......@@ -10526,10 +10526,6 @@ interface XRPlane
getter polygon
method constructor
method createAnchor
interface XRPlaneDetectionState
attribute @@toStringTag
getter enabled
method constructor
interface XRPlaneSet
attribute @@toStringTag
getter size
......@@ -10594,7 +10590,6 @@ interface XRSession : EventTarget
getter preferredReflectionFormat
getter renderState
getter visibilityState
getter worldTrackingState
method cancelAnimationFrame
method constructor
method end
......@@ -10674,14 +10669,6 @@ interface XRWebGLLayer : XRLayer
getter ignoreDepthValues
method constructor
method getViewport
interface XRWorldInformation
attribute @@toStringTag
getter detectedPlanes
method constructor
interface XRWorldTrackingState
attribute @@toStringTag
getter planeDetectionState
method constructor
interface XSLTProcessor
attribute @@toStringTag
method clearParameters
......
......@@ -179,7 +179,7 @@ function hitTestPlane(frame, ray, plane, frameOfReference) {
// multiple planes hit test
export function hitTest(frame, ray, frameOfReference) {
const planes = frame.worldInformation.detectedPlanes;
const planes = frame.detectedPlanes;
let hit_test_results = [];
planes.forEach(plane => {
......
......@@ -365,7 +365,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
new XRRigidTransform(arObject.hitPoint),
arObject.space);
} else {
if(!event.frame.worldInformation.detectedPlanes) {
if(!event.frame.detectedPlanes) {
console.log("No planes detected, placing an anchor at origin.");
addARObjectAt(event.frame,
null,
......@@ -374,7 +374,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
return;
}
console.log("Detected some planes, length:", event.frame.worldInformation.detectedPlanes.length);
console.log("Detected some planes, length:", event.frame.detectedPlanes.length);
// Otherwise we'll use the target ray from the input source that generated
// this event to fire off a new hit test.
......@@ -494,7 +494,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
let pose = frame.getViewerPose(xrRefSpace);
let detected_planes = frame.worldInformation.detectedPlanes;
let detected_planes = frame.detectedPlanes;
// Check if any of the old planes is no longer present in detected planes set.
// If it's no longer present, it was removed - clean up after.
......
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