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 2926953002: Fix WebVR so we don't animation when stopped at a JS breakpoint (Closed)
Patch Set: update includes Created 3 years, 6 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 if (which_eye == "right") 48 if (which_eye == "right")
49 return kVREyeRight; 49 return kVREyeRight;
50 return kVREyeNone; 50 return kVREyeNone;
51 } 51 }
52 52
53 } // namespace 53 } // namespace
54 54
55 VRDisplay::VRDisplay(NavigatorVR* navigator_vr, 55 VRDisplay::VRDisplay(NavigatorVR* navigator_vr,
56 device::mojom::blink::VRDisplayPtr display, 56 device::mojom::blink::VRDisplayPtr display,
57 device::mojom::blink::VRDisplayClientRequest request) 57 device::mojom::blink::VRDisplayClientRequest request)
58 : ContextLifecycleObserver(navigator_vr->GetDocument()), 58 : SuspendableObject(navigator_vr->GetDocument()),
59 navigator_vr_(navigator_vr), 59 navigator_vr_(navigator_vr),
60 capabilities_(new VRDisplayCapabilities()), 60 capabilities_(new VRDisplayCapabilities()),
61 eye_parameters_left_(new VREyeParameters()), 61 eye_parameters_left_(new VREyeParameters()),
62 eye_parameters_right_(new VREyeParameters()), 62 eye_parameters_right_(new VREyeParameters()),
63 display_(std::move(display)), 63 display_(std::move(display)),
64 submit_frame_client_binding_(this), 64 submit_frame_client_binding_(this),
65 display_client_binding_(this, std::move(request)) {} 65 display_client_binding_(this, std::move(request)) {
66 SuspendIfNeeded(); // Initialize SuspendabaleObject.
67 }
66 68
67 VRDisplay::~VRDisplay() {} 69 VRDisplay::~VRDisplay() {}
68 70
71 void VRDisplay::Suspend() {}
72
73 void VRDisplay::Resume() {
74 RequestVSync();
75 }
76
69 VRController* VRDisplay::Controller() { 77 VRController* VRDisplay::Controller() {
70 return navigator_vr_->Controller(); 78 return navigator_vr_->Controller();
71 } 79 }
72 80
73 void VRDisplay::Update(const device::mojom::blink::VRDisplayInfoPtr& display) { 81 void VRDisplay::Update(const device::mojom::blink::VRDisplayInfoPtr& display) {
74 display_id_ = display->index; 82 display_id_ = display->index;
75 display_name_ = display->displayName; 83 display_name_ = display->displayName;
76 is_connected_ = true; 84 is_connected_ = true;
77 85
78 capabilities_->SetHasPosition(display->capabilities->hasPosition); 86 capabilities_->SetHasPosition(display->capabilities->hasPosition);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 case kVREyeLeft: 131 case kVREyeLeft:
124 return eye_parameters_left_; 132 return eye_parameters_left_;
125 case kVREyeRight: 133 case kVREyeRight:
126 return eye_parameters_right_; 134 return eye_parameters_right_;
127 default: 135 default:
128 return nullptr; 136 return nullptr;
129 } 137 }
130 } 138 }
131 139
132 void VRDisplay::RequestVSync() { 140 void VRDisplay::RequestVSync() {
133 DVLOG(2) << __FUNCTION__ 141 DVLOG(2) << __FUNCTION__
mthiesse 2017/06/08 14:08:09 Oh, sorry, my mistake. The patch that makes this r
billorr 2017/06/08 18:22:35 Done.
134 << " start: pending_vrdisplay_raf_=" << pending_vrdisplay_raf_ 142 << " start: pending_vrdisplay_raf_=" << pending_vrdisplay_raf_
135 << " in_animation_frame_=" << in_animation_frame_ 143 << " in_animation_frame_=" << in_animation_frame_
136 << " did_submit_this_frame_=" << did_submit_this_frame_; 144 << " did_submit_this_frame_=" << did_submit_this_frame_;
137 145
138 // The logic here is a bit subtle. We get called from one of the following 146 // The logic here is a bit subtle. We get called from one of the following
139 // four contexts: 147 // four contexts:
140 // 148 //
141 // (a) from requestAnimationFrame if outside an animating context (i.e. the 149 // (a) from requestAnimationFrame if outside an animating context (i.e. the
142 // first rAF call from inside a getVRDisplays() promise) 150 // first rAF call from inside a getVRDisplays() promise)
143 // 151 //
(...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after
794 DVLOG(2) << __FUNCTION__; 802 DVLOG(2) << __FUNCTION__;
795 // Check if we still have a valid context, the animation controller 803 // Check if we still have a valid context, the animation controller
796 // or document may have disappeared since we scheduled this. 804 // or document may have disappeared since we scheduled this.
797 Document* doc = this->GetDocument(); 805 Document* doc = this->GetDocument();
798 if (!doc || display_blurred_) { 806 if (!doc || display_blurred_) {
799 DVLOG(2) << __FUNCTION__ << ": early exit, doc=" << doc 807 DVLOG(2) << __FUNCTION__ << ": early exit, doc=" << doc
800 << " display_blurred_=" << display_blurred_; 808 << " display_blurred_=" << display_blurred_;
801 return; 809 return;
802 } 810 }
803 811
812 if (doc->IsContextSuspended()) {
813 // We are currently suspended - try ProcessScheduledAnimations again later
814 // when we resume.
815 return;
816 }
817
804 TRACE_EVENT1("gpu", "VRDisplay::OnVSync", "frame", vr_frame_id_); 818 TRACE_EVENT1("gpu", "VRDisplay::OnVSync", "frame", vr_frame_id_);
805 819
806 if (pending_vrdisplay_raf_ && scripted_animation_controller_) { 820 if (pending_vrdisplay_raf_ && scripted_animation_controller_) {
807 // Run the callback, making sure that in_animation_frame_ is only 821 // Run the callback, making sure that in_animation_frame_ is only
808 // true for the vrDisplay rAF and not for a legacy window rAF 822 // true for the vrDisplay rAF and not for a legacy window rAF
809 // that may be called later. 823 // that may be called later.
810 AutoReset<bool> animating(&in_animation_frame_, true); 824 AutoReset<bool> animating(&in_animation_frame_, true);
811 pending_vrdisplay_raf_ = false; 825 pending_vrdisplay_raf_ = false;
812 did_submit_this_frame_ = false; 826 did_submit_this_frame_ = false;
813 scripted_animation_controller_->ServiceScriptedAnimations(timestamp); 827 scripted_animation_controller_->ServiceScriptedAnimations(timestamp);
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
903 } 917 }
904 918
905 ExecutionContext* VRDisplay::GetExecutionContext() const { 919 ExecutionContext* VRDisplay::GetExecutionContext() const {
906 return ContextLifecycleObserver::GetExecutionContext(); 920 return ContextLifecycleObserver::GetExecutionContext();
907 } 921 }
908 922
909 const AtomicString& VRDisplay::InterfaceName() const { 923 const AtomicString& VRDisplay::InterfaceName() const {
910 return EventTargetNames::VRDisplay; 924 return EventTargetNames::VRDisplay;
911 } 925 }
912 926
913 void VRDisplay::ContextDestroyed(ExecutionContext*) { 927 void VRDisplay::ContextDestroyed(ExecutionContext* context) {
928 SuspendableObject::ContextDestroyed(context);
914 ForceExitPresent(); 929 ForceExitPresent();
915 scripted_animation_controller_.Clear(); 930 scripted_animation_controller_.Clear();
916 } 931 }
917 932
918 bool VRDisplay::HasPendingActivity() const { 933 bool VRDisplay::HasPendingActivity() const {
919 // Prevent V8 from garbage collecting the wrapper object if there are 934 // Prevent V8 from garbage collecting the wrapper object if there are
920 // event listeners attached to it. 935 // event listeners attached to it.
921 return GetExecutionContext() && HasEventListeners(); 936 return GetExecutionContext() && HasEventListeners();
922 } 937 }
923 938
(...skipping 18 matching lines...) Expand all
942 visitor->Trace(stage_parameters_); 957 visitor->Trace(stage_parameters_);
943 visitor->Trace(eye_parameters_left_); 958 visitor->Trace(eye_parameters_left_);
944 visitor->Trace(eye_parameters_right_); 959 visitor->Trace(eye_parameters_right_);
945 visitor->Trace(layer_); 960 visitor->Trace(layer_);
946 visitor->Trace(rendering_context_); 961 visitor->Trace(rendering_context_);
947 visitor->Trace(scripted_animation_controller_); 962 visitor->Trace(scripted_animation_controller_);
948 visitor->Trace(pending_present_resolvers_); 963 visitor->Trace(pending_present_resolvers_);
949 } 964 }
950 965
951 } // namespace blink 966 } // 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