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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
45 has_pending_tree_(false), | 45 has_pending_tree_(false), |
46 pending_tree_is_ready_for_activation_(false), | 46 pending_tree_is_ready_for_activation_(false), |
47 active_tree_needs_first_draw_(false), | 47 active_tree_needs_first_draw_(false), |
48 did_create_and_initialize_first_output_surface_(false), | 48 did_create_and_initialize_first_output_surface_(false), |
49 impl_latency_takes_priority_(false), | 49 impl_latency_takes_priority_(false), |
50 skip_next_begin_main_frame_to_reduce_latency_(false), | 50 skip_next_begin_main_frame_to_reduce_latency_(false), |
51 skip_begin_main_frame_to_reduce_latency_(false), | 51 skip_begin_main_frame_to_reduce_latency_(false), |
52 continuous_painting_(false), | 52 continuous_painting_(false), |
53 children_need_begin_frames_(false), | 53 children_need_begin_frames_(false), |
54 defer_commits_(false), | 54 defer_commits_(false), |
55 video_needs_begin_frames_(false), | |
55 last_commit_had_no_updates_(false), | 56 last_commit_had_no_updates_(false), |
56 wait_for_active_tree_ready_to_draw_(false), | 57 wait_for_active_tree_ready_to_draw_(false), |
57 did_request_swap_in_last_frame_(false), | 58 did_request_swap_in_last_frame_(false), |
58 did_perform_swap_in_last_draw_(false) { | 59 did_perform_swap_in_last_draw_(false) { |
59 } | 60 } |
60 | 61 |
61 const char* SchedulerStateMachine::OutputSurfaceStateToString( | 62 const char* SchedulerStateMachine::OutputSurfaceStateToString( |
62 OutputSurfaceState state) { | 63 OutputSurfaceState state) { |
63 switch (state) { | 64 switch (state) { |
64 case OUTPUT_SURFACE_ACTIVE: | 65 case OUTPUT_SURFACE_ACTIVE: |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
236 state->SetBoolean("impl_latency_takes_priority", | 237 state->SetBoolean("impl_latency_takes_priority", |
237 impl_latency_takes_priority_); | 238 impl_latency_takes_priority_); |
238 state->SetBoolean("main_thread_is_in_high_latency_mode", | 239 state->SetBoolean("main_thread_is_in_high_latency_mode", |
239 MainThreadIsInHighLatencyMode()); | 240 MainThreadIsInHighLatencyMode()); |
240 state->SetBoolean("skip_begin_main_frame_to_reduce_latency", | 241 state->SetBoolean("skip_begin_main_frame_to_reduce_latency", |
241 skip_begin_main_frame_to_reduce_latency_); | 242 skip_begin_main_frame_to_reduce_latency_); |
242 state->SetBoolean("skip_next_begin_main_frame_to_reduce_latency", | 243 state->SetBoolean("skip_next_begin_main_frame_to_reduce_latency", |
243 skip_next_begin_main_frame_to_reduce_latency_); | 244 skip_next_begin_main_frame_to_reduce_latency_); |
244 state->SetBoolean("continuous_painting", continuous_painting_); | 245 state->SetBoolean("continuous_painting", continuous_painting_); |
245 state->SetBoolean("children_need_begin_frames", children_need_begin_frames_); | 246 state->SetBoolean("children_need_begin_frames", children_need_begin_frames_); |
247 state->SetBoolean("video_needs_begin_frames", video_needs_begin_frames_); | |
246 state->SetBoolean("defer_commits", defer_commits_); | 248 state->SetBoolean("defer_commits", defer_commits_); |
247 state->SetBoolean("last_commit_had_no_updates", last_commit_had_no_updates_); | 249 state->SetBoolean("last_commit_had_no_updates", last_commit_had_no_updates_); |
248 state->SetBoolean("did_request_swap_in_last_frame", | 250 state->SetBoolean("did_request_swap_in_last_frame", |
249 did_request_swap_in_last_frame_); | 251 did_request_swap_in_last_frame_); |
250 state->SetBoolean("did_perform_swap_in_last_draw", | 252 state->SetBoolean("did_perform_swap_in_last_draw", |
251 did_perform_swap_in_last_draw_); | 253 did_perform_swap_in_last_draw_); |
252 state->EndDictionary(); | 254 state->EndDictionary(); |
253 } | 255 } |
254 | 256 |
255 bool SchedulerStateMachine::PendingDrawsShouldBeAborted() const { | 257 bool SchedulerStateMachine::PendingDrawsShouldBeAborted() const { |
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
708 void SchedulerStateMachine::SetSkipNextBeginMainFrameToReduceLatency() { | 710 void SchedulerStateMachine::SetSkipNextBeginMainFrameToReduceLatency() { |
709 TRACE_EVENT_INSTANT0("cc", | 711 TRACE_EVENT_INSTANT0("cc", |
710 "Scheduler: SkipNextBeginMainFrameToReduceLatency", | 712 "Scheduler: SkipNextBeginMainFrameToReduceLatency", |
711 TRACE_EVENT_SCOPE_THREAD); | 713 TRACE_EVENT_SCOPE_THREAD); |
712 skip_next_begin_main_frame_to_reduce_latency_ = true; | 714 skip_next_begin_main_frame_to_reduce_latency_ = true; |
713 } | 715 } |
714 | 716 |
715 bool SchedulerStateMachine::BeginFrameRequiredForChildren() const { | 717 bool SchedulerStateMachine::BeginFrameRequiredForChildren() const { |
716 return children_need_begin_frames_; | 718 return children_need_begin_frames_; |
717 } | 719 } |
720 bool SchedulerStateMachine::BeginFrameNeededForVideo() const { | |
721 return video_needs_begin_frames_; | |
722 } | |
718 | 723 |
719 bool SchedulerStateMachine::BeginFrameNeeded() const { | 724 bool SchedulerStateMachine::BeginFrameNeeded() const { |
720 // We can't handle BeginFrames when output surface isn't initialized. | 725 // We can't handle BeginFrames when output surface isn't initialized. |
721 // TODO(brianderson): Support output surface creation inside a BeginFrame. | 726 // TODO(brianderson): Support output surface creation inside a BeginFrame. |
722 if (!HasInitializedOutputSurface()) | 727 if (!HasInitializedOutputSurface()) |
723 return false; | 728 return false; |
724 | 729 |
725 // If we are not visible, we don't need BeginFrame messages. | 730 // If we are not visible, we don't need BeginFrame messages. |
726 if (!visible_) | 731 if (!visible_) |
727 return false; | 732 return false; |
728 | 733 |
729 return (BeginFrameRequiredForAction() || BeginFrameRequiredForChildren() || | 734 return (BeginFrameRequiredForAction() || BeginFrameRequiredForChildren() || |
730 ProactiveBeginFrameWanted()); | 735 BeginFrameNeededForVideo() || ProactiveBeginFrameWanted()); |
brianderson
2015/04/16 01:42:23
To confirm: Video doesn't need BeginFrames when th
sunnyps
2015/04/16 20:56:11
Yes, video doesn't need BeginFrames when the rende
| |
731 } | 736 } |
732 | 737 |
733 void SchedulerStateMachine::SetChildrenNeedBeginFrames( | 738 void SchedulerStateMachine::SetChildrenNeedBeginFrames( |
734 bool children_need_begin_frames) { | 739 bool children_need_begin_frames) { |
735 children_need_begin_frames_ = children_need_begin_frames; | 740 children_need_begin_frames_ = children_need_begin_frames; |
736 } | 741 } |
737 | 742 |
743 void SchedulerStateMachine::SetVideoNeedsBeginFrames( | |
744 bool video_needs_begin_frames) { | |
745 video_needs_begin_frames_ = video_needs_begin_frames; | |
746 } | |
747 | |
738 void SchedulerStateMachine::SetDeferCommits(bool defer_commits) { | 748 void SchedulerStateMachine::SetDeferCommits(bool defer_commits) { |
739 defer_commits_ = defer_commits; | 749 defer_commits_ = defer_commits; |
740 } | 750 } |
741 | 751 |
742 // These are the cases where we require a BeginFrame message to make progress | 752 // These are the cases where we require a BeginFrame message to make progress |
743 // on requested actions. | 753 // on requested actions. |
744 bool SchedulerStateMachine::BeginFrameRequiredForAction() const { | 754 bool SchedulerStateMachine::BeginFrameRequiredForAction() const { |
745 // The forced draw respects our normal draw scheduling, so we need to | 755 // The forced draw respects our normal draw scheduling, so we need to |
746 // request a BeginImplFrame for it. | 756 // request a BeginImplFrame for it. |
747 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW) | 757 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW) |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1116 static_cast<int>(begin_impl_frame_state_), | 1126 static_cast<int>(begin_impl_frame_state_), |
1117 static_cast<int>(commit_state_), | 1127 static_cast<int>(commit_state_), |
1118 has_pending_tree_ ? 'T' : 'F', | 1128 has_pending_tree_ ? 'T' : 'F', |
1119 pending_tree_is_ready_for_activation_ ? 'T' : 'F', | 1129 pending_tree_is_ready_for_activation_ ? 'T' : 'F', |
1120 active_tree_needs_first_draw_ ? 'T' : 'F', | 1130 active_tree_needs_first_draw_ ? 'T' : 'F', |
1121 max_pending_swaps_, | 1131 max_pending_swaps_, |
1122 pending_swaps_); | 1132 pending_swaps_); |
1123 } | 1133 } |
1124 | 1134 |
1125 } // namespace cc | 1135 } // namespace cc |
OLD | NEW |