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, VRServiceImpl* service) |
14 : binding_(this), | 14 : binding_(this), |
15 device_(device), | 15 device_(device), |
16 service_(service), | 16 service_(service), |
17 weak_ptr_factory_(this) { | 17 weak_ptr_factory_(this) { |
18 mojom::VRDisplayInfoPtr display_info = device->GetVRDevice(); | 18 mojom::VRDisplayInfoPtr display_info = device->GetVRDevice(); |
19 if (service->client()) { | 19 if (service->client()) { |
20 service->client()->OnDisplayConnected(binding_.CreateInterfacePtrAndBind(), | 20 service->client()->OnDisplayConnected(binding_.CreateInterfacePtrAndBind(), |
21 mojo::MakeRequest(&client_), | 21 mojo::MakeRequest(&client_), |
22 std::move(display_info)); | 22 std::move(display_info)); |
23 } | 23 } |
24 } | 24 } |
25 | 25 |
26 VRDisplayImpl::~VRDisplayImpl() { | 26 VRDisplayImpl::~VRDisplayImpl() { |
27 device_->RemoveDisplay(this); | 27 device_->RemoveDisplay(this); |
28 } | 28 } |
29 | 29 |
30 void VRDisplayImpl::GetPose(const GetPoseCallback& callback) { | |
31 if (!device_->IsAccessAllowed(this)) { | |
32 callback.Run(nullptr); | |
33 return; | |
34 } | |
35 | |
36 callback.Run(device_->GetPose()); | |
37 } | |
38 | |
39 void VRDisplayImpl::ResetPose() { | 30 void VRDisplayImpl::ResetPose() { |
40 if (!device_->IsAccessAllowed(this)) | 31 if (!device_->IsAccessAllowed(this)) |
41 return; | 32 return; |
42 | 33 |
43 device_->ResetPose(); | 34 device_->ResetPose(); |
44 } | 35 } |
45 | 36 |
46 void VRDisplayImpl::RequestPresent(bool secure_origin, | 37 void VRDisplayImpl::RequestPresent(bool secure_origin, |
47 const RequestPresentCallback& callback) { | 38 const RequestPresentCallback& callback) { |
48 if (!device_->IsAccessAllowed(this)) { | 39 if (!device_->IsAccessAllowed(this)) { |
(...skipping 27 matching lines...) Expand all Loading... |
76 device_->SubmitFrame(std::move(pose)); | 67 device_->SubmitFrame(std::move(pose)); |
77 } | 68 } |
78 | 69 |
79 void VRDisplayImpl::UpdateLayerBounds(mojom::VRLayerBoundsPtr left_bounds, | 70 void VRDisplayImpl::UpdateLayerBounds(mojom::VRLayerBoundsPtr left_bounds, |
80 mojom::VRLayerBoundsPtr right_bounds) { | 71 mojom::VRLayerBoundsPtr right_bounds) { |
81 if (!device_->IsAccessAllowed(this)) | 72 if (!device_->IsAccessAllowed(this)) |
82 return; | 73 return; |
83 | 74 |
84 device_->UpdateLayerBounds(std::move(left_bounds), std::move(right_bounds)); | 75 device_->UpdateLayerBounds(std::move(left_bounds), std::move(right_bounds)); |
85 } | 76 } |
| 77 |
| 78 void VRDisplayImpl::GetVRVSyncProvider(mojom::VRVSyncProviderRequest request) { |
| 79 if (!device_->IsAccessAllowed(this)) { |
| 80 return; |
| 81 } |
| 82 device_->GetVRVSyncProvider(std::move(request)); |
86 } | 83 } |
| 84 } |
OLD | NEW |