Commit a693b439 authored by Brandon Jones's avatar Brandon Jones Committed by Commit Bot

Stop sending XRDeviceId with VRDisplayInfo (Attempt 2)

This time with the Oculus code path fixed too!

This value is not used by Blink, and does not need to be communicated
over the mojo interface. The XRDeviceId enum should not be removed
because it is used for usage stats.

Bug: 1017477
Change-Id: I84115dafd37288afa2425aeebb863e9dee9d3093
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2435938Reviewed-by: default avatarAlexander Cooper <alcooper@chromium.org>
Reviewed-by: default avatarChris Palmer <palmer@chromium.org>
Commit-Queue: Brandon Jones <bajones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#811576}
parent 0fbea5c9
...@@ -33,10 +33,8 @@ namespace device { ...@@ -33,10 +33,8 @@ namespace device {
namespace { namespace {
mojom::VRDisplayInfoPtr CreateVRDisplayInfo(mojom::XRDeviceId device_id, mojom::VRDisplayInfoPtr CreateVRDisplayInfo(const gfx::Size& frame_size) {
const gfx::Size& frame_size) {
mojom::VRDisplayInfoPtr device = mojom::VRDisplayInfo::New(); mojom::VRDisplayInfoPtr device = mojom::VRDisplayInfo::New();
device->id = device_id;
device->webxr_default_framebuffer_scale = 1.0; device->webxr_default_framebuffer_scale = 1.0;
device->left_eye = mojom::VREyeParameters::New(); device->left_eye = mojom::VREyeParameters::New();
device->right_eye = nullptr; device->right_eye = nullptr;
...@@ -80,7 +78,7 @@ ArCoreDevice::ArCoreDevice( ...@@ -80,7 +78,7 @@ ArCoreDevice::ArCoreDevice(
// if initialization fails. Use an arbitrary but really low resolution to make // if initialization fails. Use an arbitrary but really low resolution to make
// it obvious if we're using this data instead of the actual values we get // it obvious if we're using this data instead of the actual values we get
// from the output drawing surface. // from the output drawing surface.
SetVRDisplayInfo(CreateVRDisplayInfo(GetId(), {16, 16})); SetVRDisplayInfo(CreateVRDisplayInfo({16, 16}));
} }
ArCoreDevice::ArCoreDevice() ArCoreDevice::ArCoreDevice()
...@@ -177,7 +175,7 @@ void ArCoreDevice::OnDrawingSurfaceReady(gfx::AcceleratedWidget window, ...@@ -177,7 +175,7 @@ void ArCoreDevice::OnDrawingSurfaceReady(gfx::AcceleratedWidget window,
<< frame_size.height() << " rotation=" << static_cast<int>(rotation); << frame_size.height() << " rotation=" << static_cast<int>(rotation);
DCHECK(!session_state_->is_arcore_gl_initialized_); DCHECK(!session_state_->is_arcore_gl_initialized_);
auto display_info = CreateVRDisplayInfo(GetId(), frame_size); auto display_info = CreateVRDisplayInfo(frame_size);
SetVRDisplayInfo(std::move(display_info)); SetVRDisplayInfo(std::move(display_info));
RequestArCoreGlInitialization(window, rotation, frame_size); RequestArCoreGlInitialization(window, rotation, frame_size);
......
...@@ -111,17 +111,12 @@ device::mojom::VREyeParametersPtr ValidateEyeParameters( ...@@ -111,17 +111,12 @@ device::mojom::VREyeParametersPtr ValidateEyeParameters(
} }
device::mojom::VRDisplayInfoPtr ValidateVRDisplayInfo( device::mojom::VRDisplayInfoPtr ValidateVRDisplayInfo(
const device::mojom::VRDisplayInfo* info, const device::mojom::VRDisplayInfo* info) {
device::mojom::XRDeviceId id) {
if (!info) if (!info)
return nullptr; return nullptr;
device::mojom::VRDisplayInfoPtr ret = device::mojom::VRDisplayInfo::New(); device::mojom::VRDisplayInfoPtr ret = device::mojom::VRDisplayInfo::New();
// Rather than just cloning everything, we copy over each field and validate
// individually. This ensures new fields don't bypass validation.
ret->id = id;
// Maximum 1000km translation. // Maximum 1000km translation.
if (info->stage_parameters && if (info->stage_parameters &&
IsValidTransform(info->stage_parameters->mojo_from_floor, 1000000)) { IsValidTransform(info->stage_parameters->mojo_from_floor, 1000000)) {
...@@ -215,7 +210,7 @@ BrowserXRRuntimeImpl::BrowserXRRuntimeImpl( ...@@ -215,7 +210,7 @@ BrowserXRRuntimeImpl::BrowserXRRuntimeImpl(
: id_(id), : id_(id),
device_data_(std::move(device_data)), device_data_(std::move(device_data)),
runtime_(std::move(runtime)), runtime_(std::move(runtime)),
display_info_(ValidateVRDisplayInfo(display_info.get(), id)) { display_info_(ValidateVRDisplayInfo(display_info.get())) {
DVLOG(2) << __func__ << ": id=" << id; DVLOG(2) << __func__ << ": id=" << id;
// Unretained is safe because we are calling through an InterfacePtr we own, // Unretained is safe because we are calling through an InterfacePtr we own,
// so we won't be called after runtime_ is destroyed. // so we won't be called after runtime_ is destroyed.
...@@ -357,7 +352,7 @@ bool BrowserXRRuntimeImpl::SupportsNonEmulatedHeight() const { ...@@ -357,7 +352,7 @@ bool BrowserXRRuntimeImpl::SupportsNonEmulatedHeight() const {
void BrowserXRRuntimeImpl::OnDisplayInfoChanged( void BrowserXRRuntimeImpl::OnDisplayInfoChanged(
device::mojom::VRDisplayInfoPtr vr_device_info) { device::mojom::VRDisplayInfoPtr vr_device_info) {
bool had_display_info = !!display_info_; bool had_display_info = !!display_info_;
display_info_ = ValidateVRDisplayInfo(vr_device_info.get(), id_); display_info_ = ValidateVRDisplayInfo(vr_device_info.get());
if (had_display_info) { if (had_display_info) {
for (VRServiceImpl* service : services_) { for (VRServiceImpl* service : services_) {
service->OnDisplayInfoChanged(); service->OnDisplayInfoChanged();
......
...@@ -98,14 +98,11 @@ mojom::VREyeParametersPtr CreateEyeParamater( ...@@ -98,14 +98,11 @@ mojom::VREyeParametersPtr CreateEyeParamater(
return eye_params; return eye_params;
} }
mojom::VRDisplayInfoPtr CreateVRDisplayInfo(gvr::GvrApi* gvr_api, mojom::VRDisplayInfoPtr CreateVRDisplayInfo(gvr::GvrApi* gvr_api) {
mojom::XRDeviceId device_id) {
TRACE_EVENT0("input", "GvrDelegate::CreateVRDisplayInfo"); TRACE_EVENT0("input", "GvrDelegate::CreateVRDisplayInfo");
mojom::VRDisplayInfoPtr device = mojom::VRDisplayInfo::New(); mojom::VRDisplayInfoPtr device = mojom::VRDisplayInfo::New();
device->id = device_id;
gvr::BufferViewportList gvr_buffer_viewports = gvr::BufferViewportList gvr_buffer_viewports =
gvr_api->CreateEmptyBufferViewportList(); gvr_api->CreateEmptyBufferViewportList();
gvr_buffer_viewports.SetToRecommendedBufferViewports(); gvr_buffer_viewports.SetToRecommendedBufferViewports();
...@@ -270,7 +267,7 @@ GvrDelegateProvider* GvrDevice::GetGvrDelegateProvider() { ...@@ -270,7 +267,7 @@ GvrDelegateProvider* GvrDevice::GetGvrDelegateProvider() {
void GvrDevice::OnDisplayConfigurationChanged(JNIEnv* env, void GvrDevice::OnDisplayConfigurationChanged(JNIEnv* env,
const JavaRef<jobject>& obj) { const JavaRef<jobject>& obj) {
DCHECK(gvr_api_); DCHECK(gvr_api_);
SetVRDisplayInfo(CreateVRDisplayInfo(gvr_api_.get(), GetId())); SetVRDisplayInfo(CreateVRDisplayInfo(gvr_api_.get()));
} }
void GvrDevice::Init(base::OnceCallback<void(bool)> on_finished) { void GvrDevice::Init(base::OnceCallback<void(bool)> on_finished) {
...@@ -294,7 +291,7 @@ void GvrDevice::CreateNonPresentingContext() { ...@@ -294,7 +291,7 @@ void GvrDevice::CreateNonPresentingContext() {
jlong context = Java_NonPresentingGvrContext_getNativeGvrContext( jlong context = Java_NonPresentingGvrContext_getNativeGvrContext(
env, non_presenting_context_); env, non_presenting_context_);
gvr_api_ = gvr::GvrApi::WrapNonOwned(reinterpret_cast<gvr_context*>(context)); gvr_api_ = gvr::GvrApi::WrapNonOwned(reinterpret_cast<gvr_context*>(context));
SetVRDisplayInfo(CreateVRDisplayInfo(gvr_api_.get(), GetId())); SetVRDisplayInfo(CreateVRDisplayInfo(gvr_api_.get()));
if (paused_) { if (paused_) {
PauseTracking(); PauseTracking();
......
...@@ -59,10 +59,8 @@ mojom::VREyeParametersPtr GetEyeDetails(ovrSession session, ...@@ -59,10 +59,8 @@ mojom::VREyeParametersPtr GetEyeDetails(ovrSession session,
return eye_parameters; return eye_parameters;
} }
mojom::VRDisplayInfoPtr CreateVRDisplayInfo(mojom::XRDeviceId id, mojom::VRDisplayInfoPtr CreateVRDisplayInfo(ovrSession session) {
ovrSession session) {
mojom::VRDisplayInfoPtr display_info = mojom::VRDisplayInfo::New(); mojom::VRDisplayInfoPtr display_info = mojom::VRDisplayInfo::New();
display_info->id = id;
ovrHmdDesc hmdDesc = ovr_GetHmdDesc(session); ovrHmdDesc hmdDesc = ovr_GetHmdDesc(session);
display_info->left_eye = GetEyeDetails(session, hmdDesc, ovrEye_Left); display_info->left_eye = GetEyeDetails(session, hmdDesc, ovrEye_Left);
...@@ -174,7 +172,7 @@ bool OculusDevice::EnsureValidDisplayInfo() { ...@@ -174,7 +172,7 @@ bool OculusDevice::EnsureValidDisplayInfo() {
return false; return false;
} }
SetVRDisplayInfo(CreateVRDisplayInfo(GetId(), session_)); SetVRDisplayInfo(CreateVRDisplayInfo(session_));
have_real_display_info_ = true; have_real_display_info_ = true;
} }
return have_real_display_info_; return have_real_display_info_;
......
...@@ -27,11 +27,9 @@ constexpr unsigned int kRenderHeight = 1024; ...@@ -27,11 +27,9 @@ constexpr unsigned int kRenderHeight = 1024;
// However our mojo interface expects display info right away to support WebVR. // However our mojo interface expects display info right away to support WebVR.
// We create a fake display info to use, then notify the client that the display // We create a fake display info to use, then notify the client that the display
// info changed when we get real data. // info changed when we get real data.
mojom::VRDisplayInfoPtr CreateFakeVRDisplayInfo(device::mojom::XRDeviceId id) { mojom::VRDisplayInfoPtr CreateFakeVRDisplayInfo() {
mojom::VRDisplayInfoPtr display_info = mojom::VRDisplayInfo::New(); mojom::VRDisplayInfoPtr display_info = mojom::VRDisplayInfo::New();
display_info->id = id;
display_info->left_eye = mojom::VREyeParameters::New(); display_info->left_eye = mojom::VREyeParameters::New();
display_info->right_eye = mojom::VREyeParameters::New(); display_info->right_eye = mojom::VREyeParameters::New();
...@@ -61,7 +59,7 @@ OpenXrDevice::OpenXrDevice(OpenXrStatics* openxr_statics) ...@@ -61,7 +59,7 @@ OpenXrDevice::OpenXrDevice(OpenXrStatics* openxr_statics)
: VRDeviceBase(device::mojom::XRDeviceId::OPENXR_DEVICE_ID), : VRDeviceBase(device::mojom::XRDeviceId::OPENXR_DEVICE_ID),
instance_(openxr_statics->GetXrInstance()), instance_(openxr_statics->GetXrInstance()),
weak_ptr_factory_(this) { weak_ptr_factory_(this) {
mojom::VRDisplayInfoPtr display_info = CreateFakeVRDisplayInfo(GetId()); mojom::VRDisplayInfoPtr display_info = CreateFakeVRDisplayInfo();
SetVRDisplayInfo(std::move(display_info)); SetVRDisplayInfo(std::move(display_info));
#if defined(OS_WIN) #if defined(OS_WIN)
......
...@@ -168,8 +168,6 @@ void OpenXrRenderLoop::InitializeDisplayInfo() { ...@@ -168,8 +168,6 @@ void OpenXrRenderLoop::InitializeDisplayInfo() {
current_display_info_->left_eye = mojom::VREyeParameters::New(); current_display_info_->left_eye = mojom::VREyeParameters::New();
} }
current_display_info_->id = device::mojom::XRDeviceId::OPENXR_DEVICE_ID;
gfx::Size view_size = openxr_->GetViewSize(); gfx::Size view_size = openxr_->GetViewSize();
current_display_info_->left_eye->render_width = view_size.width(); current_display_info_->left_eye->render_width = view_size.width();
current_display_info_->right_eye->render_width = view_size.width(); current_display_info_->right_eye->render_width = view_size.width();
......
...@@ -27,12 +27,6 @@ using gfx::Vector3dF; ...@@ -27,12 +27,6 @@ using gfx::Vector3dF;
namespace { namespace {
static constexpr int kDefaultPumpFrequencyHz = 60; static constexpr int kDefaultPumpFrequencyHz = 60;
mojom::VRDisplayInfoPtr CreateVRDisplayInfo(mojom::XRDeviceId id) {
mojom::VRDisplayInfoPtr display_info = mojom::VRDisplayInfo::New();
display_info->id = id;
return display_info;
}
display::Display::Rotation GetRotation() { display::Display::Rotation GetRotation() {
display::Screen* screen = display::Screen::GetScreen(); display::Screen* screen = display::Screen::GetScreen();
if (!screen) { if (!screen) {
...@@ -54,7 +48,7 @@ VROrientationDevice::VROrientationDevice(mojom::SensorProvider* sensor_provider, ...@@ -54,7 +48,7 @@ VROrientationDevice::VROrientationDevice(mojom::SensorProvider* sensor_provider,
base::BindOnce(&VROrientationDevice::SensorReady, base::BindOnce(&VROrientationDevice::SensorReady,
base::Unretained(this))); base::Unretained(this)));
SetVRDisplayInfo(CreateVRDisplayInfo(GetId())); SetVRDisplayInfo(mojom::VRDisplayInfo::New());
} }
VROrientationDevice::~VROrientationDevice() { VROrientationDevice::~VROrientationDevice() {
......
...@@ -298,7 +298,6 @@ struct VRStageParameters { ...@@ -298,7 +298,6 @@ struct VRStageParameters {
}; };
struct VRDisplayInfo { struct VRDisplayInfo {
XRDeviceId id;
VRStageParameters? stage_parameters; VRStageParameters? stage_parameters;
// Parameters required to distort a scene for viewing in a VR headset. Only // Parameters required to distort a scene for viewing in a VR headset. Only
// required for devices which have the can_present capability. // required for devices which have the can_present capability.
......
...@@ -17,8 +17,6 @@ FakeVRDevice::~FakeVRDevice() {} ...@@ -17,8 +17,6 @@ FakeVRDevice::~FakeVRDevice() {}
mojom::VRDisplayInfoPtr FakeVRDevice::InitBasicDevice() { mojom::VRDisplayInfoPtr FakeVRDevice::InitBasicDevice() {
mojom::VRDisplayInfoPtr display_info = mojom::VRDisplayInfo::New(); mojom::VRDisplayInfoPtr display_info = mojom::VRDisplayInfo::New();
display_info->id = GetId();
display_info->left_eye = InitEye(45, -0.03f, 1024); display_info->left_eye = InitEye(45, -0.03f, 1024);
display_info->right_eye = InitEye(45, 0.03f, 1024); display_info->right_eye = InitEye(45, 0.03f, 1024);
return display_info; return display_info;
......
...@@ -66,7 +66,6 @@ void VRDeviceBase::ListenToDeviceChanges( ...@@ -66,7 +66,6 @@ void VRDeviceBase::ListenToDeviceChanges(
void VRDeviceBase::SetVRDisplayInfo(mojom::VRDisplayInfoPtr display_info) { void VRDeviceBase::SetVRDisplayInfo(mojom::VRDisplayInfoPtr display_info) {
DCHECK(display_info); DCHECK(display_info);
DCHECK(display_info->id == id_);
display_info_ = std::move(display_info); display_info_ = std::move(display_info);
if (listener_) if (listener_)
......
...@@ -72,16 +72,10 @@ class VRDeviceTest : public testing::Test { ...@@ -72,16 +72,10 @@ class VRDeviceTest : public testing::Test {
std::unique_ptr<VRDeviceBaseForTesting> MakeVRDevice() { std::unique_ptr<VRDeviceBaseForTesting> MakeVRDevice() {
std::unique_ptr<VRDeviceBaseForTesting> device = std::unique_ptr<VRDeviceBaseForTesting> device =
std::make_unique<VRDeviceBaseForTesting>(); std::make_unique<VRDeviceBaseForTesting>();
device->SetVRDisplayInfoForTest(MakeVRDisplayInfo(device->GetId())); device->SetVRDisplayInfoForTest(mojom::VRDisplayInfo::New());
return device; return device;
} }
mojom::VRDisplayInfoPtr MakeVRDisplayInfo(mojom::XRDeviceId device_id) {
mojom::VRDisplayInfoPtr display_info = mojom::VRDisplayInfo::New();
display_info->id = device_id;
return display_info;
}
base::test::SingleThreadTaskEnvironment task_environment_; base::test::SingleThreadTaskEnvironment task_environment_;
DISALLOW_COPY_AND_ASSIGN(VRDeviceTest); DISALLOW_COPY_AND_ASSIGN(VRDeviceTest);
...@@ -99,7 +93,7 @@ TEST_F(VRDeviceTest, DeviceChangedDispatched) { ...@@ -99,7 +93,7 @@ TEST_F(VRDeviceTest, DeviceChangedDispatched) {
base::DoNothing()); // TODO: consider getting initial info base::DoNothing()); // TODO: consider getting initial info
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
EXPECT_CALL(listener, DoOnChanged(testing::_)).Times(1); EXPECT_CALL(listener, DoOnChanged(testing::_)).Times(1);
device->SetVRDisplayInfoForTest(MakeVRDisplayInfo(device->GetId())); device->SetVRDisplayInfoForTest(mojom::VRDisplayInfo::New());
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
} }
......
...@@ -27,9 +27,8 @@ namespace { ...@@ -27,9 +27,8 @@ namespace {
// However our mojo interface expects display info right away to support WebVR. // However our mojo interface expects display info right away to support WebVR.
// We create a fake display info to use, then notify the client that the display // We create a fake display info to use, then notify the client that the display
// info changed when we get real data. // info changed when we get real data.
mojom::VRDisplayInfoPtr CreateFakeVRDisplayInfo(device::mojom::XRDeviceId id) { mojom::VRDisplayInfoPtr CreateFakeVRDisplayInfo() {
mojom::VRDisplayInfoPtr display_info = mojom::VRDisplayInfo::New(); mojom::VRDisplayInfoPtr display_info = mojom::VRDisplayInfo::New();
display_info->id = id;
display_info->left_eye = mojom::VREyeParameters::New(); display_info->left_eye = mojom::VREyeParameters::New();
display_info->right_eye = mojom::VREyeParameters::New(); display_info->right_eye = mojom::VREyeParameters::New();
...@@ -56,7 +55,7 @@ mojom::VRDisplayInfoPtr CreateFakeVRDisplayInfo(device::mojom::XRDeviceId id) { ...@@ -56,7 +55,7 @@ mojom::VRDisplayInfoPtr CreateFakeVRDisplayInfo(device::mojom::XRDeviceId id) {
MixedRealityDevice::MixedRealityDevice() MixedRealityDevice::MixedRealityDevice()
: VRDeviceBase(device::mojom::XRDeviceId::WINDOWS_MIXED_REALITY_ID) { : VRDeviceBase(device::mojom::XRDeviceId::WINDOWS_MIXED_REALITY_ID) {
SetVRDisplayInfo(CreateFakeVRDisplayInfo(GetId())); SetVRDisplayInfo(CreateFakeVRDisplayInfo());
} }
MixedRealityDevice::~MixedRealityDevice() { MixedRealityDevice::~MixedRealityDevice() {
......
...@@ -671,8 +671,6 @@ bool MixedRealityRenderLoop::UpdateDisplayInfo() { ...@@ -671,8 +671,6 @@ bool MixedRealityRenderLoop::UpdateDisplayInfo() {
if (!current_display_info_) { if (!current_display_info_) {
current_display_info_ = mojom::VRDisplayInfo::New(); current_display_info_ = mojom::VRDisplayInfo::New();
current_display_info_->id =
device::mojom::XRDeviceId::WINDOWS_MIXED_REALITY_ID;
changed = true; changed = true;
} }
......
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