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

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

Issue 2409923002: cc: Rename SwapBuffers on CompositorFrameSink to SubmitCompositorFrame (Closed)
Patch Set: swap-to-submit: rebase Created 4 years, 2 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 | « cc/scheduler/scheduler.h ('k') | cc/scheduler/scheduler_settings.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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 state_machine_.SetNeedsRedraw(); 122 state_machine_.SetNeedsRedraw();
123 ProcessScheduledActions(); 123 ProcessScheduledActions();
124 } 124 }
125 125
126 void Scheduler::SetNeedsPrepareTiles() { 126 void Scheduler::SetNeedsPrepareTiles() {
127 DCHECK(!IsInsideAction(SchedulerStateMachine::ACTION_PREPARE_TILES)); 127 DCHECK(!IsInsideAction(SchedulerStateMachine::ACTION_PREPARE_TILES));
128 state_machine_.SetNeedsPrepareTiles(); 128 state_machine_.SetNeedsPrepareTiles();
129 ProcessScheduledActions(); 129 ProcessScheduledActions();
130 } 130 }
131 131
132 void Scheduler::DidSwapBuffers() { 132 void Scheduler::DidSubmitCompositorFrame() {
133 compositor_timing_history_->DidSwapBuffers(); 133 compositor_timing_history_->DidSubmitCompositorFrame();
134 state_machine_.DidSwapBuffers(); 134 state_machine_.DidSubmitCompositorFrame();
135 135
136 // There is no need to call ProcessScheduledActions here because 136 // There is no need to call ProcessScheduledActions here because
137 // swapping should not trigger any new actions. 137 // submitting a CompositorFrame should not trigger any new actions.
138 if (!inside_process_scheduled_actions_) { 138 if (!inside_process_scheduled_actions_) {
139 DCHECK_EQ(state_machine_.NextAction(), SchedulerStateMachine::ACTION_NONE); 139 DCHECK_EQ(state_machine_.NextAction(), SchedulerStateMachine::ACTION_NONE);
140 } 140 }
141 } 141 }
142 142
143 void Scheduler::DidSwapBuffersComplete() { 143 void Scheduler::DidReceiveCompositorFrameAck() {
144 DCHECK_GT(state_machine_.pending_swaps(), 0) << AsValue()->ToString(); 144 DCHECK_GT(state_machine_.pending_submit_frames(), 0) << AsValue()->ToString();
145 compositor_timing_history_->DidSwapBuffersComplete(); 145 compositor_timing_history_->DidReceiveCompositorFrameAck();
146 state_machine_.DidSwapBuffersComplete(); 146 state_machine_.DidReceiveCompositorFrameAck();
147 ProcessScheduledActions(); 147 ProcessScheduledActions();
148 } 148 }
149 149
150 void Scheduler::SetTreePrioritiesAndScrollState( 150 void Scheduler::SetTreePrioritiesAndScrollState(
151 TreePriority tree_priority, 151 TreePriority tree_priority,
152 ScrollHandlerState scroll_handler_state) { 152 ScrollHandlerState scroll_handler_state) {
153 state_machine_.SetTreePrioritiesAndScrollState(tree_priority, 153 state_machine_.SetTreePrioritiesAndScrollState(tree_priority,
154 scroll_handler_state); 154 scroll_handler_state);
155 ProcessScheduledActions(); 155 ProcessScheduledActions();
156 } 156 }
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 // order to wait for more user-input before starting the next commit. 518 // order to wait for more user-input before starting the next commit.
519 // * Creating a new OuputSurface will not occur during the deadline in 519 // * Creating a new OuputSurface will not occur during the deadline in
520 // order to allow the state machine to "settle" first. 520 // order to allow the state machine to "settle" first.
521 compositor_timing_history_->WillFinishImplFrame( 521 compositor_timing_history_->WillFinishImplFrame(
522 state_machine_.needs_redraw()); 522 state_machine_.needs_redraw());
523 state_machine_.OnBeginImplFrameDeadline(); 523 state_machine_.OnBeginImplFrameDeadline();
524 ProcessScheduledActions(); 524 ProcessScheduledActions();
525 FinishImplFrame(); 525 FinishImplFrame();
526 } 526 }
527 527
528 void Scheduler::DrawAndSwapIfPossible() { 528 void Scheduler::DrawIfPossible() {
529 bool drawing_with_new_active_tree = 529 bool drawing_with_new_active_tree =
530 state_machine_.active_tree_needs_first_draw(); 530 state_machine_.active_tree_needs_first_draw();
531 bool main_thread_missed_last_deadline = 531 bool main_thread_missed_last_deadline =
532 state_machine_.main_thread_missed_last_deadline(); 532 state_machine_.main_thread_missed_last_deadline();
533 compositor_timing_history_->WillDraw(); 533 compositor_timing_history_->WillDraw();
534 state_machine_.WillDraw(); 534 state_machine_.WillDraw();
535 DrawResult result = client_->ScheduledActionDrawAndSwapIfPossible(); 535 DrawResult result = client_->ScheduledActionDrawIfPossible();
536 state_machine_.DidDraw(result); 536 state_machine_.DidDraw(result);
537 compositor_timing_history_->DidDraw( 537 compositor_timing_history_->DidDraw(
538 drawing_with_new_active_tree, main_thread_missed_last_deadline, 538 drawing_with_new_active_tree, main_thread_missed_last_deadline,
539 begin_impl_frame_tracker_.DangerousMethodCurrentOrLast().frame_time); 539 begin_impl_frame_tracker_.DangerousMethodCurrentOrLast().frame_time);
540 } 540 }
541 541
542 void Scheduler::DrawAndSwapForced() { 542 void Scheduler::DrawForced() {
543 bool drawing_with_new_active_tree = 543 bool drawing_with_new_active_tree =
544 state_machine_.active_tree_needs_first_draw(); 544 state_machine_.active_tree_needs_first_draw();
545 bool main_thread_missed_last_deadline = 545 bool main_thread_missed_last_deadline =
546 state_machine_.main_thread_missed_last_deadline(); 546 state_machine_.main_thread_missed_last_deadline();
547 compositor_timing_history_->WillDraw(); 547 compositor_timing_history_->WillDraw();
548 state_machine_.WillDraw(); 548 state_machine_.WillDraw();
549 DrawResult result = client_->ScheduledActionDrawAndSwapForced(); 549 DrawResult result = client_->ScheduledActionDrawForced();
550 state_machine_.DidDraw(result); 550 state_machine_.DidDraw(result);
551 compositor_timing_history_->DidDraw( 551 compositor_timing_history_->DidDraw(
552 drawing_with_new_active_tree, main_thread_missed_last_deadline, 552 drawing_with_new_active_tree, main_thread_missed_last_deadline,
553 begin_impl_frame_tracker_.DangerousMethodCurrentOrLast().frame_time); 553 begin_impl_frame_tracker_.DangerousMethodCurrentOrLast().frame_time);
554 } 554 }
555 555
556 void Scheduler::SetDeferCommits(bool defer_commits) { 556 void Scheduler::SetDeferCommits(bool defer_commits) {
557 TRACE_EVENT1("cc", "Scheduler::SetDeferCommits", "defer_commits", 557 TRACE_EVENT1("cc", "Scheduler::SetDeferCommits", "defer_commits",
558 defer_commits); 558 defer_commits);
559 state_machine_.SetDeferCommits(defer_commits); 559 state_machine_.SetDeferCommits(defer_commits);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 state_machine_.WillCommit(commit_has_no_updates); 595 state_machine_.WillCommit(commit_has_no_updates);
596 client_->ScheduledActionCommit(); 596 client_->ScheduledActionCommit();
597 break; 597 break;
598 } 598 }
599 case SchedulerStateMachine::ACTION_ACTIVATE_SYNC_TREE: 599 case SchedulerStateMachine::ACTION_ACTIVATE_SYNC_TREE:
600 compositor_timing_history_->WillActivate(); 600 compositor_timing_history_->WillActivate();
601 state_machine_.WillActivate(); 601 state_machine_.WillActivate();
602 client_->ScheduledActionActivateSyncTree(); 602 client_->ScheduledActionActivateSyncTree();
603 compositor_timing_history_->DidActivate(); 603 compositor_timing_history_->DidActivate();
604 break; 604 break;
605 case SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE: 605 case SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE:
606 DrawAndSwapIfPossible(); 606 DrawIfPossible();
607 break; 607 break;
608 case SchedulerStateMachine::ACTION_DRAW_AND_SWAP_FORCED: 608 case SchedulerStateMachine::ACTION_DRAW_FORCED:
609 DrawAndSwapForced(); 609 DrawForced();
610 break; 610 break;
611 case SchedulerStateMachine::ACTION_DRAW_AND_SWAP_ABORT: { 611 case SchedulerStateMachine::ACTION_DRAW_ABORT: {
612 // No action is actually performed, but this allows the state machine to 612 // No action is actually performed, but this allows the state machine to
613 // drain the pipeline without actually drawing. 613 // drain the pipeline without actually drawing.
614 state_machine_.AbortDrawAndSwap(); 614 state_machine_.AbortDraw();
615 compositor_timing_history_->DrawAborted(); 615 compositor_timing_history_->DrawAborted();
616 break; 616 break;
617 } 617 }
618 case SchedulerStateMachine::ACTION_BEGIN_COMPOSITOR_FRAME_SINK_CREATION: 618 case SchedulerStateMachine::ACTION_BEGIN_COMPOSITOR_FRAME_SINK_CREATION:
619 state_machine_.WillBeginCompositorFrameSinkCreation(); 619 state_machine_.WillBeginCompositorFrameSinkCreation();
620 client_->ScheduledActionBeginCompositorFrameSinkCreation(); 620 client_->ScheduledActionBeginCompositorFrameSinkCreation();
621 break; 621 break;
622 case SchedulerStateMachine::ACTION_PREPARE_TILES: 622 case SchedulerStateMachine::ACTION_PREPARE_TILES:
623 state_machine_.WillPrepareTiles(); 623 state_machine_.WillPrepareTiles();
624 client_->ScheduledActionPrepareTiles(); 624 client_->ScheduledActionPrepareTiles();
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 return false; 706 return false;
707 707
708 // Disable impl thread latency recovery when using the unthrottled 708 // Disable impl thread latency recovery when using the unthrottled
709 // begin frame source since we will always get a BeginFrame before 709 // begin frame source since we will always get a BeginFrame before
710 // the swap ack and our heuristics below will not work. 710 // the swap ack and our heuristics below will not work.
711 if (begin_frame_source_ && !begin_frame_source_->IsThrottled()) 711 if (begin_frame_source_ && !begin_frame_source_->IsThrottled())
712 return false; 712 return false;
713 713
714 // If we are swap throttled at the BeginFrame, that means the impl thread is 714 // If we are swap throttled at the BeginFrame, that means the impl thread is
715 // very likely in a high latency mode. 715 // very likely in a high latency mode.
716 bool impl_thread_is_likely_high_latency = state_machine_.SwapThrottled(); 716 bool impl_thread_is_likely_high_latency = state_machine_.IsDrawThrottled();
717 if (!impl_thread_is_likely_high_latency) 717 if (!impl_thread_is_likely_high_latency)
718 return false; 718 return false;
719 719
720 // The deadline may be in the past if our draw time is too long. 720 // The deadline may be in the past if our draw time is too long.
721 bool can_draw_before_deadline = args.frame_time < args.deadline; 721 bool can_draw_before_deadline = args.frame_time < args.deadline;
722 722
723 // When prioritizing impl thread latency, the deadline doesn't wait 723 // When prioritizing impl thread latency, the deadline doesn't wait
724 // for the main thread. 724 // for the main thread.
725 if (state_machine_.ImplLatencyTakesPriority()) 725 if (state_machine_.ImplLatencyTakesPriority())
726 return can_draw_before_deadline; 726 return can_draw_before_deadline;
(...skipping 22 matching lines...) Expand all
749 } 749 }
750 750
751 bool Scheduler::IsBeginMainFrameSentOrStarted() const { 751 bool Scheduler::IsBeginMainFrameSentOrStarted() const {
752 return (state_machine_.begin_main_frame_state() == 752 return (state_machine_.begin_main_frame_state() ==
753 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_SENT || 753 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_SENT ||
754 state_machine_.begin_main_frame_state() == 754 state_machine_.begin_main_frame_state() ==
755 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_STARTED); 755 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_STARTED);
756 } 756 }
757 757
758 } // namespace cc 758 } // namespace cc
OLDNEW
« no previous file with comments | « cc/scheduler/scheduler.h ('k') | cc/scheduler/scheduler_settings.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698