| 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.h" | 5 #include "cc/scheduler/scheduler.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 | 191 |
| 192 void Scheduler::WillPrepareTiles() { | 192 void Scheduler::WillPrepareTiles() { |
| 193 compositor_timing_history_->WillPrepareTiles(); | 193 compositor_timing_history_->WillPrepareTiles(); |
| 194 } | 194 } |
| 195 | 195 |
| 196 void Scheduler::DidPrepareTiles() { | 196 void Scheduler::DidPrepareTiles() { |
| 197 compositor_timing_history_->DidPrepareTiles(); | 197 compositor_timing_history_->DidPrepareTiles(); |
| 198 state_machine_.DidPrepareTiles(); | 198 state_machine_.DidPrepareTiles(); |
| 199 } | 199 } |
| 200 | 200 |
| 201 void Scheduler::DidLoseOutputSurface() { | 201 void Scheduler::DidLoseCompositorFrameSink() { |
| 202 TRACE_EVENT0("cc", "Scheduler::DidLoseOutputSurface"); | 202 TRACE_EVENT0("cc", "Scheduler::DidLoseCompositorFrameSink"); |
| 203 begin_retro_frame_args_.clear(); | 203 begin_retro_frame_args_.clear(); |
| 204 begin_retro_frame_task_.Cancel(); | 204 begin_retro_frame_task_.Cancel(); |
| 205 state_machine_.DidLoseOutputSurface(); | 205 state_machine_.DidLoseCompositorFrameSink(); |
| 206 UpdateCompositorTimingHistoryRecordingEnabled(); | 206 UpdateCompositorTimingHistoryRecordingEnabled(); |
| 207 ProcessScheduledActions(); | 207 ProcessScheduledActions(); |
| 208 } | 208 } |
| 209 | 209 |
| 210 void Scheduler::DidCreateAndInitializeOutputSurface() { | 210 void Scheduler::DidCreateAndInitializeCompositorFrameSink() { |
| 211 TRACE_EVENT0("cc", "Scheduler::DidCreateAndInitializeOutputSurface"); | 211 TRACE_EVENT0("cc", "Scheduler::DidCreateAndInitializeCompositorFrameSink"); |
| 212 DCHECK(!observing_begin_frame_source_); | 212 DCHECK(!observing_begin_frame_source_); |
| 213 DCHECK(begin_impl_frame_deadline_task_.IsCancelled()); | 213 DCHECK(begin_impl_frame_deadline_task_.IsCancelled()); |
| 214 state_machine_.DidCreateAndInitializeOutputSurface(); | 214 state_machine_.DidCreateAndInitializeCompositorFrameSink(); |
| 215 compositor_timing_history_->DidCreateAndInitializeOutputSurface(); | 215 compositor_timing_history_->DidCreateAndInitializeCompositorFrameSink(); |
| 216 UpdateCompositorTimingHistoryRecordingEnabled(); | 216 UpdateCompositorTimingHistoryRecordingEnabled(); |
| 217 ProcessScheduledActions(); | 217 ProcessScheduledActions(); |
| 218 } | 218 } |
| 219 | 219 |
| 220 void Scheduler::NotifyBeginMainFrameStarted( | 220 void Scheduler::NotifyBeginMainFrameStarted( |
| 221 base::TimeTicks main_thread_start_time) { | 221 base::TimeTicks main_thread_start_time) { |
| 222 TRACE_EVENT0("cc", "Scheduler::NotifyBeginMainFrameStarted"); | 222 TRACE_EVENT0("cc", "Scheduler::NotifyBeginMainFrameStarted"); |
| 223 state_machine_.NotifyBeginMainFrameStarted(); | 223 state_machine_.NotifyBeginMainFrameStarted(); |
| 224 compositor_timing_history_->BeginMainFrameStarted(main_thread_start_time); | 224 compositor_timing_history_->BeginMainFrameStarted(main_thread_start_time); |
| 225 } | 225 } |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 BeginImplFrameWithDeadline(adjusted_args); | 319 BeginImplFrameWithDeadline(adjusted_args); |
| 320 } | 320 } |
| 321 return true; | 321 return true; |
| 322 } | 322 } |
| 323 | 323 |
| 324 void Scheduler::SetVideoNeedsBeginFrames(bool video_needs_begin_frames) { | 324 void Scheduler::SetVideoNeedsBeginFrames(bool video_needs_begin_frames) { |
| 325 state_machine_.SetVideoNeedsBeginFrames(video_needs_begin_frames); | 325 state_machine_.SetVideoNeedsBeginFrames(video_needs_begin_frames); |
| 326 ProcessScheduledActions(); | 326 ProcessScheduledActions(); |
| 327 } | 327 } |
| 328 | 328 |
| 329 void Scheduler::OnDrawForOutputSurface(bool resourceless_software_draw) { | 329 void Scheduler::OnDrawForCompositorFrameSink(bool resourceless_software_draw) { |
| 330 DCHECK(settings_.using_synchronous_renderer_compositor); | 330 DCHECK(settings_.using_synchronous_renderer_compositor); |
| 331 DCHECK_EQ(state_machine_.begin_impl_frame_state(), | 331 DCHECK_EQ(state_machine_.begin_impl_frame_state(), |
| 332 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE); | 332 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE); |
| 333 DCHECK(begin_impl_frame_deadline_task_.IsCancelled()); | 333 DCHECK(begin_impl_frame_deadline_task_.IsCancelled()); |
| 334 | 334 |
| 335 state_machine_.SetResourcelessSoftwareDraw(resourceless_software_draw); | 335 state_machine_.SetResourcelessSoftwareDraw(resourceless_software_draw); |
| 336 state_machine_.OnBeginImplFrameDeadline(); | 336 state_machine_.OnBeginImplFrameDeadline(); |
| 337 ProcessScheduledActions(); | 337 ProcessScheduledActions(); |
| 338 | 338 |
| 339 state_machine_.OnBeginImplFrameIdle(); | 339 state_machine_.OnBeginImplFrameIdle(); |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 497 begin_impl_frame_tracker_.Finish(); | 497 begin_impl_frame_tracker_.Finish(); |
| 498 } | 498 } |
| 499 | 499 |
| 500 // BeginImplFrame starts a compositor frame that will wait up until a deadline | 500 // BeginImplFrame starts a compositor frame that will wait up until a deadline |
| 501 // for a BeginMainFrame+activation to complete before it times out and draws | 501 // for a BeginMainFrame+activation to complete before it times out and draws |
| 502 // any asynchronous animation and scroll/pinch updates. | 502 // any asynchronous animation and scroll/pinch updates. |
| 503 void Scheduler::BeginImplFrame(const BeginFrameArgs& args) { | 503 void Scheduler::BeginImplFrame(const BeginFrameArgs& args) { |
| 504 DCHECK_EQ(state_machine_.begin_impl_frame_state(), | 504 DCHECK_EQ(state_machine_.begin_impl_frame_state(), |
| 505 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE); | 505 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE); |
| 506 DCHECK(begin_impl_frame_deadline_task_.IsCancelled()); | 506 DCHECK(begin_impl_frame_deadline_task_.IsCancelled()); |
| 507 DCHECK(state_machine_.HasInitializedOutputSurface()); | 507 DCHECK(state_machine_.HasInitializedCompositorFrameSink()); |
| 508 | 508 |
| 509 begin_impl_frame_tracker_.Start(args); | 509 begin_impl_frame_tracker_.Start(args); |
| 510 state_machine_.OnBeginImplFrame(); | 510 state_machine_.OnBeginImplFrame(); |
| 511 devtools_instrumentation::DidBeginFrame(layer_tree_host_id_); | 511 devtools_instrumentation::DidBeginFrame(layer_tree_host_id_); |
| 512 compositor_timing_history_->WillBeginImplFrame( | 512 compositor_timing_history_->WillBeginImplFrame( |
| 513 state_machine_.NewActiveTreeLikely()); | 513 state_machine_.NewActiveTreeLikely()); |
| 514 client_->WillBeginImplFrame(begin_impl_frame_tracker_.Current()); | 514 client_->WillBeginImplFrame(begin_impl_frame_tracker_.Current()); |
| 515 | 515 |
| 516 ProcessScheduledActions(); | 516 ProcessScheduledActions(); |
| 517 } | 517 } |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 678 case SchedulerStateMachine::ACTION_DRAW_AND_SWAP_FORCED: | 678 case SchedulerStateMachine::ACTION_DRAW_AND_SWAP_FORCED: |
| 679 DrawAndSwapForced(); | 679 DrawAndSwapForced(); |
| 680 break; | 680 break; |
| 681 case SchedulerStateMachine::ACTION_DRAW_AND_SWAP_ABORT: { | 681 case SchedulerStateMachine::ACTION_DRAW_AND_SWAP_ABORT: { |
| 682 // No action is actually performed, but this allows the state machine to | 682 // No action is actually performed, but this allows the state machine to |
| 683 // drain the pipeline without actually drawing. | 683 // drain the pipeline without actually drawing. |
| 684 state_machine_.AbortDrawAndSwap(); | 684 state_machine_.AbortDrawAndSwap(); |
| 685 compositor_timing_history_->DrawAborted(); | 685 compositor_timing_history_->DrawAborted(); |
| 686 break; | 686 break; |
| 687 } | 687 } |
| 688 case SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION: | 688 case SchedulerStateMachine::ACTION_BEGIN_COMPOSITOR_FRAME_SINK_CREATION: |
| 689 state_machine_.WillBeginOutputSurfaceCreation(); | 689 state_machine_.WillBeginCompositorFrameSinkCreation(); |
| 690 client_->ScheduledActionBeginOutputSurfaceCreation(); | 690 client_->ScheduledActionBeginCompositorFrameSinkCreation(); |
| 691 break; | 691 break; |
| 692 case SchedulerStateMachine::ACTION_PREPARE_TILES: | 692 case SchedulerStateMachine::ACTION_PREPARE_TILES: |
| 693 state_machine_.WillPrepareTiles(); | 693 state_machine_.WillPrepareTiles(); |
| 694 client_->ScheduledActionPrepareTiles(); | 694 client_->ScheduledActionPrepareTiles(); |
| 695 break; | 695 break; |
| 696 case SchedulerStateMachine::ACTION_INVALIDATE_OUTPUT_SURFACE: { | 696 case SchedulerStateMachine::ACTION_INVALIDATE_COMPOSITOR_FRAME_SINK: { |
| 697 state_machine_.WillInvalidateOutputSurface(); | 697 state_machine_.WillInvalidateCompositorFrameSink(); |
| 698 client_->ScheduledActionInvalidateOutputSurface(); | 698 client_->ScheduledActionInvalidateCompositorFrameSink(); |
| 699 break; | 699 break; |
| 700 } | 700 } |
| 701 } | 701 } |
| 702 } while (action != SchedulerStateMachine::ACTION_NONE); | 702 } while (action != SchedulerStateMachine::ACTION_NONE); |
| 703 | 703 |
| 704 ScheduleBeginImplFrameDeadlineIfNeeded(); | 704 ScheduleBeginImplFrameDeadlineIfNeeded(); |
| 705 SetupNextBeginFrameIfNeeded(); | 705 SetupNextBeginFrameIfNeeded(); |
| 706 } | 706 } |
| 707 | 707 |
| 708 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> | 708 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 742 | 742 |
| 743 state->BeginDictionary("compositor_timing_history"); | 743 state->BeginDictionary("compositor_timing_history"); |
| 744 compositor_timing_history_->AsValueInto(state.get()); | 744 compositor_timing_history_->AsValueInto(state.get()); |
| 745 state->EndDictionary(); | 745 state->EndDictionary(); |
| 746 | 746 |
| 747 return std::move(state); | 747 return std::move(state); |
| 748 } | 748 } |
| 749 | 749 |
| 750 void Scheduler::UpdateCompositorTimingHistoryRecordingEnabled() { | 750 void Scheduler::UpdateCompositorTimingHistoryRecordingEnabled() { |
| 751 compositor_timing_history_->SetRecordingEnabled( | 751 compositor_timing_history_->SetRecordingEnabled( |
| 752 state_machine_.HasInitializedOutputSurface() && state_machine_.visible()); | 752 state_machine_.HasInitializedCompositorFrameSink() && |
| 753 state_machine_.visible()); |
| 753 } | 754 } |
| 754 | 755 |
| 755 bool Scheduler::ShouldRecoverMainLatency( | 756 bool Scheduler::ShouldRecoverMainLatency( |
| 756 const BeginFrameArgs& args, | 757 const BeginFrameArgs& args, |
| 757 bool can_activate_before_deadline) const { | 758 bool can_activate_before_deadline) const { |
| 758 DCHECK(!settings_.using_synchronous_renderer_compositor); | 759 DCHECK(!settings_.using_synchronous_renderer_compositor); |
| 759 | 760 |
| 760 // The main thread is in a low latency mode and there's no need to recover. | 761 // The main thread is in a low latency mode and there's no need to recover. |
| 761 if (!state_machine_.main_thread_missed_last_deadline()) | 762 if (!state_machine_.main_thread_missed_last_deadline()) |
| 762 return false; | 763 return false; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 818 } | 819 } |
| 819 | 820 |
| 820 bool Scheduler::IsBeginMainFrameSentOrStarted() const { | 821 bool Scheduler::IsBeginMainFrameSentOrStarted() const { |
| 821 return (state_machine_.begin_main_frame_state() == | 822 return (state_machine_.begin_main_frame_state() == |
| 822 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_SENT || | 823 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_SENT || |
| 823 state_machine_.begin_main_frame_state() == | 824 state_machine_.begin_main_frame_state() == |
| 824 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_STARTED); | 825 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_STARTED); |
| 825 } | 826 } |
| 826 | 827 |
| 827 } // namespace cc | 828 } // namespace cc |
| OLD | NEW |