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" |
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
443 if (doc) { | 443 if (doc) { |
444 // Since the callback for requestPresent is asynchronous, we've lost our | 444 // Since the callback for requestPresent is asynchronous, we've lost our |
445 // UserGestureToken, and need to create a new one to enter fullscreen. | 445 // UserGestureToken, and need to create a new one to enter fullscreen. |
446 gestureIndicator = | 446 gestureIndicator = |
447 wrapUnique(new UserGestureIndicator(DocumentUserGestureToken::create( | 447 wrapUnique(new UserGestureIndicator(DocumentUserGestureToken::create( |
448 doc, UserGestureToken::Status::PossiblyExistingGesture))); | 448 doc, UserGestureToken::Status::PossiblyExistingGesture))); |
449 } | 449 } |
450 Fullscreen::requestFullscreen(*canvas, Fullscreen::UnprefixedRequest); | 450 Fullscreen::requestFullscreen(*canvas, Fullscreen::UnprefixedRequest); |
451 | 451 |
452 // Check to see if the canvas is still the current fullscreen | 452 // Check to see if the canvas is still the current fullscreen |
453 // element once every 5 seconds. | 453 // element once every 2 seconds. |
454 m_fullscreenCheckTimer.startRepeating(5.0, BLINK_FROM_HERE); | 454 m_fullscreenCheckTimer.startRepeating(2.0, BLINK_FROM_HERE); |
| 455 m_reenteredFullscreen = false; |
455 } | 456 } |
456 | 457 |
457 if (doc) { | 458 if (doc) { |
458 Platform::current()->recordRapporURL("VR.WebVR.PresentSuccess", | 459 Platform::current()->recordRapporURL("VR.WebVR.PresentSuccess", |
459 WebURL(doc->url())); | 460 WebURL(doc->url())); |
460 } | 461 } |
461 | 462 |
462 m_isPresenting = true; | 463 m_isPresenting = true; |
463 ReportPresentationResult(PresentationResult::Success); | 464 ReportPresentationResult(PresentationResult::Success); |
464 | 465 |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
632 EventTypeNames::vrdisplayactivate, true, false, this, reason)); | 633 EventTypeNames::vrdisplayactivate, true, false, this, reason)); |
633 } | 634 } |
634 | 635 |
635 void VRDisplay::OnDeactivate( | 636 void VRDisplay::OnDeactivate( |
636 device::mojom::blink::VRDisplayEventReason reason) { | 637 device::mojom::blink::VRDisplayEventReason reason) { |
637 m_navigatorVR->enqueueVREvent(VRDisplayEvent::create( | 638 m_navigatorVR->enqueueVREvent(VRDisplayEvent::create( |
638 EventTypeNames::vrdisplaydeactivate, true, false, this, reason)); | 639 EventTypeNames::vrdisplaydeactivate, true, false, this, reason)); |
639 } | 640 } |
640 | 641 |
641 void VRDisplay::onFullscreenCheck(TimerBase*) { | 642 void VRDisplay::onFullscreenCheck(TimerBase*) { |
| 643 if (!m_isPresenting) { |
| 644 m_fullscreenCheckTimer.stop(); |
| 645 return; |
| 646 } |
642 // TODO: This is a temporary measure to track if fullscreen mode has been | 647 // TODO: This is a temporary measure to track if fullscreen mode has been |
643 // exited by the UA. If so we need to end VR presentation. Soon we won't | 648 // exited by the UA. If so we need to end VR presentation. Soon we won't |
644 // depend on the Fullscreen API to fake VR presentation, so this will | 649 // depend on the Fullscreen API to fake VR presentation, so this will |
645 // become unnessecary. Until that point, though, this seems preferable to | 650 // become unnessecary. Until that point, though, this seems preferable to |
646 // adding a bunch of notification plumbing to Fullscreen. | 651 // adding a bunch of notification plumbing to Fullscreen. |
647 if (!Fullscreen::isCurrentFullScreenElement(*m_layer.source())) { | 652 if (!Fullscreen::isCurrentFullScreenElement(*m_layer.source())) { |
648 m_isPresenting = false; | 653 // TODO(mthiesse): Due to asynchronous resizing, we might get kicked out of |
649 OnPresentChange(); | 654 // fullscreen when changing display parameters upon entering WebVR. So one |
650 m_fullscreenCheckTimer.stop(); | 655 // time only, we reenter fullscreen after having left it; otherwise we exit |
651 if (!m_display) | 656 // presentation. |
| 657 if (m_reenteredFullscreen) { |
| 658 m_isPresenting = false; |
| 659 OnPresentChange(); |
| 660 m_fullscreenCheckTimer.stop(); |
| 661 if (m_display) |
| 662 m_display->ExitPresent(); |
652 return; | 663 return; |
653 m_display->ExitPresent(); | 664 } |
| 665 m_reenteredFullscreen = true; |
| 666 auto canvas = m_layer.source(); |
| 667 Document* doc = m_navigatorVR->document(); |
| 668 std::unique_ptr<UserGestureIndicator> gestureIndicator; |
| 669 if (doc) { |
| 670 gestureIndicator = |
| 671 wrapUnique(new UserGestureIndicator(DocumentUserGestureToken::create( |
| 672 doc, UserGestureToken::Status::PossiblyExistingGesture))); |
| 673 } |
| 674 Fullscreen::requestFullscreen(*canvas, Fullscreen::UnprefixedRequest); |
654 } | 675 } |
655 } | 676 } |
656 | 677 |
657 ScriptedAnimationController& VRDisplay::ensureScriptedAnimationController( | 678 ScriptedAnimationController& VRDisplay::ensureScriptedAnimationController( |
658 Document* doc) { | 679 Document* doc) { |
659 if (!m_scriptedAnimationController) | 680 if (!m_scriptedAnimationController) |
660 m_scriptedAnimationController = ScriptedAnimationController::create(doc); | 681 m_scriptedAnimationController = ScriptedAnimationController::create(doc); |
661 | 682 |
662 return *m_scriptedAnimationController; | 683 return *m_scriptedAnimationController; |
663 } | 684 } |
664 | 685 |
665 void VRDisplay::dispose() { | 686 void VRDisplay::dispose() { |
666 m_binding.Close(); | 687 m_binding.Close(); |
667 } | 688 } |
668 | 689 |
669 DEFINE_TRACE(VRDisplay) { | 690 DEFINE_TRACE(VRDisplay) { |
670 visitor->trace(m_navigatorVR); | 691 visitor->trace(m_navigatorVR); |
671 visitor->trace(m_capabilities); | 692 visitor->trace(m_capabilities); |
672 visitor->trace(m_stageParameters); | 693 visitor->trace(m_stageParameters); |
673 visitor->trace(m_eyeParametersLeft); | 694 visitor->trace(m_eyeParametersLeft); |
674 visitor->trace(m_eyeParametersRight); | 695 visitor->trace(m_eyeParametersRight); |
675 visitor->trace(m_layer); | 696 visitor->trace(m_layer); |
676 visitor->trace(m_renderingContext); | 697 visitor->trace(m_renderingContext); |
677 visitor->trace(m_scriptedAnimationController); | 698 visitor->trace(m_scriptedAnimationController); |
678 } | 699 } |
679 | 700 |
680 } // namespace blink | 701 } // namespace blink |
OLD | NEW |