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 10 matching lines...) Expand all Loading... | |
21 SchedulerStateMachine::SchedulerStateMachine(const SchedulerSettings& settings) | 21 SchedulerStateMachine::SchedulerStateMachine(const SchedulerSettings& settings) |
22 : settings_(settings), | 22 : settings_(settings), |
23 output_surface_state_(OUTPUT_SURFACE_NONE), | 23 output_surface_state_(OUTPUT_SURFACE_NONE), |
24 begin_impl_frame_state_(BEGIN_IMPL_FRAME_STATE_IDLE), | 24 begin_impl_frame_state_(BEGIN_IMPL_FRAME_STATE_IDLE), |
25 begin_main_frame_state_(BEGIN_MAIN_FRAME_STATE_IDLE), | 25 begin_main_frame_state_(BEGIN_MAIN_FRAME_STATE_IDLE), |
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_animate_performed_(-1), | 29 last_frame_number_animate_performed_(-1), |
30 last_frame_number_swap_performed_(-1), | 30 last_frame_number_swap_performed_(-1), |
31 last_frame_number_swap_requested_(-1), | 31 last_frame_number_draw_performed_(-1), |
32 last_frame_number_begin_main_frame_sent_(-1), | 32 last_frame_number_begin_main_frame_sent_(-1), |
33 last_frame_number_invalidate_output_surface_performed_(-1), | 33 last_frame_number_invalidate_output_surface_performed_(-1), |
34 animate_funnel_(false), | 34 animate_funnel_(false), |
35 request_swap_funnel_(false), | 35 draw_funnel_(false), |
36 send_begin_main_frame_funnel_(true), | 36 send_begin_main_frame_funnel_(true), |
37 invalidate_output_surface_funnel_(false), | 37 invalidate_output_surface_funnel_(false), |
38 prepare_tiles_funnel_(0), | 38 prepare_tiles_funnel_(0), |
39 consecutive_checkerboard_animations_(0), | 39 consecutive_checkerboard_animations_(0), |
40 pending_swaps_(0), | 40 pending_swaps_(0), |
41 swaps_with_current_output_surface_(0), | 41 swaps_with_current_output_surface_(0), |
42 needs_redraw_(false), | 42 needs_redraw_(false), |
43 needs_animate_(false), | 43 needs_animate_(false), |
44 needs_prepare_tiles_(false), | 44 needs_prepare_tiles_(false), |
45 needs_begin_main_frame_(false), | 45 needs_begin_main_frame_(false), |
46 needs_one_begin_impl_frame_(false), | 46 needs_one_begin_impl_frame_(false), |
47 visible_(false), | 47 visible_(false), |
48 resourceless_draw_(false), | 48 resourceless_draw_(false), |
49 can_draw_(false), | 49 can_draw_(false), |
50 has_pending_tree_(false), | 50 has_pending_tree_(false), |
51 pending_tree_is_ready_for_activation_(false), | 51 pending_tree_is_ready_for_activation_(false), |
52 active_tree_needs_first_draw_(false), | 52 active_tree_needs_first_draw_(false), |
53 did_create_and_initialize_first_output_surface_(false), | 53 did_create_and_initialize_first_output_surface_(false), |
54 tree_priority_(NEW_CONTENT_TAKES_PRIORITY), | 54 tree_priority_(NEW_CONTENT_TAKES_PRIORITY), |
55 scroll_handler_state_( | 55 scroll_handler_state_( |
56 ScrollHandlerState::SCROLL_DOES_NOT_AFFECT_SCROLL_HANDLER), | 56 ScrollHandlerState::SCROLL_DOES_NOT_AFFECT_SCROLL_HANDLER), |
57 critical_begin_main_frame_to_activate_is_fast_(true), | 57 critical_begin_main_frame_to_activate_is_fast_(true), |
58 main_thread_missed_last_deadline_(false), | 58 main_thread_missed_last_deadline_(false), |
59 skip_next_begin_main_frame_to_reduce_latency_(false), | 59 skip_next_begin_main_frame_to_reduce_latency_(false), |
60 children_need_begin_frames_(false), | 60 children_need_begin_frames_(false), |
61 defer_commits_(false), | 61 defer_commits_(false), |
62 video_needs_begin_frames_(false), | 62 video_needs_begin_frames_(false), |
63 last_commit_had_no_updates_(false), | 63 last_commit_had_no_updates_(false), |
64 wait_for_ready_to_draw_(false), | 64 wait_for_ready_to_draw_(false), |
65 did_request_swap_in_last_frame_(false), | 65 did_draw_in_last_frame_(false), |
66 did_perform_swap_in_last_draw_(false) {} | 66 did_perform_swap_in_last_draw_(false), |
67 last_draw_result_(INVALID_RESULT) {} | |
67 | 68 |
68 const char* SchedulerStateMachine::OutputSurfaceStateToString( | 69 const char* SchedulerStateMachine::OutputSurfaceStateToString( |
69 OutputSurfaceState state) { | 70 OutputSurfaceState state) { |
70 switch (state) { | 71 switch (state) { |
71 case OUTPUT_SURFACE_NONE: | 72 case OUTPUT_SURFACE_NONE: |
72 return "OUTPUT_SURFACE_NONE"; | 73 return "OUTPUT_SURFACE_NONE"; |
73 case OUTPUT_SURFACE_ACTIVE: | 74 case OUTPUT_SURFACE_ACTIVE: |
74 return "OUTPUT_SURFACE_ACTIVE"; | 75 return "OUTPUT_SURFACE_ACTIVE"; |
75 case OUTPUT_SURFACE_CREATING: | 76 case OUTPUT_SURFACE_CREATING: |
76 return "OUTPUT_SURFACE_CREATING"; | 77 return "OUTPUT_SURFACE_CREATING"; |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
215 ForcedRedrawOnTimeoutStateToString(forced_redraw_state_)); | 216 ForcedRedrawOnTimeoutStateToString(forced_redraw_state_)); |
216 state->EndDictionary(); | 217 state->EndDictionary(); |
217 | 218 |
218 state->BeginDictionary("minor_state"); | 219 state->BeginDictionary("minor_state"); |
219 state->SetInteger("commit_count", commit_count_); | 220 state->SetInteger("commit_count", commit_count_); |
220 state->SetInteger("current_frame_number", current_frame_number_); | 221 state->SetInteger("current_frame_number", current_frame_number_); |
221 state->SetInteger("last_frame_number_animate_performed", | 222 state->SetInteger("last_frame_number_animate_performed", |
222 last_frame_number_animate_performed_); | 223 last_frame_number_animate_performed_); |
223 state->SetInteger("last_frame_number_swap_performed", | 224 state->SetInteger("last_frame_number_swap_performed", |
224 last_frame_number_swap_performed_); | 225 last_frame_number_swap_performed_); |
225 state->SetInteger("last_frame_number_swap_requested", | 226 state->SetInteger("last_frame_number_draw_performed", |
226 last_frame_number_swap_requested_); | 227 last_frame_number_draw_performed_); |
227 state->SetInteger("last_frame_number_begin_main_frame_sent", | 228 state->SetInteger("last_frame_number_begin_main_frame_sent", |
228 last_frame_number_begin_main_frame_sent_); | 229 last_frame_number_begin_main_frame_sent_); |
229 state->SetBoolean("funnel: animate_funnel", animate_funnel_); | 230 state->SetBoolean("funnel: animate_funnel", animate_funnel_); |
230 state->SetBoolean("funnel: request_swap_funnel", request_swap_funnel_); | 231 state->SetBoolean("funnel: draw_funnel", draw_funnel_); |
231 state->SetBoolean("funnel: send_begin_main_frame_funnel", | 232 state->SetBoolean("funnel: send_begin_main_frame_funnel", |
232 send_begin_main_frame_funnel_); | 233 send_begin_main_frame_funnel_); |
233 state->SetInteger("funnel: prepare_tiles_funnel", prepare_tiles_funnel_); | 234 state->SetInteger("funnel: prepare_tiles_funnel", prepare_tiles_funnel_); |
234 state->SetBoolean("funnel: invalidate_output_surface_funnel", | 235 state->SetBoolean("funnel: invalidate_output_surface_funnel", |
235 invalidate_output_surface_funnel_); | 236 invalidate_output_surface_funnel_); |
236 state->SetInteger("consecutive_checkerboard_animations", | 237 state->SetInteger("consecutive_checkerboard_animations", |
237 consecutive_checkerboard_animations_); | 238 consecutive_checkerboard_animations_); |
238 state->SetInteger("pending_swaps_", pending_swaps_); | 239 state->SetInteger("pending_swaps_", pending_swaps_); |
239 state->SetInteger("swaps_with_current_output_surface", | 240 state->SetInteger("swaps_with_current_output_surface", |
240 swaps_with_current_output_surface_); | 241 swaps_with_current_output_surface_); |
(...skipping 19 matching lines...) Expand all Loading... | |
260 state->SetBoolean("critical_begin_main_frame_to_activate_is_fast_", | 261 state->SetBoolean("critical_begin_main_frame_to_activate_is_fast_", |
261 critical_begin_main_frame_to_activate_is_fast_); | 262 critical_begin_main_frame_to_activate_is_fast_); |
262 state->SetBoolean("main_thread_missed_last_deadline", | 263 state->SetBoolean("main_thread_missed_last_deadline", |
263 main_thread_missed_last_deadline_); | 264 main_thread_missed_last_deadline_); |
264 state->SetBoolean("skip_next_begin_main_frame_to_reduce_latency", | 265 state->SetBoolean("skip_next_begin_main_frame_to_reduce_latency", |
265 skip_next_begin_main_frame_to_reduce_latency_); | 266 skip_next_begin_main_frame_to_reduce_latency_); |
266 state->SetBoolean("children_need_begin_frames", children_need_begin_frames_); | 267 state->SetBoolean("children_need_begin_frames", children_need_begin_frames_); |
267 state->SetBoolean("video_needs_begin_frames", video_needs_begin_frames_); | 268 state->SetBoolean("video_needs_begin_frames", video_needs_begin_frames_); |
268 state->SetBoolean("defer_commits", defer_commits_); | 269 state->SetBoolean("defer_commits", defer_commits_); |
269 state->SetBoolean("last_commit_had_no_updates", last_commit_had_no_updates_); | 270 state->SetBoolean("last_commit_had_no_updates", last_commit_had_no_updates_); |
270 state->SetBoolean("did_request_swap_in_last_frame", | 271 state->SetBoolean("did_draw_in_last_frame", did_draw_in_last_frame_); |
271 did_request_swap_in_last_frame_); | |
272 state->SetBoolean("did_perform_swap_in_last_draw", | 272 state->SetBoolean("did_perform_swap_in_last_draw", |
273 did_perform_swap_in_last_draw_); | 273 did_perform_swap_in_last_draw_); |
274 state->EndDictionary(); | 274 state->EndDictionary(); |
275 } | 275 } |
276 | 276 |
277 bool SchedulerStateMachine::PendingDrawsShouldBeAborted() const { | 277 bool SchedulerStateMachine::PendingDrawsShouldBeAborted() const { |
278 // Normally when |visible_| is false, pending activations will be forced and | 278 // Normally when |visible_| is false, pending activations will be forced and |
279 // draws will be aborted. However, when the embedder is Android WebView, | 279 // draws will be aborted. However, when the embedder is Android WebView, |
280 // software draws could be scheduled by the Android OS at any time and draws | 280 // software draws could be scheduled by the Android OS at any time and draws |
281 // should not be aborted in this case. | 281 // should not be aborted in this case. |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
343 // be blocking other important actions (like output surface initialization), | 343 // be blocking other important actions (like output surface initialization), |
344 // from occurring. If we are waiting for the first draw, then perform the | 344 // from occurring. If we are waiting for the first draw, then perform the |
345 // aborted draw to keep things moving. If we are not waiting for the first | 345 // aborted draw to keep things moving. If we are not waiting for the first |
346 // draw however, we don't want to abort for no reason. | 346 // draw however, we don't want to abort for no reason. |
347 if (PendingDrawsShouldBeAborted()) | 347 if (PendingDrawsShouldBeAborted()) |
348 return active_tree_needs_first_draw_; | 348 return active_tree_needs_first_draw_; |
349 | 349 |
350 // Do not draw too many times in a single frame. It's okay that we don't check | 350 // Do not draw too many times in a single frame. It's okay that we don't check |
351 // this before checking for aborted draws because aborted draws do not request | 351 // this before checking for aborted draws because aborted draws do not request |
352 // a swap. | 352 // a swap. |
353 if (request_swap_funnel_) | 353 if (draw_funnel_) |
354 return false; | 354 return false; |
355 | 355 |
356 // Don't draw if we are waiting on the first commit after a surface. | 356 // Don't draw if we are waiting on the first commit after a surface. |
357 if (output_surface_state_ != OUTPUT_SURFACE_ACTIVE) | 357 if (output_surface_state_ != OUTPUT_SURFACE_ACTIVE) |
358 return false; | 358 return false; |
359 | 359 |
360 // Do not queue too many swaps. | 360 // Do not queue too many swaps. |
361 if (SwapThrottled()) | 361 if (SwapThrottled()) |
362 return false; | 362 return false; |
363 | 363 |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
661 | 661 |
662 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_ACTIVATION) | 662 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_ACTIVATION) |
663 forced_redraw_state_ = FORCED_REDRAW_STATE_WAITING_FOR_DRAW; | 663 forced_redraw_state_ = FORCED_REDRAW_STATE_WAITING_FOR_DRAW; |
664 | 664 |
665 has_pending_tree_ = false; | 665 has_pending_tree_ = false; |
666 pending_tree_is_ready_for_activation_ = false; | 666 pending_tree_is_ready_for_activation_ = false; |
667 active_tree_needs_first_draw_ = true; | 667 active_tree_needs_first_draw_ = true; |
668 needs_redraw_ = true; | 668 needs_redraw_ = true; |
669 } | 669 } |
670 | 670 |
671 void SchedulerStateMachine::WillDraw(bool did_request_swap) { | 671 void SchedulerStateMachine::WillDrawInternal() { |
672 // We need to reset needs_redraw_ before we draw since the | |
673 // draw itself might request another draw. | |
674 needs_redraw_ = false; | |
675 | |
676 draw_funnel_ = true; | |
677 active_tree_needs_first_draw_ = false; | |
678 did_draw_in_last_frame_ = true; | |
679 last_frame_number_draw_performed_ = current_frame_number_; | |
680 | |
672 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW) | 681 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW) |
673 forced_redraw_state_ = FORCED_REDRAW_STATE_IDLE; | 682 forced_redraw_state_ = FORCED_REDRAW_STATE_IDLE; |
674 | 683 |
675 if (begin_main_frame_state_ == BEGIN_MAIN_FRAME_STATE_WAITING_FOR_DRAW) | 684 if (begin_main_frame_state_ == BEGIN_MAIN_FRAME_STATE_WAITING_FOR_DRAW) |
676 begin_main_frame_state_ = BEGIN_MAIN_FRAME_STATE_IDLE; | 685 begin_main_frame_state_ = BEGIN_MAIN_FRAME_STATE_IDLE; |
686 } | |
677 | 687 |
678 needs_redraw_ = false; | 688 void SchedulerStateMachine::DidDrawInternal(DrawResult draw_result) { |
679 active_tree_needs_first_draw_ = false; | 689 switch (draw_result) { |
690 case INVALID_RESULT: | |
691 case DRAW_ABORTED_CANT_DRAW: | |
692 case DRAW_ABORTED_CONTEXT_LOST: | |
693 NOTREACHED() << "Invalid return DrawResult:" << draw_result; | |
694 break; | |
695 case DRAW_ABORTED_DRAINING_PIPELINE: | |
sunnyps
2015/11/24 22:42:44
nit: Maybe DCHECK(!did_perform_swap_in_last_draw_)
brianderson
2015/11/24 23:19:38
Tried doing this. DRAW_ABORTED_DRAINING_PIPELINE c
| |
696 case DRAW_SUCCESS: | |
697 consecutive_checkerboard_animations_ = 0; | |
698 forced_redraw_state_ = FORCED_REDRAW_STATE_IDLE; | |
699 break; | |
700 case DRAW_ABORTED_CHECKERBOARD_ANIMATIONS: | |
701 DCHECK(!did_perform_swap_in_last_draw_); | |
702 needs_begin_main_frame_ = true; | |
703 needs_redraw_ = true; | |
704 consecutive_checkerboard_animations_++; | |
680 | 705 |
681 if (did_request_swap) { | 706 if (consecutive_checkerboard_animations_ >= |
682 DCHECK(!request_swap_funnel_); | 707 settings_.maximum_number_of_failed_draws_before_draw_is_forced && |
683 request_swap_funnel_ = true; | 708 forced_redraw_state_ == FORCED_REDRAW_STATE_IDLE && |
684 did_request_swap_in_last_frame_ = true; | 709 settings_.timeout_and_draw_when_animation_checkerboards) { |
685 last_frame_number_swap_requested_ = current_frame_number_; | 710 // We need to force a draw, but it doesn't make sense to do this until |
711 // we've committed and have new textures. | |
712 forced_redraw_state_ = FORCED_REDRAW_STATE_WAITING_FOR_COMMIT; | |
713 } | |
714 break; | |
715 case DRAW_ABORTED_MISSING_HIGH_RES_CONTENT: | |
716 DCHECK(!did_perform_swap_in_last_draw_); | |
717 // It's not clear whether this missing content is because of missing | |
718 // pictures (which requires a commit) or because of memory pressure | |
719 // removing textures (which might not). To be safe, request a commit | |
720 // anyway. | |
721 needs_begin_main_frame_ = true; | |
722 break; | |
686 } | 723 } |
724 last_draw_result_ = draw_result; | |
725 } | |
726 | |
727 void SchedulerStateMachine::WillDraw() { | |
728 DCHECK(!draw_funnel_); | |
729 WillDrawInternal(); | |
730 | |
731 // Assume the draw will succeed in case we get a DidSwapBuffers | |
732 // before DidDraw is called. | |
733 last_draw_result_ = DRAW_SUCCESS; | |
sunnyps
2015/11/24 22:42:44
nit: Looks like the only reason to set this is for
brianderson
2015/11/24 23:19:38
True. Removed.
| |
734 } | |
735 | |
736 void SchedulerStateMachine::DidDraw(DrawResult draw_result) { | |
737 DidDrawInternal(draw_result); | |
738 } | |
739 | |
740 void SchedulerStateMachine::AbortDrawAndSwap() { | |
741 // Pretend like the draw was successful. | |
742 WillDrawInternal(); | |
743 DidDrawInternal(DRAW_ABORTED_DRAINING_PIPELINE); | |
687 } | 744 } |
688 | 745 |
689 void SchedulerStateMachine::WillPrepareTiles() { | 746 void SchedulerStateMachine::WillPrepareTiles() { |
690 needs_prepare_tiles_ = false; | 747 needs_prepare_tiles_ = false; |
691 } | 748 } |
692 | 749 |
693 void SchedulerStateMachine::WillBeginOutputSurfaceCreation() { | 750 void SchedulerStateMachine::WillBeginOutputSurfaceCreation() { |
694 DCHECK_EQ(output_surface_state_, OUTPUT_SURFACE_NONE); | 751 DCHECK_EQ(output_surface_state_, OUTPUT_SURFACE_NONE); |
695 output_surface_state_ = OUTPUT_SURFACE_CREATING; | 752 output_surface_state_ = OUTPUT_SURFACE_CREATING; |
696 | 753 |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
792 // If the pending tree activates quickly, we'll want a BeginImplFrame soon | 849 // If the pending tree activates quickly, we'll want a BeginImplFrame soon |
793 // to draw the new active tree. | 850 // to draw the new active tree. |
794 if (has_pending_tree_) | 851 if (has_pending_tree_) |
795 return true; | 852 return true; |
796 | 853 |
797 // Changing priorities may allow us to activate (given the new priorities), | 854 // Changing priorities may allow us to activate (given the new priorities), |
798 // which may result in a new frame. | 855 // which may result in a new frame. |
799 if (needs_prepare_tiles_) | 856 if (needs_prepare_tiles_) |
800 return true; | 857 return true; |
801 | 858 |
802 // If we just sent a swap request, it's likely that we are going to produce | 859 // If we just tried to DrawAndSwap, it's likely that we are going to produce |
803 // another frame soon. This helps avoid negative glitches in our | 860 // another frame soon. This helps avoid negative glitches in our |
804 // SetNeedsBeginFrame requests, which may propagate to the BeginImplFrame | 861 // SetNeedsBeginFrame requests, which may propagate to the BeginImplFrame |
805 // provider and get sampled at an inopportune time, delaying the next | 862 // provider and get sampled at an inopportune time, delaying the next |
806 // BeginImplFrame. | 863 // BeginImplFrame. |
807 if (did_request_swap_in_last_frame_) | 864 if (did_draw_in_last_frame_) |
808 return true; | 865 return true; |
809 | 866 |
810 // If the last commit was aborted because of early out (no updates), we should | 867 // If the last commit was aborted because of early out (no updates), we should |
811 // still want a begin frame in case there is a commit coming again. | 868 // still want a begin frame in case there is a commit coming again. |
812 if (last_commit_had_no_updates_) | 869 if (last_commit_had_no_updates_) |
813 return true; | 870 return true; |
814 | 871 |
815 return false; | 872 return false; |
816 } | 873 } |
817 | 874 |
818 void SchedulerStateMachine::OnBeginImplFrame() { | 875 void SchedulerStateMachine::OnBeginImplFrame() { |
819 begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_BEGIN_FRAME_STARTING; | 876 begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_BEGIN_FRAME_STARTING; |
820 current_frame_number_++; | 877 current_frame_number_++; |
821 | 878 |
822 last_commit_had_no_updates_ = false; | 879 last_commit_had_no_updates_ = false; |
823 did_request_swap_in_last_frame_ = false; | 880 did_draw_in_last_frame_ = false; |
824 needs_one_begin_impl_frame_ = false; | 881 needs_one_begin_impl_frame_ = false; |
825 | 882 |
826 // Clear funnels for any actions we perform during the frame. | 883 // Clear funnels for any actions we perform during the frame. |
827 animate_funnel_ = false; | 884 animate_funnel_ = false; |
828 send_begin_main_frame_funnel_ = false; | 885 send_begin_main_frame_funnel_ = false; |
829 invalidate_output_surface_funnel_ = false; | 886 invalidate_output_surface_funnel_ = false; |
830 | 887 |
831 // "Drain" the PrepareTiles funnel. | 888 // "Drain" the PrepareTiles funnel. |
832 if (prepare_tiles_funnel_ > 0) | 889 if (prepare_tiles_funnel_ > 0) |
833 prepare_tiles_funnel_--; | 890 prepare_tiles_funnel_--; |
834 } | 891 } |
835 | 892 |
836 void SchedulerStateMachine::OnBeginImplFrameDeadlinePending() { | 893 void SchedulerStateMachine::OnBeginImplFrameDeadlinePending() { |
837 begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME; | 894 begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME; |
838 } | 895 } |
839 | 896 |
840 void SchedulerStateMachine::OnBeginImplFrameDeadline() { | 897 void SchedulerStateMachine::OnBeginImplFrameDeadline() { |
841 begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE; | 898 begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE; |
842 | 899 |
843 did_perform_swap_in_last_draw_ = false; | 900 did_perform_swap_in_last_draw_ = false; |
844 | 901 |
845 // Clear funnels for any actions we perform during the deadline. | 902 // Clear funnels for any actions we perform during the deadline. |
846 request_swap_funnel_ = false; | 903 draw_funnel_ = false; |
847 | 904 |
848 // Allow one PrepareTiles per draw for synchronous compositor. | 905 // Allow one PrepareTiles per draw for synchronous compositor. |
849 if (settings_.using_synchronous_renderer_compositor) { | 906 if (settings_.using_synchronous_renderer_compositor) { |
850 if (prepare_tiles_funnel_ > 0) | 907 if (prepare_tiles_funnel_ > 0) |
851 prepare_tiles_funnel_--; | 908 prepare_tiles_funnel_--; |
852 } | 909 } |
853 } | 910 } |
854 | 911 |
855 void SchedulerStateMachine::OnBeginImplFrameIdle() { | 912 void SchedulerStateMachine::OnBeginImplFrameIdle() { |
856 begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_IDLE; | 913 begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_IDLE; |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
972 } | 1029 } |
973 | 1030 |
974 void SchedulerStateMachine::SetNeedsPrepareTiles() { | 1031 void SchedulerStateMachine::SetNeedsPrepareTiles() { |
975 if (!needs_prepare_tiles_) { | 1032 if (!needs_prepare_tiles_) { |
976 TRACE_EVENT0("cc", "SchedulerStateMachine::SetNeedsPrepareTiles"); | 1033 TRACE_EVENT0("cc", "SchedulerStateMachine::SetNeedsPrepareTiles"); |
977 needs_prepare_tiles_ = true; | 1034 needs_prepare_tiles_ = true; |
978 } | 1035 } |
979 } | 1036 } |
980 void SchedulerStateMachine::DidSwapBuffers() { | 1037 void SchedulerStateMachine::DidSwapBuffers() { |
981 TRACE_EVENT_ASYNC_BEGIN0("cc", "Scheduler:pending_swaps", this); | 1038 TRACE_EVENT_ASYNC_BEGIN0("cc", "Scheduler:pending_swaps", this); |
1039 DCHECK_EQ(last_draw_result_, DRAW_SUCCESS); | |
sunnyps
2015/11/24 22:42:44
nit: This DCHECK_EQ should be unnecessary.
brianderson
2015/11/24 23:19:38
Done.
| |
1040 DCHECK_LT(pending_swaps_, kMaxPendingSwaps); | |
1041 | |
982 pending_swaps_++; | 1042 pending_swaps_++; |
983 swaps_with_current_output_surface_++; | 1043 swaps_with_current_output_surface_++; |
984 | 1044 |
985 DCHECK_LE(pending_swaps_, kMaxPendingSwaps); | |
986 | |
987 did_perform_swap_in_last_draw_ = true; | 1045 did_perform_swap_in_last_draw_ = true; |
988 last_frame_number_swap_performed_ = current_frame_number_; | 1046 last_frame_number_swap_performed_ = current_frame_number_; |
989 } | 1047 } |
990 | 1048 |
991 void SchedulerStateMachine::DidSwapBuffersComplete() { | 1049 void SchedulerStateMachine::DidSwapBuffersComplete() { |
992 TRACE_EVENT_ASYNC_END0("cc", "Scheduler:pending_swaps", this); | 1050 TRACE_EVENT_ASYNC_END0("cc", "Scheduler:pending_swaps", this); |
993 pending_swaps_--; | 1051 pending_swaps_--; |
994 } | 1052 } |
995 | 1053 |
996 void SchedulerStateMachine::SetTreePrioritiesAndScrollState( | 1054 void SchedulerStateMachine::SetTreePrioritiesAndScrollState( |
(...skipping 16 matching lines...) Expand all Loading... | |
1013 critical_begin_main_frame_to_activate_is_fast_) | 1071 critical_begin_main_frame_to_activate_is_fast_) |
1014 return false; | 1072 return false; |
1015 | 1073 |
1016 // Don't wait for the main thread if we are prioritizing smoothness. | 1074 // Don't wait for the main thread if we are prioritizing smoothness. |
1017 if (SMOOTHNESS_TAKES_PRIORITY == tree_priority_) | 1075 if (SMOOTHNESS_TAKES_PRIORITY == tree_priority_) |
1018 return true; | 1076 return true; |
1019 | 1077 |
1020 return false; | 1078 return false; |
1021 } | 1079 } |
1022 | 1080 |
1023 void SchedulerStateMachine::DidDrawIfPossibleCompleted(DrawResult result) { | |
1024 switch (result) { | |
1025 case INVALID_RESULT: | |
1026 NOTREACHED() << "Uninitialized DrawResult."; | |
1027 break; | |
1028 case DRAW_ABORTED_CANT_DRAW: | |
1029 case DRAW_ABORTED_CONTEXT_LOST: | |
1030 NOTREACHED() << "Invalid return value from DrawAndSwapIfPossible:" | |
1031 << result; | |
1032 break; | |
1033 case DRAW_SUCCESS: | |
1034 consecutive_checkerboard_animations_ = 0; | |
1035 forced_redraw_state_ = FORCED_REDRAW_STATE_IDLE; | |
1036 break; | |
1037 case DRAW_ABORTED_CHECKERBOARD_ANIMATIONS: | |
1038 needs_redraw_ = true; | |
1039 | |
1040 // If we're already in the middle of a redraw, we don't need to | |
1041 // restart it. | |
1042 if (forced_redraw_state_ != FORCED_REDRAW_STATE_IDLE) | |
1043 return; | |
1044 | |
1045 needs_begin_main_frame_ = true; | |
1046 consecutive_checkerboard_animations_++; | |
1047 if (settings_.timeout_and_draw_when_animation_checkerboards && | |
1048 consecutive_checkerboard_animations_ >= | |
1049 settings_.maximum_number_of_failed_draws_before_draw_is_forced) { | |
1050 consecutive_checkerboard_animations_ = 0; | |
1051 // We need to force a draw, but it doesn't make sense to do this until | |
1052 // we've committed and have new textures. | |
1053 forced_redraw_state_ = FORCED_REDRAW_STATE_WAITING_FOR_COMMIT; | |
1054 } | |
1055 break; | |
1056 case DRAW_ABORTED_MISSING_HIGH_RES_CONTENT: | |
1057 // It's not clear whether this missing content is because of missing | |
1058 // pictures (which requires a commit) or because of memory pressure | |
1059 // removing textures (which might not). To be safe, request a commit | |
1060 // anyway. | |
1061 needs_begin_main_frame_ = true; | |
1062 break; | |
1063 } | |
1064 } | |
1065 | |
1066 void SchedulerStateMachine::SetNeedsBeginMainFrame() { | 1081 void SchedulerStateMachine::SetNeedsBeginMainFrame() { |
1067 needs_begin_main_frame_ = true; | 1082 needs_begin_main_frame_ = true; |
1068 } | 1083 } |
1069 | 1084 |
1070 void SchedulerStateMachine::SetNeedsOneBeginImplFrame() { | 1085 void SchedulerStateMachine::SetNeedsOneBeginImplFrame() { |
1071 needs_one_begin_impl_frame_ = true; | 1086 needs_one_begin_impl_frame_ = true; |
1072 } | 1087 } |
1073 | 1088 |
1074 void SchedulerStateMachine::NotifyReadyToCommit() { | 1089 void SchedulerStateMachine::NotifyReadyToCommit() { |
1075 DCHECK_EQ(begin_main_frame_state_, BEGIN_MAIN_FRAME_STATE_STARTED) | 1090 DCHECK_EQ(begin_main_frame_state_, BEGIN_MAIN_FRAME_STATE_STARTED) |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1151 case OUTPUT_SURFACE_ACTIVE: | 1166 case OUTPUT_SURFACE_ACTIVE: |
1152 case OUTPUT_SURFACE_WAITING_FOR_FIRST_COMMIT: | 1167 case OUTPUT_SURFACE_WAITING_FOR_FIRST_COMMIT: |
1153 case OUTPUT_SURFACE_WAITING_FOR_FIRST_ACTIVATION: | 1168 case OUTPUT_SURFACE_WAITING_FOR_FIRST_ACTIVATION: |
1154 return true; | 1169 return true; |
1155 } | 1170 } |
1156 NOTREACHED(); | 1171 NOTREACHED(); |
1157 return false; | 1172 return false; |
1158 } | 1173 } |
1159 | 1174 |
1160 } // namespace cc | 1175 } // namespace cc |
OLD | NEW |