summaryrefslogtreecommitdiffstats
path: root/cc/trees/layer_tree_host_unittest_picture.cc
diff options
context:
space:
mode:
authordanakj <danakj@chromium.org>2014-12-12 14:00:22 -0800
committerCommit bot <commit-bot@chromium.org>2014-12-12 22:01:49 +0000
commitbd6d7bc43094d50c0ce3d785aa270b49efb5959a (patch)
treea19d1c856f7dead94981c762256a7b19c63bd687 /cc/trees/layer_tree_host_unittest_picture.cc
parent2baf737555fb43ee6296be5d2e2562b6f3562a24 (diff)
downloadchromium_src-bd6d7bc43094d50c0ce3d785aa270b49efb5959a.zip
chromium_src-bd6d7bc43094d50c0ce3d785aa270b49efb5959a.tar.gz
chromium_src-bd6d7bc43094d50c0ce3d785aa270b49efb5959a.tar.bz2
cc: Mirror LiveTilesRect and tiles between active and recycled trees.
When the live tiles rect changes on the active tiling, we also remove tiles on the recycled tiling to avoid unshared tiles in the recycle tree. But when a tile is created on the active tree, we should also share the tile to the recycle tree. Since we're creating tiles, we also need to update the live tiles rect so tiles do not exist outside of it. So now the live tiles rect is simply updated on both trees at once. This ensures that on the next commit, if the picture layer did not get any invalidations, and doesn't push properties, it still has all the tiles in its live tiles rect so we can do ready-to-activate checks correctly. Secondly, when activating, if any tiles were present on the pending tree but are not on the active tree (can happen due to missing recordings on the active tree), then share those tiles to the active tree during activation. This patch fixes DCHECKs occuring in PictureLayerTiling's CloneTilesAndPropertiesFrom() where the pending and active tiling were not ending up with the same number of tiles. R=enne, vmpstr BUG=387116 Review URL: https://codereview.chromium.org/799463005 Cr-Commit-Position: refs/heads/master@{#308174}
Diffstat (limited to 'cc/trees/layer_tree_host_unittest_picture.cc')
-rw-r--r--cc/trees/layer_tree_host_unittest_picture.cc126
1 files changed, 126 insertions, 0 deletions
diff --git a/cc/trees/layer_tree_host_unittest_picture.cc b/cc/trees/layer_tree_host_unittest_picture.cc
index 4f49bb3..773798a 100644
--- a/cc/trees/layer_tree_host_unittest_picture.cc
+++ b/cc/trees/layer_tree_host_unittest_picture.cc
@@ -191,5 +191,131 @@ class LayerTreeHostPictureTestResizeViewportWithGpuRaster
SINGLE_AND_MULTI_THREAD_IMPL_TEST_F(
LayerTreeHostPictureTestResizeViewportWithGpuRaster);
+class LayerTreeHostPictureTestChangeLiveTilesRectWithRecycleTree
+ : public LayerTreeHostPictureTest {
+ void SetupTree() override {
+ frame_ = 0;
+ did_post_commit_ = false;
+
+ scoped_refptr<Layer> root = Layer::Create();
+ root->SetBounds(gfx::Size(100, 100));
+
+ // The layer is big enough that the live tiles rect won't cover the full
+ // layer.
+ client_.set_fill_with_nonsolid_color(true);
+ picture_ = FakePictureLayer::Create(&client_);
+ picture_->SetBounds(gfx::Size(100, 100000));
+ root->AddChild(picture_);
+
+ layer_tree_host()->SetRootLayer(root);
+ LayerTreeHostPictureTest::SetupTree();
+ }
+
+ void BeginTest() override { PostSetNeedsCommitToMainThread(); }
+
+ void DrawLayersOnThread(LayerTreeHostImpl* impl) override {
+ LayerImpl* child = impl->active_tree()->root_layer()->children()[0];
+ FakePictureLayerImpl* picture_impl =
+ static_cast<FakePictureLayerImpl*>(child);
+ FakePictureLayerImpl* recycled_impl = static_cast<FakePictureLayerImpl*>(
+ picture_impl->GetRecycledTwinLayer());
+
+ switch (++frame_) {
+ case 1: {
+ PictureLayerTiling* tiling = picture_impl->HighResTiling();
+ PictureLayerTiling* recycled_tiling = recycled_impl->HighResTiling();
+ int num_tiles_y = tiling->TilingDataForTesting().num_tiles_y();
+
+ // There should be tiles at the top of the picture layer but not at the
+ // bottom.
+ EXPECT_TRUE(tiling->TileAt(0, 0));
+ EXPECT_FALSE(tiling->TileAt(0, num_tiles_y));
+
+ // The recycled tiling matches it.
+ EXPECT_TRUE(recycled_tiling->TileAt(0, 0));
+ EXPECT_FALSE(recycled_tiling->TileAt(0, num_tiles_y));
+
+ // The live tiles rect matches on the recycled tree.
+ EXPECT_EQ(tiling->live_tiles_rect(),
+ recycled_tiling->live_tiles_rect());
+
+ // Make the bottom of the layer visible.
+ picture_impl->SetPosition(gfx::PointF(0.f, -100000.f + 100.f));
+ impl->SetNeedsRedraw();
+ break;
+ }
+ case 2: {
+ PictureLayerTiling* tiling = picture_impl->HighResTiling();
+ PictureLayerTiling* recycled_tiling = recycled_impl->HighResTiling();
+
+ // There not be tiles at the top of the layer now.
+ EXPECT_FALSE(tiling->TileAt(0, 0));
+
+ // The recycled twin tiling should not have unshared tiles at the top
+ // either.
+ EXPECT_FALSE(recycled_tiling->TileAt(0, 0));
+
+ // The live tiles rect matches on the recycled tree.
+ EXPECT_EQ(tiling->live_tiles_rect(),
+ recycled_tiling->live_tiles_rect());
+
+ // Make the top of the layer visible again.
+ picture_impl->SetPosition(gfx::PointF());
+ impl->SetNeedsRedraw();
+ break;
+ }
+ case 3: {
+ PictureLayerTiling* tiling = picture_impl->HighResTiling();
+ PictureLayerTiling* recycled_tiling = recycled_impl->HighResTiling();
+ int num_tiles_y = tiling->TilingDataForTesting().num_tiles_y();
+
+ // There should be tiles at the top of the picture layer again.
+ EXPECT_TRUE(tiling->TileAt(0, 0));
+ EXPECT_FALSE(tiling->TileAt(0, num_tiles_y));
+
+ // The recycled tiling should also have tiles at the top.
+ EXPECT_TRUE(recycled_tiling->TileAt(0, 0));
+ EXPECT_FALSE(recycled_tiling->TileAt(0, num_tiles_y));
+
+ // The live tiles rect matches on the recycled tree.
+ EXPECT_EQ(tiling->live_tiles_rect(),
+ recycled_tiling->live_tiles_rect());
+
+ // Make a new main frame without changing the picture layer at all, so
+ // it won't need to update or push properties.
+ did_post_commit_ = true;
+ PostSetNeedsCommitToMainThread();
+ break;
+ }
+ }
+ }
+
+ void WillActivateTreeOnThread(LayerTreeHostImpl* impl) override {
+ LayerImpl* child = impl->sync_tree()->root_layer()->children()[0];
+ FakePictureLayerImpl* picture_impl =
+ static_cast<FakePictureLayerImpl*>(child);
+ PictureLayerTiling* tiling = picture_impl->HighResTiling();
+ int num_tiles_y = tiling->TilingDataForTesting().num_tiles_y();
+
+ // The pending layer should always have tiles at the top of it each commit.
+ // The tile is part of the required for activation set so it should exist.
+ EXPECT_TRUE(tiling->TileAt(0, 0));
+ EXPECT_FALSE(tiling->TileAt(0, num_tiles_y));
+
+ if (did_post_commit_)
+ EndTest();
+ }
+
+ void AfterTest() override {}
+
+ int frame_;
+ bool did_post_commit_;
+ FakeContentLayerClient client_;
+ scoped_refptr<FakePictureLayer> picture_;
+};
+
+SINGLE_AND_MULTI_THREAD_IMPL_TEST_F(
+ LayerTreeHostPictureTestChangeLiveTilesRectWithRecycleTree);
+
} // namespace
} // namespace cc