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

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

Issue 2080223010: cc: Clean up root_layer code in LTI (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase++ Created 4 years, 5 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
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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 } 168 }
169 return true; 169 return true;
170 } 170 }
171 }; 171 };
172 172
173 // Attempts to synchronizes a null tree. This should not crash, and should 173 // Attempts to synchronizes a null tree. This should not crash, and should
174 // return a null tree. 174 // return a null tree.
175 TEST_F(TreeSynchronizerTest, SyncNullTree) { 175 TEST_F(TreeSynchronizerTest, SyncNullTree) {
176 TreeSynchronizer::SynchronizeTrees(static_cast<Layer*>(NULL), 176 TreeSynchronizer::SynchronizeTrees(static_cast<Layer*>(NULL),
177 host_->active_tree()); 177 host_->active_tree());
178 EXPECT_TRUE(!host_->active_tree()->root_layer()); 178 EXPECT_TRUE(!host_->active_tree()->root_layer_for_testing());
179 } 179 }
180 180
181 // Constructs a very simple tree and synchronizes it without trying to reuse any 181 // Constructs a very simple tree and synchronizes it without trying to reuse any
182 // preexisting layers. 182 // preexisting layers.
183 TEST_F(TreeSynchronizerTest, SyncSimpleTreeFromEmpty) { 183 TEST_F(TreeSynchronizerTest, SyncSimpleTreeFromEmpty) {
184 scoped_refptr<Layer> layer_tree_root = Layer::Create(); 184 scoped_refptr<Layer> layer_tree_root = Layer::Create();
185 layer_tree_root->AddChild(Layer::Create()); 185 layer_tree_root->AddChild(Layer::Create());
186 layer_tree_root->AddChild(Layer::Create()); 186 layer_tree_root->AddChild(Layer::Create());
187 187
188 host_->SetRootLayer(layer_tree_root); 188 host_->SetRootLayer(layer_tree_root);
189 189
190 TreeSynchronizer::SynchronizeTrees(layer_tree_root.get(), 190 TreeSynchronizer::SynchronizeTrees(layer_tree_root.get(),
191 host_->active_tree()); 191 host_->active_tree());
192 192
193 ExpectTreesAreIdentical(layer_tree_root.get(), 193 ExpectTreesAreIdentical(layer_tree_root.get(),
194 host_->active_tree()->root_layer(), 194 host_->active_tree()->root_layer_for_testing(),
195 host_->active_tree()); 195 host_->active_tree());
196 } 196 }
197 197
198 // Constructs a very simple tree and synchronizes it attempting to reuse some 198 // Constructs a very simple tree and synchronizes it attempting to reuse some
199 // layers 199 // layers
200 TEST_F(TreeSynchronizerTest, SyncSimpleTreeReusingLayers) { 200 TEST_F(TreeSynchronizerTest, SyncSimpleTreeReusingLayers) {
201 std::vector<int> layer_impl_destruction_list; 201 std::vector<int> layer_impl_destruction_list;
202 202
203 scoped_refptr<Layer> layer_tree_root = 203 scoped_refptr<Layer> layer_tree_root =
204 MockLayer::Create(&layer_impl_destruction_list); 204 MockLayer::Create(&layer_impl_destruction_list);
205 layer_tree_root->AddChild(MockLayer::Create(&layer_impl_destruction_list)); 205 layer_tree_root->AddChild(MockLayer::Create(&layer_impl_destruction_list));
206 layer_tree_root->AddChild(MockLayer::Create(&layer_impl_destruction_list)); 206 layer_tree_root->AddChild(MockLayer::Create(&layer_impl_destruction_list));
207 int second_layer_impl_id = layer_tree_root->children()[1]->id(); 207 int second_layer_impl_id = layer_tree_root->children()[1]->id();
208 208
209 host_->SetRootLayer(layer_tree_root); 209 host_->SetRootLayer(layer_tree_root);
210 210
211 TreeSynchronizer::SynchronizeTrees(layer_tree_root.get(), 211 TreeSynchronizer::SynchronizeTrees(layer_tree_root.get(),
212 host_->active_tree()); 212 host_->active_tree());
213 LayerImpl* layer_impl_tree_root = host_->active_tree()->root_layer(); 213 LayerImpl* layer_impl_tree_root =
214 host_->active_tree()->root_layer_for_testing();
214 ExpectTreesAreIdentical(layer_tree_root.get(), layer_impl_tree_root, 215 ExpectTreesAreIdentical(layer_tree_root.get(), layer_impl_tree_root,
215 host_->active_tree()); 216 host_->active_tree());
216 217
217 // We have to push properties to pick up the destruction list pointer. 218 // We have to push properties to pick up the destruction list pointer.
218 TreeSynchronizer::PushLayerProperties(layer_tree_root->layer_tree_host(), 219 TreeSynchronizer::PushLayerProperties(layer_tree_root->layer_tree_host(),
219 host_->active_tree()); 220 host_->active_tree());
220 221
221 // Add a new layer to the Layer side 222 // Add a new layer to the Layer side
222 layer_tree_root->children()[0]->AddChild( 223 layer_tree_root->children()[0]->AddChild(
223 MockLayer::Create(&layer_impl_destruction_list)); 224 MockLayer::Create(&layer_impl_destruction_list));
224 // Remove one. 225 // Remove one.
225 layer_tree_root->children()[1]->RemoveFromParent(); 226 layer_tree_root->children()[1]->RemoveFromParent();
226 227
227 // Synchronize again. After the sync the trees should be equivalent and we 228 // Synchronize again. After the sync the trees should be equivalent and we
228 // should have created and destroyed one LayerImpl. 229 // should have created and destroyed one LayerImpl.
229 TreeSynchronizer::SynchronizeTrees(layer_tree_root.get(), 230 TreeSynchronizer::SynchronizeTrees(layer_tree_root.get(),
230 host_->active_tree()); 231 host_->active_tree());
231 layer_impl_tree_root = host_->active_tree()->root_layer(); 232 layer_impl_tree_root = host_->active_tree()->root_layer_for_testing();
232 233
233 ExpectTreesAreIdentical(layer_tree_root.get(), layer_impl_tree_root, 234 ExpectTreesAreIdentical(layer_tree_root.get(), layer_impl_tree_root,
234 host_->active_tree()); 235 host_->active_tree());
235 236
236 ASSERT_EQ(1u, layer_impl_destruction_list.size()); 237 ASSERT_EQ(1u, layer_impl_destruction_list.size());
237 EXPECT_EQ(second_layer_impl_id, layer_impl_destruction_list[0]); 238 EXPECT_EQ(second_layer_impl_id, layer_impl_destruction_list[0]);
238 239
239 host_->active_tree()->DetachLayers(); 240 host_->active_tree()->DetachLayers();
240 } 241 }
241 242
242 // Constructs a very simple tree and checks that a stacking-order change is 243 // Constructs a very simple tree and checks that a stacking-order change is
243 // tracked properly. 244 // tracked properly.
244 TEST_F(TreeSynchronizerTest, SyncSimpleTreeAndTrackStackingOrderChange) { 245 TEST_F(TreeSynchronizerTest, SyncSimpleTreeAndTrackStackingOrderChange) {
245 std::vector<int> layer_impl_destruction_list; 246 std::vector<int> layer_impl_destruction_list;
246 247
247 // Set up the tree and sync once. child2 needs to be synced here, too, even 248 // Set up the tree and sync once. child2 needs to be synced here, too, even
248 // though we remove it to set up the intended scenario. 249 // though we remove it to set up the intended scenario.
249 scoped_refptr<Layer> layer_tree_root = 250 scoped_refptr<Layer> layer_tree_root =
250 MockLayer::Create(&layer_impl_destruction_list); 251 MockLayer::Create(&layer_impl_destruction_list);
251 scoped_refptr<Layer> child2 = MockLayer::Create(&layer_impl_destruction_list); 252 scoped_refptr<Layer> child2 = MockLayer::Create(&layer_impl_destruction_list);
252 layer_tree_root->AddChild(MockLayer::Create(&layer_impl_destruction_list)); 253 layer_tree_root->AddChild(MockLayer::Create(&layer_impl_destruction_list));
253 layer_tree_root->AddChild(child2); 254 layer_tree_root->AddChild(child2);
254 int child1_id = layer_tree_root->children()[0]->id(); 255 int child1_id = layer_tree_root->children()[0]->id();
255 int child2_id = layer_tree_root->children()[1]->id(); 256 int child2_id = layer_tree_root->children()[1]->id();
256 257
257 host_->SetRootLayer(layer_tree_root); 258 host_->SetRootLayer(layer_tree_root);
258 259
259 TreeSynchronizer::SynchronizeTrees(layer_tree_root.get(), 260 TreeSynchronizer::SynchronizeTrees(layer_tree_root.get(),
260 host_->active_tree()); 261 host_->active_tree());
261 LayerImpl* layer_impl_tree_root = host_->active_tree()->root_layer(); 262 LayerImpl* layer_impl_tree_root =
263 host_->active_tree()->root_layer_for_testing();
262 ExpectTreesAreIdentical(layer_tree_root.get(), layer_impl_tree_root, 264 ExpectTreesAreIdentical(layer_tree_root.get(), layer_impl_tree_root,
263 host_->active_tree()); 265 host_->active_tree());
264 266
265 // We have to push properties to pick up the destruction list pointer. 267 // We have to push properties to pick up the destruction list pointer.
266 TreeSynchronizer::PushLayerProperties(layer_tree_root->layer_tree_host(), 268 TreeSynchronizer::PushLayerProperties(layer_tree_root->layer_tree_host(),
267 host_->active_tree()); 269 host_->active_tree());
268 270
269 host_->active_tree()->ResetAllChangeTracking(); 271 host_->active_tree()->ResetAllChangeTracking();
270 272
271 // re-insert the layer and sync again. 273 // re-insert the layer and sync again.
272 child2->RemoveFromParent(); 274 child2->RemoveFromParent();
273 layer_tree_root->AddChild(child2); 275 layer_tree_root->AddChild(child2);
274 TreeSynchronizer::SynchronizeTrees(layer_tree_root.get(), 276 TreeSynchronizer::SynchronizeTrees(layer_tree_root.get(),
275 host_->active_tree()); 277 host_->active_tree());
276 layer_impl_tree_root = host_->active_tree()->root_layer(); 278 layer_impl_tree_root = host_->active_tree()->root_layer_for_testing();
277 ExpectTreesAreIdentical(layer_tree_root.get(), layer_impl_tree_root, 279 ExpectTreesAreIdentical(layer_tree_root.get(), layer_impl_tree_root,
278 host_->active_tree()); 280 host_->active_tree());
279 281
280 TreeSynchronizer::PushLayerProperties(layer_tree_root->layer_tree_host(), 282 TreeSynchronizer::PushLayerProperties(layer_tree_root->layer_tree_host(),
281 host_->active_tree()); 283 host_->active_tree());
282 284
283 // Check that the impl thread properly tracked the change. 285 // Check that the impl thread properly tracked the change.
284 EXPECT_FALSE(layer_impl_tree_root->LayerPropertyChanged()); 286 EXPECT_FALSE(layer_impl_tree_root->LayerPropertyChanged());
285 EXPECT_FALSE( 287 EXPECT_FALSE(
286 host_->active_tree()->LayerById(child1_id)->LayerPropertyChanged()); 288 host_->active_tree()->LayerById(child1_id)->LayerPropertyChanged());
(...skipping 14 matching lines...) Expand all
301 gfx::PointF root_position = gfx::PointF(2.3f, 7.4f); 303 gfx::PointF root_position = gfx::PointF(2.3f, 7.4f);
302 layer_tree_root->SetPosition(root_position); 304 layer_tree_root->SetPosition(root_position);
303 305
304 gfx::Size second_child_bounds = gfx::Size(25, 53); 306 gfx::Size second_child_bounds = gfx::Size(25, 53);
305 layer_tree_root->children()[1]->SetBounds(second_child_bounds); 307 layer_tree_root->children()[1]->SetBounds(second_child_bounds);
306 layer_tree_root->children()[1]->SavePaintProperties(); 308 layer_tree_root->children()[1]->SavePaintProperties();
307 int second_child_id = layer_tree_root->children()[1]->id(); 309 int second_child_id = layer_tree_root->children()[1]->id();
308 310
309 TreeSynchronizer::SynchronizeTrees(layer_tree_root.get(), 311 TreeSynchronizer::SynchronizeTrees(layer_tree_root.get(),
310 host_->active_tree()); 312 host_->active_tree());
311 LayerImpl* layer_impl_tree_root = host_->active_tree()->root_layer(); 313 LayerImpl* layer_impl_tree_root =
314 host_->active_tree()->root_layer_for_testing();
312 ExpectTreesAreIdentical(layer_tree_root.get(), layer_impl_tree_root, 315 ExpectTreesAreIdentical(layer_tree_root.get(), layer_impl_tree_root,
313 host_->active_tree()); 316 host_->active_tree());
314 317
315 TreeSynchronizer::PushLayerProperties(layer_tree_root->layer_tree_host(), 318 TreeSynchronizer::PushLayerProperties(layer_tree_root->layer_tree_host(),
316 host_->active_tree()); 319 host_->active_tree());
317 320
318 // Check that the property values we set on the Layer tree are reflected in 321 // Check that the property values we set on the Layer tree are reflected in
319 // the LayerImpl tree. 322 // the LayerImpl tree.
320 gfx::PointF root_layer_impl_position = layer_impl_tree_root->position(); 323 gfx::PointF root_layer_impl_position = layer_impl_tree_root->position();
321 EXPECT_EQ(root_position.x(), root_layer_impl_position.x()); 324 EXPECT_EQ(root_position.x(), root_layer_impl_position.x());
(...skipping 27 matching lines...) Expand all
349 layer_b->AddChild(MockLayer::Create(&layer_impl_destruction_list)); 352 layer_b->AddChild(MockLayer::Create(&layer_impl_destruction_list));
350 353
351 scoped_refptr<Layer> layer_c = layer_b->children()[0]; 354 scoped_refptr<Layer> layer_c = layer_b->children()[0];
352 layer_b->AddChild(MockLayer::Create(&layer_impl_destruction_list)); 355 layer_b->AddChild(MockLayer::Create(&layer_impl_destruction_list));
353 scoped_refptr<Layer> layer_d = layer_b->children()[1]; 356 scoped_refptr<Layer> layer_d = layer_b->children()[1];
354 357
355 host_->SetRootLayer(layer_tree_root); 358 host_->SetRootLayer(layer_tree_root);
356 359
357 TreeSynchronizer::SynchronizeTrees(layer_tree_root.get(), 360 TreeSynchronizer::SynchronizeTrees(layer_tree_root.get(),
358 host_->active_tree()); 361 host_->active_tree());
359 LayerImpl* layer_impl_tree_root = host_->active_tree()->root_layer(); 362 LayerImpl* layer_impl_tree_root =
363 host_->active_tree()->root_layer_for_testing();
360 ExpectTreesAreIdentical(layer_tree_root.get(), layer_impl_tree_root, 364 ExpectTreesAreIdentical(layer_tree_root.get(), layer_impl_tree_root,
361 host_->active_tree()); 365 host_->active_tree());
362 366
363 // We have to push properties to pick up the destruction list pointer. 367 // We have to push properties to pick up the destruction list pointer.
364 TreeSynchronizer::PushLayerProperties(layer_tree_root->layer_tree_host(), 368 TreeSynchronizer::PushLayerProperties(layer_tree_root->layer_tree_host(),
365 host_->active_tree()); 369 host_->active_tree());
366 370
367 // Now restructure the tree to look like this: 371 // Now restructure the tree to look like this:
368 // root --- D ---+--- A 372 // root --- D ---+--- A
369 // | 373 // |
370 // +--- C --- B 374 // +--- C --- B
371 layer_tree_root->RemoveAllChildren(); 375 layer_tree_root->RemoveAllChildren();
372 layer_d->RemoveAllChildren(); 376 layer_d->RemoveAllChildren();
373 layer_tree_root->AddChild(layer_d); 377 layer_tree_root->AddChild(layer_d);
374 layer_a->RemoveAllChildren(); 378 layer_a->RemoveAllChildren();
375 layer_d->AddChild(layer_a); 379 layer_d->AddChild(layer_a);
376 layer_c->RemoveAllChildren(); 380 layer_c->RemoveAllChildren();
377 layer_d->AddChild(layer_c); 381 layer_d->AddChild(layer_c);
378 layer_b->RemoveAllChildren(); 382 layer_b->RemoveAllChildren();
379 layer_c->AddChild(layer_b); 383 layer_c->AddChild(layer_b);
380 384
381 // After another synchronize our trees should match and we should not have 385 // After another synchronize our trees should match and we should not have
382 // destroyed any LayerImpls 386 // destroyed any LayerImpls
383 TreeSynchronizer::SynchronizeTrees(layer_tree_root.get(), 387 TreeSynchronizer::SynchronizeTrees(layer_tree_root.get(),
384 host_->active_tree()); 388 host_->active_tree());
385 layer_impl_tree_root = host_->active_tree()->root_layer(); 389 layer_impl_tree_root = host_->active_tree()->root_layer_for_testing();
386 ExpectTreesAreIdentical(layer_tree_root.get(), layer_impl_tree_root, 390 ExpectTreesAreIdentical(layer_tree_root.get(), layer_impl_tree_root,
387 host_->active_tree()); 391 host_->active_tree());
388 392
389 EXPECT_EQ(0u, layer_impl_destruction_list.size()); 393 EXPECT_EQ(0u, layer_impl_destruction_list.size());
390 394
391 host_->active_tree()->DetachLayers(); 395 host_->active_tree()->DetachLayers();
392 } 396 }
393 397
394 // Constructs a very simple tree, synchronizes it, then synchronizes to a 398 // Constructs a very simple tree, synchronizes it, then synchronizes to a
395 // totally new tree. All layers from the old tree should be deleted. 399 // totally new tree. All layers from the old tree should be deleted.
396 TEST_F(TreeSynchronizerTest, SyncSimpleTreeThenDestroy) { 400 TEST_F(TreeSynchronizerTest, SyncSimpleTreeThenDestroy) {
397 std::vector<int> layer_impl_destruction_list; 401 std::vector<int> layer_impl_destruction_list;
398 402
399 scoped_refptr<Layer> old_layer_tree_root = 403 scoped_refptr<Layer> old_layer_tree_root =
400 MockLayer::Create(&layer_impl_destruction_list); 404 MockLayer::Create(&layer_impl_destruction_list);
401 old_layer_tree_root->AddChild( 405 old_layer_tree_root->AddChild(
402 MockLayer::Create(&layer_impl_destruction_list)); 406 MockLayer::Create(&layer_impl_destruction_list));
403 old_layer_tree_root->AddChild( 407 old_layer_tree_root->AddChild(
404 MockLayer::Create(&layer_impl_destruction_list)); 408 MockLayer::Create(&layer_impl_destruction_list));
405 409
406 host_->SetRootLayer(old_layer_tree_root); 410 host_->SetRootLayer(old_layer_tree_root);
407 411
408 int old_tree_root_layer_id = old_layer_tree_root->id(); 412 int old_tree_root_layer_id = old_layer_tree_root->id();
409 int old_tree_first_child_layer_id = old_layer_tree_root->children()[0]->id(); 413 int old_tree_first_child_layer_id = old_layer_tree_root->children()[0]->id();
410 int old_tree_second_child_layer_id = old_layer_tree_root->children()[1]->id(); 414 int old_tree_second_child_layer_id = old_layer_tree_root->children()[1]->id();
411 415
412 TreeSynchronizer::SynchronizeTrees(old_layer_tree_root.get(), 416 TreeSynchronizer::SynchronizeTrees(old_layer_tree_root.get(),
413 host_->active_tree()); 417 host_->active_tree());
414 LayerImpl* layer_impl_tree_root = host_->active_tree()->root_layer(); 418 LayerImpl* layer_impl_tree_root =
419 host_->active_tree()->root_layer_for_testing();
415 ExpectTreesAreIdentical(old_layer_tree_root.get(), layer_impl_tree_root, 420 ExpectTreesAreIdentical(old_layer_tree_root.get(), layer_impl_tree_root,
416 host_->active_tree()); 421 host_->active_tree());
417 422
418 // We have to push properties to pick up the destruction list pointer. 423 // We have to push properties to pick up the destruction list pointer.
419 TreeSynchronizer::PushLayerProperties(old_layer_tree_root->layer_tree_host(), 424 TreeSynchronizer::PushLayerProperties(old_layer_tree_root->layer_tree_host(),
420 host_->active_tree()); 425 host_->active_tree());
421 426
422 // Remove all children on the Layer side. 427 // Remove all children on the Layer side.
423 old_layer_tree_root->RemoveAllChildren(); 428 old_layer_tree_root->RemoveAllChildren();
424 429
425 // Synchronize again. After the sync all LayerImpls from the old tree should 430 // Synchronize again. After the sync all LayerImpls from the old tree should
426 // be deleted. 431 // be deleted.
427 scoped_refptr<Layer> new_layer_tree_root = Layer::Create(); 432 scoped_refptr<Layer> new_layer_tree_root = Layer::Create();
428 host_->SetRootLayer(new_layer_tree_root); 433 host_->SetRootLayer(new_layer_tree_root);
429 434
430 TreeSynchronizer::SynchronizeTrees(new_layer_tree_root.get(), 435 TreeSynchronizer::SynchronizeTrees(new_layer_tree_root.get(),
431 host_->active_tree()); 436 host_->active_tree());
432 layer_impl_tree_root = host_->active_tree()->root_layer(); 437 layer_impl_tree_root = host_->active_tree()->root_layer_for_testing();
433 ExpectTreesAreIdentical(new_layer_tree_root.get(), layer_impl_tree_root, 438 ExpectTreesAreIdentical(new_layer_tree_root.get(), layer_impl_tree_root,
434 host_->active_tree()); 439 host_->active_tree());
435 440
436 ASSERT_EQ(3u, layer_impl_destruction_list.size()); 441 ASSERT_EQ(3u, layer_impl_destruction_list.size());
437 442
438 EXPECT_TRUE(std::find(layer_impl_destruction_list.begin(), 443 EXPECT_TRUE(std::find(layer_impl_destruction_list.begin(),
439 layer_impl_destruction_list.end(), 444 layer_impl_destruction_list.end(),
440 old_tree_root_layer_id) != 445 old_tree_root_layer_id) !=
441 layer_impl_destruction_list.end()); 446 layer_impl_destruction_list.end());
442 EXPECT_TRUE(std::find(layer_impl_destruction_list.begin(), 447 EXPECT_TRUE(std::find(layer_impl_destruction_list.begin(),
(...skipping 25 matching lines...) Expand all
468 scoped_refptr<Layer> replica_layer_with_mask = Layer::Create(); 473 scoped_refptr<Layer> replica_layer_with_mask = Layer::Create();
469 scoped_refptr<Layer> replica_mask_layer = Layer::Create(); 474 scoped_refptr<Layer> replica_mask_layer = Layer::Create();
470 replica_layer_with_mask->SetMaskLayer(replica_mask_layer.get()); 475 replica_layer_with_mask->SetMaskLayer(replica_mask_layer.get());
471 layer_tree_root->children()[2]->SetReplicaLayer( 476 layer_tree_root->children()[2]->SetReplicaLayer(
472 replica_layer_with_mask.get()); 477 replica_layer_with_mask.get());
473 478
474 host_->SetRootLayer(layer_tree_root); 479 host_->SetRootLayer(layer_tree_root);
475 host_->BuildPropertyTreesForTesting(); 480 host_->BuildPropertyTreesForTesting();
476 host_->CommitAndCreateLayerImplTree(); 481 host_->CommitAndCreateLayerImplTree();
477 482
478 LayerImpl* layer_impl_tree_root = host_->active_tree()->root_layer(); 483 LayerImpl* layer_impl_tree_root =
484 host_->active_tree()->root_layer_for_testing();
479 ExpectTreesAreIdentical(layer_tree_root.get(), layer_impl_tree_root, 485 ExpectTreesAreIdentical(layer_tree_root.get(), layer_impl_tree_root,
480 host_->active_tree()); 486 host_->active_tree());
481 487
482 // Remove the mask layer. 488 // Remove the mask layer.
483 layer_tree_root->children()[0]->SetMaskLayer(NULL); 489 layer_tree_root->children()[0]->SetMaskLayer(NULL);
484 host_->BuildPropertyTreesForTesting(); 490 host_->BuildPropertyTreesForTesting();
485 host_->CommitAndCreateLayerImplTree(); 491 host_->CommitAndCreateLayerImplTree();
486 492
487 layer_impl_tree_root = host_->active_tree()->root_layer(); 493 layer_impl_tree_root = host_->active_tree()->root_layer_for_testing();
488 ExpectTreesAreIdentical(layer_tree_root.get(), layer_impl_tree_root, 494 ExpectTreesAreIdentical(layer_tree_root.get(), layer_impl_tree_root,
489 host_->active_tree()); 495 host_->active_tree());
490 496
491 // Remove the replica layer. 497 // Remove the replica layer.
492 layer_tree_root->children()[1]->SetReplicaLayer(NULL); 498 layer_tree_root->children()[1]->SetReplicaLayer(NULL);
493 host_->BuildPropertyTreesForTesting(); 499 host_->BuildPropertyTreesForTesting();
494 host_->CommitAndCreateLayerImplTree(); 500 host_->CommitAndCreateLayerImplTree();
495 501
496 layer_impl_tree_root = host_->active_tree()->root_layer(); 502 layer_impl_tree_root = host_->active_tree()->root_layer_for_testing();
497 ExpectTreesAreIdentical(layer_tree_root.get(), layer_impl_tree_root, 503 ExpectTreesAreIdentical(layer_tree_root.get(), layer_impl_tree_root,
498 host_->active_tree()); 504 host_->active_tree());
499 505
500 // Remove the replica mask. 506 // Remove the replica mask.
501 replica_layer_with_mask->SetMaskLayer(NULL); 507 replica_layer_with_mask->SetMaskLayer(NULL);
502 host_->BuildPropertyTreesForTesting(); 508 host_->BuildPropertyTreesForTesting();
503 host_->CommitAndCreateLayerImplTree(); 509 host_->CommitAndCreateLayerImplTree();
504 510
505 layer_impl_tree_root = host_->active_tree()->root_layer(); 511 layer_impl_tree_root = host_->active_tree()->root_layer_for_testing();
506 ExpectTreesAreIdentical(layer_tree_root.get(), layer_impl_tree_root, 512 ExpectTreesAreIdentical(layer_tree_root.get(), layer_impl_tree_root,
507 host_->active_tree()); 513 host_->active_tree());
508 514
509 host_->active_tree()->DetachLayers(); 515 host_->active_tree()->DetachLayers();
510 } 516 }
511 517
512 TEST_F(TreeSynchronizerTest, SynchronizeCurrentlyScrollingNode) { 518 TEST_F(TreeSynchronizerTest, SynchronizeCurrentlyScrollingNode) {
513 LayerTreeSettings settings; 519 LayerTreeSettings settings;
514 FakeLayerTreeHostImplClient client; 520 FakeLayerTreeHostImplClient client;
515 FakeImplTaskRunnerProvider task_runner_provider; 521 FakeImplTaskRunnerProvider task_runner_provider;
(...skipping 16 matching lines...) Expand all
532 538
533 transient_scroll_layer->SetScrollClipLayerId( 539 transient_scroll_layer->SetScrollClipLayerId(
534 transient_scroll_clip_layer->id()); 540 transient_scroll_clip_layer->id());
535 scroll_layer->SetScrollClipLayerId(scroll_clip_layer->id()); 541 scroll_layer->SetScrollClipLayerId(scroll_clip_layer->id());
536 host_->SetRootLayer(layer_tree_root); 542 host_->SetRootLayer(layer_tree_root);
537 host_->BuildPropertyTreesForTesting(); 543 host_->BuildPropertyTreesForTesting();
538 host_->CommitAndCreatePendingTree(); 544 host_->CommitAndCreatePendingTree();
539 host_impl->ActivateSyncTree(); 545 host_impl->ActivateSyncTree();
540 546
541 ExpectTreesAreIdentical(layer_tree_root.get(), 547 ExpectTreesAreIdentical(layer_tree_root.get(),
542 host_impl->active_tree()->root_layer(), 548 host_impl->active_tree()->root_layer_for_testing(),
543 host_impl->active_tree()); 549 host_impl->active_tree());
544 550
545 host_impl->active_tree()->SetCurrentlyScrollingLayer( 551 host_impl->active_tree()->SetCurrentlyScrollingLayer(
546 host_impl->active_tree()->LayerById(scroll_layer->id())); 552 host_impl->active_tree()->LayerById(scroll_layer->id()));
547 transient_scroll_layer->SetScrollClipLayerId(Layer::INVALID_ID); 553 transient_scroll_layer->SetScrollClipLayerId(Layer::INVALID_ID);
548 host_->BuildPropertyTreesForTesting(); 554 host_->BuildPropertyTreesForTesting();
549 555
550 host_impl->CreatePendingTree(); 556 host_impl->CreatePendingTree();
551 host_->CommitAndCreatePendingTree(); 557 host_->CommitAndCreatePendingTree();
552 host_impl->ActivateSyncTree(); 558 host_impl->ActivateSyncTree();
(...skipping 30 matching lines...) Expand all
583 scroll_layer->SetScrollClipLayerId(scroll_clip_layer->id()); 589 scroll_layer->SetScrollClipLayerId(scroll_clip_layer->id());
584 transient_scroll_layer->SetScrollOffset(gfx::ScrollOffset(1, 2)); 590 transient_scroll_layer->SetScrollOffset(gfx::ScrollOffset(1, 2));
585 scroll_layer->SetScrollOffset(gfx::ScrollOffset(10, 20)); 591 scroll_layer->SetScrollOffset(gfx::ScrollOffset(10, 20));
586 592
587 host_->SetRootLayer(layer_tree_root); 593 host_->SetRootLayer(layer_tree_root);
588 host_->BuildPropertyTreesForTesting(); 594 host_->BuildPropertyTreesForTesting();
589 host_->CommitAndCreatePendingTree(); 595 host_->CommitAndCreatePendingTree();
590 host_impl->ActivateSyncTree(); 596 host_impl->ActivateSyncTree();
591 597
592 ExpectTreesAreIdentical(layer_tree_root.get(), 598 ExpectTreesAreIdentical(layer_tree_root.get(),
593 host_impl->active_tree()->root_layer(), 599 host_impl->active_tree()->root_layer_for_testing(),
594 host_impl->active_tree()); 600 host_impl->active_tree());
595 601
596 // After the initial commit, scroll_offset_map in scroll_tree is expected to 602 // After the initial commit, scroll_offset_map in scroll_tree is expected to
597 // have one entry for scroll_layer and one entry for transient_scroll_layer, 603 // have one entry for scroll_layer and one entry for transient_scroll_layer,
598 // the pending base and active base must be the same at this stage. 604 // the pending base and active base must be the same at this stage.
599 ScrollTree::ScrollOffsetMap scroll_offset_map; 605 ScrollTree::ScrollOffsetMap scroll_offset_map;
600 scroll_offset_map[scroll_layer->id()] = new SyncedScrollOffset; 606 scroll_offset_map[scroll_layer->id()] = new SyncedScrollOffset;
601 scroll_offset_map[transient_scroll_layer->id()] = new SyncedScrollOffset; 607 scroll_offset_map[transient_scroll_layer->id()] = new SyncedScrollOffset;
602 scroll_offset_map[scroll_layer->id()]->PushFromMainThread( 608 scroll_offset_map[scroll_layer->id()]->PushFromMainThread(
603 scroll_layer->scroll_offset()); 609 scroll_layer->scroll_offset());
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 scroll_offset_map[scroll_layer->id()]->PullDeltaForMainThread(); 652 scroll_offset_map[scroll_layer->id()]->PullDeltaForMainThread();
647 scroll_offset_map[scroll_layer->id()]->SetCurrent(gfx::ScrollOffset(40, 50)); 653 scroll_offset_map[scroll_layer->id()]->SetCurrent(gfx::ScrollOffset(40, 50));
648 scroll_offset_map[scroll_layer->id()]->PushFromMainThread( 654 scroll_offset_map[scroll_layer->id()]->PushFromMainThread(
649 gfx::ScrollOffset(100, 100)); 655 gfx::ScrollOffset(100, 100));
650 scroll_offset_map[scroll_layer->id()]->PushPendingToActive(); 656 scroll_offset_map[scroll_layer->id()]->PushPendingToActive();
651 EXPECT_TRUE(is_equal(scroll_offset_map, scroll_tree.scroll_offset_map())); 657 EXPECT_TRUE(is_equal(scroll_offset_map, scroll_tree.scroll_offset_map()));
652 } 658 }
653 659
654 } // namespace 660 } // namespace
655 } // namespace cc 661 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/tree_synchronizer.cc ('k') | third_party/WebKit/Source/platform/graphics/CompositorMutableStateTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698