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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 state_machine_.SetNeedsManageTiles(); | 184 state_machine_.SetNeedsManageTiles(); |
185 ProcessScheduledActions(); | 185 ProcessScheduledActions(); |
186 } | 186 } |
187 | 187 |
188 void Scheduler::SetMaxSwapsPending(int max) { | 188 void Scheduler::SetMaxSwapsPending(int max) { |
189 state_machine_.SetMaxSwapsPending(max); | 189 state_machine_.SetMaxSwapsPending(max); |
190 } | 190 } |
191 | 191 |
192 void Scheduler::DidSwapBuffers() { | 192 void Scheduler::DidSwapBuffers() { |
193 state_machine_.DidSwapBuffers(); | 193 state_machine_.DidSwapBuffers(); |
| 194 |
| 195 // Swap should not occur inside readback operation. |
| 196 DCHECK(!IsInsideAction(SchedulerStateMachine::ACTION_DRAW_AND_READBACK)); |
| 197 |
194 // There is no need to call ProcessScheduledActions here because | 198 // There is no need to call ProcessScheduledActions here because |
195 // swapping should not trigger any new actions. | 199 // swapping should not trigger any new actions. |
196 if (!inside_process_scheduled_actions_) { | 200 if (!inside_process_scheduled_actions_) { |
197 DCHECK_EQ(state_machine_.NextAction(), SchedulerStateMachine::ACTION_NONE); | 201 DCHECK_EQ(state_machine_.NextAction(), SchedulerStateMachine::ACTION_NONE); |
198 } | 202 } |
199 } | 203 } |
200 | 204 |
201 void Scheduler::SetSwapUsedIncompleteTile(bool used_incomplete_tile) { | 205 void Scheduler::SetSwapUsedIncompleteTile(bool used_incomplete_tile) { |
202 state_machine_.SetSwapUsedIncompleteTile(used_incomplete_tile); | 206 state_machine_.SetSwapUsedIncompleteTile(used_incomplete_tile); |
203 ProcessScheduledActions(); | 207 ProcessScheduledActions(); |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
594 advance_commit_state_task_.Cancel(); | 598 advance_commit_state_task_.Cancel(); |
595 ProcessScheduledActions(); | 599 ProcessScheduledActions(); |
596 } | 600 } |
597 | 601 |
598 bool Scheduler::IsBeginMainFrameSent() const { | 602 bool Scheduler::IsBeginMainFrameSent() const { |
599 return state_machine_.commit_state() == | 603 return state_machine_.commit_state() == |
600 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT; | 604 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT; |
601 } | 605 } |
602 | 606 |
603 void Scheduler::DrawAndSwapIfPossible() { | 607 void Scheduler::DrawAndSwapIfPossible() { |
604 DrawSwapReadbackResult result = | 608 DrawResult result = client_->ScheduledActionDrawAndSwapIfPossible(); |
605 client_->ScheduledActionDrawAndSwapIfPossible(); | 609 state_machine_.DidDrawIfPossibleCompleted(result); |
606 state_machine_.DidDrawIfPossibleCompleted(result.draw_result); | |
607 } | |
608 | |
609 void Scheduler::DrawAndSwapForced() { | |
610 client_->ScheduledActionDrawAndSwapForced(); | |
611 } | |
612 | |
613 void Scheduler::DrawAndReadback() { | |
614 DrawSwapReadbackResult result = client_->ScheduledActionDrawAndReadback(); | |
615 DCHECK(!result.did_request_swap); | |
616 } | 610 } |
617 | 611 |
618 void Scheduler::ProcessScheduledActions() { | 612 void Scheduler::ProcessScheduledActions() { |
619 // We do not allow ProcessScheduledActions to be recursive. | 613 // We do not allow ProcessScheduledActions to be recursive. |
620 // The top-level call will iteratively execute the next action for us anyway. | 614 // The top-level call will iteratively execute the next action for us anyway. |
621 if (inside_process_scheduled_actions_) | 615 if (inside_process_scheduled_actions_) |
622 return; | 616 return; |
623 | 617 |
624 base::AutoReset<bool> mark_inside(&inside_process_scheduled_actions_, true); | 618 base::AutoReset<bool> mark_inside(&inside_process_scheduled_actions_, true); |
625 | 619 |
(...skipping 23 matching lines...) Expand all Loading... |
649 case SchedulerStateMachine::ACTION_UPDATE_VISIBLE_TILES: | 643 case SchedulerStateMachine::ACTION_UPDATE_VISIBLE_TILES: |
650 client_->ScheduledActionUpdateVisibleTiles(); | 644 client_->ScheduledActionUpdateVisibleTiles(); |
651 break; | 645 break; |
652 case SchedulerStateMachine::ACTION_ACTIVATE_PENDING_TREE: | 646 case SchedulerStateMachine::ACTION_ACTIVATE_PENDING_TREE: |
653 ActivatePendingTree(); | 647 ActivatePendingTree(); |
654 break; | 648 break; |
655 case SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE: | 649 case SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE: |
656 DrawAndSwapIfPossible(); | 650 DrawAndSwapIfPossible(); |
657 break; | 651 break; |
658 case SchedulerStateMachine::ACTION_DRAW_AND_SWAP_FORCED: | 652 case SchedulerStateMachine::ACTION_DRAW_AND_SWAP_FORCED: |
659 DrawAndSwapForced(); | 653 client_->ScheduledActionDrawAndSwapForced(); |
660 break; | 654 break; |
661 case SchedulerStateMachine::ACTION_DRAW_AND_SWAP_ABORT: | 655 case SchedulerStateMachine::ACTION_DRAW_AND_SWAP_ABORT: |
662 // No action is actually performed, but this allows the state machine to | 656 // No action is actually performed, but this allows the state machine to |
663 // advance out of its waiting to draw state without actually drawing. | 657 // advance out of its waiting to draw state without actually drawing. |
664 break; | 658 break; |
665 case SchedulerStateMachine::ACTION_DRAW_AND_READBACK: | 659 case SchedulerStateMachine::ACTION_DRAW_AND_READBACK: |
666 DrawAndReadback(); | 660 client_->ScheduledActionDrawAndReadback(); |
667 break; | 661 break; |
668 case SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION: | 662 case SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION: |
669 client_->ScheduledActionBeginOutputSurfaceCreation(); | 663 client_->ScheduledActionBeginOutputSurfaceCreation(); |
670 break; | 664 break; |
671 case SchedulerStateMachine::ACTION_MANAGE_TILES: | 665 case SchedulerStateMachine::ACTION_MANAGE_TILES: |
672 client_->ScheduledActionManageTiles(); | 666 client_->ScheduledActionManageTiles(); |
673 break; | 667 break; |
674 } | 668 } |
675 } while (action != SchedulerStateMachine::ACTION_NONE); | 669 } while (action != SchedulerStateMachine::ACTION_NONE); |
676 | 670 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
748 } | 742 } |
749 | 743 |
750 bool Scheduler::IsBeginMainFrameSentOrStarted() const { | 744 bool Scheduler::IsBeginMainFrameSentOrStarted() const { |
751 return (state_machine_.commit_state() == | 745 return (state_machine_.commit_state() == |
752 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT || | 746 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT || |
753 state_machine_.commit_state() == | 747 state_machine_.commit_state() == |
754 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED); | 748 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED); |
755 } | 749 } |
756 | 750 |
757 } // namespace cc | 751 } // namespace cc |
OLD | NEW |