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

Side by Side Diff: device/vr/openvr/openvr_device.h

Issue 2834843002: Add event listening function to openvr device (Closed)
Patch Set: Address billorr1@ comments Created 3 years, 7 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
« no previous file with comments | « no previous file | device/vr/openvr/openvr_device.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 DEVICE_VR_OPENVR_DEVICE_H 5 #ifndef DEVICE_VR_OPENVR_DEVICE_H
6 #define DEVICE_VR_OPENVR_DEVICE_H 6 #define DEVICE_VR_OPENVR_DEVICE_H
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/threading/simple_thread.h" 9 #include "base/threading/simple_thread.h"
10 #include "device/vr/vr_device.h" 10 #include "device/vr/vr_device.h"
(...skipping 21 matching lines...) Expand all
32 32
33 void SubmitFrame(int16_t frame_index, 33 void SubmitFrame(int16_t frame_index,
34 const gpu::MailboxHolder& mailbox) override; 34 const gpu::MailboxHolder& mailbox) override;
35 void UpdateLayerBounds(int16_t frame_index, 35 void UpdateLayerBounds(int16_t frame_index,
36 mojom::VRLayerBoundsPtr left_bounds, 36 mojom::VRLayerBoundsPtr left_bounds,
37 mojom::VRLayerBoundsPtr right_bounds, 37 mojom::VRLayerBoundsPtr right_bounds,
38 int16_t source_width, 38 int16_t source_width,
39 int16_t source_height) override; 39 int16_t source_height) override;
40 void GetVRVSyncProvider(mojom::VRVSyncProviderRequest request) override; 40 void GetVRVSyncProvider(mojom::VRVSyncProviderRequest request) override;
41 41
42 void OnPollingEvents();
43
42 private: 44 private:
43 class OpenVRRenderLoop : public base::SimpleThread, 45 class OpenVRRenderLoop : public base::SimpleThread,
44 device::mojom::VRVSyncProvider { 46 device::mojom::VRVSyncProvider {
45 public: 47 public:
46 OpenVRRenderLoop(vr::IVRSystem* vr); 48 OpenVRRenderLoop(vr::IVRSystem* vr);
47 49
50 void RegisterPollingEventCallback(
51 const base::Callback<void()>& onPollingEvents);
52
53 void UnregisterPollingEventCallback();
54
48 void Bind(mojom::VRVSyncProviderRequest request); 55 void Bind(mojom::VRVSyncProviderRequest request);
49 56
50 mojom::VRPosePtr getPose(); 57 mojom::VRPosePtr getPose();
51 58
52 private: 59 private:
53 void Run() override; 60 void Run() override;
54 61
55 void GetVSync(const device::mojom::VRVSyncProvider::GetVSyncCallback& 62 void GetVSync(const device::mojom::VRVSyncProvider::GetVSyncCallback&
56 callback) override; 63 callback) override;
57 64
58 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; 65 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_;
66 base::Callback<void()> on_polling_events_;
59 vr::IVRSystem* vr_system_; 67 vr::IVRSystem* vr_system_;
60 mojo::Binding<device::mojom::VRVSyncProvider> binding_; 68 mojo::Binding<device::mojom::VRVSyncProvider> binding_;
61 }; 69 };
62 70
63 std::unique_ptr<OpenVRRenderLoop> 71 std::unique_ptr<OpenVRRenderLoop>
64 render_loop_; // TODO (BillOrr): This should not be a unique_ptr because 72 render_loop_; // TODO (BillOrr): This should not be a unique_ptr because
65 // the render_loop_ binds to VRVSyncProvider requests, 73 // the render_loop_ binds to VRVSyncProvider requests,
66 // so its lifetime should be tied to the lifetime of that 74 // so its lifetime should be tied to the lifetime of that
67 // binding. 75 // binding.
68 76
69 mojom::VRSubmitFrameClientPtr submit_client_; 77 mojom::VRSubmitFrameClientPtr submit_client_;
70 78
71 vr::IVRSystem* vr_system_; 79 vr::IVRSystem* vr_system_;
72 80
81 bool is_polling_events_;
82
83 base::WeakPtrFactory<OpenVRDevice> weak_ptr_factory_;
84
73 DISALLOW_COPY_AND_ASSIGN(OpenVRDevice); 85 DISALLOW_COPY_AND_ASSIGN(OpenVRDevice);
74 }; 86 };
75 87
76 } // namespace device 88 } // namespace device
77 89
78 #endif // DEVICE_VR_OPENVR_DEVICE_H 90 #endif // DEVICE_VR_OPENVR_DEVICE_H
OLDNEW
« no previous file with comments | « no previous file | device/vr/openvr/openvr_device.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698