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

Unified Diff: content/renderer/device_sensors/device_orientation_util.h

Issue 2885203004: Refactor content/renderer/device_sensors to use device/generic_sensor instead of device/sensors (Closed)
Patch Set: updated content/renderer/BUILD.gn Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: content/renderer/device_sensors/device_orientation_util.h
diff --git a/content/renderer/device_sensors/device_orientation_util.h b/content/renderer/device_sensors/device_orientation_util.h
new file mode 100644
index 0000000000000000000000000000000000000000..ca08af3508a48f3020e25cfb25a86c2f59cb88ed
--- /dev/null
+++ b/content/renderer/device_sensors/device_orientation_util.h
@@ -0,0 +1,52 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_RENDERER_DEVICE_SENSORS_DEVICE_ORIENTATION_UTIL_H_
+#define CONTENT_RENDERER_DEVICE_SENSORS_DEVICE_ORIENTATION_UTIL_H_
+
+#include "content/common/content_export.h"
+#include "device/generic_sensor/public/cpp/sensor_reading.h"
+#include "device/generic_sensor/public/interfaces/sensor.mojom.h"
+
+namespace blink {
+class WebDeviceOrientationData;
+}
+
+namespace content {
+
+// Angle threshold beyond which two orientation events are considered
+// sufficiently different.
+constexpr double kOrientationThreshold = 0.1;
+
+constexpr uint64_t kReadingBufferSize =
+ sizeof(device::SensorReadingSharedBuffer);
+
+constexpr uint64_t kSharedBufferSizeInBytes =
+ kReadingBufferSize * static_cast<uint64_t>(device::mojom::SensorType::LAST);
+
+bool IsSignificantlyDifferent(const blink::WebDeviceOrientationData& data1,
+ const blink::WebDeviceOrientationData& data2);
+
+void CONTENT_EXPORT ComputeDeviceOrientationFromQuaternion(double x,
+ double y,
+ double z,
+ double w,
+ double* alpha,
+ double* beta,
+ double* gamma);
+
+bool CONTENT_EXPORT
+ComputeDeviceOrientationFromGravityAndGeomagnetic(double gravity_x,
+ double gravity_y,
+ double gravity_z,
+ double geomagnetic_x,
+ double geomagnetic_y,
+ double geomagnetic_z,
+ double* alpha,
+ double* beta,
+ double* gamma);
+
+} // namespace content
+
+#endif // CONTENT_RENDERER_DEVICE_SENSORS_DEVICE_ORIENTATION_UTIL_H_

Powered by Google App Engine
This is Rietveld 408576698