Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / public / platform / modules / vr / WebVR.h
blob404fd4b8c667fffbe5aac502a2929f4909e24e51
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
3 // found in the LICENSE file.
5 #ifndef WebVR_h
6 #define WebVR_h
8 #include "public/platform/WebCommon.h"
9 #include "public/platform/WebString.h"
11 #if BLINK_IMPLEMENTATION
12 #include "wtf/Assertions.h"
13 #endif
15 namespace blink {
17 struct WebVRVector3 {
18 float x, y, z;
21 struct WebVRVector4 {
22 float x, y, z, w;
25 struct WebVRRect {
26 int x, y, width, height;
29 // A field of view, given by 4 degrees describing the view from a center point.
30 struct WebVRFieldOfView {
31 float upDegrees;
32 float downDegrees;
33 float leftDegrees;
34 float rightDegrees;
37 // Bit flags to indicate which fields of an WebHMDSensorState are valid.
38 enum WebVRSensorStateFlags {
39 WebVRSensorStateOrientation = 1 << 1,
40 WebVRSensorStatePosition = 1 << 2,
41 WebVRSensorStateAngularVelocity = 1 << 3,
42 WebVRSensorStateLinearVelocity = 1 << 4,
43 WebVRSensorStateAngularAcceleration = 1 << 5,
44 WebVRSensorStateLinearAcceleration = 1 << 6,
45 WebVRSensorStateComplete = (1 << 7) - 1 // All previous states combined.
48 // A bitfield of WebVRSensorStateFlags.
49 typedef int WebVRSensorStateMask;
51 // A sensor's position, orientation, velocity, and acceleration state at the
52 // given timestamp.
53 struct WebHMDSensorState {
54 double timestamp;
55 unsigned frameIndex;
56 WebVRSensorStateMask flags;
57 WebVRVector4 orientation;
58 WebVRVector3 position;
59 WebVRVector3 angularVelocity;
60 WebVRVector3 linearVelocity;
61 WebVRVector3 angularAcceleration;
62 WebVRVector3 linearAcceleration;
65 // Information about the optical properties for an eye in an HMD.
66 struct WebVREyeParameters {
67 WebVRFieldOfView minimumFieldOfView;
68 WebVRFieldOfView maximumFieldOfView;
69 WebVRFieldOfView recommendedFieldOfView;
70 WebVRVector3 eyeTranslation;
71 WebVRRect renderRect;
74 // Information pertaining to Head Mounted Displays.
75 struct WebVRHMDInfo {
76 WebVREyeParameters leftEye;
77 WebVREyeParameters rightEye;
80 // Bit flags to indicate what type of data a WebVRDevice describes.
81 enum WebVRDeviceTypeFlags {
82 WebVRDeviceTypePosition = 1 << 1,
83 WebVRDeviceTypeHMD = 1 << 2
86 // A bitfield of WebVRDeviceTypeFlags.
87 typedef int WebVRDeviceTypeMask;
89 // Describes a single VR hardware unit. May describe multiple capabilities,
90 // such as position sensors or head mounted display metrics.
91 struct WebVRDevice {
92 // Index for this hardware unit.
93 unsigned index;
94 // Friendly device name.
95 WebString deviceName;
96 // Identifies the capabilities of this hardware unit.
97 WebVRDeviceTypeMask flags;
98 // Will only contain valid data if (flags & HasHMDDevice).
99 WebVRHMDInfo hmdInfo;
104 #endif // WebVR_h