| Index: cc/trees/layer_tree_host_unittest.cc
|
| diff --git a/cc/trees/layer_tree_host_unittest.cc b/cc/trees/layer_tree_host_unittest.cc
|
| index d7e784025aec1afbf124cd208de235a0ffa8037b..96977bd2de03815e8eb85160a70dcc2b2d33b9b4 100644
|
| --- a/cc/trees/layer_tree_host_unittest.cc
|
| +++ b/cc/trees/layer_tree_host_unittest.cc
|
| @@ -65,8 +65,7 @@ namespace {
|
| class LayerTreeHostTest : public LayerTreeTest {
|
| };
|
|
|
| -// Two setNeedsCommits in a row should lead to at least 1 commit and at least 1
|
| -// draw with frame 0.
|
| +// Two setNeedsCommits in a row should lead to 1 commit and 1 draw.
|
| class LayerTreeHostTestSetNeedsCommit1 : public LayerTreeHostTest {
|
| public:
|
| LayerTreeHostTestSetNeedsCommit1() : num_commits_(0), num_draws_(0) {}
|
| @@ -87,8 +86,8 @@ class LayerTreeHostTestSetNeedsCommit1 : public LayerTreeHostTest {
|
| }
|
|
|
| virtual void AfterTest() OVERRIDE {
|
| - EXPECT_GE(1, num_commits_);
|
| - EXPECT_GE(1, num_draws_);
|
| + EXPECT_EQ(num_commits_, 1);
|
| + EXPECT_EQ(num_draws_, 1);
|
| }
|
|
|
| private:
|
| @@ -623,7 +622,7 @@ class LayerTreeHostTestCompositeAndReadbackWhileInvisible
|
|
|
| virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); }
|
|
|
| - virtual void DidCommitAndDrawFrame() OVERRIDE {
|
| + virtual void DidCommit() OVERRIDE {
|
| num_commits_++;
|
| if (num_commits_ == 1) {
|
| layer_tree_host()->SetVisible(false);
|
| @@ -702,7 +701,8 @@ MULTI_THREAD_TEST_F(LayerTreeHostTestCommit);
|
| class LayerTreeHostTestFrameTimeUpdatesAfterActivationFails
|
| : public LayerTreeHostTest {
|
| public:
|
| - LayerTreeHostTestFrameTimeUpdatesAfterActivationFails() : frame_(0) {}
|
| + LayerTreeHostTestFrameTimeUpdatesAfterActivationFails()
|
| + : frame_count_with_pending_tree_(0) {}
|
|
|
| virtual void BeginTest() OVERRIDE {
|
| layer_tree_host()->SetViewportSize(gfx::Size(20, 20));
|
| @@ -711,9 +711,16 @@ class LayerTreeHostTestFrameTimeUpdatesAfterActivationFails
|
| PostSetNeedsCommitToMainThread();
|
| }
|
|
|
| + virtual void WillBeginFrameOnThread(LayerTreeHostImpl* host_impl,
|
| + const BeginFrameArgs& args) OVERRIDE {
|
| + if (host_impl->pending_tree())
|
| + frame_count_with_pending_tree_++;
|
| + }
|
| +
|
| virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE {
|
| - if (frame_ >= 1) {
|
| - EXPECT_NE(first_frame_time_, impl->CurrentFrameTimeTicks());
|
| + if (frame_count_with_pending_tree_ > 1) {
|
| + EXPECT_NE(first_frame_time_.ToInternalValue(),
|
| + impl->CurrentFrameTimeTicks().ToInternalValue());
|
| EndTest();
|
| return;
|
| }
|
| @@ -723,33 +730,18 @@ class LayerTreeHostTestFrameTimeUpdatesAfterActivationFails
|
| }
|
|
|
| virtual bool CanActivatePendingTree(LayerTreeHostImpl* impl) OVERRIDE {
|
| - if (frame_ >= 1)
|
| - return true;
|
| -
|
| - return false;
|
| + return frame_count_with_pending_tree_ > 1;
|
| }
|
|
|
| - virtual bool CanActivatePendingTreeIfNeeded(LayerTreeHostImpl* impl)
|
| - OVERRIDE {
|
| - frame_++;
|
| - if (frame_ == 1) {
|
| - first_frame_time_ = impl->CurrentFrameTimeTicks();
|
| -
|
| - // Since base::TimeTicks::Now() uses a low-resolution clock on
|
| - // Windows, we need to make sure that the clock has incremented past
|
| - // first_frame_time_.
|
| - while (first_frame_time_ == base::TimeTicks::Now()) {}
|
| -
|
| - return false;
|
| - }
|
| -
|
| - return true;
|
| + virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) OVERRIDE {
|
| + if (impl->settings().impl_side_painting)
|
| + EXPECT_NE(frame_count_with_pending_tree_, 1);
|
| }
|
|
|
| virtual void AfterTest() OVERRIDE {}
|
|
|
| private:
|
| - int frame_;
|
| + int frame_count_with_pending_tree_;
|
| base::TimeTicks first_frame_time_;
|
| };
|
|
|
| @@ -831,8 +823,8 @@ class LayerTreeHostTestStartPageScaleAnimation : public LayerTreeHostTest {
|
| layer_tree_host()->SetPageScaleFactorAndLimits(scale, 0.5f, 2.f);
|
| }
|
|
|
| - virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) OVERRIDE {
|
| - impl->ProcessScrollDeltas();
|
| + virtual void SwapBuffersOnThread(LayerTreeHostImpl* impl,
|
| + bool result) OVERRIDE {
|
| // We get one commit before the first draw, and the animation doesn't happen
|
| // until the second draw.
|
| switch (impl->active_tree()->source_frame_number()) {
|
| @@ -842,7 +834,6 @@ class LayerTreeHostTestStartPageScaleAnimation : public LayerTreeHostTest {
|
| break;
|
| case 1:
|
| EXPECT_EQ(1.f, impl->active_tree()->page_scale_factor());
|
| - PostSetNeedsRedrawToMainThread();
|
| break;
|
| case 2:
|
| EXPECT_EQ(1.25f, impl->active_tree()->page_scale_factor());
|
| @@ -853,7 +844,7 @@ class LayerTreeHostTestStartPageScaleAnimation : public LayerTreeHostTest {
|
| }
|
| }
|
|
|
| - virtual void DidCommitAndDrawFrame() OVERRIDE {
|
| + virtual void DidCommit() OVERRIDE {
|
| switch (layer_tree_host()->source_frame_number()) {
|
| case 1:
|
| layer_tree_host()->SetPageScaleFactorAndLimits(1.f, 0.5f, 2.f);
|
| @@ -1317,7 +1308,7 @@ class LayerTreeHostTestAtomicCommitWithPartialUpdate
|
| PostSetNeedsCommitToMainThread();
|
| }
|
|
|
| - virtual void DidCommitAndDrawFrame() OVERRIDE {
|
| + virtual void DidCommit() OVERRIDE {
|
| switch (layer_tree_host()->source_frame_number()) {
|
| case 1:
|
| parent_->SetNeedsDisplay();
|
| @@ -1448,7 +1439,7 @@ class LayerTreeHostTestFinishAllRendering : public LayerTreeHostTest {
|
| PostSetNeedsCommitToMainThread();
|
| }
|
|
|
| - virtual void DidCommitAndDrawFrame() OVERRIDE {
|
| + virtual void DidCommit() OVERRIDE {
|
| if (once_)
|
| return;
|
| once_ = true;
|
| @@ -1536,6 +1527,20 @@ class LayerTreeHostTestSurfaceNotAllocatedForLayersOutsideMemoryLimit
|
| PostSetNeedsCommitToMainThread();
|
| }
|
|
|
| + virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) OVERRIDE {
|
| + if (host_impl->active_tree()->source_frame_number() == 0) {
|
| + // Reduce the memory limit to only fit the root layer and one render
|
| + // surface. This prevents any contents drawing into surfaces
|
| + // from being allocated.
|
| + host_impl->SetMemoryPolicy(ManagedMemoryPolicy(100 * 100 * 4 * 2));
|
| + host_impl->SetDiscardBackBufferWhenNotVisible(true);
|
| +
|
| + // If ManageTiles ever deallocates resources before the subsequent draw,
|
| + // this test will need to change.
|
| + host_impl->ManageTiles();
|
| + }
|
| + }
|
| +
|
| virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE {
|
| Renderer* renderer = host_impl->renderer();
|
| RenderPass::Id surface1_render_pass_id = host_impl->active_tree()
|
| @@ -1550,25 +1555,18 @@ class LayerTreeHostTestSurfaceNotAllocatedForLayersOutsideMemoryLimit
|
| surface1_render_pass_id));
|
| EXPECT_TRUE(renderer->HaveCachedResourcesForRenderPassId(
|
| surface2_render_pass_id));
|
| -
|
| - // Reduce the memory limit to only fit the root layer and one render
|
| - // surface. This prevents any contents drawing into surfaces
|
| - // from being allocated.
|
| - host_impl->SetMemoryPolicy(ManagedMemoryPolicy(100 * 100 * 4 * 2));
|
| - host_impl->SetDiscardBackBufferWhenNotVisible(true);
|
| break;
|
| case 1:
|
| EXPECT_FALSE(renderer->HaveCachedResourcesForRenderPassId(
|
| surface1_render_pass_id));
|
| EXPECT_FALSE(renderer->HaveCachedResourcesForRenderPassId(
|
| surface2_render_pass_id));
|
| -
|
| EndTest();
|
| break;
|
| }
|
| }
|
|
|
| - virtual void DidCommitAndDrawFrame() OVERRIDE {
|
| + virtual void DidCommit() OVERRIDE {
|
| if (layer_tree_host()->source_frame_number() < 2)
|
| root_layer_->SetNeedsDisplay();
|
| }
|
| @@ -1874,15 +1872,11 @@ class LayerTreeHostTestContinuousInvalidate : public LayerTreeHostTest {
|
| PostSetNeedsCommitToMainThread();
|
| }
|
|
|
| - virtual void DidCommitAndDrawFrame() OVERRIDE {
|
| - if (num_draw_layers_ == 2)
|
| - return;
|
| - content_layer_->SetNeedsDisplay();
|
| - }
|
| + virtual void DidCommit() OVERRIDE { content_layer_->SetNeedsDisplay(); }
|
|
|
| virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE {
|
| - if (num_draw_layers_ == 1)
|
| - num_commit_complete_++;
|
| + EXPECT_EQ(num_draw_layers_, num_commit_complete_);
|
| + num_commit_complete_++;
|
| }
|
|
|
| virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE {
|
| @@ -1891,10 +1885,7 @@ class LayerTreeHostTestContinuousInvalidate : public LayerTreeHostTest {
|
| EndTest();
|
| }
|
|
|
| - virtual void AfterTest() OVERRIDE {
|
| - // Check that we didn't commit twice between first and second draw.
|
| - EXPECT_EQ(1, num_commit_complete_);
|
| - }
|
| + virtual void AfterTest() OVERRIDE {}
|
|
|
| private:
|
| FakeContentLayerClient client_;
|
| @@ -2272,8 +2263,10 @@ class LayerTreeHostTestBeginFrameNotificationShutdownWhileEnabled
|
| // once we return. End test while it's enabled.
|
| ImplThreadTaskRunner()->PostTask(
|
| FROM_HERE,
|
| - base::Bind(&LayerTreeHostTestBeginFrameNotification::EndTest,
|
| - base::Unretained(this)));
|
| + base::Bind(
|
| + &LayerTreeHostTestBeginFrameNotificationShutdownWhileEnabled::
|
| + EndTest,
|
| + base::Unretained(this)));
|
| }
|
|
|
| virtual void AfterTest() OVERRIDE {}
|
| @@ -2520,9 +2513,7 @@ class LayerTreeHostTestAsyncReadback : public LayerTreeHostTest {
|
| PostSetNeedsCommitToMainThread();
|
| }
|
|
|
| - virtual void DidCommitAndDrawFrame() OVERRIDE {
|
| - WaitForCallback();
|
| - }
|
| + virtual void DidCommit() OVERRIDE { WaitForCallback(); }
|
|
|
| void WaitForCallback() {
|
| base::MessageLoop::current()->PostTask(
|
| @@ -3204,6 +3195,10 @@ class LayerTreeHostTestNumFramesPending : public LayerTreeHostTest {
|
| // Round 4 done.
|
| EXPECT_EQ(2, frame_);
|
| layer_tree_host()->SetNeedsCommit();
|
| + // We can't SetNeedsRedraw immediately because it will race the commit.
|
| + break;
|
| + case 5:
|
| + EXPECT_EQ(2, frame_);
|
| layer_tree_host()->SetNeedsRedraw();
|
| break;
|
| }
|
| @@ -3526,7 +3521,7 @@ class LayerTreeHostTestLayersPushProperties : public LayerTreeHostTest {
|
| LayerTreeHostTest::SetupTree();
|
| }
|
|
|
| - virtual void DidCommitAndDrawFrame() OVERRIDE {
|
| + virtual void DidCommit() OVERRIDE {
|
| ++num_commits_;
|
|
|
| EXPECT_EQ(expected_push_properties_root_, root_->push_properties_count());
|
| @@ -3720,7 +3715,7 @@ class LayerTreeHostTestPropertyChangesDuringUpdateArePushed
|
| LayerTreeHostTest::SetupTree();
|
| }
|
|
|
| - virtual void DidCommitAndDrawFrame() OVERRIDE {
|
| + virtual void DidCommit() OVERRIDE {
|
| switch (layer_tree_host()->source_frame_number()) {
|
| case 0:
|
| break;
|
| @@ -3803,7 +3798,7 @@ class LayerTreeHostTestCasePushPropertiesThreeGrandChildren
|
| class LayerTreeHostTestPushPropertiesAddingToTreeRequiresPush
|
| : public LayerTreeHostTestCasePushPropertiesThreeGrandChildren {
|
| protected:
|
| - virtual void DidCommitAndDrawFrame() OVERRIDE {
|
| + virtual void DidCommit() OVERRIDE {
|
| int last_source_frame_number = layer_tree_host()->source_frame_number() - 1;
|
| switch (last_source_frame_number) {
|
| case 0:
|
| @@ -3843,7 +3838,7 @@ MULTI_THREAD_TEST_F(LayerTreeHostTestPushPropertiesAddingToTreeRequiresPush);
|
| class LayerTreeHostTestPushPropertiesRemovingChildStopsRecursion
|
| : public LayerTreeHostTestCasePushPropertiesThreeGrandChildren {
|
| protected:
|
| - virtual void DidCommitAndDrawFrame() OVERRIDE {
|
| + virtual void DidCommit() OVERRIDE {
|
| int last_source_frame_number = layer_tree_host()->source_frame_number() - 1;
|
| switch (last_source_frame_number) {
|
| case 0:
|
| @@ -3926,7 +3921,7 @@ MULTI_THREAD_TEST_F(LayerTreeHostTestPushPropertiesRemovingChildStopsRecursion);
|
| class LayerTreeHostTestPushPropertiesRemovingChildStopsRecursionWithPersistence
|
| : public LayerTreeHostTestCasePushPropertiesThreeGrandChildren {
|
| protected:
|
| - virtual void DidCommitAndDrawFrame() OVERRIDE {
|
| + virtual void DidCommit() OVERRIDE {
|
| int last_source_frame_number = layer_tree_host()->source_frame_number() - 1;
|
| switch (last_source_frame_number) {
|
| case 0:
|
| @@ -3974,7 +3969,7 @@ MULTI_THREAD_TEST_F(
|
| class LayerTreeHostTestPushPropertiesSetPropertiesWhileOutsideTree
|
| : public LayerTreeHostTestCasePushPropertiesThreeGrandChildren {
|
| protected:
|
| - virtual void DidCommitAndDrawFrame() OVERRIDE {
|
| + virtual void DidCommit() OVERRIDE {
|
| int last_source_frame_number = layer_tree_host()->source_frame_number() - 1;
|
| switch (last_source_frame_number) {
|
| case 0:
|
| @@ -4042,7 +4037,7 @@ MULTI_THREAD_TEST_F(
|
| class LayerTreeHostTestPushPropertiesSetPropertyInParentThenChild
|
| : public LayerTreeHostTestCasePushPropertiesThreeGrandChildren {
|
| protected:
|
| - virtual void DidCommitAndDrawFrame() OVERRIDE {
|
| + virtual void DidCommit() OVERRIDE {
|
| int last_source_frame_number = layer_tree_host()->source_frame_number() - 1;
|
| switch (last_source_frame_number) {
|
| case 0:
|
| @@ -4106,7 +4101,7 @@ MULTI_THREAD_TEST_F(
|
| class LayerTreeHostTestPushPropertiesSetPropertyInChildThenParent
|
| : public LayerTreeHostTestCasePushPropertiesThreeGrandChildren {
|
| protected:
|
| - virtual void DidCommitAndDrawFrame() OVERRIDE {
|
| + virtual void DidCommit() OVERRIDE {
|
| int last_source_frame_number = layer_tree_host()->source_frame_number() - 1;
|
| switch (last_source_frame_number) {
|
| case 0:
|
|
|