OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/browser/device_sensors/sensor_manager_chromeos.h" | 5 #include "device/sensors/sensor_manager_chromeos.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 | 8 |
9 #include "chromeos/accelerometer/accelerometer_reader.h" | 9 #include "chromeos/accelerometer/accelerometer_reader.h" |
10 #include "chromeos/accelerometer/accelerometer_types.h" | 10 #include "chromeos/accelerometer/accelerometer_types.h" |
11 #include "content/browser/device_sensors/device_sensors_consts.h" | 11 #include "device/sensors/device_sensors_consts.h" |
12 #include "ui/gfx/geometry/vector3d_f.h" | 12 #include "ui/gfx/geometry/vector3d_f.h" |
13 | 13 |
14 namespace { | 14 namespace { |
15 // Conversion ratio from radians to degrees. | 15 // Conversion ratio from radians to degrees. |
16 const double kRad2deg = 180.0 / M_PI; | 16 const double kRad2deg = 180.0 / M_PI; |
17 } | 17 } |
18 | 18 |
19 namespace content { | 19 namespace device { |
20 | 20 |
21 SensorManagerChromeOS::SensorManagerChromeOS() | 21 SensorManagerChromeOS::SensorManagerChromeOS() |
22 : motion_buffer_(nullptr), orientation_buffer_(nullptr) { | 22 : motion_buffer_(nullptr), orientation_buffer_(nullptr) {} |
23 } | |
24 | 23 |
25 SensorManagerChromeOS::~SensorManagerChromeOS() { | 24 SensorManagerChromeOS::~SensorManagerChromeOS() {} |
26 } | |
27 | 25 |
28 void SensorManagerChromeOS::StartFetchingDeviceMotionData( | 26 void SensorManagerChromeOS::StartFetchingDeviceMotionData( |
29 DeviceMotionHardwareBuffer* buffer) { | 27 DeviceMotionHardwareBuffer* buffer) { |
30 DCHECK(thread_checker_.CalledOnValidThread()); | 28 DCHECK(thread_checker_.CalledOnValidThread()); |
31 DCHECK(!motion_buffer_); | 29 DCHECK(!motion_buffer_); |
32 motion_buffer_ = buffer; | 30 motion_buffer_ = buffer; |
33 | 31 |
34 motion_buffer_->seqlock.WriteBegin(); | 32 motion_buffer_->seqlock.WriteBegin(); |
35 // The interval between updates is the longer of the rate set on the buffer, | 33 // The interval between updates is the longer of the rate set on the buffer, |
36 // and the rate at which AccelerometerReader polls the sensor. | 34 // and the rate at which AccelerometerReader polls the sensor. |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 gamma = -90.0f; | 156 gamma = -90.0f; |
159 orientation_buffer_->seqlock.WriteBegin(); | 157 orientation_buffer_->seqlock.WriteBegin(); |
160 orientation_buffer_->data.beta = beta; | 158 orientation_buffer_->data.beta = beta; |
161 orientation_buffer_->data.hasBeta = true; | 159 orientation_buffer_->data.hasBeta = true; |
162 orientation_buffer_->data.gamma = gamma; | 160 orientation_buffer_->data.gamma = gamma; |
163 orientation_buffer_->data.hasGamma = true; | 161 orientation_buffer_->data.hasGamma = true; |
164 orientation_buffer_->data.allAvailableSensorsAreActive = true; | 162 orientation_buffer_->data.allAvailableSensorsAreActive = true; |
165 orientation_buffer_->seqlock.WriteEnd(); | 163 orientation_buffer_->seqlock.WriteEnd(); |
166 } | 164 } |
167 | 165 |
168 } // namespace content | 166 } // namespace device |
OLD | NEW |