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/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 } else { | 392 } else { |
393 advance_commit_state_task_.Cancel(); | 393 advance_commit_state_task_.Cancel(); |
394 } | 394 } |
395 } | 395 } |
396 | 396 |
397 // BeginFrame is the mechanism that tells us that now is a good time to start | 397 // BeginFrame is the mechanism that tells us that now is a good time to start |
398 // making a frame. Usually this means that user input for the frame is complete. | 398 // making a frame. Usually this means that user input for the frame is complete. |
399 // If the scheduler is busy, we queue the BeginFrame to be handled later as | 399 // If the scheduler is busy, we queue the BeginFrame to be handled later as |
400 // a BeginRetroFrame. | 400 // a BeginRetroFrame. |
401 bool Scheduler::OnBeginFrameMixInDelegate(const BeginFrameArgs& args) { | 401 bool Scheduler::OnBeginFrameMixInDelegate(const BeginFrameArgs& args) { |
402 TRACE_EVENT1("cc", "Scheduler::BeginFrame", "args", args.AsValue()); | 402 TRACE_EVENT1("cc,benchmark", "Scheduler::BeginFrame", "args", args.AsValue()); |
403 | 403 |
404 // Deliver BeginFrames to children. | 404 // Deliver BeginFrames to children. |
405 if (settings_.forward_begin_frames_to_children && | 405 if (settings_.forward_begin_frames_to_children && |
406 state_machine_.children_need_begin_frames()) { | 406 state_machine_.children_need_begin_frames()) { |
407 BeginFrameArgs adjusted_args_for_children(args); | 407 BeginFrameArgs adjusted_args_for_children(args); |
408 // Adjust a deadline for child schedulers. | 408 // Adjust a deadline for child schedulers. |
409 // TODO(simonhong): Once we have commitless update, we can get rid of | 409 // TODO(simonhong): Once we have commitless update, we can get rid of |
410 // BeginMainFrameToCommitDurationEstimate() + | 410 // BeginMainFrameToCommitDurationEstimate() + |
411 // CommitToActivateDurationEstimate(). | 411 // CommitToActivateDurationEstimate(). |
412 adjusted_args_for_children.deadline -= | 412 adjusted_args_for_children.deadline -= |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 | 454 |
455 void Scheduler::SetChildrenNeedBeginFrames(bool children_need_begin_frames) { | 455 void Scheduler::SetChildrenNeedBeginFrames(bool children_need_begin_frames) { |
456 DCHECK(settings_.forward_begin_frames_to_children); | 456 DCHECK(settings_.forward_begin_frames_to_children); |
457 state_machine_.SetChildrenNeedBeginFrames(children_need_begin_frames); | 457 state_machine_.SetChildrenNeedBeginFrames(children_need_begin_frames); |
458 ProcessScheduledActions(); | 458 ProcessScheduledActions(); |
459 } | 459 } |
460 | 460 |
461 // BeginRetroFrame is called for BeginFrames that we've deferred because | 461 // BeginRetroFrame is called for BeginFrames that we've deferred because |
462 // the scheduler was in the middle of processing a previous BeginFrame. | 462 // the scheduler was in the middle of processing a previous BeginFrame. |
463 void Scheduler::BeginRetroFrame() { | 463 void Scheduler::BeginRetroFrame() { |
464 TRACE_EVENT0("cc", "Scheduler::BeginRetroFrame"); | 464 TRACE_EVENT0("cc,benchmark", "Scheduler::BeginRetroFrame"); |
465 DCHECK(!settings_.using_synchronous_renderer_compositor); | 465 DCHECK(!settings_.using_synchronous_renderer_compositor); |
466 DCHECK(!begin_retro_frame_args_.empty()); | 466 DCHECK(!begin_retro_frame_args_.empty()); |
467 DCHECK(!begin_retro_frame_task_.IsCancelled()); | 467 DCHECK(!begin_retro_frame_task_.IsCancelled()); |
468 DCHECK_EQ(state_machine_.begin_impl_frame_state(), | 468 DCHECK_EQ(state_machine_.begin_impl_frame_state(), |
469 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE); | 469 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE); |
470 | 470 |
471 begin_retro_frame_task_.Cancel(); | 471 begin_retro_frame_task_.Cancel(); |
472 | 472 |
473 // Discard expired BeginRetroFrames | 473 // Discard expired BeginRetroFrames |
474 // Today, we should always end up with at most one un-expired BeginRetroFrame | 474 // Today, we should always end up with at most one un-expired BeginRetroFrame |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
530 | 530 |
531 task_runner_->PostTask(FROM_HERE, begin_retro_frame_task_.callback()); | 531 task_runner_->PostTask(FROM_HERE, begin_retro_frame_task_.callback()); |
532 } | 532 } |
533 | 533 |
534 // BeginImplFrame starts a compositor frame that will wait up until a deadline | 534 // BeginImplFrame starts a compositor frame that will wait up until a deadline |
535 // for a BeginMainFrame+activation to complete before it times out and draws | 535 // for a BeginMainFrame+activation to complete before it times out and draws |
536 // any asynchronous animation and scroll/pinch updates. | 536 // any asynchronous animation and scroll/pinch updates. |
537 void Scheduler::BeginImplFrame(const BeginFrameArgs& args) { | 537 void Scheduler::BeginImplFrame(const BeginFrameArgs& args) { |
538 bool main_thread_is_in_high_latency_mode = | 538 bool main_thread_is_in_high_latency_mode = |
539 state_machine_.MainThreadIsInHighLatencyMode(); | 539 state_machine_.MainThreadIsInHighLatencyMode(); |
540 TRACE_EVENT2("cc", | 540 TRACE_EVENT2("cc,benchmark", |
541 "Scheduler::BeginImplFrame", | 541 "Scheduler::BeginImplFrame", |
542 "args", | 542 "args", |
543 args.AsValue(), | 543 args.AsValue(), |
544 "main_thread_is_high_latency", | 544 "main_thread_is_high_latency", |
545 main_thread_is_in_high_latency_mode); | 545 main_thread_is_in_high_latency_mode); |
546 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler"), | 546 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler"), |
547 "MainThreadLatency", | 547 "MainThreadLatency", |
548 main_thread_is_in_high_latency_mode); | 548 main_thread_is_in_high_latency_mode); |
549 DCHECK_EQ(state_machine_.begin_impl_frame_state(), | 549 DCHECK_EQ(state_machine_.begin_impl_frame_state(), |
550 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE); | 550 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
628 if (state_machine_.begin_impl_frame_state() != | 628 if (state_machine_.begin_impl_frame_state() != |
629 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME) | 629 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME) |
630 return; | 630 return; |
631 | 631 |
632 if (begin_impl_frame_deadline_mode_ != | 632 if (begin_impl_frame_deadline_mode_ != |
633 state_machine_.CurrentBeginImplFrameDeadlineMode()) | 633 state_machine_.CurrentBeginImplFrameDeadlineMode()) |
634 ScheduleBeginImplFrameDeadline(); | 634 ScheduleBeginImplFrameDeadline(); |
635 } | 635 } |
636 | 636 |
637 void Scheduler::OnBeginImplFrameDeadline() { | 637 void Scheduler::OnBeginImplFrameDeadline() { |
638 TRACE_EVENT0("cc", "Scheduler::OnBeginImplFrameDeadline"); | 638 TRACE_EVENT0("cc,benchmark", "Scheduler::OnBeginImplFrameDeadline"); |
639 begin_impl_frame_deadline_task_.Cancel(); | 639 begin_impl_frame_deadline_task_.Cancel(); |
640 // We split the deadline actions up into two phases so the state machine | 640 // We split the deadline actions up into two phases so the state machine |
641 // has a chance to trigger actions that should occur durring and after | 641 // has a chance to trigger actions that should occur durring and after |
642 // the deadline separately. For example: | 642 // the deadline separately. For example: |
643 // * Sending the BeginMainFrame will not occur after the deadline in | 643 // * Sending the BeginMainFrame will not occur after the deadline in |
644 // order to wait for more user-input before starting the next commit. | 644 // order to wait for more user-input before starting the next commit. |
645 // * Creating a new OuputSurface will not occur during the deadline in | 645 // * Creating a new OuputSurface will not occur during the deadline in |
646 // order to allow the state machine to "settle" first. | 646 // order to allow the state machine to "settle" first. |
647 state_machine_.OnBeginImplFrameDeadline(); | 647 state_machine_.OnBeginImplFrameDeadline(); |
648 ProcessScheduledActions(); | 648 ProcessScheduledActions(); |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
810 } | 810 } |
811 | 811 |
812 bool Scheduler::IsBeginMainFrameSentOrStarted() const { | 812 bool Scheduler::IsBeginMainFrameSentOrStarted() const { |
813 return (state_machine_.commit_state() == | 813 return (state_machine_.commit_state() == |
814 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT || | 814 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT || |
815 state_machine_.commit_state() == | 815 state_machine_.commit_state() == |
816 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED); | 816 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED); |
817 } | 817 } |
818 | 818 |
819 } // namespace cc | 819 } // namespace cc |
OLD | NEW |