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 #include "base/auto_reset.h" | 8 #include "base/auto_reset.h" |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 void Scheduler::NotifyReadyToActivate() { | 157 void Scheduler::NotifyReadyToActivate() { |
158 state_machine_.NotifyReadyToActivate(); | 158 state_machine_.NotifyReadyToActivate(); |
159 ProcessScheduledActions(); | 159 ProcessScheduledActions(); |
160 } | 160 } |
161 | 161 |
162 void Scheduler::SetNeedsCommit() { | 162 void Scheduler::SetNeedsCommit() { |
163 state_machine_.SetNeedsCommit(); | 163 state_machine_.SetNeedsCommit(); |
164 ProcessScheduledActions(); | 164 ProcessScheduledActions(); |
165 } | 165 } |
166 | 166 |
167 void Scheduler::SetNeedsForcedCommitForReadback() { | |
168 state_machine_.SetNeedsForcedCommitForReadback(); | |
169 ProcessScheduledActions(); | |
170 } | |
171 | |
172 void Scheduler::SetNeedsRedraw() { | 167 void Scheduler::SetNeedsRedraw() { |
173 state_machine_.SetNeedsRedraw(); | 168 state_machine_.SetNeedsRedraw(); |
174 ProcessScheduledActions(); | 169 ProcessScheduledActions(); |
175 } | 170 } |
176 | 171 |
177 void Scheduler::SetNeedsAnimate() { | 172 void Scheduler::SetNeedsAnimate() { |
178 state_machine_.SetNeedsAnimate(); | 173 state_machine_.SetNeedsAnimate(); |
179 ProcessScheduledActions(); | 174 ProcessScheduledActions(); |
180 } | 175 } |
181 | 176 |
182 void Scheduler::SetNeedsManageTiles() { | 177 void Scheduler::SetNeedsManageTiles() { |
183 DCHECK(!IsInsideAction(SchedulerStateMachine::ACTION_MANAGE_TILES)); | 178 DCHECK(!IsInsideAction(SchedulerStateMachine::ACTION_MANAGE_TILES)); |
184 state_machine_.SetNeedsManageTiles(); | 179 state_machine_.SetNeedsManageTiles(); |
185 ProcessScheduledActions(); | 180 ProcessScheduledActions(); |
186 } | 181 } |
187 | 182 |
188 void Scheduler::SetMaxSwapsPending(int max) { | 183 void Scheduler::SetMaxSwapsPending(int max) { |
189 state_machine_.SetMaxSwapsPending(max); | 184 state_machine_.SetMaxSwapsPending(max); |
190 } | 185 } |
191 | 186 |
192 void Scheduler::DidSwapBuffers() { | 187 void Scheduler::DidSwapBuffers() { |
193 state_machine_.DidSwapBuffers(); | 188 state_machine_.DidSwapBuffers(); |
194 | 189 |
195 // Swap should not occur inside readback operation. | |
196 DCHECK(!IsInsideAction(SchedulerStateMachine::ACTION_DRAW_AND_READBACK)); | |
197 | |
198 // There is no need to call ProcessScheduledActions here because | 190 // There is no need to call ProcessScheduledActions here because |
199 // swapping should not trigger any new actions. | 191 // swapping should not trigger any new actions. |
200 if (!inside_process_scheduled_actions_) { | 192 if (!inside_process_scheduled_actions_) { |
201 DCHECK_EQ(state_machine_.NextAction(), SchedulerStateMachine::ACTION_NONE); | 193 DCHECK_EQ(state_machine_.NextAction(), SchedulerStateMachine::ACTION_NONE); |
202 } | 194 } |
203 } | 195 } |
204 | 196 |
205 void Scheduler::SetSwapUsedIncompleteTile(bool used_incomplete_tile) { | 197 void Scheduler::SetSwapUsedIncompleteTile(bool used_incomplete_tile) { |
206 state_machine_.SetSwapUsedIncompleteTile(used_incomplete_tile); | 198 state_machine_.SetSwapUsedIncompleteTile(used_incomplete_tile); |
207 ProcessScheduledActions(); | 199 ProcessScheduledActions(); |
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
611 void Scheduler::ProcessScheduledActions() { | 603 void Scheduler::ProcessScheduledActions() { |
612 // We do not allow ProcessScheduledActions to be recursive. | 604 // We do not allow ProcessScheduledActions to be recursive. |
613 // The top-level call will iteratively execute the next action for us anyway. | 605 // The top-level call will iteratively execute the next action for us anyway. |
614 if (inside_process_scheduled_actions_) | 606 if (inside_process_scheduled_actions_) |
615 return; | 607 return; |
616 | 608 |
617 base::AutoReset<bool> mark_inside(&inside_process_scheduled_actions_, true); | 609 base::AutoReset<bool> mark_inside(&inside_process_scheduled_actions_, true); |
618 | 610 |
619 SchedulerStateMachine::Action action; | 611 SchedulerStateMachine::Action action; |
620 do { | 612 do { |
621 state_machine_.CheckInvariants(); | |
622 action = state_machine_.NextAction(); | 613 action = state_machine_.NextAction(); |
623 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler"), | 614 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler"), |
624 "SchedulerStateMachine", | 615 "SchedulerStateMachine", |
625 "state", | 616 "state", |
626 ToTrace(this)); | 617 ToTrace(this)); |
627 state_machine_.UpdateState(action); | 618 state_machine_.UpdateState(action); |
628 base::AutoReset<SchedulerStateMachine::Action> | 619 base::AutoReset<SchedulerStateMachine::Action> |
629 mark_inside_action(&inside_action_, action); | 620 mark_inside_action(&inside_action_, action); |
630 switch (action) { | 621 switch (action) { |
631 case SchedulerStateMachine::ACTION_NONE: | 622 case SchedulerStateMachine::ACTION_NONE: |
(...skipping 16 matching lines...) Expand all Loading... |
648 case SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE: | 639 case SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE: |
649 DrawAndSwapIfPossible(); | 640 DrawAndSwapIfPossible(); |
650 break; | 641 break; |
651 case SchedulerStateMachine::ACTION_DRAW_AND_SWAP_FORCED: | 642 case SchedulerStateMachine::ACTION_DRAW_AND_SWAP_FORCED: |
652 client_->ScheduledActionDrawAndSwapForced(); | 643 client_->ScheduledActionDrawAndSwapForced(); |
653 break; | 644 break; |
654 case SchedulerStateMachine::ACTION_DRAW_AND_SWAP_ABORT: | 645 case SchedulerStateMachine::ACTION_DRAW_AND_SWAP_ABORT: |
655 // No action is actually performed, but this allows the state machine to | 646 // No action is actually performed, but this allows the state machine to |
656 // advance out of its waiting to draw state without actually drawing. | 647 // advance out of its waiting to draw state without actually drawing. |
657 break; | 648 break; |
658 case SchedulerStateMachine::ACTION_DRAW_AND_READBACK: | |
659 client_->ScheduledActionDrawAndReadback(); | |
660 break; | |
661 case SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION: | 649 case SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION: |
662 client_->ScheduledActionBeginOutputSurfaceCreation(); | 650 client_->ScheduledActionBeginOutputSurfaceCreation(); |
663 break; | 651 break; |
664 case SchedulerStateMachine::ACTION_MANAGE_TILES: | 652 case SchedulerStateMachine::ACTION_MANAGE_TILES: |
665 client_->ScheduledActionManageTiles(); | 653 client_->ScheduledActionManageTiles(); |
666 break; | 654 break; |
667 } | 655 } |
668 } while (action != SchedulerStateMachine::ACTION_NONE); | 656 } while (action != SchedulerStateMachine::ACTION_NONE); |
669 | 657 |
670 SetupNextBeginFrameIfNeeded(); | 658 SetupNextBeginFrameIfNeeded(); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
744 } | 732 } |
745 | 733 |
746 bool Scheduler::IsBeginMainFrameSentOrStarted() const { | 734 bool Scheduler::IsBeginMainFrameSentOrStarted() const { |
747 return (state_machine_.commit_state() == | 735 return (state_machine_.commit_state() == |
748 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT || | 736 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT || |
749 state_machine_.commit_state() == | 737 state_machine_.commit_state() == |
750 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED); | 738 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED); |
751 } | 739 } |
752 | 740 |
753 } // namespace cc | 741 } // namespace cc |
OLD | NEW |