Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(88)

Side by Side Diff: third_party/WebKit/Source/modules/vr/VRDisplay.cpp

Issue 2881233002: WebVR: lock focus while presenting to presenting window (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/modules/vr/VRDisplay.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 } else { 98 } else {
99 stage_parameters_ = nullptr; 99 stage_parameters_ = nullptr;
100 } 100 }
101 101
102 if (need_on_present_change) { 102 if (need_on_present_change) {
103 OnPresentChange(); 103 OnPresentChange();
104 } 104 }
105 } 105 }
106 106
107 bool VRDisplay::getFrameData(VRFrameData* frame_data) { 107 bool VRDisplay::getFrameData(VRFrameData* frame_data) {
108 if (!navigator_vr_->IsFocused() || !frame_pose_ || display_blurred_) 108 if (!FocusedOrPresenting() || !frame_pose_ || display_blurred_)
109 return false; 109 return false;
110 110
111 if (!frame_data) 111 if (!frame_data)
112 return false; 112 return false;
113 113
114 if (depth_near_ == depth_far_) 114 if (depth_near_ == depth_far_)
115 return false; 115 return false;
116 116
117 return frame_data->Update(frame_pose_, eye_parameters_left_, 117 return frame_data->Update(frame_pose_, eye_parameters_left_,
118 eye_parameters_right_, depth_near_, depth_far_); 118 eye_parameters_right_, depth_near_, depth_far_);
(...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after
783 // this is due to WaitForIncomingMethodCall receiving the OnVSync 783 // this is due to WaitForIncomingMethodCall receiving the OnVSync
784 // but queueing it for immediate execution since it doesn't match 784 // but queueing it for immediate execution since it doesn't match
785 // the interface being waited on. 785 // the interface being waited on.
786 Platform::Current()->CurrentThread()->GetWebTaskRunner()->PostTask( 786 Platform::Current()->CurrentThread()->GetWebTaskRunner()->PostTask(
787 BLINK_FROM_HERE, 787 BLINK_FROM_HERE,
788 WTF::Bind(&VRDisplay::ProcessScheduledAnimations, 788 WTF::Bind(&VRDisplay::ProcessScheduledAnimations,
789 WrapWeakPersistent(this), timebase_ + time_delta.InSecondsF())); 789 WrapWeakPersistent(this), timebase_ + time_delta.InSecondsF()));
790 } 790 }
791 791
792 void VRDisplay::ConnectVSyncProvider() { 792 void VRDisplay::ConnectVSyncProvider() {
793 if (!navigator_vr_->IsFocused() || vr_v_sync_provider_.is_bound()) 793 if (!FocusedOrPresenting() || vr_v_sync_provider_.is_bound())
794 return; 794 return;
795 display_->GetVRVSyncProvider(mojo::MakeRequest(&vr_v_sync_provider_)); 795 display_->GetVRVSyncProvider(mojo::MakeRequest(&vr_v_sync_provider_));
796 vr_v_sync_provider_.set_connection_error_handler(ConvertToBaseCallback( 796 vr_v_sync_provider_.set_connection_error_handler(ConvertToBaseCallback(
797 WTF::Bind(&VRDisplay::OnVSyncConnectionError, WrapWeakPersistent(this)))); 797 WTF::Bind(&VRDisplay::OnVSyncConnectionError, WrapWeakPersistent(this))));
798 if (pending_vrdisplay_raf_ && !display_blurred_) { 798 if (pending_vrdisplay_raf_ && !display_blurred_) {
799 pending_vsync_ = true; 799 pending_vsync_ = true;
800 vr_v_sync_provider_->GetVSync(ConvertToBaseCallback( 800 vr_v_sync_provider_->GetVSync(ConvertToBaseCallback(
801 WTF::Bind(&VRDisplay::OnVSync, WrapWeakPersistent(this)))); 801 WTF::Bind(&VRDisplay::OnVSync, WrapWeakPersistent(this))));
802 } 802 }
803 } 803 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
842 return GetExecutionContext() && HasEventListeners(); 842 return GetExecutionContext() && HasEventListeners();
843 } 843 }
844 844
845 void VRDisplay::FocusChanged() { 845 void VRDisplay::FocusChanged() {
846 // TODO(mthiesse): Blur/focus the display. 846 // TODO(mthiesse): Blur/focus the display.
847 DVLOG(1) << __FUNCTION__; 847 DVLOG(1) << __FUNCTION__;
848 vr_v_sync_provider_.reset(); 848 vr_v_sync_provider_.reset();
849 ConnectVSyncProvider(); 849 ConnectVSyncProvider();
850 } 850 }
851 851
852 bool VRDisplay::FocusedOrPresenting() {
853 // TODO(mthiesse, crbug.com/687411): Focused state should be determined
854 // browser-side to correctly track which display should be receiving input.
855 return navigator_vr_->IsFocused() || is_presenting_;
856 }
857
852 DEFINE_TRACE(VRDisplay) { 858 DEFINE_TRACE(VRDisplay) {
853 EventTargetWithInlineData::Trace(visitor); 859 EventTargetWithInlineData::Trace(visitor);
854 ContextLifecycleObserver::Trace(visitor); 860 ContextLifecycleObserver::Trace(visitor);
855 visitor->Trace(navigator_vr_); 861 visitor->Trace(navigator_vr_);
856 visitor->Trace(capabilities_); 862 visitor->Trace(capabilities_);
857 visitor->Trace(stage_parameters_); 863 visitor->Trace(stage_parameters_);
858 visitor->Trace(eye_parameters_left_); 864 visitor->Trace(eye_parameters_left_);
859 visitor->Trace(eye_parameters_right_); 865 visitor->Trace(eye_parameters_right_);
860 visitor->Trace(layer_); 866 visitor->Trace(layer_);
861 visitor->Trace(rendering_context_); 867 visitor->Trace(rendering_context_);
862 visitor->Trace(scripted_animation_controller_); 868 visitor->Trace(scripted_animation_controller_);
863 visitor->Trace(pending_present_resolvers_); 869 visitor->Trace(pending_present_resolvers_);
864 } 870 }
865 871
866 } // namespace blink 872 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/vr/VRDisplay.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698