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

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

Issue 423773002: Unified BeginFrame scheduling (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Working on aura with --enable-begin-frame-scheduling Created 6 years, 4 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 | Annotate | Revision Log
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 #include "base/auto_reset.h" 8 #include "base/auto_reset.h"
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "base/debug/trace_event_argument.h" 10 #include "base/debug/trace_event_argument.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 client_(client), 84 client_(client),
85 layer_tree_host_id_(layer_tree_host_id), 85 layer_tree_host_id_(layer_tree_host_id),
86 task_runner_(task_runner), 86 task_runner_(task_runner),
87 vsync_interval_(BeginFrameArgs::DefaultInterval()), 87 vsync_interval_(BeginFrameArgs::DefaultInterval()),
88 last_set_needs_begin_frame_(false), 88 last_set_needs_begin_frame_(false),
89 begin_unthrottled_frame_posted_(false), 89 begin_unthrottled_frame_posted_(false),
90 begin_retro_frame_posted_(false), 90 begin_retro_frame_posted_(false),
91 state_machine_(scheduler_settings), 91 state_machine_(scheduler_settings),
92 inside_process_scheduled_actions_(false), 92 inside_process_scheduled_actions_(false),
93 inside_action_(SchedulerStateMachine::ACTION_NONE), 93 inside_action_(SchedulerStateMachine::ACTION_NONE),
94 begin_frame_requested_(false),
94 weak_factory_(this) { 95 weak_factory_(this) {
95 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler"), 96 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler"),
96 "Scheduler::Scheduler", 97 "Scheduler::Scheduler",
97 "settings", 98 "settings",
98 settings_.AsValue()); 99 settings_.AsValue());
99 DCHECK(client_); 100 DCHECK(client_);
100 DCHECK(!state_machine_.BeginFrameNeeded()); 101 DCHECK(!state_machine_.BeginFrameNeeded());
101 if (settings_.main_frame_before_activation_enabled) { 102 if (settings_.main_frame_before_activation_enabled) {
102 DCHECK(settings_.main_frame_before_draw_enabled); 103 DCHECK(settings_.main_frame_before_draw_enabled);
103 } 104 }
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 void Scheduler::SetupNextBeginFrameWhenVSyncThrottlingEnabled( 293 void Scheduler::SetupNextBeginFrameWhenVSyncThrottlingEnabled(
293 bool needs_begin_frame) { 294 bool needs_begin_frame) {
294 bool at_end_of_deadline = 295 bool at_end_of_deadline =
295 state_machine_.begin_impl_frame_state() == 296 state_machine_.begin_impl_frame_state() ==
296 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE; 297 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE;
297 298
298 bool should_call_set_needs_begin_frame = 299 bool should_call_set_needs_begin_frame =
299 // Always request the BeginFrame immediately if it wasn't needed before. 300 // Always request the BeginFrame immediately if it wasn't needed before.
300 (needs_begin_frame && !last_set_needs_begin_frame_) || 301 (needs_begin_frame && !last_set_needs_begin_frame_) ||
301 // Only stop requesting BeginFrames after a deadline. 302 // Only stop requesting BeginFrames after a deadline.
302 (!needs_begin_frame && last_set_needs_begin_frame_ && at_end_of_deadline); 303 (!needs_begin_frame &&
304 last_set_needs_begin_frame_ &&
305 at_end_of_deadline &&
306 !begin_frame_requested_);
brianderson 2014/08/21 00:13:59 Instead of taking begin_frame_requested_ into acco
simonhong 2014/08/26 08:24:47 Yeap, handling this state by SchdulerStateMachine
303 307
304 if (should_call_set_needs_begin_frame) { 308 if (should_call_set_needs_begin_frame) {
305 if (settings_.begin_frame_scheduling_enabled) { 309 if (settings_.begin_frame_scheduling_enabled) {
306 client_->SetNeedsBeginFrame(needs_begin_frame); 310 client_->SetNeedsBeginFrame(needs_begin_frame);
307 } else { 311 } else {
308 synthetic_begin_frame_source_->SetNeedsBeginFrame( 312 synthetic_begin_frame_source_->SetNeedsBeginFrame(
309 needs_begin_frame, &begin_retro_frame_args_); 313 needs_begin_frame, &begin_retro_frame_args_);
310 } 314 }
311 last_set_needs_begin_frame_ = needs_begin_frame; 315 last_set_needs_begin_frame_ = needs_begin_frame;
312 } 316 }
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 405
402 // BeginFrame is the mechanism that tells us that now is a good time to start 406 // BeginFrame is the mechanism that tells us that now is a good time to start
403 // making a frame. Usually this means that user input for the frame is complete. 407 // making a frame. Usually this means that user input for the frame is complete.
404 // If the scheduler is busy, we queue the BeginFrame to be handled later as 408 // If the scheduler is busy, we queue the BeginFrame to be handled later as
405 // a BeginRetroFrame. 409 // a BeginRetroFrame.
406 void Scheduler::BeginFrame(const BeginFrameArgs& args) { 410 void Scheduler::BeginFrame(const BeginFrameArgs& args) {
407 TRACE_EVENT1("cc", "Scheduler::BeginFrame", "args", args.AsValue()); 411 TRACE_EVENT1("cc", "Scheduler::BeginFrame", "args", args.AsValue());
408 DCHECK(settings_.throttle_frame_production); 412 DCHECK(settings_.throttle_frame_production);
409 413
410 BeginFrameArgs adjusted_args(args); 414 BeginFrameArgs adjusted_args(args);
415
416 if (settings_.begin_frame_publisher && begin_frame_requested_) {
417 // |arg.deadline| should be adjusted by subscribed Scheduler.
418 client_->SendBeginFrame(args);
419 begin_frame_requested_ = false;
brianderson 2014/08/21 00:13:59 The child Schedulers should be setting begin_frame
simonhong 2014/08/26 08:24:47 Yeap, calling SetChildrenNeedBeginFrames() from Be
420 }
421
411 adjusted_args.deadline -= EstimatedParentDrawTime(); 422 adjusted_args.deadline -= EstimatedParentDrawTime();
412 423
413 bool should_defer_begin_frame; 424 bool should_defer_begin_frame;
414 if (settings_.using_synchronous_renderer_compositor) { 425 if (settings_.using_synchronous_renderer_compositor) {
415 should_defer_begin_frame = false; 426 should_defer_begin_frame = false;
416 } else { 427 } else {
417 should_defer_begin_frame = 428 should_defer_begin_frame =
418 !begin_retro_frame_args_.empty() || begin_retro_frame_posted_ || 429 !begin_retro_frame_args_.empty() || begin_retro_frame_posted_ ||
419 !last_set_needs_begin_frame_ || 430 !last_set_needs_begin_frame_ ||
420 (state_machine_.begin_impl_frame_state() != 431 (state_machine_.begin_impl_frame_state() !=
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 TRACE_EVENT0("cc", "Scheduler::PollToAdvanceCommitState"); 616 TRACE_EVENT0("cc", "Scheduler::PollToAdvanceCommitState");
606 advance_commit_state_task_.Cancel(); 617 advance_commit_state_task_.Cancel();
607 ProcessScheduledActions(); 618 ProcessScheduledActions();
608 } 619 }
609 620
610 bool Scheduler::IsBeginMainFrameSent() const { 621 bool Scheduler::IsBeginMainFrameSent() const {
611 return state_machine_.commit_state() == 622 return state_machine_.commit_state() ==
612 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT; 623 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT;
613 } 624 }
614 625
626 void Scheduler::BeginFrameRequested() {
627 DCHECK(settings_.begin_frame_publisher);
628 DCHECK(!begin_frame_requested_);
629
630 begin_frame_requested_ = true;
631
632 // If frame source is already activated, next BeginFrame will be scheduled.
633 if (synthetic_begin_frame_source_->IsActive())
634 return;
635
636 synthetic_begin_frame_source_->SetNeedsBeginFrame(true,
brianderson 2014/08/21 00:13:59 Instead of calling SetNeedsBeginFrame direcly here
simonhong 2014/08/26 08:24:47 Done.
637 &begin_retro_frame_args_);
638 }
639
615 void Scheduler::DrawAndSwapIfPossible() { 640 void Scheduler::DrawAndSwapIfPossible() {
616 DrawResult result = client_->ScheduledActionDrawAndSwapIfPossible(); 641 DrawResult result = client_->ScheduledActionDrawAndSwapIfPossible();
617 state_machine_.DidDrawIfPossibleCompleted(result); 642 state_machine_.DidDrawIfPossibleCompleted(result);
618 } 643 }
619 644
620 void Scheduler::ProcessScheduledActions() { 645 void Scheduler::ProcessScheduledActions() {
621 // We do not allow ProcessScheduledActions to be recursive. 646 // We do not allow ProcessScheduledActions to be recursive.
622 // The top-level call will iteratively execute the next action for us anyway. 647 // The top-level call will iteratively execute the next action for us anyway.
623 if (inside_process_scheduled_actions_) 648 if (inside_process_scheduled_actions_)
624 return; 649 return;
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
755 } 780 }
756 781
757 bool Scheduler::IsBeginMainFrameSentOrStarted() const { 782 bool Scheduler::IsBeginMainFrameSentOrStarted() const {
758 return (state_machine_.commit_state() == 783 return (state_machine_.commit_state() ==
759 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT || 784 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT ||
760 state_machine_.commit_state() == 785 state_machine_.commit_state() ==
761 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED); 786 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED);
762 } 787 }
763 788
764 } // namespace cc 789 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698