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 #include "modules/vr/VRHardwareUnitCollection.h" | |
6 | |
7 #include "bindings/core/v8/ScriptPromiseResolver.h" | |
8 #include "core/dom/Document.h" | |
9 #include "core/frame/LocalDOMWindow.h" | |
10 #include "core/frame/LocalFrame.h" | |
11 #include "core/frame/Navigator.h" | |
12 #include "core/page/Page.h" | |
13 #include "modules/vr/HMDVRDevice.h" | |
14 #include "modules/vr/NavigatorVRDevice.h" | |
15 #include "modules/vr/PositionSensorVRDevice.h" | |
16 #include "modules/vr/VRController.h" | |
17 #include "modules/vr/VRGetDevicesCallback.h" | |
18 #include "modules/vr/VRHardwareUnit.h" | |
19 #include "modules/vr/VRPositionState.h" | |
20 | |
21 namespace blink { | |
22 | |
23 VRHardwareUnitCollection::VRHardwareUnitCollection(NavigatorVRDevice* navigatorV
RDevice) | |
24 : m_navigatorVRDevice(navigatorVRDevice) | |
25 { | |
26 } | |
27 | |
28 HeapVector<Member<VRDevice>> VRHardwareUnitCollection::updateVRHardwareUnits(con
st WebVector<WebVRDevice>& devices) | |
29 { | |
30 VRDeviceVector vrDevices; | |
31 | |
32 for (const auto& device : devices) { | |
33 VRHardwareUnit* hardwareUnit = getHardwareUnitForIndex(device.index); | |
34 if (!hardwareUnit) { | |
35 hardwareUnit = new VRHardwareUnit(m_navigatorVRDevice); | |
36 m_hardwareUnits.append(hardwareUnit); | |
37 } | |
38 | |
39 hardwareUnit->updateFromWebVRDevice(device); | |
40 hardwareUnit->addDevicesToVector(vrDevices); | |
41 } | |
42 | |
43 return vrDevices; | |
44 } | |
45 | |
46 VRHardwareUnit* VRHardwareUnitCollection::getHardwareUnitForIndex(unsigned index
) | |
47 { | |
48 VRHardwareUnit* hardwareUnit; | |
49 for (size_t i = 0; i < m_hardwareUnits.size(); ++i) { | |
50 hardwareUnit = m_hardwareUnits[i]; | |
51 if (hardwareUnit->index() == index) { | |
52 return hardwareUnit; | |
53 } | |
54 } | |
55 | |
56 return 0; | |
57 } | |
58 | |
59 DEFINE_TRACE(VRHardwareUnitCollection) | |
60 { | |
61 visitor->trace(m_navigatorVRDevice); | |
62 visitor->trace(m_hardwareUnits); | |
63 } | |
64 | |
65 } // namespace blink | |
OLD | NEW |