| 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 bb315e79d02c152d57cb9ecb4dc8d343eee4acd1..be4940d7b349130590b7f10f5eeeea4971bcd92b 100644
|
| --- a/cc/trees/layer_tree_host_unittest.cc
|
| +++ b/cc/trees/layer_tree_host_unittest.cc
|
| @@ -6320,4 +6320,83 @@ class LayerTreeHostTestNoTasksBetweenWillAndDidCommit
|
|
|
| SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestNoTasksBetweenWillAndDidCommit);
|
|
|
| +// Verify that if a LayerImpl holds onto a copy request for multiple
|
| +// frames that it will continue to have a render surface through
|
| +// multiple commits, even though the Layer itself has no reason
|
| +// to have a render surface.
|
| +class LayerPreserveRenderSurfaceFromOutputRequests : public LayerTreeHostTest {
|
| + protected:
|
| + void SetupTree() override {
|
| + scoped_refptr<Layer> root = Layer::Create();
|
| + root->CreateRenderSurface();
|
| + root->SetBounds(gfx::Size(10, 10));
|
| + child_ = Layer::Create();
|
| + child_->SetBounds(gfx::Size(20, 20));
|
| + root->AddChild(child_);
|
| +
|
| + layer_tree_host()->SetRootLayer(root);
|
| + LayerTreeHostTest::SetupTree();
|
| + }
|
| +
|
| + static void CopyOutputCallback(scoped_ptr<CopyOutputResult> result) {}
|
| +
|
| + void BeginTest() override {
|
| + child_->RequestCopyOfOutput(
|
| + CopyOutputRequest::CreateBitmapRequest(base::Bind(CopyOutputCallback)));
|
| + EXPECT_TRUE(child_->HasCopyRequest());
|
| + PostSetNeedsCommitToMainThread();
|
| + }
|
| +
|
| + void DidCommit() override { EXPECT_FALSE(child_->HasCopyRequest()); }
|
| +
|
| + void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override {
|
| + LayerImpl* child_impl = host_impl->sync_tree()->LayerById(child_->id());
|
| +
|
| + switch (host_impl->sync_tree()->source_frame_number()) {
|
| + case 0:
|
| + EXPECT_TRUE(child_impl->HasCopyRequest());
|
| + EXPECT_TRUE(child_impl->render_surface());
|
| + break;
|
| + case 1:
|
| + if (host_impl->proxy()->CommitToActiveTree()) {
|
| + EXPECT_TRUE(child_impl->HasCopyRequest());
|
| + EXPECT_TRUE(child_impl->render_surface());
|
| + } else {
|
| + EXPECT_FALSE(child_impl->HasCopyRequest());
|
| + EXPECT_FALSE(child_impl->render_surface());
|
| + }
|
| + break;
|
| + default:
|
| + NOTREACHED();
|
| + break;
|
| + }
|
| + }
|
| +
|
| + void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override {
|
| + LayerImpl* child_impl = host_impl->active_tree()->LayerById(child_->id());
|
| + EXPECT_TRUE(child_impl->HasCopyRequest());
|
| + EXPECT_TRUE(child_impl->render_surface());
|
| +
|
| + switch (host_impl->active_tree()->source_frame_number()) {
|
| + case 0:
|
| + // Lose output surface to prevent drawing and cause another commit.
|
| + host_impl->DidLoseOutputSurface();
|
| + break;
|
| + case 1:
|
| + EndTest();
|
| + break;
|
| + default:
|
| + NOTREACHED();
|
| + break;
|
| + }
|
| + }
|
| +
|
| + void AfterTest() override {}
|
| +
|
| + private:
|
| + scoped_refptr<Layer> child_;
|
| +};
|
| +
|
| +SINGLE_AND_MULTI_THREAD_TEST_F(LayerPreserveRenderSurfaceFromOutputRequests);
|
| +
|
| } // namespace cc
|
|
|