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

Unified Diff: cc/scheduler/scheduler_unittest.cc

Issue 227413011: Remove old texture path in TextureLayer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 8 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
« no previous file with comments | « cc/scheduler/scheduler_state_machine_unittest.cc ('k') | cc/test/fake_proxy.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/scheduler/scheduler_unittest.cc
diff --git a/cc/scheduler/scheduler_unittest.cc b/cc/scheduler/scheduler_unittest.cc
index 67a064b59d6e93cfefa37f02dc34dfb25edcc217..c40185063dc8d2d7016d929b6a1c0972a7d0b619 100644
--- a/cc/scheduler/scheduler_unittest.cc
+++ b/cc/scheduler/scheduler_unittest.cc
@@ -150,10 +150,6 @@ class FakeSchedulerClient : public SchedulerClient {
actions_.push_back("ScheduledActionBeginOutputSurfaceCreation");
states_.push_back(scheduler_->StateAsValue().release());
}
- virtual void ScheduledActionAcquireLayerTexturesForMainThread() OVERRIDE {
- actions_.push_back("ScheduledActionAcquireLayerTexturesForMainThread");
- states_.push_back(scheduler_->StateAsValue().release());
- }
virtual void ScheduledActionManageTiles() OVERRIDE {
actions_.push_back("ScheduledActionManageTiles");
states_.push_back(scheduler_->StateAsValue().release());
@@ -366,248 +362,6 @@ TEST(SchedulerTest, RequestCommitAfterBeginMainFrameSent) {
client.Reset();
}
-TEST(SchedulerTest, TextureAcquisitionCausesCommitInsteadOfDraw) {
- FakeSchedulerClient client;
- SchedulerSettings scheduler_settings;
- Scheduler* scheduler = client.CreateScheduler(scheduler_settings);
- scheduler->SetCanStart();
- scheduler->SetVisible(true);
- scheduler->SetCanDraw(true);
- EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client);
-
- InitializeOutputSurfaceAndFirstCommit(scheduler, &client);
- client.Reset();
- scheduler->SetNeedsRedraw();
- EXPECT_TRUE(scheduler->RedrawPending());
- EXPECT_SINGLE_ACTION("SetNeedsBeginImplFrame", client);
- EXPECT_TRUE(client.needs_begin_impl_frame());
-
- client.Reset();
- scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting());
- EXPECT_EQ(client.num_actions_(), 0);
- EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
- client.Reset();
- scheduler->OnBeginImplFrameDeadline();
- EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 2);
- EXPECT_ACTION("SetNeedsBeginImplFrame", client, 1, 2);
- EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
- EXPECT_FALSE(scheduler->RedrawPending());
- EXPECT_TRUE(client.needs_begin_impl_frame());
-
- client.Reset();
- scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting());
- EXPECT_EQ(client.num_actions_(), 0);
- EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
- client.Reset();
- scheduler->OnBeginImplFrameDeadline();
- EXPECT_SINGLE_ACTION("SetNeedsBeginImplFrame", client);
- EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
- EXPECT_FALSE(scheduler->RedrawPending());
- EXPECT_FALSE(client.needs_begin_impl_frame());
-
- client.Reset();
- scheduler->SetMainThreadNeedsLayerTextures();
- EXPECT_SINGLE_ACTION("ScheduledActionAcquireLayerTexturesForMainThread",
- client);
-
- // We should request a BeginImplFrame in anticipation of a draw.
- client.Reset();
- scheduler->SetNeedsRedraw();
- EXPECT_TRUE(scheduler->RedrawPending());
- EXPECT_SINGLE_ACTION("SetNeedsBeginImplFrame", client);
- EXPECT_TRUE(client.needs_begin_impl_frame());
-
- // No draw happens since the textures are acquired by the main thread.
- client.Reset();
- scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting());
- EXPECT_EQ(client.num_actions_(), 0);
- EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
- client.Reset();
- scheduler->OnBeginImplFrameDeadline();
- EXPECT_SINGLE_ACTION("SetNeedsBeginImplFrame", client);
- EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
- EXPECT_TRUE(scheduler->RedrawPending());
- EXPECT_TRUE(client.needs_begin_impl_frame());
-
- client.Reset();
- scheduler->SetNeedsCommit();
- EXPECT_EQ(0, client.num_actions_());
-
- client.Reset();
- scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting());
- EXPECT_SINGLE_ACTION("ScheduledActionSendBeginMainFrame", client);
- EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
-
- // Commit will release the texture.
- client.Reset();
- scheduler->NotifyBeginMainFrameStarted();
- scheduler->NotifyReadyToCommit();
- EXPECT_SINGLE_ACTION("ScheduledActionCommit", client);
- EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
- EXPECT_TRUE(scheduler->RedrawPending());
-
- // Now we can draw again after the commit happens.
- client.Reset();
- scheduler->OnBeginImplFrameDeadline();
- EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 2);
- EXPECT_ACTION("SetNeedsBeginImplFrame", client, 1, 2);
- EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
- EXPECT_FALSE(scheduler->RedrawPending());
- EXPECT_TRUE(client.needs_begin_impl_frame());
-
- // Make sure we stop requesting BeginImplFrames if we don't swap.
- client.Reset();
- scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting());
- EXPECT_EQ(client.num_actions_(), 0);
- EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
- client.Reset();
- scheduler->OnBeginImplFrameDeadline();
- EXPECT_SINGLE_ACTION("SetNeedsBeginImplFrame", client);
- EXPECT_FALSE(client.needs_begin_impl_frame());
-}
-
-TEST(SchedulerTest, TextureAcquisitionCollision) {
- FakeSchedulerClient client;
- SchedulerSettings scheduler_settings;
- Scheduler* scheduler = client.CreateScheduler(scheduler_settings);
- scheduler->SetCanStart();
- scheduler->SetVisible(true);
- scheduler->SetCanDraw(true);
-
- EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client);
- InitializeOutputSurfaceAndFirstCommit(scheduler, &client);
-
- client.Reset();
- scheduler->SetNeedsCommit();
- EXPECT_SINGLE_ACTION("SetNeedsBeginImplFrame", client);
-
- client.Reset();
- scheduler->SetMainThreadNeedsLayerTextures();
- EXPECT_SINGLE_ACTION(
- "ScheduledActionAcquireLayerTexturesForMainThread", client);
-
- client.Reset();
- scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting());
- EXPECT_SINGLE_ACTION("ScheduledActionSendBeginMainFrame", client);
- EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
-
- client.Reset();
- scheduler->OnBeginImplFrameDeadline();
- EXPECT_SINGLE_ACTION("SetNeedsBeginImplFrame", client);
-
- // Although the compositor cannot draw because textures are locked by main
- // thread, we continue requesting SetNeedsBeginImplFrame in anticipation of
- // the unlock.
- EXPECT_TRUE(client.needs_begin_impl_frame());
-
- // Trigger the commit.
- scheduler->NotifyBeginMainFrameStarted();
- scheduler->NotifyReadyToCommit();
- EXPECT_TRUE(client.needs_begin_impl_frame());
-
- // Between commit and draw, texture acquisition for main thread delayed,
- // and main thread blocks.
- client.Reset();
- scheduler->SetMainThreadNeedsLayerTextures();
- EXPECT_EQ(0, client.num_actions_());
-
- // No implicit commit is expected.
- client.Reset();
- scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting());
- EXPECT_EQ(client.num_actions_(), 0);
- EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
-
- client.Reset();
- scheduler->OnBeginImplFrameDeadline();
- EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 3);
- EXPECT_ACTION(
- "ScheduledActionAcquireLayerTexturesForMainThread", client, 1, 3);
- EXPECT_ACTION("SetNeedsBeginImplFrame", client, 2, 3);
- EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
- EXPECT_TRUE(client.needs_begin_impl_frame());
-
- // The compositor should not draw because textures are locked by main
- // thread.
- client.Reset();
- scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting());
- EXPECT_EQ(client.num_actions_(), 0);
- EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
- client.Reset();
- scheduler->OnBeginImplFrameDeadline();
- EXPECT_SINGLE_ACTION("SetNeedsBeginImplFrame", client);
- EXPECT_FALSE(client.needs_begin_impl_frame());
- EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
-
- // The impl thread need an explicit commit from the main thread to lock
- // the textures.
- client.Reset();
- scheduler->SetNeedsCommit();
- EXPECT_SINGLE_ACTION("SetNeedsBeginImplFrame", client);
- EXPECT_TRUE(client.needs_begin_impl_frame());
-
- client.Reset();
- scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting());
- EXPECT_SINGLE_ACTION("ScheduledActionSendBeginMainFrame", client);
- EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
- client.Reset();
-
- // Trigger the commit, which will trigger the deadline task early.
- scheduler->NotifyBeginMainFrameStarted();
- scheduler->NotifyReadyToCommit();
- EXPECT_SINGLE_ACTION("ScheduledActionCommit", client);
- EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
- EXPECT_TRUE(client.needs_begin_impl_frame());
- client.Reset();
-
- // Verify we draw on the next BeginImplFrame deadline
- scheduler->OnBeginImplFrameDeadline();
- EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 2);
- EXPECT_ACTION("SetNeedsBeginImplFrame", client, 1, 2);
- EXPECT_TRUE(client.needs_begin_impl_frame());
- EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
- client.Reset();
-}
-
-TEST(SchedulerTest, VisibilitySwitchWithTextureAcquisition) {
- FakeSchedulerClient client;
- SchedulerSettings scheduler_settings;
- Scheduler* scheduler = client.CreateScheduler(scheduler_settings);
- scheduler->SetCanStart();
- scheduler->SetVisible(true);
- scheduler->SetCanDraw(true);
-
- EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client);
- client.Reset();
- scheduler->DidCreateAndInitializeOutputSurface();
-
- scheduler->SetNeedsCommit();
- scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting());
- scheduler->OnBeginImplFrameDeadline();
- scheduler->NotifyBeginMainFrameStarted();
- scheduler->NotifyReadyToCommit();
- scheduler->SetMainThreadNeedsLayerTextures();
- scheduler->SetNeedsCommit();
- client.Reset();
- // Verify that pending texture acquisition fires when visibility
- // is lost in order to avoid a deadlock.
- scheduler->SetVisible(false);
- EXPECT_SINGLE_ACTION("ScheduledActionAcquireLayerTexturesForMainThread",
- client);
-
- client.Reset();
- scheduler->SetVisible(true);
- EXPECT_EQ(0, client.num_actions_());
- EXPECT_TRUE(client.needs_begin_impl_frame());
-
- // Regaining visibility with textures acquired by main thread while
- // compositor is waiting for first draw should result in a request
- // for a new frame in order to escape a deadlock.
- client.Reset();
- scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting());
- EXPECT_SINGLE_ACTION("ScheduledActionSendBeginMainFrame", client);
- EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
-}
-
class SchedulerClientThatsetNeedsDrawInsideDraw : public FakeSchedulerClient {
public:
virtual void ScheduledActionSendBeginMainFrame() OVERRIDE {}
« no previous file with comments | « cc/scheduler/scheduler_state_machine_unittest.cc ('k') | cc/test/fake_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698