| 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 #include "cc/scheduler/scheduler.h" | 4 #include "cc/scheduler/scheduler.h" |
| 5 | 5 |
| 6 #include <string> | 6 #include <string> |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/scoped_vector.h" | 10 #include "base/memory/scoped_vector.h" |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 virtual void ScheduledActionSendBeginMainFrame() OVERRIDE { | 103 virtual void ScheduledActionSendBeginMainFrame() OVERRIDE { |
| 104 actions_.push_back("ScheduledActionSendBeginMainFrame"); | 104 actions_.push_back("ScheduledActionSendBeginMainFrame"); |
| 105 states_.push_back(scheduler_->StateAsValue().release()); | 105 states_.push_back(scheduler_->StateAsValue().release()); |
| 106 } | 106 } |
| 107 virtual DrawSwapReadbackResult ScheduledActionDrawAndSwapIfPossible() | 107 virtual DrawSwapReadbackResult ScheduledActionDrawAndSwapIfPossible() |
| 108 OVERRIDE { | 108 OVERRIDE { |
| 109 actions_.push_back("ScheduledActionDrawAndSwapIfPossible"); | 109 actions_.push_back("ScheduledActionDrawAndSwapIfPossible"); |
| 110 states_.push_back(scheduler_->StateAsValue().release()); | 110 states_.push_back(scheduler_->StateAsValue().release()); |
| 111 num_draws_++; | 111 num_draws_++; |
| 112 bool did_readback = false; | 112 bool did_readback = false; |
| 113 DrawSwapReadbackResult::DrawResult result = |
| 114 draw_will_happen_ |
| 115 ? DrawSwapReadbackResult::DRAW_SUCCESS |
| 116 : DrawSwapReadbackResult::DRAW_ABORTED_CHECKERBOARD_ANIMATIONS; |
| 113 return DrawSwapReadbackResult( | 117 return DrawSwapReadbackResult( |
| 114 draw_will_happen_, | 118 result, |
| 115 draw_will_happen_ && swap_will_happen_if_draw_happens_, | 119 draw_will_happen_ && swap_will_happen_if_draw_happens_, |
| 116 did_readback); | 120 did_readback); |
| 117 } | 121 } |
| 118 virtual DrawSwapReadbackResult ScheduledActionDrawAndSwapForced() OVERRIDE { | 122 virtual DrawSwapReadbackResult ScheduledActionDrawAndSwapForced() OVERRIDE { |
| 119 actions_.push_back("ScheduledActionDrawAndSwapForced"); | 123 actions_.push_back("ScheduledActionDrawAndSwapForced"); |
| 120 states_.push_back(scheduler_->StateAsValue().release()); | 124 states_.push_back(scheduler_->StateAsValue().release()); |
| 121 bool did_draw = true; | |
| 122 bool did_swap = swap_will_happen_if_draw_happens_; | 125 bool did_swap = swap_will_happen_if_draw_happens_; |
| 123 bool did_readback = false; | 126 bool did_readback = false; |
| 124 return DrawSwapReadbackResult(did_draw, did_swap, did_readback); | 127 return DrawSwapReadbackResult( |
| 128 DrawSwapReadbackResult::DRAW_SUCCESS, did_swap, did_readback); |
| 125 } | 129 } |
| 126 virtual DrawSwapReadbackResult ScheduledActionDrawAndReadback() OVERRIDE { | 130 virtual DrawSwapReadbackResult ScheduledActionDrawAndReadback() OVERRIDE { |
| 127 actions_.push_back("ScheduledActionDrawAndReadback"); | 131 actions_.push_back("ScheduledActionDrawAndReadback"); |
| 128 states_.push_back(scheduler_->StateAsValue().release()); | 132 states_.push_back(scheduler_->StateAsValue().release()); |
| 129 bool did_draw = true; | |
| 130 bool did_swap = false; | 133 bool did_swap = false; |
| 131 bool did_readback = true; | 134 bool did_readback = true; |
| 132 return DrawSwapReadbackResult(did_draw, did_swap, did_readback); | 135 return DrawSwapReadbackResult( |
| 136 DrawSwapReadbackResult::DRAW_SUCCESS, did_swap, did_readback); |
| 133 } | 137 } |
| 134 virtual void ScheduledActionCommit() OVERRIDE { | 138 virtual void ScheduledActionCommit() OVERRIDE { |
| 135 actions_.push_back("ScheduledActionCommit"); | 139 actions_.push_back("ScheduledActionCommit"); |
| 136 states_.push_back(scheduler_->StateAsValue().release()); | 140 states_.push_back(scheduler_->StateAsValue().release()); |
| 137 } | 141 } |
| 138 virtual void ScheduledActionUpdateVisibleTiles() OVERRIDE { | 142 virtual void ScheduledActionUpdateVisibleTiles() OVERRIDE { |
| 139 actions_.push_back("ScheduledActionUpdateVisibleTiles"); | 143 actions_.push_back("ScheduledActionUpdateVisibleTiles"); |
| 140 states_.push_back(scheduler_->StateAsValue().release()); | 144 states_.push_back(scheduler_->StateAsValue().release()); |
| 141 } | 145 } |
| 142 virtual void ScheduledActionActivatePendingTree() OVERRIDE { | 146 virtual void ScheduledActionActivatePendingTree() OVERRIDE { |
| (...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 682 virtual DrawSwapReadbackResult ScheduledActionDrawAndSwapIfPossible() | 686 virtual DrawSwapReadbackResult ScheduledActionDrawAndSwapIfPossible() |
| 683 OVERRIDE { | 687 OVERRIDE { |
| 684 // Only SetNeedsRedraw the first time this is called | 688 // Only SetNeedsRedraw the first time this is called |
| 685 if (!num_draws_) | 689 if (!num_draws_) |
| 686 scheduler_->SetNeedsRedraw(); | 690 scheduler_->SetNeedsRedraw(); |
| 687 return FakeSchedulerClient::ScheduledActionDrawAndSwapIfPossible(); | 691 return FakeSchedulerClient::ScheduledActionDrawAndSwapIfPossible(); |
| 688 } | 692 } |
| 689 | 693 |
| 690 virtual DrawSwapReadbackResult ScheduledActionDrawAndSwapForced() OVERRIDE { | 694 virtual DrawSwapReadbackResult ScheduledActionDrawAndSwapForced() OVERRIDE { |
| 691 NOTREACHED(); | 695 NOTREACHED(); |
| 692 bool did_draw = true; | |
| 693 bool did_swap = true; | 696 bool did_swap = true; |
| 694 bool did_readback = false; | 697 bool did_readback = false; |
| 695 return DrawSwapReadbackResult(did_draw, did_swap, did_readback); | 698 return DrawSwapReadbackResult( |
| 699 DrawSwapReadbackResult::DRAW_SUCCESS, did_swap, did_readback); |
| 696 } | 700 } |
| 697 | 701 |
| 698 virtual void ScheduledActionCommit() OVERRIDE {} | 702 virtual void ScheduledActionCommit() OVERRIDE {} |
| 699 virtual void ScheduledActionBeginOutputSurfaceCreation() OVERRIDE {} | 703 virtual void ScheduledActionBeginOutputSurfaceCreation() OVERRIDE {} |
| 700 virtual void DidAnticipatedDrawTimeChange(base::TimeTicks) OVERRIDE {} | 704 virtual void DidAnticipatedDrawTimeChange(base::TimeTicks) OVERRIDE {} |
| 701 }; | 705 }; |
| 702 | 706 |
| 703 // Tests for two different situations: | 707 // Tests for two different situations: |
| 704 // 1. the scheduler dropping SetNeedsRedraw requests that happen inside | 708 // 1. the scheduler dropping SetNeedsRedraw requests that happen inside |
| 705 // a ScheduledActionDrawAndSwap | 709 // a ScheduledActionDrawAndSwap |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 798 // Only SetNeedsCommit the first time this is called | 802 // Only SetNeedsCommit the first time this is called |
| 799 if (set_needs_commit_on_next_draw_) { | 803 if (set_needs_commit_on_next_draw_) { |
| 800 scheduler_->SetNeedsCommit(); | 804 scheduler_->SetNeedsCommit(); |
| 801 set_needs_commit_on_next_draw_ = false; | 805 set_needs_commit_on_next_draw_ = false; |
| 802 } | 806 } |
| 803 return FakeSchedulerClient::ScheduledActionDrawAndSwapIfPossible(); | 807 return FakeSchedulerClient::ScheduledActionDrawAndSwapIfPossible(); |
| 804 } | 808 } |
| 805 | 809 |
| 806 virtual DrawSwapReadbackResult ScheduledActionDrawAndSwapForced() OVERRIDE { | 810 virtual DrawSwapReadbackResult ScheduledActionDrawAndSwapForced() OVERRIDE { |
| 807 NOTREACHED(); | 811 NOTREACHED(); |
| 808 bool did_draw = true; | |
| 809 bool did_swap = false; | 812 bool did_swap = false; |
| 810 bool did_readback = false; | 813 bool did_readback = false; |
| 811 return DrawSwapReadbackResult(did_draw, did_swap, did_readback); | 814 return DrawSwapReadbackResult( |
| 815 DrawSwapReadbackResult::DRAW_SUCCESS, did_swap, did_readback); |
| 812 } | 816 } |
| 813 | 817 |
| 814 virtual void ScheduledActionCommit() OVERRIDE {} | 818 virtual void ScheduledActionCommit() OVERRIDE {} |
| 815 virtual void ScheduledActionBeginOutputSurfaceCreation() OVERRIDE {} | 819 virtual void ScheduledActionBeginOutputSurfaceCreation() OVERRIDE {} |
| 816 virtual void DidAnticipatedDrawTimeChange(base::TimeTicks) OVERRIDE {} | 820 virtual void DidAnticipatedDrawTimeChange(base::TimeTicks) OVERRIDE {} |
| 817 | 821 |
| 818 void SetNeedsCommitOnNextDraw() { set_needs_commit_on_next_draw_ = true; } | 822 void SetNeedsCommitOnNextDraw() { set_needs_commit_on_next_draw_ = true; } |
| 819 | 823 |
| 820 private: | 824 private: |
| 821 bool set_needs_commit_on_next_draw_; | 825 bool set_needs_commit_on_next_draw_; |
| (...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1334 SpinForMillis(interval * 2); | 1338 SpinForMillis(interval * 2); |
| 1335 EXPECT_GT(client.num_actions_(), actions_so_far); | 1339 EXPECT_GT(client.num_actions_(), actions_so_far); |
| 1336 EXPECT_STREQ(client.Action(client.num_actions_() - 1), | 1340 EXPECT_STREQ(client.Action(client.num_actions_() - 1), |
| 1337 "DidAnticipatedDrawTimeChange"); | 1341 "DidAnticipatedDrawTimeChange"); |
| 1338 actions_so_far = client.num_actions_(); | 1342 actions_so_far = client.num_actions_(); |
| 1339 } | 1343 } |
| 1340 } | 1344 } |
| 1341 | 1345 |
| 1342 } // namespace | 1346 } // namespace |
| 1343 } // namespace cc | 1347 } // namespace cc |
| OLD | NEW |