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

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

Issue 2339633003: Reland of cc: Remove frame queuing from the scheduler. (Closed)
Patch Set: prevent draw if commit is pending Created 4 years, 3 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
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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 BeginMainFrameState state) { 116 BeginMainFrameState state) {
117 switch (state) { 117 switch (state) {
118 case BEGIN_MAIN_FRAME_STATE_IDLE: 118 case BEGIN_MAIN_FRAME_STATE_IDLE:
119 return "BEGIN_MAIN_FRAME_STATE_IDLE"; 119 return "BEGIN_MAIN_FRAME_STATE_IDLE";
120 case BEGIN_MAIN_FRAME_STATE_SENT: 120 case BEGIN_MAIN_FRAME_STATE_SENT:
121 return "BEGIN_MAIN_FRAME_STATE_SENT"; 121 return "BEGIN_MAIN_FRAME_STATE_SENT";
122 case BEGIN_MAIN_FRAME_STATE_STARTED: 122 case BEGIN_MAIN_FRAME_STATE_STARTED:
123 return "BEGIN_MAIN_FRAME_STATE_STARTED"; 123 return "BEGIN_MAIN_FRAME_STATE_STARTED";
124 case BEGIN_MAIN_FRAME_STATE_READY_TO_COMMIT: 124 case BEGIN_MAIN_FRAME_STATE_READY_TO_COMMIT:
125 return "BEGIN_MAIN_FRAME_STATE_READY_TO_COMMIT"; 125 return "BEGIN_MAIN_FRAME_STATE_READY_TO_COMMIT";
126 case BEGIN_MAIN_FRAME_STATE_WAITING_FOR_ACTIVATION:
brianderson 2016/09/26 23:10:28 Nice way to remove these states.
127 return "BEGIN_MAIN_FRAME_STATE_WAITING_FOR_ACTIVATION";
128 case BEGIN_MAIN_FRAME_STATE_WAITING_FOR_DRAW:
129 return "BEGIN_MAIN_FRAME_STATE_WAITING_FOR_DRAW";
130 } 126 }
131 NOTREACHED(); 127 NOTREACHED();
132 return "???"; 128 return "???";
133 } 129 }
134 130
135 const char* SchedulerStateMachine::ForcedRedrawOnTimeoutStateToString( 131 const char* SchedulerStateMachine::ForcedRedrawOnTimeoutStateToString(
136 ForcedRedrawOnTimeoutState state) { 132 ForcedRedrawOnTimeoutState state) {
137 switch (state) { 133 switch (state) {
138 case FORCED_REDRAW_STATE_IDLE: 134 case FORCED_REDRAW_STATE_IDLE:
139 return "FORCED_REDRAW_STATE_IDLE"; 135 return "FORCED_REDRAW_STATE_IDLE";
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 356
361 // Do not queue too many swaps. 357 // Do not queue too many swaps.
362 if (SwapThrottled()) 358 if (SwapThrottled())
363 return false; 359 return false;
364 360
365 // Except for the cases above, do not draw outside of the BeginImplFrame 361 // Except for the cases above, do not draw outside of the BeginImplFrame
366 // deadline. 362 // deadline.
367 if (begin_impl_frame_state_ != BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE) 363 if (begin_impl_frame_state_ != BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE)
368 return false; 364 return false;
369 365
366 // Wait for active tree to be rasterized before drawing in browser compositor.
367 if (wait_for_ready_to_draw_) {
368 DCHECK(settings_.commit_to_active_tree);
369 return false;
370 }
371
372 // Browser compositor commit steals any resources submitted in draw. Therefore
373 // drawing while a commit is pending is wasteful.
374 if (settings_.commit_to_active_tree && CommitPending())
375 return false;
376
370 // Only handle forced redraws due to timeouts on the regular deadline. 377 // Only handle forced redraws due to timeouts on the regular deadline.
371 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW) 378 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW)
372 return true; 379 return true;
373 380
374 return needs_redraw_; 381 return needs_redraw_;
375 } 382 }
376 383
377 bool SchedulerStateMachine::ShouldActivatePendingTree() const { 384 bool SchedulerStateMachine::ShouldActivatePendingTree() const {
378 // There is nothing to activate. 385 // There is nothing to activate.
379 if (!has_pending_tree_) 386 if (!has_pending_tree_)
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 if (send_begin_main_frame_funnel_) 429 if (send_begin_main_frame_funnel_)
423 return false; 430 return false;
424 431
425 // Only send BeginMainFrame when there isn't another commit pending already. 432 // Only send BeginMainFrame when there isn't another commit pending already.
426 // Other parts of the state machine indirectly defer the BeginMainFrame 433 // Other parts of the state machine indirectly defer the BeginMainFrame
427 // by transitioning to WAITING commit states rather than going 434 // by transitioning to WAITING commit states rather than going
428 // immediately to IDLE. 435 // immediately to IDLE.
429 if (begin_main_frame_state_ != BEGIN_MAIN_FRAME_STATE_IDLE) 436 if (begin_main_frame_state_ != BEGIN_MAIN_FRAME_STATE_IDLE)
430 return false; 437 return false;
431 438
439 // MFBA is disabled and we are waiting for previous activation.
440 if (!settings_.main_frame_before_activation_enabled && has_pending_tree_)
441 return false;
442
443 // We are waiting for previous frame to be drawn, swapped and acked.
444 if (settings_.commit_to_active_tree &&
445 (active_tree_needs_first_draw_ || SwapThrottled())) {
446 return false;
447 }
448
432 // Don't send BeginMainFrame early if we are prioritizing the active tree 449 // Don't send BeginMainFrame early if we are prioritizing the active tree
433 // because of ImplLatencyTakesPriority. 450 // because of ImplLatencyTakesPriority.
434 if (ImplLatencyTakesPriority() && 451 if (ImplLatencyTakesPriority() &&
435 (has_pending_tree_ || active_tree_needs_first_draw_)) { 452 (has_pending_tree_ || active_tree_needs_first_draw_)) {
436 return false; 453 return false;
437 } 454 }
438 455
439 // We should not send BeginMainFrame while we are in the idle state since we 456 // We should not send BeginMainFrame while we are in the idle state since we
440 // might have new user input arriving soon. It's okay to send BeginMainFrame 457 // might have new user input arriving soon. It's okay to send BeginMainFrame
441 // for the synchronous compositor because the main thread is always high 458 // for the synchronous compositor because the main thread is always high
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 bool SchedulerStateMachine::ShouldCommit() const { 494 bool SchedulerStateMachine::ShouldCommit() const {
478 if (begin_main_frame_state_ != BEGIN_MAIN_FRAME_STATE_READY_TO_COMMIT) 495 if (begin_main_frame_state_ != BEGIN_MAIN_FRAME_STATE_READY_TO_COMMIT)
479 return false; 496 return false;
480 497
481 // We must not finish the commit until the pending tree is free. 498 // We must not finish the commit until the pending tree is free.
482 if (has_pending_tree_) { 499 if (has_pending_tree_) {
483 DCHECK(settings_.main_frame_before_activation_enabled); 500 DCHECK(settings_.main_frame_before_activation_enabled);
484 return false; 501 return false;
485 } 502 }
486 503
487 // If we only have an active tree, it is incorrect to replace it 504 // If we only have an active tree, it is incorrect to replace it before we've
488 // before we've drawn it. 505 // drawn it.
489 DCHECK(!settings_.commit_to_active_tree || !active_tree_needs_first_draw_); 506 DCHECK(!settings_.commit_to_active_tree || !active_tree_needs_first_draw_);
490 507
508 // In browser compositor commit reclaims any resources submitted during draw.
509 DCHECK(!settings_.commit_to_active_tree || !SwapThrottled());
510
491 return true; 511 return true;
492 } 512 }
493 513
494 bool SchedulerStateMachine::ShouldPrepareTiles() const { 514 bool SchedulerStateMachine::ShouldPrepareTiles() const {
495 // PrepareTiles only really needs to be called immediately after commit 515 // PrepareTiles only really needs to be called immediately after commit
496 // and then periodically after that. Use a funnel to make sure we average 516 // and then periodically after that. Use a funnel to make sure we average
497 // one PrepareTiles per BeginImplFrame in the long run. 517 // one PrepareTiles per BeginImplFrame in the long run.
498 if (prepare_tiles_funnel_ > 0) 518 if (prepare_tiles_funnel_ > 0)
499 return false; 519 return false;
500 520
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 send_begin_main_frame_funnel_ = true; 579 send_begin_main_frame_funnel_ = true;
560 last_frame_number_begin_main_frame_sent_ = current_frame_number_; 580 last_frame_number_begin_main_frame_sent_ = current_frame_number_;
561 } 581 }
562 582
563 void SchedulerStateMachine::WillCommit(bool commit_has_no_updates) { 583 void SchedulerStateMachine::WillCommit(bool commit_has_no_updates) {
564 DCHECK(!has_pending_tree_ || 584 DCHECK(!has_pending_tree_ ||
565 (settings_.main_frame_before_activation_enabled && 585 (settings_.main_frame_before_activation_enabled &&
566 commit_has_no_updates)); 586 commit_has_no_updates));
567 commit_count_++; 587 commit_count_++;
568 last_commit_had_no_updates_ = commit_has_no_updates; 588 last_commit_had_no_updates_ = commit_has_no_updates;
569 589 begin_main_frame_state_ = BEGIN_MAIN_FRAME_STATE_IDLE;
570 if (commit_has_no_updates || settings_.main_frame_before_activation_enabled) {
571 begin_main_frame_state_ = BEGIN_MAIN_FRAME_STATE_IDLE;
572 } else {
573 begin_main_frame_state_ = BEGIN_MAIN_FRAME_STATE_WAITING_FOR_ACTIVATION;
574 }
575 590
576 if (!commit_has_no_updates) { 591 if (!commit_has_no_updates) {
577 // Pending tree only exists if commit had updates. 592 // Pending tree only exists if commit had updates.
578 has_pending_tree_ = true; 593 has_pending_tree_ = true;
579 pending_tree_is_ready_for_activation_ = false; 594 pending_tree_is_ready_for_activation_ = false;
580 wait_for_ready_to_draw_ = settings_.commit_to_active_tree; 595 wait_for_ready_to_draw_ = settings_.commit_to_active_tree;
581 } 596 }
582 597
583 // Update state related to forced draws. 598 // Update state related to forced draws.
584 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_COMMIT) { 599 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_COMMIT) {
585 forced_redraw_state_ = has_pending_tree_ 600 forced_redraw_state_ = has_pending_tree_
586 ? FORCED_REDRAW_STATE_WAITING_FOR_ACTIVATION 601 ? FORCED_REDRAW_STATE_WAITING_FOR_ACTIVATION
587 : FORCED_REDRAW_STATE_WAITING_FOR_DRAW; 602 : FORCED_REDRAW_STATE_WAITING_FOR_DRAW;
588 } 603 }
589 604
590 // Update the output surface state. 605 // Update the output surface state.
591 if (compositor_frame_sink_state_ == 606 if (compositor_frame_sink_state_ ==
592 COMPOSITOR_FRAME_SINK_WAITING_FOR_FIRST_COMMIT) { 607 COMPOSITOR_FRAME_SINK_WAITING_FOR_FIRST_COMMIT) {
593 compositor_frame_sink_state_ = 608 compositor_frame_sink_state_ =
594 has_pending_tree_ ? COMPOSITOR_FRAME_SINK_WAITING_FOR_FIRST_ACTIVATION 609 has_pending_tree_ ? COMPOSITOR_FRAME_SINK_WAITING_FOR_FIRST_ACTIVATION
595 : COMPOSITOR_FRAME_SINK_ACTIVE; 610 : COMPOSITOR_FRAME_SINK_ACTIVE;
596 } 611 }
597 } 612 }
598 613
599 void SchedulerStateMachine::WillActivate() { 614 void SchedulerStateMachine::WillActivate() {
600 if (begin_main_frame_state_ ==
601 BEGIN_MAIN_FRAME_STATE_WAITING_FOR_ACTIVATION) {
602 begin_main_frame_state_ = settings_.commit_to_active_tree
603 ? BEGIN_MAIN_FRAME_STATE_WAITING_FOR_DRAW
604 : BEGIN_MAIN_FRAME_STATE_IDLE;
605 }
606
607 if (compositor_frame_sink_state_ == 615 if (compositor_frame_sink_state_ ==
608 COMPOSITOR_FRAME_SINK_WAITING_FOR_FIRST_ACTIVATION) 616 COMPOSITOR_FRAME_SINK_WAITING_FOR_FIRST_ACTIVATION)
609 compositor_frame_sink_state_ = COMPOSITOR_FRAME_SINK_ACTIVE; 617 compositor_frame_sink_state_ = COMPOSITOR_FRAME_SINK_ACTIVE;
610 618
611 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_ACTIVATION) 619 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_ACTIVATION)
612 forced_redraw_state_ = FORCED_REDRAW_STATE_WAITING_FOR_DRAW; 620 forced_redraw_state_ = FORCED_REDRAW_STATE_WAITING_FOR_DRAW;
613 621
614 has_pending_tree_ = false; 622 has_pending_tree_ = false;
615 pending_tree_is_ready_for_activation_ = false; 623 pending_tree_is_ready_for_activation_ = false;
616 active_tree_needs_first_draw_ = true; 624 active_tree_needs_first_draw_ = true;
(...skipping 12 matching lines...) Expand all
629 // draw itself might request another draw. 637 // draw itself might request another draw.
630 needs_redraw_ = false; 638 needs_redraw_ = false;
631 639
632 draw_funnel_ = true; 640 draw_funnel_ = true;
633 active_tree_needs_first_draw_ = false; 641 active_tree_needs_first_draw_ = false;
634 did_draw_in_last_frame_ = true; 642 did_draw_in_last_frame_ = true;
635 last_frame_number_draw_performed_ = current_frame_number_; 643 last_frame_number_draw_performed_ = current_frame_number_;
636 644
637 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW) 645 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW)
638 forced_redraw_state_ = FORCED_REDRAW_STATE_IDLE; 646 forced_redraw_state_ = FORCED_REDRAW_STATE_IDLE;
639
640 if (begin_main_frame_state_ == BEGIN_MAIN_FRAME_STATE_WAITING_FOR_DRAW)
641 begin_main_frame_state_ = BEGIN_MAIN_FRAME_STATE_IDLE;
642 } 647 }
643 648
644 void SchedulerStateMachine::DidDrawInternal(DrawResult draw_result) { 649 void SchedulerStateMachine::DidDrawInternal(DrawResult draw_result) {
645 switch (draw_result) { 650 switch (draw_result) {
646 case INVALID_RESULT: 651 case INVALID_RESULT:
647 case DRAW_ABORTED_CANT_DRAW: 652 case DRAW_ABORTED_CANT_DRAW:
648 case DRAW_ABORTED_CONTEXT_LOST: 653 case DRAW_ABORTED_CONTEXT_LOST:
649 NOTREACHED() << "Invalid return DrawResult:" << draw_result; 654 NOTREACHED() << "Invalid return DrawResult:" << draw_result;
650 break; 655 break;
651 case DRAW_ABORTED_DRAINING_PIPELINE: 656 case DRAW_ABORTED_DRAINING_PIPELINE:
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
722 last_frame_number_invalidate_compositor_frame_sink_performed_ = 727 last_frame_number_invalidate_compositor_frame_sink_performed_ =
723 current_frame_number_; 728 current_frame_number_;
724 729
725 // The synchronous compositor makes no guarantees about a draw coming in after 730 // The synchronous compositor makes no guarantees about a draw coming in after
726 // an invalidate so clear any flags that would cause the compositor's pipeline 731 // an invalidate so clear any flags that would cause the compositor's pipeline
727 // to stall. 732 // to stall.
728 active_tree_needs_first_draw_ = false; // blocks commit if true 733 active_tree_needs_first_draw_ = false; // blocks commit if true
729 } 734 }
730 735
731 void SchedulerStateMachine::SetSkipNextBeginMainFrameToReduceLatency() { 736 void SchedulerStateMachine::SetSkipNextBeginMainFrameToReduceLatency() {
732 TRACE_EVENT_INSTANT0("cc", 737 TRACE_EVENT_INSTANT0("cc", "Scheduler: SkipNextBeginMainFrameToReduceLatency",
733 "Scheduler: SkipNextBeginMainFrameToReduceLatency",
734 TRACE_EVENT_SCOPE_THREAD); 738 TRACE_EVENT_SCOPE_THREAD);
735 skip_next_begin_main_frame_to_reduce_latency_ = true; 739 skip_next_begin_main_frame_to_reduce_latency_ = true;
736 } 740 }
737 741
738 bool SchedulerStateMachine::BeginFrameNeededForVideo() const { 742 bool SchedulerStateMachine::BeginFrameNeededForVideo() const {
739 return video_needs_begin_frames_; 743 return video_needs_begin_frames_;
740 } 744 }
741 745
742 bool SchedulerStateMachine::BeginFrameNeeded() const { 746 bool SchedulerStateMachine::BeginFrameNeeded() const {
743 // We can't handle BeginFrames when output surface isn't initialized. 747 // We can't handle BeginFrames when output surface isn't initialized.
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
865 // funnels so that we don't perform any actions that we shouldn't. 869 // funnels so that we don't perform any actions that we shouldn't.
866 if (!BeginFrameNeeded()) 870 if (!BeginFrameNeeded())
867 send_begin_main_frame_funnel_ = true; 871 send_begin_main_frame_funnel_ = true;
868 } 872 }
869 873
870 SchedulerStateMachine::BeginImplFrameDeadlineMode 874 SchedulerStateMachine::BeginImplFrameDeadlineMode
871 SchedulerStateMachine::CurrentBeginImplFrameDeadlineMode() const { 875 SchedulerStateMachine::CurrentBeginImplFrameDeadlineMode() const {
872 if (settings_.using_synchronous_renderer_compositor) { 876 if (settings_.using_synchronous_renderer_compositor) {
873 // No deadline for synchronous compositor. 877 // No deadline for synchronous compositor.
874 return BEGIN_IMPL_FRAME_DEADLINE_MODE_NONE; 878 return BEGIN_IMPL_FRAME_DEADLINE_MODE_NONE;
879 } else if (wait_for_ready_to_draw_) {
880 // In browser compositor, wait for active tree to be rasterized.
881 DCHECK(settings_.commit_to_active_tree);
882 return BEGIN_IMPL_FRAME_DEADLINE_MODE_BLOCKED_ON_READY_TO_DRAW;
875 } else if (ShouldTriggerBeginImplFrameDeadlineImmediately()) { 883 } else if (ShouldTriggerBeginImplFrameDeadlineImmediately()) {
876 return BEGIN_IMPL_FRAME_DEADLINE_MODE_IMMEDIATE; 884 return BEGIN_IMPL_FRAME_DEADLINE_MODE_IMMEDIATE;
877 } else if (wait_for_ready_to_draw_) {
878 // When we are waiting for ready to draw signal, we do not wait to post a
879 // deadline yet.
880 return BEGIN_IMPL_FRAME_DEADLINE_MODE_BLOCKED_ON_READY_TO_DRAW;
881 } else if (needs_redraw_) { 885 } else if (needs_redraw_) {
882 // We have an animation or fast input path on the impl thread that wants 886 // We have an animation or fast input path on the impl thread that wants
883 // to draw, so don't wait too long for a new active tree. 887 // to draw, so don't wait too long for a new active tree.
884 return BEGIN_IMPL_FRAME_DEADLINE_MODE_REGULAR; 888 return BEGIN_IMPL_FRAME_DEADLINE_MODE_REGULAR;
885 } else { 889 } else {
886 // The impl thread doesn't have anything it wants to draw and we are just 890 // The impl thread doesn't have anything it wants to draw and we are just
887 // waiting for a new active tree. In short we are blocked. 891 // waiting for a new active tree. In short we are blocked.
888 return BEGIN_IMPL_FRAME_DEADLINE_MODE_LATE; 892 return BEGIN_IMPL_FRAME_DEADLINE_MODE_LATE;
889 } 893 }
890 } 894 }
891 895
892 bool SchedulerStateMachine::ShouldTriggerBeginImplFrameDeadlineImmediately() 896 bool SchedulerStateMachine::ShouldTriggerBeginImplFrameDeadlineImmediately()
893 const { 897 const {
894 // If we just forced activation, we should end the deadline right now. 898 // If we just forced activation, we should end the deadline right now.
895 if (PendingActivationsShouldBeForced() && !has_pending_tree_) 899 if (PendingActivationsShouldBeForced() && !has_pending_tree_)
896 return true; 900 return true;
897 901
898 // Do not trigger deadline immediately if we're waiting for READY_TO_DRAW
899 // unless it's one of the forced cases.
900 if (wait_for_ready_to_draw_)
901 return false;
902
903 // SwapAck throttle the deadline since we wont draw and swap anyway. 902 // SwapAck throttle the deadline since we wont draw and swap anyway.
904 if (SwapThrottled()) 903 if (SwapThrottled())
905 return false; 904 return false;
906 905
907 if (active_tree_needs_first_draw_) 906 if (active_tree_needs_first_draw_)
908 return true; 907 return true;
909 908
910 if (!needs_redraw_) 909 if (!needs_redraw_)
911 return false; 910 return false;
912 911
913 // This is used to prioritize impl-thread draws when the main thread isn't 912 // This is used to prioritize impl-thread draws when the main thread isn't
914 // producing anything, e.g., after an aborted commit. We also check that we 913 // producing anything, e.g., after an aborted commit. We also check that we
915 // don't have a pending tree -- otherwise we should give it a chance to 914 // don't have a pending tree -- otherwise we should give it a chance to
916 // activate. 915 // activate.
917 // TODO(skyostil): Revisit this when we have more accurate deadline estimates. 916 // TODO(skyostil): Revisit this when we have more accurate deadline estimates.
918 if (begin_main_frame_state_ == BEGIN_MAIN_FRAME_STATE_IDLE && 917 if (!CommitPending() && !has_pending_tree_)
919 !has_pending_tree_)
920 return true; 918 return true;
921 919
922 // Prioritize impl-thread draws in ImplLatencyTakesPriority mode. 920 // Prioritize impl-thread draws in ImplLatencyTakesPriority mode.
923 if (ImplLatencyTakesPriority()) 921 if (ImplLatencyTakesPriority())
924 return true; 922 return true;
925 923
926 return false; 924 return false;
927 } 925 }
928 926
929 bool SchedulerStateMachine::SwapThrottled() const { 927 bool SchedulerStateMachine::SwapThrottled() const {
(...skipping 16 matching lines...) Expand all
946 944
947 void SchedulerStateMachine::SetBeginFrameSourcePaused(bool paused) { 945 void SchedulerStateMachine::SetBeginFrameSourcePaused(bool paused) {
948 begin_frame_source_paused_ = paused; 946 begin_frame_source_paused_ = paused;
949 } 947 }
950 948
951 void SchedulerStateMachine::SetResourcelessSoftwareDraw( 949 void SchedulerStateMachine::SetResourcelessSoftwareDraw(
952 bool resourceless_draw) { 950 bool resourceless_draw) {
953 resourceless_draw_ = resourceless_draw; 951 resourceless_draw_ = resourceless_draw;
954 } 952 }
955 953
956 void SchedulerStateMachine::SetCanDraw(bool can_draw) { can_draw_ = can_draw; } 954 void SchedulerStateMachine::SetCanDraw(bool can_draw) {
955 can_draw_ = can_draw;
956 }
957 957
958 void SchedulerStateMachine::SetNeedsRedraw() { needs_redraw_ = true; } 958 void SchedulerStateMachine::SetNeedsRedraw() {
959 needs_redraw_ = true;
960 }
959 961
960 bool SchedulerStateMachine::OnlyImplSideUpdatesExpected() const { 962 bool SchedulerStateMachine::OnlyImplSideUpdatesExpected() const {
961 bool has_impl_updates = needs_redraw_ || needs_one_begin_impl_frame_; 963 bool has_impl_updates = needs_redraw_ || needs_one_begin_impl_frame_;
962 bool main_updates_expected = 964 bool main_updates_expected =
963 needs_begin_main_frame_ || 965 needs_begin_main_frame_ ||
964 begin_main_frame_state_ != BEGIN_MAIN_FRAME_STATE_IDLE || 966 begin_main_frame_state_ != BEGIN_MAIN_FRAME_STATE_IDLE ||
965 has_pending_tree_; 967 has_pending_tree_;
966 return has_impl_updates && !main_updates_expected; 968 return has_impl_updates && !main_updates_expected;
967 } 969 }
968 970
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1022 } 1024 }
1023 1025
1024 void SchedulerStateMachine::SetNeedsOneBeginImplFrame() { 1026 void SchedulerStateMachine::SetNeedsOneBeginImplFrame() {
1025 needs_one_begin_impl_frame_ = true; 1027 needs_one_begin_impl_frame_ = true;
1026 } 1028 }
1027 1029
1028 void SchedulerStateMachine::NotifyReadyToCommit() { 1030 void SchedulerStateMachine::NotifyReadyToCommit() {
1029 DCHECK_EQ(begin_main_frame_state_, BEGIN_MAIN_FRAME_STATE_STARTED) 1031 DCHECK_EQ(begin_main_frame_state_, BEGIN_MAIN_FRAME_STATE_STARTED)
1030 << AsValue()->ToString(); 1032 << AsValue()->ToString();
1031 begin_main_frame_state_ = BEGIN_MAIN_FRAME_STATE_READY_TO_COMMIT; 1033 begin_main_frame_state_ = BEGIN_MAIN_FRAME_STATE_READY_TO_COMMIT;
1032 // In commit_to_active_tree mode, commit should happen right after 1034 // In commit_to_active_tree mode, commit should happen right after BeginFrame,
1033 // BeginFrame, meaning when this function is called, next action should be 1035 // meaning when this function is called, next action should be commit.
1034 // commit.
1035 if (settings_.commit_to_active_tree) 1036 if (settings_.commit_to_active_tree)
1036 DCHECK(ShouldCommit()); 1037 DCHECK(ShouldCommit());
1037 } 1038 }
1038 1039
1039 void SchedulerStateMachine::BeginMainFrameAborted(CommitEarlyOutReason reason) { 1040 void SchedulerStateMachine::BeginMainFrameAborted(CommitEarlyOutReason reason) {
1040 DCHECK_EQ(begin_main_frame_state_, BEGIN_MAIN_FRAME_STATE_STARTED); 1041 DCHECK_EQ(begin_main_frame_state_, BEGIN_MAIN_FRAME_STATE_STARTED);
1041 1042
1042 // If the main thread aborted, it doesn't matter if the main thread missed 1043 // If the main thread aborted, it doesn't matter if the main thread missed
1043 // the last deadline since it didn't have an update anyway. 1044 // the last deadline since it didn't have an update anyway.
1044 main_thread_missed_last_deadline_ = false; 1045 main_thread_missed_last_deadline_ = false;
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
1110 case COMPOSITOR_FRAME_SINK_ACTIVE: 1111 case COMPOSITOR_FRAME_SINK_ACTIVE:
1111 case COMPOSITOR_FRAME_SINK_WAITING_FOR_FIRST_COMMIT: 1112 case COMPOSITOR_FRAME_SINK_WAITING_FOR_FIRST_COMMIT:
1112 case COMPOSITOR_FRAME_SINK_WAITING_FOR_FIRST_ACTIVATION: 1113 case COMPOSITOR_FRAME_SINK_WAITING_FOR_FIRST_ACTIVATION:
1113 return true; 1114 return true;
1114 } 1115 }
1115 NOTREACHED(); 1116 NOTREACHED();
1116 return false; 1117 return false;
1117 } 1118 }
1118 1119
1119 } // namespace cc 1120 } // namespace cc
OLDNEW
« no previous file with comments | « cc/scheduler/scheduler_state_machine.h ('k') | cc/scheduler/scheduler_state_machine_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698