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

Side by Side Diff: cc/trees/tree_synchronizer_unittest.cc

Issue 2048863003: Reland of cc : Make LayerImpl destruction independent of tree hierarchy (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 unified diff | Download patch
« no previous file with comments | « cc/trees/tree_synchronizer.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/trees/tree_synchronizer.h" 5 #include "cc/trees/tree_synchronizer.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <set> 10 #include <set>
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 TreeSynchronizer::SynchronizeTrees(layer_tree_root.get(), 219 TreeSynchronizer::SynchronizeTrees(layer_tree_root.get(),
220 host_->active_tree()); 220 host_->active_tree());
221 layer_impl_tree_root = host_->active_tree()->root_layer(); 221 layer_impl_tree_root = host_->active_tree()->root_layer();
222 222
223 ExpectTreesAreIdentical(layer_tree_root.get(), layer_impl_tree_root, 223 ExpectTreesAreIdentical(layer_tree_root.get(), layer_impl_tree_root,
224 host_->active_tree()); 224 host_->active_tree());
225 225
226 ASSERT_EQ(1u, layer_impl_destruction_list.size()); 226 ASSERT_EQ(1u, layer_impl_destruction_list.size());
227 EXPECT_EQ(second_layer_impl_id, layer_impl_destruction_list[0]); 227 EXPECT_EQ(second_layer_impl_id, layer_impl_destruction_list[0]);
228 228
229 host_->active_tree()->ClearLayers(); 229 host_->active_tree()->DetachLayers();
230 } 230 }
231 231
232 // Constructs a very simple tree and checks that a stacking-order change is 232 // Constructs a very simple tree and checks that a stacking-order change is
233 // tracked properly. 233 // tracked properly.
234 TEST_F(TreeSynchronizerTest, SyncSimpleTreeAndTrackStackingOrderChange) { 234 TEST_F(TreeSynchronizerTest, SyncSimpleTreeAndTrackStackingOrderChange) {
235 std::vector<int> layer_impl_destruction_list; 235 std::vector<int> layer_impl_destruction_list;
236 236
237 // Set up the tree and sync once. child2 needs to be synced here, too, even 237 // Set up the tree and sync once. child2 needs to be synced here, too, even
238 // though we remove it to set up the intended scenario. 238 // though we remove it to set up the intended scenario.
239 scoped_refptr<Layer> layer_tree_root = 239 scoped_refptr<Layer> layer_tree_root =
(...skipping 25 matching lines...) Expand all
265 ExpectTreesAreIdentical(layer_tree_root.get(), layer_impl_tree_root, 265 ExpectTreesAreIdentical(layer_tree_root.get(), layer_impl_tree_root,
266 host_->active_tree()); 266 host_->active_tree());
267 267
268 TreeSynchronizer::PushLayerProperties(layer_tree_root->layer_tree_host(), 268 TreeSynchronizer::PushLayerProperties(layer_tree_root->layer_tree_host(),
269 host_->active_tree()); 269 host_->active_tree());
270 270
271 // Check that the impl thread properly tracked the change. 271 // Check that the impl thread properly tracked the change.
272 EXPECT_FALSE(layer_impl_tree_root->LayerPropertyChanged()); 272 EXPECT_FALSE(layer_impl_tree_root->LayerPropertyChanged());
273 EXPECT_FALSE(layer_impl_tree_root->children()[0]->LayerPropertyChanged()); 273 EXPECT_FALSE(layer_impl_tree_root->children()[0]->LayerPropertyChanged());
274 EXPECT_TRUE(layer_impl_tree_root->children()[1]->LayerPropertyChanged()); 274 EXPECT_TRUE(layer_impl_tree_root->children()[1]->LayerPropertyChanged());
275 host_->active_tree()->ClearLayers(); 275 host_->active_tree()->DetachLayers();
276 } 276 }
277 277
278 TEST_F(TreeSynchronizerTest, SyncSimpleTreeAndProperties) { 278 TEST_F(TreeSynchronizerTest, SyncSimpleTreeAndProperties) {
279 scoped_refptr<Layer> layer_tree_root = Layer::Create(); 279 scoped_refptr<Layer> layer_tree_root = Layer::Create();
280 layer_tree_root->AddChild(Layer::Create()); 280 layer_tree_root->AddChild(Layer::Create());
281 layer_tree_root->AddChild(Layer::Create()); 281 layer_tree_root->AddChild(Layer::Create());
282 282
283 host_->SetRootLayer(layer_tree_root); 283 host_->SetRootLayer(layer_tree_root);
284 284
285 // Pick some random properties to set. The values are not important, we're 285 // Pick some random properties to set. The values are not important, we're
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 // After another synchronize our trees should match and we should not have 364 // After another synchronize our trees should match and we should not have
365 // destroyed any LayerImpls 365 // destroyed any LayerImpls
366 TreeSynchronizer::SynchronizeTrees(layer_tree_root.get(), 366 TreeSynchronizer::SynchronizeTrees(layer_tree_root.get(),
367 host_->active_tree()); 367 host_->active_tree());
368 layer_impl_tree_root = host_->active_tree()->root_layer(); 368 layer_impl_tree_root = host_->active_tree()->root_layer();
369 ExpectTreesAreIdentical(layer_tree_root.get(), layer_impl_tree_root, 369 ExpectTreesAreIdentical(layer_tree_root.get(), layer_impl_tree_root,
370 host_->active_tree()); 370 host_->active_tree());
371 371
372 EXPECT_EQ(0u, layer_impl_destruction_list.size()); 372 EXPECT_EQ(0u, layer_impl_destruction_list.size());
373 373
374 host_->active_tree()->ClearLayers(); 374 host_->active_tree()->DetachLayers();
375 } 375 }
376 376
377 // Constructs a very simple tree, synchronizes it, then synchronizes to a 377 // Constructs a very simple tree, synchronizes it, then synchronizes to a
378 // totally new tree. All layers from the old tree should be deleted. 378 // totally new tree. All layers from the old tree should be deleted.
379 TEST_F(TreeSynchronizerTest, SyncSimpleTreeThenDestroy) { 379 TEST_F(TreeSynchronizerTest, SyncSimpleTreeThenDestroy) {
380 std::vector<int> layer_impl_destruction_list; 380 std::vector<int> layer_impl_destruction_list;
381 381
382 scoped_refptr<Layer> old_layer_tree_root = 382 scoped_refptr<Layer> old_layer_tree_root =
383 MockLayer::Create(&layer_impl_destruction_list); 383 MockLayer::Create(&layer_impl_destruction_list);
384 old_layer_tree_root->AddChild( 384 old_layer_tree_root->AddChild(
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 host_->active_tree()); 479 host_->active_tree());
480 480
481 // Remove the replica mask. 481 // Remove the replica mask.
482 replica_layer_with_mask->SetMaskLayer(NULL); 482 replica_layer_with_mask->SetMaskLayer(NULL);
483 TreeSynchronizer::SynchronizeTrees(layer_tree_root.get(), 483 TreeSynchronizer::SynchronizeTrees(layer_tree_root.get(),
484 host_->active_tree()); 484 host_->active_tree());
485 layer_impl_tree_root = host_->active_tree()->root_layer(); 485 layer_impl_tree_root = host_->active_tree()->root_layer();
486 ExpectTreesAreIdentical(layer_tree_root.get(), layer_impl_tree_root, 486 ExpectTreesAreIdentical(layer_tree_root.get(), layer_impl_tree_root,
487 host_->active_tree()); 487 host_->active_tree());
488 488
489 host_->active_tree()->ClearLayers(); 489 host_->active_tree()->DetachLayers();
490 } 490 }
491 491
492 TEST_F(TreeSynchronizerTest, SynchronizeCurrentlyScrollingNode) { 492 TEST_F(TreeSynchronizerTest, SynchronizeCurrentlyScrollingNode) {
493 LayerTreeSettings settings; 493 LayerTreeSettings settings;
494 FakeLayerTreeHostImplClient client; 494 FakeLayerTreeHostImplClient client;
495 FakeImplTaskRunnerProvider task_runner_provider; 495 FakeImplTaskRunnerProvider task_runner_provider;
496 FakeRenderingStatsInstrumentation stats_instrumentation; 496 FakeRenderingStatsInstrumentation stats_instrumentation;
497 TestSharedBitmapManager shared_bitmap_manager; 497 TestSharedBitmapManager shared_bitmap_manager;
498 TestTaskGraphRunner task_graph_runner; 498 TestTaskGraphRunner task_graph_runner;
499 FakeLayerTreeHostImpl* host_impl = host_->host_impl(); 499 FakeLayerTreeHostImpl* host_impl = host_->host_impl();
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 scroll_offset_map[scroll_layer->id()]->PullDeltaForMainThread(); 626 scroll_offset_map[scroll_layer->id()]->PullDeltaForMainThread();
627 scroll_offset_map[scroll_layer->id()]->SetCurrent(gfx::ScrollOffset(40, 50)); 627 scroll_offset_map[scroll_layer->id()]->SetCurrent(gfx::ScrollOffset(40, 50));
628 scroll_offset_map[scroll_layer->id()]->PushFromMainThread( 628 scroll_offset_map[scroll_layer->id()]->PushFromMainThread(
629 gfx::ScrollOffset(100, 100)); 629 gfx::ScrollOffset(100, 100));
630 scroll_offset_map[scroll_layer->id()]->PushPendingToActive(); 630 scroll_offset_map[scroll_layer->id()]->PushPendingToActive();
631 EXPECT_TRUE(is_equal(scroll_offset_map, scroll_tree.scroll_offset_map())); 631 EXPECT_TRUE(is_equal(scroll_offset_map, scroll_tree.scroll_offset_map()));
632 } 632 }
633 633
634 } // namespace 634 } // namespace
635 } // namespace cc 635 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/tree_synchronizer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698