Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(69)

Side by Side Diff: third_party/WebKit/Source/modules/sensor/OrientationSensor.cpp

Issue 2809743002: [Sensors] OrientationSensor.quaternion returns [x, y, z, w] (Closed)
Patch Set: rebased Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/sensor/absolute-orientation-sensor.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/sensor/absolute-orientation-sensor.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698