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/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 Loading... | |
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 Loading... | |
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 Loading... | |
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 Loading... | |
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 Loading... | |
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())) { | |
sunnyps
2017/02/14 21:40:18
What does impl-side invalidation mean if commit_to
Khushal
2017/02/15 00:56:33
It would mean we invalidate the tiles on the activ
enne (OOO)
2017/02/15 01:09:28
Yeah, that was my thought as well. It seems like
sunnyps
2017/02/20 23:19:22
I'm still confused about how active tree tiles wil
Khushal
2017/02/21 09:43:44
The impl-side invalidation works exactly like a co
| |
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) | |
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::WillRunImplSideInvalidation() { | |
631 DCHECK(needs_impl_side_invalidation_); | |
632 WillRunImplSideInvalidationInternal(); | |
633 } | |
634 | |
635 void SchedulerStateMachine::WillRunImplSideInvalidationInternal() { | |
636 needs_impl_side_invalidation_ = false; | |
637 has_pending_tree_ = true; | |
638 impl_side_invalidations_take_priority_ = false; | |
639 impl_side_invalidation_funnel_ = true; | |
640 | |
641 // We fill the BeginMainFrame funnel when running impl-side invalidations | |
642 // since we know that another pending tree in this BeginFrame will end up | |
643 // getting blocked on drawing of the impl-side pending tree further down the | |
644 // pipeline. | |
645 send_begin_main_frame_funnel_ = true; | |
sunnyps
2017/02/14 21:40:18
I'm kinda worried about this. It means there will
Khushal
2017/02/15 00:56:33
If there is rAF alongside a pending invalidation,
Khushal
2017/02/15 03:23:52
Okay. After offline discussion, removed this. We w
| |
646 } | |
647 | |
648 bool SchedulerStateMachine::CouldCreatePendingTree() const { | |
649 // Can't create a new pending tree till the current one is activated. | |
650 if (has_pending_tree_) | |
651 return false; | |
652 | |
653 // Can't make frames while we're invisible. | |
654 if (!visible_) | |
655 return false; | |
656 | |
657 // If the BeginFrameSource is paused, we will not be able to make any impl | |
658 // frames. | |
659 if (begin_frame_source_paused_) | |
660 return false; | |
661 | |
662 // Don't create a pending tree till a frame sink is initialized. | |
663 if (!HasInitializedCompositorFrameSink()) | |
664 return false; | |
665 | |
666 return true; | |
667 } | |
668 | |
568 void SchedulerStateMachine::WillSendBeginMainFrame() { | 669 void SchedulerStateMachine::WillSendBeginMainFrame() { |
569 DCHECK(!has_pending_tree_ || settings_.main_frame_before_activation_enabled); | 670 DCHECK(!has_pending_tree_ || settings_.main_frame_before_activation_enabled); |
570 DCHECK(visible_); | 671 DCHECK(visible_); |
571 DCHECK(!begin_frame_source_paused_); | 672 DCHECK(!begin_frame_source_paused_); |
572 DCHECK(!send_begin_main_frame_funnel_); | 673 DCHECK(!send_begin_main_frame_funnel_); |
573 begin_main_frame_state_ = BEGIN_MAIN_FRAME_STATE_SENT; | 674 begin_main_frame_state_ = BEGIN_MAIN_FRAME_STATE_SENT; |
574 needs_begin_main_frame_ = false; | 675 needs_begin_main_frame_ = false; |
575 send_begin_main_frame_funnel_ = true; | 676 send_begin_main_frame_funnel_ = true; |
576 last_frame_number_begin_main_frame_sent_ = current_frame_number_; | 677 last_frame_number_begin_main_frame_sent_ = current_frame_number_; |
577 } | 678 } |
578 | 679 |
579 void SchedulerStateMachine::WillCommit(bool commit_has_no_updates) { | 680 void SchedulerStateMachine::WillCommit(bool commit_has_no_updates) { |
580 DCHECK(!has_pending_tree_ || | 681 DCHECK(!has_pending_tree_ || |
581 (settings_.main_frame_before_activation_enabled && | 682 (settings_.main_frame_before_activation_enabled && |
582 commit_has_no_updates)); | 683 commit_has_no_updates)); |
583 commit_count_++; | 684 commit_count_++; |
584 last_commit_had_no_updates_ = commit_has_no_updates; | 685 last_commit_had_no_updates_ = commit_has_no_updates; |
585 begin_main_frame_state_ = BEGIN_MAIN_FRAME_STATE_IDLE; | 686 begin_main_frame_state_ = BEGIN_MAIN_FRAME_STATE_IDLE; |
586 | 687 |
587 if (!commit_has_no_updates) { | 688 if (!commit_has_no_updates) { |
588 // Pending tree only exists if commit had updates. | 689 // Pending tree only exists if commit had updates. |
589 has_pending_tree_ = true; | 690 has_pending_tree_ = true; |
590 pending_tree_is_ready_for_activation_ = false; | 691 pending_tree_is_ready_for_activation_ = false; |
591 wait_for_ready_to_draw_ = settings_.commit_to_active_tree; | 692 wait_for_ready_to_draw_ = settings_.commit_to_active_tree; |
693 | |
694 // If there was a commit, the impl-side invalidations will be merged with | |
695 // it. | |
696 WillRunImplSideInvalidationInternal(); | |
697 } else if (needs_impl_side_invalidation_) { | |
698 // If the main frame is getting aborted, the impl-side updates will end up | |
699 // continuously waiting on a commit. In this case, prioritize these over | |
700 // the main frame. | |
701 impl_side_invalidations_take_priority_ = true; | |
sunnyps
2017/02/14 21:40:18
nit: you can use last_commit_had_no_updates_ inste
Khushal
2017/02/15 00:56:33
That flag gets reset on every BeginImplFrame, but
| |
592 } | 702 } |
593 | 703 |
594 // Update state related to forced draws. | 704 // Update state related to forced draws. |
595 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_COMMIT) { | 705 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_COMMIT) { |
596 forced_redraw_state_ = has_pending_tree_ | 706 forced_redraw_state_ = has_pending_tree_ |
597 ? FORCED_REDRAW_STATE_WAITING_FOR_ACTIVATION | 707 ? FORCED_REDRAW_STATE_WAITING_FOR_ACTIVATION |
598 : FORCED_REDRAW_STATE_WAITING_FOR_DRAW; | 708 : FORCED_REDRAW_STATE_WAITING_FOR_DRAW; |
599 } | 709 } |
600 | 710 |
601 // Update the output surface state. | 711 // Update the output surface state. |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
682 | 792 |
683 void SchedulerStateMachine::WillDraw() { | 793 void SchedulerStateMachine::WillDraw() { |
684 DCHECK(!draw_funnel_); | 794 DCHECK(!draw_funnel_); |
685 WillDrawInternal(); | 795 WillDrawInternal(); |
686 } | 796 } |
687 | 797 |
688 void SchedulerStateMachine::DidDraw(DrawResult draw_result) { | 798 void SchedulerStateMachine::DidDraw(DrawResult draw_result) { |
689 DidDrawInternal(draw_result); | 799 DidDrawInternal(draw_result); |
690 } | 800 } |
691 | 801 |
802 void SchedulerStateMachine::SetNeedsImplSideInvalidation() { | |
803 needs_impl_side_invalidation_ = true; | |
804 } | |
805 | |
692 void SchedulerStateMachine::AbortDraw() { | 806 void SchedulerStateMachine::AbortDraw() { |
693 // Pretend like the draw was successful. | 807 // Pretend like the draw was successful. |
694 // Note: We may abort at any time and cannot DCHECK that | 808 // Note: We may abort at any time and cannot DCHECK that |
695 // we haven't drawn in or swapped in the last frame here. | 809 // we haven't drawn in or swapped in the last frame here. |
696 WillDrawInternal(); | 810 WillDrawInternal(); |
697 DidDrawInternal(DRAW_ABORTED_DRAINING_PIPELINE); | 811 DidDrawInternal(DRAW_ABORTED_DRAINING_PIPELINE); |
698 } | 812 } |
699 | 813 |
700 void SchedulerStateMachine::WillPrepareTiles() { | 814 void SchedulerStateMachine::WillPrepareTiles() { |
701 needs_prepare_tiles_ = false; | 815 needs_prepare_tiles_ = false; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
760 | 874 |
761 // These are the cases where we require a BeginFrame message to make progress | 875 // These are the cases where we require a BeginFrame message to make progress |
762 // on requested actions. | 876 // on requested actions. |
763 bool SchedulerStateMachine::BeginFrameRequiredForAction() const { | 877 bool SchedulerStateMachine::BeginFrameRequiredForAction() const { |
764 // The forced draw respects our normal draw scheduling, so we need to | 878 // The forced draw respects our normal draw scheduling, so we need to |
765 // request a BeginImplFrame for it. | 879 // request a BeginImplFrame for it. |
766 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW) | 880 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW) |
767 return true; | 881 return true; |
768 | 882 |
769 return needs_redraw_ || needs_one_begin_impl_frame_ || | 883 return needs_redraw_ || needs_one_begin_impl_frame_ || |
770 (needs_begin_main_frame_ && !defer_commits_); | 884 (needs_begin_main_frame_ && !defer_commits_) || |
885 needs_impl_side_invalidation_; | |
771 } | 886 } |
772 | 887 |
773 // These are cases where we are very likely want a BeginFrame message in the | 888 // 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 | 889 // near future. Proactively requesting the BeginImplFrame helps hide the round |
775 // trip latency of the SetNeedsBeginFrame request that has to go to the | 890 // trip latency of the SetNeedsBeginFrame request that has to go to the |
776 // Browser. | 891 // Browser. |
777 // This includes things like drawing soon, but might not actually have a new | 892 // This includes things like drawing soon, but might not actually have a new |
778 // frame to draw when we receive the next BeginImplFrame. | 893 // frame to draw when we receive the next BeginImplFrame. |
779 bool SchedulerStateMachine::ProactiveBeginFrameWanted() const { | 894 bool SchedulerStateMachine::ProactiveBeginFrameWanted() const { |
780 // Do not be proactive when invisible. | 895 // Do not be proactive when invisible. |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
820 current_frame_number_++; | 935 current_frame_number_++; |
821 | 936 |
822 last_commit_had_no_updates_ = false; | 937 last_commit_had_no_updates_ = false; |
823 did_draw_in_last_frame_ = false; | 938 did_draw_in_last_frame_ = false; |
824 did_submit_in_last_frame_ = false; | 939 did_submit_in_last_frame_ = false; |
825 needs_one_begin_impl_frame_ = false; | 940 needs_one_begin_impl_frame_ = false; |
826 | 941 |
827 // Clear funnels for any actions we perform during the frame. | 942 // Clear funnels for any actions we perform during the frame. |
828 send_begin_main_frame_funnel_ = false; | 943 send_begin_main_frame_funnel_ = false; |
829 invalidate_compositor_frame_sink_funnel_ = false; | 944 invalidate_compositor_frame_sink_funnel_ = false; |
945 impl_side_invalidation_funnel_ = false; | |
830 | 946 |
831 // "Drain" the PrepareTiles funnel. | 947 // "Drain" the PrepareTiles funnel. |
832 if (prepare_tiles_funnel_ > 0) | 948 if (prepare_tiles_funnel_ > 0) |
833 prepare_tiles_funnel_--; | 949 prepare_tiles_funnel_--; |
834 } | 950 } |
835 | 951 |
836 void SchedulerStateMachine::OnBeginImplFrameDeadline() { | 952 void SchedulerStateMachine::OnBeginImplFrameDeadline() { |
837 begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE; | 953 begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE; |
838 | 954 |
839 // Clear funnels for any actions we perform during the deadline. | 955 // Clear funnels for any actions we perform during the deadline. |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1103 case COMPOSITOR_FRAME_SINK_ACTIVE: | 1219 case COMPOSITOR_FRAME_SINK_ACTIVE: |
1104 case COMPOSITOR_FRAME_SINK_WAITING_FOR_FIRST_COMMIT: | 1220 case COMPOSITOR_FRAME_SINK_WAITING_FOR_FIRST_COMMIT: |
1105 case COMPOSITOR_FRAME_SINK_WAITING_FOR_FIRST_ACTIVATION: | 1221 case COMPOSITOR_FRAME_SINK_WAITING_FOR_FIRST_ACTIVATION: |
1106 return true; | 1222 return true; |
1107 } | 1223 } |
1108 NOTREACHED(); | 1224 NOTREACHED(); |
1109 return false; | 1225 return false; |
1110 } | 1226 } |
1111 | 1227 |
1112 } // namespace cc | 1228 } // namespace cc |
OLD | NEW |