Commit d2d58cb0 authored by Anna Offenwanger's avatar Anna Offenwanger Committed by Commit Bot

Special casing windows for VR orientation device

Chrome for windows does not support the relative orientation sensor, so
if we are on windows, use the absolute sensor.

Bug: 820308
Change-Id: I3630ae8417839d94bedf8901b4f1509ed8e071d0
Reviewed-on: https://chromium-review.googlesource.com/1050372
Commit-Queue: Anna Offenwanger <offenwanger@chromium.org>
Reviewed-by: default avatarBill Orr <billorr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#557947}
parent c654ee39
......@@ -17,7 +17,6 @@
namespace device {
using mojom::SensorType;
using gfx::Quaternion;
using gfx::Vector3dF;
......@@ -54,11 +53,8 @@ VROrientationDevice::VROrientationDevice(
mojom::SensorProviderPtr* sensor_provider,
base::OnceClosure ready_callback)
: ready_callback_(std::move(ready_callback)), binding_(this) {
// Use RELATIVE_ORIENTATION_QUATERNION rather than
// ABSOLUTE_ORIENTATION_QUATERNION because compass readings can be innacurate
// when used indoors.
(*sensor_provider)
->GetSensor(SensorType::RELATIVE_ORIENTATION_QUATERNION,
->GetSensor(kOrientationSensorType,
base::BindOnce(&VROrientationDevice::SensorReady,
base::Unretained(this)));
......
......@@ -10,6 +10,7 @@
#include "base/callback_forward.h"
#include "base/macros.h"
#include "base/threading/simple_thread.h"
#include "build/build_config.h"
#include "device/vr/public/mojom/vr_service.mojom.h"
#include "device/vr/vr_device_base.h"
#include "mojo/public/cpp/bindings/binding.h"
......@@ -20,6 +21,19 @@ namespace device {
class SensorReadingSharedBufferReader;
// Use RELATIVE_ORIENTATION_QUATERNION rather than
// ABSOLUTE_ORIENTATION_QUATERNION because compass readings can be inacurate
// when used indoors, unless we're on Windows which doesn't support
// RELATIVE_ORIENTATION_QUATERNION.
// TODO(crbug.com/730440) If RELATIVE_ORIENTATION_QUATERNION is ever
// implemented on Windows, use that instead.
static constexpr mojom::SensorType kOrientationSensorType =
#if defined(OS_WIN)
mojom::SensorType::ABSOLUTE_ORIENTATION_QUATERNION;
#else
mojom::SensorType::RELATIVE_ORIENTATION_QUATERNION;
#endif
// This class connects the orientation sensor events to the Web VR apis.
class DEVICE_VR_EXPORT VROrientationDevice : public VRDeviceBase,
public mojom::SensorClient {
......
......@@ -70,16 +70,15 @@ class VROrientationDeviceProviderTest : public testing::Test {
auto init_params = mojom::SensorInitParams::New();
init_params->sensor = std::move(sensor_ptr_);
init_params->default_configuration = PlatformSensorConfiguration(
SensorTraits<mojom::SensorType::RELATIVE_ORIENTATION_QUATERNION>::
kDefaultFrequency);
SensorTraits<kOrientationSensorType>::kDefaultFrequency);
init_params->client_request = mojo::MakeRequest(&sensor_client_ptr_);
init_params->memory = shared_buffer_handle_->Clone(
mojo::SharedBufferHandle::AccessMode::READ_ONLY);
init_params->buffer_offset = SensorReadingSharedBuffer::GetOffset(
mojom::SensorType::RELATIVE_ORIENTATION_QUATERNION);
init_params->buffer_offset =
SensorReadingSharedBuffer::GetOffset(kOrientationSensorType);
return init_params;
}
......
......@@ -100,8 +100,7 @@ class VROrientationDeviceTest : public testing::Test {
void TearDown() override { shared_buffer_handle_.reset(); }
double GetBufferOffset() {
return SensorReadingSharedBuffer::GetOffset(
mojom::SensorType::RELATIVE_ORIENTATION_QUATERNION);
return SensorReadingSharedBuffer::GetOffset(kOrientationSensorType);
}
void InitializeDevice(mojom::SensorInitParamsPtr params) {
......@@ -154,8 +153,7 @@ class VROrientationDeviceTest : public testing::Test {
auto init_params = mojom::SensorInitParams::New();
init_params->sensor = std::move(sensor_ptr_);
init_params->default_configuration = PlatformSensorConfiguration(
SensorTraits<mojom::SensorType::RELATIVE_ORIENTATION_QUATERNION>::
kDefaultFrequency);
SensorTraits<kOrientationSensorType>::kDefaultFrequency);
init_params->client_request = mojo::MakeRequest(&sensor_client_ptr_);
......
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