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

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: moar tests 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 impl_side_invalidations_take_priority_(false) {}
64 67
65 const char* SchedulerStateMachine::CompositorFrameSinkStateToString( 68 const char* SchedulerStateMachine::CompositorFrameSinkStateToString(
66 CompositorFrameSinkState state) { 69 CompositorFrameSinkState state) {
67 switch (state) { 70 switch (state) {
68 case COMPOSITOR_FRAME_SINK_NONE: 71 case COMPOSITOR_FRAME_SINK_NONE:
69 return "COMPOSITOR_FRAME_SINK_NONE"; 72 return "COMPOSITOR_FRAME_SINK_NONE";
70 case COMPOSITOR_FRAME_SINK_ACTIVE: 73 case COMPOSITOR_FRAME_SINK_ACTIVE:
71 return "COMPOSITOR_FRAME_SINK_ACTIVE"; 74 return "COMPOSITOR_FRAME_SINK_ACTIVE";
72 case COMPOSITOR_FRAME_SINK_CREATING: 75 case COMPOSITOR_FRAME_SINK_CREATING:
73 return "COMPOSITOR_FRAME_SINK_CREATING"; 76 return "COMPOSITOR_FRAME_SINK_CREATING";
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 case ACTION_DRAW_FORCED: 173 case ACTION_DRAW_FORCED:
171 return "ACTION_DRAW_FORCED"; 174 return "ACTION_DRAW_FORCED";
172 case ACTION_DRAW_ABORT: 175 case ACTION_DRAW_ABORT:
173 return "ACTION_DRAW_ABORT"; 176 return "ACTION_DRAW_ABORT";
174 case ACTION_BEGIN_COMPOSITOR_FRAME_SINK_CREATION: 177 case ACTION_BEGIN_COMPOSITOR_FRAME_SINK_CREATION:
175 return "ACTION_BEGIN_COMPOSITOR_FRAME_SINK_CREATION"; 178 return "ACTION_BEGIN_COMPOSITOR_FRAME_SINK_CREATION";
176 case ACTION_PREPARE_TILES: 179 case ACTION_PREPARE_TILES:
177 return "ACTION_PREPARE_TILES"; 180 return "ACTION_PREPARE_TILES";
178 case ACTION_INVALIDATE_COMPOSITOR_FRAME_SINK: 181 case ACTION_INVALIDATE_COMPOSITOR_FRAME_SINK:
179 return "ACTION_INVALIDATE_COMPOSITOR_FRAME_SINK"; 182 return "ACTION_INVALIDATE_COMPOSITOR_FRAME_SINK";
183 case ACTION_PERFORM_IMPL_SIDE_INVALIDATION:
184 return "ACTION_PERFORM_IMPL_SIDE_INVALIDATION";
180 } 185 }
181 NOTREACHED(); 186 NOTREACHED();
182 return "???"; 187 return "???";
183 } 188 }
184 189
185 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> 190 std::unique_ptr<base::trace_event::ConvertableToTraceFormat>
186 SchedulerStateMachine::AsValue() const { 191 SchedulerStateMachine::AsValue() const {
187 std::unique_ptr<base::trace_event::TracedValue> state( 192 std::unique_ptr<base::trace_event::TracedValue> state(
188 new base::trace_event::TracedValue()); 193 new base::trace_event::TracedValue());
189 AsValueInto(state.get()); 194 AsValueInto(state.get());
(...skipping 23 matching lines...) Expand all
213 state->SetInteger("last_frame_number_draw_performed", 218 state->SetInteger("last_frame_number_draw_performed",
214 last_frame_number_draw_performed_); 219 last_frame_number_draw_performed_);
215 state->SetInteger("last_frame_number_begin_main_frame_sent", 220 state->SetInteger("last_frame_number_begin_main_frame_sent",
216 last_frame_number_begin_main_frame_sent_); 221 last_frame_number_begin_main_frame_sent_);
217 state->SetBoolean("funnel: draw_funnel", draw_funnel_); 222 state->SetBoolean("funnel: draw_funnel", draw_funnel_);
218 state->SetBoolean("funnel: send_begin_main_frame_funnel", 223 state->SetBoolean("funnel: send_begin_main_frame_funnel",
219 send_begin_main_frame_funnel_); 224 send_begin_main_frame_funnel_);
220 state->SetInteger("funnel: prepare_tiles_funnel", prepare_tiles_funnel_); 225 state->SetInteger("funnel: prepare_tiles_funnel", prepare_tiles_funnel_);
221 state->SetBoolean("funnel: invalidate_compositor_frame_sink_funnel", 226 state->SetBoolean("funnel: invalidate_compositor_frame_sink_funnel",
222 invalidate_compositor_frame_sink_funnel_); 227 invalidate_compositor_frame_sink_funnel_);
228 state->SetBoolean("funnel: impl_side_invalidation_funnel",
229 impl_side_invalidation_funnel_);
223 state->SetInteger("consecutive_checkerboard_animations", 230 state->SetInteger("consecutive_checkerboard_animations",
224 consecutive_checkerboard_animations_); 231 consecutive_checkerboard_animations_);
225 state->SetInteger("pending_submit_frames_", pending_submit_frames_); 232 state->SetInteger("pending_submit_frames_", pending_submit_frames_);
226 state->SetInteger("submit_frames_with_current_compositor_frame_sink", 233 state->SetInteger("submit_frames_with_current_compositor_frame_sink",
227 submit_frames_with_current_compositor_frame_sink_); 234 submit_frames_with_current_compositor_frame_sink_);
228 state->SetBoolean("needs_redraw", needs_redraw_); 235 state->SetBoolean("needs_redraw", needs_redraw_);
229 state->SetBoolean("needs_prepare_tiles", needs_prepare_tiles_); 236 state->SetBoolean("needs_prepare_tiles", needs_prepare_tiles_);
230 state->SetBoolean("needs_begin_main_frame", needs_begin_main_frame_); 237 state->SetBoolean("needs_begin_main_frame", needs_begin_main_frame_);
231 state->SetBoolean("needs_one_begin_impl_frame", needs_one_begin_impl_frame_); 238 state->SetBoolean("needs_one_begin_impl_frame", needs_one_begin_impl_frame_);
232 state->SetBoolean("visible", visible_); 239 state->SetBoolean("visible", visible_);
(...skipping 15 matching lines...) Expand all
248 critical_begin_main_frame_to_activate_is_fast_); 255 critical_begin_main_frame_to_activate_is_fast_);
249 state->SetBoolean("main_thread_missed_last_deadline", 256 state->SetBoolean("main_thread_missed_last_deadline",
250 main_thread_missed_last_deadline_); 257 main_thread_missed_last_deadline_);
251 state->SetBoolean("skip_next_begin_main_frame_to_reduce_latency", 258 state->SetBoolean("skip_next_begin_main_frame_to_reduce_latency",
252 skip_next_begin_main_frame_to_reduce_latency_); 259 skip_next_begin_main_frame_to_reduce_latency_);
253 state->SetBoolean("video_needs_begin_frames", video_needs_begin_frames_); 260 state->SetBoolean("video_needs_begin_frames", video_needs_begin_frames_);
254 state->SetBoolean("defer_commits", defer_commits_); 261 state->SetBoolean("defer_commits", defer_commits_);
255 state->SetBoolean("last_commit_had_no_updates", last_commit_had_no_updates_); 262 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_); 263 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_); 264 state->SetBoolean("did_submit_in_last_frame", did_submit_in_last_frame_);
265 state->SetBoolean("needs_impl_side_invalidation",
266 needs_impl_side_invalidation_);
267 state->SetBoolean("impl_side_invalidations_take_priority",
268 impl_side_invalidations_take_priority_);
258 state->EndDictionary(); 269 state->EndDictionary();
259 } 270 }
260 271
261 bool SchedulerStateMachine::PendingDrawsShouldBeAborted() const { 272 bool SchedulerStateMachine::PendingDrawsShouldBeAborted() const {
262 // Normally when |visible_| is false or |begin_frame_source_paused_| is true, 273 // Normally when |visible_| is false or |begin_frame_source_paused_| is true,
263 // pending activations will be forced and draws will be aborted. However, 274 // pending activations will be forced and draws will be aborted. However,
264 // when the embedder is Android WebView, software draws could be scheduled by 275 // 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. 276 // the Android OS at any time and draws should not be aborted in this case.
266 bool is_compositor_frame_sink_lost = 277 bool is_compositor_frame_sink_lost =
267 (compositor_frame_sink_state_ == COMPOSITOR_FRAME_SINK_NONE); 278 (compositor_frame_sink_state_ == COMPOSITOR_FRAME_SINK_NONE);
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 return ACTION_DRAW_ABORT; 562 return ACTION_DRAW_ABORT;
552 else if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW) 563 else if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW)
553 return ACTION_DRAW_FORCED; 564 return ACTION_DRAW_FORCED;
554 else 565 else
555 return ACTION_DRAW_IF_POSSIBLE; 566 return ACTION_DRAW_IF_POSSIBLE;
556 } 567 }
557 if (ShouldPrepareTiles()) 568 if (ShouldPrepareTiles())
558 return ACTION_PREPARE_TILES; 569 return ACTION_PREPARE_TILES;
559 if (ShouldSendBeginMainFrame()) 570 if (ShouldSendBeginMainFrame())
560 return ACTION_SEND_BEGIN_MAIN_FRAME; 571 return ACTION_SEND_BEGIN_MAIN_FRAME;
572 if (ShouldPerformImplSideInvalidation())
573 return ACTION_PERFORM_IMPL_SIDE_INVALIDATION;
561 if (ShouldInvalidateCompositorFrameSink()) 574 if (ShouldInvalidateCompositorFrameSink())
562 return ACTION_INVALIDATE_COMPOSITOR_FRAME_SINK; 575 return ACTION_INVALIDATE_COMPOSITOR_FRAME_SINK;
563 if (ShouldBeginCompositorFrameSinkCreation()) 576 if (ShouldBeginCompositorFrameSinkCreation())
564 return ACTION_BEGIN_COMPOSITOR_FRAME_SINK_CREATION; 577 return ACTION_BEGIN_COMPOSITOR_FRAME_SINK_CREATION;
565 return ACTION_NONE; 578 return ACTION_NONE;
566 } 579 }
567 580
581 bool SchedulerStateMachine::ShouldPerformImplSideInvalidation() const {
582 if (!needs_impl_side_invalidation_)
583 return false;
584
585 if (!CouldCreatePendingTree())
586 return false;
587
588 // If the main thread is ready to commit, the impl-side invalidations will be
589 // merged with the incoming main frame.
590 if (begin_main_frame_state_ == BEGIN_MAIN_FRAME_STATE_READY_TO_COMMIT)
591 return false;
592
593 // Don't invalidate too many times in the same frame.
594 if (impl_side_invalidation_funnel_)
595 return false;
596
597 // If invalidations go to the active tree and we are waiting for the previous
598 // frame to be drawn, submitted and acked.
599 if (settings_.commit_to_active_tree &&
600 (active_tree_needs_first_draw_ || IsDrawThrottled())) {
601 return false;
602 }
603
604 // Don't wait on the response to BeginMainFrame if we are prioritizing impl
605 // side invalidations.
606 if (impl_side_invalidations_take_priority_)
607 return true;
608
609 // If BeginMainFrame has been sent, let's wait for the main thread before
610 // pipelining impl-side invalidations.
611 // TODO(khushalsagar): If the main thread is high latency, may be run
612 // impl-side invalidations instead of waiting on the main thread?
613 // See crbug.com/691735.
614 if (begin_main_frame_state_ == BEGIN_MAIN_FRAME_STATE_SENT ||
615 begin_main_frame_state_ == BEGIN_MAIN_FRAME_STATE_STARTED)
616 return false;
617
618 // If a main frame request is pending, always prioritize sending a
619 // BeginMainFrame and receiving an update from the main thread before creating
620 // a pending tree for impl-side invalidations.
621 if (CouldSendBeginMainFrame() &&
622 begin_main_frame_state_ ==
623 BeginMainFrameState::BEGIN_MAIN_FRAME_STATE_IDLE)
brianderson 2017/02/21 23:34:59 Given the preceding logic, I think the STATE_IDLE
Khushal 2017/02/22 20:24:02 This code went away in the new patch, now that we
624 return false;
625
626 // At this point, create a pending tree to run impl-side invalidations.
627 return true;
628 }
629
630 void SchedulerStateMachine::WillPerformImplSideInvalidation() {
631 WillPerformImplSideInvalidationInternal();
632 }
633
634 void SchedulerStateMachine::WillPerformImplSideInvalidationInternal() {
635 DCHECK(needs_impl_side_invalidation_);
636 DCHECK(!has_pending_tree_);
637
638 needs_impl_side_invalidation_ = false;
639 has_pending_tree_ = true;
sunnyps 2017/02/20 23:19:22 For UI, has_pending_tree_ = true should never be t
Khushal 2017/02/21 09:43:44 Good point. The impl-side invalidation should be d
640 impl_side_invalidations_take_priority_ = false;
641 impl_side_invalidation_funnel_ = true;
642 }
643
644 bool SchedulerStateMachine::CouldCreatePendingTree() const {
645 // Can't create a new pending tree till the current one is activated.
646 if (has_pending_tree_)
647 return false;
648
649 // Can't make frames while we're invisible.
650 if (!visible_)
651 return false;
652
653 // If the BeginFrameSource is paused, we will not be able to make any impl
654 // frames.
655 if (begin_frame_source_paused_)
656 return false;
657
658 // Don't create a pending tree till a frame sink is initialized.
659 if (!HasInitializedCompositorFrameSink())
660 return false;
661
662 return true;
663 }
664
568 void SchedulerStateMachine::WillSendBeginMainFrame() { 665 void SchedulerStateMachine::WillSendBeginMainFrame() {
569 DCHECK(!has_pending_tree_ || settings_.main_frame_before_activation_enabled); 666 DCHECK(!has_pending_tree_ || settings_.main_frame_before_activation_enabled);
570 DCHECK(visible_); 667 DCHECK(visible_);
571 DCHECK(!begin_frame_source_paused_); 668 DCHECK(!begin_frame_source_paused_);
572 DCHECK(!send_begin_main_frame_funnel_); 669 DCHECK(!send_begin_main_frame_funnel_);
573 begin_main_frame_state_ = BEGIN_MAIN_FRAME_STATE_SENT; 670 begin_main_frame_state_ = BEGIN_MAIN_FRAME_STATE_SENT;
574 needs_begin_main_frame_ = false; 671 needs_begin_main_frame_ = false;
575 send_begin_main_frame_funnel_ = true; 672 send_begin_main_frame_funnel_ = true;
576 last_frame_number_begin_main_frame_sent_ = current_frame_number_; 673 last_frame_number_begin_main_frame_sent_ = current_frame_number_;
577 } 674 }
578 675
579 void SchedulerStateMachine::WillCommit(bool commit_has_no_updates) { 676 void SchedulerStateMachine::WillCommit(bool commit_has_no_updates) {
580 DCHECK(!has_pending_tree_ || 677 DCHECK(!has_pending_tree_ ||
581 (settings_.main_frame_before_activation_enabled && 678 (settings_.main_frame_before_activation_enabled &&
582 commit_has_no_updates)); 679 commit_has_no_updates));
583 commit_count_++; 680 commit_count_++;
584 last_commit_had_no_updates_ = commit_has_no_updates; 681 last_commit_had_no_updates_ = commit_has_no_updates;
585 begin_main_frame_state_ = BEGIN_MAIN_FRAME_STATE_IDLE; 682 begin_main_frame_state_ = BEGIN_MAIN_FRAME_STATE_IDLE;
586 683
587 if (!commit_has_no_updates) { 684 if (!commit_has_no_updates) {
685 // If there was a commit, the impl-side invalidations will be merged with
686 // it. We always fill the impl-side invalidation funnel here, even if no
687 // request was currently pending, to defer creating another pending tree and
688 // performing PrepareTiles until the next frame, in case the invalidation
689 // request is received after the commit.
690 if (needs_impl_side_invalidation_)
691 WillPerformImplSideInvalidationInternal();
692 impl_side_invalidation_funnel_ = true;
693
588 // Pending tree only exists if commit had updates. 694 // Pending tree only exists if commit had updates.
589 has_pending_tree_ = true; 695 has_pending_tree_ = true;
590 pending_tree_is_ready_for_activation_ = false; 696 pending_tree_is_ready_for_activation_ = false;
591 wait_for_ready_to_draw_ = settings_.commit_to_active_tree; 697 wait_for_ready_to_draw_ = settings_.commit_to_active_tree;
698 } else if (needs_impl_side_invalidation_) {
699 // If the main frame is getting aborted, the impl-side updates will end up
700 // continuously waiting on a commit. In this case, prioritize these over
701 // the main frame.
702 impl_side_invalidations_take_priority_ = true;
592 } 703 }
593 704
594 // Update state related to forced draws. 705 // Update state related to forced draws.
595 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_COMMIT) { 706 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_COMMIT) {
596 forced_redraw_state_ = has_pending_tree_ 707 forced_redraw_state_ = has_pending_tree_
597 ? FORCED_REDRAW_STATE_WAITING_FOR_ACTIVATION 708 ? FORCED_REDRAW_STATE_WAITING_FOR_ACTIVATION
598 : FORCED_REDRAW_STATE_WAITING_FOR_DRAW; 709 : FORCED_REDRAW_STATE_WAITING_FOR_DRAW;
599 } 710 }
600 711
601 // Update the output surface state. 712 // Update the output surface state.
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 793
683 void SchedulerStateMachine::WillDraw() { 794 void SchedulerStateMachine::WillDraw() {
684 DCHECK(!draw_funnel_); 795 DCHECK(!draw_funnel_);
685 WillDrawInternal(); 796 WillDrawInternal();
686 } 797 }
687 798
688 void SchedulerStateMachine::DidDraw(DrawResult draw_result) { 799 void SchedulerStateMachine::DidDraw(DrawResult draw_result) {
689 DidDrawInternal(draw_result); 800 DidDrawInternal(draw_result);
690 } 801 }
691 802
803 void SchedulerStateMachine::SetNeedsImplSideInvalidation() {
804 needs_impl_side_invalidation_ = true;
805 }
806
692 void SchedulerStateMachine::AbortDraw() { 807 void SchedulerStateMachine::AbortDraw() {
693 // Pretend like the draw was successful. 808 // Pretend like the draw was successful.
694 // Note: We may abort at any time and cannot DCHECK that 809 // Note: We may abort at any time and cannot DCHECK that
695 // we haven't drawn in or swapped in the last frame here. 810 // we haven't drawn in or swapped in the last frame here.
696 WillDrawInternal(); 811 WillDrawInternal();
697 DidDrawInternal(DRAW_ABORTED_DRAINING_PIPELINE); 812 DidDrawInternal(DRAW_ABORTED_DRAINING_PIPELINE);
698 } 813 }
699 814
700 void SchedulerStateMachine::WillPrepareTiles() { 815 void SchedulerStateMachine::WillPrepareTiles() {
701 needs_prepare_tiles_ = false; 816 needs_prepare_tiles_ = false;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
760 875
761 // These are the cases where we require a BeginFrame message to make progress 876 // These are the cases where we require a BeginFrame message to make progress
762 // on requested actions. 877 // on requested actions.
763 bool SchedulerStateMachine::BeginFrameRequiredForAction() const { 878 bool SchedulerStateMachine::BeginFrameRequiredForAction() const {
764 // The forced draw respects our normal draw scheduling, so we need to 879 // The forced draw respects our normal draw scheduling, so we need to
765 // request a BeginImplFrame for it. 880 // request a BeginImplFrame for it.
766 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW) 881 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW)
767 return true; 882 return true;
768 883
769 return needs_redraw_ || needs_one_begin_impl_frame_ || 884 return needs_redraw_ || needs_one_begin_impl_frame_ ||
770 (needs_begin_main_frame_ && !defer_commits_); 885 (needs_begin_main_frame_ && !defer_commits_) ||
886 needs_impl_side_invalidation_;
771 } 887 }
772 888
773 // These are cases where we are very likely want a BeginFrame message in the 889 // 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 890 // near future. Proactively requesting the BeginImplFrame helps hide the round
775 // trip latency of the SetNeedsBeginFrame request that has to go to the 891 // trip latency of the SetNeedsBeginFrame request that has to go to the
776 // Browser. 892 // Browser.
777 // This includes things like drawing soon, but might not actually have a new 893 // This includes things like drawing soon, but might not actually have a new
778 // frame to draw when we receive the next BeginImplFrame. 894 // frame to draw when we receive the next BeginImplFrame.
779 bool SchedulerStateMachine::ProactiveBeginFrameWanted() const { 895 bool SchedulerStateMachine::ProactiveBeginFrameWanted() const {
780 // Do not be proactive when invisible. 896 // Do not be proactive when invisible.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
820 current_frame_number_++; 936 current_frame_number_++;
821 937
822 last_commit_had_no_updates_ = false; 938 last_commit_had_no_updates_ = false;
823 did_draw_in_last_frame_ = false; 939 did_draw_in_last_frame_ = false;
824 did_submit_in_last_frame_ = false; 940 did_submit_in_last_frame_ = false;
825 needs_one_begin_impl_frame_ = false; 941 needs_one_begin_impl_frame_ = false;
826 942
827 // Clear funnels for any actions we perform during the frame. 943 // Clear funnels for any actions we perform during the frame.
828 send_begin_main_frame_funnel_ = false; 944 send_begin_main_frame_funnel_ = false;
829 invalidate_compositor_frame_sink_funnel_ = false; 945 invalidate_compositor_frame_sink_funnel_ = false;
946 impl_side_invalidation_funnel_ = false;
830 947
831 // "Drain" the PrepareTiles funnel. 948 // "Drain" the PrepareTiles funnel.
832 if (prepare_tiles_funnel_ > 0) 949 if (prepare_tiles_funnel_ > 0)
833 prepare_tiles_funnel_--; 950 prepare_tiles_funnel_--;
834 } 951 }
835 952
836 void SchedulerStateMachine::OnBeginImplFrameDeadline() { 953 void SchedulerStateMachine::OnBeginImplFrameDeadline() {
837 begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE; 954 begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE;
838 955
839 // Clear funnels for any actions we perform during the deadline. 956 // 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: 1220 case COMPOSITOR_FRAME_SINK_ACTIVE:
1104 case COMPOSITOR_FRAME_SINK_WAITING_FOR_FIRST_COMMIT: 1221 case COMPOSITOR_FRAME_SINK_WAITING_FOR_FIRST_COMMIT:
1105 case COMPOSITOR_FRAME_SINK_WAITING_FOR_FIRST_ACTIVATION: 1222 case COMPOSITOR_FRAME_SINK_WAITING_FOR_FIRST_ACTIVATION:
1106 return true; 1223 return true;
1107 } 1224 }
1108 NOTREACHED(); 1225 NOTREACHED();
1109 return false; 1226 return false;
1110 } 1227 }
1111 1228
1112 } // namespace cc 1229 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698