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

Unified Diff: public/platform/WebVR.h

Issue 848053002: Adding WebVR interface to Blink (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 5 years, 11 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: public/platform/WebVR.h
diff --git a/public/platform/WebVR.h b/public/platform/WebVR.h
new file mode 100644
index 0000000000000000000000000000000000000000..817d44e842e96fa9dc1017f0ea6a445471b9f158
--- /dev/null
+++ b/public/platform/WebVR.h
@@ -0,0 +1,109 @@
+// Copyright 2014 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 WebVR_h
+#define WebVR_h
+
+#include "WebCommon.h"
+
+#if BLINK_IMPLEMENTATION
+#include "wtf/Assertions.h"
+#endif
+
+namespace blink {
+
+#pragma pack(push, 1)
+
+struct WebVRVector3 {
+ float x, y, z;
+};
+
+struct WebVRVector4 {
+ float x, y, z, w;
+};
+
+struct WebVRFieldOfView {
+ float upDegrees;
+ float downDegrees;
+ float leftDegrees;
+ float rightDegrees;
+};
+
+enum WebVRSensorState {
+ WebVRSensorStateOrientation = 1 << 1,
+ WebVRSensorStatePosition = 1 << 2,
+ WebVRSensorStateAngularVelocity = 1 << 3,
+ WebVRSensorStateLinearVelocity = 1 << 4,
+ WebVRSensorStateAngularAcceleration = 1 << 5,
+ WebVRSensorStateLinearAcceleration = 1 << 6,
+ WebVRSensorStateComplete = (1 << 7) - 1 // All previous states combined
+};
+
+// A bitfield of WebVRSensorState
+typedef int WebVRSensorStateMask;
+
+enum WebVRDeviceType {
+ WebVRDeviceTypePosition = 1 << 1,
+ WebVRDeviceTypeHMD = 1 << 2
+};
+
+// A bitfield of WebVRDeviceType
+typedef int WebVRDeviceTypeMask;
+
+class WebHMDSensorState {
+public:
+ WebHMDSensorState()
+ {
+ }
+
+ double timestamp;
+ unsigned frameIndex;
+ WebVRSensorStateMask flags;
+ WebVRVector4 orientation;
+ WebVRVector3 position;
+ WebVRVector3 angularVelocity;
+ WebVRVector3 linearVelocity;
+ WebVRVector3 angularAcceleration;
+ WebVRVector3 linearAcceleration;
+};
+
+struct WebVRHMDInfo {
+ WebVRFieldOfView recommendedFOVLeft;
+ WebVRFieldOfView recommendedFOVRight;
+ WebVRFieldOfView maximumFOVLeft;
+ WebVRFieldOfView maximumFOVRight;
+ WebVRVector3 eyeTranslationLeft;
+ WebVRVector3 eyeTranslationRight;
+};
+
+class WebVRDevice {
+public:
+ static const size_t deviceIdLengthCap = 128;
+ static const size_t deviceNameLengthCap = 128;
+
+ WebVRDevice()
+ : flags(0)
+ {
+ deviceId[0] = 0;
+ deviceName[0] = 0;
+ }
+
+ // Index for this hardware unit
+ unsigned index;
+ // Device identifier (based on manufacturer, model, etc.).
Ken Russell (switch to Gerrit) 2015/02/04 19:14:00 Is there any reason not to use WebString for both
+ WebUChar deviceId[deviceIdLengthCap];
+ // Friendly device name
+ WebUChar deviceName[deviceNameLengthCap];
+
+ WebVRDeviceTypeMask flags;
+
+ // Will only contain valid data if (flags & HasHMDDevice)
+ WebVRHMDInfo hmdInfo;
+};
+
+#pragma pack(pop)
+
+}
+
+#endif // WebVR_h

Powered by Google App Engine
This is Rietveld 408576698