OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 <utility> | 5 #include <utility> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "device/vr/vr_device.h" | 8 #include "device/vr/vr_device.h" |
9 #include "device/vr/vr_service_impl.h" | 9 #include "device/vr/vr_service_impl.h" |
10 | 10 |
11 namespace device { | 11 namespace device { |
12 | 12 |
13 VRDisplayImpl::VRDisplayImpl(device::VRDevice* device, VRServiceImpl* service) | 13 VRDisplayImpl::VRDisplayImpl(device::VRDevice* device, |
| 14 VRServiceImpl* service, |
| 15 mojom::VRServiceClient* service_client, |
| 16 mojom::VRDisplayInfoPtr display_info) |
14 : binding_(this), | 17 : binding_(this), |
15 device_(device), | 18 device_(device), |
16 service_(service), | 19 service_(service), |
17 weak_ptr_factory_(this) { | 20 weak_ptr_factory_(this) { |
18 base::Callback<void(mojom::VRDisplayInfoPtr)> callback = base::Bind( | 21 device_->AddDisplay(this); |
19 &VRDisplayImpl::OnVRDisplayInfoCreated, weak_ptr_factory_.GetWeakPtr()); | 22 service_client->OnDisplayConnected(binding_.CreateInterfacePtrAndBind(), |
20 device->GetVRDevice(callback); | 23 mojo::MakeRequest(&client_), |
21 } | 24 std::move(display_info)); |
22 | |
23 void VRDisplayImpl::OnVRDisplayInfoCreated( | |
24 mojom::VRDisplayInfoPtr display_info) { | |
25 if (service_->client() && display_info) { | |
26 service_->client()->OnDisplayConnected(binding_.CreateInterfacePtrAndBind(), | |
27 mojo::MakeRequest(&client_), | |
28 std::move(display_info)); | |
29 } | |
30 } | 25 } |
31 | 26 |
32 VRDisplayImpl::~VRDisplayImpl() { | 27 VRDisplayImpl::~VRDisplayImpl() { |
33 device_->RemoveDisplay(this); | 28 device_->RemoveDisplay(this); |
34 } | 29 } |
35 | 30 |
| 31 void VRDisplayImpl::OnChanged(mojom::VRDisplayInfoPtr vr_device_info) { |
| 32 client_->OnChanged(std::move(vr_device_info)); |
| 33 } |
| 34 |
| 35 void VRDisplayImpl::OnExitPresent() { |
| 36 client_->OnExitPresent(); |
| 37 } |
| 38 |
| 39 void VRDisplayImpl::OnBlur() { |
| 40 client_->OnBlur(); |
| 41 } |
| 42 |
| 43 void VRDisplayImpl::OnFocus() { |
| 44 client_->OnFocus(); |
| 45 } |
| 46 |
| 47 void VRDisplayImpl::OnActivate(mojom::VRDisplayEventReason reason) { |
| 48 client_->OnActivate(reason); |
| 49 } |
| 50 |
| 51 void VRDisplayImpl::OnDeactivate(mojom::VRDisplayEventReason reason) { |
| 52 client_->OnDeactivate(reason); |
| 53 } |
| 54 |
36 void VRDisplayImpl::ResetPose() { | 55 void VRDisplayImpl::ResetPose() { |
37 if (!device_->IsAccessAllowed(this)) | 56 if (!device_->IsAccessAllowed(this)) |
38 return; | 57 return; |
39 | 58 |
40 device_->ResetPose(); | 59 device_->ResetPose(); |
41 } | 60 } |
42 | 61 |
43 void VRDisplayImpl::RequestPresent(bool secure_origin, | 62 void VRDisplayImpl::RequestPresent(bool secure_origin, |
44 const RequestPresentCallback& callback) { | 63 const RequestPresentCallback& callback) { |
45 if (!device_->IsAccessAllowed(this)) { | 64 if (!device_->IsAccessAllowed(this)) { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 std::move(right_bounds)); | 102 std::move(right_bounds)); |
84 } | 103 } |
85 | 104 |
86 void VRDisplayImpl::GetVRVSyncProvider(mojom::VRVSyncProviderRequest request) { | 105 void VRDisplayImpl::GetVRVSyncProvider(mojom::VRVSyncProviderRequest request) { |
87 if (!device_->IsAccessAllowed(this)) { | 106 if (!device_->IsAccessAllowed(this)) { |
88 return; | 107 return; |
89 } | 108 } |
90 device_->GetVRVSyncProvider(std::move(request)); | 109 device_->GetVRVSyncProvider(std::move(request)); |
91 } | 110 } |
92 } | 111 } |
OLD | NEW |