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

Unified Diff: cc/layers/picture_layer_impl_unittest.cc

Issue 676953003: cc: Always keep the PictureLayerImpl::twin_layer_ pointer valid. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: twins: . Created 6 years, 2 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
Index: cc/layers/picture_layer_impl_unittest.cc
diff --git a/cc/layers/picture_layer_impl_unittest.cc b/cc/layers/picture_layer_impl_unittest.cc
index 47e307ad009893f98c1e5155fa03180abb0234ca..6c72965f7d496f0e7034a7ddfd71389fe78df599 100644
--- a/cc/layers/picture_layer_impl_unittest.cc
+++ b/cc/layers/picture_layer_impl_unittest.cc
@@ -138,12 +138,23 @@ class PictureLayerImplTest : public testing::Test {
host_impl_.CreatePendingTree();
host_impl_.pending_tree()->SetPageScaleFactorAndLimits(1.f, 0.25f, 100.f);
LayerTreeImpl* pending_tree = host_impl_.pending_tree();
- // Clear recycled tree.
- pending_tree->DetachLayerTree();
- scoped_ptr<FakePictureLayerImpl> pending_layer =
- FakePictureLayerImpl::CreateWithPile(pending_tree, id_, pile);
- pending_layer->SetDrawsContent(true);
+ // Steal from the recycled tree.
+ scoped_ptr<LayerImpl> old_pending_root = pending_tree->DetachLayerTree();
+ DCHECK_IMPLIES(old_pending_root, old_pending_root->id() == id_);
+
+ scoped_ptr<FakePictureLayerImpl> pending_layer;
+ if (old_pending_root) {
+ pending_layer.reset(
+ static_cast<FakePictureLayerImpl*>(old_pending_root.release()));
+ pending_layer->SetPile(pile);
+ } else {
+ pending_layer =
+ FakePictureLayerImpl::CreateWithPile(pending_tree, id_, pile);
+ pending_layer->SetDrawsContent(true);
+ }
+ // The bounds() just mirror the pile size.
+ pending_layer->SetBounds(pending_layer->pile()->tiling_size());
pending_tree->SetRootLayer(pending_layer.Pass());
pending_layer_ = static_cast<FakePictureLayerImpl*>(
@@ -2210,12 +2221,11 @@ TEST_F(PictureLayerImplTest, HighResCreatedWhenBoundsShrink) {
// other words we want the pending layer to sync from the active layer.
pending_layer_->SetBounds(gfx::Size(1, 1));
pending_layer_->SetNeedsPostCommitInitialization();
- pending_layer_->set_twin_layer(nullptr);
- active_layer_->set_twin_layer(nullptr);
EXPECT_TRUE(pending_layer_->needs_post_commit_initialization());
// Update the draw properties: sync from active tree should happen here.
host_impl_.pending_tree()->UpdateDrawProperties();
+ EXPECT_FALSE(pending_layer_->needs_post_commit_initialization());
// Another sanity check.
ASSERT_EQ(1.f, pending_layer_->MinimumContentsScale());
@@ -4319,6 +4329,33 @@ TEST_F(OcclusionTrackingPictureLayerImplTest,
total_expected_occluded_tile_count);
}
+TEST_F(PictureLayerImplTest, PendingOrActiveTwinLayer) {
+ gfx::Size tile_size(102, 102);
+ gfx::Size layer_bounds(1000, 1000);
+
+ scoped_refptr<FakePicturePileImpl> pile =
+ FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
+ SetupPendingTree(pile);
+ EXPECT_FALSE(pending_layer_->GetPendingOrActiveTwinLayer());
+
+ ActivateTree();
+ EXPECT_FALSE(active_layer_->GetPendingOrActiveTwinLayer());
+
+ SetupPendingTree(pile);
+ EXPECT_TRUE(pending_layer_->GetPendingOrActiveTwinLayer());
+ EXPECT_TRUE(active_layer_->GetPendingOrActiveTwinLayer());
+ EXPECT_EQ(pending_layer_, active_layer_->GetPendingOrActiveTwinLayer());
+ EXPECT_EQ(active_layer_, pending_layer_->GetPendingOrActiveTwinLayer());
+
+ ActivateTree();
+ EXPECT_FALSE(active_layer_->GetPendingOrActiveTwinLayer());
+
+ // Make an empty pending tree.
+ host_impl_.CreatePendingTree();
+ host_impl_.pending_tree()->DetachLayerTree();
+ EXPECT_FALSE(active_layer_->GetPendingOrActiveTwinLayer());
+}
+
TEST_F(PictureLayerImplTest, RecycledTwinLayer) {
gfx::Size tile_size(102, 102);
gfx::Size layer_bounds(1000, 1000);
@@ -4340,7 +4377,9 @@ TEST_F(PictureLayerImplTest, RecycledTwinLayer) {
EXPECT_TRUE(active_layer_->GetRecycledTwinLayer());
EXPECT_EQ(old_pending_layer_, active_layer_->GetRecycledTwinLayer());
- host_impl_.ResetRecycleTreeForTesting();
+ // Make an empty pending tree.
+ host_impl_.CreatePendingTree();
+ host_impl_.pending_tree()->DetachLayerTree();
vmpstr 2014/10/24 16:47:05 I'm not sure this tests the same thing since we no
danakj 2014/10/24 16:53:30 I think the only way the layer can be deleted from
EXPECT_FALSE(active_layer_->GetRecycledTwinLayer());
}

Powered by Google App Engine
This is Rietveld 408576698