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