OLD | NEW |
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/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
8 #include "base/debug/trace_event_argument.h" | 8 #include "base/debug/trace_event_argument.h" |
9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 if (last_frame_number_animate_performed_ == current_frame_number_) | 411 if (last_frame_number_animate_performed_ == current_frame_number_) |
412 return false; | 412 return false; |
413 | 413 |
414 if (begin_impl_frame_state_ != BEGIN_IMPL_FRAME_STATE_BEGIN_FRAME_STARTING && | 414 if (begin_impl_frame_state_ != BEGIN_IMPL_FRAME_STATE_BEGIN_FRAME_STARTING && |
415 begin_impl_frame_state_ != BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE) | 415 begin_impl_frame_state_ != BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE) |
416 return false; | 416 return false; |
417 | 417 |
418 return needs_redraw_ || needs_animate_; | 418 return needs_redraw_ || needs_animate_; |
419 } | 419 } |
420 | 420 |
| 421 bool SchedulerStateMachine::CouldSendBeginMainFrame() const { |
| 422 if (!needs_commit_) |
| 423 return false; |
| 424 |
| 425 // We can not perform commits if we are not visible. |
| 426 if (!visible_) |
| 427 return false; |
| 428 |
| 429 return true; |
| 430 } |
| 431 |
421 bool SchedulerStateMachine::ShouldSendBeginMainFrame() const { | 432 bool SchedulerStateMachine::ShouldSendBeginMainFrame() const { |
422 if (!needs_commit_) | 433 if (!CouldSendBeginMainFrame()) |
423 return false; | 434 return false; |
424 | 435 |
425 // Only send BeginMainFrame when there isn't another commit pending already. | 436 // Only send BeginMainFrame when there isn't another commit pending already. |
426 if (commit_state_ != COMMIT_STATE_IDLE) | 437 if (commit_state_ != COMMIT_STATE_IDLE) |
427 return false; | 438 return false; |
428 | 439 |
429 // Don't send BeginMainFrame early if we are prioritizing the active tree | 440 // Don't send BeginMainFrame early if we are prioritizing the active tree |
430 // because of smoothness_takes_priority. | 441 // because of smoothness_takes_priority. |
431 if (smoothness_takes_priority_ && | 442 if (smoothness_takes_priority_ && |
432 (has_pending_tree_ || active_tree_needs_first_draw_)) { | 443 (has_pending_tree_ || active_tree_needs_first_draw_)) { |
433 return false; | 444 return false; |
434 } | 445 } |
435 | 446 |
436 // We do not need commits if we are not visible. | |
437 if (!visible_) | |
438 return false; | |
439 | |
440 // We want to start the first commit after we get a new output surface ASAP. | 447 // We want to start the first commit after we get a new output surface ASAP. |
441 if (output_surface_state_ == OUTPUT_SURFACE_WAITING_FOR_FIRST_COMMIT) | 448 if (output_surface_state_ == OUTPUT_SURFACE_WAITING_FOR_FIRST_COMMIT) |
442 return true; | 449 return true; |
443 | 450 |
444 // We should not send BeginMainFrame while we are in | 451 // We should not send BeginMainFrame while we are in |
445 // BEGIN_IMPL_FRAME_STATE_IDLE since we might have new | 452 // BEGIN_IMPL_FRAME_STATE_IDLE since we might have new |
446 // user input arriving soon. | 453 // user input arriving soon. |
447 // TODO(brianderson): Allow sending BeginMainFrame while idle when the main | 454 // TODO(brianderson): Allow sending BeginMainFrame while idle when the main |
448 // thread isn't consuming user input. | 455 // thread isn't consuming user input. |
449 if (begin_impl_frame_state_ == BEGIN_IMPL_FRAME_STATE_IDLE && | 456 if (begin_impl_frame_state_ == BEGIN_IMPL_FRAME_STATE_IDLE && |
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1071 case OUTPUT_SURFACE_ACTIVE: | 1078 case OUTPUT_SURFACE_ACTIVE: |
1072 case OUTPUT_SURFACE_WAITING_FOR_FIRST_COMMIT: | 1079 case OUTPUT_SURFACE_WAITING_FOR_FIRST_COMMIT: |
1073 case OUTPUT_SURFACE_WAITING_FOR_FIRST_ACTIVATION: | 1080 case OUTPUT_SURFACE_WAITING_FOR_FIRST_ACTIVATION: |
1074 return true; | 1081 return true; |
1075 } | 1082 } |
1076 NOTREACHED(); | 1083 NOTREACHED(); |
1077 return false; | 1084 return false; |
1078 } | 1085 } |
1079 | 1086 |
1080 } // namespace cc | 1087 } // namespace cc |
OLD | NEW |