Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(450)

Side by Side Diff: device/vr/vr_device.cc

Issue 2471433002: Implement WebVR presentation pausing for VR Shell Menu Mode (Closed)
Patch Set: rebase Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « device/vr/vr_device.h ('k') | device/vr/vr_device_manager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « device/vr/vr_device.h ('k') | device/vr/vr_device_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698