| 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 660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 671 EventTypeNames::vrdisplayactivate, true, false, this, reason)); | 671 EventTypeNames::vrdisplayactivate, true, false, this, reason)); |
| 672 } | 672 } |
| 673 | 673 |
| 674 void VRDisplay::OnDeactivate( | 674 void VRDisplay::OnDeactivate( |
| 675 device::mojom::blink::VRDisplayEventReason reason) { | 675 device::mojom::blink::VRDisplayEventReason reason) { |
| 676 m_navigatorVR->enqueueVREvent(VRDisplayEvent::create( | 676 m_navigatorVR->enqueueVREvent(VRDisplayEvent::create( |
| 677 EventTypeNames::vrdisplaydeactivate, true, false, this, reason)); | 677 EventTypeNames::vrdisplaydeactivate, true, false, this, reason)); |
| 678 } | 678 } |
| 679 | 679 |
| 680 void VRDisplay::processScheduledAnimations(double timestamp) { | 680 void VRDisplay::processScheduledAnimations(double timestamp) { |
| 681 // Check if we still have a valid context, the animation controller |
| 682 // or document may have disappeared since we scheduled this. |
| 683 Document* doc = this->document(); |
| 684 if (!doc || m_displayBlurred || !m_scriptedAnimationController) |
| 685 return; |
| 686 |
| 681 TRACE_EVENT1("gpu", "VRDisplay::OnVSync", "frame", m_vrFrameId); | 687 TRACE_EVENT1("gpu", "VRDisplay::OnVSync", "frame", m_vrFrameId); |
| 682 | 688 |
| 683 AutoReset<bool> animating(&m_inAnimationFrame, true); | 689 AutoReset<bool> animating(&m_inAnimationFrame, true); |
| 684 m_pendingRaf = false; | 690 m_pendingRaf = false; |
| 691 |
| 685 m_scriptedAnimationController->serviceScriptedAnimations(timestamp); | 692 m_scriptedAnimationController->serviceScriptedAnimations(timestamp); |
| 686 } | 693 } |
| 687 | 694 |
| 688 void VRDisplay::OnVSync(device::mojom::blink::VRPosePtr pose, | 695 void VRDisplay::OnVSync(device::mojom::blink::VRPosePtr pose, |
| 689 mojo::common::mojom::blink::TimeDeltaPtr time, | 696 mojo::common::mojom::blink::TimeDeltaPtr time, |
| 690 int16_t frameId, | 697 int16_t frameId, |
| 691 device::mojom::blink::VRVSyncProvider::Status error) { | 698 device::mojom::blink::VRVSyncProvider::Status error) { |
| 692 switch (error) { | 699 switch (error) { |
| 693 case device::mojom::blink::VRVSyncProvider::Status::SUCCESS: | 700 case device::mojom::blink::VRVSyncProvider::Status::SUCCESS: |
| 694 break; | 701 break; |
| 695 case device::mojom::blink::VRVSyncProvider::Status::RETRY: | 702 case device::mojom::blink::VRVSyncProvider::Status::RETRY: |
| 696 m_vrVSyncProvider->GetVSync(convertToBaseCallback( | 703 m_vrVSyncProvider->GetVSync(convertToBaseCallback( |
| 697 WTF::bind(&VRDisplay::OnVSync, wrapWeakPersistent(this)))); | 704 WTF::bind(&VRDisplay::OnVSync, wrapWeakPersistent(this)))); |
| 698 return; | 705 return; |
| 699 } | 706 } |
| 700 m_pendingVsync = false; | 707 m_pendingVsync = false; |
| 701 if (m_displayBlurred) | |
| 702 return; | |
| 703 if (!m_scriptedAnimationController) | |
| 704 return; | |
| 705 Document* doc = this->document(); | |
| 706 if (!doc) | |
| 707 return; | |
| 708 | 708 |
| 709 WTF::TimeDelta timeDelta = | 709 WTF::TimeDelta timeDelta = |
| 710 WTF::TimeDelta::FromMicroseconds(time->microseconds); | 710 WTF::TimeDelta::FromMicroseconds(time->microseconds); |
| 711 // Ensure a consistent timebase with document rAF. | 711 // Ensure a consistent timebase with document rAF. |
| 712 if (m_timebase < 0) { | 712 if (m_timebase < 0) { |
| 713 m_timebase = WTF::monotonicallyIncreasingTime() - timeDelta.InSecondsF(); | 713 m_timebase = WTF::monotonicallyIncreasingTime() - timeDelta.InSecondsF(); |
| 714 } | 714 } |
| 715 | 715 |
| 716 m_framePose = std::move(pose); | 716 m_framePose = std::move(pose); |
| 717 m_vrFrameId = frameId; | 717 m_vrFrameId = frameId; |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 825 visitor->trace(m_stageParameters); | 825 visitor->trace(m_stageParameters); |
| 826 visitor->trace(m_eyeParametersLeft); | 826 visitor->trace(m_eyeParametersLeft); |
| 827 visitor->trace(m_eyeParametersRight); | 827 visitor->trace(m_eyeParametersRight); |
| 828 visitor->trace(m_layer); | 828 visitor->trace(m_layer); |
| 829 visitor->trace(m_renderingContext); | 829 visitor->trace(m_renderingContext); |
| 830 visitor->trace(m_scriptedAnimationController); | 830 visitor->trace(m_scriptedAnimationController); |
| 831 visitor->trace(m_pendingPresentResolvers); | 831 visitor->trace(m_pendingPresentResolvers); |
| 832 } | 832 } |
| 833 | 833 |
| 834 } // namespace blink | 834 } // namespace blink |
| OLD | NEW |