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

Side by Side 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: Fixed compiler warning treated as an error on Windows Created 5 years, 9 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
OLDNEW
(Empty)
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.
4
5 #ifndef WebVR_h
6 #define WebVR_h
7
8 #include "WebCommon.h"
9
10 #if BLINK_IMPLEMENTATION
11 #include "wtf/Assertions.h"
12 #endif
13
14 namespace blink {
15
16 struct WebVRVector3 {
17 float x, y, z;
18 };
19
20 struct WebVRVector4 {
21 float x, y, z, w;
22 };
23
24 // A field of view, given by 4 degrees describing the view from a center point.
25 struct WebVRFieldOfView {
26 float upDegrees;
27 float downDegrees;
28 float leftDegrees;
29 float rightDegrees;
30 };
31
32 // Bit flags to indicate which fields of an WebHMDSensorState are valid.
33 enum WebVRSensorStateFlags {
34 WebVRSensorStateOrientation = 1 << 1,
35 WebVRSensorStatePosition = 1 << 2,
36 WebVRSensorStateAngularVelocity = 1 << 3,
37 WebVRSensorStateLinearVelocity = 1 << 4,
38 WebVRSensorStateAngularAcceleration = 1 << 5,
39 WebVRSensorStateLinearAcceleration = 1 << 6,
40 WebVRSensorStateComplete = (1 << 7) - 1 // All previous states combined.
41 };
42
43 // A bitfield of WebVRSensorStateFlags.
44 typedef int WebVRSensorStateMask;
45
46 // A sensor's position, orientation, velocity, and acceleration state at the
47 // given timestamp.
48 struct WebHMDSensorState {
49 double timestamp;
50 unsigned frameIndex;
51 WebVRSensorStateMask flags;
52 WebVRVector4 orientation;
53 WebVRVector3 position;
54 WebVRVector3 angularVelocity;
55 WebVRVector3 linearVelocity;
56 WebVRVector3 angularAcceleration;
57 WebVRVector3 linearAcceleration;
58 };
59
60 // Information about the optical properties for an eye in an HMD.
61 struct WebVREyeParameters {
62 WebVRFieldOfView minimumFieldOfView;
63 WebVRFieldOfView maximumFieldOfView;
64 WebVRFieldOfView recommendedFieldOfView;
65 WebVRVector3 eyeTranslation;
66 };
67
68 // Information pertaining to Head Mounted Displays.
69 struct WebVRHMDInfo {
70 WebVREyeParameters leftEye;
71 WebVREyeParameters rightEye;
72 };
73
74 // Bit flags to indicate what type of data a WebVRDevice describes.
75 enum WebVRDeviceTypeFlags {
76 WebVRDeviceTypePosition = 1 << 1,
77 WebVRDeviceTypeHMD = 1 << 2
78 };
79
80 // A bitfield of WebVRDeviceTypeFlags.
81 typedef int WebVRDeviceTypeMask;
82
83 // Describes a single VR hardware unit. May describe multiple capabilities,
84 // such as position sensors or head mounted display metrics.
85 class WebVRDevice {
86 public:
87 static const size_t deviceIdLengthCap = 128;
88 static const size_t deviceNameLengthCap = 128;
89
90 WebVRDevice()
91 : flags(0)
92 {
93 deviceId[0] = 0;
94 deviceName[0] = 0;
95 }
96
97 // Index for this hardware unit.
98 unsigned index;
99 // Device identifier (based on manufacturer, model, etc.).
100 WebUChar deviceId[deviceIdLengthCap];
101 // Friendly device name.
102 WebUChar deviceName[deviceNameLengthCap];
103 // Identifies the capabilities of this hardware unit.
104 WebVRDeviceTypeMask flags;
105
106 // Will only contain valid data if (flags & HasHMDDevice).
107 WebVRHMDInfo hmdInfo;
108 };
109
110 }
111
112 #endif // WebVR_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698