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 =
"xr/xr_reference_space_event.idl",
"xr/xr_render_state.idl",
"xr/xr_rigid_transform.idl",
"xr/xr_hit_test_options.idl",
"xr/xr_hit_test_result.idl",
"xr/xr_hit_test_source.idl",
"xr/xr_session.idl",
......
......@@ -30,8 +30,6 @@ blink_modules_sources("xr") {
"xr_grip_space.h",
"xr_hit_result.cc",
"xr_hit_result.h",
"xr_hit_test_options.cc",
"xr_hit_test_options.h",
"xr_hit_test_result.cc",
"xr_hit_test_result.h",
"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,
: hit_test_source_(hit_test_source),
pose_(std::make_unique<TransformationMatrix>(pose)) {}
XRHitTestOptions* XRHitTestResult::hitTestOptions() const {
return hit_test_source_->hitTestOptions();
}
XRPose* XRHitTestResult::getPose(XRSpace* relative_to) {
DCHECK(relative_to->MojoFromSpace());
......
......@@ -10,7 +10,6 @@
namespace blink {
class TransformationMatrix;
class XRHitTestOptions;
class XRHitTestSource;
class XRPose;
class XRSpace;
......@@ -22,8 +21,6 @@ class XRHitTestResult : public ScriptWrappable {
XRHitTestResult(XRHitTestSource* hit_test_source,
const TransformationMatrix& pose);
XRHitTestOptions* hitTestOptions() const;
XRPose* getPose(XRSpace* relative_to);
void Trace(blink::Visitor* visitor) override;
......
......@@ -4,7 +4,5 @@
[SecureContext, Exposed=Window, RuntimeEnabled=WebXRHitTest]
interface XRHitTestResult {
readonly attribute XRHitTestOptions hitTestOptions;
XRPose? getPose(XRSpace relative_to);
};
......@@ -5,22 +5,16 @@
#include "third_party/blink/renderer/modules/xr/xr_hit_test_source.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"
namespace blink {
XRHitTestSource::XRHitTestSource(uint64_t id, XRHitTestOptions* options)
: id_(id), options_(options) {}
XRHitTestSource::XRHitTestSource(uint64_t id) : id_(id) {}
uint64_t XRHitTestSource::id() const {
return id_;
}
XRHitTestOptions* XRHitTestSource::hitTestOptions() const {
return options_;
}
HeapVector<Member<XRHitTestResult>> XRHitTestSource::Results() {
HeapVector<Member<XRHitTestResult>> results;
......@@ -41,9 +35,4 @@ void XRHitTestSource::Update(
}
}
void XRHitTestSource::Trace(blink::Visitor* visitor) {
visitor->Trace(options_);
ScriptWrappable::Trace(visitor);
}
} // namespace blink
......@@ -14,19 +14,16 @@
namespace blink {
class XRHitTestOptions;
class XRHitTestResult;
class XRHitTestSource : public ScriptWrappable {
DEFINE_WRAPPERTYPEINFO();
public:
XRHitTestSource(uint64_t id, XRHitTestOptions* options);
explicit XRHitTestSource(uint64_t id);
uint64_t id() const;
XRHitTestOptions* hitTestOptions() const;
// Returns a vector of XRHitTestResults that were obtained during last frame
// update. This method is not exposed to JavaScript.
HeapVector<Member<XRHitTestResult>> Results();
......@@ -34,13 +31,9 @@ class XRHitTestSource : public ScriptWrappable {
void Update(const WTF::Vector<device::mojom::blink::XRHitResultPtr>&
hit_test_results);
void Trace(blink::Visitor*) override;
private:
const uint64_t id_;
Member<XRHitTestOptions> options_;
Vector<std::unique_ptr<TransformationMatrix>> last_frame_results_;
};
......
......@@ -4,5 +4,4 @@
[SecureContext, Exposed=Window, RuntimeEnabled=WebXRHitTest]
interface XRHitTestSource {
readonly attribute XRHitTestOptions hitTestOptions;
};
......@@ -31,7 +31,7 @@
#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_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_input_source_event.h"
#include "third_party/blink/renderer/modules/xr/xr_input_sources_change_event.h"
......@@ -631,12 +631,11 @@ ScriptPromise XRSession::requestHitTestSource(
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.
base::Optional<XRNativeOriginInformation> maybe_native_origin =
options->space()->NativeOrigin();
options_init && options_init->hasSpace()
? options_init->space()->NativeOrigin()
: base::nullopt;
if (!maybe_native_origin) {
exception_state.ThrowDOMException(DOMExceptionCode::kInvalidStateError,
......@@ -648,13 +647,20 @@ ScriptPromise XRSession::requestHitTestSource(
// should only matter for spaces whose transforms are not fully known on the
// device (for example any space containing origin-offset).
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__
<< ": origin_from_space = " << origin_from_space.ToString(true);
// 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;
DVLOG(3) << __func__
......@@ -681,7 +687,7 @@ ScriptPromise XRSession::requestHitTestSource(
xr_->xrEnvironmentProviderRemote()->SubscribeToHitTest(
maybe_native_origin->ToMojo(), std::move(ray_mojo),
WTF::Bind(&XRSession::OnSubscribeToHitTestResult, WrapPersistent(this),
WrapPersistent(resolver), WrapPersistent(options)));
WrapPersistent(resolver)));
request_hit_test_source_promises_.insert(resolver);
return promise;
......@@ -709,7 +715,6 @@ void XRSession::OnHitTestResults(
void XRSession::OnSubscribeToHitTestResult(
ScriptPromiseResolver* resolver,
XRHitTestOptions* options,
device::mojom::SubscribeToHitTestResult result,
uint64_t subscription_id) {
DVLOG(2) << __func__ << ": result=" << result
......@@ -725,7 +730,7 @@ void XRSession::OnSubscribeToHitTestResult(
}
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);
......
......@@ -39,7 +39,6 @@ class XR;
class XRAnchor;
class XRAnchorSet;
class XRCanvasInputProvider;
class XRHitTestOptions;
class XRHitTestOptionsInit;
class XRHitTestSource;
class XRPlane;
......@@ -311,7 +310,6 @@ class XRSession final
void OnSubscribeToHitTestResult(
ScriptPromiseResolver* resolver,
XRHitTestOptions* options,
device::mojom::SubscribeToHitTestResult result,
uint64_t subscription_id);
......
......@@ -11074,19 +11074,12 @@ interface XRHitResult
attribute @@toStringTag
getter hitMatrix
method constructor
interface XRHitTestOptions
attribute @@toStringTag
getter offsetRay
getter space
method constructor
interface XRHitTestResult
attribute @@toStringTag
getter hitTestOptions
method constructor
method getPose
interface XRHitTestSource
attribute @@toStringTag
getter hitTestOptions
method constructor
interface XRInputSource
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