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

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

Issue 2846653002: cc : Stop pushing layers from hidden subtrees at commit
Patch Set: . Created 3 years, 7 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/draw_property_utils.cc ('k') | cc/trees/occlusion_tracker_unittest.cc » ('j') | 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/layer_tree_host_common.h" 5 #include "cc/trees/layer_tree_host_common.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 5350 matching lines...) Expand 10 before | Expand all | Expand 10 after
5361 EXPECT_EQ(expect_not_lcd_text, child_->CanUseLCDText()); 5361 EXPECT_EQ(expect_not_lcd_text, child_->CanUseLCDText());
5362 EXPECT_EQ(expect_lcd_text, grand_child_->CanUseLCDText()); 5362 EXPECT_EQ(expect_lcd_text, grand_child_->CanUseLCDText());
5363 } 5363 }
5364 5364
5365 INSTANTIATE_TEST_CASE_P(LayerTreeHostCommonTest, 5365 INSTANTIATE_TEST_CASE_P(LayerTreeHostCommonTest,
5366 LCDTextTest, 5366 LCDTextTest,
5367 testing::Combine(testing::Bool(), 5367 testing::Combine(testing::Bool(),
5368 testing::Bool(), 5368 testing::Bool(),
5369 testing::Bool())); 5369 testing::Bool()));
5370 5370
5371 TEST_F(LayerTreeHostCommonTest, SubtreeHidden_SingleLayerImpl) {
jaydasika 2017/04/27 21:36:58 Deleted these tests as hidden subtrees now don't e
5372 FakeImplTaskRunnerProvider task_runner_provider;
5373 TestTaskGraphRunner task_graph_runner;
5374 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner);
5375 host_impl.CreatePendingTree();
5376
5377 std::unique_ptr<LayerImpl> root =
5378 LayerImpl::Create(host_impl.pending_tree(), 1);
5379 root->SetBounds(gfx::Size(50, 50));
5380 root->SetDrawsContent(true);
5381 LayerImpl* root_layer = root.get();
5382
5383 std::unique_ptr<LayerImpl> child =
5384 LayerImpl::Create(host_impl.pending_tree(), 2);
5385 child->SetBounds(gfx::Size(40, 40));
5386 child->SetDrawsContent(true);
5387
5388 std::unique_ptr<LayerImpl> grand_child =
5389 LayerImpl::Create(host_impl.pending_tree(), 3);
5390 grand_child->SetBounds(gfx::Size(30, 30));
5391 grand_child->SetDrawsContent(true);
5392 grand_child->test_properties()->hide_layer_and_subtree = true;
5393
5394 child->test_properties()->AddChild(std::move(grand_child));
5395 root->test_properties()->AddChild(std::move(child));
5396 host_impl.pending_tree()->SetRootLayerForTesting(std::move(root));
5397
5398 LayerImplList render_surface_layer_list;
5399 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
5400 root_layer, root_layer->bounds(), &render_surface_layer_list);
5401 inputs.can_adjust_raster_scales = true;
5402 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
5403
5404 // We should have one render surface and two layers. The grand child has
5405 // hidden itself.
5406 ASSERT_EQ(1u, render_surface_layer_list.size());
5407 ASSERT_EQ(2u, root_layer->GetRenderSurface()->layer_list().size());
5408 EXPECT_EQ(1, root_layer->GetRenderSurface()->layer_list().at(0)->id());
5409 EXPECT_EQ(2, root_layer->GetRenderSurface()->layer_list().at(1)->id());
5410 }
5411
5412 TEST_F(LayerTreeHostCommonTest, SubtreeHidden_TwoLayersImpl) {
5413 FakeImplTaskRunnerProvider task_runner_provider;
5414 TestTaskGraphRunner task_graph_runner;
5415 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner);
5416 host_impl.CreatePendingTree();
5417
5418 std::unique_ptr<LayerImpl> root =
5419 LayerImpl::Create(host_impl.pending_tree(), 1);
5420 root->SetBounds(gfx::Size(50, 50));
5421 root->SetDrawsContent(true);
5422 LayerImpl* root_layer = root.get();
5423
5424 std::unique_ptr<LayerImpl> child =
5425 LayerImpl::Create(host_impl.pending_tree(), 2);
5426 child->SetBounds(gfx::Size(40, 40));
5427 child->SetDrawsContent(true);
5428 child->test_properties()->hide_layer_and_subtree = true;
5429
5430 std::unique_ptr<LayerImpl> grand_child =
5431 LayerImpl::Create(host_impl.pending_tree(), 3);
5432 grand_child->SetBounds(gfx::Size(30, 30));
5433 grand_child->SetDrawsContent(true);
5434
5435 child->test_properties()->AddChild(std::move(grand_child));
5436 root->test_properties()->AddChild(std::move(child));
5437 host_impl.pending_tree()->SetRootLayerForTesting(std::move(root));
5438
5439 LayerImplList render_surface_layer_list;
5440 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
5441 root_layer, root_layer->bounds(), &render_surface_layer_list);
5442 inputs.can_adjust_raster_scales = true;
5443 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
5444
5445 // We should have one render surface and one layers. The child has
5446 // hidden itself and the grand child.
5447 ASSERT_EQ(1u, render_surface_layer_list.size());
5448 ASSERT_EQ(1u, root_layer->GetRenderSurface()->layer_list().size());
5449 EXPECT_EQ(1, root_layer->GetRenderSurface()->layer_list().at(0)->id());
5450 }
5451
5452 void EmptyCopyOutputCallback(std::unique_ptr<CopyOutputResult> result) {} 5371 void EmptyCopyOutputCallback(std::unique_ptr<CopyOutputResult> result) {}
5453 5372
5454 TEST_F(LayerTreeHostCommonTest, SubtreeHiddenWithCopyRequest) { 5373 TEST_F(LayerTreeHostCommonTest, SubtreeHiddenWithCopyRequest) {
5455 FakeImplTaskRunnerProvider task_runner_provider; 5374 scoped_refptr<Layer> root = Layer::Create();
5456 TestTaskGraphRunner task_graph_runner; 5375 scoped_refptr<Layer> copy_grand_parent = Layer::Create();
5457 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner); 5376 scoped_refptr<Layer> copy_parent = Layer::Create();
5458 host_impl.CreatePendingTree(); 5377 scoped_refptr<Layer> copy_layer = Layer::Create();
5378 scoped_refptr<Layer> copy_child = Layer::Create();
5379 scoped_refptr<Layer> copy_grand_child = Layer::Create();
5380 scoped_refptr<Layer> copy_grand_parent_sibling_before = Layer::Create();
5381 scoped_refptr<Layer> copy_grand_parent_sibling_after = Layer::Create();
5459 5382
5460 std::unique_ptr<LayerImpl> root =
5461 LayerImpl::Create(host_impl.pending_tree(), 1);
5462 root->SetBounds(gfx::Size(50, 50)); 5383 root->SetBounds(gfx::Size(50, 50));
5463 root->SetDrawsContent(true); 5384 copy_grand_parent->SetBounds(gfx::Size(50, 50));
5464 LayerImpl* root_layer = root.get(); 5385 copy_parent->SetBounds(gfx::Size(50, 50));
5386 copy_parent->SetForceRenderSurfaceForTesting(true);
5387 copy_layer->SetBounds(gfx::Size(50, 50));
5388 copy_child->SetBounds(gfx::Size(50, 50));
5389 copy_grand_child->SetBounds(gfx::Size(50, 50));
5390 copy_grand_parent_sibling_before->SetBounds(gfx::Size(50, 50));
5391 copy_grand_parent_sibling_after->SetBounds(gfx::Size(50, 50));
5465 5392
5466 std::unique_ptr<LayerImpl> copy_grand_parent = 5393 root->AddChild(copy_grand_parent_sibling_before);
5467 LayerImpl::Create(host_impl.pending_tree(), 2); 5394 root->AddChild(copy_grand_parent);
5468 copy_grand_parent->SetBounds(gfx::Size(40, 40)); 5395 root->AddChild(copy_grand_parent_sibling_after);
5469 copy_grand_parent->SetDrawsContent(true); 5396 copy_grand_parent->AddChild(copy_parent);
5470 LayerImpl* copy_grand_parent_layer = copy_grand_parent.get(); 5397 copy_parent->AddChild(copy_layer);
5398 copy_layer->AddChild(copy_child);
5399 copy_child->AddChild(copy_grand_child);
5400 host()->SetRootLayer(root);
5471 5401
5472 std::unique_ptr<LayerImpl> copy_parent = 5402 copy_layer->RequestCopyOfOutput(
5473 LayerImpl::Create(host_impl.pending_tree(), 3);
5474 copy_parent->SetBounds(gfx::Size(30, 30));
5475 copy_parent->SetDrawsContent(true);
5476 copy_parent->test_properties()->force_render_surface = true;
5477 LayerImpl* copy_parent_layer = copy_parent.get();
5478
5479 std::unique_ptr<LayerImpl> copy_request =
5480 LayerImpl::Create(host_impl.pending_tree(), 4);
5481 copy_request->SetBounds(gfx::Size(20, 20));
5482 copy_request->SetDrawsContent(true);
5483 copy_request->test_properties()->force_render_surface = true;
5484 LayerImpl* copy_layer = copy_request.get();
5485
5486 std::unique_ptr<LayerImpl> copy_child =
5487 LayerImpl::Create(host_impl.pending_tree(), 5);
5488 copy_child->SetBounds(gfx::Size(20, 20));
5489 copy_child->SetDrawsContent(true);
5490 LayerImpl* copy_child_layer = copy_child.get();
5491
5492 std::unique_ptr<LayerImpl> copy_grand_child =
5493 LayerImpl::Create(host_impl.pending_tree(), 6);
5494 copy_grand_child->SetBounds(gfx::Size(20, 20));
5495 copy_grand_child->SetDrawsContent(true);
5496 LayerImpl* copy_grand_child_layer = copy_grand_child.get();
5497
5498 std::unique_ptr<LayerImpl> copy_grand_parent_sibling_before =
5499 LayerImpl::Create(host_impl.pending_tree(), 7);
5500 copy_grand_parent_sibling_before->SetBounds(gfx::Size(40, 40));
5501 copy_grand_parent_sibling_before->SetDrawsContent(true);
5502 LayerImpl* copy_grand_parent_sibling_before_layer =
5503 copy_grand_parent_sibling_before.get();
5504
5505 std::unique_ptr<LayerImpl> copy_grand_parent_sibling_after =
5506 LayerImpl::Create(host_impl.pending_tree(), 8);
5507 copy_grand_parent_sibling_after->SetBounds(gfx::Size(40, 40));
5508 copy_grand_parent_sibling_after->SetDrawsContent(true);
5509 LayerImpl* copy_grand_parent_sibling_after_layer =
5510 copy_grand_parent_sibling_after.get();
5511
5512 copy_child->test_properties()->AddChild(std::move(copy_grand_child));
5513 copy_request->test_properties()->AddChild(std::move(copy_child));
5514 copy_parent->test_properties()->AddChild(std::move(copy_request));
5515 copy_grand_parent->test_properties()->AddChild(std::move(copy_parent));
5516 root->test_properties()->AddChild(
5517 std::move(copy_grand_parent_sibling_before));
5518 root->test_properties()->AddChild(std::move(copy_grand_parent));
5519 root->test_properties()->AddChild(std::move(copy_grand_parent_sibling_after));
5520 host_impl.pending_tree()->SetRootLayerForTesting(std::move(root));
5521
5522 // Hide the copy_grand_parent and its subtree. But make a copy request in that
5523 // hidden subtree on copy_layer. Also hide the copy grand child and its
5524 // subtree.
5525 copy_grand_parent_layer->test_properties()->hide_layer_and_subtree = true;
5526 copy_grand_parent_sibling_before_layer->test_properties()
5527 ->hide_layer_and_subtree = true;
5528 copy_grand_parent_sibling_after_layer->test_properties()
5529 ->hide_layer_and_subtree = true;
5530 copy_grand_child_layer->test_properties()->hide_layer_and_subtree = true;
5531
5532 copy_layer->test_properties()->copy_requests.push_back(
5533 CopyOutputRequest::CreateRequest(base::Bind(&EmptyCopyOutputCallback))); 5403 CopyOutputRequest::CreateRequest(base::Bind(&EmptyCopyOutputCallback)));
5534 5404
5535 LayerImplList render_surface_layer_list; 5405 copy_grand_parent->SetHideLayerAndSubtree(true);
5536 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 5406 copy_grand_parent_sibling_before->SetHideLayerAndSubtree(true);
5537 root_layer, root_layer->bounds(), &render_surface_layer_list); 5407 copy_grand_parent_sibling_after->SetHideLayerAndSubtree(true);
5538 inputs.can_adjust_raster_scales = true; 5408 copy_grand_child->SetHideLayerAndSubtree(true);
5539 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
5540 5409
5541 EXPECT_TRUE(root_layer->has_copy_requests_in_target_subtree()); 5410 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get());
5542 EXPECT_TRUE(copy_grand_parent_layer->has_copy_requests_in_target_subtree()); 5411 EXPECT_FALSE(copy_grand_parent->is_hidden());
5543 EXPECT_TRUE(copy_parent_layer->has_copy_requests_in_target_subtree()); 5412 EXPECT_TRUE(copy_grand_parent_sibling_after->is_hidden());
5544 EXPECT_TRUE(copy_layer->has_copy_requests_in_target_subtree()); 5413 EXPECT_TRUE(copy_grand_parent_sibling_before->is_hidden());
5414 EXPECT_TRUE(copy_grand_child->is_hidden());
5545 5415
5546 // We should have four render surfaces, one for the root, one for the grand 5416 EffectTree& tree = host()->property_trees()->effect_tree;
5547 // parent since it has opacity and two drawing descendants, one for the parent 5417 EffectNode* node = tree.Node(copy_grand_parent->effect_tree_index());
5548 // since it owns a surface, and one for the copy_layer.
5549 ASSERT_EQ(4u, render_surface_layer_list.size());
5550 EXPECT_EQ(root_layer->id(), render_surface_layer_list.at(0)->id());
5551 EXPECT_EQ(copy_grand_parent_layer->id(),
5552 render_surface_layer_list.at(1)->id());
5553 EXPECT_EQ(copy_parent_layer->id(), render_surface_layer_list.at(2)->id());
5554 EXPECT_EQ(copy_layer->id(), render_surface_layer_list.at(3)->id());
5555
5556 // The root render surface should have 2 contributing layers.
5557 ASSERT_EQ(2u, root_layer->GetRenderSurface()->layer_list().size());
5558 EXPECT_EQ(root_layer->id(),
5559 root_layer->GetRenderSurface()->layer_list().at(0)->id());
5560 EXPECT_EQ(copy_grand_parent_layer->id(),
5561 root_layer->GetRenderSurface()->layer_list().at(1)->id());
5562
5563 // Nothing actually draws into the copy parent, so only the copy_layer will
5564 // appear in its list, since it needs to be drawn for the copy request.
5565 ASSERT_EQ(1u, copy_parent_layer->GetRenderSurface()->layer_list().size());
5566 EXPECT_EQ(copy_layer->id(),
5567 copy_parent_layer->GetRenderSurface()->layer_list().at(0)->id());
5568
5569 // The copy_layer's render surface should have two contributing layers.
5570 ASSERT_EQ(2u, copy_layer->GetRenderSurface()->layer_list().size());
5571 EXPECT_EQ(copy_layer->id(),
5572 copy_layer->GetRenderSurface()->layer_list().at(0)->id());
5573 EXPECT_EQ(copy_child_layer->id(),
5574 copy_layer->GetRenderSurface()->layer_list().at(1)->id());
5575
5576 // copy_grand_parent, copy_parent shouldn't be drawn because they are hidden,
5577 // but the copy_layer and copy_child should be drawn for the copy request.
5578 // copy grand child should not be drawn as its hidden even in the copy
5579 // request.
5580 EffectTree& tree =
5581 root_layer->layer_tree_impl()->property_trees()->effect_tree;
5582 EffectNode* node = tree.Node(copy_grand_parent_layer->effect_tree_index());
5583 EXPECT_FALSE(node->is_drawn); 5418 EXPECT_FALSE(node->is_drawn);
5584 node = tree.Node(copy_parent_layer->effect_tree_index()); 5419 node = tree.Node(copy_parent->effect_tree_index());
5585 EXPECT_FALSE(node->is_drawn); 5420 EXPECT_FALSE(node->is_drawn);
5586 node = tree.Node(copy_layer->effect_tree_index()); 5421 node = tree.Node(copy_layer->effect_tree_index());
5587 EXPECT_TRUE(node->is_drawn); 5422 EXPECT_TRUE(node->is_drawn);
5588 node = tree.Node(copy_child_layer->effect_tree_index()); 5423 node = tree.Node(copy_child->effect_tree_index());
5589 EXPECT_TRUE(node->is_drawn); 5424 EXPECT_TRUE(node->is_drawn);
5590 node = tree.Node(copy_grand_child_layer->effect_tree_index());
5591 EXPECT_FALSE(node->is_drawn);
5592
5593 // Though copy_layer is drawn, it shouldn't contribute to drawn surface as its
5594 // actually hidden.
5595 EXPECT_FALSE(copy_layer->GetRenderSurface()->contributes_to_drawn_surface());
5596 } 5425 }
5597 5426
5598 TEST_F(LayerTreeHostCommonTest, ClippedOutCopyRequest) { 5427 TEST_F(LayerTreeHostCommonTest, ClippedOutCopyRequest) {
5599 FakeImplTaskRunnerProvider task_runner_provider; 5428 FakeImplTaskRunnerProvider task_runner_provider;
5600 TestTaskGraphRunner task_graph_runner; 5429 TestTaskGraphRunner task_graph_runner;
5601 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner); 5430 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner);
5602 host_impl.CreatePendingTree(); 5431 host_impl.CreatePendingTree();
5603 5432
5604 std::unique_ptr<LayerImpl> root = 5433 std::unique_ptr<LayerImpl> root =
5605 LayerImpl::Create(host_impl.pending_tree(), 1); 5434 LayerImpl::Create(host_impl.pending_tree(), 1);
(...skipping 3801 matching lines...) Expand 10 before | Expand all | Expand 10 after
9407 9236
9408 child->SetTransform(singular); 9237 child->SetTransform(singular);
9409 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get()); 9238 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get());
9410 update_list = GetUpdateLayerList(); 9239 update_list = GetUpdateLayerList();
9411 EXPECT_FALSE(VerifyLayerInList(grandchild, update_list)); 9240 EXPECT_FALSE(VerifyLayerInList(grandchild, update_list));
9412 child->SetTransform(gfx::Transform()); 9241 child->SetTransform(gfx::Transform());
9413 9242
9414 child->SetHideLayerAndSubtree(true); 9243 child->SetHideLayerAndSubtree(true);
9415 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get()); 9244 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get());
9416 update_list = GetUpdateLayerList(); 9245 update_list = GetUpdateLayerList();
9246 EXPECT_TRUE(child->is_hidden());
9247 EXPECT_TRUE(grandchild->is_hidden());
9248 EXPECT_FALSE(VerifyLayerInList(child, update_list));
9417 EXPECT_FALSE(VerifyLayerInList(grandchild, update_list)); 9249 EXPECT_FALSE(VerifyLayerInList(grandchild, update_list));
9418 child->SetHideLayerAndSubtree(false); 9250 child->SetHideLayerAndSubtree(false);
9419 9251
9420 gfx::Transform zero_z_scale; 9252 gfx::Transform zero_z_scale;
9421 zero_z_scale.Scale3d(1, 1, 0); 9253 zero_z_scale.Scale3d(1, 1, 0);
9422 child->SetTransform(zero_z_scale); 9254 child->SetTransform(zero_z_scale);
9423 9255
9424 // Add a transform animation with a start delay. Now, even though |child| has 9256 // Add a transform animation with a start delay. Now, even though |child| has
9425 // a singular transform, the subtree should still get processed. 9257 // a singular transform, the subtree should still get processed.
9426 int animation_id = 0; 9258 int animation_id = 0;
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
9520 gfx::Transform rotate_back_and_translate; 9352 gfx::Transform rotate_back_and_translate;
9521 rotate_back_and_translate.RotateAboutYAxis(180); 9353 rotate_back_and_translate.RotateAboutYAxis(180);
9522 rotate_back_and_translate.Translate(-10, 0); 9354 rotate_back_and_translate.Translate(-10, 0);
9523 9355
9524 child_ptr->test_properties()->transform = singular; 9356 child_ptr->test_properties()->transform = singular;
9525 host_impl.active_tree()->property_trees()->needs_rebuild = true; 9357 host_impl.active_tree()->property_trees()->needs_rebuild = true;
9526 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root_ptr); 9358 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root_ptr);
9527 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); 9359 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect());
9528 child_ptr->test_properties()->transform = gfx::Transform(); 9360 child_ptr->test_properties()->transform = gfx::Transform();
9529 9361
9530 child_ptr->test_properties()->hide_layer_and_subtree = true;
9531 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root_ptr);
9532 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect());
9533 child_ptr->test_properties()->hide_layer_and_subtree = false;
9534
9535 child_ptr->test_properties()->opacity = 0.f; 9362 child_ptr->test_properties()->opacity = 0.f;
9536 host_impl.active_tree()->property_trees()->needs_rebuild = true; 9363 host_impl.active_tree()->property_trees()->needs_rebuild = true;
9537 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root_ptr); 9364 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root_ptr);
9538 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); 9365 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect());
9539 child_ptr->test_properties()->opacity = 1.f; 9366 child_ptr->test_properties()->opacity = 1.f;
9540 9367
9541 root_ptr->test_properties()->transform = singular; 9368 root_ptr->test_properties()->transform = singular;
9542 // Force transform tree to have a node for child, so that ancestor's 9369 // Force transform tree to have a node for child, so that ancestor's
9543 // invertible transform can be tested. 9370 // invertible transform can be tested.
9544 child_ptr->test_properties()->transform = rotate; 9371 child_ptr->test_properties()->transform = rotate;
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
9719 LayerImpl* child = AddChild<LayerImpl>(root); 9546 LayerImpl* child = AddChild<LayerImpl>(root);
9720 9547
9721 root->SetBounds(gfx::Size(100, 100)); 9548 root->SetBounds(gfx::Size(100, 100));
9722 child->SetBounds(gfx::Size(10, 10)); 9549 child->SetBounds(gfx::Size(10, 10));
9723 child->SetDrawsContent(true); 9550 child->SetDrawsContent(true);
9724 9551
9725 ExecuteCalculateDrawProperties(root); 9552 ExecuteCalculateDrawProperties(root);
9726 EXPECT_EQ(gfx::Rect(10, 10), child->visible_layer_rect()); 9553 EXPECT_EQ(gfx::Rect(10, 10), child->visible_layer_rect());
9727 child->set_visible_layer_rect(gfx::Rect()); 9554 child->set_visible_layer_rect(gfx::Rect());
9728 9555
9729 child->test_properties()->hide_layer_and_subtree = true;
9730 root->layer_tree_impl()->property_trees()->needs_rebuild = true;
9731 ExecuteCalculateDrawProperties(root);
9732 EXPECT_EQ(gfx::Rect(0, 0), child->visible_layer_rect());
9733 child->test_properties()->hide_layer_and_subtree = false;
9734
9735 child->SetBounds(gfx::Size()); 9556 child->SetBounds(gfx::Size());
9736 root->layer_tree_impl()->property_trees()->needs_rebuild = true; 9557 root->layer_tree_impl()->property_trees()->needs_rebuild = true;
9737 ExecuteCalculateDrawProperties(root); 9558 ExecuteCalculateDrawProperties(root);
9738 EXPECT_EQ(gfx::Rect(0, 0), child->visible_layer_rect()); 9559 EXPECT_EQ(gfx::Rect(0, 0), child->visible_layer_rect());
9739 child->SetBounds(gfx::Size(10, 10)); 9560 child->SetBounds(gfx::Size(10, 10));
9740 9561
9741 gfx::Transform rotate; 9562 gfx::Transform rotate;
9742 child->test_properties()->double_sided = false; 9563 child->test_properties()->double_sided = false;
9743 rotate.RotateAboutXAxis(180.f); 9564 rotate.RotateAboutXAxis(180.f);
9744 child->test_properties()->transform = rotate; 9565 child->test_properties()->transform = rotate;
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after
10251 test_layer->SetDrawsContent(true); 10072 test_layer->SetDrawsContent(true);
10252 ExecuteCalculateDrawProperties(root); 10073 ExecuteCalculateDrawProperties(root);
10253 10074
10254 EXPECT_EQ(gfx::Rect(30, 30), root->clip_rect()); 10075 EXPECT_EQ(gfx::Rect(30, 30), root->clip_rect());
10255 EXPECT_EQ(gfx::Rect(50, 50), render_surface->clip_rect()); 10076 EXPECT_EQ(gfx::Rect(50, 50), render_surface->clip_rect());
10256 EXPECT_EQ(gfx::Rect(50, 50), test_layer->clip_rect()); 10077 EXPECT_EQ(gfx::Rect(50, 50), test_layer->clip_rect());
10257 } 10078 }
10258 10079
10259 TEST_F(LayerTreeHostCommonTest, SubtreeIsHiddenTest) { 10080 TEST_F(LayerTreeHostCommonTest, SubtreeIsHiddenTest) {
10260 // Tests that subtree is hidden is updated. 10081 // Tests that subtree is hidden is updated.
10261 LayerImpl* root = root_layer_for_testing(); 10082 scoped_refptr<Layer> root = Layer::Create();
10262 LayerImpl* hidden = AddChild<LayerImpl>(root); 10083 scoped_refptr<Layer> hidden = Layer::Create();
10263 LayerImpl* test = AddChild<LayerImpl>(hidden); 10084 scoped_refptr<Layer> test = Layer::Create();
10264 10085
10265 root->SetBounds(gfx::Size(30, 30)); 10086 root->SetBounds(gfx::Size(30, 30));
10266 hidden->SetBounds(gfx::Size(30, 30)); 10087 hidden->SetBounds(gfx::Size(30, 30));
10267 hidden->test_properties()->force_render_surface = true; 10088 hidden->SetHideLayerAndSubtree(true);
10268 hidden->test_properties()->hide_layer_and_subtree = true;
10269 test->SetBounds(gfx::Size(30, 30)); 10089 test->SetBounds(gfx::Size(30, 30));
10270 test->test_properties()->force_render_surface = true;
10271 10090
10272 ExecuteCalculateDrawProperties(root); 10091 root->AddChild(hidden);
10273 EXPECT_EQ(0.f, 10092 hidden->AddChild(test);
10274 test->GetRenderSurface()->OwningEffectNode()->screen_space_opacity); 10093 host()->SetRootLayer(root);
10275 10094
10276 hidden->test_properties()->hide_layer_and_subtree = false; 10095 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get());
10277 root->layer_tree_impl()->property_trees()->needs_rebuild = true; 10096 EXPECT_TRUE(test->is_hidden());
10278 ExecuteCalculateDrawProperties(root); 10097 // Hidden layers should have invalid property tree indices.
10279 EXPECT_EQ(1.f, 10098 const int kInvalidNodeId = -1;
10280 test->GetRenderSurface()->OwningEffectNode()->screen_space_opacity); 10099 EXPECT_EQ(test->effect_tree_index(), kInvalidNodeId);
10100 EXPECT_EQ(test->scroll_tree_index(), kInvalidNodeId);
10101 EXPECT_EQ(test->clip_tree_index(), kInvalidNodeId);
10102 EXPECT_EQ(test->transform_tree_index(), kInvalidNodeId);
10103
10104 hidden->SetHideLayerAndSubtree(false);
10105 root->layer_tree_host()->property_trees()->needs_rebuild = true;
10106 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get());
10107 EXPECT_FALSE(test->is_hidden());
10108 EXPECT_NE(test->effect_tree_index(), kInvalidNodeId);
10109 EXPECT_NE(test->scroll_tree_index(), kInvalidNodeId);
10110 EXPECT_NE(test->clip_tree_index(), kInvalidNodeId);
10111 EXPECT_NE(test->transform_tree_index(), kInvalidNodeId);
10281 } 10112 }
10282 10113
10283 TEST_F(LayerTreeHostCommonTest, TwoUnclippedRenderSurfaces) { 10114 TEST_F(LayerTreeHostCommonTest, TwoUnclippedRenderSurfaces) {
10284 LayerImpl* root = root_layer_for_testing(); 10115 LayerImpl* root = root_layer_for_testing();
10285 LayerImpl* clip_layer = AddChild<LayerImpl>(root); 10116 LayerImpl* clip_layer = AddChild<LayerImpl>(root);
10286 LayerImpl* render_surface1 = AddChild<LayerImpl>(clip_layer); 10117 LayerImpl* render_surface1 = AddChild<LayerImpl>(clip_layer);
10287 LayerImpl* render_surface2 = AddChild<LayerImpl>(render_surface1); 10118 LayerImpl* render_surface2 = AddChild<LayerImpl>(render_surface1);
10288 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface2); 10119 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface2);
10289 10120
10290 root->SetBounds(gfx::Size(30, 30)); 10121 root->SetBounds(gfx::Size(30, 30));
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after
10860 10691
10861 // Check child layer draw properties. 10692 // Check child layer draw properties.
10862 EXPECT_EQ(gfx::Rect(10, 10), child->visible_layer_rect()); 10693 EXPECT_EQ(gfx::Rect(10, 10), child->visible_layer_rect());
10863 EXPECT_EQ(gfx::Transform(), child->DrawTransform()); 10694 EXPECT_EQ(gfx::Transform(), child->DrawTransform());
10864 EXPECT_EQ(gfx::Rect(10, 10), child->clip_rect()); 10695 EXPECT_EQ(gfx::Rect(10, 10), child->clip_rect());
10865 EXPECT_EQ(gfx::Rect(10, 10), child->drawable_content_rect()); 10696 EXPECT_EQ(gfx::Rect(10, 10), child->drawable_content_rect());
10866 } 10697 }
10867 10698
10868 } // namespace 10699 } // namespace
10869 } // namespace cc 10700 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/draw_property_utils.cc ('k') | cc/trees/occlusion_tracker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698