| 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/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 Loading... |
| 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) { | |
| 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 3806 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9412 | 9241 |
| 9413 child->SetTransform(singular); | 9242 child->SetTransform(singular); |
| 9414 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get()); | 9243 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get()); |
| 9415 update_list = GetUpdateLayerList(); | 9244 update_list = GetUpdateLayerList(); |
| 9416 EXPECT_FALSE(VerifyLayerInList(grandchild, update_list)); | 9245 EXPECT_FALSE(VerifyLayerInList(grandchild, update_list)); |
| 9417 child->SetTransform(gfx::Transform()); | 9246 child->SetTransform(gfx::Transform()); |
| 9418 | 9247 |
| 9419 child->SetHideLayerAndSubtree(true); | 9248 child->SetHideLayerAndSubtree(true); |
| 9420 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get()); | 9249 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get()); |
| 9421 update_list = GetUpdateLayerList(); | 9250 update_list = GetUpdateLayerList(); |
| 9251 EXPECT_TRUE(child->is_hidden()); |
| 9252 EXPECT_TRUE(grandchild->is_hidden()); |
| 9253 EXPECT_FALSE(VerifyLayerInList(child, update_list)); |
| 9422 EXPECT_FALSE(VerifyLayerInList(grandchild, update_list)); | 9254 EXPECT_FALSE(VerifyLayerInList(grandchild, update_list)); |
| 9423 child->SetHideLayerAndSubtree(false); | 9255 child->SetHideLayerAndSubtree(false); |
| 9424 | 9256 |
| 9425 gfx::Transform zero_z_scale; | 9257 gfx::Transform zero_z_scale; |
| 9426 zero_z_scale.Scale3d(1, 1, 0); | 9258 zero_z_scale.Scale3d(1, 1, 0); |
| 9427 child->SetTransform(zero_z_scale); | 9259 child->SetTransform(zero_z_scale); |
| 9428 | 9260 |
| 9429 // Add a transform animation with a start delay. Now, even though |child| has | 9261 // Add a transform animation with a start delay. Now, even though |child| has |
| 9430 // a singular transform, the subtree should still get processed. | 9262 // a singular transform, the subtree should still get processed. |
| 9431 int animation_id = 0; | 9263 int animation_id = 0; |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9525 gfx::Transform rotate_back_and_translate; | 9357 gfx::Transform rotate_back_and_translate; |
| 9526 rotate_back_and_translate.RotateAboutYAxis(180); | 9358 rotate_back_and_translate.RotateAboutYAxis(180); |
| 9527 rotate_back_and_translate.Translate(-10, 0); | 9359 rotate_back_and_translate.Translate(-10, 0); |
| 9528 | 9360 |
| 9529 child_ptr->test_properties()->transform = singular; | 9361 child_ptr->test_properties()->transform = singular; |
| 9530 host_impl.active_tree()->property_trees()->needs_rebuild = true; | 9362 host_impl.active_tree()->property_trees()->needs_rebuild = true; |
| 9531 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root_ptr); | 9363 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root_ptr); |
| 9532 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); | 9364 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); |
| 9533 child_ptr->test_properties()->transform = gfx::Transform(); | 9365 child_ptr->test_properties()->transform = gfx::Transform(); |
| 9534 | 9366 |
| 9535 child_ptr->test_properties()->hide_layer_and_subtree = true; | |
| 9536 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root_ptr); | |
| 9537 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); | |
| 9538 child_ptr->test_properties()->hide_layer_and_subtree = false; | |
| 9539 | |
| 9540 child_ptr->test_properties()->opacity = 0.f; | 9367 child_ptr->test_properties()->opacity = 0.f; |
| 9541 host_impl.active_tree()->property_trees()->needs_rebuild = true; | 9368 host_impl.active_tree()->property_trees()->needs_rebuild = true; |
| 9542 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root_ptr); | 9369 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root_ptr); |
| 9543 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); | 9370 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); |
| 9544 child_ptr->test_properties()->opacity = 1.f; | 9371 child_ptr->test_properties()->opacity = 1.f; |
| 9545 | 9372 |
| 9546 root_ptr->test_properties()->transform = singular; | 9373 root_ptr->test_properties()->transform = singular; |
| 9547 // Force transform tree to have a node for child, so that ancestor's | 9374 // Force transform tree to have a node for child, so that ancestor's |
| 9548 // invertible transform can be tested. | 9375 // invertible transform can be tested. |
| 9549 child_ptr->test_properties()->transform = rotate; | 9376 child_ptr->test_properties()->transform = rotate; |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9724 LayerImpl* child = AddChild<LayerImpl>(root); | 9551 LayerImpl* child = AddChild<LayerImpl>(root); |
| 9725 | 9552 |
| 9726 root->SetBounds(gfx::Size(100, 100)); | 9553 root->SetBounds(gfx::Size(100, 100)); |
| 9727 child->SetBounds(gfx::Size(10, 10)); | 9554 child->SetBounds(gfx::Size(10, 10)); |
| 9728 child->SetDrawsContent(true); | 9555 child->SetDrawsContent(true); |
| 9729 | 9556 |
| 9730 ExecuteCalculateDrawProperties(root); | 9557 ExecuteCalculateDrawProperties(root); |
| 9731 EXPECT_EQ(gfx::Rect(10, 10), child->visible_layer_rect()); | 9558 EXPECT_EQ(gfx::Rect(10, 10), child->visible_layer_rect()); |
| 9732 child->set_visible_layer_rect(gfx::Rect()); | 9559 child->set_visible_layer_rect(gfx::Rect()); |
| 9733 | 9560 |
| 9734 child->test_properties()->hide_layer_and_subtree = true; | |
| 9735 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | |
| 9736 ExecuteCalculateDrawProperties(root); | |
| 9737 EXPECT_EQ(gfx::Rect(0, 0), child->visible_layer_rect()); | |
| 9738 child->test_properties()->hide_layer_and_subtree = false; | |
| 9739 | |
| 9740 child->SetBounds(gfx::Size()); | 9561 child->SetBounds(gfx::Size()); |
| 9741 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 9562 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 9742 ExecuteCalculateDrawProperties(root); | 9563 ExecuteCalculateDrawProperties(root); |
| 9743 EXPECT_EQ(gfx::Rect(0, 0), child->visible_layer_rect()); | 9564 EXPECT_EQ(gfx::Rect(0, 0), child->visible_layer_rect()); |
| 9744 child->SetBounds(gfx::Size(10, 10)); | 9565 child->SetBounds(gfx::Size(10, 10)); |
| 9745 | 9566 |
| 9746 gfx::Transform rotate; | 9567 gfx::Transform rotate; |
| 9747 child->test_properties()->double_sided = false; | 9568 child->test_properties()->double_sided = false; |
| 9748 rotate.RotateAboutXAxis(180.f); | 9569 rotate.RotateAboutXAxis(180.f); |
| 9749 child->test_properties()->transform = rotate; | 9570 child->test_properties()->transform = rotate; |
| (...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10256 test_layer->SetDrawsContent(true); | 10077 test_layer->SetDrawsContent(true); |
| 10257 ExecuteCalculateDrawProperties(root); | 10078 ExecuteCalculateDrawProperties(root); |
| 10258 | 10079 |
| 10259 EXPECT_EQ(gfx::Rect(30, 30), root->clip_rect()); | 10080 EXPECT_EQ(gfx::Rect(30, 30), root->clip_rect()); |
| 10260 EXPECT_EQ(gfx::Rect(50, 50), render_surface->clip_rect()); | 10081 EXPECT_EQ(gfx::Rect(50, 50), render_surface->clip_rect()); |
| 10261 EXPECT_EQ(gfx::Rect(50, 50), test_layer->clip_rect()); | 10082 EXPECT_EQ(gfx::Rect(50, 50), test_layer->clip_rect()); |
| 10262 } | 10083 } |
| 10263 | 10084 |
| 10264 TEST_F(LayerTreeHostCommonTest, SubtreeIsHiddenTest) { | 10085 TEST_F(LayerTreeHostCommonTest, SubtreeIsHiddenTest) { |
| 10265 // Tests that subtree is hidden is updated. | 10086 // Tests that subtree is hidden is updated. |
| 10266 LayerImpl* root = root_layer_for_testing(); | 10087 scoped_refptr<Layer> root = Layer::Create(); |
| 10267 LayerImpl* hidden = AddChild<LayerImpl>(root); | 10088 scoped_refptr<Layer> hidden = Layer::Create(); |
| 10268 LayerImpl* test = AddChild<LayerImpl>(hidden); | 10089 scoped_refptr<Layer> test = Layer::Create(); |
| 10269 | 10090 |
| 10270 root->SetBounds(gfx::Size(30, 30)); | 10091 root->SetBounds(gfx::Size(30, 30)); |
| 10271 hidden->SetBounds(gfx::Size(30, 30)); | 10092 hidden->SetBounds(gfx::Size(30, 30)); |
| 10272 hidden->test_properties()->force_render_surface = true; | 10093 hidden->SetHideLayerAndSubtree(true); |
| 10273 hidden->test_properties()->hide_layer_and_subtree = true; | |
| 10274 test->SetBounds(gfx::Size(30, 30)); | 10094 test->SetBounds(gfx::Size(30, 30)); |
| 10275 test->test_properties()->force_render_surface = true; | |
| 10276 | 10095 |
| 10277 ExecuteCalculateDrawProperties(root); | 10096 root->AddChild(hidden); |
| 10278 EXPECT_EQ(0.f, | 10097 hidden->AddChild(test); |
| 10279 test->GetRenderSurface()->OwningEffectNode()->screen_space_opacity); | 10098 host()->SetRootLayer(root); |
| 10280 | 10099 |
| 10281 hidden->test_properties()->hide_layer_and_subtree = false; | 10100 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get()); |
| 10282 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 10101 EXPECT_TRUE(test->is_hidden()); |
| 10283 ExecuteCalculateDrawProperties(root); | 10102 // Hidden layers should have invalid property tree indices. |
| 10284 EXPECT_EQ(1.f, | 10103 const int kInvalidNodeId = -1; |
| 10285 test->GetRenderSurface()->OwningEffectNode()->screen_space_opacity); | 10104 EXPECT_EQ(test->effect_tree_index(), kInvalidNodeId); |
| 10105 EXPECT_EQ(test->scroll_tree_index(), kInvalidNodeId); |
| 10106 EXPECT_EQ(test->clip_tree_index(), kInvalidNodeId); |
| 10107 EXPECT_EQ(test->transform_tree_index(), kInvalidNodeId); |
| 10108 |
| 10109 hidden->SetHideLayerAndSubtree(false); |
| 10110 root->layer_tree_host()->property_trees()->needs_rebuild = true; |
| 10111 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get()); |
| 10112 EXPECT_FALSE(test->is_hidden()); |
| 10113 EXPECT_NE(test->effect_tree_index(), kInvalidNodeId); |
| 10114 EXPECT_NE(test->scroll_tree_index(), kInvalidNodeId); |
| 10115 EXPECT_NE(test->clip_tree_index(), kInvalidNodeId); |
| 10116 EXPECT_NE(test->transform_tree_index(), kInvalidNodeId); |
| 10286 } | 10117 } |
| 10287 | 10118 |
| 10288 TEST_F(LayerTreeHostCommonTest, TwoUnclippedRenderSurfaces) { | 10119 TEST_F(LayerTreeHostCommonTest, TwoUnclippedRenderSurfaces) { |
| 10289 LayerImpl* root = root_layer_for_testing(); | 10120 LayerImpl* root = root_layer_for_testing(); |
| 10290 LayerImpl* clip_layer = AddChild<LayerImpl>(root); | 10121 LayerImpl* clip_layer = AddChild<LayerImpl>(root); |
| 10291 LayerImpl* render_surface1 = AddChild<LayerImpl>(clip_layer); | 10122 LayerImpl* render_surface1 = AddChild<LayerImpl>(clip_layer); |
| 10292 LayerImpl* render_surface2 = AddChild<LayerImpl>(render_surface1); | 10123 LayerImpl* render_surface2 = AddChild<LayerImpl>(render_surface1); |
| 10293 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface2); | 10124 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface2); |
| 10294 | 10125 |
| 10295 root->SetBounds(gfx::Size(30, 30)); | 10126 root->SetBounds(gfx::Size(30, 30)); |
| (...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10865 | 10696 |
| 10866 // Check child layer draw properties. | 10697 // Check child layer draw properties. |
| 10867 EXPECT_EQ(gfx::Rect(10, 10), child->visible_layer_rect()); | 10698 EXPECT_EQ(gfx::Rect(10, 10), child->visible_layer_rect()); |
| 10868 EXPECT_EQ(gfx::Transform(), child->DrawTransform()); | 10699 EXPECT_EQ(gfx::Transform(), child->DrawTransform()); |
| 10869 EXPECT_EQ(gfx::Rect(10, 10), child->clip_rect()); | 10700 EXPECT_EQ(gfx::Rect(10, 10), child->clip_rect()); |
| 10870 EXPECT_EQ(gfx::Rect(10, 10), child->drawable_content_rect()); | 10701 EXPECT_EQ(gfx::Rect(10, 10), child->drawable_content_rect()); |
| 10871 } | 10702 } |
| 10872 | 10703 |
| 10873 } // namespace | 10704 } // namespace |
| 10874 } // namespace cc | 10705 } // namespace cc |
| OLD | NEW |