Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(33)

Side by Side Diff: cc/scheduler/scheduler_unittest.cc

Issue 199523002: cc: Throttle swaps in Scheduler instead of OutputSurface (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: WIP: pulling FRC out of OS Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 1238 matching lines...) Expand 10 before | Expand all | Expand 10 after
1249 scheduler->SetNeedsCommit(); 1249 scheduler->SetNeedsCommit();
1250 EXPECT_TRUE(scheduler->CommitPending()); 1250 EXPECT_TRUE(scheduler->CommitPending());
1251 scheduler->NotifyBeginMainFrameStarted(); 1251 scheduler->NotifyBeginMainFrameStarted();
1252 scheduler->NotifyReadyToCommit(); 1252 scheduler->NotifyReadyToCommit();
1253 scheduler->SetNeedsRedraw(); 1253 scheduler->SetNeedsRedraw();
1254 BeginFrameArgs impl_frame_args = BeginFrameArgs::CreateForTesting(); 1254 BeginFrameArgs impl_frame_args = BeginFrameArgs::CreateForTesting();
1255 const int interval = 1; 1255 const int interval = 1;
1256 impl_frame_args.interval = base::TimeDelta::FromMilliseconds(interval); 1256 impl_frame_args.interval = base::TimeDelta::FromMilliseconds(interval);
1257 scheduler->BeginImplFrame(impl_frame_args); 1257 scheduler->BeginImplFrame(impl_frame_args);
1258 scheduler->OnBeginImplFrameDeadline(); 1258 scheduler->OnBeginImplFrameDeadline();
1259 scheduler->DidSwapBuffers();
1260 scheduler->OnSwapBuffersComplete();
1259 1261
1260 // At this point, we've drawn a frame. Start another commit, but hold off on 1262 // At this point, we've drawn a frame. Start another commit, but hold off on
1261 // the NotifyReadyToCommit for now. 1263 // the NotifyReadyToCommit for now.
1262 EXPECT_FALSE(scheduler->CommitPending()); 1264 EXPECT_FALSE(scheduler->CommitPending());
1265 scheduler->BeginImplFrame(impl_frame_args);
1263 scheduler->SetNeedsCommit(); 1266 scheduler->SetNeedsCommit();
1264 EXPECT_TRUE(scheduler->CommitPending()); 1267 EXPECT_TRUE(scheduler->CommitPending());
1265 1268
1269 // Draw and swap the frame, but don't ack the swap to simulate the Browser
1270 // blocking on the renderer.
1271 scheduler->OnBeginImplFrameDeadline();
1272 scheduler->DidSwapBuffers();
1273
1266 // Spin the event loop a few times and make sure we get more 1274 // Spin the event loop a few times and make sure we get more
1267 // DidAnticipateDrawTimeChange calls every time. 1275 // DidAnticipateDrawTimeChange calls every time.
1268 int actions_so_far = client.num_actions_(); 1276 int actions_so_far = client.num_actions_();
1269 1277
1270 // Does three iterations to make sure that the timer is properly repeating. 1278 // Does three iterations to make sure that the timer is properly repeating.
1271 for (int i = 0; i < 3; ++i) { 1279 for (int i = 0; i < 3; ++i) {
1272 // Wait for 2x the frame interval to match 1280 // Wait for 2x the frame interval to match
1273 // Scheduler::advance_commit_state_timer_'s rate. 1281 // Scheduler::advance_commit_state_timer_'s rate.
1274 SpinForMillis(interval * 2); 1282 SpinForMillis(interval * 2);
1275 EXPECT_GT(client.num_actions_(), actions_so_far); 1283 EXPECT_GT(client.num_actions_(), actions_so_far);
1276 EXPECT_STREQ(client.Action(client.num_actions_() - 1), 1284 EXPECT_STREQ(client.Action(client.num_actions_() - 1),
1277 "DidAnticipatedDrawTimeChange"); 1285 "DidAnticipatedDrawTimeChange");
1278 actions_so_far = client.num_actions_(); 1286 actions_so_far = client.num_actions_();
1279 } 1287 }
1280 } 1288 }
1281 1289
1282 } // namespace 1290 } // namespace
1283 } // namespace cc 1291 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698