OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
haraken
2016/04/27 15:52:13
2016
RaviKasibhatla
2016/04/28 14:34:15
Done.
| |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "modules/vr/VRTypeConverters.h" | |
6 | |
7 #include <string.h> | |
8 | |
haraken
2016/04/27 15:52:13
Remove the empty line.
RaviKasibhatla
2016/04/28 14:34:15
Done.
| |
9 #include <algorithm> | |
10 | |
11 using blink::mojom::VRVector3Ptr; | |
12 using blink::mojom::VRVector4Ptr; | |
13 using blink::mojom::VRRectPtr; | |
14 using blink::mojom::VRFieldOfViewPtr; | |
15 using blink::mojom::VREyeParametersPtr; | |
16 using blink::mojom::VRHMDInfoPtr; | |
17 using blink::mojom::VRDeviceInfoPtr; | |
18 using blink::mojom::VRSensorStatePtr; | |
19 | |
20 namespace mojo { | |
21 | |
22 // static | |
23 blink::WebVRVector3 TypeConverter<blink::WebVRVector3, VRVector3Ptr>::Convert( | |
24 const VRVector3Ptr& input) | |
25 { | |
26 blink::WebVRVector3 output; | |
27 output.x = input->x; | |
28 output.y = input->y; | |
29 output.z = input->z; | |
30 return output; | |
31 } | |
32 | |
33 // static | |
34 blink::WebVRVector4 TypeConverter<blink::WebVRVector4, VRVector4Ptr>::Convert( | |
35 const VRVector4Ptr& input) | |
36 { | |
37 blink::WebVRVector4 output; | |
38 output.x = input->x; | |
39 output.y = input->y; | |
40 output.z = input->z; | |
41 output.w = input->w; | |
42 return output; | |
43 } | |
44 | |
45 // static | |
46 blink::WebVRRect TypeConverter<blink::WebVRRect, VRRectPtr>::Convert( | |
47 const VRRectPtr& input) | |
48 { | |
49 blink::WebVRRect output; | |
50 output.x = input->x; | |
51 output.y = input->y; | |
52 output.width = input->width; | |
53 output.height = input->height; | |
54 return output; | |
55 } | |
56 | |
57 // static | |
58 blink::WebVRFieldOfView | |
59 TypeConverter<blink::WebVRFieldOfView, VRFieldOfViewPtr>::Convert( | |
60 const VRFieldOfViewPtr& input) | |
61 { | |
62 blink::WebVRFieldOfView output; | |
63 output.upDegrees = input->upDegrees; | |
64 output.downDegrees = input->downDegrees; | |
65 output.leftDegrees = input->leftDegrees; | |
66 output.rightDegrees = input->rightDegrees; | |
67 return output; | |
68 } | |
69 | |
70 // static | |
71 blink::WebVREyeParameters | |
72 TypeConverter<blink::WebVREyeParameters, VREyeParametersPtr>::Convert( | |
73 const VREyeParametersPtr& input) | |
74 { | |
75 blink::WebVREyeParameters output; | |
76 output.minimumFieldOfView = input->minimumFieldOfView.To<blink::WebVRFieldOf View>(); | |
77 output.maximumFieldOfView = input->maximumFieldOfView.To<blink::WebVRFieldOf View>(); | |
78 output.recommendedFieldOfView = input->recommendedFieldOfView.To<blink::WebV RFieldOfView>(); | |
79 output.eyeTranslation = input->eyeTranslation.To<blink::WebVRVector3>(); | |
80 output.renderRect = input->renderRect.To<blink::WebVRRect>(); | |
81 return output; | |
82 } | |
83 | |
84 // static | |
85 blink::WebVRHMDInfo TypeConverter<blink::WebVRHMDInfo, VRHMDInfoPtr>::Convert( | |
86 const VRHMDInfoPtr& input) | |
87 { | |
88 blink::WebVRHMDInfo output; | |
89 output.leftEye = input->leftEye.To<blink::WebVREyeParameters>(); | |
90 output.rightEye = input->rightEye.To<blink::WebVREyeParameters>(); | |
91 return output; | |
92 } | |
93 | |
94 // static | |
95 blink::WebVRDevice TypeConverter<blink::WebVRDevice, VRDeviceInfoPtr>::Convert( | |
96 const VRDeviceInfoPtr& input) | |
97 { | |
98 blink::WebVRDevice output; | |
99 memset(&output, 0, sizeof(blink::WebVRDevice)); | |
100 | |
101 output.index = input->index; | |
102 output.flags = blink::WebVRDeviceTypePosition; | |
103 output.deviceName = blink::WebString::fromUTF8(input->deviceName.data(), | |
104 input->deviceName.size()); | |
105 | |
106 if (!input->hmdInfo.is_null()) { | |
107 output.flags |= blink::WebVRDeviceTypeHMD; | |
108 output.hmdInfo = input->hmdInfo.To<blink::WebVRHMDInfo>(); | |
109 } | |
110 | |
111 return output; | |
112 } | |
113 | |
114 // static | |
115 blink::WebHMDSensorState | |
116 TypeConverter<blink::WebHMDSensorState, VRSensorStatePtr>::Convert( | |
117 const VRSensorStatePtr& input) | |
118 { | |
119 blink::WebHMDSensorState output; | |
120 output.timestamp = input->timestamp; | |
121 output.frameIndex = input->frameIndex; | |
122 output.flags = 0; | |
123 | |
124 if (!input->orientation.is_null()) { | |
125 output.flags |= blink::WebVRSensorStateOrientation; | |
126 output.orientation = input->orientation.To<blink::WebVRVector4>(); | |
127 } | |
128 if (!input->position.is_null()) { | |
129 output.flags |= blink::WebVRSensorStatePosition; | |
130 output.position = input->position.To<blink::WebVRVector3>(); | |
131 } | |
132 if (!input->angularVelocity.is_null()) { | |
133 output.flags |= blink::WebVRSensorStateAngularVelocity; | |
134 output.angularVelocity = input->angularVelocity.To<blink::WebVRVector3>( ); | |
135 } | |
136 if (!input->linearVelocity.is_null()) { | |
137 output.flags |= blink::WebVRSensorStateLinearVelocity; | |
138 output.linearVelocity = input->linearVelocity.To<blink::WebVRVector3>(); | |
139 } | |
140 if (!input->angularAcceleration.is_null()) { | |
141 output.flags |= blink::WebVRSensorStateAngularAcceleration; | |
142 output.angularAcceleration = input->angularAcceleration.To<blink::WebVRV ector3>(); | |
143 } | |
144 if (!input->linearAcceleration.is_null()) { | |
145 output.flags |= blink::WebVRSensorStateLinearAcceleration; | |
146 output.linearAcceleration = input->linearAcceleration.To<blink::WebVRVec tor3>(); | |
147 } | |
148 | |
149 return output; | |
150 } | |
151 | |
152 } // namespace mojo | |
OLD | NEW |