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

Unified Diff: device/vr/vr_service_impl.cc

Issue 2488273002: Revert of mojo VR interface simplified (Closed)
Patch Set: 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_service_impl.h ('k') | device/vr/vr_service_impl_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/vr/vr_service_impl.cc
diff --git a/device/vr/vr_service_impl.cc b/device/vr/vr_service_impl.cc
index ad12ace4c8affb86b0ddca747b7a4eeb83811ea6..6ea486de284d4d5e0e37bb7a7a36adb172b41a6b 100644
--- a/device/vr/vr_service_impl.cc
+++ b/device/vr/vr_service_impl.cc
@@ -18,53 +18,74 @@
RemoveFromDeviceManager();
}
-void VRServiceImpl::BindRequest(
- mojo::InterfaceRequest<mojom::VRService> request) {
+void VRServiceImpl::BindRequest(mojo::InterfaceRequest<VRService> request) {
VRServiceImpl* service = new VRServiceImpl();
service->Bind(std::move(request));
}
-// Gets a VRDisplayPtr unique to this service so that the associated page can
-// communicate with the VRDevice.
-VRDisplayImpl* VRServiceImpl::GetVRDisplayImpl(VRDevice* device) {
- DisplayImplMap::iterator it = displays_.find(device);
- if (it != displays_.end())
- return it->second.get();
-
- VRDisplayImpl* display_impl = new VRDisplayImpl(device, this);
- displays_[device] = base::WrapUnique(display_impl);
- return display_impl;
-}
-
-void VRServiceImpl::Bind(mojo::InterfaceRequest<mojom::VRService> request) {
- // TODO(shaobo.yan@intel.com) : Keep one binding_ and use close and rebind.
- binding_.reset(new mojo::Binding<mojom::VRService>(this, std::move(request)));
+void VRServiceImpl::Bind(mojo::InterfaceRequest<VRService> request) {
+ binding_.reset(new mojo::Binding<VRService>(this, std::move(request)));
binding_->set_connection_error_handler(base::Bind(
&VRServiceImpl::RemoveFromDeviceManager, base::Unretained(this)));
}
void VRServiceImpl::RemoveFromDeviceManager() {
- displays_.clear();
VRDeviceManager* device_manager = VRDeviceManager::GetInstance();
device_manager->RemoveService(this);
}
-void VRServiceImpl::RemoveDevice(VRDevice* device) {
- displays_.erase(device);
+void VRServiceImpl::SetClient(VRServiceClientPtr client) {
+ DCHECK(!client_.get());
+
+ client_ = std::move(client);
+ VRDeviceManager* device_manager = VRDeviceManager::GetInstance();
+ device_manager->AddService(this);
}
-void VRServiceImpl::SetClient(mojom::VRServiceClientPtr service_client,
- const SetClientCallback& callback) {
- DCHECK(!client_.get());
+void VRServiceImpl::GetDisplays(const GetDisplaysCallback& callback) {
+ VRDeviceManager* device_manager = VRDeviceManager::GetInstance();
+ callback.Run(device_manager->GetVRDevices());
+}
- client_ = std::move(service_client);
+void VRServiceImpl::GetPose(uint32_t index, const GetPoseCallback& callback) {
+ VRDevice* device = VRDeviceManager::GetAllowedDevice(this, index);
+
+ if (device) {
+ callback.Run(device->GetPose());
+ } else {
+ callback.Run(nullptr);
+ }
+}
+
+void VRServiceImpl::ResetPose(uint32_t index) {
+ VRDevice* device = VRDeviceManager::GetAllowedDevice(this, index);
+ if (device)
+ device->ResetPose();
+}
+
+void VRServiceImpl::RequestPresent(uint32_t index,
+ bool secureOrigin,
+ const RequestPresentCallback& callback) {
VRDeviceManager* device_manager = VRDeviceManager::GetInstance();
- // Once a client has been connected AddService will force any VRDisplays to
- // send OnConnected to it so that it's populated with the currently active
- // displays. Thereafer it will stay up to date by virtue of listening for new
- // connected events.
- device_manager->AddService(this);
- callback.Run(device_manager->GetNumberOfConnectedDevices());
+ callback.Run(device_manager->RequestPresent(this, index, secureOrigin));
+}
+
+void VRServiceImpl::ExitPresent(uint32_t index) {
+ VRDeviceManager* device_manager = VRDeviceManager::GetInstance();
+ device_manager->ExitPresent(this, index);
+}
+
+void VRServiceImpl::SubmitFrame(uint32_t index, VRPosePtr pose) {
+ VRDeviceManager* device_manager = VRDeviceManager::GetInstance();
+ device_manager->SubmitFrame(this, index, std::move(pose));
+}
+
+void VRServiceImpl::UpdateLayerBounds(uint32_t index,
+ VRLayerBoundsPtr leftBounds,
+ VRLayerBoundsPtr rightBounds) {
+ VRDevice* device = VRDeviceManager::GetAllowedDevice(this, index);
+ if (device)
+ device->UpdateLayerBounds(std::move(leftBounds), std::move(rightBounds));
}
} // namespace device
« no previous file with comments | « device/vr/vr_service_impl.h ('k') | device/vr/vr_service_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698