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 1404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1415 root->SetBounds(gfx::Size(10, 10)); | 1415 root->SetBounds(gfx::Size(10, 10)); |
1416 render_surface1->SetBounds(gfx::Size(10, 10)); | 1416 render_surface1->SetBounds(gfx::Size(10, 10)); |
1417 render_surface1->test_properties()->force_render_surface = true; | 1417 render_surface1->test_properties()->force_render_surface = true; |
1418 render_surface1->test_properties()->opacity = 0.f; | 1418 render_surface1->test_properties()->opacity = 0.f; |
1419 render_surface1->SetDrawsContent(true); | 1419 render_surface1->SetDrawsContent(true); |
1420 FilterOperations filters; | 1420 FilterOperations filters; |
1421 filters.Append(FilterOperation::CreateBlurFilter(1.5f)); | 1421 filters.Append(FilterOperation::CreateBlurFilter(1.5f)); |
1422 render_surface1->test_properties()->background_filters = filters; | 1422 render_surface1->test_properties()->background_filters = filters; |
1423 child->SetBounds(gfx::Size(10, 10)); | 1423 child->SetBounds(gfx::Size(10, 10)); |
1424 child->SetDrawsContent(true); | 1424 child->SetDrawsContent(true); |
| 1425 root->layer_tree_impl()->SetElementIdsForTesting(); |
1425 | 1426 |
1426 { | 1427 { |
1427 LayerImplList render_surface_layer_list; | 1428 LayerImplList render_surface_layer_list; |
1428 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 1429 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
1429 root, root->bounds(), &render_surface_layer_list); | 1430 root, root->bounds(), &render_surface_layer_list); |
1430 inputs.can_adjust_raster_scales = true; | 1431 inputs.can_adjust_raster_scales = true; |
1431 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); | 1432 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); |
1432 EXPECT_EQ(2U, render_surface_layer_list.size()); | 1433 EXPECT_EQ(2U, render_surface_layer_list.size()); |
1433 } | 1434 } |
1434 // The layer is fully transparent, but has a background filter, so it | 1435 // The layer is fully transparent, but has a background filter, so it |
1435 // shouldn't be skipped and should be drawn. | 1436 // shouldn't be skipped and should be drawn. |
1436 ASSERT_TRUE(root->GetRenderSurface()); | 1437 ASSERT_TRUE(root->GetRenderSurface()); |
1437 EXPECT_EQ(1U, root->GetRenderSurface()->layer_list().size()); | 1438 EXPECT_EQ(1U, root->GetRenderSurface()->layer_list().size()); |
1438 EXPECT_EQ(gfx::RectF(0, 0, 10, 10), | 1439 EXPECT_EQ(gfx::RectF(0, 0, 10, 10), |
1439 root->GetRenderSurface()->DrawableContentRect()); | 1440 root->GetRenderSurface()->DrawableContentRect()); |
1440 EffectTree& effect_tree = | 1441 EffectTree& effect_tree = |
1441 root->layer_tree_impl()->property_trees()->effect_tree; | 1442 root->layer_tree_impl()->property_trees()->effect_tree; |
1442 EffectNode* node = effect_tree.Node(render_surface1->effect_tree_index()); | 1443 EffectNode* node = effect_tree.Node(render_surface1->effect_tree_index()); |
1443 EXPECT_TRUE(node->is_drawn); | 1444 EXPECT_TRUE(node->is_drawn); |
1444 | 1445 |
1445 // When root is transparent, the layer should not be drawn. | 1446 // When root is transparent, the layer should not be drawn. |
1446 effect_tree.OnOpacityAnimated(0.f, root->effect_tree_index(), | 1447 root->layer_tree_impl()->SetOpacityMutated(root->element_id(), 0.f); |
1447 root->layer_tree_impl()); | 1448 root->layer_tree_impl()->SetOpacityMutated(render_surface1->element_id(), |
1448 effect_tree.OnOpacityAnimated(1.f, render_surface1->effect_tree_index(), | 1449 1.f); |
1449 root->layer_tree_impl()); | |
1450 render_surface1->set_visible_layer_rect(gfx::Rect()); | 1450 render_surface1->set_visible_layer_rect(gfx::Rect()); |
1451 { | 1451 { |
1452 LayerImplList render_surface_layer_list; | 1452 LayerImplList render_surface_layer_list; |
1453 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 1453 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
1454 root, root->bounds(), &render_surface_layer_list); | 1454 root, root->bounds(), &render_surface_layer_list); |
1455 inputs.can_adjust_raster_scales = true; | 1455 inputs.can_adjust_raster_scales = true; |
1456 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); | 1456 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); |
1457 } | 1457 } |
1458 | 1458 |
1459 node = effect_tree.Node(render_surface1->effect_tree_index()); | 1459 node = effect_tree.Node(render_surface1->effect_tree_index()); |
(...skipping 4926 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6386 render_surface1->SetBounds(gfx::Size(30, 30)); | 6386 render_surface1->SetBounds(gfx::Size(30, 30)); |
6387 render_surface1->test_properties()->should_flatten_transform = false; | 6387 render_surface1->test_properties()->should_flatten_transform = false; |
6388 render_surface1->test_properties()->double_sided = false; | 6388 render_surface1->test_properties()->double_sided = false; |
6389 render_surface1->test_properties()->force_render_surface = true; | 6389 render_surface1->test_properties()->force_render_surface = true; |
6390 render_surface1->test_properties()->sorting_context_id = 1; | 6390 render_surface1->test_properties()->sorting_context_id = 1; |
6391 render_surface2->SetBounds(gfx::Size(30, 30)); | 6391 render_surface2->SetBounds(gfx::Size(30, 30)); |
6392 render_surface2->test_properties()->should_flatten_transform = false; | 6392 render_surface2->test_properties()->should_flatten_transform = false; |
6393 render_surface2->test_properties()->double_sided = false; | 6393 render_surface2->test_properties()->double_sided = false; |
6394 render_surface2->test_properties()->force_render_surface = true; | 6394 render_surface2->test_properties()->force_render_surface = true; |
6395 render_surface2->test_properties()->sorting_context_id = 1; | 6395 render_surface2->test_properties()->sorting_context_id = 1; |
| 6396 SetElementIdsForTesting(); |
6396 ExecuteCalculateDrawProperties(root); | 6397 ExecuteCalculateDrawProperties(root); |
6397 | 6398 |
6398 const EffectTree& tree = | 6399 const EffectTree& tree = |
6399 root->layer_tree_impl()->property_trees()->effect_tree; | 6400 root->layer_tree_impl()->property_trees()->effect_tree; |
6400 EXPECT_TRUE(tree.Node(render_surface1->effect_tree_index()) | 6401 EXPECT_TRUE(tree.Node(render_surface1->effect_tree_index()) |
6401 ->hidden_by_backface_visibility); | 6402 ->hidden_by_backface_visibility); |
6402 EXPECT_TRUE(tree.Node(render_surface2->effect_tree_index()) | 6403 EXPECT_TRUE(tree.Node(render_surface2->effect_tree_index()) |
6403 ->hidden_by_backface_visibility); | 6404 ->hidden_by_backface_visibility); |
6404 | 6405 |
6405 root->layer_tree_impl()->property_trees()->transform_tree.OnTransformAnimated( | 6406 root->layer_tree_impl()->SetTransformMutated(back_facing->element_id(), |
6406 gfx::Transform(), back_facing->transform_tree_index(), | 6407 gfx::Transform()); |
6407 root->layer_tree_impl()); | 6408 root->layer_tree_impl()->SetTransformMutated(render_surface2->element_id(), |
6408 root->layer_tree_impl()->property_trees()->transform_tree.OnTransformAnimated( | 6409 rotate_about_y); |
6409 rotate_about_y, render_surface2->transform_tree_index(), | |
6410 root->layer_tree_impl()); | |
6411 ExecuteCalculateDrawProperties(root); | 6410 ExecuteCalculateDrawProperties(root); |
6412 EXPECT_FALSE(tree.Node(render_surface1->effect_tree_index()) | 6411 EXPECT_FALSE(tree.Node(render_surface1->effect_tree_index()) |
6413 ->hidden_by_backface_visibility); | 6412 ->hidden_by_backface_visibility); |
6414 EXPECT_TRUE(tree.Node(render_surface2->effect_tree_index()) | 6413 EXPECT_TRUE(tree.Node(render_surface2->effect_tree_index()) |
6415 ->hidden_by_backface_visibility); | 6414 ->hidden_by_backface_visibility); |
6416 | 6415 |
6417 root->layer_tree_impl()->property_trees()->transform_tree.OnTransformAnimated( | 6416 root->layer_tree_impl()->SetTransformMutated(render_surface1->element_id(), |
6418 rotate_about_y, render_surface1->transform_tree_index(), | 6417 rotate_about_y); |
6419 root->layer_tree_impl()); | |
6420 ExecuteCalculateDrawProperties(root); | 6418 ExecuteCalculateDrawProperties(root); |
6421 EXPECT_TRUE(tree.Node(render_surface1->effect_tree_index()) | 6419 EXPECT_TRUE(tree.Node(render_surface1->effect_tree_index()) |
6422 ->hidden_by_backface_visibility); | 6420 ->hidden_by_backface_visibility); |
6423 EXPECT_TRUE(tree.Node(render_surface2->effect_tree_index()) | 6421 EXPECT_TRUE(tree.Node(render_surface2->effect_tree_index()) |
6424 ->hidden_by_backface_visibility); | 6422 ->hidden_by_backface_visibility); |
6425 } | 6423 } |
6426 | 6424 |
6427 TEST_F(LayerTreeHostCommonTest, ClippedByScrollParent) { | 6425 TEST_F(LayerTreeHostCommonTest, ClippedByScrollParent) { |
6428 // Checks that the simple case (being clipped by a scroll parent that would | 6426 // Checks that the simple case (being clipped by a scroll parent that would |
6429 // have been processed before you anyhow) results in the right clips. | 6427 // have been processed before you anyhow) results in the right clips. |
(...skipping 2326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8756 EXPECT_FLOAT_EQ(0.f, GetMaximumAnimationScale(root_layer)); | 8754 EXPECT_FLOAT_EQ(0.f, GetMaximumAnimationScale(root_layer)); |
8757 EXPECT_FLOAT_EQ(0.f, GetMaximumAnimationScale(child1_layer)); | 8755 EXPECT_FLOAT_EQ(0.f, GetMaximumAnimationScale(child1_layer)); |
8758 EXPECT_FLOAT_EQ(24.f, GetMaximumAnimationScale(child2_layer)); | 8756 EXPECT_FLOAT_EQ(24.f, GetMaximumAnimationScale(child2_layer)); |
8759 | 8757 |
8760 EXPECT_FLOAT_EQ(0.f, GetStartingAnimationScale(root_layer)); | 8758 EXPECT_FLOAT_EQ(0.f, GetStartingAnimationScale(root_layer)); |
8761 EXPECT_FLOAT_EQ(0.f, GetStartingAnimationScale(child1_layer)); | 8759 EXPECT_FLOAT_EQ(0.f, GetStartingAnimationScale(child1_layer)); |
8762 EXPECT_FLOAT_EQ(3.f, GetStartingAnimationScale(child2_layer)); | 8760 EXPECT_FLOAT_EQ(3.f, GetStartingAnimationScale(child2_layer)); |
8763 | 8761 |
8764 // Correctly updates animation scale when layer property changes. | 8762 // Correctly updates animation scale when layer property changes. |
8765 child1_layer->test_properties()->transform = gfx::Transform(); | 8763 child1_layer->test_properties()->transform = gfx::Transform(); |
8766 root_layer->layer_tree_impl() | 8764 root_layer->layer_tree_impl()->SetTransformMutated(child1_layer->element_id(), |
8767 ->property_trees() | 8765 gfx::Transform()); |
8768 ->transform_tree.OnTransformAnimated(gfx::Transform(), | |
8769 child1_layer->transform_tree_index(), | |
8770 root_layer->layer_tree_impl()); | |
8771 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = false; | 8766 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = false; |
8772 ExecuteCalculateDrawProperties(root_layer); | 8767 ExecuteCalculateDrawProperties(root_layer); |
8773 EXPECT_FLOAT_EQ(8.f, GetMaximumAnimationScale(child2_layer)); | 8768 EXPECT_FLOAT_EQ(8.f, GetMaximumAnimationScale(child2_layer)); |
8774 EXPECT_FLOAT_EQ(1.f, GetStartingAnimationScale(child2_layer)); | 8769 EXPECT_FLOAT_EQ(1.f, GetStartingAnimationScale(child2_layer)); |
8775 | 8770 |
8776 // Do not update animation scale if already updated. | 8771 // Do not update animation scale if already updated. |
8777 host_impl.active_tree()->property_trees()->SetAnimationScalesForTesting( | 8772 host_impl.active_tree()->property_trees()->SetAnimationScalesForTesting( |
8778 child2_layer->transform_tree_index(), 100.f, 100.f); | 8773 child2_layer->transform_tree_index(), 100.f, 100.f); |
8779 EXPECT_FLOAT_EQ(100.f, GetMaximumAnimationScale(child2_layer)); | 8774 EXPECT_FLOAT_EQ(100.f, GetMaximumAnimationScale(child2_layer)); |
8780 EXPECT_FLOAT_EQ(100.f, GetStartingAnimationScale(child2_layer)); | 8775 EXPECT_FLOAT_EQ(100.f, GetStartingAnimationScale(child2_layer)); |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9036 // clipped target space, so is treated as fully visible. | 9031 // clipped target space, so is treated as fully visible. |
9037 EXPECT_EQ(gfx::Rect(120, 120), animated->visible_layer_rect()); | 9032 EXPECT_EQ(gfx::Rect(120, 120), animated->visible_layer_rect()); |
9038 | 9033 |
9039 // The singular transform on |animated| is flattened when inherited by | 9034 // The singular transform on |animated| is flattened when inherited by |
9040 // |surface|, and this happens to make it invertible. | 9035 // |surface|, and this happens to make it invertible. |
9041 EXPECT_EQ(gfx::Rect(2, 2), surface->visible_layer_rect()); | 9036 EXPECT_EQ(gfx::Rect(2, 2), surface->visible_layer_rect()); |
9042 EXPECT_EQ(gfx::Rect(2, 2), descendant_of_animation->visible_layer_rect()); | 9037 EXPECT_EQ(gfx::Rect(2, 2), descendant_of_animation->visible_layer_rect()); |
9043 | 9038 |
9044 gfx::Transform zero_matrix; | 9039 gfx::Transform zero_matrix; |
9045 zero_matrix.Scale3d(0.f, 0.f, 0.f); | 9040 zero_matrix.Scale3d(0.f, 0.f, 0.f); |
9046 root->layer_tree_impl()->property_trees()->transform_tree.OnTransformAnimated( | 9041 root->layer_tree_impl()->SetTransformMutated(animated->element_id(), |
9047 zero_matrix, animated->transform_tree_index(), root->layer_tree_impl()); | 9042 zero_matrix); |
9048 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root); | 9043 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root); |
9049 | 9044 |
9050 // The animated layer will be treated as fully visible when we combine clips | 9045 // The animated layer will be treated as fully visible when we combine clips |
9051 // in screen space. | 9046 // in screen space. |
9052 EXPECT_EQ(gfx::Rect(120, 120), animated->visible_layer_rect()); | 9047 EXPECT_EQ(gfx::Rect(120, 120), animated->visible_layer_rect()); |
9053 | 9048 |
9054 // This time, flattening does not make |animated|'s transform invertible. This | 9049 // This time, flattening does not make |animated|'s transform invertible. This |
9055 // means the clip cannot be projected into |surface|'s space, so we treat | 9050 // means the clip cannot be projected into |surface|'s space, so we treat |
9056 // |surface| and layers that draw into it as having empty visible rect. | 9051 // |surface| and layers that draw into it as having empty visible rect. |
9057 EXPECT_EQ(gfx::Rect(100, 100), surface->visible_layer_rect()); | 9052 EXPECT_EQ(gfx::Rect(100, 100), surface->visible_layer_rect()); |
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9537 host_impl.active_tree()->property_trees()->needs_rebuild = true; | 9532 host_impl.active_tree()->property_trees()->needs_rebuild = true; |
9538 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root_ptr); | 9533 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root_ptr); |
9539 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); | 9534 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); |
9540 child_ptr->test_properties()->transform = gfx::Transform(); | 9535 child_ptr->test_properties()->transform = gfx::Transform(); |
9541 | 9536 |
9542 child_ptr->test_properties()->hide_layer_and_subtree = true; | 9537 child_ptr->test_properties()->hide_layer_and_subtree = true; |
9543 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root_ptr); | 9538 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root_ptr); |
9544 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); | 9539 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); |
9545 child_ptr->test_properties()->hide_layer_and_subtree = false; | 9540 child_ptr->test_properties()->hide_layer_and_subtree = false; |
9546 | 9541 |
9547 child_ptr->layer_tree_impl()->property_trees()->effect_tree.OnOpacityAnimated( | 9542 child_ptr->test_properties()->opacity = 0.f; |
9548 0.f, child_ptr->effect_tree_index(), child_ptr->layer_tree_impl()); | 9543 host_impl.active_tree()->property_trees()->needs_rebuild = true; |
9549 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root_ptr); | 9544 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root_ptr); |
9550 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); | 9545 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); |
9551 child_ptr->test_properties()->opacity = 1.f; | 9546 child_ptr->test_properties()->opacity = 1.f; |
9552 | 9547 |
9553 root_ptr->test_properties()->transform = singular; | 9548 root_ptr->test_properties()->transform = singular; |
9554 // Force transform tree to have a node for child, so that ancestor's | 9549 // Force transform tree to have a node for child, so that ancestor's |
9555 // invertible transform can be tested. | 9550 // invertible transform can be tested. |
9556 child_ptr->test_properties()->transform = rotate; | 9551 child_ptr->test_properties()->transform = rotate; |
9557 host_impl.active_tree()->property_trees()->needs_rebuild = true; | 9552 host_impl.active_tree()->property_trees()->needs_rebuild = true; |
9558 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root_ptr); | 9553 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root_ptr); |
(...skipping 1269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10828 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); | 10823 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); |
10829 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); | 10824 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); |
10830 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); | 10825 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); |
10831 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); | 10826 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); |
10832 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); | 10827 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); |
10833 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); | 10828 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); |
10834 } | 10829 } |
10835 | 10830 |
10836 } // namespace | 10831 } // namespace |
10837 } // namespace cc | 10832 } // namespace cc |
OLD | NEW |