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/VRHardwareUnit.h" | 5 #include "modules/vr/VRHardwareUnit.h" |
6 | 6 |
7 #include "modules/vr/HMDVRDevice.h" | 7 #include "modules/vr/HMDVRDevice.h" |
8 #include "modules/vr/NavigatorVRDevice.h" | 8 #include "modules/vr/NavigatorVRDevice.h" |
9 #include "modules/vr/PositionSensorVRDevice.h" | 9 #include "modules/vr/PositionSensorVRDevice.h" |
10 #include "modules/vr/VRController.h" | 10 #include "modules/vr/VRController.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 Platform::current()->currentThread()->addTaskObserver(this); | 71 Platform::current()->currentThread()->addTaskObserver(this); |
72 m_canUpdatePositionState = false; | 72 m_canUpdatePositionState = false; |
73 } | 73 } |
74 | 74 |
75 return m_positionState; | 75 return m_positionState; |
76 } | 76 } |
77 | 77 |
78 VRPositionState* VRHardwareUnit::getImmediateSensorState(bool updateFrameIndex) | 78 VRPositionState* VRHardwareUnit::getImmediateSensorState(bool updateFrameIndex) |
79 { | 79 { |
80 WebHMDSensorState state; | 80 WebHMDSensorState state; |
81 controller()->getSensorState(m_index, state); | 81 controller()->getSensorState(m_index, &state); |
82 if (updateFrameIndex) | 82 if (updateFrameIndex) |
83 m_frameIndex = state.frameIndex; | 83 m_frameIndex = state.frameIndex; |
84 | 84 |
85 VRPositionState* immediatePositionState = VRPositionState::create(); | 85 VRPositionState* immediatePositionState = VRPositionState::create(); |
86 immediatePositionState->setState(state); | 86 immediatePositionState->setState(state); |
87 return immediatePositionState; | 87 return immediatePositionState; |
88 } | 88 } |
89 | 89 |
90 | 90 |
91 void VRHardwareUnit::didProcessTask() | 91 void VRHardwareUnit::didProcessTask() |
92 { | 92 { |
93 // State should be stable until control is returned to the user agent. | 93 // State should be stable until control is returned to the user agent. |
94 if (!m_canUpdatePositionState) { | 94 if (!m_canUpdatePositionState) { |
95 Platform::current()->currentThread()->removeTaskObserver(this); | 95 Platform::current()->currentThread()->removeTaskObserver(this); |
96 m_canUpdatePositionState = true; | 96 m_canUpdatePositionState = true; |
97 } | 97 } |
98 } | 98 } |
99 | 99 |
100 DEFINE_TRACE(VRHardwareUnit) | 100 DEFINE_TRACE(VRHardwareUnit) |
101 { | 101 { |
102 visitor->trace(m_navigatorVRDevice); | 102 visitor->trace(m_navigatorVRDevice); |
103 visitor->trace(m_positionState); | 103 visitor->trace(m_positionState); |
104 visitor->trace(m_hmd); | 104 visitor->trace(m_hmd); |
105 visitor->trace(m_positionSensor); | 105 visitor->trace(m_positionSensor); |
106 } | 106 } |
107 | 107 |
108 } // namespace blink | 108 } // namespace blink |
OLD | NEW |