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