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/android/gvr/gvr_device_provider.h" | 5 #include "device/vr/android/gvr/gvr_device_provider.h" |
6 | 6 |
7 #include <jni.h> | 7 #include <jni.h> |
8 | 8 |
9 #include "base/android/context_utils.h" | 9 #include "base/android/context_utils.h" |
10 #include "base/android/jni_android.h" | 10 #include "base/android/jni_android.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
78 GvrDelegateManager::GetInstance()->RemoveClient(this); | 78 GvrDelegateManager::GetInstance()->RemoveClient(this); |
79 } | 79 } |
80 | 80 |
81 void GvrDeviceProvider::GetDevices(std::vector<VRDevice*>* devices) { | 81 void GvrDeviceProvider::GetDevices(std::vector<VRDevice*>* devices) { |
82 Initialize(); | 82 Initialize(); |
83 | 83 |
84 if (vr_device_) | 84 if (vr_device_) |
85 devices->push_back(vr_device_.get()); | 85 devices->push_back(vr_device_.get()); |
86 } | 86 } |
87 | 87 |
88 void GvrDeviceProvider::SetClient(VRClientDispatcher* client) { | |
89 if (!client_) | |
90 client_.reset(client); | |
91 } | |
92 | |
88 void GvrDeviceProvider::Initialize() { | 93 void GvrDeviceProvider::Initialize() { |
89 if (!delegate_) { | 94 if (!delegate_) |
90 delegate_.reset(new GvrDeviceProviderDelegate()); | 95 delegate_.reset(new GvrDeviceProviderDelegate()); |
91 } | |
92 } | 96 } |
93 | 97 |
94 void GvrDeviceProvider::OnDelegateInitialized(GvrDelegate* delegate) { | 98 void GvrDeviceProvider::OnDelegateInitialized(GvrDelegate* delegate) { |
95 if (!vr_device_) | 99 if (!vr_device_) |
96 vr_device_.reset(new GvrDevice(this, delegate)); | 100 vr_device_.reset(new GvrDevice(this, delegate)); |
97 | 101 |
98 // Should fire a vrdisplayconnected event here. | 102 client_->OnDeviceConnectionStatusChanged(vr_device_.get(), true); |
99 } | 103 } |
100 | 104 |
101 void GvrDeviceProvider::OnDelegateShutdown() { | 105 void GvrDeviceProvider::OnDelegateShutdown() { |
102 // Nothing to do here just yet. Eventually want to shut down the VRDevice and | 106 // Nothing to do here just yet. Eventually want to shut down the VRDevice and |
103 // fire a vrdisplaydisconnected event. | 107 // fire a vrdisplaydisconnected event. |
bajones
2016/09/12 01:36:15
Happily this comment is no longer accurate! Lets r
shaobo.yan
2016/09/12 01:59:01
Done.
| |
108 if (client_ && vr_device_) | |
109 client_->OnDeviceConnectionStatusChanged(vr_device_.get(), false); | |
110 } | |
111 | |
112 void GvrDeviceProvider::PollEvents() { | |
113 if (vr_device_) | |
114 vr_device_->PollEvents(); | |
104 } | 115 } |
105 | 116 |
106 } // namespace device | 117 } // namespace device |
OLD | NEW |