| 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..d40feb167dd53e724901e60959db96e32b36ad61 100644
|
| --- a/cc/output/output_surface_unittest.cc
|
| +++ b/cc/output/output_surface_unittest.cc
|
| @@ -24,18 +24,18 @@ class TestOutputSurface : public OutputSurface {
|
| public:
|
| explicit TestOutputSurface(scoped_refptr<ContextProvider> context_provider)
|
| : OutputSurface(context_provider),
|
| - retroactive_begin_impl_frame_deadline_enabled_(false),
|
| + retroactive_begin_frame_deadline_enabled_(false),
|
| override_retroactive_period_(false) {}
|
|
|
| explicit TestOutputSurface(scoped_ptr<SoftwareOutputDevice> software_device)
|
| : OutputSurface(software_device.Pass()),
|
| - retroactive_begin_impl_frame_deadline_enabled_(false),
|
| + retroactive_begin_frame_deadline_enabled_(false),
|
| override_retroactive_period_(false) {}
|
|
|
| TestOutputSurface(scoped_refptr<ContextProvider> context_provider,
|
| scoped_ptr<SoftwareOutputDevice> software_device)
|
| : OutputSurface(context_provider, software_device.Pass()),
|
| - retroactive_begin_impl_frame_deadline_enabled_(false),
|
| + retroactive_begin_frame_deadline_enabled_(false),
|
| override_retroactive_period_(false) {}
|
|
|
| bool InitializeNewContext3d(
|
| @@ -51,8 +51,8 @@ class TestOutputSurface : public OutputSurface {
|
| CommitVSyncParameters(timebase, interval);
|
| }
|
|
|
| - void BeginImplFrameForTesting() {
|
| - OutputSurface::BeginImplFrame(BeginFrameArgs::CreateExpiredForTesting());
|
| + void BeginFrameForTesting() {
|
| + OutputSurface::BeginFrame(BeginFrameArgs::CreateExpiredForTesting());
|
| }
|
|
|
| void DidSwapBuffersForTesting() {
|
| @@ -67,34 +67,33 @@ class TestOutputSurface : public OutputSurface {
|
| OnSwapBuffersComplete();
|
| }
|
|
|
| - void EnableRetroactiveBeginImplFrameDeadline(
|
| - bool enable,
|
| - bool override_retroactive_period,
|
| - base::TimeDelta period_override) {
|
| - retroactive_begin_impl_frame_deadline_enabled_ = enable;
|
| + void EnableRetroactiveBeginFrameDeadline(bool enable,
|
| + bool override_retroactive_period,
|
| + base::TimeDelta period_override) {
|
| + retroactive_begin_frame_deadline_enabled_ = enable;
|
| override_retroactive_period_ = override_retroactive_period;
|
| retroactive_period_override_ = period_override;
|
| }
|
|
|
| protected:
|
| - virtual void PostCheckForRetroactiveBeginImplFrame() OVERRIDE {
|
| + virtual void PostCheckForRetroactiveBeginFrame() OVERRIDE {
|
| // For testing purposes, we check immediately rather than posting a task.
|
| - CheckForRetroactiveBeginImplFrame();
|
| + CheckForRetroactiveBeginFrame();
|
| }
|
|
|
| - virtual base::TimeTicks RetroactiveBeginImplFrameDeadline() OVERRIDE {
|
| - if (retroactive_begin_impl_frame_deadline_enabled_) {
|
| + virtual base::TimeTicks RetroactiveBeginFrameDeadline() OVERRIDE {
|
| + if (retroactive_begin_frame_deadline_enabled_) {
|
| if (override_retroactive_period_) {
|
| - return skipped_begin_impl_frame_args_.frame_time +
|
| + return skipped_begin_frame_args_.frame_time +
|
| retroactive_period_override_;
|
| } else {
|
| - return OutputSurface::RetroactiveBeginImplFrameDeadline();
|
| + return OutputSurface::RetroactiveBeginFrameDeadline();
|
| }
|
| }
|
| return base::TimeTicks();
|
| }
|
|
|
| - bool retroactive_begin_impl_frame_deadline_enabled_;
|
| + bool retroactive_begin_frame_deadline_enabled_;
|
| bool override_retroactive_period_;
|
| base::TimeDelta retroactive_period_override_;
|
| };
|
| @@ -221,7 +220,7 @@ TEST_F(OutputSurfaceTestInitializeNewContext3d, ClientDeferredInitializeFails) {
|
| InitializeNewContextExpectFail();
|
| }
|
|
|
| -TEST(OutputSurfaceTest, BeginImplFrameEmulation) {
|
| +TEST(OutputSurfaceTest, BeginFrameEmulation) {
|
| TestOutputSurface output_surface(TestContextProvider::Create());
|
| EXPECT_FALSE(output_surface.HasClient());
|
|
|
| @@ -230,86 +229,84 @@ TEST(OutputSurfaceTest, BeginImplFrameEmulation) {
|
| EXPECT_TRUE(output_surface.HasClient());
|
| EXPECT_FALSE(client.deferred_initialize_called());
|
|
|
| - // Initialize BeginImplFrame emulation
|
| + // Initialize BeginFrame 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.InitializeBeginFrameEmulation(
|
| + task_runner.get(), throttle_frame_production, display_refresh_interval);
|
|
|
| output_surface.SetMaxFramesPending(2);
|
| - output_surface.EnableRetroactiveBeginImplFrameDeadline(
|
| + output_surface.EnableRetroactiveBeginFrameDeadline(
|
| false, false, base::TimeDelta());
|
|
|
| - // We should start off with 0 BeginImplFrames
|
| - EXPECT_EQ(client.begin_impl_frame_count(), 0);
|
| + // We should start off with 0 BeginFrames
|
| + EXPECT_EQ(client.begin_frame_count(), 0);
|
| EXPECT_EQ(output_surface.pending_swap_buffers(), 0);
|
|
|
| - // We should not have a pending task until a BeginImplFrame has been
|
| + // We should not have a pending task until a BeginFrame has been
|
| // requested.
|
| EXPECT_FALSE(task_runner->HasPendingTask());
|
| - output_surface.SetNeedsBeginImplFrame(true);
|
| + output_surface.SetNeedsBeginFrame(true);
|
| EXPECT_TRUE(task_runner->HasPendingTask());
|
|
|
| - // BeginImplFrame should be called on the first tick.
|
| + // BeginFrame should be called on the first tick.
|
| task_runner->RunPendingTasks();
|
| - EXPECT_EQ(client.begin_impl_frame_count(), 1);
|
| + EXPECT_EQ(client.begin_frame_count(), 1);
|
| EXPECT_EQ(output_surface.pending_swap_buffers(), 0);
|
|
|
| - // BeginImplFrame should not be called when there is a pending BeginImplFrame.
|
| + // BeginFrame should not be called when there is a pending BeginFrame.
|
| task_runner->RunPendingTasks();
|
| - EXPECT_EQ(client.begin_impl_frame_count(), 1);
|
| + EXPECT_EQ(client.begin_frame_count(), 1);
|
| EXPECT_EQ(output_surface.pending_swap_buffers(), 0);
|
|
|
| - // SetNeedsBeginImplFrame should clear the pending BeginImplFrame after
|
| + // SetNeedsBeginFrame should clear the pending BeginFrame after
|
| // a SwapBuffers.
|
| output_surface.DidSwapBuffersForTesting();
|
| - output_surface.SetNeedsBeginImplFrame(true);
|
| - EXPECT_EQ(client.begin_impl_frame_count(), 1);
|
| + output_surface.SetNeedsBeginFrame(true);
|
| + EXPECT_EQ(client.begin_frame_count(), 1);
|
| EXPECT_EQ(output_surface.pending_swap_buffers(), 1);
|
| task_runner->RunPendingTasks();
|
| - EXPECT_EQ(client.begin_impl_frame_count(), 2);
|
| + EXPECT_EQ(client.begin_frame_count(), 2);
|
| EXPECT_EQ(output_surface.pending_swap_buffers(), 1);
|
|
|
| - // BeginImplFrame should be throttled by pending swap buffers.
|
| + // BeginFrame should be throttled by pending swap buffers.
|
| output_surface.DidSwapBuffersForTesting();
|
| - output_surface.SetNeedsBeginImplFrame(true);
|
| - EXPECT_EQ(client.begin_impl_frame_count(), 2);
|
| + output_surface.SetNeedsBeginFrame(true);
|
| + EXPECT_EQ(client.begin_frame_count(), 2);
|
| EXPECT_EQ(output_surface.pending_swap_buffers(), 2);
|
| task_runner->RunPendingTasks();
|
| - EXPECT_EQ(client.begin_impl_frame_count(), 2);
|
| + EXPECT_EQ(client.begin_frame_count(), 2);
|
| EXPECT_EQ(output_surface.pending_swap_buffers(), 2);
|
|
|
| - // SwapAck should decrement pending swap buffers and unblock BeginImplFrame
|
| + // SwapAck should decrement pending swap buffers and unblock BeginFrame
|
| // again.
|
| output_surface.OnSwapBuffersCompleteForTesting();
|
| - EXPECT_EQ(client.begin_impl_frame_count(), 2);
|
| + EXPECT_EQ(client.begin_frame_count(), 2);
|
| EXPECT_EQ(output_surface.pending_swap_buffers(), 1);
|
| task_runner->RunPendingTasks();
|
| - EXPECT_EQ(client.begin_impl_frame_count(), 3);
|
| + EXPECT_EQ(client.begin_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);
|
| + // Calling SetNeedsBeginFrame again indicates a swap did not occur but
|
| + // the client still wants another BeginFrame.
|
| + output_surface.SetNeedsBeginFrame(true);
|
| task_runner->RunPendingTasks();
|
| - EXPECT_EQ(client.begin_impl_frame_count(), 4);
|
| + EXPECT_EQ(client.begin_frame_count(), 4);
|
| EXPECT_EQ(output_surface.pending_swap_buffers(), 1);
|
|
|
| - // Disabling SetNeedsBeginImplFrame should prevent further BeginImplFrames.
|
| - output_surface.SetNeedsBeginImplFrame(false);
|
| + // Disabling SetNeedsBeginFrame should prevent further BeginFrames.
|
| + output_surface.SetNeedsBeginFrame(false);
|
| task_runner->RunPendingTasks();
|
| EXPECT_FALSE(task_runner->HasPendingTask());
|
| - EXPECT_EQ(client.begin_impl_frame_count(), 4);
|
| + EXPECT_EQ(client.begin_frame_count(), 4);
|
| EXPECT_EQ(output_surface.pending_swap_buffers(), 1);
|
| }
|
|
|
| -TEST(OutputSurfaceTest, OptimisticAndRetroactiveBeginImplFrames) {
|
| +TEST(OutputSurfaceTest, OptimisticAndRetroactiveBeginFrames) {
|
| TestOutputSurface output_surface(TestContextProvider::Create());
|
| EXPECT_FALSE(output_surface.HasClient());
|
|
|
| @@ -319,48 +316,47 @@ TEST(OutputSurfaceTest, OptimisticAndRetroactiveBeginImplFrames) {
|
| EXPECT_FALSE(client.deferred_initialize_called());
|
|
|
| output_surface.SetMaxFramesPending(2);
|
| - output_surface.EnableRetroactiveBeginImplFrameDeadline(
|
| + output_surface.EnableRetroactiveBeginFrameDeadline(
|
| true, false, base::TimeDelta());
|
|
|
| - // Optimistically injected BeginImplFrames should be throttled if
|
| - // SetNeedsBeginImplFrame is false...
|
| - output_surface.SetNeedsBeginImplFrame(false);
|
| - output_surface.BeginImplFrameForTesting();
|
| - EXPECT_EQ(client.begin_impl_frame_count(), 0);
|
| - // ...and retroactively triggered by a SetNeedsBeginImplFrame.
|
| - output_surface.SetNeedsBeginImplFrame(true);
|
| - EXPECT_EQ(client.begin_impl_frame_count(), 1);
|
| -
|
| - // Optimistically injected BeginImplFrames should be throttled by pending
|
| - // BeginImplFrames...
|
| - output_surface.BeginImplFrameForTesting();
|
| - EXPECT_EQ(client.begin_impl_frame_count(), 1);
|
| - // ...and retroactively triggered by a SetNeedsBeginImplFrame.
|
| - output_surface.SetNeedsBeginImplFrame(true);
|
| - EXPECT_EQ(client.begin_impl_frame_count(), 2);
|
| + // Optimistically injected BeginFrames should be throttled if
|
| + // SetNeedsBeginFrame is false...
|
| + output_surface.SetNeedsBeginFrame(false);
|
| + output_surface.BeginFrameForTesting();
|
| + EXPECT_EQ(client.begin_frame_count(), 0);
|
| + // ...and retroactively triggered by a SetNeedsBeginFrame.
|
| + output_surface.SetNeedsBeginFrame(true);
|
| + EXPECT_EQ(client.begin_frame_count(), 1);
|
| +
|
| + // Optimistically injected BeginFrames should be throttled by pending
|
| + // BeginFrames...
|
| + output_surface.BeginFrameForTesting();
|
| + EXPECT_EQ(client.begin_frame_count(), 1);
|
| + // ...and retroactively triggered by a SetNeedsBeginFrame.
|
| + output_surface.SetNeedsBeginFrame(true);
|
| + EXPECT_EQ(client.begin_frame_count(), 2);
|
| // ...or retroactively triggered by a Swap.
|
| - output_surface.BeginImplFrameForTesting();
|
| - EXPECT_EQ(client.begin_impl_frame_count(), 2);
|
| + output_surface.BeginFrameForTesting();
|
| + EXPECT_EQ(client.begin_frame_count(), 2);
|
| output_surface.DidSwapBuffersForTesting();
|
| - output_surface.SetNeedsBeginImplFrame(true);
|
| - EXPECT_EQ(client.begin_impl_frame_count(), 3);
|
| + output_surface.SetNeedsBeginFrame(true);
|
| + EXPECT_EQ(client.begin_frame_count(), 3);
|
| EXPECT_EQ(output_surface.pending_swap_buffers(), 1);
|
|
|
| - // Optimistically injected BeginImplFrames should be by throttled by pending
|
| + // Optimistically injected BeginFrames should be by throttled by pending
|
| // swap buffers...
|
| output_surface.DidSwapBuffersForTesting();
|
| - output_surface.SetNeedsBeginImplFrame(true);
|
| - EXPECT_EQ(client.begin_impl_frame_count(), 3);
|
| + output_surface.SetNeedsBeginFrame(true);
|
| + EXPECT_EQ(client.begin_frame_count(), 3);
|
| EXPECT_EQ(output_surface.pending_swap_buffers(), 2);
|
| - output_surface.BeginImplFrameForTesting();
|
| - EXPECT_EQ(client.begin_impl_frame_count(), 3);
|
| + output_surface.BeginFrameForTesting();
|
| + EXPECT_EQ(client.begin_frame_count(), 3);
|
| // ...and retroactively triggered by OnSwapBuffersComplete
|
| output_surface.OnSwapBuffersCompleteForTesting();
|
| - EXPECT_EQ(client.begin_impl_frame_count(), 4);
|
| + EXPECT_EQ(client.begin_frame_count(), 4);
|
| }
|
|
|
| -TEST(OutputSurfaceTest,
|
| - RetroactiveBeginImplFrameDoesNotDoubleTickWhenEmulating) {
|
| +TEST(OutputSurfaceTest, RetroactiveBeginFrameDoesNotDoubleTickWhenEmulating) {
|
| scoped_refptr<TestContextProvider> context_provider =
|
| TestContextProvider::Create();
|
|
|
| @@ -374,16 +370,14 @@ TEST(OutputSurfaceTest,
|
|
|
| base::TimeDelta big_interval = base::TimeDelta::FromSeconds(10);
|
|
|
| - // Initialize BeginImplFrame emulation
|
| + // Initialize BeginFrame 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);
|
| + output_surface.InitializeBeginFrameEmulation(
|
| + task_runner.get(), throttle_frame_production, display_refresh_interval);
|
|
|
| // We need to subtract an epsilon from Now() because some platforms have
|
| // a slow clock.
|
| @@ -391,31 +385,30 @@ TEST(OutputSurfaceTest,
|
| gfx::FrameTime::Now() - base::TimeDelta::FromSeconds(1), big_interval);
|
|
|
| output_surface.SetMaxFramesPending(2);
|
| - output_surface.EnableRetroactiveBeginImplFrameDeadline(
|
| - true, true, big_interval);
|
| + output_surface.EnableRetroactiveBeginFrameDeadline(true, true, big_interval);
|
|
|
| - // We should start off with 0 BeginImplFrames
|
| - EXPECT_EQ(client.begin_impl_frame_count(), 0);
|
| + // We should start off with 0 BeginFrames
|
| + EXPECT_EQ(client.begin_frame_count(), 0);
|
| EXPECT_EQ(output_surface.pending_swap_buffers(), 0);
|
|
|
| - // The first SetNeedsBeginImplFrame(true) should start a retroactive
|
| - // BeginImplFrame.
|
| + // The first SetNeedsBeginFrame(true) should start a retroactive
|
| + // BeginFrame.
|
| EXPECT_FALSE(task_runner->HasPendingTask());
|
| - output_surface.SetNeedsBeginImplFrame(true);
|
| + output_surface.SetNeedsBeginFrame(true);
|
| EXPECT_TRUE(task_runner->HasPendingTask());
|
| EXPECT_GT(task_runner->NextPendingTaskDelay(), big_interval / 2);
|
| - EXPECT_EQ(client.begin_impl_frame_count(), 1);
|
| + EXPECT_EQ(client.begin_frame_count(), 1);
|
|
|
| - output_surface.SetNeedsBeginImplFrame(false);
|
| + output_surface.SetNeedsBeginFrame(false);
|
| EXPECT_TRUE(task_runner->HasPendingTask());
|
| - EXPECT_EQ(client.begin_impl_frame_count(), 1);
|
| + EXPECT_EQ(client.begin_frame_count(), 1);
|
|
|
| - // The second SetNeedBeginImplFrame(true) should not retroactively start a
|
| - // BeginImplFrame if the timestamp would be the same as the previous
|
| - // BeginImplFrame.
|
| - output_surface.SetNeedsBeginImplFrame(true);
|
| + // The second SetNeedBeginFrame(true) should not retroactively start a
|
| + // BeginFrame if the timestamp would be the same as the previous
|
| + // BeginFrame.
|
| + output_surface.SetNeedsBeginFrame(true);
|
| EXPECT_TRUE(task_runner->HasPendingTask());
|
| - EXPECT_EQ(client.begin_impl_frame_count(), 1);
|
| + EXPECT_EQ(client.begin_frame_count(), 1);
|
| }
|
|
|
| TEST(OutputSurfaceTest, MemoryAllocation) {
|
|
|