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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 } | 59 } |
60 | 60 |
61 Scheduler::~Scheduler() { | 61 Scheduler::~Scheduler() { |
62 SetBeginFrameSource(nullptr); | 62 SetBeginFrameSource(nullptr); |
63 } | 63 } |
64 | 64 |
65 void Scheduler::Stop() { | 65 void Scheduler::Stop() { |
66 stopped_ = true; | 66 stopped_ = true; |
67 } | 67 } |
68 | 68 |
| 69 void Scheduler::SetNeedsImplSideInvalidation() { |
| 70 state_machine_.SetNeedsImplSideInvalidation(); |
| 71 ProcessScheduledActions(); |
| 72 } |
| 73 |
69 base::TimeTicks Scheduler::Now() const { | 74 base::TimeTicks Scheduler::Now() const { |
70 base::TimeTicks now = base::TimeTicks::Now(); | 75 base::TimeTicks now = base::TimeTicks::Now(); |
71 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler.now"), | 76 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler.now"), |
72 "Scheduler::Now", "now", now); | 77 "Scheduler::Now", "now", now); |
73 return now; | 78 return now; |
74 } | 79 } |
75 | 80 |
76 void Scheduler::SetVisible(bool visible) { | 81 void Scheduler::SetVisible(bool visible) { |
77 state_machine_.SetVisible(visible); | 82 state_machine_.SetVisible(visible); |
78 UpdateCompositorTimingHistoryRecordingEnabled(); | 83 UpdateCompositorTimingHistoryRecordingEnabled(); |
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
542 // order to allow the state machine to "settle" first. | 547 // order to allow the state machine to "settle" first. |
543 compositor_timing_history_->WillFinishImplFrame( | 548 compositor_timing_history_->WillFinishImplFrame( |
544 state_machine_.needs_redraw()); | 549 state_machine_.needs_redraw()); |
545 state_machine_.OnBeginImplFrameDeadline(); | 550 state_machine_.OnBeginImplFrameDeadline(); |
546 ProcessScheduledActions(); | 551 ProcessScheduledActions(); |
547 FinishImplFrame(); | 552 FinishImplFrame(); |
548 } | 553 } |
549 | 554 |
550 void Scheduler::DrawIfPossible() { | 555 void Scheduler::DrawIfPossible() { |
551 bool drawing_with_new_active_tree = | 556 bool drawing_with_new_active_tree = |
552 state_machine_.active_tree_needs_first_draw(); | 557 state_machine_.active_tree_needs_first_draw() && |
| 558 !state_machine_.previous_pending_tree_was_impl_side(); |
553 bool main_thread_missed_last_deadline = | 559 bool main_thread_missed_last_deadline = |
554 state_machine_.main_thread_missed_last_deadline(); | 560 state_machine_.main_thread_missed_last_deadline(); |
555 compositor_timing_history_->WillDraw(); | 561 compositor_timing_history_->WillDraw(); |
556 state_machine_.WillDraw(); | 562 state_machine_.WillDraw(); |
557 DrawResult result = client_->ScheduledActionDrawIfPossible(); | 563 DrawResult result = client_->ScheduledActionDrawIfPossible(); |
558 state_machine_.DidDraw(result); | 564 state_machine_.DidDraw(result); |
559 compositor_timing_history_->DidDraw( | 565 compositor_timing_history_->DidDraw( |
560 drawing_with_new_active_tree, main_thread_missed_last_deadline, | 566 drawing_with_new_active_tree, main_thread_missed_last_deadline, |
561 begin_impl_frame_tracker_.DangerousMethodCurrentOrLast().frame_time); | 567 begin_impl_frame_tracker_.DangerousMethodCurrentOrLast().frame_time); |
562 } | 568 } |
563 | 569 |
564 void Scheduler::DrawForced() { | 570 void Scheduler::DrawForced() { |
565 bool drawing_with_new_active_tree = | 571 bool drawing_with_new_active_tree = |
566 state_machine_.active_tree_needs_first_draw(); | 572 state_machine_.active_tree_needs_first_draw() && |
| 573 !state_machine_.previous_pending_tree_was_impl_side(); |
567 bool main_thread_missed_last_deadline = | 574 bool main_thread_missed_last_deadline = |
568 state_machine_.main_thread_missed_last_deadline(); | 575 state_machine_.main_thread_missed_last_deadline(); |
569 compositor_timing_history_->WillDraw(); | 576 compositor_timing_history_->WillDraw(); |
570 state_machine_.WillDraw(); | 577 state_machine_.WillDraw(); |
571 DrawResult result = client_->ScheduledActionDrawForced(); | 578 DrawResult result = client_->ScheduledActionDrawForced(); |
572 state_machine_.DidDraw(result); | 579 state_machine_.DidDraw(result); |
573 compositor_timing_history_->DidDraw( | 580 compositor_timing_history_->DidDraw( |
574 drawing_with_new_active_tree, main_thread_missed_last_deadline, | 581 drawing_with_new_active_tree, main_thread_missed_last_deadline, |
575 begin_impl_frame_tracker_.DangerousMethodCurrentOrLast().frame_time); | 582 begin_impl_frame_tracker_.DangerousMethodCurrentOrLast().frame_time); |
576 } | 583 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
617 state_machine_.WillCommit(commit_has_no_updates); | 624 state_machine_.WillCommit(commit_has_no_updates); |
618 client_->ScheduledActionCommit(); | 625 client_->ScheduledActionCommit(); |
619 break; | 626 break; |
620 } | 627 } |
621 case SchedulerStateMachine::ACTION_ACTIVATE_SYNC_TREE: | 628 case SchedulerStateMachine::ACTION_ACTIVATE_SYNC_TREE: |
622 compositor_timing_history_->WillActivate(); | 629 compositor_timing_history_->WillActivate(); |
623 state_machine_.WillActivate(); | 630 state_machine_.WillActivate(); |
624 client_->ScheduledActionActivateSyncTree(); | 631 client_->ScheduledActionActivateSyncTree(); |
625 compositor_timing_history_->DidActivate(); | 632 compositor_timing_history_->DidActivate(); |
626 break; | 633 break; |
| 634 case SchedulerStateMachine::ACTION_PERFORM_IMPL_SIDE_INVALIDATION: |
| 635 state_machine_.WillPerformImplSideInvalidation(); |
| 636 client_->ScheduledActionPerformImplSideInvalidation(); |
| 637 break; |
627 case SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE: | 638 case SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE: |
628 DrawIfPossible(); | 639 DrawIfPossible(); |
629 break; | 640 break; |
630 case SchedulerStateMachine::ACTION_DRAW_FORCED: | 641 case SchedulerStateMachine::ACTION_DRAW_FORCED: |
631 DrawForced(); | 642 DrawForced(); |
632 break; | 643 break; |
633 case SchedulerStateMachine::ACTION_DRAW_ABORT: { | 644 case SchedulerStateMachine::ACTION_DRAW_ABORT: { |
634 // No action is actually performed, but this allows the state machine to | 645 // No action is actually performed, but this allows the state machine to |
635 // drain the pipeline without actually drawing. | 646 // drain the pipeline without actually drawing. |
636 state_machine_.AbortDraw(); | 647 state_machine_.AbortDraw(); |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
771 } | 782 } |
772 | 783 |
773 bool Scheduler::IsBeginMainFrameSentOrStarted() const { | 784 bool Scheduler::IsBeginMainFrameSentOrStarted() const { |
774 return (state_machine_.begin_main_frame_state() == | 785 return (state_machine_.begin_main_frame_state() == |
775 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_SENT || | 786 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_SENT || |
776 state_machine_.begin_main_frame_state() == | 787 state_machine_.begin_main_frame_state() == |
777 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_STARTED); | 788 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_STARTED); |
778 } | 789 } |
779 | 790 |
780 } // namespace cc | 791 } // namespace cc |
OLD | NEW |