| 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 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 622 | 622 |
| 623 base::AutoReset<bool> mark_inside(&inside_process_scheduled_actions_, true); | 623 base::AutoReset<bool> mark_inside(&inside_process_scheduled_actions_, true); |
| 624 | 624 |
| 625 SchedulerStateMachine::Action action; | 625 SchedulerStateMachine::Action action; |
| 626 do { | 626 do { |
| 627 action = state_machine_.NextAction(); | 627 action = state_machine_.NextAction(); |
| 628 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler"), | 628 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler"), |
| 629 "SchedulerStateMachine", | 629 "SchedulerStateMachine", |
| 630 "state", | 630 "state", |
| 631 AsValue()); | 631 AsValue()); |
| 632 state_machine_.UpdateState(action); | |
| 633 base::AutoReset<SchedulerStateMachine::Action> | 632 base::AutoReset<SchedulerStateMachine::Action> |
| 634 mark_inside_action(&inside_action_, action); | 633 mark_inside_action(&inside_action_, action); |
| 635 switch (action) { | 634 switch (action) { |
| 636 case SchedulerStateMachine::ACTION_NONE: | 635 case SchedulerStateMachine::ACTION_NONE: |
| 637 break; | 636 break; |
| 638 case SchedulerStateMachine::ACTION_ANIMATE: | 637 case SchedulerStateMachine::ACTION_ANIMATE: |
| 638 state_machine_.WillAnimate(); |
| 639 client_->ScheduledActionAnimate(); | 639 client_->ScheduledActionAnimate(); |
| 640 break; | 640 break; |
| 641 case SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME: | 641 case SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME: |
| 642 compositor_timing_history_->WillBeginMainFrame(); | 642 compositor_timing_history_->WillBeginMainFrame(); |
| 643 state_machine_.WillSendBeginMainFrame(); |
| 643 client_->ScheduledActionSendBeginMainFrame(); | 644 client_->ScheduledActionSendBeginMainFrame(); |
| 644 break; | 645 break; |
| 645 case SchedulerStateMachine::ACTION_COMMIT: { | 646 case SchedulerStateMachine::ACTION_COMMIT: { |
| 646 // TODO(robliao): Remove ScopedTracker below once crbug.com/461509 is | 647 // TODO(robliao): Remove ScopedTracker below once crbug.com/461509 is |
| 647 // fixed. | 648 // fixed. |
| 648 tracked_objects::ScopedTracker tracking_profile4( | 649 tracked_objects::ScopedTracker tracking_profile4( |
| 649 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 650 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 650 "461509 Scheduler::ProcessScheduledActions4")); | 651 "461509 Scheduler::ProcessScheduledActions4")); |
| 652 bool commit_has_no_updates = false; |
| 653 state_machine_.WillCommit(commit_has_no_updates); |
| 651 client_->ScheduledActionCommit(); | 654 client_->ScheduledActionCommit(); |
| 652 break; | 655 break; |
| 653 } | 656 } |
| 654 case SchedulerStateMachine::ACTION_ACTIVATE_SYNC_TREE: | 657 case SchedulerStateMachine::ACTION_ACTIVATE_SYNC_TREE: |
| 655 compositor_timing_history_->WillActivate(); | 658 compositor_timing_history_->WillActivate(); |
| 659 state_machine_.WillActivate(); |
| 656 client_->ScheduledActionActivateSyncTree(); | 660 client_->ScheduledActionActivateSyncTree(); |
| 657 compositor_timing_history_->DidActivate(); | 661 compositor_timing_history_->DidActivate(); |
| 658 break; | 662 break; |
| 659 case SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE: { | 663 case SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE: { |
| 660 // TODO(robliao): Remove ScopedTracker below once crbug.com/461509 is | 664 // TODO(robliao): Remove ScopedTracker below once crbug.com/461509 is |
| 661 // fixed. | 665 // fixed. |
| 662 tracked_objects::ScopedTracker tracking_profile6( | 666 tracked_objects::ScopedTracker tracking_profile6( |
| 663 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 667 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 664 "461509 Scheduler::ProcessScheduledActions6")); | 668 "461509 Scheduler::ProcessScheduledActions6")); |
| 669 bool did_request_swap = true; |
| 670 state_machine_.WillDraw(did_request_swap); |
| 665 DrawAndSwapIfPossible(); | 671 DrawAndSwapIfPossible(); |
| 666 break; | 672 break; |
| 667 } | 673 } |
| 668 case SchedulerStateMachine::ACTION_DRAW_AND_SWAP_FORCED: | 674 case SchedulerStateMachine::ACTION_DRAW_AND_SWAP_FORCED: { |
| 675 bool did_request_swap = true; |
| 676 state_machine_.WillDraw(did_request_swap); |
| 669 DrawAndSwapForced(); | 677 DrawAndSwapForced(); |
| 670 break; | 678 break; |
| 671 case SchedulerStateMachine::ACTION_DRAW_AND_SWAP_ABORT: | 679 } |
| 680 case SchedulerStateMachine::ACTION_DRAW_AND_SWAP_ABORT: { |
| 672 // No action is actually performed, but this allows the state machine to | 681 // No action is actually performed, but this allows the state machine to |
| 673 // advance out of its waiting to draw state without actually drawing. | 682 // advance out of its waiting to draw state without actually drawing. |
| 683 bool did_request_swap = false; |
| 684 state_machine_.WillDraw(did_request_swap); |
| 674 break; | 685 break; |
| 686 } |
| 675 case SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION: | 687 case SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION: |
| 688 state_machine_.WillBeginOutputSurfaceCreation(); |
| 676 client_->ScheduledActionBeginOutputSurfaceCreation(); | 689 client_->ScheduledActionBeginOutputSurfaceCreation(); |
| 677 break; | 690 break; |
| 678 case SchedulerStateMachine::ACTION_PREPARE_TILES: | 691 case SchedulerStateMachine::ACTION_PREPARE_TILES: |
| 692 state_machine_.WillPrepareTiles(); |
| 679 client_->ScheduledActionPrepareTiles(); | 693 client_->ScheduledActionPrepareTiles(); |
| 680 break; | 694 break; |
| 681 case SchedulerStateMachine::ACTION_INVALIDATE_OUTPUT_SURFACE: { | 695 case SchedulerStateMachine::ACTION_INVALIDATE_OUTPUT_SURFACE: { |
| 696 state_machine_.WillInvalidateOutputSurface(); |
| 682 client_->ScheduledActionInvalidateOutputSurface(); | 697 client_->ScheduledActionInvalidateOutputSurface(); |
| 683 break; | 698 break; |
| 684 } | 699 } |
| 685 } | 700 } |
| 686 } while (action != SchedulerStateMachine::ACTION_NONE); | 701 } while (action != SchedulerStateMachine::ACTION_NONE); |
| 687 | 702 |
| 688 ScheduleBeginImplFrameDeadlineIfNeeded(); | 703 ScheduleBeginImplFrameDeadlineIfNeeded(); |
| 689 SetupNextBeginFrameIfNeeded(); | 704 SetupNextBeginFrameIfNeeded(); |
| 690 } | 705 } |
| 691 | 706 |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 810 } | 825 } |
| 811 | 826 |
| 812 bool Scheduler::IsBeginMainFrameSentOrStarted() const { | 827 bool Scheduler::IsBeginMainFrameSentOrStarted() const { |
| 813 return (state_machine_.begin_main_frame_state() == | 828 return (state_machine_.begin_main_frame_state() == |
| 814 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_SENT || | 829 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_SENT || |
| 815 state_machine_.begin_main_frame_state() == | 830 state_machine_.begin_main_frame_state() == |
| 816 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_STARTED); | 831 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_STARTED); |
| 817 } | 832 } |
| 818 | 833 |
| 819 } // namespace cc | 834 } // namespace cc |
| OLD | NEW |