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

Unified Diff: device/vr/vr_device.cc

Issue 2494733002: Reland of mojo VR interface simpified. (Closed)
Patch Set: Fix Werror 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/vr/vr_device.cc
diff --git a/device/vr/vr_device.cc b/device/vr/vr_device.cc
index 5e3d7fc253d6fa29c2755622baf9241df7ca49b5..c580d5fff4cc3eb8dceeba35a1c7ab05b33c42cc 100644
--- a/device/vr/vr_device.cc
+++ b/device/vr/vr_device.cc
@@ -4,13 +4,14 @@
#include "device/vr/vr_device.h"
#include "device/vr/vr_device_provider.h"
+#include "device/vr/vr_service_impl.h"
namespace device {
unsigned int VRDevice::next_id_ = 1;
VRDevice::VRDevice(VRDeviceProvider* provider)
- : provider_(provider), id_(next_id_) {
+ : presenting_service_(nullptr), provider_(provider), id_(next_id_) {
// Prevent wraparound. Devices with this ID will be treated as invalid.
if (next_id_ != VR_DEVICE_LAST_ID)
next_id_++;
@@ -18,8 +19,48 @@ VRDevice::VRDevice(VRDeviceProvider* provider)
VRDevice::~VRDevice() {}
-bool VRDevice::RequestPresent(bool secure_origin) {
+bool VRDevice::RequestPresent(VRServiceImpl* service, bool secure_origin) {
return true;
};
+void VRDevice::AddService(VRServiceImpl* service) {
+ // Create a VRDisplayImpl for this service/device pair
+ VRDisplayImpl* display_impl = service->GetVRDisplayImpl(this);
+ displays_.insert(std::make_pair(service, display_impl));
+}
+
+void VRDevice::RemoveService(VRServiceImpl* service) {
+ ExitPresent(service);
+ displays_.erase(service);
+}
+
+bool VRDevice::IsAccessAllowed(VRServiceImpl* service) {
+ return (!presenting_service_ || presenting_service_ == service);
+}
+
+bool VRDevice::IsPresentingService(VRServiceImpl* service) {
+ return (presenting_service_ && presenting_service_ == service);
+}
+
+void VRDevice::OnDisplayChanged() {
+ mojom::VRDisplayInfoPtr vr_device_info = GetVRDevice();
+ if (vr_device_info.is_null())
+ return;
+
+ for (const auto& display : displays_) {
+ mojom::VRDisplayClient* client = display.second->client();
+ if (client)
+ client->OnDisplayChanged(vr_device_info.Clone());
+ }
+}
+
+void VRDevice::OnExitPresent(VRServiceImpl* service) {
+ DisplayClientMap::iterator it = displays_.find(service);
+ if (it != displays_.end()) {
+ mojom::VRDisplayClient* client = it->second->client();
+ if (client)
+ client->OnExitPresent();
+ }
+}
+
} // namespace device
« 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