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 "modules/vr/VRDisplay.h" | 5 #include "modules/vr/VRDisplay.h" |
6 | 6 |
7 #include "core/css/StylePropertySet.h" | 7 #include "core/css/StylePropertySet.h" |
8 #include "core/dom/DOMException.h" | 8 #include "core/dom/DOMException.h" |
9 #include "core/dom/DocumentUserGestureToken.h" | 9 #include "core/dom/DocumentUserGestureToken.h" |
10 #include "core/dom/FrameRequestCallback.h" | 10 #include "core/dom/FrameRequestCallback.h" |
11 #include "core/dom/Fullscreen.h" | 11 #include "core/dom/Fullscreen.h" |
12 #include "core/dom/ScriptedAnimationController.h" | 12 #include "core/dom/ScriptedAnimationController.h" |
13 #include "core/frame/UseCounter.h" | 13 #include "core/frame/UseCounter.h" |
14 #include "core/inspector/ConsoleMessage.h" | 14 #include "core/inspector/ConsoleMessage.h" |
15 #include "gpu/command_buffer/client/gles2_interface.h" | 15 #include "gpu/command_buffer/client/gles2_interface.h" |
16 #include "modules/vr/NavigatorVR.h" | 16 #include "modules/vr/NavigatorVR.h" |
17 #include "modules/vr/VRController.h" | 17 #include "modules/vr/VRController.h" |
18 #include "modules/vr/VRDisplayCapabilities.h" | 18 #include "modules/vr/VRDisplayCapabilities.h" |
19 #include "modules/vr/VREyeParameters.h" | 19 #include "modules/vr/VREyeParameters.h" |
20 #include "modules/vr/VRFrameData.h" | 20 #include "modules/vr/VRFrameData.h" |
21 #include "modules/vr/VRLayer.h" | 21 #include "modules/vr/VRLayer.h" |
22 #include "modules/vr/VRPose.h" | 22 #include "modules/vr/VRPose.h" |
23 #include "modules/vr/VRStageParameters.h" | 23 #include "modules/vr/VRStageParameters.h" |
24 #include "modules/webgl/WebGLRenderingContextBase.h" | 24 #include "modules/webgl/WebGLRenderingContextBase.h" |
25 #include "platform/Histogram.h" | 25 #include "platform/Histogram.h" |
26 #include "platform/RuntimeEnabledFeatures.h" | |
26 #include "platform/UserGestureIndicator.h" | 27 #include "platform/UserGestureIndicator.h" |
27 #include "public/platform/Platform.h" | 28 #include "public/platform/Platform.h" |
28 #include "wtf/AutoReset.h" | 29 #include "wtf/AutoReset.h" |
29 | 30 |
30 namespace blink { | 31 namespace blink { |
31 | 32 |
32 namespace { | 33 namespace { |
33 | 34 |
34 VREye stringToVREye(const String& whichEye) { | 35 VREye stringToVREye(const String& whichEye) { |
35 if (whichEye == "left") | 36 if (whichEye == "left") |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
267 // request. | 268 // request. |
268 if (!m_capabilities->canPresent()) { | 269 if (!m_capabilities->canPresent()) { |
269 DOMException* exception = | 270 DOMException* exception = |
270 DOMException::create(InvalidStateError, "VRDisplay cannot present."); | 271 DOMException::create(InvalidStateError, "VRDisplay cannot present."); |
271 resolver->reject(exception); | 272 resolver->reject(exception); |
272 ReportPresentationResult(PresentationResult::VRDisplayCannotPresent); | 273 ReportPresentationResult(PresentationResult::VRDisplayCannotPresent); |
273 return promise; | 274 return promise; |
274 } | 275 } |
275 | 276 |
276 bool firstPresent = !m_isPresenting; | 277 bool firstPresent = !m_isPresenting; |
278 bool gesturesDisabled = | |
279 RuntimeEnabledFeatures::webVrGesturesDisabledEnabled(); | |
bokan
2016/11/30 22:29:11
Perhaps a better name might be webVrWithoutUserGes
bsheedy
2016/11/30 22:45:29
Done.
| |
277 | 280 |
278 // Initiating VR presentation is only allowed in response to a user gesture. | 281 // Initiating VR presentation is only allowed in response to a user gesture. |
279 // If the VRDisplay is already presenting, however, repeated calls are | 282 // If the VRDisplay is already presenting, however, repeated calls are |
280 // allowed outside a user gesture so that the presented content may be | 283 // allowed outside a user gesture so that the presented content may be |
281 // updated. | 284 // updated. |
282 if (firstPresent && !UserGestureIndicator::utilizeUserGesture()) { | 285 if (firstPresent && !UserGestureIndicator::utilizeUserGesture() && |
286 !gesturesDisabled) { | |
283 DOMException* exception = DOMException::create( | 287 DOMException* exception = DOMException::create( |
284 InvalidStateError, "API can only be initiated by a user gesture."); | 288 InvalidStateError, "API can only be initiated by a user gesture."); |
285 resolver->reject(exception); | 289 resolver->reject(exception); |
286 ReportPresentationResult(PresentationResult::NotInitiatedByUserGesture); | 290 ReportPresentationResult(PresentationResult::NotInitiatedByUserGesture); |
287 return promise; | 291 return promise; |
288 } | 292 } |
289 | 293 |
290 // A valid number of layers must be provided in order to present. | 294 // A valid number of layers must be provided in order to present. |
291 if (layers.size() == 0 || layers.size() > m_capabilities->maxLayers()) { | 295 if (layers.size() == 0 || layers.size() > m_capabilities->maxLayers()) { |
292 forceExitPresent(); | 296 forceExitPresent(); |
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
671 visitor->trace(m_capabilities); | 675 visitor->trace(m_capabilities); |
672 visitor->trace(m_stageParameters); | 676 visitor->trace(m_stageParameters); |
673 visitor->trace(m_eyeParametersLeft); | 677 visitor->trace(m_eyeParametersLeft); |
674 visitor->trace(m_eyeParametersRight); | 678 visitor->trace(m_eyeParametersRight); |
675 visitor->trace(m_layer); | 679 visitor->trace(m_layer); |
676 visitor->trace(m_renderingContext); | 680 visitor->trace(m_renderingContext); |
677 visitor->trace(m_scriptedAnimationController); | 681 visitor->trace(m_scriptedAnimationController); |
678 } | 682 } |
679 | 683 |
680 } // namespace blink | 684 } // namespace blink |
OLD | NEW |