| OLD | NEW |
| 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 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 host_->SetRootLayer(layer_tree_root); | 210 host_->SetRootLayer(layer_tree_root); |
| 211 | 211 |
| 212 TreeSynchronizer::SynchronizeTrees(layer_tree_root.get(), | 212 TreeSynchronizer::SynchronizeTrees(layer_tree_root.get(), |
| 213 host_->active_tree()); | 213 host_->active_tree()); |
| 214 LayerImpl* layer_impl_tree_root = | 214 LayerImpl* layer_impl_tree_root = |
| 215 host_->active_tree()->root_layer_for_testing(); | 215 host_->active_tree()->root_layer_for_testing(); |
| 216 ExpectTreesAreIdentical(layer_tree_root.get(), layer_impl_tree_root, | 216 ExpectTreesAreIdentical(layer_tree_root.get(), layer_impl_tree_root, |
| 217 host_->active_tree()); | 217 host_->active_tree()); |
| 218 | 218 |
| 219 // We have to push properties to pick up the destruction list pointer. | 219 // We have to push properties to pick up the destruction list pointer. |
| 220 TreeSynchronizer::PushLayerProperties(layer_tree_root->layer_tree_host(), | 220 TreeSynchronizer::PushLayerProperties( |
| 221 host_->active_tree()); | 221 layer_tree_root->layer_tree_host()->GetLayerTree(), host_->active_tree()); |
| 222 | 222 |
| 223 // Add a new layer to the Layer side | 223 // Add a new layer to the Layer side |
| 224 layer_tree_root->children()[0]->AddChild( | 224 layer_tree_root->children()[0]->AddChild( |
| 225 MockLayer::Create(&layer_impl_destruction_list)); | 225 MockLayer::Create(&layer_impl_destruction_list)); |
| 226 // Remove one. | 226 // Remove one. |
| 227 layer_tree_root->children()[1]->RemoveFromParent(); | 227 layer_tree_root->children()[1]->RemoveFromParent(); |
| 228 | 228 |
| 229 // Synchronize again. After the sync the trees should be equivalent and we | 229 // Synchronize again. After the sync the trees should be equivalent and we |
| 230 // should have created and destroyed one LayerImpl. | 230 // should have created and destroyed one LayerImpl. |
| 231 TreeSynchronizer::SynchronizeTrees(layer_tree_root.get(), | 231 TreeSynchronizer::SynchronizeTrees(layer_tree_root.get(), |
| (...skipping 27 matching lines...) Expand all Loading... |
| 259 host_->SetRootLayer(layer_tree_root); | 259 host_->SetRootLayer(layer_tree_root); |
| 260 | 260 |
| 261 TreeSynchronizer::SynchronizeTrees(layer_tree_root.get(), | 261 TreeSynchronizer::SynchronizeTrees(layer_tree_root.get(), |
| 262 host_->active_tree()); | 262 host_->active_tree()); |
| 263 LayerImpl* layer_impl_tree_root = | 263 LayerImpl* layer_impl_tree_root = |
| 264 host_->active_tree()->root_layer_for_testing(); | 264 host_->active_tree()->root_layer_for_testing(); |
| 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 // We have to push properties to pick up the destruction list pointer. | 268 // We have to push properties to pick up the destruction list pointer. |
| 269 TreeSynchronizer::PushLayerProperties(layer_tree_root->layer_tree_host(), | 269 TreeSynchronizer::PushLayerProperties( |
| 270 host_->active_tree()); | 270 layer_tree_root->layer_tree_host()->GetLayerTree(), host_->active_tree()); |
| 271 | 271 |
| 272 host_->active_tree()->ResetAllChangeTracking(); | 272 host_->active_tree()->ResetAllChangeTracking(); |
| 273 | 273 |
| 274 // re-insert the layer and sync again. | 274 // re-insert the layer and sync again. |
| 275 child2->RemoveFromParent(); | 275 child2->RemoveFromParent(); |
| 276 layer_tree_root->AddChild(child2); | 276 layer_tree_root->AddChild(child2); |
| 277 TreeSynchronizer::SynchronizeTrees(layer_tree_root.get(), | 277 TreeSynchronizer::SynchronizeTrees(layer_tree_root.get(), |
| 278 host_->active_tree()); | 278 host_->active_tree()); |
| 279 layer_impl_tree_root = host_->active_tree()->root_layer_for_testing(); | 279 layer_impl_tree_root = host_->active_tree()->root_layer_for_testing(); |
| 280 ExpectTreesAreIdentical(layer_tree_root.get(), layer_impl_tree_root, | 280 ExpectTreesAreIdentical(layer_tree_root.get(), layer_impl_tree_root, |
| 281 host_->active_tree()); | 281 host_->active_tree()); |
| 282 | 282 |
| 283 TreeSynchronizer::PushLayerProperties(layer_tree_root->layer_tree_host(), | 283 TreeSynchronizer::PushLayerProperties( |
| 284 host_->active_tree()); | 284 layer_tree_root->layer_tree_host()->GetLayerTree(), host_->active_tree()); |
| 285 | 285 |
| 286 // Check that the impl thread properly tracked the change. | 286 // Check that the impl thread properly tracked the change. |
| 287 EXPECT_FALSE(layer_impl_tree_root->LayerPropertyChanged()); | 287 EXPECT_FALSE(layer_impl_tree_root->LayerPropertyChanged()); |
| 288 EXPECT_FALSE( | 288 EXPECT_FALSE( |
| 289 host_->active_tree()->LayerById(child1_id)->LayerPropertyChanged()); | 289 host_->active_tree()->LayerById(child1_id)->LayerPropertyChanged()); |
| 290 EXPECT_TRUE( | 290 EXPECT_TRUE( |
| 291 host_->active_tree()->LayerById(child2_id)->LayerPropertyChanged()); | 291 host_->active_tree()->LayerById(child2_id)->LayerPropertyChanged()); |
| 292 host_->active_tree()->DetachLayers(); | 292 host_->active_tree()->DetachLayers(); |
| 293 } | 293 } |
| 294 | 294 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 309 layer_tree_root->children()[1]->SavePaintProperties(); | 309 layer_tree_root->children()[1]->SavePaintProperties(); |
| 310 int second_child_id = layer_tree_root->children()[1]->id(); | 310 int second_child_id = layer_tree_root->children()[1]->id(); |
| 311 | 311 |
| 312 TreeSynchronizer::SynchronizeTrees(layer_tree_root.get(), | 312 TreeSynchronizer::SynchronizeTrees(layer_tree_root.get(), |
| 313 host_->active_tree()); | 313 host_->active_tree()); |
| 314 LayerImpl* layer_impl_tree_root = | 314 LayerImpl* layer_impl_tree_root = |
| 315 host_->active_tree()->root_layer_for_testing(); | 315 host_->active_tree()->root_layer_for_testing(); |
| 316 ExpectTreesAreIdentical(layer_tree_root.get(), layer_impl_tree_root, | 316 ExpectTreesAreIdentical(layer_tree_root.get(), layer_impl_tree_root, |
| 317 host_->active_tree()); | 317 host_->active_tree()); |
| 318 | 318 |
| 319 TreeSynchronizer::PushLayerProperties(layer_tree_root->layer_tree_host(), | 319 TreeSynchronizer::PushLayerProperties( |
| 320 host_->active_tree()); | 320 layer_tree_root->layer_tree_host()->GetLayerTree(), host_->active_tree()); |
| 321 | 321 |
| 322 // Check that the property values we set on the Layer tree are reflected in | 322 // Check that the property values we set on the Layer tree are reflected in |
| 323 // the LayerImpl tree. | 323 // the LayerImpl tree. |
| 324 gfx::PointF root_layer_impl_position = layer_impl_tree_root->position(); | 324 gfx::PointF root_layer_impl_position = layer_impl_tree_root->position(); |
| 325 EXPECT_EQ(root_position.x(), root_layer_impl_position.x()); | 325 EXPECT_EQ(root_position.x(), root_layer_impl_position.x()); |
| 326 EXPECT_EQ(root_position.y(), root_layer_impl_position.y()); | 326 EXPECT_EQ(root_position.y(), root_layer_impl_position.y()); |
| 327 | 327 |
| 328 gfx::Size second_layer_impl_child_bounds = | 328 gfx::Size second_layer_impl_child_bounds = |
| 329 layer_impl_tree_root->layer_tree_impl() | 329 layer_impl_tree_root->layer_tree_impl() |
| 330 ->LayerById(second_child_id) | 330 ->LayerById(second_child_id) |
| (...skipping 28 matching lines...) Expand all Loading... |
| 359 host_->SetRootLayer(layer_tree_root); | 359 host_->SetRootLayer(layer_tree_root); |
| 360 | 360 |
| 361 TreeSynchronizer::SynchronizeTrees(layer_tree_root.get(), | 361 TreeSynchronizer::SynchronizeTrees(layer_tree_root.get(), |
| 362 host_->active_tree()); | 362 host_->active_tree()); |
| 363 LayerImpl* layer_impl_tree_root = | 363 LayerImpl* layer_impl_tree_root = |
| 364 host_->active_tree()->root_layer_for_testing(); | 364 host_->active_tree()->root_layer_for_testing(); |
| 365 ExpectTreesAreIdentical(layer_tree_root.get(), layer_impl_tree_root, | 365 ExpectTreesAreIdentical(layer_tree_root.get(), layer_impl_tree_root, |
| 366 host_->active_tree()); | 366 host_->active_tree()); |
| 367 | 367 |
| 368 // We have to push properties to pick up the destruction list pointer. | 368 // We have to push properties to pick up the destruction list pointer. |
| 369 TreeSynchronizer::PushLayerProperties(layer_tree_root->layer_tree_host(), | 369 TreeSynchronizer::PushLayerProperties( |
| 370 host_->active_tree()); | 370 layer_tree_root->layer_tree_host()->GetLayerTree(), host_->active_tree()); |
| 371 | 371 |
| 372 // Now restructure the tree to look like this: | 372 // Now restructure the tree to look like this: |
| 373 // root --- D ---+--- A | 373 // root --- D ---+--- A |
| 374 // | | 374 // | |
| 375 // +--- C --- B | 375 // +--- C --- B |
| 376 layer_tree_root->RemoveAllChildren(); | 376 layer_tree_root->RemoveAllChildren(); |
| 377 layer_d->RemoveAllChildren(); | 377 layer_d->RemoveAllChildren(); |
| 378 layer_tree_root->AddChild(layer_d); | 378 layer_tree_root->AddChild(layer_d); |
| 379 layer_a->RemoveAllChildren(); | 379 layer_a->RemoveAllChildren(); |
| 380 layer_d->AddChild(layer_a); | 380 layer_d->AddChild(layer_a); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 int old_tree_second_child_layer_id = old_layer_tree_root->children()[1]->id(); | 415 int old_tree_second_child_layer_id = old_layer_tree_root->children()[1]->id(); |
| 416 | 416 |
| 417 TreeSynchronizer::SynchronizeTrees(old_layer_tree_root.get(), | 417 TreeSynchronizer::SynchronizeTrees(old_layer_tree_root.get(), |
| 418 host_->active_tree()); | 418 host_->active_tree()); |
| 419 LayerImpl* layer_impl_tree_root = | 419 LayerImpl* layer_impl_tree_root = |
| 420 host_->active_tree()->root_layer_for_testing(); | 420 host_->active_tree()->root_layer_for_testing(); |
| 421 ExpectTreesAreIdentical(old_layer_tree_root.get(), layer_impl_tree_root, | 421 ExpectTreesAreIdentical(old_layer_tree_root.get(), layer_impl_tree_root, |
| 422 host_->active_tree()); | 422 host_->active_tree()); |
| 423 | 423 |
| 424 // We have to push properties to pick up the destruction list pointer. | 424 // We have to push properties to pick up the destruction list pointer. |
| 425 TreeSynchronizer::PushLayerProperties(old_layer_tree_root->layer_tree_host(), | 425 TreeSynchronizer::PushLayerProperties( |
| 426 host_->active_tree()); | 426 old_layer_tree_root->layer_tree_host()->GetLayerTree(), |
| 427 host_->active_tree()); |
| 427 | 428 |
| 428 // Remove all children on the Layer side. | 429 // Remove all children on the Layer side. |
| 429 old_layer_tree_root->RemoveAllChildren(); | 430 old_layer_tree_root->RemoveAllChildren(); |
| 430 | 431 |
| 431 // Synchronize again. After the sync all LayerImpls from the old tree should | 432 // Synchronize again. After the sync all LayerImpls from the old tree should |
| 432 // be deleted. | 433 // be deleted. |
| 433 scoped_refptr<Layer> new_layer_tree_root = Layer::Create(); | 434 scoped_refptr<Layer> new_layer_tree_root = Layer::Create(); |
| 434 host_->SetRootLayer(new_layer_tree_root); | 435 host_->SetRootLayer(new_layer_tree_root); |
| 435 | 436 |
| 436 TreeSynchronizer::SynchronizeTrees(new_layer_tree_root.get(), | 437 TreeSynchronizer::SynchronizeTrees(new_layer_tree_root.get(), |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 699 host_->CommitAndCreatePendingTree(); | 700 host_->CommitAndCreatePendingTree(); |
| 700 host_impl->ActivateSyncTree(); | 701 host_impl->ActivateSyncTree(); |
| 701 EXPECT_EQ( | 702 EXPECT_EQ( |
| 702 CombinedAnimationScale(0.f, 0.f), | 703 CombinedAnimationScale(0.f, 0.f), |
| 703 host_impl->active_tree()->property_trees()->GetAnimationScales( | 704 host_impl->active_tree()->property_trees()->GetAnimationScales( |
| 704 transform_layer->transform_tree_index(), host_impl->active_tree())); | 705 transform_layer->transform_tree_index(), host_impl->active_tree())); |
| 705 } | 706 } |
| 706 | 707 |
| 707 } // namespace | 708 } // namespace |
| 708 } // namespace cc | 709 } // namespace cc |
| OLD | NEW |