| 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/FrameRequestCallback.h" | 9 #include "core/dom/FrameRequestCallback.h" |
| 10 #include "core/dom/ScriptedAnimationController.h" | 10 #include "core/dom/ScriptedAnimationController.h" |
| (...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 674 OnPresentChange(); | 674 OnPresentChange(); |
| 675 } | 675 } |
| 676 | 676 |
| 677 m_renderingContext = nullptr; | 677 m_renderingContext = nullptr; |
| 678 m_contextGL = nullptr; | 678 m_contextGL = nullptr; |
| 679 m_pendingSubmitFrame = false; | 679 m_pendingSubmitFrame = false; |
| 680 m_pendingPreviousFrameRender = false; | 680 m_pendingPreviousFrameRender = false; |
| 681 } | 681 } |
| 682 | 682 |
| 683 void VRDisplay::OnActivate(device::mojom::blink::VRDisplayEventReason reason) { | 683 void VRDisplay::OnActivate(device::mojom::blink::VRDisplayEventReason reason) { |
| 684 if (!m_navigatorVR->isFocused() || m_displayBlurred) | |
| 685 return; | |
| 686 AutoReset<bool> activating(&m_inDisplayActivate, true); | 684 AutoReset<bool> activating(&m_inDisplayActivate, true); |
| 687 m_navigatorVR->dispatchVREvent(VRDisplayEvent::create( | 685 m_navigatorVR->dispatchVREvent(VRDisplayEvent::create( |
| 688 EventTypeNames::vrdisplayactivate, true, false, this, reason)); | 686 EventTypeNames::vrdisplayactivate, true, false, this, reason)); |
| 689 } | 687 } |
| 690 | 688 |
| 691 void VRDisplay::OnDeactivate( | 689 void VRDisplay::OnDeactivate( |
| 692 device::mojom::blink::VRDisplayEventReason reason) { | 690 device::mojom::blink::VRDisplayEventReason reason) { |
| 693 m_navigatorVR->enqueueVREvent(VRDisplayEvent::create( | 691 m_navigatorVR->enqueueVREvent(VRDisplayEvent::create( |
| 694 EventTypeNames::vrdisplaydeactivate, true, false, this, reason)); | 692 EventTypeNames::vrdisplaydeactivate, true, false, this, reason)); |
| 695 } | 693 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 706 AutoReset<bool> animating(&m_inAnimationFrame, true); | 704 AutoReset<bool> animating(&m_inAnimationFrame, true); |
| 707 m_pendingRaf = false; | 705 m_pendingRaf = false; |
| 708 | 706 |
| 709 m_scriptedAnimationController->serviceScriptedAnimations(timestamp); | 707 m_scriptedAnimationController->serviceScriptedAnimations(timestamp); |
| 710 } | 708 } |
| 711 | 709 |
| 712 void VRDisplay::OnVSync(device::mojom::blink::VRPosePtr pose, | 710 void VRDisplay::OnVSync(device::mojom::blink::VRPosePtr pose, |
| 713 mojo::common::mojom::blink::TimeDeltaPtr time, | 711 mojo::common::mojom::blink::TimeDeltaPtr time, |
| 714 int16_t frameId, | 712 int16_t frameId, |
| 715 device::mojom::blink::VRVSyncProvider::Status error) { | 713 device::mojom::blink::VRVSyncProvider::Status error) { |
| 714 m_VSyncConnectionFailed = false; |
| 716 switch (error) { | 715 switch (error) { |
| 717 case device::mojom::blink::VRVSyncProvider::Status::SUCCESS: | 716 case device::mojom::blink::VRVSyncProvider::Status::SUCCESS: |
| 718 break; | 717 break; |
| 719 case device::mojom::blink::VRVSyncProvider::Status::CLOSING: | 718 case device::mojom::blink::VRVSyncProvider::Status::CLOSING: |
| 720 return; | 719 return; |
| 721 } | 720 } |
| 722 m_pendingVsync = false; | 721 m_pendingVsync = false; |
| 723 | 722 |
| 724 WTF::TimeDelta timeDelta = | 723 WTF::TimeDelta timeDelta = |
| 725 WTF::TimeDelta::FromMicroseconds(time->microseconds); | 724 WTF::TimeDelta::FromMicroseconds(time->microseconds); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 753 WTF::bind(&VRDisplay::OnVSyncConnectionError, wrapWeakPersistent(this)))); | 752 WTF::bind(&VRDisplay::OnVSyncConnectionError, wrapWeakPersistent(this)))); |
| 754 if (m_pendingRaf && !m_displayBlurred) { | 753 if (m_pendingRaf && !m_displayBlurred) { |
| 755 m_pendingVsync = true; | 754 m_pendingVsync = true; |
| 756 m_vrVSyncProvider->GetVSync(convertToBaseCallback( | 755 m_vrVSyncProvider->GetVSync(convertToBaseCallback( |
| 757 WTF::bind(&VRDisplay::OnVSync, wrapWeakPersistent(this)))); | 756 WTF::bind(&VRDisplay::OnVSync, wrapWeakPersistent(this)))); |
| 758 } | 757 } |
| 759 } | 758 } |
| 760 | 759 |
| 761 void VRDisplay::OnVSyncConnectionError() { | 760 void VRDisplay::OnVSyncConnectionError() { |
| 762 m_vrVSyncProvider.reset(); | 761 m_vrVSyncProvider.reset(); |
| 762 if (m_VSyncConnectionFailed) |
| 763 return; |
| 763 ConnectVSyncProvider(); | 764 ConnectVSyncProvider(); |
| 765 m_VSyncConnectionFailed = true; |
| 764 } | 766 } |
| 765 | 767 |
| 766 ScriptedAnimationController& VRDisplay::ensureScriptedAnimationController( | 768 ScriptedAnimationController& VRDisplay::ensureScriptedAnimationController( |
| 767 Document* doc) { | 769 Document* doc) { |
| 768 if (!m_scriptedAnimationController) | 770 if (!m_scriptedAnimationController) |
| 769 m_scriptedAnimationController = ScriptedAnimationController::create(doc); | 771 m_scriptedAnimationController = ScriptedAnimationController::create(doc); |
| 770 | 772 |
| 771 return *m_scriptedAnimationController; | 773 return *m_scriptedAnimationController; |
| 772 } | 774 } |
| 773 | 775 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 809 visitor->trace(m_stageParameters); | 811 visitor->trace(m_stageParameters); |
| 810 visitor->trace(m_eyeParametersLeft); | 812 visitor->trace(m_eyeParametersLeft); |
| 811 visitor->trace(m_eyeParametersRight); | 813 visitor->trace(m_eyeParametersRight); |
| 812 visitor->trace(m_layer); | 814 visitor->trace(m_layer); |
| 813 visitor->trace(m_renderingContext); | 815 visitor->trace(m_renderingContext); |
| 814 visitor->trace(m_scriptedAnimationController); | 816 visitor->trace(m_scriptedAnimationController); |
| 815 visitor->trace(m_pendingPresentResolvers); | 817 visitor->trace(m_pendingPresentResolvers); |
| 816 } | 818 } |
| 817 | 819 |
| 818 } // namespace blink | 820 } // namespace blink |
| OLD | NEW |