| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "modules/sensor/OrientationSensor.h" | 5 #include "modules/sensor/OrientationSensor.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ExceptionState.h" | 7 #include "bindings/core/v8/ExceptionState.h" |
| 8 #include "core/geometry/DOMMatrix.h" | 8 #include "core/geometry/DOMMatrix.h" |
| 9 | 9 |
| 10 using device::mojom::blink::SensorType; | 10 using device::mojom::blink::SensorType; |
| 11 | 11 |
| 12 namespace blink { | 12 namespace blink { |
| 13 | 13 |
| 14 Vector<double> OrientationSensor::quaternion(bool& is_null) { | 14 Vector<double> OrientationSensor::quaternion(bool& is_null) { |
| 15 reading_dirty_ = false; | 15 reading_dirty_ = false; |
| 16 is_null = !CanReturnReadings(); | 16 is_null = !CanReturnReadings(); |
| 17 return is_null ? Vector<double>() | 17 return is_null ? Vector<double>() |
| 18 : Vector<double>({ReadingValueUnchecked(3), // W | 18 : Vector<double>({ReadingValueUnchecked(0), // Vx |
| 19 ReadingValueUnchecked(0), // Vx | |
| 20 ReadingValueUnchecked(1), // Vy | 19 ReadingValueUnchecked(1), // Vy |
| 21 ReadingValueUnchecked(2)}); // Vz | 20 ReadingValueUnchecked(2), // Vz |
| 21 ReadingValueUnchecked(3)}); // W |
| 22 } | 22 } |
| 23 | 23 |
| 24 template <typename T> | 24 template <typename T> |
| 25 void DoPopulateMatrix(T* target_matrix, | 25 void DoPopulateMatrix(T* target_matrix, |
| 26 double x, | 26 double x, |
| 27 double y, | 27 double y, |
| 28 double z, | 28 double z, |
| 29 double w) { | 29 double w) { |
| 30 auto out = target_matrix->Data(); | 30 auto out = target_matrix->Data(); |
| 31 out[0] = 1.0 - 2 * (y * y + z * z); | 31 out[0] = 1.0 - 2 * (y * y + z * z); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 | 129 |
| 130 void OrientationSensor::OnSensorReadingChanged() { | 130 void OrientationSensor::OnSensorReadingChanged() { |
| 131 reading_dirty_ = true; | 131 reading_dirty_ = true; |
| 132 } | 132 } |
| 133 | 133 |
| 134 DEFINE_TRACE(OrientationSensor) { | 134 DEFINE_TRACE(OrientationSensor) { |
| 135 Sensor::Trace(visitor); | 135 Sensor::Trace(visitor); |
| 136 } | 136 } |
| 137 | 137 |
| 138 } // namespace blink | 138 } // namespace blink |
| OLD | NEW |