| 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.h" | 5 #include "device/vr/vr_device.h" |
| 6 #include "device/vr/vr_device_provider.h" | 6 #include "device/vr/vr_device_provider.h" |
| 7 #include "device/vr/vr_service_impl.h" | 7 #include "device/vr/vr_service_impl.h" |
| 8 | 8 |
| 9 namespace device { | 9 namespace device { |
| 10 | 10 |
| 11 unsigned int VRDevice::next_id_ = 1; | 11 unsigned int VRDevice::next_id_ = 1; |
| 12 | 12 |
| 13 VRDevice::VRDevice(VRDeviceProvider* provider) | 13 VRDevice::VRDevice() : presenting_service_(nullptr), id_(next_id_) { |
| 14 : presenting_service_(nullptr), provider_(provider), id_(next_id_) { | |
| 15 // Prevent wraparound. Devices with this ID will be treated as invalid. | 14 // Prevent wraparound. Devices with this ID will be treated as invalid. |
| 16 if (next_id_ != VR_DEVICE_LAST_ID) | 15 if (next_id_ != VR_DEVICE_LAST_ID) |
| 17 next_id_++; | 16 next_id_++; |
| 18 } | 17 } |
| 19 | 18 |
| 20 VRDevice::~VRDevice() {} | 19 VRDevice::~VRDevice() {} |
| 21 | 20 |
| 22 bool VRDevice::RequestPresent(VRServiceImpl* service, bool secure_origin) { | 21 bool VRDevice::RequestPresent(VRServiceImpl* service, bool secure_origin) { |
| 23 return true; | 22 return true; |
| 24 }; | 23 }; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 40 | 39 |
| 41 bool VRDevice::IsPresentingService(VRServiceImpl* service) { | 40 bool VRDevice::IsPresentingService(VRServiceImpl* service) { |
| 42 return (presenting_service_ && presenting_service_ == service); | 41 return (presenting_service_ && presenting_service_ == service); |
| 43 } | 42 } |
| 44 | 43 |
| 45 void VRDevice::OnDisplayChanged() { | 44 void VRDevice::OnDisplayChanged() { |
| 46 mojom::VRDisplayInfoPtr vr_device_info = GetVRDevice(); | 45 mojom::VRDisplayInfoPtr vr_device_info = GetVRDevice(); |
| 47 if (vr_device_info.is_null()) | 46 if (vr_device_info.is_null()) |
| 48 return; | 47 return; |
| 49 | 48 |
| 50 for (const auto& display : displays_) { | 49 for (const auto& display : displays_) |
| 51 mojom::VRDisplayClient* client = display.second->client(); | 50 display.second->client()->OnDisplayChanged(vr_device_info.Clone()); |
| 52 if (client) | |
| 53 client->OnDisplayChanged(vr_device_info.Clone()); | |
| 54 } | |
| 55 } | 51 } |
| 56 | 52 |
| 57 void VRDevice::OnExitPresent(VRServiceImpl* service) { | 53 void VRDevice::OnExitPresent(VRServiceImpl* service) { |
| 58 DisplayClientMap::iterator it = displays_.find(service); | 54 DisplayClientMap::iterator it = displays_.find(service); |
| 59 if (it != displays_.end()) { | 55 if (it != displays_.end()) |
| 60 mojom::VRDisplayClient* client = it->second->client(); | 56 it->second->client()->OnExitPresent(); |
| 61 if (client) | 57 } |
| 62 client->OnExitPresent(); | 58 |
| 63 } | 59 void VRDevice::OnDisplayBlur() { |
| 60 for (const auto& display : displays_) |
| 61 display.second->client()->OnDisplayBlur(); |
| 62 } |
| 63 |
| 64 void VRDevice::OnDisplayFocus() { |
| 65 for (const auto& display : displays_) |
| 66 display.second->client()->OnDisplayFocus(); |
| 64 } | 67 } |
| 65 | 68 |
| 66 } // namespace device | 69 } // namespace device |
| OLD | NEW |