Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1492)

Side by Side Diff: third_party/WebKit/Source/modules/vr/VRController.h

Issue 2420743003: mojo VR interface simplified (Closed)
Patch Set: Address bajones@ comments and some clean up Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #ifndef VRController_h 5 #ifndef VRController_h
6 #define VRController_h 6 #define VRController_h
7 7
8 #include "core/dom/ContextLifecycleObserver.h" 8 #include "core/dom/ContextLifecycleObserver.h"
9 #include "core/dom/Document.h" 9 #include "core/dom/Document.h"
10 #include "device/vr/vr_service.mojom-blink.h" 10 #include "device/vr/vr_service.mojom-blink.h"
11 #include "modules/vr/VRDisplay.h" 11 #include "modules/vr/VRDisplay.h"
12 #include "mojo/public/cpp/bindings/binding.h" 12 #include "mojo/public/cpp/bindings/binding.h"
13 #include "platform/heap/Handle.h" 13 #include "platform/heap/Handle.h"
14 #include "wtf/Deque.h" 14 #include "wtf/Deque.h"
15 15
16 #include <memory> 16 #include <memory>
17 17
18 namespace blink { 18 namespace blink {
19 19
20 class NavigatorVR; 20 class NavigatorVR;
21 class VRGetDevicesCallback; 21 class VRGetDevicesCallback;
22 22
23 class VRController final : public GarbageCollectedFinalized<VRController>, 23 class VRController final : public GarbageCollectedFinalized<VRController>,
24 public device::blink::VRServiceClient,
25 public ContextLifecycleObserver { 24 public ContextLifecycleObserver {
26 USING_GARBAGE_COLLECTED_MIXIN(VRController); 25 USING_GARBAGE_COLLECTED_MIXIN(VRController);
27 WTF_MAKE_NONCOPYABLE(VRController); 26 WTF_MAKE_NONCOPYABLE(VRController);
28 27
29 public: 28 public:
30 VRController(NavigatorVR*); 29 VRController(NavigatorVR*);
31 virtual ~VRController(); 30 virtual ~VRController();
32 31
33 // VRService. 32 // VRService.
34 void getDisplays(ScriptPromiseResolver*); 33 void getDisplays(ScriptPromiseResolver*);
35 device::blink::VRPosePtr getPose(unsigned index);
36 void resetPose(unsigned index);
37 void requestPresent(ScriptPromiseResolver*,
38 unsigned index,
39 bool secureOrigin);
40 void exitPresent(unsigned index);
41 void submitFrame(unsigned index, device::blink::VRPosePtr);
42 void updateLayerBounds(unsigned index,
43 device::blink::VRLayerBoundsPtr leftBounds,
44 device::blink::VRLayerBoundsPtr rightBounds);
45 34
46 VRDisplay* createOrUpdateDisplay(const device::blink::VRDisplayPtr&); 35 VRDisplay* createOrUpdateDisplay(const device::blink::VRDisplayPtr&);
47 VRDisplayVector updateDisplays(mojo::WTFArray<device::blink::VRDisplayPtr>); 36 VRDisplayVector updateDisplays(
37 mojo::WTFArray<device::blink::VRDisplayWithServicePtr>);
48 VRDisplay* getDisplayForIndex(unsigned index); 38 VRDisplay* getDisplayForIndex(unsigned index);
49 39
50 DECLARE_VIRTUAL_TRACE(); 40 DECLARE_VIRTUAL_TRACE();
51 41
52 private: 42 private:
53 // Binding callbacks. 43 // Binding callbacks.
54 void onGetDisplays(mojo::WTFArray<device::blink::VRDisplayPtr>); 44 void onGetDisplays(mojo::WTFArray<device::blink::VRDisplayWithServicePtr>);
55 void onPresentComplete(ScriptPromiseResolver*, unsigned index, bool success);
56
57 // VRServiceClient.
58 void OnDisplayChanged(device::blink::VRDisplayPtr) override;
59 void OnExitPresent(unsigned index) override;
60 void OnDisplayConnected(device::blink::VRDisplayPtr) override;
61 void OnDisplayDisconnected(unsigned) override;
62 45
63 // ContextLifecycleObserver. 46 // ContextLifecycleObserver.
64 void contextDestroyed() override; 47 void contextDestroyed() override;
65 48
66 Member<NavigatorVR> m_navigatorVR; 49 Member<NavigatorVR> m_navigatorVR;
67 VRDisplayVector m_displays; 50 VRDisplayVector m_displays;
68 51
69 Deque<std::unique_ptr<VRGetDevicesCallback>> m_pendingGetDevicesCallbacks; 52 Deque<std::unique_ptr<VRGetDevicesCallback>> m_pendingGetDevicesCallbacks;
70 device::blink::VRServicePtr m_service; 53 device::blink::VRServicePtr m_service;
71 mojo::Binding<device::blink::VRServiceClient> m_binding;
72 }; 54 };
73 55
74 } // namespace blink 56 } // namespace blink
75 57
76 #endif // VRController_h 58 #endif // VRController_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698