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_display_impl.h" | 7 #include "device/vr/vr_display_impl.h" |
8 | 8 |
9 namespace device { | 9 namespace device { |
10 | 10 |
(...skipping 28 matching lines...) Expand all Loading... |
39 return (!presenting_display_ || presenting_display_ == display); | 39 return (!presenting_display_ || presenting_display_ == display); |
40 } | 40 } |
41 | 41 |
42 bool VRDevice::CheckPresentingDisplay(VRDisplayImpl* display) { | 42 bool VRDevice::CheckPresentingDisplay(VRDisplayImpl* display) { |
43 return (presenting_display_ && presenting_display_ == display); | 43 return (presenting_display_ && presenting_display_ == display); |
44 } | 44 } |
45 | 45 |
46 void VRDevice::OnChanged() { | 46 void VRDevice::OnChanged() { |
47 base::Callback<void(mojom::VRDisplayInfoPtr)> callback = base::Bind( | 47 base::Callback<void(mojom::VRDisplayInfoPtr)> callback = base::Bind( |
48 &VRDevice::OnVRDisplayInfoCreated, weak_ptr_factory_.GetWeakPtr()); | 48 &VRDevice::OnVRDisplayInfoCreated, weak_ptr_factory_.GetWeakPtr()); |
49 GetVRDevice(callback); | 49 CreateVRDisplayInfo(callback); |
50 } | 50 } |
51 | 51 |
52 void VRDevice::OnVRDisplayInfoCreated(mojom::VRDisplayInfoPtr vr_device_info) { | 52 void VRDevice::OnVRDisplayInfoCreated(mojom::VRDisplayInfoPtr vr_device_info) { |
53 if (vr_device_info.is_null()) | 53 if (vr_device_info.is_null()) |
54 return; | 54 return; |
55 for (auto* display : displays_) | 55 for (auto* display : displays_) |
56 display->client()->OnChanged(vr_device_info.Clone()); | 56 display->OnChanged(vr_device_info.Clone()); |
57 } | 57 } |
58 | 58 |
59 void VRDevice::OnExitPresent() { | 59 void VRDevice::OnExitPresent() { |
60 if (!presenting_display_) | 60 if (!presenting_display_) |
61 return; | 61 return; |
62 auto it = displays_.find(presenting_display_); | 62 auto it = displays_.find(presenting_display_); |
63 CHECK(it != displays_.end()); | 63 CHECK(it != displays_.end()); |
64 (*it)->client()->OnExitPresent(); | 64 (*it)->OnExitPresent(); |
65 SetPresentingDisplay(nullptr); | 65 SetPresentingDisplay(nullptr); |
66 } | 66 } |
67 | 67 |
68 void VRDevice::OnBlur() { | 68 void VRDevice::OnBlur() { |
69 for (auto* display : displays_) | 69 for (auto* display : displays_) |
70 display->client()->OnBlur(); | 70 display->OnBlur(); |
71 } | 71 } |
72 | 72 |
73 void VRDevice::OnFocus() { | 73 void VRDevice::OnFocus() { |
74 for (auto* display : displays_) | 74 for (auto* display : displays_) |
75 display->client()->OnFocus(); | 75 display->OnFocus(); |
76 } | 76 } |
77 | 77 |
78 void VRDevice::OnActivate(mojom::VRDisplayEventReason reason) { | 78 void VRDevice::OnActivate(mojom::VRDisplayEventReason reason) { |
79 for (auto* display : displays_) | 79 for (auto* display : displays_) |
80 display->client()->OnActivate(reason); | 80 display->OnActivate(reason); |
81 } | 81 } |
82 | 82 |
83 void VRDevice::OnDeactivate(mojom::VRDisplayEventReason reason) { | 83 void VRDevice::OnDeactivate(mojom::VRDisplayEventReason reason) { |
84 for (auto* display : displays_) | 84 for (auto* display : displays_) |
85 display->client()->OnDeactivate(reason); | 85 display->OnDeactivate(reason); |
86 } | 86 } |
87 | 87 |
88 void VRDevice::SetPresentingDisplay(VRDisplayImpl* display) { | 88 void VRDevice::SetPresentingDisplay(VRDisplayImpl* display) { |
89 presenting_display_ = display; | 89 presenting_display_ = display; |
90 } | 90 } |
91 | 91 |
92 } // namespace device | 92 } // namespace device |
OLD | NEW |