Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
|
haraken
2015/02/25 11:52:56
2015
| |
| 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 { | |
|
sof
2015/02/25 06:30:34
Could we have some comments, description, somethin
| |
| 15 | |
| 16 #pragma pack(push, 1) | |
|
haraken
2015/02/25 11:52:56
Does this really matter? (Otherwise, we don't want
| |
| 17 | |
| 18 struct WebVRVector3 { | |
| 19 float x, y, z; | |
| 20 }; | |
| 21 | |
| 22 struct WebVRVector4 { | |
| 23 float x, y, z, w; | |
| 24 }; | |
| 25 | |
| 26 struct WebVRFieldOfView { | |
| 27 float upDegrees; | |
| 28 float downDegrees; | |
| 29 float leftDegrees; | |
| 30 float rightDegrees; | |
| 31 }; | |
| 32 | |
| 33 enum WebVRSensorState { | |
| 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 WebVRSensorState | |
| 44 typedef int WebVRSensorStateMask; | |
| 45 | |
| 46 enum WebVRDeviceType { | |
| 47 WebVRDeviceTypePosition = 1 << 1, | |
| 48 WebVRDeviceTypeHMD = 1 << 2 | |
| 49 }; | |
| 50 | |
| 51 // A bitfield of WebVRDeviceType | |
| 52 typedef int WebVRDeviceTypeMask; | |
| 53 | |
| 54 class WebHMDSensorState { | |
| 55 public: | |
| 56 WebHMDSensorState() | |
| 57 { | |
| 58 } | |
| 59 | |
| 60 double timestamp; | |
| 61 unsigned frameIndex; | |
| 62 WebVRSensorStateMask flags; | |
| 63 WebVRVector4 orientation; | |
| 64 WebVRVector3 position; | |
| 65 WebVRVector3 angularVelocity; | |
| 66 WebVRVector3 linearVelocity; | |
| 67 WebVRVector3 angularAcceleration; | |
| 68 WebVRVector3 linearAcceleration; | |
| 69 }; | |
| 70 | |
| 71 struct WebVRHMDInfo { | |
| 72 WebVRFieldOfView recommendedFOVLeft; | |
| 73 WebVRFieldOfView recommendedFOVRight; | |
| 74 WebVRFieldOfView maximumFOVLeft; | |
| 75 WebVRFieldOfView maximumFOVRight; | |
| 76 WebVRVector3 eyeTranslationLeft; | |
| 77 WebVRVector3 eyeTranslationRight; | |
| 78 }; | |
| 79 | |
| 80 class WebVRDevice { | |
| 81 public: | |
| 82 static const size_t deviceIdLengthCap = 128; | |
| 83 static const size_t deviceNameLengthCap = 128; | |
| 84 | |
| 85 WebVRDevice() | |
| 86 : flags(0) | |
| 87 { | |
| 88 deviceId[0] = 0; | |
| 89 deviceName[0] = 0; | |
| 90 } | |
| 91 | |
| 92 // Index for this hardware unit | |
| 93 unsigned index; | |
| 94 // Device identifier (based on manufacturer, model, etc.). | |
| 95 WebUChar deviceId[deviceIdLengthCap]; | |
| 96 // Friendly device name | |
| 97 WebUChar deviceName[deviceNameLengthCap]; | |
| 98 | |
| 99 WebVRDeviceTypeMask flags; | |
| 100 | |
| 101 // Will only contain valid data if (flags & HasHMDDevice) | |
| 102 WebVRHMDInfo hmdInfo; | |
| 103 }; | |
| 104 | |
| 105 #pragma pack(pop) | |
| 106 | |
| 107 } | |
| 108 | |
| 109 #endif // WebVR_h | |
| OLD | NEW |