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 1417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1428 root->SetBounds(gfx::Size(10, 10)); | 1428 root->SetBounds(gfx::Size(10, 10)); |
1429 render_surface1->SetBounds(gfx::Size(10, 10)); | 1429 render_surface1->SetBounds(gfx::Size(10, 10)); |
1430 render_surface1->test_properties()->force_render_surface = true; | 1430 render_surface1->test_properties()->force_render_surface = true; |
1431 render_surface1->test_properties()->opacity = 0.f; | 1431 render_surface1->test_properties()->opacity = 0.f; |
1432 render_surface1->SetDrawsContent(true); | 1432 render_surface1->SetDrawsContent(true); |
1433 FilterOperations filters; | 1433 FilterOperations filters; |
1434 filters.Append(FilterOperation::CreateBlurFilter(1.5f)); | 1434 filters.Append(FilterOperation::CreateBlurFilter(1.5f)); |
1435 render_surface1->test_properties()->background_filters = filters; | 1435 render_surface1->test_properties()->background_filters = filters; |
1436 child->SetBounds(gfx::Size(10, 10)); | 1436 child->SetBounds(gfx::Size(10, 10)); |
1437 child->SetDrawsContent(true); | 1437 child->SetDrawsContent(true); |
| 1438 root->layer_tree_impl()->SetElementIdsForTesting(); |
1438 | 1439 |
1439 { | 1440 { |
1440 LayerImplList render_surface_layer_list; | 1441 LayerImplList render_surface_layer_list; |
1441 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 1442 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
1442 root, root->bounds(), &render_surface_layer_list); | 1443 root, root->bounds(), &render_surface_layer_list); |
1443 inputs.can_adjust_raster_scales = true; | 1444 inputs.can_adjust_raster_scales = true; |
1444 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); | 1445 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); |
1445 EXPECT_EQ(2U, render_surface_layer_list.size()); | 1446 EXPECT_EQ(2U, render_surface_layer_list.size()); |
1446 } | 1447 } |
1447 // The layer is fully transparent, but has a background filter, so it | 1448 // The layer is fully transparent, but has a background filter, so it |
1448 // shouldn't be skipped and should be drawn. | 1449 // shouldn't be skipped and should be drawn. |
1449 ASSERT_TRUE(root->GetRenderSurface()); | 1450 ASSERT_TRUE(root->GetRenderSurface()); |
1450 EXPECT_EQ(1U, root->GetRenderSurface()->layer_list().size()); | 1451 EXPECT_EQ(1U, root->GetRenderSurface()->layer_list().size()); |
1451 EXPECT_EQ(gfx::RectF(0, 0, 10, 10), | 1452 EXPECT_EQ(gfx::RectF(0, 0, 10, 10), |
1452 root->GetRenderSurface()->DrawableContentRect()); | 1453 root->GetRenderSurface()->DrawableContentRect()); |
1453 EffectTree& effect_tree = | 1454 EffectTree& effect_tree = |
1454 root->layer_tree_impl()->property_trees()->effect_tree; | 1455 root->layer_tree_impl()->property_trees()->effect_tree; |
1455 EffectNode* node = effect_tree.Node(render_surface1->effect_tree_index()); | 1456 EffectNode* node = effect_tree.Node(render_surface1->effect_tree_index()); |
1456 EXPECT_TRUE(node->is_drawn); | 1457 EXPECT_TRUE(node->is_drawn); |
1457 | 1458 |
1458 // When root is transparent, the layer should not be drawn. | 1459 // When root is transparent, the layer should not be drawn. |
1459 effect_tree.OnOpacityAnimated(0.f, root->effect_tree_index(), | 1460 root->layer_tree_impl()->SetTreeLayerOpacityMutated(root->element_id(), 0.f); |
1460 root->layer_tree_impl()); | 1461 root->layer_tree_impl()->SetTreeLayerOpacityMutated( |
1461 effect_tree.OnOpacityAnimated(1.f, render_surface1->effect_tree_index(), | 1462 render_surface1->element_id(), 1.f); |
1462 root->layer_tree_impl()); | |
1463 render_surface1->set_visible_layer_rect(gfx::Rect()); | 1463 render_surface1->set_visible_layer_rect(gfx::Rect()); |
1464 { | 1464 { |
1465 LayerImplList render_surface_layer_list; | 1465 LayerImplList render_surface_layer_list; |
1466 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 1466 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
1467 root, root->bounds(), &render_surface_layer_list); | 1467 root, root->bounds(), &render_surface_layer_list); |
1468 inputs.can_adjust_raster_scales = true; | 1468 inputs.can_adjust_raster_scales = true; |
1469 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); | 1469 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); |
1470 } | 1470 } |
1471 | 1471 |
1472 node = effect_tree.Node(render_surface1->effect_tree_index()); | 1472 node = effect_tree.Node(render_surface1->effect_tree_index()); |
(...skipping 4904 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6377 render_surface1->SetBounds(gfx::Size(30, 30)); | 6377 render_surface1->SetBounds(gfx::Size(30, 30)); |
6378 render_surface1->test_properties()->should_flatten_transform = false; | 6378 render_surface1->test_properties()->should_flatten_transform = false; |
6379 render_surface1->test_properties()->double_sided = false; | 6379 render_surface1->test_properties()->double_sided = false; |
6380 render_surface1->test_properties()->force_render_surface = true; | 6380 render_surface1->test_properties()->force_render_surface = true; |
6381 render_surface1->test_properties()->sorting_context_id = 1; | 6381 render_surface1->test_properties()->sorting_context_id = 1; |
6382 render_surface2->SetBounds(gfx::Size(30, 30)); | 6382 render_surface2->SetBounds(gfx::Size(30, 30)); |
6383 render_surface2->test_properties()->should_flatten_transform = false; | 6383 render_surface2->test_properties()->should_flatten_transform = false; |
6384 render_surface2->test_properties()->double_sided = false; | 6384 render_surface2->test_properties()->double_sided = false; |
6385 render_surface2->test_properties()->force_render_surface = true; | 6385 render_surface2->test_properties()->force_render_surface = true; |
6386 render_surface2->test_properties()->sorting_context_id = 1; | 6386 render_surface2->test_properties()->sorting_context_id = 1; |
| 6387 SetElementIdsForTesting(); |
6387 ExecuteCalculateDrawProperties(root); | 6388 ExecuteCalculateDrawProperties(root); |
6388 | 6389 |
6389 const EffectTree& tree = | 6390 const EffectTree& tree = |
6390 root->layer_tree_impl()->property_trees()->effect_tree; | 6391 root->layer_tree_impl()->property_trees()->effect_tree; |
6391 EXPECT_TRUE(tree.Node(render_surface1->effect_tree_index()) | 6392 EXPECT_TRUE(tree.Node(render_surface1->effect_tree_index()) |
6392 ->hidden_by_backface_visibility); | 6393 ->hidden_by_backface_visibility); |
6393 EXPECT_TRUE(tree.Node(render_surface2->effect_tree_index()) | 6394 EXPECT_TRUE(tree.Node(render_surface2->effect_tree_index()) |
6394 ->hidden_by_backface_visibility); | 6395 ->hidden_by_backface_visibility); |
6395 | 6396 |
6396 root->layer_tree_impl()->property_trees()->transform_tree.OnTransformAnimated( | 6397 root->layer_tree_impl()->SetTreeLayerTransformMutated( |
6397 gfx::Transform(), back_facing->transform_tree_index(), | 6398 back_facing->element_id(), gfx::Transform()); |
6398 root->layer_tree_impl()); | 6399 root->layer_tree_impl()->SetTreeLayerTransformMutated( |
6399 root->layer_tree_impl()->property_trees()->transform_tree.OnTransformAnimated( | 6400 render_surface2->element_id(), rotate_about_y); |
6400 rotate_about_y, render_surface2->transform_tree_index(), | |
6401 root->layer_tree_impl()); | |
6402 ExecuteCalculateDrawProperties(root); | 6401 ExecuteCalculateDrawProperties(root); |
6403 EXPECT_FALSE(tree.Node(render_surface1->effect_tree_index()) | 6402 EXPECT_FALSE(tree.Node(render_surface1->effect_tree_index()) |
6404 ->hidden_by_backface_visibility); | 6403 ->hidden_by_backface_visibility); |
6405 EXPECT_TRUE(tree.Node(render_surface2->effect_tree_index()) | 6404 EXPECT_TRUE(tree.Node(render_surface2->effect_tree_index()) |
6406 ->hidden_by_backface_visibility); | 6405 ->hidden_by_backface_visibility); |
6407 | 6406 |
6408 root->layer_tree_impl()->property_trees()->transform_tree.OnTransformAnimated( | 6407 root->layer_tree_impl()->SetTreeLayerTransformMutated( |
6409 rotate_about_y, render_surface1->transform_tree_index(), | 6408 render_surface1->element_id(), rotate_about_y); |
6410 root->layer_tree_impl()); | |
6411 ExecuteCalculateDrawProperties(root); | 6409 ExecuteCalculateDrawProperties(root); |
6412 EXPECT_TRUE(tree.Node(render_surface1->effect_tree_index()) | 6410 EXPECT_TRUE(tree.Node(render_surface1->effect_tree_index()) |
6413 ->hidden_by_backface_visibility); | 6411 ->hidden_by_backface_visibility); |
6414 EXPECT_TRUE(tree.Node(render_surface2->effect_tree_index()) | 6412 EXPECT_TRUE(tree.Node(render_surface2->effect_tree_index()) |
6415 ->hidden_by_backface_visibility); | 6413 ->hidden_by_backface_visibility); |
6416 } | 6414 } |
6417 | 6415 |
6418 TEST_F(LayerTreeHostCommonTest, ClippedByScrollParent) { | 6416 TEST_F(LayerTreeHostCommonTest, ClippedByScrollParent) { |
6419 // Checks that the simple case (being clipped by a scroll parent that would | 6417 // Checks that the simple case (being clipped by a scroll parent that would |
6420 // have been processed before you anyhow) results in the right clips. | 6418 // have been processed before you anyhow) results in the right clips. |
(...skipping 2267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8688 EXPECT_FLOAT_EQ(0.f, GetMaximumAnimationScale(root_layer)); | 8686 EXPECT_FLOAT_EQ(0.f, GetMaximumAnimationScale(root_layer)); |
8689 EXPECT_FLOAT_EQ(0.f, GetMaximumAnimationScale(child1_layer)); | 8687 EXPECT_FLOAT_EQ(0.f, GetMaximumAnimationScale(child1_layer)); |
8690 EXPECT_FLOAT_EQ(24.f, GetMaximumAnimationScale(child2_layer)); | 8688 EXPECT_FLOAT_EQ(24.f, GetMaximumAnimationScale(child2_layer)); |
8691 | 8689 |
8692 EXPECT_FLOAT_EQ(0.f, GetStartingAnimationScale(root_layer)); | 8690 EXPECT_FLOAT_EQ(0.f, GetStartingAnimationScale(root_layer)); |
8693 EXPECT_FLOAT_EQ(0.f, GetStartingAnimationScale(child1_layer)); | 8691 EXPECT_FLOAT_EQ(0.f, GetStartingAnimationScale(child1_layer)); |
8694 EXPECT_FLOAT_EQ(3.f, GetStartingAnimationScale(child2_layer)); | 8692 EXPECT_FLOAT_EQ(3.f, GetStartingAnimationScale(child2_layer)); |
8695 | 8693 |
8696 // Correctly updates animation scale when layer property changes. | 8694 // Correctly updates animation scale when layer property changes. |
8697 child1_layer->test_properties()->transform = gfx::Transform(); | 8695 child1_layer->test_properties()->transform = gfx::Transform(); |
8698 root_layer->layer_tree_impl() | 8696 root_layer->layer_tree_impl()->SetTreeLayerTransformMutated( |
8699 ->property_trees() | 8697 child1_layer->element_id(), gfx::Transform()); |
8700 ->transform_tree.OnTransformAnimated(gfx::Transform(), | |
8701 child1_layer->transform_tree_index(), | |
8702 root_layer->layer_tree_impl()); | |
8703 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = false; | 8698 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = false; |
8704 ExecuteCalculateDrawProperties(root_layer); | 8699 ExecuteCalculateDrawProperties(root_layer); |
8705 EXPECT_FLOAT_EQ(8.f, GetMaximumAnimationScale(child2_layer)); | 8700 EXPECT_FLOAT_EQ(8.f, GetMaximumAnimationScale(child2_layer)); |
8706 EXPECT_FLOAT_EQ(1.f, GetStartingAnimationScale(child2_layer)); | 8701 EXPECT_FLOAT_EQ(1.f, GetStartingAnimationScale(child2_layer)); |
8707 | 8702 |
8708 // Do not update animation scale if already updated. | 8703 // Do not update animation scale if already updated. |
8709 host_impl.active_tree()->property_trees()->SetAnimationScalesForTesting( | 8704 host_impl.active_tree()->property_trees()->SetAnimationScalesForTesting( |
8710 child2_layer->transform_tree_index(), 100.f, 100.f); | 8705 child2_layer->transform_tree_index(), 100.f, 100.f); |
8711 EXPECT_FLOAT_EQ(100.f, GetMaximumAnimationScale(child2_layer)); | 8706 EXPECT_FLOAT_EQ(100.f, GetMaximumAnimationScale(child2_layer)); |
8712 EXPECT_FLOAT_EQ(100.f, GetStartingAnimationScale(child2_layer)); | 8707 EXPECT_FLOAT_EQ(100.f, GetStartingAnimationScale(child2_layer)); |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8968 // clipped target space, so is treated as fully visible. | 8963 // clipped target space, so is treated as fully visible. |
8969 EXPECT_EQ(gfx::Rect(120, 120), animated->visible_layer_rect()); | 8964 EXPECT_EQ(gfx::Rect(120, 120), animated->visible_layer_rect()); |
8970 | 8965 |
8971 // The singular transform on |animated| is flattened when inherited by | 8966 // The singular transform on |animated| is flattened when inherited by |
8972 // |surface|, and this happens to make it invertible. | 8967 // |surface|, and this happens to make it invertible. |
8973 EXPECT_EQ(gfx::Rect(2, 2), surface->visible_layer_rect()); | 8968 EXPECT_EQ(gfx::Rect(2, 2), surface->visible_layer_rect()); |
8974 EXPECT_EQ(gfx::Rect(2, 2), descendant_of_animation->visible_layer_rect()); | 8969 EXPECT_EQ(gfx::Rect(2, 2), descendant_of_animation->visible_layer_rect()); |
8975 | 8970 |
8976 gfx::Transform zero_matrix; | 8971 gfx::Transform zero_matrix; |
8977 zero_matrix.Scale3d(0.f, 0.f, 0.f); | 8972 zero_matrix.Scale3d(0.f, 0.f, 0.f); |
8978 root->layer_tree_impl()->property_trees()->transform_tree.OnTransformAnimated( | 8973 root->layer_tree_impl()->SetTreeLayerTransformMutated(animated->element_id(), |
8979 zero_matrix, animated->transform_tree_index(), root->layer_tree_impl()); | 8974 zero_matrix); |
8980 // While computing visible rects by combining clips in screen space, we set | 8975 // While computing visible rects by combining clips in screen space, we set |
8981 // the entire layer as visible if the screen space transform is singular. This | 8976 // the entire layer as visible if the screen space transform is singular. This |
8982 // is not always true when we combine clips in target space because if the | 8977 // is not always true when we combine clips in target space because if the |
8983 // intersection of combined_clip in taret space with layer_rect projected to | 8978 // intersection of combined_clip in taret space with layer_rect projected to |
8984 // target space is empty, we set it to an empty rect. | 8979 // target space is empty, we set it to an empty rect. |
8985 bool skip_verify_visible_rect_calculations = true; | 8980 bool skip_verify_visible_rect_calculations = true; |
8986 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList( | 8981 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList( |
8987 root, skip_verify_visible_rect_calculations); | 8982 root, skip_verify_visible_rect_calculations); |
8988 | 8983 |
8989 // The animated layer maps to the empty rect in clipped target space, so is | 8984 // The animated layer maps to the empty rect in clipped target space, so is |
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9482 host_impl.active_tree()->property_trees()->needs_rebuild = true; | 9477 host_impl.active_tree()->property_trees()->needs_rebuild = true; |
9483 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root_ptr); | 9478 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root_ptr); |
9484 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); | 9479 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); |
9485 child_ptr->test_properties()->transform = gfx::Transform(); | 9480 child_ptr->test_properties()->transform = gfx::Transform(); |
9486 | 9481 |
9487 child_ptr->test_properties()->hide_layer_and_subtree = true; | 9482 child_ptr->test_properties()->hide_layer_and_subtree = true; |
9488 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root_ptr); | 9483 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root_ptr); |
9489 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); | 9484 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); |
9490 child_ptr->test_properties()->hide_layer_and_subtree = false; | 9485 child_ptr->test_properties()->hide_layer_and_subtree = false; |
9491 | 9486 |
9492 child_ptr->layer_tree_impl()->property_trees()->effect_tree.OnOpacityAnimated( | 9487 child_ptr->test_properties()->opacity = 0.f; |
9493 0.f, child_ptr->effect_tree_index(), child_ptr->layer_tree_impl()); | 9488 host_impl.active_tree()->property_trees()->needs_rebuild = true; |
9494 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root_ptr); | 9489 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root_ptr); |
9495 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); | 9490 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); |
9496 child_ptr->test_properties()->opacity = 1.f; | 9491 child_ptr->test_properties()->opacity = 1.f; |
9497 | 9492 |
9498 root_ptr->test_properties()->transform = singular; | 9493 root_ptr->test_properties()->transform = singular; |
9499 // Force transform tree to have a node for child, so that ancestor's | 9494 // Force transform tree to have a node for child, so that ancestor's |
9500 // invertible transform can be tested. | 9495 // invertible transform can be tested. |
9501 child_ptr->test_properties()->transform = rotate; | 9496 child_ptr->test_properties()->transform = rotate; |
9502 host_impl.active_tree()->property_trees()->needs_rebuild = true; | 9497 host_impl.active_tree()->property_trees()->needs_rebuild = true; |
9503 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root_ptr); | 9498 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root_ptr); |
(...skipping 1285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10789 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); | 10784 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); |
10790 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); | 10785 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); |
10791 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); | 10786 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); |
10792 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); | 10787 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); |
10793 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); | 10788 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); |
10794 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); | 10789 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); |
10795 } | 10790 } |
10796 | 10791 |
10797 } // namespace | 10792 } // namespace |
10798 } // namespace cc | 10793 } // namespace cc |
OLD | NEW |