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

Side by Side Diff: cc/scheduler/scheduler.cc

Issue 2411793008: Adds BeginFrameControl via DevTools.
Patch Set: BFC prototype v2 with allow_latency_opts and waiting for BFOs. Created 4 years, 1 month 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 | « cc/output/begin_frame_args.cc ('k') | cc/scheduler/scheduler_state_machine.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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 "cc/scheduler/scheduler.h" 5 #include "cc/scheduler/scheduler.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 state_machine_.SetSkipNextBeginMainFrameToReduceLatency(); 389 state_machine_.SetSkipNextBeginMainFrameToReduceLatency();
390 } else if (ShouldRecoverImplLatency(adjusted_args, 390 } else if (ShouldRecoverImplLatency(adjusted_args,
391 can_activate_before_deadline)) { 391 can_activate_before_deadline)) {
392 TRACE_EVENT_INSTANT0("cc", "SkipBeginImplFrameToReduceLatency", 392 TRACE_EVENT_INSTANT0("cc", "SkipBeginImplFrameToReduceLatency",
393 TRACE_EVENT_SCOPE_THREAD); 393 TRACE_EVENT_SCOPE_THREAD);
394 if (begin_frame_source_) 394 if (begin_frame_source_)
395 begin_frame_source_->DidFinishFrame(this, 0); 395 begin_frame_source_->DidFinishFrame(this, 0);
396 return; 396 return;
397 } 397 }
398 398
399 state_machine_.SetBeginFrameAllowsLatencyOptimizations(
400 adjusted_args.allow_latency_optimizations);
401
399 BeginImplFrame(adjusted_args); 402 BeginImplFrame(adjusted_args);
400 } 403 }
401 404
402 void Scheduler::BeginImplFrameSynchronous(const BeginFrameArgs& args) { 405 void Scheduler::BeginImplFrameSynchronous(const BeginFrameArgs& args) {
403 TRACE_EVENT1("cc,benchmark", "Scheduler::BeginImplFrame", "args", 406 TRACE_EVENT1("cc,benchmark", "Scheduler::BeginImplFrame", "args",
404 args.AsValue()); 407 args.AsValue());
405 408
406 // The main thread currently can't commit before we draw with the 409 // The main thread currently can't commit before we draw with the
407 // synchronous compositor, so never consider the BeginMainFrame fast. 410 // synchronous compositor, so never consider the BeginMainFrame fast.
408 state_machine_.SetCriticalBeginMainFrameToActivateIsFast(false); 411 state_machine_.SetCriticalBeginMainFrameToActivateIsFast(false);
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 692
690 // The main thread is in a low latency mode and there's no need to recover. 693 // The main thread is in a low latency mode and there's no need to recover.
691 if (!state_machine_.main_thread_missed_last_deadline()) 694 if (!state_machine_.main_thread_missed_last_deadline())
692 return false; 695 return false;
693 696
694 // When prioritizing impl thread latency, we currently put the 697 // When prioritizing impl thread latency, we currently put the
695 // main thread in a high latency mode. Don't try to fight it. 698 // main thread in a high latency mode. Don't try to fight it.
696 if (state_machine_.ImplLatencyTakesPriority()) 699 if (state_machine_.ImplLatencyTakesPriority())
697 return false; 700 return false;
698 701
702 // If the args explicitly forbid it, we shouldn't skip BeginMainFrames.
703 if (!args.allow_latency_optimizations)
704 return false;
705
699 return can_activate_before_deadline; 706 return can_activate_before_deadline;
700 } 707 }
701 708
702 bool Scheduler::ShouldRecoverImplLatency( 709 bool Scheduler::ShouldRecoverImplLatency(
703 const BeginFrameArgs& args, 710 const BeginFrameArgs& args,
704 bool can_activate_before_deadline) const { 711 bool can_activate_before_deadline) const {
705 DCHECK(!settings_.using_synchronous_renderer_compositor); 712 DCHECK(!settings_.using_synchronous_renderer_compositor);
706 713
707 if (!settings_.enable_latency_recovery) 714 if (!settings_.enable_latency_recovery)
708 return false; 715 return false;
709 716
710 // Disable impl thread latency recovery when using the unthrottled 717 // Disable impl thread latency recovery when using the unthrottled
711 // begin frame source since we will always get a BeginFrame before 718 // begin frame source since we will always get a BeginFrame before
712 // the swap ack and our heuristics below will not work. 719 // the swap ack and our heuristics below will not work.
713 if (begin_frame_source_ && !begin_frame_source_->IsThrottled()) 720 if (begin_frame_source_ && !begin_frame_source_->IsThrottled())
714 return false; 721 return false;
715 722
716 // If we are swap throttled at the BeginFrame, that means the impl thread is 723 // If we are swap throttled at the BeginFrame, that means the impl thread is
717 // very likely in a high latency mode. 724 // very likely in a high latency mode.
718 bool impl_thread_is_likely_high_latency = state_machine_.IsDrawThrottled(); 725 bool impl_thread_is_likely_high_latency = state_machine_.IsDrawThrottled();
719 if (!impl_thread_is_likely_high_latency) 726 if (!impl_thread_is_likely_high_latency)
720 return false; 727 return false;
721 728
729 // If the args explicitly forbid it, we shouldn't skip BeginFrames.
730 if (!args.allow_latency_optimizations)
731 return false;
732
722 // The deadline may be in the past if our draw time is too long. 733 // The deadline may be in the past if our draw time is too long.
723 bool can_draw_before_deadline = args.frame_time < args.deadline; 734 bool can_draw_before_deadline = args.frame_time < args.deadline;
724 735
725 // When prioritizing impl thread latency, the deadline doesn't wait 736 // When prioritizing impl thread latency, the deadline doesn't wait
726 // for the main thread. 737 // for the main thread.
727 if (state_machine_.ImplLatencyTakesPriority()) 738 if (state_machine_.ImplLatencyTakesPriority())
728 return can_draw_before_deadline; 739 return can_draw_before_deadline;
729 740
730 // If we only have impl-side updates, the deadline doesn't wait for 741 // If we only have impl-side updates, the deadline doesn't wait for
731 // the main thread. 742 // the main thread.
(...skipping 19 matching lines...) Expand all
751 } 762 }
752 763
753 bool Scheduler::IsBeginMainFrameSentOrStarted() const { 764 bool Scheduler::IsBeginMainFrameSentOrStarted() const {
754 return (state_machine_.begin_main_frame_state() == 765 return (state_machine_.begin_main_frame_state() ==
755 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_SENT || 766 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_SENT ||
756 state_machine_.begin_main_frame_state() == 767 state_machine_.begin_main_frame_state() ==
757 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_STARTED); 768 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_STARTED);
758 } 769 }
759 770
760 } // namespace cc 771 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/begin_frame_args.cc ('k') | cc/scheduler/scheduler_state_machine.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698