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/+/2435938 Reviewed-by: Alexander Cooper <alcooper@chromium.org> Reviewed-by: Chris Palmer <palmer@chromium.org> Commit-Queue: Brandon Jones <bajones@chromium.org> Cr-Commit-Position: refs/heads/master@{#811576}
This commit is contained in:

committed by
Commit Bot

parent
0fbea5c938
commit
a693b439c9
chrome/browser/android/vr/arcore_device
content/browser/xr/service
device/vr
android
oculus
openxr
orientation
public
mojom
test
vr_device_base.ccvr_device_base_unittest.ccwindows_mixed_reality
@ -33,10 +33,8 @@ namespace device {
|
||||
|
||||
namespace {
|
||||
|
||||
mojom::VRDisplayInfoPtr CreateVRDisplayInfo(mojom::XRDeviceId device_id,
|
||||
const gfx::Size& frame_size) {
|
||||
mojom::VRDisplayInfoPtr CreateVRDisplayInfo(const gfx::Size& frame_size) {
|
||||
mojom::VRDisplayInfoPtr device = mojom::VRDisplayInfo::New();
|
||||
device->id = device_id;
|
||||
device->webxr_default_framebuffer_scale = 1.0;
|
||||
device->left_eye = mojom::VREyeParameters::New();
|
||||
device->right_eye = nullptr;
|
||||
@ -80,7 +78,7 @@ ArCoreDevice::ArCoreDevice(
|
||||
// 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
|
||||
// from the output drawing surface.
|
||||
SetVRDisplayInfo(CreateVRDisplayInfo(GetId(), {16, 16}));
|
||||
SetVRDisplayInfo(CreateVRDisplayInfo({16, 16}));
|
||||
}
|
||||
|
||||
ArCoreDevice::ArCoreDevice()
|
||||
@ -177,7 +175,7 @@ void ArCoreDevice::OnDrawingSurfaceReady(gfx::AcceleratedWidget window,
|
||||
<< frame_size.height() << " rotation=" << static_cast<int>(rotation);
|
||||
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));
|
||||
|
||||
RequestArCoreGlInitialization(window, rotation, frame_size);
|
||||
|
@ -111,17 +111,12 @@ device::mojom::VREyeParametersPtr ValidateEyeParameters(
|
||||
}
|
||||
|
||||
device::mojom::VRDisplayInfoPtr ValidateVRDisplayInfo(
|
||||
const device::mojom::VRDisplayInfo* info,
|
||||
device::mojom::XRDeviceId id) {
|
||||
const device::mojom::VRDisplayInfo* info) {
|
||||
if (!info)
|
||||
return nullptr;
|
||||
|
||||
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.
|
||||
if (info->stage_parameters &&
|
||||
IsValidTransform(info->stage_parameters->mojo_from_floor, 1000000)) {
|
||||
@ -215,7 +210,7 @@ BrowserXRRuntimeImpl::BrowserXRRuntimeImpl(
|
||||
: id_(id),
|
||||
device_data_(std::move(device_data)),
|
||||
runtime_(std::move(runtime)),
|
||||
display_info_(ValidateVRDisplayInfo(display_info.get(), id)) {
|
||||
display_info_(ValidateVRDisplayInfo(display_info.get())) {
|
||||
DVLOG(2) << __func__ << ": id=" << id;
|
||||
// Unretained is safe because we are calling through an InterfacePtr we own,
|
||||
// so we won't be called after runtime_ is destroyed.
|
||||
@ -357,7 +352,7 @@ bool BrowserXRRuntimeImpl::SupportsNonEmulatedHeight() const {
|
||||
void BrowserXRRuntimeImpl::OnDisplayInfoChanged(
|
||||
device::mojom::VRDisplayInfoPtr vr_device_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) {
|
||||
for (VRServiceImpl* service : services_) {
|
||||
service->OnDisplayInfoChanged();
|
||||
|
@ -98,14 +98,11 @@ mojom::VREyeParametersPtr CreateEyeParamater(
|
||||
return eye_params;
|
||||
}
|
||||
|
||||
mojom::VRDisplayInfoPtr CreateVRDisplayInfo(gvr::GvrApi* gvr_api,
|
||||
mojom::XRDeviceId device_id) {
|
||||
mojom::VRDisplayInfoPtr CreateVRDisplayInfo(gvr::GvrApi* gvr_api) {
|
||||
TRACE_EVENT0("input", "GvrDelegate::CreateVRDisplayInfo");
|
||||
|
||||
mojom::VRDisplayInfoPtr device = mojom::VRDisplayInfo::New();
|
||||
|
||||
device->id = device_id;
|
||||
|
||||
gvr::BufferViewportList gvr_buffer_viewports =
|
||||
gvr_api->CreateEmptyBufferViewportList();
|
||||
gvr_buffer_viewports.SetToRecommendedBufferViewports();
|
||||
@ -270,7 +267,7 @@ GvrDelegateProvider* GvrDevice::GetGvrDelegateProvider() {
|
||||
void GvrDevice::OnDisplayConfigurationChanged(JNIEnv* env,
|
||||
const JavaRef<jobject>& obj) {
|
||||
DCHECK(gvr_api_);
|
||||
SetVRDisplayInfo(CreateVRDisplayInfo(gvr_api_.get(), GetId()));
|
||||
SetVRDisplayInfo(CreateVRDisplayInfo(gvr_api_.get()));
|
||||
}
|
||||
|
||||
void GvrDevice::Init(base::OnceCallback<void(bool)> on_finished) {
|
||||
@ -294,7 +291,7 @@ void GvrDevice::CreateNonPresentingContext() {
|
||||
jlong context = Java_NonPresentingGvrContext_getNativeGvrContext(
|
||||
env, non_presenting_context_);
|
||||
gvr_api_ = gvr::GvrApi::WrapNonOwned(reinterpret_cast<gvr_context*>(context));
|
||||
SetVRDisplayInfo(CreateVRDisplayInfo(gvr_api_.get(), GetId()));
|
||||
SetVRDisplayInfo(CreateVRDisplayInfo(gvr_api_.get()));
|
||||
|
||||
if (paused_) {
|
||||
PauseTracking();
|
||||
|
@ -59,10 +59,8 @@ mojom::VREyeParametersPtr GetEyeDetails(ovrSession session,
|
||||
return eye_parameters;
|
||||
}
|
||||
|
||||
mojom::VRDisplayInfoPtr CreateVRDisplayInfo(mojom::XRDeviceId id,
|
||||
ovrSession session) {
|
||||
mojom::VRDisplayInfoPtr CreateVRDisplayInfo(ovrSession session) {
|
||||
mojom::VRDisplayInfoPtr display_info = mojom::VRDisplayInfo::New();
|
||||
display_info->id = id;
|
||||
|
||||
ovrHmdDesc hmdDesc = ovr_GetHmdDesc(session);
|
||||
display_info->left_eye = GetEyeDetails(session, hmdDesc, ovrEye_Left);
|
||||
@ -174,7 +172,7 @@ bool OculusDevice::EnsureValidDisplayInfo() {
|
||||
return false;
|
||||
}
|
||||
|
||||
SetVRDisplayInfo(CreateVRDisplayInfo(GetId(), session_));
|
||||
SetVRDisplayInfo(CreateVRDisplayInfo(session_));
|
||||
have_real_display_info_ = true;
|
||||
}
|
||||
return have_real_display_info_;
|
||||
|
@ -27,11 +27,9 @@ constexpr unsigned int kRenderHeight = 1024;
|
||||
// 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
|
||||
// info changed when we get real data.
|
||||
mojom::VRDisplayInfoPtr CreateFakeVRDisplayInfo(device::mojom::XRDeviceId id) {
|
||||
mojom::VRDisplayInfoPtr CreateFakeVRDisplayInfo() {
|
||||
mojom::VRDisplayInfoPtr display_info = mojom::VRDisplayInfo::New();
|
||||
|
||||
display_info->id = id;
|
||||
|
||||
display_info->left_eye = mojom::VREyeParameters::New();
|
||||
display_info->right_eye = mojom::VREyeParameters::New();
|
||||
|
||||
@ -61,7 +59,7 @@ OpenXrDevice::OpenXrDevice(OpenXrStatics* openxr_statics)
|
||||
: VRDeviceBase(device::mojom::XRDeviceId::OPENXR_DEVICE_ID),
|
||||
instance_(openxr_statics->GetXrInstance()),
|
||||
weak_ptr_factory_(this) {
|
||||
mojom::VRDisplayInfoPtr display_info = CreateFakeVRDisplayInfo(GetId());
|
||||
mojom::VRDisplayInfoPtr display_info = CreateFakeVRDisplayInfo();
|
||||
SetVRDisplayInfo(std::move(display_info));
|
||||
|
||||
#if defined(OS_WIN)
|
||||
|
@ -168,8 +168,6 @@ void OpenXrRenderLoop::InitializeDisplayInfo() {
|
||||
current_display_info_->left_eye = mojom::VREyeParameters::New();
|
||||
}
|
||||
|
||||
current_display_info_->id = device::mojom::XRDeviceId::OPENXR_DEVICE_ID;
|
||||
|
||||
gfx::Size view_size = openxr_->GetViewSize();
|
||||
current_display_info_->left_eye->render_width = view_size.width();
|
||||
current_display_info_->right_eye->render_width = view_size.width();
|
||||
|
@ -27,12 +27,6 @@ using gfx::Vector3dF;
|
||||
namespace {
|
||||
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::Screen* screen = display::Screen::GetScreen();
|
||||
if (!screen) {
|
||||
@ -54,7 +48,7 @@ VROrientationDevice::VROrientationDevice(mojom::SensorProvider* sensor_provider,
|
||||
base::BindOnce(&VROrientationDevice::SensorReady,
|
||||
base::Unretained(this)));
|
||||
|
||||
SetVRDisplayInfo(CreateVRDisplayInfo(GetId()));
|
||||
SetVRDisplayInfo(mojom::VRDisplayInfo::New());
|
||||
}
|
||||
|
||||
VROrientationDevice::~VROrientationDevice() {
|
||||
|
@ -298,7 +298,6 @@ struct VRStageParameters {
|
||||
};
|
||||
|
||||
struct VRDisplayInfo {
|
||||
XRDeviceId id;
|
||||
VRStageParameters? stage_parameters;
|
||||
// Parameters required to distort a scene for viewing in a VR headset. Only
|
||||
// required for devices which have the can_present capability.
|
||||
|
@ -17,8 +17,6 @@ FakeVRDevice::~FakeVRDevice() {}
|
||||
|
||||
mojom::VRDisplayInfoPtr FakeVRDevice::InitBasicDevice() {
|
||||
mojom::VRDisplayInfoPtr display_info = mojom::VRDisplayInfo::New();
|
||||
display_info->id = GetId();
|
||||
|
||||
display_info->left_eye = InitEye(45, -0.03f, 1024);
|
||||
display_info->right_eye = InitEye(45, 0.03f, 1024);
|
||||
return display_info;
|
||||
|
@ -66,7 +66,6 @@ void VRDeviceBase::ListenToDeviceChanges(
|
||||
|
||||
void VRDeviceBase::SetVRDisplayInfo(mojom::VRDisplayInfoPtr display_info) {
|
||||
DCHECK(display_info);
|
||||
DCHECK(display_info->id == id_);
|
||||
display_info_ = std::move(display_info);
|
||||
|
||||
if (listener_)
|
||||
|
@ -72,16 +72,10 @@ class VRDeviceTest : public testing::Test {
|
||||
std::unique_ptr<VRDeviceBaseForTesting> MakeVRDevice() {
|
||||
std::unique_ptr<VRDeviceBaseForTesting> device =
|
||||
std::make_unique<VRDeviceBaseForTesting>();
|
||||
device->SetVRDisplayInfoForTest(MakeVRDisplayInfo(device->GetId()));
|
||||
device->SetVRDisplayInfoForTest(mojom::VRDisplayInfo::New());
|
||||
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_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(VRDeviceTest);
|
||||
@ -99,7 +93,7 @@ TEST_F(VRDeviceTest, DeviceChangedDispatched) {
|
||||
base::DoNothing()); // TODO: consider getting initial info
|
||||
base::RunLoop().RunUntilIdle();
|
||||
EXPECT_CALL(listener, DoOnChanged(testing::_)).Times(1);
|
||||
device->SetVRDisplayInfoForTest(MakeVRDisplayInfo(device->GetId()));
|
||||
device->SetVRDisplayInfoForTest(mojom::VRDisplayInfo::New());
|
||||
base::RunLoop().RunUntilIdle();
|
||||
}
|
||||
|
||||
|
@ -27,9 +27,8 @@ namespace {
|
||||
// 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
|
||||
// info changed when we get real data.
|
||||
mojom::VRDisplayInfoPtr CreateFakeVRDisplayInfo(device::mojom::XRDeviceId id) {
|
||||
mojom::VRDisplayInfoPtr CreateFakeVRDisplayInfo() {
|
||||
mojom::VRDisplayInfoPtr display_info = mojom::VRDisplayInfo::New();
|
||||
display_info->id = id;
|
||||
|
||||
display_info->left_eye = mojom::VREyeParameters::New();
|
||||
display_info->right_eye = mojom::VREyeParameters::New();
|
||||
@ -56,7 +55,7 @@ mojom::VRDisplayInfoPtr CreateFakeVRDisplayInfo(device::mojom::XRDeviceId id) {
|
||||
|
||||
MixedRealityDevice::MixedRealityDevice()
|
||||
: VRDeviceBase(device::mojom::XRDeviceId::WINDOWS_MIXED_REALITY_ID) {
|
||||
SetVRDisplayInfo(CreateFakeVRDisplayInfo(GetId()));
|
||||
SetVRDisplayInfo(CreateFakeVRDisplayInfo());
|
||||
}
|
||||
|
||||
MixedRealityDevice::~MixedRealityDevice() {
|
||||
|
@ -671,8 +671,6 @@ bool MixedRealityRenderLoop::UpdateDisplayInfo() {
|
||||
|
||||
if (!current_display_info_) {
|
||||
current_display_info_ = mojom::VRDisplayInfo::New();
|
||||
current_display_info_->id =
|
||||
device::mojom::XRDeviceId::WINDOWS_MIXED_REALITY_ID;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user