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/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 EXPECT_TRUE(task_runner().RunTasksWhile(ImplFrameDeadlinePending(false))); | 184 EXPECT_TRUE(task_runner().RunTasksWhile(ImplFrameDeadlinePending(false))); |
185 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); | 185 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); |
186 } | 186 } |
187 | 187 |
188 void SendNextBeginFrame() { | 188 void SendNextBeginFrame() { |
189 DCHECK(ExternalBeginFrame()); | 189 DCHECK(ExternalBeginFrame()); |
190 // Creep the time forward so that any BeginFrameArgs is not equal to the | 190 // Creep the time forward so that any BeginFrameArgs is not equal to the |
191 // last one otherwise we violate the BeginFrameSource contract. | 191 // last one otherwise we violate the BeginFrameSource contract. |
192 now_src_->AdvanceNow(BeginFrameArgs::DefaultInterval()); | 192 now_src_->AdvanceNow(BeginFrameArgs::DefaultInterval()); |
193 fake_external_begin_frame_source_->TestOnBeginFrame( | 193 fake_external_begin_frame_source_->TestOnBeginFrame( |
194 CreateBeginFrameArgsForTesting(now_src_)); | 194 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now_src_)); |
195 } | 195 } |
196 | 196 |
197 OrderedSimpleTaskRunner& task_runner() { return *task_runner_; } | 197 OrderedSimpleTaskRunner& task_runner() { return *task_runner_; } |
198 TestNowSource* now_src() { return now_src_.get(); } | 198 TestNowSource* now_src() { return now_src_.get(); } |
199 | 199 |
200 int ActionIndex(const char* action) const { | 200 int ActionIndex(const char* action) const { |
201 for (size_t i = 0; i < actions_.size(); i++) | 201 for (size_t i = 0; i < actions_.size(); i++) |
202 if (!strcmp(actions_[i], action)) | 202 if (!strcmp(actions_[i], action)) |
203 return i; | 203 return i; |
204 return -1; | 204 return -1; |
(...skipping 968 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1173 scheduler->SetCanStart(); | 1173 scheduler->SetCanStart(); |
1174 scheduler->SetVisible(true); | 1174 scheduler->SetVisible(true); |
1175 scheduler->DidCreateAndInitializeOutputSurface(); | 1175 scheduler->DidCreateAndInitializeOutputSurface(); |
1176 | 1176 |
1177 scheduler->SetNeedsCommit(); | 1177 scheduler->SetNeedsCommit(); |
1178 EXPECT_TRUE(scheduler->CommitPending()); | 1178 EXPECT_TRUE(scheduler->CommitPending()); |
1179 scheduler->NotifyBeginMainFrameStarted(); | 1179 scheduler->NotifyBeginMainFrameStarted(); |
1180 scheduler->NotifyReadyToCommit(); | 1180 scheduler->NotifyReadyToCommit(); |
1181 scheduler->SetNeedsRedraw(); | 1181 scheduler->SetNeedsRedraw(); |
1182 | 1182 |
1183 BeginFrameArgs frame_args = CreateBeginFrameArgsForTesting(client.now_src()); | 1183 BeginFrameArgs frame_args = |
| 1184 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, client.now_src()); |
1184 frame_args.interval = base::TimeDelta::FromMilliseconds(1000); | 1185 frame_args.interval = base::TimeDelta::FromMilliseconds(1000); |
1185 client.fake_external_begin_frame_source()->TestOnBeginFrame(frame_args); | 1186 client.fake_external_begin_frame_source()->TestOnBeginFrame(frame_args); |
1186 | 1187 |
1187 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); | 1188 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
1188 client.task_runner().RunPendingTasks(); // Run posted deadline. | 1189 client.task_runner().RunPendingTasks(); // Run posted deadline. |
1189 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); | 1190 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); |
1190 | 1191 |
1191 scheduler->DidSwapBuffers(); | 1192 scheduler->DidSwapBuffers(); |
1192 scheduler->DidSwapBuffersComplete(); | 1193 scheduler->DidSwapBuffersComplete(); |
1193 | 1194 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1246 InitializeOutputSurfaceAndFirstCommit(scheduler, &client); | 1247 InitializeOutputSurfaceAndFirstCommit(scheduler, &client); |
1247 | 1248 |
1248 // SetNeedsCommit should begin the frame on the next BeginImplFrame. | 1249 // SetNeedsCommit should begin the frame on the next BeginImplFrame. |
1249 client.Reset(); | 1250 client.Reset(); |
1250 scheduler->SetNeedsCommit(); | 1251 scheduler->SetNeedsCommit(); |
1251 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client); | 1252 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client); |
1252 client.Reset(); | 1253 client.Reset(); |
1253 | 1254 |
1254 // Create a BeginFrame with a long deadline to avoid race conditions. | 1255 // Create a BeginFrame with a long deadline to avoid race conditions. |
1255 // This is the first BeginFrame, which will be handled immediately. | 1256 // This is the first BeginFrame, which will be handled immediately. |
1256 BeginFrameArgs args = CreateBeginFrameArgsForTesting(client.now_src()); | 1257 BeginFrameArgs args = |
| 1258 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, client.now_src()); |
1257 args.deadline += base::TimeDelta::FromHours(1); | 1259 args.deadline += base::TimeDelta::FromHours(1); |
1258 client.fake_external_begin_frame_source()->TestOnBeginFrame(args); | 1260 client.fake_external_begin_frame_source()->TestOnBeginFrame(args); |
1259 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); | 1261 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); |
1260 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2); | 1262 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2); |
1261 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); | 1263 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
1262 EXPECT_TRUE(client.needs_begin_frames()); | 1264 EXPECT_TRUE(client.needs_begin_frames()); |
1263 client.Reset(); | 1265 client.Reset(); |
1264 | 1266 |
1265 // Queue BeginFrames while we are still handling the previous BeginFrame. | 1267 // Queue BeginFrames while we are still handling the previous BeginFrame. |
1266 args.frame_time += base::TimeDelta::FromSeconds(1); | 1268 args.frame_time += base::TimeDelta::FromSeconds(1); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1324 client.SetAutomaticSwapAck(false); | 1326 client.SetAutomaticSwapAck(false); |
1325 | 1327 |
1326 // SetNeedsCommit should begin the frame on the next BeginImplFrame. | 1328 // SetNeedsCommit should begin the frame on the next BeginImplFrame. |
1327 client.Reset(); | 1329 client.Reset(); |
1328 scheduler->SetNeedsCommit(); | 1330 scheduler->SetNeedsCommit(); |
1329 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client); | 1331 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client); |
1330 client.Reset(); | 1332 client.Reset(); |
1331 | 1333 |
1332 // Create a BeginFrame with a long deadline to avoid race conditions. | 1334 // Create a BeginFrame with a long deadline to avoid race conditions. |
1333 // This is the first BeginFrame, which will be handled immediately. | 1335 // This is the first BeginFrame, which will be handled immediately. |
1334 BeginFrameArgs args = CreateBeginFrameArgsForTesting(client.now_src()); | 1336 BeginFrameArgs args = |
| 1337 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, client.now_src()); |
1335 args.deadline += base::TimeDelta::FromHours(1); | 1338 args.deadline += base::TimeDelta::FromHours(1); |
1336 client.fake_external_begin_frame_source()->TestOnBeginFrame(args); | 1339 client.fake_external_begin_frame_source()->TestOnBeginFrame(args); |
1337 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); | 1340 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); |
1338 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2); | 1341 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2); |
1339 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); | 1342 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
1340 EXPECT_TRUE(client.needs_begin_frames()); | 1343 EXPECT_TRUE(client.needs_begin_frames()); |
1341 client.Reset(); | 1344 client.Reset(); |
1342 | 1345 |
1343 // Queue BeginFrame while we are still handling the previous BeginFrame. | 1346 // Queue BeginFrame while we are still handling the previous BeginFrame. |
1344 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); | 1347 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1924 InitializeOutputSurfaceAndFirstCommit(scheduler, &client); | 1927 InitializeOutputSurfaceAndFirstCommit(scheduler, &client); |
1925 | 1928 |
1926 // SetNeedsCommit should begin the frame on the next BeginImplFrame. | 1929 // SetNeedsCommit should begin the frame on the next BeginImplFrame. |
1927 client.Reset(); | 1930 client.Reset(); |
1928 scheduler->SetNeedsCommit(); | 1931 scheduler->SetNeedsCommit(); |
1929 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client); | 1932 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client); |
1930 | 1933 |
1931 // Create a BeginFrame with a long deadline to avoid race conditions. | 1934 // Create a BeginFrame with a long deadline to avoid race conditions. |
1932 // This is the first BeginFrame, which will be handled immediately. | 1935 // This is the first BeginFrame, which will be handled immediately. |
1933 client.Reset(); | 1936 client.Reset(); |
1934 BeginFrameArgs args = CreateBeginFrameArgsForTesting(client.now_src()); | 1937 BeginFrameArgs args = |
| 1938 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, client.now_src()); |
1935 args.deadline += base::TimeDelta::FromHours(1); | 1939 args.deadline += base::TimeDelta::FromHours(1); |
1936 client.fake_external_begin_frame_source()->TestOnBeginFrame(args); | 1940 client.fake_external_begin_frame_source()->TestOnBeginFrame(args); |
1937 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); | 1941 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); |
1938 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2); | 1942 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2); |
1939 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); | 1943 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
1940 EXPECT_TRUE(client.needs_begin_frames()); | 1944 EXPECT_TRUE(client.needs_begin_frames()); |
1941 | 1945 |
1942 // Queue BeginFrames while we are still handling the previous BeginFrame. | 1946 // Queue BeginFrames while we are still handling the previous BeginFrame. |
1943 args.frame_time += base::TimeDelta::FromSeconds(1); | 1947 args.frame_time += base::TimeDelta::FromSeconds(1); |
1944 client.fake_external_begin_frame_source()->TestOnBeginFrame(args); | 1948 client.fake_external_begin_frame_source()->TestOnBeginFrame(args); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1983 InitializeOutputSurfaceAndFirstCommit(scheduler, &client); | 1987 InitializeOutputSurfaceAndFirstCommit(scheduler, &client); |
1984 | 1988 |
1985 // SetNeedsCommit should begin the frame on the next BeginImplFrame. | 1989 // SetNeedsCommit should begin the frame on the next BeginImplFrame. |
1986 client.Reset(); | 1990 client.Reset(); |
1987 scheduler->SetNeedsCommit(); | 1991 scheduler->SetNeedsCommit(); |
1988 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client); | 1992 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client); |
1989 | 1993 |
1990 // Create a BeginFrame with a long deadline to avoid race conditions. | 1994 // Create a BeginFrame with a long deadline to avoid race conditions. |
1991 // This is the first BeginFrame, which will be handled immediately. | 1995 // This is the first BeginFrame, which will be handled immediately. |
1992 client.Reset(); | 1996 client.Reset(); |
1993 BeginFrameArgs args = CreateBeginFrameArgsForTesting(client.now_src()); | 1997 BeginFrameArgs args = |
| 1998 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, client.now_src()); |
1994 args.deadline += base::TimeDelta::FromHours(1); | 1999 args.deadline += base::TimeDelta::FromHours(1); |
1995 client.fake_external_begin_frame_source()->TestOnBeginFrame(args); | 2000 client.fake_external_begin_frame_source()->TestOnBeginFrame(args); |
1996 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); | 2001 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); |
1997 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2); | 2002 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2); |
1998 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); | 2003 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
1999 EXPECT_TRUE(client.needs_begin_frames()); | 2004 EXPECT_TRUE(client.needs_begin_frames()); |
2000 | 2005 |
2001 // Queue BeginFrames while we are still handling the previous BeginFrame. | 2006 // Queue BeginFrames while we are still handling the previous BeginFrame. |
2002 args.frame_time += base::TimeDelta::FromSeconds(1); | 2007 args.frame_time += base::TimeDelta::FromSeconds(1); |
2003 client.fake_external_begin_frame_source()->TestOnBeginFrame(args); | 2008 client.fake_external_begin_frame_source()->TestOnBeginFrame(args); |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2266 | 2271 |
2267 // Deadline task is pending | 2272 // Deadline task is pending |
2268 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); | 2273 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
2269 client.task_runner().RunPendingTasks(); | 2274 client.task_runner().RunPendingTasks(); |
2270 // Deadline task runs immediately | 2275 // Deadline task runs immediately |
2271 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); | 2276 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); |
2272 } | 2277 } |
2273 | 2278 |
2274 } // namespace | 2279 } // namespace |
2275 } // namespace cc | 2280 } // namespace cc |
OLD | NEW |