OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "modules/vr/VRPose.h" | 5 #include "modules/vr/VRPose.h" |
6 | 6 |
7 namespace blink { | 7 namespace blink { |
8 | 8 |
9 namespace { | 9 namespace { |
10 | 10 |
11 DOMFloat32Array* mojoArrayToFloat32Array( | 11 DOMFloat32Array* mojoArrayToFloat32Array( |
12 const WTF::Optional<WTF::Vector<float>>& vec) { | 12 const WTF::Optional<WTF::Vector<float>>& vec) { |
13 if (!vec) | 13 if (!vec) |
14 return nullptr; | 14 return nullptr; |
15 | 15 |
16 return DOMFloat32Array::create(&(vec.value().first()), vec.value().size()); | 16 return DOMFloat32Array::create(&(vec.value().front()), vec.value().size()); |
17 } | 17 } |
18 | 18 |
19 } // namespace | 19 } // namespace |
20 | 20 |
21 VRPose::VRPose() {} | 21 VRPose::VRPose() {} |
22 | 22 |
23 void VRPose::setPose(const device::mojom::blink::VRPosePtr& state) { | 23 void VRPose::setPose(const device::mojom::blink::VRPosePtr& state) { |
24 if (state.is_null()) | 24 if (state.is_null()) |
25 return; | 25 return; |
26 | 26 |
27 m_orientation = mojoArrayToFloat32Array(state->orientation); | 27 m_orientation = mojoArrayToFloat32Array(state->orientation); |
28 m_position = mojoArrayToFloat32Array(state->position); | 28 m_position = mojoArrayToFloat32Array(state->position); |
29 m_angularVelocity = mojoArrayToFloat32Array(state->angularVelocity); | 29 m_angularVelocity = mojoArrayToFloat32Array(state->angularVelocity); |
30 m_linearVelocity = mojoArrayToFloat32Array(state->linearVelocity); | 30 m_linearVelocity = mojoArrayToFloat32Array(state->linearVelocity); |
31 m_angularAcceleration = mojoArrayToFloat32Array(state->angularAcceleration); | 31 m_angularAcceleration = mojoArrayToFloat32Array(state->angularAcceleration); |
32 m_linearAcceleration = mojoArrayToFloat32Array(state->linearAcceleration); | 32 m_linearAcceleration = mojoArrayToFloat32Array(state->linearAcceleration); |
33 } | 33 } |
34 | 34 |
35 DEFINE_TRACE(VRPose) { | 35 DEFINE_TRACE(VRPose) { |
36 visitor->trace(m_orientation); | 36 visitor->trace(m_orientation); |
37 visitor->trace(m_position); | 37 visitor->trace(m_position); |
38 visitor->trace(m_angularVelocity); | 38 visitor->trace(m_angularVelocity); |
39 visitor->trace(m_linearVelocity); | 39 visitor->trace(m_linearVelocity); |
40 visitor->trace(m_angularAcceleration); | 40 visitor->trace(m_angularAcceleration); |
41 visitor->trace(m_linearAcceleration); | 41 visitor->trace(m_linearAcceleration); |
42 } | 42 } |
43 | 43 |
44 } // namespace blink | 44 } // namespace blink |
OLD | NEW |