OLD | NEW |
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 #include "device/vr/vr_device_manager.h" | 5 #include "device/vr/vr_device_manager.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 // Should never have a presenting service without a presenting device. | 239 // Should never have a presenting service without a presenting device. |
240 DCHECK(presenting_device_); | 240 DCHECK(presenting_device_); |
241 | 241 |
242 // Don't submit frames to devices other than the currently presenting one. | 242 // Don't submit frames to devices other than the currently presenting one. |
243 if (presenting_device_->id() != index) | 243 if (presenting_device_->id() != index) |
244 return; | 244 return; |
245 | 245 |
246 presenting_device_->SubmitFrame(std::move(pose)); | 246 presenting_device_->SubmitFrame(std::move(pose)); |
247 } | 247 } |
248 | 248 |
| 249 void VRDeviceManager::OnDeviceConnectionStatusChanged(VRDevice* device, |
| 250 bool is_connected) { |
| 251 if (is_connected) { |
| 252 VRDisplayPtr vr_device_info = device->GetVRDevice(); |
| 253 if (vr_device_info.is_null()) |
| 254 return; |
| 255 |
| 256 vr_device_info->index = device->id(); |
| 257 |
| 258 for (const auto& service : services_) |
| 259 service->client()->OnDisplayConnected(vr_device_info.Clone()); |
| 260 } else { |
| 261 for (const auto& service : services_) |
| 262 service->client()->OnDisplayDisconnected(device->id()); |
| 263 } |
| 264 } |
| 265 |
249 void VRDeviceManager::InitializeProviders() { | 266 void VRDeviceManager::InitializeProviders() { |
250 if (vr_initialized_) { | 267 if (vr_initialized_) { |
251 return; | 268 return; |
252 } | 269 } |
253 | 270 |
254 for (const auto& provider : providers_) | 271 for (const auto& provider : providers_) { |
| 272 provider->SetClient(this); |
255 provider->Initialize(); | 273 provider->Initialize(); |
| 274 } |
256 | 275 |
257 vr_initialized_ = true; | 276 vr_initialized_ = true; |
258 } | 277 } |
259 | 278 |
260 void VRDeviceManager::RegisterProvider( | 279 void VRDeviceManager::RegisterProvider( |
261 std::unique_ptr<VRDeviceProvider> provider) { | 280 std::unique_ptr<VRDeviceProvider> provider) { |
262 providers_.push_back(make_linked_ptr(provider.release())); | 281 providers_.push_back(make_linked_ptr(provider.release())); |
263 } | 282 } |
264 | 283 |
265 void VRDeviceManager::SchedulePollEvents() { | 284 void VRDeviceManager::SchedulePollEvents() { |
(...skipping 10 matching lines...) Expand all Loading... |
276 for (const auto& provider : providers_) | 295 for (const auto& provider : providers_) |
277 provider->PollEvents(); | 296 provider->PollEvents(); |
278 } | 297 } |
279 | 298 |
280 void VRDeviceManager::StopSchedulingPollEvents() { | 299 void VRDeviceManager::StopSchedulingPollEvents() { |
281 if (has_scheduled_poll_) | 300 if (has_scheduled_poll_) |
282 timer_.Stop(); | 301 timer_.Stop(); |
283 } | 302 } |
284 | 303 |
285 } // namespace device | 304 } // namespace device |
OLD | NEW |