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

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: 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 | 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 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"
11 #include "base/trace_event/trace_event_argument.h" 11 #include "base/trace_event/trace_event_argument.h"
12 #include "base/values.h" 12 #include "base/values.h"
13 13
14 namespace cc { 14 namespace cc {
15 15
16 SchedulerStateMachine::SchedulerStateMachine(const SchedulerSettings& settings) 16 SchedulerStateMachine::SchedulerStateMachine(const SchedulerSettings& settings)
17 : settings_(settings), 17 : settings_(settings),
18 output_surface_state_(OUTPUT_SURFACE_LOST), 18 output_surface_state_(OUTPUT_SURFACE_LOST),
19 begin_impl_frame_state_(BEGIN_IMPL_FRAME_STATE_IDLE), 19 begin_impl_frame_state_(BEGIN_IMPL_FRAME_STATE_IDLE),
20 commit_state_(COMMIT_STATE_IDLE), 20 commit_state_(COMMIT_STATE_IDLE),
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_(true),
30 request_swap_funnel_(false), 30 request_swap_funnel_(true),
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_(true),
33 prepare_tiles_funnel_(0), 33 prepare_tiles_funnel_(1),
mithro-old 2015/07/08 03:26:33 Why do these values change?
sunnyps 2015/07/13 23:56:11 Only the value for send_begin_main_frame_funnel_ n
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),
42 visible_(false), 42 visible_(false),
43 can_start_(false), 43 can_start_(false),
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 // This returns true if there's too much backpressure to finish a commit 414 // This returns true if there's too much backpressure to finish a commit
415 // if we were to initiate a BeginMainFrame. 415 // if we were to initiate a BeginMainFrame.
416 return has_pending_tree_ && active_tree_needs_first_draw_ && 416 return has_pending_tree_ && active_tree_needs_first_draw_ &&
417 pending_swaps_ >= max_pending_swaps_; 417 pending_swaps_ >= max_pending_swaps_;
418 } 418 }
419 419
420 bool SchedulerStateMachine::ShouldSendBeginMainFrame() const { 420 bool SchedulerStateMachine::ShouldSendBeginMainFrame() const {
421 if (!CouldSendBeginMainFrame()) 421 if (!CouldSendBeginMainFrame())
422 return false; 422 return false;
423 423
424 // Do not send begin main frame too many times in a single frame. 424 // Do not send begin main frame too many times in a single frame or before
425 // the first BeginFrame.
425 if (send_begin_main_frame_funnel_) 426 if (send_begin_main_frame_funnel_)
426 return false; 427 return false;
427 428
428 // Only send BeginMainFrame when there isn't another commit pending already. 429 // Only send BeginMainFrame when there isn't another commit pending already.
429 // Other parts of the state machine indirectly defer the BeginMainFrame 430 // Other parts of the state machine indirectly defer the BeginMainFrame
430 // by transitioning to WAITING commit states rather than going 431 // by transitioning to WAITING commit states rather than going
431 // immediately to IDLE. 432 // immediately to IDLE.
432 if (commit_state_ != COMMIT_STATE_IDLE) 433 if (commit_state_ != COMMIT_STATE_IDLE)
433 return false; 434 return false;
434 435
435 // Don't send BeginMainFrame early if we are prioritizing the active tree 436 // Don't send BeginMainFrame early if we are prioritizing the active tree
436 // because of impl_latency_takes_priority_. 437 // because of impl_latency_takes_priority_.
437 if (impl_latency_takes_priority_ && 438 if (impl_latency_takes_priority_ &&
438 (has_pending_tree_ || active_tree_needs_first_draw_)) { 439 (has_pending_tree_ || active_tree_needs_first_draw_)) {
439 return false; 440 return false;
440 } 441 }
441 442
442 // We should not send BeginMainFrame while we are in 443 // We should not send BeginMainFrame while we are in the idle state since we
443 // BEGIN_IMPL_FRAME_STATE_IDLE since we might have new 444 // might have new user input arriving soon. It's okay to send BeginMainFrame
444 // user input arriving soon. 445 // for the synchronous compositor because the main thread is always high
446 // latency in that case.
445 // TODO(brianderson): Allow sending BeginMainFrame while idle when the main 447 // TODO(brianderson): Allow sending BeginMainFrame while idle when the main
446 // thread isn't consuming user input. 448 // thread isn't consuming user input for non-synchronous compositor.
447 if (begin_impl_frame_state_ == BEGIN_IMPL_FRAME_STATE_IDLE && 449 if (!settings_.using_synchronous_renderer_compositor &&
448 BeginFrameNeeded()) 450 begin_impl_frame_state_ == BEGIN_IMPL_FRAME_STATE_IDLE) {
449 return false; 451 return false;
452 }
450 453
451 // We need a new commit for the forced redraw. This honors the 454 // We need a new commit for the forced redraw. This honors the
452 // single commit per interval because the result will be swapped to screen. 455 // single commit per interval because the result will be swapped to screen.
453 // TODO(brianderson): Remove this or move it below the 456 // TODO(brianderson): Remove this or move it below the
454 // SendingBeginMainFrameMightCauseDeadlock check since we want to avoid 457 // SendingBeginMainFrameMightCauseDeadlock check since we want to avoid
455 // ever returning true from this method if we might cause deadlock. 458 // ever returning true from this method if we might cause deadlock.
456 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_COMMIT) 459 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_COMMIT)
457 return true; 460 return true;
458 461
459 // We shouldn't normally accept commits if there isn't an OutputSurface. 462 // We shouldn't normally accept commits if there isn't an OutputSurface.
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after
1157 case OUTPUT_SURFACE_ACTIVE: 1160 case OUTPUT_SURFACE_ACTIVE:
1158 case OUTPUT_SURFACE_WAITING_FOR_FIRST_COMMIT: 1161 case OUTPUT_SURFACE_WAITING_FOR_FIRST_COMMIT:
1159 case OUTPUT_SURFACE_WAITING_FOR_FIRST_ACTIVATION: 1162 case OUTPUT_SURFACE_WAITING_FOR_FIRST_ACTIVATION:
1160 return true; 1163 return true;
1161 } 1164 }
1162 NOTREACHED(); 1165 NOTREACHED();
1163 return false; 1166 return false;
1164 } 1167 }
1165 1168
1166 } // namespace cc 1169 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698