| 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 "device/vr/vr_service_impl.h" | 5 #include "device/vr/vr_service_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "device/vr/vr_device.h" | 10 #include "device/vr/vr_device.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 VRDeviceManager* device_manager = VRDeviceManager::GetInstance(); | 41 VRDeviceManager* device_manager = VRDeviceManager::GetInstance(); |
| 42 device_manager->AddService(this); | 42 device_manager->AddService(this); |
| 43 } | 43 } |
| 44 | 44 |
| 45 void VRServiceImpl::GetDisplays(const GetDisplaysCallback& callback) { | 45 void VRServiceImpl::GetDisplays(const GetDisplaysCallback& callback) { |
| 46 VRDeviceManager* device_manager = VRDeviceManager::GetInstance(); | 46 VRDeviceManager* device_manager = VRDeviceManager::GetInstance(); |
| 47 callback.Run(device_manager->GetVRDevices()); | 47 callback.Run(device_manager->GetVRDevices()); |
| 48 } | 48 } |
| 49 | 49 |
| 50 void VRServiceImpl::GetPose(uint32_t index, const GetPoseCallback& callback) { | 50 void VRServiceImpl::GetPose(uint32_t index, const GetPoseCallback& callback) { |
| 51 VRDeviceManager* device_manager = VRDeviceManager::GetInstance(); | 51 VRDevice* device = VRDeviceManager::GetAllowedDevice(this, index); |
| 52 VRDevice* device = device_manager->GetDevice(index); | |
| 53 | 52 |
| 54 if (device) { | 53 if (device) { |
| 55 callback.Run(device->GetPose()); | 54 callback.Run(device->GetPose()); |
| 56 } else { | 55 } else { |
| 57 callback.Run(nullptr); | 56 callback.Run(nullptr); |
| 58 } | 57 } |
| 59 } | 58 } |
| 60 | 59 |
| 61 void VRServiceImpl::ResetPose(uint32_t index) { | 60 void VRServiceImpl::ResetPose(uint32_t index) { |
| 62 VRDeviceManager* device_manager = VRDeviceManager::GetInstance(); | 61 VRDevice* device = VRDeviceManager::GetAllowedDevice(this, index); |
| 63 VRDevice* device = device_manager->GetDevice(index); | |
| 64 if (device) | 62 if (device) |
| 65 device->ResetPose(); | 63 device->ResetPose(); |
| 66 } | 64 } |
| 67 | 65 |
| 68 void VRServiceImpl::RequestPresent(uint32_t index) { | 66 void VRServiceImpl::RequestPresent(uint32_t index, |
| 67 const RequestPresentCallback& callback) { |
| 69 VRDeviceManager* device_manager = VRDeviceManager::GetInstance(); | 68 VRDeviceManager* device_manager = VRDeviceManager::GetInstance(); |
| 70 VRDevice* device = device_manager->GetDevice(index); | 69 callback.Run(device_manager->RequestPresent(this, index)); |
| 71 if (device) | |
| 72 device->RequestPresent(); | |
| 73 } | 70 } |
| 74 | 71 |
| 75 void VRServiceImpl::ExitPresent(uint32_t index) { | 72 void VRServiceImpl::ExitPresent(uint32_t index) { |
| 76 VRDeviceManager* device_manager = VRDeviceManager::GetInstance(); | 73 VRDeviceManager* device_manager = VRDeviceManager::GetInstance(); |
| 77 VRDevice* device = device_manager->GetDevice(index); | 74 device_manager->ExitPresent(this, index); |
| 78 if (device) | |
| 79 device->ExitPresent(); | |
| 80 } | 75 } |
| 81 | 76 |
| 82 void VRServiceImpl::SubmitFrame(uint32_t index) { | 77 void VRServiceImpl::SubmitFrame(uint32_t index, VRPosePtr pose) { |
| 83 VRDeviceManager* device_manager = VRDeviceManager::GetInstance(); | 78 VRDeviceManager* device_manager = VRDeviceManager::GetInstance(); |
| 84 VRDevice* device = device_manager->GetDevice(index); | 79 device_manager->SubmitFrame(this, index, std::move(pose)); |
| 85 if (device) | |
| 86 device->SubmitFrame(); | |
| 87 } | 80 } |
| 88 | 81 |
| 89 void VRServiceImpl::UpdateLayerBounds(uint32_t index, | 82 void VRServiceImpl::UpdateLayerBounds(uint32_t index, |
| 90 VRLayerBoundsPtr leftBounds, | 83 VRLayerBoundsPtr leftBounds, |
| 91 VRLayerBoundsPtr rightBounds) { | 84 VRLayerBoundsPtr rightBounds) { |
| 92 VRDeviceManager* device_manager = VRDeviceManager::GetInstance(); | 85 VRDevice* device = VRDeviceManager::GetAllowedDevice(this, index); |
| 93 VRDevice* device = device_manager->GetDevice(index); | |
| 94 if (device) | 86 if (device) |
| 95 device->UpdateLayerBounds(std::move(leftBounds), std::move(rightBounds)); | 87 device->UpdateLayerBounds(std::move(leftBounds), std::move(rightBounds)); |
| 96 } | 88 } |
| 97 | 89 |
| 98 } // namespace device | 90 } // namespace device |
| OLD | NEW |