Commit 9da03c10 authored by Piotr Bialecki's avatar Piotr Bialecki Committed by Commit Bot

Remove hit test options from hit test source and hit test result

Hit test options are redundant on XRHitTestSource since hit test source
can only be created by passing XRHitTestOptionsInit.

Change-Id: I13f2a5d398a8c524d967bee14a7a20025b222c39
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1907708
Commit-Queue: Piotr Bialecki <bialpio@chromium.org>
Reviewed-by: default avatarKlaus Weidner <klausw@chromium.org>
Reviewed-by: default avatarMounir Lamouri <mlamouri@chromium.org>
Cr-Commit-Position: refs/heads/master@{#714599}
parent e9925c47
...@@ -524,7 +524,6 @@ modules_idl_files = ...@@ -524,7 +524,6 @@ modules_idl_files =
"xr/xr_reference_space_event.idl", "xr/xr_reference_space_event.idl",
"xr/xr_render_state.idl", "xr/xr_render_state.idl",
"xr/xr_rigid_transform.idl", "xr/xr_rigid_transform.idl",
"xr/xr_hit_test_options.idl",
"xr/xr_hit_test_result.idl", "xr/xr_hit_test_result.idl",
"xr/xr_hit_test_source.idl", "xr/xr_hit_test_source.idl",
"xr/xr_session.idl", "xr/xr_session.idl",
......
...@@ -30,8 +30,6 @@ blink_modules_sources("xr") { ...@@ -30,8 +30,6 @@ blink_modules_sources("xr") {
"xr_grip_space.h", "xr_grip_space.h",
"xr_hit_result.cc", "xr_hit_result.cc",
"xr_hit_result.h", "xr_hit_result.h",
"xr_hit_test_options.cc",
"xr_hit_test_options.h",
"xr_hit_test_result.cc", "xr_hit_test_result.cc",
"xr_hit_test_result.h", "xr_hit_test_result.h",
"xr_hit_test_source.cc", "xr_hit_test_source.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_hit_test_options.h"
#include "third_party/blink/renderer/modules/xr/xr_hit_test_options_init.h"
#include "third_party/blink/renderer/modules/xr/xr_ray.h"
#include "third_party/blink/renderer/modules/xr/xr_space.h"
namespace blink {
XRHitTestOptions::XRHitTestOptions(XRHitTestOptionsInit* options_init) {
DCHECK(options_init);
space_ = options_init->space();
if (options_init->hasOffsetRay()) {
ray_ = options_init->offsetRay();
} else {
ray_ = MakeGarbageCollected<XRRay>();
}
}
void XRHitTestOptions::Trace(blink::Visitor* visitor) {
visitor->Trace(space_);
visitor->Trace(ray_);
ScriptWrappable::Trace(visitor);
}
XRSpace* XRHitTestOptions::space() const {
return space_;
}
XRRay* XRHitTestOptions::offsetRay() const {
return ray_;
}
} // 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_HIT_TEST_OPTIONS_H_
#define THIRD_PARTY_BLINK_RENDERER_MODULES_XR_XR_HIT_TEST_OPTIONS_H_
#include "third_party/blink/renderer/platform/bindings/script_wrappable.h"
namespace blink {
class XRRay;
class XRSpace;
class XRHitTestOptionsInit;
class XRHitTestOptions : public ScriptWrappable {
DEFINE_WRAPPERTYPEINFO();
public:
explicit XRHitTestOptions(XRHitTestOptionsInit* options_init);
XRSpace* space() const;
XRRay* offsetRay() const;
void Trace(blink::Visitor* visitor) override;
private:
Member<XRSpace> space_;
Member<XRRay> ray_;
};
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_MODULES_XR_XR_HIT_TEST_OPTIONS_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.
[SecureContext, Exposed=Window, RuntimeEnabled=WebXRHitTest]
interface XRHitTestOptions {
readonly attribute XRSpace space;
readonly attribute XRRay offsetRay;
};
...@@ -15,10 +15,6 @@ XRHitTestResult::XRHitTestResult(XRHitTestSource* hit_test_source, ...@@ -15,10 +15,6 @@ XRHitTestResult::XRHitTestResult(XRHitTestSource* hit_test_source,
: hit_test_source_(hit_test_source), : hit_test_source_(hit_test_source),
pose_(std::make_unique<TransformationMatrix>(pose)) {} pose_(std::make_unique<TransformationMatrix>(pose)) {}
XRHitTestOptions* XRHitTestResult::hitTestOptions() const {
return hit_test_source_->hitTestOptions();
}
XRPose* XRHitTestResult::getPose(XRSpace* relative_to) { XRPose* XRHitTestResult::getPose(XRSpace* relative_to) {
DCHECK(relative_to->MojoFromSpace()); DCHECK(relative_to->MojoFromSpace());
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
namespace blink { namespace blink {
class TransformationMatrix; class TransformationMatrix;
class XRHitTestOptions;
class XRHitTestSource; class XRHitTestSource;
class XRPose; class XRPose;
class XRSpace; class XRSpace;
...@@ -22,8 +21,6 @@ class XRHitTestResult : public ScriptWrappable { ...@@ -22,8 +21,6 @@ class XRHitTestResult : public ScriptWrappable {
XRHitTestResult(XRHitTestSource* hit_test_source, XRHitTestResult(XRHitTestSource* hit_test_source,
const TransformationMatrix& pose); const TransformationMatrix& pose);
XRHitTestOptions* hitTestOptions() const;
XRPose* getPose(XRSpace* relative_to); XRPose* getPose(XRSpace* relative_to);
void Trace(blink::Visitor* visitor) override; void Trace(blink::Visitor* visitor) override;
......
...@@ -4,7 +4,5 @@ ...@@ -4,7 +4,5 @@
[SecureContext, Exposed=Window, RuntimeEnabled=WebXRHitTest] [SecureContext, Exposed=Window, RuntimeEnabled=WebXRHitTest]
interface XRHitTestResult { interface XRHitTestResult {
readonly attribute XRHitTestOptions hitTestOptions;
XRPose? getPose(XRSpace relative_to); XRPose? getPose(XRSpace relative_to);
}; };
...@@ -5,22 +5,16 @@ ...@@ -5,22 +5,16 @@
#include "third_party/blink/renderer/modules/xr/xr_hit_test_source.h" #include "third_party/blink/renderer/modules/xr/xr_hit_test_source.h"
#include "device/vr/public/mojom/vr_service.mojom-blink.h" #include "device/vr/public/mojom/vr_service.mojom-blink.h"
#include "third_party/blink/renderer/modules/xr/xr_hit_test_options.h"
#include "third_party/blink/renderer/modules/xr/xr_hit_test_result.h" #include "third_party/blink/renderer/modules/xr/xr_hit_test_result.h"
namespace blink { namespace blink {
XRHitTestSource::XRHitTestSource(uint64_t id, XRHitTestOptions* options) XRHitTestSource::XRHitTestSource(uint64_t id) : id_(id) {}
: id_(id), options_(options) {}
uint64_t XRHitTestSource::id() const { uint64_t XRHitTestSource::id() const {
return id_; return id_;
} }
XRHitTestOptions* XRHitTestSource::hitTestOptions() const {
return options_;
}
HeapVector<Member<XRHitTestResult>> XRHitTestSource::Results() { HeapVector<Member<XRHitTestResult>> XRHitTestSource::Results() {
HeapVector<Member<XRHitTestResult>> results; HeapVector<Member<XRHitTestResult>> results;
...@@ -41,9 +35,4 @@ void XRHitTestSource::Update( ...@@ -41,9 +35,4 @@ void XRHitTestSource::Update(
} }
} }
void XRHitTestSource::Trace(blink::Visitor* visitor) {
visitor->Trace(options_);
ScriptWrappable::Trace(visitor);
}
} // namespace blink } // namespace blink
...@@ -14,19 +14,16 @@ ...@@ -14,19 +14,16 @@
namespace blink { namespace blink {
class XRHitTestOptions;
class XRHitTestResult; class XRHitTestResult;
class XRHitTestSource : public ScriptWrappable { class XRHitTestSource : public ScriptWrappable {
DEFINE_WRAPPERTYPEINFO(); DEFINE_WRAPPERTYPEINFO();
public: public:
XRHitTestSource(uint64_t id, XRHitTestOptions* options); explicit XRHitTestSource(uint64_t id);
uint64_t id() const; uint64_t id() const;
XRHitTestOptions* hitTestOptions() const;
// Returns a vector of XRHitTestResults that were obtained during last frame // Returns a vector of XRHitTestResults that were obtained during last frame
// update. This method is not exposed to JavaScript. // update. This method is not exposed to JavaScript.
HeapVector<Member<XRHitTestResult>> Results(); HeapVector<Member<XRHitTestResult>> Results();
...@@ -34,13 +31,9 @@ class XRHitTestSource : public ScriptWrappable { ...@@ -34,13 +31,9 @@ class XRHitTestSource : public ScriptWrappable {
void Update(const WTF::Vector<device::mojom::blink::XRHitResultPtr>& void Update(const WTF::Vector<device::mojom::blink::XRHitResultPtr>&
hit_test_results); hit_test_results);
void Trace(blink::Visitor*) override;
private: private:
const uint64_t id_; const uint64_t id_;
Member<XRHitTestOptions> options_;
Vector<std::unique_ptr<TransformationMatrix>> last_frame_results_; Vector<std::unique_ptr<TransformationMatrix>> last_frame_results_;
}; };
......
...@@ -4,5 +4,4 @@ ...@@ -4,5 +4,4 @@
[SecureContext, Exposed=Window, RuntimeEnabled=WebXRHitTest] [SecureContext, Exposed=Window, RuntimeEnabled=WebXRHitTest]
interface XRHitTestSource { interface XRHitTestSource {
readonly attribute XRHitTestOptions hitTestOptions;
}; };
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
#include "third_party/blink/renderer/modules/xr/xr_frame.h" #include "third_party/blink/renderer/modules/xr/xr_frame.h"
#include "third_party/blink/renderer/modules/xr/xr_frame_provider.h" #include "third_party/blink/renderer/modules/xr/xr_frame_provider.h"
#include "third_party/blink/renderer/modules/xr/xr_hit_result.h" #include "third_party/blink/renderer/modules/xr/xr_hit_result.h"
#include "third_party/blink/renderer/modules/xr/xr_hit_test_options.h" #include "third_party/blink/renderer/modules/xr/xr_hit_test_options_init.h"
#include "third_party/blink/renderer/modules/xr/xr_hit_test_source.h" #include "third_party/blink/renderer/modules/xr/xr_hit_test_source.h"
#include "third_party/blink/renderer/modules/xr/xr_input_source_event.h" #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_input_sources_change_event.h"
...@@ -631,12 +631,11 @@ ScriptPromise XRSession::requestHitTestSource( ...@@ -631,12 +631,11 @@ ScriptPromise XRSession::requestHitTestSource(
DCHECK(options_init); // is this enforced by generated bindings? DCHECK(options_init); // is this enforced by generated bindings?
XRHitTestOptions* options =
MakeGarbageCollected<XRHitTestOptions>(options_init);
// 1. Grab the native origin from the passed in XRSpace. // 1. Grab the native origin from the passed in XRSpace.
base::Optional<XRNativeOriginInformation> maybe_native_origin = base::Optional<XRNativeOriginInformation> maybe_native_origin =
options->space()->NativeOrigin(); options_init && options_init->hasSpace()
? options_init->space()->NativeOrigin()
: base::nullopt;
if (!maybe_native_origin) { if (!maybe_native_origin) {
exception_state.ThrowDOMException(DOMExceptionCode::kInvalidStateError, exception_state.ThrowDOMException(DOMExceptionCode::kInvalidStateError,
...@@ -648,13 +647,20 @@ ScriptPromise XRSession::requestHitTestSource( ...@@ -648,13 +647,20 @@ ScriptPromise XRSession::requestHitTestSource(
// should only matter for spaces whose transforms are not fully known on the // should only matter for spaces whose transforms are not fully known on the
// device (for example any space containing origin-offset). // device (for example any space containing origin-offset).
TransformationMatrix origin_from_space = TransformationMatrix origin_from_space =
options->space()->OriginOffsetMatrix(); options_init->space()
->OriginOffsetMatrix(); // Null checks not needed since native origin
// wouldn't be set if options_init or space()
// were null.
DVLOG(3) << __func__ DVLOG(3) << __func__
<< ": origin_from_space = " << origin_from_space.ToString(true); << ": origin_from_space = " << origin_from_space.ToString(true);
// Transformation from passed in pose to |space|. // Transformation from passed in pose to |space|.
auto space_from_ray = options->offsetRay()->RawMatrix();
XRRay* offsetRay = options_init && options_init->hasOffsetRay()
? options_init->offsetRay()
: MakeGarbageCollected<XRRay>();
auto space_from_ray = offsetRay->RawMatrix();
auto origin_from_ray = origin_from_space * space_from_ray; auto origin_from_ray = origin_from_space * space_from_ray;
DVLOG(3) << __func__ DVLOG(3) << __func__
...@@ -681,7 +687,7 @@ ScriptPromise XRSession::requestHitTestSource( ...@@ -681,7 +687,7 @@ ScriptPromise XRSession::requestHitTestSource(
xr_->xrEnvironmentProviderRemote()->SubscribeToHitTest( xr_->xrEnvironmentProviderRemote()->SubscribeToHitTest(
maybe_native_origin->ToMojo(), std::move(ray_mojo), maybe_native_origin->ToMojo(), std::move(ray_mojo),
WTF::Bind(&XRSession::OnSubscribeToHitTestResult, WrapPersistent(this), WTF::Bind(&XRSession::OnSubscribeToHitTestResult, WrapPersistent(this),
WrapPersistent(resolver), WrapPersistent(options))); WrapPersistent(resolver)));
request_hit_test_source_promises_.insert(resolver); request_hit_test_source_promises_.insert(resolver);
return promise; return promise;
...@@ -709,7 +715,6 @@ void XRSession::OnHitTestResults( ...@@ -709,7 +715,6 @@ void XRSession::OnHitTestResults(
void XRSession::OnSubscribeToHitTestResult( void XRSession::OnSubscribeToHitTestResult(
ScriptPromiseResolver* resolver, ScriptPromiseResolver* resolver,
XRHitTestOptions* options,
device::mojom::SubscribeToHitTestResult result, device::mojom::SubscribeToHitTestResult result,
uint64_t subscription_id) { uint64_t subscription_id) {
DVLOG(2) << __func__ << ": result=" << result DVLOG(2) << __func__ << ": result=" << result
...@@ -725,7 +730,7 @@ void XRSession::OnSubscribeToHitTestResult( ...@@ -725,7 +730,7 @@ void XRSession::OnSubscribeToHitTestResult(
} }
XRHitTestSource* hit_test_source = XRHitTestSource* hit_test_source =
MakeGarbageCollected<XRHitTestSource>(subscription_id, options); MakeGarbageCollected<XRHitTestSource>(subscription_id);
hit_test_source_ids_to_hit_test_sources_.insert(subscription_id, hit_test_source_ids_to_hit_test_sources_.insert(subscription_id,
hit_test_source); hit_test_source);
......
...@@ -39,7 +39,6 @@ class XR; ...@@ -39,7 +39,6 @@ class XR;
class XRAnchor; class XRAnchor;
class XRAnchorSet; class XRAnchorSet;
class XRCanvasInputProvider; class XRCanvasInputProvider;
class XRHitTestOptions;
class XRHitTestOptionsInit; class XRHitTestOptionsInit;
class XRHitTestSource; class XRHitTestSource;
class XRPlane; class XRPlane;
...@@ -311,7 +310,6 @@ class XRSession final ...@@ -311,7 +310,6 @@ class XRSession final
void OnSubscribeToHitTestResult( void OnSubscribeToHitTestResult(
ScriptPromiseResolver* resolver, ScriptPromiseResolver* resolver,
XRHitTestOptions* options,
device::mojom::SubscribeToHitTestResult result, device::mojom::SubscribeToHitTestResult result,
uint64_t subscription_id); uint64_t subscription_id);
......
...@@ -11074,19 +11074,12 @@ interface XRHitResult ...@@ -11074,19 +11074,12 @@ interface XRHitResult
attribute @@toStringTag attribute @@toStringTag
getter hitMatrix getter hitMatrix
method constructor method constructor
interface XRHitTestOptions
attribute @@toStringTag
getter offsetRay
getter space
method constructor
interface XRHitTestResult interface XRHitTestResult
attribute @@toStringTag attribute @@toStringTag
getter hitTestOptions
method constructor method constructor
method getPose method getPose
interface XRHitTestSource interface XRHitTestSource
attribute @@toStringTag attribute @@toStringTag
getter hitTestOptions
method constructor method constructor
interface XRInputSource interface XRInputSource
attribute @@toStringTag attribute @@toStringTag
......
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