| 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 672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 683 EventTypeNames::vrdisplayactivate, true, false, this, reason)); | 683 EventTypeNames::vrdisplayactivate, true, false, this, reason)); |
| 684 } | 684 } |
| 685 | 685 |
| 686 void VRDisplay::OnDeactivate( | 686 void VRDisplay::OnDeactivate( |
| 687 device::mojom::blink::VRDisplayEventReason reason) { | 687 device::mojom::blink::VRDisplayEventReason reason) { |
| 688 m_navigatorVR->enqueueVREvent(VRDisplayEvent::create( | 688 m_navigatorVR->enqueueVREvent(VRDisplayEvent::create( |
| 689 EventTypeNames::vrdisplaydeactivate, true, false, this, reason)); | 689 EventTypeNames::vrdisplaydeactivate, true, false, this, reason)); |
| 690 } | 690 } |
| 691 | 691 |
| 692 void VRDisplay::processScheduledAnimations(double timestamp) { | 692 void VRDisplay::processScheduledAnimations(double timestamp) { |
| 693 // Check if we still have a valid context, the animation controller |
| 694 // or document may have disappeared since we scheduled this. |
| 695 Document* doc = this->document(); |
| 696 if (!doc || m_displayBlurred || !m_scriptedAnimationController) |
| 697 return; |
| 698 |
| 693 TRACE_EVENT1("gpu", "VRDisplay::OnVSync", "frame", m_vrFrameId); | 699 TRACE_EVENT1("gpu", "VRDisplay::OnVSync", "frame", m_vrFrameId); |
| 694 | 700 |
| 695 AutoReset<bool> animating(&m_inAnimationFrame, true); | 701 AutoReset<bool> animating(&m_inAnimationFrame, true); |
| 696 m_pendingRaf = false; | 702 m_pendingRaf = false; |
| 703 |
| 697 m_scriptedAnimationController->serviceScriptedAnimations(timestamp); | 704 m_scriptedAnimationController->serviceScriptedAnimations(timestamp); |
| 698 } | 705 } |
| 699 | 706 |
| 700 void VRDisplay::OnVSync(device::mojom::blink::VRPosePtr pose, | 707 void VRDisplay::OnVSync(device::mojom::blink::VRPosePtr pose, |
| 701 mojo::common::mojom::blink::TimeDeltaPtr time, | 708 mojo::common::mojom::blink::TimeDeltaPtr time, |
| 702 int16_t frameId, | 709 int16_t frameId, |
| 703 device::mojom::blink::VRVSyncProvider::Status error) { | 710 device::mojom::blink::VRVSyncProvider::Status error) { |
| 704 switch (error) { | 711 switch (error) { |
| 705 case device::mojom::blink::VRVSyncProvider::Status::SUCCESS: | 712 case device::mojom::blink::VRVSyncProvider::Status::SUCCESS: |
| 706 break; | 713 break; |
| 707 case device::mojom::blink::VRVSyncProvider::Status::CLOSING: | 714 case device::mojom::blink::VRVSyncProvider::Status::CLOSING: |
| 708 return; | 715 return; |
| 709 } | 716 } |
| 710 m_pendingVsync = false; | 717 m_pendingVsync = false; |
| 711 Document* doc = this->document(); | |
| 712 if (!doc || m_displayBlurred || !m_scriptedAnimationController) | |
| 713 return; | |
| 714 | 718 |
| 715 WTF::TimeDelta timeDelta = | 719 WTF::TimeDelta timeDelta = |
| 716 WTF::TimeDelta::FromMicroseconds(time->microseconds); | 720 WTF::TimeDelta::FromMicroseconds(time->microseconds); |
| 717 // Ensure a consistent timebase with document rAF. | 721 // Ensure a consistent timebase with document rAF. |
| 718 if (m_timebase < 0) { | 722 if (m_timebase < 0) { |
| 719 m_timebase = WTF::monotonicallyIncreasingTime() - timeDelta.InSecondsF(); | 723 m_timebase = WTF::monotonicallyIncreasingTime() - timeDelta.InSecondsF(); |
| 720 } | 724 } |
| 721 | 725 |
| 722 m_framePose = std::move(pose); | 726 m_framePose = std::move(pose); |
| 723 m_vrFrameId = frameId; | 727 m_vrFrameId = frameId; |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 800 visitor->trace(m_stageParameters); | 804 visitor->trace(m_stageParameters); |
| 801 visitor->trace(m_eyeParametersLeft); | 805 visitor->trace(m_eyeParametersLeft); |
| 802 visitor->trace(m_eyeParametersRight); | 806 visitor->trace(m_eyeParametersRight); |
| 803 visitor->trace(m_layer); | 807 visitor->trace(m_layer); |
| 804 visitor->trace(m_renderingContext); | 808 visitor->trace(m_renderingContext); |
| 805 visitor->trace(m_scriptedAnimationController); | 809 visitor->trace(m_scriptedAnimationController); |
| 806 visitor->trace(m_pendingPresentResolvers); | 810 visitor->trace(m_pendingPresentResolvers); |
| 807 } | 811 } |
| 808 | 812 |
| 809 } // namespace blink | 813 } // namespace blink |
| OLD | NEW |