void VRController::OnDisplayChanged(device::blink::VRDisplayPtr display) { VRDisplay* vrDisplay = getDisplayForIndex(display->index); if (!vrDisplay) return; vrDisplay->update(display); }
void VRController::OnDisplayDisconnected(unsigned index) { VRDisplay* vrDisplay = getDisplayForIndex(index); if (!vrDisplay) return; vrDisplay->disconnected(); m_navigatorVR->fireVREvent( VRDisplayEvent::create(EventTypeNames::vrdisplaydisconnect, true, false, vrDisplay, "disconnect")); }
VRDisplay* VRController::createOrUpdateDisplay( const device::blink::VRDisplayPtr& display) { VRDisplay* vrDisplay = getDisplayForIndex(display->index); if (!vrDisplay) { vrDisplay = new VRDisplay(m_navigatorVR); m_displays.append(vrDisplay); } vrDisplay->update(display); return vrDisplay; }
VRDisplayVector VRDisplayCollection::updateDisplays(mojo::WTFArray<mojom::blink::VRDeviceInfoPtr> devices) { VRDisplayVector vrDevices; for (const auto& device : devices.PassStorage()) { VRDisplay* display = getDisplayForIndex(device->index); if (!display) { display = new VRDisplay(m_navigatorVR); m_displays.append(display); } display->update(device); vrDevices.append(display); } return vrDevices; }
void VRController::onPresentComplete(ScriptPromiseResolver* resolver, unsigned index, bool success) { VRDisplay* vrDisplay = getDisplayForIndex(index); if (!vrDisplay) { DOMException* exception = DOMException::create(InvalidStateError, "VRDisplay not found."); resolver->reject(exception); ReportPresentationResult(PresentationResult::VRDisplayNotFound); return; } if (success) { vrDisplay->beginPresent(resolver); } else { vrDisplay->forceExitPresent(); DOMException* exception = DOMException::create( NotAllowedError, "Presentation request was denied."); ReportPresentationResult(PresentationResult::RequestDenied); resolver->reject(exception); } }
void VRController::OnExitPresent(unsigned index) { VRDisplay* vrDisplay = getDisplayForIndex(index); if (vrDisplay) vrDisplay->forceExitPresent(); }