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

Unified Diff: cc/output/output_surface_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: 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 side-by-side diff with in-line comments
Download patch
Index: cc/output/output_surface_unittest.cc
diff --git a/cc/output/output_surface_unittest.cc b/cc/output/output_surface_unittest.cc
index b0220fbcc5dfe576a5872e0b2d29ccc35ae7dc4b..06be883749262bcc837ceab5f0711990cba79a7d 100644
--- a/cc/output/output_surface_unittest.cc
+++ b/cc/output/output_surface_unittest.cc
@@ -59,10 +59,6 @@ class TestOutputSurface : public OutputSurface {
DidSwapBuffers();
}
- int pending_swap_buffers() {
- return pending_swap_buffers_;
- }
-
void OnSwapBuffersCompleteForTesting() {
OnSwapBuffersComplete();
}
@@ -233,22 +229,18 @@ TEST(OutputSurfaceTest, BeginImplFrameEmulation) {
// Initialize BeginImplFrame emulation
scoped_refptr<base::TestSimpleTaskRunner> task_runner =
new base::TestSimpleTaskRunner;
- bool throttle_frame_production = true;
const base::TimeDelta display_refresh_interval =
BeginFrameArgs::DefaultInterval();
output_surface.InitializeBeginImplFrameEmulation(
task_runner.get(),
- throttle_frame_production,
display_refresh_interval);
- output_surface.SetMaxFramesPending(2);
output_surface.EnableRetroactiveBeginImplFrameDeadline(
false, false, base::TimeDelta());
// We should start off with 0 BeginImplFrames
EXPECT_EQ(client.begin_impl_frame_count(), 0);
- EXPECT_EQ(output_surface.pending_swap_buffers(), 0);
// We should not have a pending task until a BeginImplFrame has been
// requested.
@@ -259,54 +251,29 @@ TEST(OutputSurfaceTest, BeginImplFrameEmulation) {
// BeginImplFrame should be called on the first tick.
task_runner->RunPendingTasks();
EXPECT_EQ(client.begin_impl_frame_count(), 1);
- EXPECT_EQ(output_surface.pending_swap_buffers(), 0);
// BeginImplFrame should not be called when there is a pending BeginImplFrame.
task_runner->RunPendingTasks();
EXPECT_EQ(client.begin_impl_frame_count(), 1);
- EXPECT_EQ(output_surface.pending_swap_buffers(), 0);
-
// SetNeedsBeginImplFrame should clear the pending BeginImplFrame after
// a SwapBuffers.
output_surface.DidSwapBuffersForTesting();
output_surface.SetNeedsBeginImplFrame(true);
EXPECT_EQ(client.begin_impl_frame_count(), 1);
- EXPECT_EQ(output_surface.pending_swap_buffers(), 1);
task_runner->RunPendingTasks();
EXPECT_EQ(client.begin_impl_frame_count(), 2);
- EXPECT_EQ(output_surface.pending_swap_buffers(), 1);
-
- // BeginImplFrame should be throttled by pending swap buffers.
- output_surface.DidSwapBuffersForTesting();
- output_surface.SetNeedsBeginImplFrame(true);
- EXPECT_EQ(client.begin_impl_frame_count(), 2);
- EXPECT_EQ(output_surface.pending_swap_buffers(), 2);
- task_runner->RunPendingTasks();
- EXPECT_EQ(client.begin_impl_frame_count(), 2);
- EXPECT_EQ(output_surface.pending_swap_buffers(), 2);
-
- // SwapAck should decrement pending swap buffers and unblock BeginImplFrame
- // again.
- output_surface.OnSwapBuffersCompleteForTesting();
- EXPECT_EQ(client.begin_impl_frame_count(), 2);
- EXPECT_EQ(output_surface.pending_swap_buffers(), 1);
- task_runner->RunPendingTasks();
- EXPECT_EQ(client.begin_impl_frame_count(), 3);
- EXPECT_EQ(output_surface.pending_swap_buffers(), 1);
// Calling SetNeedsBeginImplFrame again indicates a swap did not occur but
// the client still wants another BeginImplFrame.
output_surface.SetNeedsBeginImplFrame(true);
task_runner->RunPendingTasks();
- EXPECT_EQ(client.begin_impl_frame_count(), 4);
- EXPECT_EQ(output_surface.pending_swap_buffers(), 1);
+ EXPECT_EQ(client.begin_impl_frame_count(), 3);
// Disabling SetNeedsBeginImplFrame should prevent further BeginImplFrames.
output_surface.SetNeedsBeginImplFrame(false);
task_runner->RunPendingTasks();
EXPECT_FALSE(task_runner->HasPendingTask());
- EXPECT_EQ(client.begin_impl_frame_count(), 4);
- EXPECT_EQ(output_surface.pending_swap_buffers(), 1);
+ EXPECT_EQ(client.begin_impl_frame_count(), 3);
}
TEST(OutputSurfaceTest, OptimisticAndRetroactiveBeginImplFrames) {
@@ -318,7 +285,6 @@ TEST(OutputSurfaceTest, OptimisticAndRetroactiveBeginImplFrames) {
EXPECT_TRUE(output_surface.HasClient());
EXPECT_FALSE(client.deferred_initialize_called());
- output_surface.SetMaxFramesPending(2);
output_surface.EnableRetroactiveBeginImplFrameDeadline(
true, false, base::TimeDelta());
@@ -344,19 +310,6 @@ TEST(OutputSurfaceTest, OptimisticAndRetroactiveBeginImplFrames) {
output_surface.DidSwapBuffersForTesting();
output_surface.SetNeedsBeginImplFrame(true);
EXPECT_EQ(client.begin_impl_frame_count(), 3);
- EXPECT_EQ(output_surface.pending_swap_buffers(), 1);
-
- // Optimistically injected BeginImplFrames should be by throttled by pending
- // swap buffers...
- output_surface.DidSwapBuffersForTesting();
- output_surface.SetNeedsBeginImplFrame(true);
- EXPECT_EQ(client.begin_impl_frame_count(), 3);
- EXPECT_EQ(output_surface.pending_swap_buffers(), 2);
- output_surface.BeginImplFrameForTesting();
- EXPECT_EQ(client.begin_impl_frame_count(), 3);
- // ...and retroactively triggered by OnSwapBuffersComplete
- output_surface.OnSwapBuffersCompleteForTesting();
- EXPECT_EQ(client.begin_impl_frame_count(), 4);
}
TEST(OutputSurfaceTest,
@@ -377,12 +330,10 @@ TEST(OutputSurfaceTest,
// Initialize BeginImplFrame emulation
scoped_refptr<base::TestSimpleTaskRunner> task_runner =
new base::TestSimpleTaskRunner;
- bool throttle_frame_production = true;
const base::TimeDelta display_refresh_interval = big_interval;
output_surface.InitializeBeginImplFrameEmulation(
task_runner.get(),
- throttle_frame_production,
display_refresh_interval);
// We need to subtract an epsilon from Now() because some platforms have
@@ -390,13 +341,11 @@ TEST(OutputSurfaceTest,
output_surface.CommitVSyncParametersForTesting(
gfx::FrameTime::Now() - base::TimeDelta::FromSeconds(1), big_interval);
- output_surface.SetMaxFramesPending(2);
output_surface.EnableRetroactiveBeginImplFrameDeadline(
true, true, big_interval);
// We should start off with 0 BeginImplFrames
EXPECT_EQ(client.begin_impl_frame_count(), 0);
- EXPECT_EQ(output_surface.pending_swap_buffers(), 0);
// The first SetNeedsBeginImplFrame(true) should start a retroactive
// BeginImplFrame.

Powered by Google App Engine
This is Rietveld 408576698