Chromium Code Reviews| Index: third_party/WebKit/Source/modules/vr/VRDisplay.cpp |
| diff --git a/third_party/WebKit/Source/modules/vr/VRDisplay.cpp b/third_party/WebKit/Source/modules/vr/VRDisplay.cpp |
| index e6515a2eda78795122935ded775a9c85d462cb79..c286f069f65efba7d5c194963e6b69a5bd3a168b 100644 |
| --- a/third_party/WebKit/Source/modules/vr/VRDisplay.cpp |
| +++ b/third_party/WebKit/Source/modules/vr/VRDisplay.cpp |
| @@ -75,6 +75,7 @@ VRDisplay::VRDisplay(NavigatorVR* navigatorVR, |
| : m_navigatorVR(navigatorVR), |
| m_isConnected(false), |
| m_isPresenting(false), |
| + m_isValidDeviceForPresenting(true), |
| m_canUpdateFramePose(true), |
| m_capabilities(new VRDisplayCapabilities()), |
| m_eyeParametersLeft(new VREyeParameters()), |
| @@ -108,6 +109,13 @@ void VRDisplay::update(const device::mojom::blink::VRDisplayInfoPtr& display) { |
| m_capabilities->setCanPresent(display->capabilities->canPresent); |
| m_capabilities->setMaxLayers(display->capabilities->canPresent ? 1 : 0); |
| + // Ignore non presenting delegate |
| + bool isValid = display->leftEye->renderWidth > 0; |
| + bool needOnPresentChange = false; |
| + if (m_isPresenting && isValid && !m_isValidDeviceForPresenting) { |
| + needOnPresentChange = true; |
| + } |
| + m_isValidDeviceForPresenting = isValid; |
| m_eyeParametersLeft->update(display->leftEye); |
| m_eyeParametersRight->update(display->rightEye); |
| @@ -118,6 +126,10 @@ void VRDisplay::update(const device::mojom::blink::VRDisplayInfoPtr& display) { |
| } else { |
| m_stageParameters = nullptr; |
| } |
| + |
| + if (needOnPresentChange) { |
| + OnPresentChange(); |
| + } |
| } |
| void VRDisplay::disconnected() { |
| @@ -496,10 +508,10 @@ void VRDisplay::forceExitPresent() { |
| } else { |
| // Can't get into this presentation mode, so nothing to do here. |
| } |
| + m_isPresenting = false; |
|
mthiesse
2016/12/01 21:46:57
why this change?
klausw
2016/12/01 23:08:56
OnPresentChange() looks at m_isPresenting to tell
|
| OnPresentChange(); |
| } |
| - m_isPresenting = false; |
| m_renderingContext = nullptr; |
| m_contextGL = nullptr; |
| } |
| @@ -619,6 +631,10 @@ Document* VRDisplay::document() { |
| } |
| void VRDisplay::OnPresentChange() { |
| + if (m_isPresenting && !m_isValidDeviceForPresenting) { |
| + VLOG(1) << __FUNCTION__ << ": device not valid, not sending event"; |
| + return; |
| + } |
| m_navigatorVR->enqueueVREvent(VRDisplayEvent::create( |
| EventTypeNames::vrdisplaypresentchange, true, false, this, "")); |
| } |