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 <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 void Reset() { | 56 void Reset() { |
57 actions_.clear(); | 57 actions_.clear(); |
58 states_.clear(); | 58 states_.clear(); |
59 animate_causes_redraw_ = false; | 59 animate_causes_redraw_ = false; |
60 animate_causes_animate_ = false; | 60 animate_causes_animate_ = false; |
61 will_begin_impl_frame_requests_one_begin_impl_frame_ = false; | 61 will_begin_impl_frame_requests_one_begin_impl_frame_ = false; |
62 draw_will_happen_ = true; | 62 draw_will_happen_ = true; |
63 swap_will_happen_if_draw_happens_ = true; | 63 swap_will_happen_if_draw_happens_ = true; |
64 num_draws_ = 0; | 64 num_draws_ = 0; |
65 begin_frame_args_sent_to_children_ = BeginFrameArgs(); | 65 begin_frame_args_sent_to_children_ = BeginFrameArgs(); |
| 66 last_begin_main_frame_args_ = BeginFrameArgs(); |
66 } | 67 } |
67 | 68 |
68 void set_scheduler(TestScheduler* scheduler) { scheduler_ = scheduler; } | 69 void set_scheduler(TestScheduler* scheduler) { scheduler_ = scheduler; } |
69 | 70 |
70 bool needs_begin_frames() { | 71 bool needs_begin_frames() { |
71 return scheduler_->frame_source().NeedsBeginFrames(); | 72 return scheduler_->frame_source().NeedsBeginFrames(); |
72 } | 73 } |
73 int num_draws() const { return num_draws_; } | 74 int num_draws() const { return num_draws_; } |
74 int num_actions_() const { return static_cast<int>(actions_.size()); } | 75 int num_actions_() const { return static_cast<int>(actions_.size()); } |
75 const char* Action(int i) const { return actions_[i]; } | 76 const char* Action(int i) const { return actions_[i]; } |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 automatic_swap_ack_ = automatic_swap_ack; | 109 automatic_swap_ack_ = automatic_swap_ack; |
109 } | 110 } |
110 // SchedulerClient implementation. | 111 // SchedulerClient implementation. |
111 void WillBeginImplFrame(const BeginFrameArgs& args) override { | 112 void WillBeginImplFrame(const BeginFrameArgs& args) override { |
112 PushAction("WillBeginImplFrame"); | 113 PushAction("WillBeginImplFrame"); |
113 if (will_begin_impl_frame_requests_one_begin_impl_frame_) | 114 if (will_begin_impl_frame_requests_one_begin_impl_frame_) |
114 scheduler_->SetNeedsOneBeginImplFrame(); | 115 scheduler_->SetNeedsOneBeginImplFrame(); |
115 } | 116 } |
116 void DidFinishImplFrame() override {} | 117 void DidFinishImplFrame() override {} |
117 | 118 |
118 void ScheduledActionSendBeginMainFrame() override { | 119 void ScheduledActionSendBeginMainFrame(const BeginFrameArgs& args) override { |
119 PushAction("ScheduledActionSendBeginMainFrame"); | 120 PushAction("ScheduledActionSendBeginMainFrame"); |
| 121 last_begin_main_frame_args_ = args; |
120 } | 122 } |
| 123 |
| 124 const BeginFrameArgs& last_begin_main_frame_args() { |
| 125 return last_begin_main_frame_args_; |
| 126 } |
| 127 |
121 void ScheduledActionAnimate() override { | 128 void ScheduledActionAnimate() override { |
122 PushAction("ScheduledActionAnimate"); | 129 PushAction("ScheduledActionAnimate"); |
123 if (animate_causes_redraw_) | 130 if (animate_causes_redraw_) |
124 scheduler_->SetNeedsRedraw(); | 131 scheduler_->SetNeedsRedraw(); |
125 if (animate_causes_animate_) | 132 if (animate_causes_animate_) |
126 scheduler_->SetNeedsAnimate(); | 133 scheduler_->SetNeedsAnimate(); |
127 } | 134 } |
128 DrawResult ScheduledActionDrawAndSwapIfPossible() override { | 135 DrawResult ScheduledActionDrawAndSwapIfPossible() override { |
129 PushAction("ScheduledActionDrawAndSwapIfPossible"); | 136 PushAction("ScheduledActionDrawAndSwapIfPossible"); |
130 num_draws_++; | 137 num_draws_++; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 } | 204 } |
198 | 205 |
199 bool animate_causes_redraw_; | 206 bool animate_causes_redraw_; |
200 bool animate_causes_animate_; | 207 bool animate_causes_animate_; |
201 bool will_begin_impl_frame_requests_one_begin_impl_frame_; | 208 bool will_begin_impl_frame_requests_one_begin_impl_frame_; |
202 bool draw_will_happen_; | 209 bool draw_will_happen_; |
203 bool swap_will_happen_if_draw_happens_; | 210 bool swap_will_happen_if_draw_happens_; |
204 bool automatic_swap_ack_; | 211 bool automatic_swap_ack_; |
205 int num_draws_; | 212 int num_draws_; |
206 BeginFrameArgs begin_frame_args_sent_to_children_; | 213 BeginFrameArgs begin_frame_args_sent_to_children_; |
| 214 BeginFrameArgs last_begin_main_frame_args_; |
207 base::TimeTicks posted_begin_impl_frame_deadline_; | 215 base::TimeTicks posted_begin_impl_frame_deadline_; |
208 std::vector<const char*> actions_; | 216 std::vector<const char*> actions_; |
209 std::vector<scoped_refptr<base::trace_event::ConvertableToTraceFormat>> | 217 std::vector<scoped_refptr<base::trace_event::ConvertableToTraceFormat>> |
210 states_; | 218 states_; |
211 TestScheduler* scheduler_; | 219 TestScheduler* scheduler_; |
212 }; | 220 }; |
213 | 221 |
214 class FakeExternalBeginFrameSource : public BeginFrameSourceBase { | 222 class FakeExternalBeginFrameSource : public BeginFrameSourceBase { |
215 public: | 223 public: |
216 explicit FakeExternalBeginFrameSource(FakeSchedulerClient* client) | 224 explicit FakeExternalBeginFrameSource(FakeSchedulerClient* client) |
(...skipping 3261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3478 | 3486 |
3479 TEST_F(SchedulerTest, ImplLatencyTakesPriority) { | 3487 TEST_F(SchedulerTest, ImplLatencyTakesPriority) { |
3480 SetUpScheduler(true); | 3488 SetUpScheduler(true); |
3481 scheduler_->SetImplLatencyTakesPriority(true); | 3489 scheduler_->SetImplLatencyTakesPriority(true); |
3482 EXPECT_TRUE(scheduler_->ImplLatencyTakesPriority()); | 3490 EXPECT_TRUE(scheduler_->ImplLatencyTakesPriority()); |
3483 | 3491 |
3484 scheduler_->SetImplLatencyTakesPriority(false); | 3492 scheduler_->SetImplLatencyTakesPriority(false); |
3485 EXPECT_FALSE(scheduler_->ImplLatencyTakesPriority()); | 3493 EXPECT_FALSE(scheduler_->ImplLatencyTakesPriority()); |
3486 } | 3494 } |
3487 | 3495 |
3488 TEST_F(SchedulerTest, BeginFrameArgs_OnCriticalPath) { | 3496 TEST_F(SchedulerTest, BeginMainFrameArgs_OnCriticalPath) { |
3489 scheduler_settings_.use_external_begin_frame_source = true; | 3497 scheduler_settings_.use_external_begin_frame_source = true; |
3490 SetUpScheduler(true); | 3498 SetUpScheduler(true); |
3491 | 3499 |
3492 scheduler_->SetImplLatencyTakesPriority(false); | 3500 scheduler_->SetImplLatencyTakesPriority(false); |
3493 scheduler_->SetChildrenNeedBeginFrames(true); | 3501 scheduler_->SetNeedsBeginMainFrame(); |
3494 | 3502 |
| 3503 client_->Reset(); |
| 3504 EXPECT_FALSE(client_->last_begin_main_frame_args().IsValid()); |
3495 EXPECT_SCOPED(AdvanceFrame()); | 3505 EXPECT_SCOPED(AdvanceFrame()); |
3496 EXPECT_TRUE(client_->begin_frame_is_sent_to_children()); | 3506 EXPECT_TRUE(client_->last_begin_main_frame_args().IsValid()); |
3497 EXPECT_TRUE(client_->begin_frame_args_sent_to_children().on_critical_path); | 3507 EXPECT_TRUE(client_->last_begin_main_frame_args().on_critical_path); |
3498 } | 3508 } |
3499 | 3509 |
3500 TEST_F(SchedulerTest, BeginFrameArgs_NotOnCriticalPath) { | 3510 TEST_F(SchedulerTest, BeginMainFrameArgs_NotOnCriticalPath) { |
3501 scheduler_settings_.use_external_begin_frame_source = true; | 3511 scheduler_settings_.use_external_begin_frame_source = true; |
3502 SetUpScheduler(true); | 3512 SetUpScheduler(true); |
3503 | 3513 |
3504 scheduler_->SetImplLatencyTakesPriority(true); | 3514 scheduler_->SetImplLatencyTakesPriority(true); |
3505 scheduler_->SetChildrenNeedBeginFrames(true); | 3515 scheduler_->SetNeedsBeginMainFrame(); |
3506 | 3516 |
| 3517 client_->Reset(); |
| 3518 EXPECT_FALSE(client_->last_begin_main_frame_args().IsValid()); |
3507 EXPECT_SCOPED(AdvanceFrame()); | 3519 EXPECT_SCOPED(AdvanceFrame()); |
3508 EXPECT_TRUE(client_->begin_frame_is_sent_to_children()); | 3520 EXPECT_TRUE(client_->last_begin_main_frame_args().IsValid()); |
3509 EXPECT_FALSE(client_->begin_frame_args_sent_to_children().on_critical_path); | 3521 EXPECT_FALSE(client_->last_begin_main_frame_args().on_critical_path); |
3510 } | 3522 } |
3511 | 3523 |
3512 } // namespace | 3524 } // namespace |
3513 } // namespace cc | 3525 } // namespace cc |
OLD | NEW |