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

Unified Diff: cc/resources/tile_manager_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/resources/tile_manager_unittest.cc
diff --git a/cc/resources/tile_manager_unittest.cc b/cc/resources/tile_manager_unittest.cc
index 46f2e146454fdd9a911e26c139ee90127125dc49..2264131a7042be367ae415bcbdf7335606baf1f7 100644
--- a/cc/resources/tile_manager_unittest.cc
+++ b/cc/resources/tile_manager_unittest.cc
@@ -100,12 +100,23 @@ class TileManagerTilePriorityQueueTest : public testing::Test {
void SetupPendingTree(scoped_refptr<PicturePileImpl> pile) {
host_impl_.CreatePendingTree();
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*>(

Powered by Google App Engine
This is Rietveld 408576698