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

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

Issue 1218663007: cc: Allow SendBeginMainFrame in idle state for synchronous compositor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 5 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 | « no previous file | cc/scheduler/scheduler_state_machine_unittest.cc » ('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_state_machine.h" 5 #include "cc/scheduler/scheduler_state_machine.h"
6 6
7 #include "base/format_macros.h" 7 #include "base/format_macros.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "base/trace_event/trace_event.h" 10 #include "base/trace_event/trace_event.h"
(...skipping 10 matching lines...) Expand all
21 forced_redraw_state_(FORCED_REDRAW_STATE_IDLE), 21 forced_redraw_state_(FORCED_REDRAW_STATE_IDLE),
22 commit_count_(0), 22 commit_count_(0),
23 current_frame_number_(0), 23 current_frame_number_(0),
24 last_frame_number_animate_performed_(-1), 24 last_frame_number_animate_performed_(-1),
25 last_frame_number_swap_performed_(-1), 25 last_frame_number_swap_performed_(-1),
26 last_frame_number_swap_requested_(-1), 26 last_frame_number_swap_requested_(-1),
27 last_frame_number_begin_main_frame_sent_(-1), 27 last_frame_number_begin_main_frame_sent_(-1),
28 last_frame_number_invalidate_output_surface_performed_(-1), 28 last_frame_number_invalidate_output_surface_performed_(-1),
29 animate_funnel_(false), 29 animate_funnel_(false),
30 request_swap_funnel_(false), 30 request_swap_funnel_(false),
31 send_begin_main_frame_funnel_(false), 31 send_begin_main_frame_funnel_(true),
32 invalidate_output_surface_funnel_(false), 32 invalidate_output_surface_funnel_(false),
33 prepare_tiles_funnel_(0), 33 prepare_tiles_funnel_(0),
34 consecutive_checkerboard_animations_(0), 34 consecutive_checkerboard_animations_(0),
35 max_pending_swaps_(1), 35 max_pending_swaps_(1),
36 pending_swaps_(0), 36 pending_swaps_(0),
37 swaps_with_current_output_surface_(0), 37 swaps_with_current_output_surface_(0),
38 needs_redraw_(false), 38 needs_redraw_(false),
39 needs_animate_(false), 39 needs_animate_(false),
40 needs_prepare_tiles_(false), 40 needs_prepare_tiles_(false),
41 needs_commit_(false), 41 needs_commit_(false),
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 // and we have deadlock. 410 // and we have deadlock.
411 // This returns true if there's too much backpressure to finish a commit 411 // This returns true if there's too much backpressure to finish a commit
412 // if we were to initiate a BeginMainFrame. 412 // if we were to initiate a BeginMainFrame.
413 return has_pending_tree_ && active_tree_needs_first_draw_ && SwapThrottled(); 413 return has_pending_tree_ && active_tree_needs_first_draw_ && SwapThrottled();
414 } 414 }
415 415
416 bool SchedulerStateMachine::ShouldSendBeginMainFrame() const { 416 bool SchedulerStateMachine::ShouldSendBeginMainFrame() const {
417 if (!CouldSendBeginMainFrame()) 417 if (!CouldSendBeginMainFrame())
418 return false; 418 return false;
419 419
420 // Do not send begin main frame too many times in a single frame. 420 // Do not send begin main frame too many times in a single frame or before
421 // the first BeginFrame.
421 if (send_begin_main_frame_funnel_) 422 if (send_begin_main_frame_funnel_)
422 return false; 423 return false;
423 424
424 // Only send BeginMainFrame when there isn't another commit pending already. 425 // Only send BeginMainFrame when there isn't another commit pending already.
425 // Other parts of the state machine indirectly defer the BeginMainFrame 426 // Other parts of the state machine indirectly defer the BeginMainFrame
426 // by transitioning to WAITING commit states rather than going 427 // by transitioning to WAITING commit states rather than going
427 // immediately to IDLE. 428 // immediately to IDLE.
428 if (commit_state_ != COMMIT_STATE_IDLE) 429 if (commit_state_ != COMMIT_STATE_IDLE)
429 return false; 430 return false;
430 431
431 // Don't send BeginMainFrame early if we are prioritizing the active tree 432 // Don't send BeginMainFrame early if we are prioritizing the active tree
432 // because of impl_latency_takes_priority_. 433 // because of impl_latency_takes_priority_.
433 if (impl_latency_takes_priority_ && 434 if (impl_latency_takes_priority_ &&
434 (has_pending_tree_ || active_tree_needs_first_draw_)) { 435 (has_pending_tree_ || active_tree_needs_first_draw_)) {
435 return false; 436 return false;
436 } 437 }
437 438
438 // We should not send BeginMainFrame while we are in 439 // We should not send BeginMainFrame while we are in the idle state since we
439 // BEGIN_IMPL_FRAME_STATE_IDLE since we might have new 440 // might have new user input arriving soon. It's okay to send BeginMainFrame
440 // user input arriving soon. 441 // for the synchronous compositor because the main thread is always high
442 // latency in that case.
441 // TODO(brianderson): Allow sending BeginMainFrame while idle when the main 443 // TODO(brianderson): Allow sending BeginMainFrame while idle when the main
442 // thread isn't consuming user input. 444 // thread isn't consuming user input for non-synchronous compositor.
443 if (begin_impl_frame_state_ == BEGIN_IMPL_FRAME_STATE_IDLE && 445 if (!settings_.using_synchronous_renderer_compositor &&
444 BeginFrameNeeded()) 446 begin_impl_frame_state_ == BEGIN_IMPL_FRAME_STATE_IDLE) {
445 return false; 447 return false;
448 }
446 449
447 // We need a new commit for the forced redraw. This honors the 450 // We need a new commit for the forced redraw. This honors the
448 // single commit per interval because the result will be swapped to screen. 451 // single commit per interval because the result will be swapped to screen.
449 // TODO(brianderson): Remove this or move it below the 452 // TODO(brianderson): Remove this or move it below the
450 // SendingBeginMainFrameMightCauseDeadlock check since we want to avoid 453 // SendingBeginMainFrameMightCauseDeadlock check since we want to avoid
451 // ever returning true from this method if we might cause deadlock. 454 // ever returning true from this method if we might cause deadlock.
452 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_COMMIT) 455 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_COMMIT)
453 return true; 456 return true;
454 457
455 // We shouldn't normally accept commits if there isn't an OutputSurface. 458 // We shouldn't normally accept commits if there isn't an OutputSurface.
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
872 if (settings_.using_synchronous_renderer_compositor) { 875 if (settings_.using_synchronous_renderer_compositor) {
873 if (prepare_tiles_funnel_ > 0) 876 if (prepare_tiles_funnel_ > 0)
874 prepare_tiles_funnel_--; 877 prepare_tiles_funnel_--;
875 } 878 }
876 } 879 }
877 880
878 void SchedulerStateMachine::OnBeginImplFrameIdle() { 881 void SchedulerStateMachine::OnBeginImplFrameIdle() {
879 begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_IDLE; 882 begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_IDLE;
880 883
881 skip_next_begin_main_frame_to_reduce_latency_ = false; 884 skip_next_begin_main_frame_to_reduce_latency_ = false;
885
886 // If we're entering a state where we won't get BeginFrames set all the
887 // funnels so that we don't perform any actions that we shouldn't.
888 if (!BeginFrameNeeded())
889 send_begin_main_frame_funnel_ = true;
882 } 890 }
883 891
884 SchedulerStateMachine::BeginImplFrameDeadlineMode 892 SchedulerStateMachine::BeginImplFrameDeadlineMode
885 SchedulerStateMachine::CurrentBeginImplFrameDeadlineMode() const { 893 SchedulerStateMachine::CurrentBeginImplFrameDeadlineMode() const {
886 if (settings_.using_synchronous_renderer_compositor) { 894 if (settings_.using_synchronous_renderer_compositor) {
887 // No deadline for synchronous compositor. 895 // No deadline for synchronous compositor.
888 return BEGIN_IMPL_FRAME_DEADLINE_MODE_NONE; 896 return BEGIN_IMPL_FRAME_DEADLINE_MODE_NONE;
889 } else if (wait_for_active_tree_ready_to_draw_) { 897 } else if (wait_for_active_tree_ready_to_draw_) {
890 // When we are waiting for ready to draw signal, we do not wait to post a 898 // When we are waiting for ready to draw signal, we do not wait to post a
891 // deadline yet. 899 // deadline yet.
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
1165 case OUTPUT_SURFACE_ACTIVE: 1173 case OUTPUT_SURFACE_ACTIVE:
1166 case OUTPUT_SURFACE_WAITING_FOR_FIRST_COMMIT: 1174 case OUTPUT_SURFACE_WAITING_FOR_FIRST_COMMIT:
1167 case OUTPUT_SURFACE_WAITING_FOR_FIRST_ACTIVATION: 1175 case OUTPUT_SURFACE_WAITING_FOR_FIRST_ACTIVATION:
1168 return true; 1176 return true;
1169 } 1177 }
1170 NOTREACHED(); 1178 NOTREACHED();
1171 return false; 1179 return false;
1172 } 1180 }
1173 1181
1174 } // namespace cc 1182 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/scheduler/scheduler_state_machine_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698