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

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

Issue 2659123004: cc: Add scheduler support for invalidating content on impl thread. (Closed)
Patch Set: no DCHECK Created 3 years, 10 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 15 matching lines...) Expand all
26 forced_redraw_state_(FORCED_REDRAW_STATE_IDLE), 26 forced_redraw_state_(FORCED_REDRAW_STATE_IDLE),
27 commit_count_(0), 27 commit_count_(0),
28 current_frame_number_(0), 28 current_frame_number_(0),
29 last_frame_number_submit_performed_(-1), 29 last_frame_number_submit_performed_(-1),
30 last_frame_number_draw_performed_(-1), 30 last_frame_number_draw_performed_(-1),
31 last_frame_number_begin_main_frame_sent_(-1), 31 last_frame_number_begin_main_frame_sent_(-1),
32 last_frame_number_invalidate_compositor_frame_sink_performed_(-1), 32 last_frame_number_invalidate_compositor_frame_sink_performed_(-1),
33 draw_funnel_(false), 33 draw_funnel_(false),
34 send_begin_main_frame_funnel_(true), 34 send_begin_main_frame_funnel_(true),
35 invalidate_compositor_frame_sink_funnel_(false), 35 invalidate_compositor_frame_sink_funnel_(false),
36 impl_side_invalidation_funnel_(false),
36 prepare_tiles_funnel_(0), 37 prepare_tiles_funnel_(0),
37 consecutive_checkerboard_animations_(0), 38 consecutive_checkerboard_animations_(0),
38 pending_submit_frames_(0), 39 pending_submit_frames_(0),
39 submit_frames_with_current_compositor_frame_sink_(0), 40 submit_frames_with_current_compositor_frame_sink_(0),
40 needs_redraw_(false), 41 needs_redraw_(false),
41 needs_prepare_tiles_(false), 42 needs_prepare_tiles_(false),
42 needs_begin_main_frame_(false), 43 needs_begin_main_frame_(false),
43 needs_one_begin_impl_frame_(false), 44 needs_one_begin_impl_frame_(false),
44 visible_(false), 45 visible_(false),
45 begin_frame_source_paused_(false), 46 begin_frame_source_paused_(false),
46 resourceless_draw_(false), 47 resourceless_draw_(false),
47 can_draw_(false), 48 can_draw_(false),
48 has_pending_tree_(false), 49 has_pending_tree_(false),
49 pending_tree_is_ready_for_activation_(false), 50 pending_tree_is_ready_for_activation_(false),
50 active_tree_needs_first_draw_(false), 51 active_tree_needs_first_draw_(false),
51 did_create_and_initialize_first_compositor_frame_sink_(false), 52 did_create_and_initialize_first_compositor_frame_sink_(false),
52 tree_priority_(NEW_CONTENT_TAKES_PRIORITY), 53 tree_priority_(NEW_CONTENT_TAKES_PRIORITY),
53 scroll_handler_state_( 54 scroll_handler_state_(
54 ScrollHandlerState::SCROLL_DOES_NOT_AFFECT_SCROLL_HANDLER), 55 ScrollHandlerState::SCROLL_DOES_NOT_AFFECT_SCROLL_HANDLER),
55 critical_begin_main_frame_to_activate_is_fast_(true), 56 critical_begin_main_frame_to_activate_is_fast_(true),
56 main_thread_missed_last_deadline_(false), 57 main_thread_missed_last_deadline_(false),
57 skip_next_begin_main_frame_to_reduce_latency_(false), 58 skip_next_begin_main_frame_to_reduce_latency_(false),
58 defer_commits_(false), 59 defer_commits_(false),
59 video_needs_begin_frames_(false), 60 video_needs_begin_frames_(false),
60 last_commit_had_no_updates_(false), 61 last_commit_had_no_updates_(false),
61 wait_for_ready_to_draw_(false), 62 wait_for_ready_to_draw_(false),
62 did_draw_in_last_frame_(false), 63 did_draw_in_last_frame_(false),
63 did_submit_in_last_frame_(false) {} 64 did_submit_in_last_frame_(false),
65 needs_impl_side_invalidation_(false),
66 previous_pending_tree_was_impl_side_(false),
67 current_pending_tree_is_impl_side_(false) {}
64 68
65 const char* SchedulerStateMachine::CompositorFrameSinkStateToString( 69 const char* SchedulerStateMachine::CompositorFrameSinkStateToString(
66 CompositorFrameSinkState state) { 70 CompositorFrameSinkState state) {
67 switch (state) { 71 switch (state) {
68 case COMPOSITOR_FRAME_SINK_NONE: 72 case COMPOSITOR_FRAME_SINK_NONE:
69 return "COMPOSITOR_FRAME_SINK_NONE"; 73 return "COMPOSITOR_FRAME_SINK_NONE";
70 case COMPOSITOR_FRAME_SINK_ACTIVE: 74 case COMPOSITOR_FRAME_SINK_ACTIVE:
71 return "COMPOSITOR_FRAME_SINK_ACTIVE"; 75 return "COMPOSITOR_FRAME_SINK_ACTIVE";
72 case COMPOSITOR_FRAME_SINK_CREATING: 76 case COMPOSITOR_FRAME_SINK_CREATING:
73 return "COMPOSITOR_FRAME_SINK_CREATING"; 77 return "COMPOSITOR_FRAME_SINK_CREATING";
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 case ACTION_DRAW_FORCED: 174 case ACTION_DRAW_FORCED:
171 return "ACTION_DRAW_FORCED"; 175 return "ACTION_DRAW_FORCED";
172 case ACTION_DRAW_ABORT: 176 case ACTION_DRAW_ABORT:
173 return "ACTION_DRAW_ABORT"; 177 return "ACTION_DRAW_ABORT";
174 case ACTION_BEGIN_COMPOSITOR_FRAME_SINK_CREATION: 178 case ACTION_BEGIN_COMPOSITOR_FRAME_SINK_CREATION:
175 return "ACTION_BEGIN_COMPOSITOR_FRAME_SINK_CREATION"; 179 return "ACTION_BEGIN_COMPOSITOR_FRAME_SINK_CREATION";
176 case ACTION_PREPARE_TILES: 180 case ACTION_PREPARE_TILES:
177 return "ACTION_PREPARE_TILES"; 181 return "ACTION_PREPARE_TILES";
178 case ACTION_INVALIDATE_COMPOSITOR_FRAME_SINK: 182 case ACTION_INVALIDATE_COMPOSITOR_FRAME_SINK:
179 return "ACTION_INVALIDATE_COMPOSITOR_FRAME_SINK"; 183 return "ACTION_INVALIDATE_COMPOSITOR_FRAME_SINK";
184 case ACTION_PERFORM_IMPL_SIDE_INVALIDATION:
185 return "ACTION_PERFORM_IMPL_SIDE_INVALIDATION";
180 } 186 }
181 NOTREACHED(); 187 NOTREACHED();
182 return "???"; 188 return "???";
183 } 189 }
184 190
185 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> 191 std::unique_ptr<base::trace_event::ConvertableToTraceFormat>
186 SchedulerStateMachine::AsValue() const { 192 SchedulerStateMachine::AsValue() const {
187 std::unique_ptr<base::trace_event::TracedValue> state( 193 std::unique_ptr<base::trace_event::TracedValue> state(
188 new base::trace_event::TracedValue()); 194 new base::trace_event::TracedValue());
189 AsValueInto(state.get()); 195 AsValueInto(state.get());
(...skipping 23 matching lines...) Expand all
213 state->SetInteger("last_frame_number_draw_performed", 219 state->SetInteger("last_frame_number_draw_performed",
214 last_frame_number_draw_performed_); 220 last_frame_number_draw_performed_);
215 state->SetInteger("last_frame_number_begin_main_frame_sent", 221 state->SetInteger("last_frame_number_begin_main_frame_sent",
216 last_frame_number_begin_main_frame_sent_); 222 last_frame_number_begin_main_frame_sent_);
217 state->SetBoolean("funnel: draw_funnel", draw_funnel_); 223 state->SetBoolean("funnel: draw_funnel", draw_funnel_);
218 state->SetBoolean("funnel: send_begin_main_frame_funnel", 224 state->SetBoolean("funnel: send_begin_main_frame_funnel",
219 send_begin_main_frame_funnel_); 225 send_begin_main_frame_funnel_);
220 state->SetInteger("funnel: prepare_tiles_funnel", prepare_tiles_funnel_); 226 state->SetInteger("funnel: prepare_tiles_funnel", prepare_tiles_funnel_);
221 state->SetBoolean("funnel: invalidate_compositor_frame_sink_funnel", 227 state->SetBoolean("funnel: invalidate_compositor_frame_sink_funnel",
222 invalidate_compositor_frame_sink_funnel_); 228 invalidate_compositor_frame_sink_funnel_);
229 state->SetBoolean("funnel: impl_side_invalidation_funnel",
230 impl_side_invalidation_funnel_);
223 state->SetInteger("consecutive_checkerboard_animations", 231 state->SetInteger("consecutive_checkerboard_animations",
224 consecutive_checkerboard_animations_); 232 consecutive_checkerboard_animations_);
225 state->SetInteger("pending_submit_frames_", pending_submit_frames_); 233 state->SetInteger("pending_submit_frames_", pending_submit_frames_);
226 state->SetInteger("submit_frames_with_current_compositor_frame_sink", 234 state->SetInteger("submit_frames_with_current_compositor_frame_sink",
227 submit_frames_with_current_compositor_frame_sink_); 235 submit_frames_with_current_compositor_frame_sink_);
228 state->SetBoolean("needs_redraw", needs_redraw_); 236 state->SetBoolean("needs_redraw", needs_redraw_);
229 state->SetBoolean("needs_prepare_tiles", needs_prepare_tiles_); 237 state->SetBoolean("needs_prepare_tiles", needs_prepare_tiles_);
230 state->SetBoolean("needs_begin_main_frame", needs_begin_main_frame_); 238 state->SetBoolean("needs_begin_main_frame", needs_begin_main_frame_);
231 state->SetBoolean("needs_one_begin_impl_frame", needs_one_begin_impl_frame_); 239 state->SetBoolean("needs_one_begin_impl_frame", needs_one_begin_impl_frame_);
232 state->SetBoolean("visible", visible_); 240 state->SetBoolean("visible", visible_);
(...skipping 15 matching lines...) Expand all
248 critical_begin_main_frame_to_activate_is_fast_); 256 critical_begin_main_frame_to_activate_is_fast_);
249 state->SetBoolean("main_thread_missed_last_deadline", 257 state->SetBoolean("main_thread_missed_last_deadline",
250 main_thread_missed_last_deadline_); 258 main_thread_missed_last_deadline_);
251 state->SetBoolean("skip_next_begin_main_frame_to_reduce_latency", 259 state->SetBoolean("skip_next_begin_main_frame_to_reduce_latency",
252 skip_next_begin_main_frame_to_reduce_latency_); 260 skip_next_begin_main_frame_to_reduce_latency_);
253 state->SetBoolean("video_needs_begin_frames", video_needs_begin_frames_); 261 state->SetBoolean("video_needs_begin_frames", video_needs_begin_frames_);
254 state->SetBoolean("defer_commits", defer_commits_); 262 state->SetBoolean("defer_commits", defer_commits_);
255 state->SetBoolean("last_commit_had_no_updates", last_commit_had_no_updates_); 263 state->SetBoolean("last_commit_had_no_updates", last_commit_had_no_updates_);
256 state->SetBoolean("did_draw_in_last_frame", did_draw_in_last_frame_); 264 state->SetBoolean("did_draw_in_last_frame", did_draw_in_last_frame_);
257 state->SetBoolean("did_submit_in_last_frame", did_submit_in_last_frame_); 265 state->SetBoolean("did_submit_in_last_frame", did_submit_in_last_frame_);
266 state->SetBoolean("needs_impl_side_invalidation",
267 needs_impl_side_invalidation_);
258 state->EndDictionary(); 268 state->EndDictionary();
259 } 269 }
260 270
261 bool SchedulerStateMachine::PendingDrawsShouldBeAborted() const { 271 bool SchedulerStateMachine::PendingDrawsShouldBeAborted() const {
262 // Normally when |visible_| is false or |begin_frame_source_paused_| is true, 272 // Normally when |visible_| is false or |begin_frame_source_paused_| is true,
263 // pending activations will be forced and draws will be aborted. However, 273 // pending activations will be forced and draws will be aborted. However,
264 // when the embedder is Android WebView, software draws could be scheduled by 274 // when the embedder is Android WebView, software draws could be scheduled by
265 // the Android OS at any time and draws should not be aborted in this case. 275 // the Android OS at any time and draws should not be aborted in this case.
266 bool is_compositor_frame_sink_lost = 276 bool is_compositor_frame_sink_lost =
267 (compositor_frame_sink_state_ == COMPOSITOR_FRAME_SINK_NONE); 277 (compositor_frame_sink_state_ == COMPOSITOR_FRAME_SINK_NONE);
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 if (ShouldCommit()) 557 if (ShouldCommit())
548 return ACTION_COMMIT; 558 return ACTION_COMMIT;
549 if (ShouldDraw()) { 559 if (ShouldDraw()) {
550 if (PendingDrawsShouldBeAborted()) 560 if (PendingDrawsShouldBeAborted())
551 return ACTION_DRAW_ABORT; 561 return ACTION_DRAW_ABORT;
552 else if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW) 562 else if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW)
553 return ACTION_DRAW_FORCED; 563 return ACTION_DRAW_FORCED;
554 else 564 else
555 return ACTION_DRAW_IF_POSSIBLE; 565 return ACTION_DRAW_IF_POSSIBLE;
556 } 566 }
567 if (ShouldPerformImplSideInvalidation())
568 return ACTION_PERFORM_IMPL_SIDE_INVALIDATION;
557 if (ShouldPrepareTiles()) 569 if (ShouldPrepareTiles())
558 return ACTION_PREPARE_TILES; 570 return ACTION_PREPARE_TILES;
559 if (ShouldSendBeginMainFrame()) 571 if (ShouldSendBeginMainFrame())
560 return ACTION_SEND_BEGIN_MAIN_FRAME; 572 return ACTION_SEND_BEGIN_MAIN_FRAME;
561 if (ShouldInvalidateCompositorFrameSink()) 573 if (ShouldInvalidateCompositorFrameSink())
562 return ACTION_INVALIDATE_COMPOSITOR_FRAME_SINK; 574 return ACTION_INVALIDATE_COMPOSITOR_FRAME_SINK;
563 if (ShouldBeginCompositorFrameSinkCreation()) 575 if (ShouldBeginCompositorFrameSinkCreation())
564 return ACTION_BEGIN_COMPOSITOR_FRAME_SINK_CREATION; 576 return ACTION_BEGIN_COMPOSITOR_FRAME_SINK_CREATION;
565 return ACTION_NONE; 577 return ACTION_NONE;
566 } 578 }
567 579
580 bool SchedulerStateMachine::ShouldPerformImplSideInvalidation() const {
581 if (!needs_impl_side_invalidation_)
582 return false;
583
584 if (!CouldCreatePendingTree())
585 return false;
586
587 // If the main thread is ready to commit, the impl-side invalidations will be
588 // merged with the incoming main frame.
589 if (begin_main_frame_state_ == BEGIN_MAIN_FRAME_STATE_READY_TO_COMMIT)
590 return false;
591
592 // Don't invalidate too many times in the same frame.
593 if (impl_side_invalidation_funnel_)
594 return false;
595
596 // If invalidations go to the active tree and we are waiting for the previous
597 // frame to be drawn, submitted and acked.
598 if (settings_.commit_to_active_tree &&
599 (active_tree_needs_first_draw_ || IsDrawThrottled())) {
600 return false;
601 }
602
603 // If we are inside the deadline and an impl-side invalidation request is
604 // still pending, do it now. We restrict performing impl-side invalidations
605 // until the deadline to give the main thread a chance to respond to a sent
606 // BeginMainFrame. If the main thread responds with a commit, we know the
607 // invalidations will have been merged with the main frame.
608 // If the commit was aborted, or the main thread fails to respond within the
609 // deadline, then we create a pending tree for impl-side invalidations now.
610 // This also checks to make sure that the |prepare_tiles_funnel_| is not full,
611 // since impl-side invalidations will cause a PrepareTiles.
612 if (begin_impl_frame_state_ == BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE &&
613 prepare_tiles_funnel_ == 0) {
614 return true;
615 }
616
617 // Wait till the deadline to perform impl-side invalidations.
618 return false;
619 }
620
621 void SchedulerStateMachine::WillPerformImplSideInvalidation() {
622 current_pending_tree_is_impl_side_ = true;
623 WillPerformImplSideInvalidationInternal();
624 }
625
626 void SchedulerStateMachine::WillPerformImplSideInvalidationInternal() {
627 DCHECK(needs_impl_side_invalidation_);
628 DCHECK(!has_pending_tree_);
629
630 needs_impl_side_invalidation_ = false;
631 has_pending_tree_ = true;
632 impl_side_invalidation_funnel_ = true;
633 }
634
635 bool SchedulerStateMachine::CouldCreatePendingTree() const {
636 // Can't create a new pending tree till the current one is activated.
637 if (has_pending_tree_)
638 return false;
639
640 // Can't make frames while we're invisible.
641 if (!visible_)
642 return false;
643
644 // If the BeginFrameSource is paused, we will not be able to make any impl
645 // frames.
646 if (begin_frame_source_paused_)
647 return false;
648
649 // Don't create a pending tree till a frame sink is initialized.
650 if (!HasInitializedCompositorFrameSink())
651 return false;
652
653 return true;
654 }
655
568 void SchedulerStateMachine::WillSendBeginMainFrame() { 656 void SchedulerStateMachine::WillSendBeginMainFrame() {
569 DCHECK(!has_pending_tree_ || settings_.main_frame_before_activation_enabled); 657 DCHECK(!has_pending_tree_ || settings_.main_frame_before_activation_enabled);
570 DCHECK(visible_); 658 DCHECK(visible_);
571 DCHECK(!begin_frame_source_paused_); 659 DCHECK(!begin_frame_source_paused_);
572 DCHECK(!send_begin_main_frame_funnel_); 660 DCHECK(!send_begin_main_frame_funnel_);
573 begin_main_frame_state_ = BEGIN_MAIN_FRAME_STATE_SENT; 661 begin_main_frame_state_ = BEGIN_MAIN_FRAME_STATE_SENT;
574 needs_begin_main_frame_ = false; 662 needs_begin_main_frame_ = false;
575 send_begin_main_frame_funnel_ = true; 663 send_begin_main_frame_funnel_ = true;
576 last_frame_number_begin_main_frame_sent_ = current_frame_number_; 664 last_frame_number_begin_main_frame_sent_ = current_frame_number_;
577 } 665 }
578 666
579 void SchedulerStateMachine::WillCommit(bool commit_has_no_updates) { 667 void SchedulerStateMachine::WillCommit(bool commit_has_no_updates) {
580 DCHECK(!has_pending_tree_ || 668 DCHECK(!has_pending_tree_ ||
581 (settings_.main_frame_before_activation_enabled && 669 (settings_.main_frame_before_activation_enabled &&
582 commit_has_no_updates)); 670 commit_has_no_updates));
583 commit_count_++; 671 commit_count_++;
584 last_commit_had_no_updates_ = commit_has_no_updates; 672 last_commit_had_no_updates_ = commit_has_no_updates;
585 begin_main_frame_state_ = BEGIN_MAIN_FRAME_STATE_IDLE; 673 begin_main_frame_state_ = BEGIN_MAIN_FRAME_STATE_IDLE;
586 674
587 if (!commit_has_no_updates) { 675 if (!commit_has_no_updates) {
676 // If there was a commit, the impl-side invalidations will be merged with
677 // it. We always fill the impl-side invalidation funnel here, even if no
678 // request was currently pending, to defer creating another pending tree and
679 // performing PrepareTiles until the next frame, in case the invalidation
680 // request is received after the commit.
681 if (needs_impl_side_invalidation_)
682 WillPerformImplSideInvalidationInternal();
683 impl_side_invalidation_funnel_ = true;
684
588 // Pending tree only exists if commit had updates. 685 // Pending tree only exists if commit had updates.
589 has_pending_tree_ = true; 686 has_pending_tree_ = true;
590 pending_tree_is_ready_for_activation_ = false; 687 pending_tree_is_ready_for_activation_ = false;
591 wait_for_ready_to_draw_ = settings_.commit_to_active_tree; 688 wait_for_ready_to_draw_ = settings_.commit_to_active_tree;
592 } 689 }
593 690
594 // Update state related to forced draws. 691 // Update state related to forced draws.
595 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_COMMIT) { 692 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_COMMIT) {
596 forced_redraw_state_ = has_pending_tree_ 693 forced_redraw_state_ = has_pending_tree_
597 ? FORCED_REDRAW_STATE_WAITING_FOR_ACTIVATION 694 ? FORCED_REDRAW_STATE_WAITING_FOR_ACTIVATION
(...skipping 14 matching lines...) Expand all
612 COMPOSITOR_FRAME_SINK_WAITING_FOR_FIRST_ACTIVATION) 709 COMPOSITOR_FRAME_SINK_WAITING_FOR_FIRST_ACTIVATION)
613 compositor_frame_sink_state_ = COMPOSITOR_FRAME_SINK_ACTIVE; 710 compositor_frame_sink_state_ = COMPOSITOR_FRAME_SINK_ACTIVE;
614 711
615 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_ACTIVATION) 712 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_ACTIVATION)
616 forced_redraw_state_ = FORCED_REDRAW_STATE_WAITING_FOR_DRAW; 713 forced_redraw_state_ = FORCED_REDRAW_STATE_WAITING_FOR_DRAW;
617 714
618 has_pending_tree_ = false; 715 has_pending_tree_ = false;
619 pending_tree_is_ready_for_activation_ = false; 716 pending_tree_is_ready_for_activation_ = false;
620 active_tree_needs_first_draw_ = true; 717 active_tree_needs_first_draw_ = true;
621 needs_redraw_ = true; 718 needs_redraw_ = true;
719
720 previous_pending_tree_was_impl_side_ = current_pending_tree_is_impl_side_;
721 current_pending_tree_is_impl_side_ = false;
622 } 722 }
623 723
624 void SchedulerStateMachine::WillDrawInternal() { 724 void SchedulerStateMachine::WillDrawInternal() {
625 // If a new active tree is pending after the one we are about to draw, 725 // If a new active tree is pending after the one we are about to draw,
626 // the main thread is in a high latency mode. 726 // the main thread is in a high latency mode.
627 // main_thread_missed_last_deadline_ is here in addition to 727 // main_thread_missed_last_deadline_ is here in addition to
628 // OnBeginImplFrameIdle for cases where the scheduler aborts draws outside 728 // OnBeginImplFrameIdle for cases where the scheduler aborts draws outside
629 // of the deadline. 729 // of the deadline.
630 main_thread_missed_last_deadline_ = CommitPending() || has_pending_tree_; 730 main_thread_missed_last_deadline_ = CommitPending() || has_pending_tree_;
631 731
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 782
683 void SchedulerStateMachine::WillDraw() { 783 void SchedulerStateMachine::WillDraw() {
684 DCHECK(!draw_funnel_); 784 DCHECK(!draw_funnel_);
685 WillDrawInternal(); 785 WillDrawInternal();
686 } 786 }
687 787
688 void SchedulerStateMachine::DidDraw(DrawResult draw_result) { 788 void SchedulerStateMachine::DidDraw(DrawResult draw_result) {
689 DidDrawInternal(draw_result); 789 DidDrawInternal(draw_result);
690 } 790 }
691 791
792 void SchedulerStateMachine::SetNeedsImplSideInvalidation() {
793 needs_impl_side_invalidation_ = true;
794 }
795
692 void SchedulerStateMachine::AbortDraw() { 796 void SchedulerStateMachine::AbortDraw() {
693 // Pretend like the draw was successful. 797 // Pretend like the draw was successful.
694 // Note: We may abort at any time and cannot DCHECK that 798 // Note: We may abort at any time and cannot DCHECK that
695 // we haven't drawn in or swapped in the last frame here. 799 // we haven't drawn in or swapped in the last frame here.
696 WillDrawInternal(); 800 WillDrawInternal();
697 DidDrawInternal(DRAW_ABORTED_DRAINING_PIPELINE); 801 DidDrawInternal(DRAW_ABORTED_DRAINING_PIPELINE);
698 } 802 }
699 803
700 void SchedulerStateMachine::WillPrepareTiles() { 804 void SchedulerStateMachine::WillPrepareTiles() {
701 needs_prepare_tiles_ = false; 805 needs_prepare_tiles_ = false;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
760 864
761 // These are the cases where we require a BeginFrame message to make progress 865 // These are the cases where we require a BeginFrame message to make progress
762 // on requested actions. 866 // on requested actions.
763 bool SchedulerStateMachine::BeginFrameRequiredForAction() const { 867 bool SchedulerStateMachine::BeginFrameRequiredForAction() const {
764 // The forced draw respects our normal draw scheduling, so we need to 868 // The forced draw respects our normal draw scheduling, so we need to
765 // request a BeginImplFrame for it. 869 // request a BeginImplFrame for it.
766 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW) 870 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW)
767 return true; 871 return true;
768 872
769 return needs_redraw_ || needs_one_begin_impl_frame_ || 873 return needs_redraw_ || needs_one_begin_impl_frame_ ||
770 (needs_begin_main_frame_ && !defer_commits_); 874 (needs_begin_main_frame_ && !defer_commits_) ||
875 needs_impl_side_invalidation_;
771 } 876 }
772 877
773 // These are cases where we are very likely want a BeginFrame message in the 878 // These are cases where we are very likely want a BeginFrame message in the
774 // near future. Proactively requesting the BeginImplFrame helps hide the round 879 // near future. Proactively requesting the BeginImplFrame helps hide the round
775 // trip latency of the SetNeedsBeginFrame request that has to go to the 880 // trip latency of the SetNeedsBeginFrame request that has to go to the
776 // Browser. 881 // Browser.
777 // This includes things like drawing soon, but might not actually have a new 882 // This includes things like drawing soon, but might not actually have a new
778 // frame to draw when we receive the next BeginImplFrame. 883 // frame to draw when we receive the next BeginImplFrame.
779 bool SchedulerStateMachine::ProactiveBeginFrameWanted() const { 884 bool SchedulerStateMachine::ProactiveBeginFrameWanted() const {
780 // Do not be proactive when invisible. 885 // Do not be proactive when invisible.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
820 current_frame_number_++; 925 current_frame_number_++;
821 926
822 last_commit_had_no_updates_ = false; 927 last_commit_had_no_updates_ = false;
823 did_draw_in_last_frame_ = false; 928 did_draw_in_last_frame_ = false;
824 did_submit_in_last_frame_ = false; 929 did_submit_in_last_frame_ = false;
825 needs_one_begin_impl_frame_ = false; 930 needs_one_begin_impl_frame_ = false;
826 931
827 // Clear funnels for any actions we perform during the frame. 932 // Clear funnels for any actions we perform during the frame.
828 send_begin_main_frame_funnel_ = false; 933 send_begin_main_frame_funnel_ = false;
829 invalidate_compositor_frame_sink_funnel_ = false; 934 invalidate_compositor_frame_sink_funnel_ = false;
935 impl_side_invalidation_funnel_ = false;
830 936
831 // "Drain" the PrepareTiles funnel. 937 // "Drain" the PrepareTiles funnel.
832 if (prepare_tiles_funnel_ > 0) 938 if (prepare_tiles_funnel_ > 0)
833 prepare_tiles_funnel_--; 939 prepare_tiles_funnel_--;
834 } 940 }
835 941
836 void SchedulerStateMachine::OnBeginImplFrameDeadline() { 942 void SchedulerStateMachine::OnBeginImplFrameDeadline() {
837 begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE; 943 begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE;
838 944
839 // Clear funnels for any actions we perform during the deadline. 945 // Clear funnels for any actions we perform during the deadline.
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
1103 case COMPOSITOR_FRAME_SINK_ACTIVE: 1209 case COMPOSITOR_FRAME_SINK_ACTIVE:
1104 case COMPOSITOR_FRAME_SINK_WAITING_FOR_FIRST_COMMIT: 1210 case COMPOSITOR_FRAME_SINK_WAITING_FOR_FIRST_COMMIT:
1105 case COMPOSITOR_FRAME_SINK_WAITING_FOR_FIRST_ACTIVATION: 1211 case COMPOSITOR_FRAME_SINK_WAITING_FOR_FIRST_ACTIVATION:
1106 return true; 1212 return true;
1107 } 1213 }
1108 NOTREACHED(); 1214 NOTREACHED();
1109 return false; 1215 return false;
1110 } 1216 }
1111 1217
1112 } // namespace cc 1218 } // 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