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