diff options
author | dominikg@chromium.org <dominikg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-23 17:04:50 +0000 |
---|---|---|
committer | dominikg@chromium.org <dominikg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-23 17:04:50 +0000 |
commit | daea3d424f865ae7fc5720dea7b3c9565952a968 (patch) | |
tree | 0c6bf0ade3676ee7b735fbc0aa5e1872cef9475f /cc/output/output_surface_unittest.cc | |
parent | f54f8ce7166114c58c6ecb92b6cc2a0f8bac0a2b (diff) | |
download | chromium_src-daea3d424f865ae7fc5720dea7b3c9565952a968.zip chromium_src-daea3d424f865ae7fc5720dea7b3c9565952a968.tar.gz chromium_src-daea3d424f865ae7fc5720dea7b3c9565952a968.tar.bz2 |
Rename BeginFrame to BeginMainFrame and BeginImplFrame (part 3).
Third patch in a series to rename BeginFrame. This patch focuses on
cc::ThreadProxy, cc::LayerTreeHost, cc::LayerTreeHostImpl, cc::OutputSurface
and it's related (sub)classes.
In the scheduler, the term 'BeginFrame' is used for both the main thread and the
impl thread. This can cause confusion if it's not obvious which one is being
refered to. To clarify this, we rename BeginFrame to BeginMainFrame and
BeginImplFrame, respectively.
BUG=261765
Review URL: https://codereview.chromium.org/35023002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@230453 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/output/output_surface_unittest.cc')
-rw-r--r-- | cc/output/output_surface_unittest.cc | 185 |
1 files changed, 96 insertions, 89 deletions
diff --git a/cc/output/output_surface_unittest.cc b/cc/output/output_surface_unittest.cc index 91e7c39..bf18ada 100644 --- a/cc/output/output_surface_unittest.cc +++ b/cc/output/output_surface_unittest.cc @@ -23,19 +23,19 @@ class TestOutputSurface : public OutputSurface { public: explicit TestOutputSurface(scoped_refptr<ContextProvider> context_provider) : OutputSurface(context_provider), - retroactive_begin_frame_deadline_enabled_(false), + retroactive_begin_impl_frame_deadline_enabled_(false), override_retroactive_period_(false) {} explicit TestOutputSurface( scoped_ptr<cc::SoftwareOutputDevice> software_device) : OutputSurface(software_device.Pass()), - retroactive_begin_frame_deadline_enabled_(false), + retroactive_begin_impl_frame_deadline_enabled_(false), override_retroactive_period_(false) {} TestOutputSurface(scoped_refptr<ContextProvider> context_provider, scoped_ptr<cc::SoftwareOutputDevice> software_device) : OutputSurface(context_provider, software_device.Pass()), - retroactive_begin_frame_deadline_enabled_(false), + retroactive_begin_impl_frame_deadline_enabled_(false), override_retroactive_period_(false) {} bool InitializeNewContext3d( @@ -51,8 +51,8 @@ class TestOutputSurface : public OutputSurface { OnVSyncParametersChanged(timebase, interval); } - void BeginFrameForTesting() { - OutputSurface::BeginFrame(BeginFrameArgs::CreateExpiredForTesting()); + void BeginImplFrameForTesting() { + OutputSurface::BeginImplFrame(BeginFrameArgs::CreateExpiredForTesting()); } void DidSwapBuffersForTesting() { @@ -67,33 +67,34 @@ class TestOutputSurface : public OutputSurface { OnSwapBuffersComplete(); } - void EnableRetroactiveBeginFrameDeadline(bool enable, - bool override_retroactive_period, - base::TimeDelta period_override) { - retroactive_begin_frame_deadline_enabled_ = enable; + void EnableRetroactiveBeginImplFrameDeadline( + bool enable, + bool override_retroactive_period, + base::TimeDelta period_override) { + retroactive_begin_impl_frame_deadline_enabled_ = enable; override_retroactive_period_ = override_retroactive_period; retroactive_period_override_ = period_override; } protected: - virtual void PostCheckForRetroactiveBeginFrame() OVERRIDE { + virtual void PostCheckForRetroactiveBeginImplFrame() OVERRIDE { // For testing purposes, we check immediately rather than posting a task. - CheckForRetroactiveBeginFrame(); + CheckForRetroactiveBeginImplFrame(); } - virtual base::TimeTicks RetroactiveBeginFrameDeadline() OVERRIDE { - if (retroactive_begin_frame_deadline_enabled_) { + virtual base::TimeTicks RetroactiveBeginImplFrameDeadline() OVERRIDE { + if (retroactive_begin_impl_frame_deadline_enabled_) { if (override_retroactive_period_) { - return skipped_begin_frame_args_.frame_time + + return skipped_begin_impl_frame_args_.frame_time + retroactive_period_override_; } else { - return OutputSurface::RetroactiveBeginFrameDeadline(); + return OutputSurface::RetroactiveBeginImplFrameDeadline(); } } return base::TimeTicks(); } - bool retroactive_begin_frame_deadline_enabled_; + bool retroactive_begin_impl_frame_deadline_enabled_; bool override_retroactive_period_; base::TimeDelta retroactive_period_override_; }; @@ -218,7 +219,7 @@ TEST_F(OutputSurfaceTestInitializeNewContext3d, ClientDeferredInitializeFails) { InitializeNewContextExpectFail(); } -TEST(OutputSurfaceTest, BeginFrameEmulation) { +TEST(OutputSurfaceTest, BeginImplFrameEmulation) { TestOutputSurface output_surface(TestContextProvider::Create()); EXPECT_FALSE(output_surface.HasClient()); @@ -227,84 +228,86 @@ TEST(OutputSurfaceTest, BeginFrameEmulation) { EXPECT_TRUE(output_surface.HasClient()); EXPECT_FALSE(client.deferred_initialize_called()); - // Initialize BeginFrame emulation + // 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.InitializeBeginFrameEmulation( + output_surface.InitializeBeginImplFrameEmulation( task_runner.get(), throttle_frame_production, display_refresh_interval); output_surface.SetMaxFramesPending(2); - output_surface.EnableRetroactiveBeginFrameDeadline( + output_surface.EnableRetroactiveBeginImplFrameDeadline( false, false, base::TimeDelta()); - // We should start off with 0 BeginFrames - EXPECT_EQ(client.begin_frame_count(), 0); + // 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 BeginFrame has been requested. + // We should not have a pending task until a BeginImplFrame has been + // requested. EXPECT_FALSE(task_runner->HasPendingTask()); - output_surface.SetNeedsBeginFrame(true); + output_surface.SetNeedsBeginImplFrame(true); EXPECT_TRUE(task_runner->HasPendingTask()); - // BeginFrame should be called on the first tick. + // BeginImplFrame should be called on the first tick. task_runner->RunPendingTasks(); - EXPECT_EQ(client.begin_frame_count(), 1); + EXPECT_EQ(client.begin_impl_frame_count(), 1); EXPECT_EQ(output_surface.pending_swap_buffers(), 0); - // BeginFrame should not be called when there is a pending BeginFrame. + // BeginImplFrame should not be called when there is a pending BeginImplFrame. task_runner->RunPendingTasks(); - EXPECT_EQ(client.begin_frame_count(), 1); + EXPECT_EQ(client.begin_impl_frame_count(), 1); EXPECT_EQ(output_surface.pending_swap_buffers(), 0); - // SetNeedsBeginFrame should clear the pending BeginFrame after + // SetNeedsBeginImplFrame should clear the pending BeginImplFrame after // a SwapBuffers. output_surface.DidSwapBuffersForTesting(); - output_surface.SetNeedsBeginFrame(true); - EXPECT_EQ(client.begin_frame_count(), 1); + 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_frame_count(), 2); + EXPECT_EQ(client.begin_impl_frame_count(), 2); EXPECT_EQ(output_surface.pending_swap_buffers(), 1); - // BeginFrame should be throttled by pending swap buffers. + // BeginImplFrame should be throttled by pending swap buffers. output_surface.DidSwapBuffersForTesting(); - output_surface.SetNeedsBeginFrame(true); - EXPECT_EQ(client.begin_frame_count(), 2); + 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_frame_count(), 2); + EXPECT_EQ(client.begin_impl_frame_count(), 2); EXPECT_EQ(output_surface.pending_swap_buffers(), 2); - // SwapAck should decrement pending swap buffers and unblock BeginFrame again. + // SwapAck should decrement pending swap buffers and unblock BeginImplFrame + // again. output_surface.OnSwapBuffersCompleteForTesting(); - EXPECT_EQ(client.begin_frame_count(), 2); + EXPECT_EQ(client.begin_impl_frame_count(), 2); EXPECT_EQ(output_surface.pending_swap_buffers(), 1); task_runner->RunPendingTasks(); - EXPECT_EQ(client.begin_frame_count(), 3); + EXPECT_EQ(client.begin_impl_frame_count(), 3); EXPECT_EQ(output_surface.pending_swap_buffers(), 1); - // Calling SetNeedsBeginFrame again indicates a swap did not occur but - // the client still wants another BeginFrame. - output_surface.SetNeedsBeginFrame(true); + // 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_frame_count(), 4); + EXPECT_EQ(client.begin_impl_frame_count(), 4); EXPECT_EQ(output_surface.pending_swap_buffers(), 1); - // Disabling SetNeedsBeginFrame should prevent further BeginFrames. - output_surface.SetNeedsBeginFrame(false); + // Disabling SetNeedsBeginImplFrame should prevent further BeginImplFrames. + output_surface.SetNeedsBeginImplFrame(false); task_runner->RunPendingTasks(); EXPECT_FALSE(task_runner->HasPendingTask()); - EXPECT_EQ(client.begin_frame_count(), 4); + EXPECT_EQ(client.begin_impl_frame_count(), 4); EXPECT_EQ(output_surface.pending_swap_buffers(), 1); } -TEST(OutputSurfaceTest, OptimisticAndRetroactiveBeginFrames) { +TEST(OutputSurfaceTest, OptimisticAndRetroactiveBeginImplFrames) { TestOutputSurface output_surface(TestContextProvider::Create()); EXPECT_FALSE(output_surface.HasClient()); @@ -314,47 +317,48 @@ TEST(OutputSurfaceTest, OptimisticAndRetroactiveBeginFrames) { EXPECT_FALSE(client.deferred_initialize_called()); output_surface.SetMaxFramesPending(2); - output_surface.EnableRetroactiveBeginFrameDeadline( + output_surface.EnableRetroactiveBeginImplFrameDeadline( true, false, base::TimeDelta()); - // 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); + // 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); // ...or retroactively triggered by a Swap. - output_surface.BeginFrameForTesting(); - EXPECT_EQ(client.begin_frame_count(), 2); + output_surface.BeginImplFrameForTesting(); + EXPECT_EQ(client.begin_impl_frame_count(), 2); output_surface.DidSwapBuffersForTesting(); - output_surface.SetNeedsBeginFrame(true); - EXPECT_EQ(client.begin_frame_count(), 3); + output_surface.SetNeedsBeginImplFrame(true); + EXPECT_EQ(client.begin_impl_frame_count(), 3); EXPECT_EQ(output_surface.pending_swap_buffers(), 1); - // Optimistically injected BeginFrames should be by throttled by pending + // Optimistically injected BeginImplFrames should be by throttled by pending // swap buffers... output_surface.DidSwapBuffersForTesting(); - output_surface.SetNeedsBeginFrame(true); - EXPECT_EQ(client.begin_frame_count(), 3); + output_surface.SetNeedsBeginImplFrame(true); + EXPECT_EQ(client.begin_impl_frame_count(), 3); EXPECT_EQ(output_surface.pending_swap_buffers(), 2); - output_surface.BeginFrameForTesting(); - EXPECT_EQ(client.begin_frame_count(), 3); + output_surface.BeginImplFrameForTesting(); + EXPECT_EQ(client.begin_impl_frame_count(), 3); // ...and retroactively triggered by OnSwapBuffersComplete output_surface.OnSwapBuffersCompleteForTesting(); - EXPECT_EQ(client.begin_frame_count(), 4); + EXPECT_EQ(client.begin_impl_frame_count(), 4); } -TEST(OutputSurfaceTest, RetroactiveBeginFrameDoesNotDoubleTickWhenEmulating) { +TEST(OutputSurfaceTest, + RetroactiveBeginImplFrameDoesNotDoubleTickWhenEmulating) { scoped_refptr<TestContextProvider> context_provider = TestContextProvider::Create(); @@ -368,13 +372,13 @@ TEST(OutputSurfaceTest, RetroactiveBeginFrameDoesNotDoubleTickWhenEmulating) { base::TimeDelta big_interval = base::TimeDelta::FromSeconds(10); - // Initialize BeginFrame emulation + // 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.InitializeBeginFrameEmulation( + output_surface.InitializeBeginImplFrameEmulation( task_runner.get(), throttle_frame_production, display_refresh_interval); @@ -385,28 +389,31 @@ TEST(OutputSurfaceTest, RetroactiveBeginFrameDoesNotDoubleTickWhenEmulating) { base::TimeTicks::Now() - base::TimeDelta::FromSeconds(1), big_interval); output_surface.SetMaxFramesPending(2); - output_surface.EnableRetroactiveBeginFrameDeadline(true, true, big_interval); + output_surface.EnableRetroactiveBeginImplFrameDeadline( + true, true, big_interval); - // We should start off with 0 BeginFrames - EXPECT_EQ(client.begin_frame_count(), 0); + // 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 SetNeedsBeginFrame(true) should start a retroactive BeginFrame. + // The first SetNeedsBeginImplFrame(true) should start a retroactive + // BeginImplFrame. EXPECT_FALSE(task_runner->HasPendingTask()); - output_surface.SetNeedsBeginFrame(true); + output_surface.SetNeedsBeginImplFrame(true); EXPECT_TRUE(task_runner->HasPendingTask()); EXPECT_GT(task_runner->NextPendingTaskDelay(), big_interval / 2); - EXPECT_EQ(client.begin_frame_count(), 1); + EXPECT_EQ(client.begin_impl_frame_count(), 1); - output_surface.SetNeedsBeginFrame(false); + output_surface.SetNeedsBeginImplFrame(false); EXPECT_TRUE(task_runner->HasPendingTask()); - EXPECT_EQ(client.begin_frame_count(), 1); + EXPECT_EQ(client.begin_impl_frame_count(), 1); - // 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); + // 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); EXPECT_TRUE(task_runner->HasPendingTask()); - EXPECT_EQ(client.begin_frame_count(), 1); + EXPECT_EQ(client.begin_impl_frame_count(), 1); } TEST(OutputSurfaceTest, MemoryAllocation) { |