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" |
11 #include "core/dom/TaskRunnerHelper.h" | 11 #include "core/dom/TaskRunnerHelper.h" |
| 12 #include "core/frame/Frame.h" |
12 #include "core/frame/FrameView.h" | 13 #include "core/frame/FrameView.h" |
13 #include "core/frame/ImageBitmap.h" | 14 #include "core/frame/ImageBitmap.h" |
14 #include "core/frame/UseCounter.h" | 15 #include "core/frame/UseCounter.h" |
15 #include "core/inspector/ConsoleMessage.h" | 16 #include "core/inspector/ConsoleMessage.h" |
16 #include "core/layout/LayoutView.h" | 17 #include "core/layout/LayoutView.h" |
17 #include "core/layout/compositing/PaintLayerCompositor.h" | 18 #include "core/layout/compositing/PaintLayerCompositor.h" |
18 #include "core/loader/DocumentLoader.h" | 19 #include "core/loader/DocumentLoader.h" |
19 #include "gpu/command_buffer/client/gles2_interface.h" | 20 #include "gpu/command_buffer/client/gles2_interface.h" |
20 #include "gpu/command_buffer/common/mailbox_holder.h" | 21 #include "gpu/command_buffer/common/mailbox_holder.h" |
21 #include "modules/EventTargetModules.h" | 22 #include "modules/EventTargetModules.h" |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 stage_parameters_->Update(display->stageParameters); | 98 stage_parameters_->Update(display->stageParameters); |
98 } else { | 99 } else { |
99 stage_parameters_ = nullptr; | 100 stage_parameters_ = nullptr; |
100 } | 101 } |
101 | 102 |
102 if (need_on_present_change) { | 103 if (need_on_present_change) { |
103 OnPresentChange(); | 104 OnPresentChange(); |
104 } | 105 } |
105 } | 106 } |
106 | 107 |
| 108 bool VRDisplay::IsPresentationFocused() { |
| 109 if (!navigator_vr_) |
| 110 return false; |
| 111 |
| 112 if (navigator_vr_->IsFocused()) |
| 113 return true; |
| 114 |
| 115 auto doc = navigator_vr_->GetDocument(); |
| 116 if (!doc) |
| 117 return false; |
| 118 |
| 119 // Check if this is an embedded iframe without focus. If a local parent is |
| 120 // focused, continue presenting. |
| 121 |
| 122 Frame* frame = doc->GetFrame(); |
| 123 for (; frame; frame = frame->Tree().Parent()) { |
| 124 if (!frame->IsLocalFrame()) |
| 125 break; |
| 126 auto frame_doc = ToLocalFrame(frame)->GetDocument(); |
| 127 if (frame_doc && frame_doc->hasFocus()) { |
| 128 DVLOG(3) << __FUNCTION__ << ": a parent frame is focused"; |
| 129 return true; |
| 130 } |
| 131 } |
| 132 |
| 133 return false; |
| 134 } |
| 135 |
107 bool VRDisplay::getFrameData(VRFrameData* frame_data) { | 136 bool VRDisplay::getFrameData(VRFrameData* frame_data) { |
108 if (!navigator_vr_->IsFocused() || !frame_pose_ || display_blurred_) | 137 if (!IsPresentationFocused() || !frame_pose_ || display_blurred_) |
109 return false; | 138 return false; |
110 | 139 |
111 if (!frame_data) | 140 if (!frame_data) |
112 return false; | 141 return false; |
113 | 142 |
114 if (depth_near_ == depth_far_) | 143 if (depth_near_ == depth_far_) |
115 return false; | 144 return false; |
116 | 145 |
117 return frame_data->Update(frame_pose_, eye_parameters_left_, | 146 return frame_data->Update(frame_pose_, eye_parameters_left_, |
118 eye_parameters_right_, depth_near_, depth_far_); | 147 eye_parameters_right_, depth_near_, depth_far_); |
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
740 // this is due to WaitForIncomingMethodCall receiving the OnVSync | 769 // this is due to WaitForIncomingMethodCall receiving the OnVSync |
741 // but queueing it for immediate execution since it doesn't match | 770 // but queueing it for immediate execution since it doesn't match |
742 // the interface being waited on. | 771 // the interface being waited on. |
743 Platform::Current()->CurrentThread()->GetWebTaskRunner()->PostTask( | 772 Platform::Current()->CurrentThread()->GetWebTaskRunner()->PostTask( |
744 BLINK_FROM_HERE, | 773 BLINK_FROM_HERE, |
745 WTF::Bind(&VRDisplay::ProcessScheduledAnimations, | 774 WTF::Bind(&VRDisplay::ProcessScheduledAnimations, |
746 WrapWeakPersistent(this), timebase_ + time_delta.InSecondsF())); | 775 WrapWeakPersistent(this), timebase_ + time_delta.InSecondsF())); |
747 } | 776 } |
748 | 777 |
749 void VRDisplay::ConnectVSyncProvider() { | 778 void VRDisplay::ConnectVSyncProvider() { |
750 if (!navigator_vr_->IsFocused() || vr_v_sync_provider_.is_bound()) | 779 DVLOG(1) << __FUNCTION__ |
| 780 << ": IsPresentationFocused()=" << IsPresentationFocused() |
| 781 << " vr_v_sync_provider_.is_bound()=" |
| 782 << vr_v_sync_provider_.is_bound(); |
| 783 if (!IsPresentationFocused() || vr_v_sync_provider_.is_bound()) |
751 return; | 784 return; |
752 display_->GetVRVSyncProvider(mojo::MakeRequest(&vr_v_sync_provider_)); | 785 display_->GetVRVSyncProvider(mojo::MakeRequest(&vr_v_sync_provider_)); |
753 vr_v_sync_provider_.set_connection_error_handler(ConvertToBaseCallback( | 786 vr_v_sync_provider_.set_connection_error_handler(ConvertToBaseCallback( |
754 WTF::Bind(&VRDisplay::OnVSyncConnectionError, WrapWeakPersistent(this)))); | 787 WTF::Bind(&VRDisplay::OnVSyncConnectionError, WrapWeakPersistent(this)))); |
755 if (pending_raf_ && !display_blurred_) { | 788 if (pending_raf_ && !display_blurred_) { |
756 pending_vsync_ = true; | 789 pending_vsync_ = true; |
757 vr_v_sync_provider_->GetVSync(ConvertToBaseCallback( | 790 vr_v_sync_provider_->GetVSync(ConvertToBaseCallback( |
758 WTF::Bind(&VRDisplay::OnVSync, WrapWeakPersistent(this)))); | 791 WTF::Bind(&VRDisplay::OnVSync, WrapWeakPersistent(this)))); |
759 } | 792 } |
760 } | 793 } |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
813 visitor->Trace(stage_parameters_); | 846 visitor->Trace(stage_parameters_); |
814 visitor->Trace(eye_parameters_left_); | 847 visitor->Trace(eye_parameters_left_); |
815 visitor->Trace(eye_parameters_right_); | 848 visitor->Trace(eye_parameters_right_); |
816 visitor->Trace(layer_); | 849 visitor->Trace(layer_); |
817 visitor->Trace(rendering_context_); | 850 visitor->Trace(rendering_context_); |
818 visitor->Trace(scripted_animation_controller_); | 851 visitor->Trace(scripted_animation_controller_); |
819 visitor->Trace(pending_present_resolvers_); | 852 visitor->Trace(pending_present_resolvers_); |
820 } | 853 } |
821 | 854 |
822 } // namespace blink | 855 } // namespace blink |
OLD | NEW |