| 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 13 matching lines...) Expand all Loading... |
| 24 #include "cc/layers/layer_client.h" | 24 #include "cc/layers/layer_client.h" |
| 25 #include "cc/layers/layer_impl.h" | 25 #include "cc/layers/layer_impl.h" |
| 26 #include "cc/layers/layer_iterator.h" | 26 #include "cc/layers/layer_iterator.h" |
| 27 #include "cc/layers/render_surface_impl.h" | 27 #include "cc/layers/render_surface_impl.h" |
| 28 #include "cc/layers/texture_layer_impl.h" | 28 #include "cc/layers/texture_layer_impl.h" |
| 29 #include "cc/output/copy_output_request.h" | 29 #include "cc/output/copy_output_request.h" |
| 30 #include "cc/output/copy_output_result.h" | 30 #include "cc/output/copy_output_result.h" |
| 31 #include "cc/proto/begin_main_frame_and_commit_state.pb.h" | 31 #include "cc/proto/begin_main_frame_and_commit_state.pb.h" |
| 32 #include "cc/proto/gfx_conversions.h" | 32 #include "cc/proto/gfx_conversions.h" |
| 33 #include "cc/test/animation_test_common.h" | 33 #include "cc/test/animation_test_common.h" |
| 34 #include "cc/test/fake_compositor_frame_sink.h" |
| 34 #include "cc/test/fake_content_layer_client.h" | 35 #include "cc/test/fake_content_layer_client.h" |
| 35 #include "cc/test/fake_impl_task_runner_provider.h" | 36 #include "cc/test/fake_impl_task_runner_provider.h" |
| 36 #include "cc/test/fake_layer_tree_host.h" | 37 #include "cc/test/fake_layer_tree_host.h" |
| 37 #include "cc/test/fake_layer_tree_host_impl.h" | 38 #include "cc/test/fake_layer_tree_host_impl.h" |
| 38 #include "cc/test/fake_output_surface.h" | |
| 39 #include "cc/test/fake_picture_layer.h" | 39 #include "cc/test/fake_picture_layer.h" |
| 40 #include "cc/test/fake_picture_layer_impl.h" | 40 #include "cc/test/fake_picture_layer_impl.h" |
| 41 #include "cc/test/geometry_test_utils.h" | 41 #include "cc/test/geometry_test_utils.h" |
| 42 #include "cc/test/layer_test_common.h" | 42 #include "cc/test/layer_test_common.h" |
| 43 #include "cc/test/test_task_graph_runner.h" | 43 #include "cc/test/test_task_graph_runner.h" |
| 44 #include "cc/trees/clip_node.h" | 44 #include "cc/trees/clip_node.h" |
| 45 #include "cc/trees/draw_property_utils.h" | 45 #include "cc/trees/draw_property_utils.h" |
| 46 #include "cc/trees/effect_node.h" | 46 #include "cc/trees/effect_node.h" |
| 47 #include "cc/trees/layer_tree_impl.h" | 47 #include "cc/trees/layer_tree_impl.h" |
| 48 #include "cc/trees/property_tree_builder.h" | 48 #include "cc/trees/property_tree_builder.h" |
| (...skipping 3452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3501 | 3501 |
| 3502 // CalcDrawProps skips a subtree when a layer's screen space transform is | 3502 // CalcDrawProps skips a subtree when a layer's screen space transform is |
| 3503 // uninvertible | 3503 // uninvertible |
| 3504 EXPECT_EQ(gfx::Rect(), grand_child->visible_layer_rect()); | 3504 EXPECT_EQ(gfx::Rect(), grand_child->visible_layer_rect()); |
| 3505 } | 3505 } |
| 3506 | 3506 |
| 3507 TEST_F(LayerTreeHostCommonTest, OcclusionBySiblingOfTarget) { | 3507 TEST_F(LayerTreeHostCommonTest, OcclusionBySiblingOfTarget) { |
| 3508 FakeImplTaskRunnerProvider task_runner_provider; | 3508 FakeImplTaskRunnerProvider task_runner_provider; |
| 3509 TestSharedBitmapManager shared_bitmap_manager; | 3509 TestSharedBitmapManager shared_bitmap_manager; |
| 3510 TestTaskGraphRunner task_graph_runner; | 3510 TestTaskGraphRunner task_graph_runner; |
| 3511 std::unique_ptr<OutputSurface> output_surface = | 3511 std::unique_ptr<CompositorFrameSink> compositor_frame_sink = |
| 3512 FakeOutputSurface::CreateDelegating3d(); | 3512 FakeCompositorFrameSink::Create3d(); |
| 3513 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, | 3513 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, |
| 3514 &task_graph_runner); | 3514 &task_graph_runner); |
| 3515 | 3515 |
| 3516 std::unique_ptr<LayerImpl> root = | 3516 std::unique_ptr<LayerImpl> root = |
| 3517 LayerImpl::Create(host_impl.active_tree(), 1); | 3517 LayerImpl::Create(host_impl.active_tree(), 1); |
| 3518 std::unique_ptr<LayerImpl> child = | 3518 std::unique_ptr<LayerImpl> child = |
| 3519 LayerImpl::Create(host_impl.active_tree(), 2); | 3519 LayerImpl::Create(host_impl.active_tree(), 2); |
| 3520 std::unique_ptr<TextureLayerImpl> surface = | 3520 std::unique_ptr<TextureLayerImpl> surface = |
| 3521 TextureLayerImpl::Create(host_impl.active_tree(), 3); | 3521 TextureLayerImpl::Create(host_impl.active_tree(), 3); |
| 3522 std::unique_ptr<TextureLayerImpl> surface_child = | 3522 std::unique_ptr<TextureLayerImpl> surface_child = |
| (...skipping 30 matching lines...) Expand all Loading... |
| 3553 | 3553 |
| 3554 host_impl.SetViewportSize(root->bounds()); | 3554 host_impl.SetViewportSize(root->bounds()); |
| 3555 | 3555 |
| 3556 surface_child->test_properties()->SetMaskLayer(std::move(surface_child_mask)); | 3556 surface_child->test_properties()->SetMaskLayer(std::move(surface_child_mask)); |
| 3557 surface->test_properties()->AddChild(std::move(surface_child)); | 3557 surface->test_properties()->AddChild(std::move(surface_child)); |
| 3558 child->test_properties()->AddChild(std::move(surface)); | 3558 child->test_properties()->AddChild(std::move(surface)); |
| 3559 child->test_properties()->AddChild(std::move(surface_sibling)); | 3559 child->test_properties()->AddChild(std::move(surface_sibling)); |
| 3560 root->test_properties()->AddChild(std::move(child)); | 3560 root->test_properties()->AddChild(std::move(child)); |
| 3561 host_impl.active_tree()->SetRootLayerForTesting(std::move(root)); | 3561 host_impl.active_tree()->SetRootLayerForTesting(std::move(root)); |
| 3562 host_impl.SetVisible(true); | 3562 host_impl.SetVisible(true); |
| 3563 host_impl.InitializeRenderer(output_surface.get()); | 3563 host_impl.InitializeRenderer(compositor_frame_sink.get()); |
| 3564 host_impl.active_tree()->BuildLayerListAndPropertyTreesForTesting(); | 3564 host_impl.active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
| 3565 bool update_lcd_text = false; | 3565 bool update_lcd_text = false; |
| 3566 host_impl.active_tree()->UpdateDrawProperties(update_lcd_text); | 3566 host_impl.active_tree()->UpdateDrawProperties(update_lcd_text); |
| 3567 | 3567 |
| 3568 EXPECT_TRANSFORMATION_MATRIX_EQ( | 3568 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 3569 surface_ptr->render_surface()->draw_transform(), translate); | 3569 surface_ptr->render_surface()->draw_transform(), translate); |
| 3570 // surface_sibling draws into the root render surface and occludes | 3570 // surface_sibling draws into the root render surface and occludes |
| 3571 // surface_child's contents. | 3571 // surface_child's contents. |
| 3572 Occlusion actual_occlusion = | 3572 Occlusion actual_occlusion = |
| 3573 surface_child_ptr->render_surface()->occlusion_in_content_space(); | 3573 surface_child_ptr->render_surface()->occlusion_in_content_space(); |
| 3574 Occlusion expected_occlusion(translate, SimpleEnclosedRegion(gfx::Rect()), | 3574 Occlusion expected_occlusion(translate, SimpleEnclosedRegion(gfx::Rect()), |
| 3575 SimpleEnclosedRegion(gfx::Rect(200, 200))); | 3575 SimpleEnclosedRegion(gfx::Rect(200, 200))); |
| 3576 EXPECT_TRUE(expected_occlusion.IsEqual(actual_occlusion)); | 3576 EXPECT_TRUE(expected_occlusion.IsEqual(actual_occlusion)); |
| 3577 | 3577 |
| 3578 // Mask layer should have the same occlusion. | 3578 // Mask layer should have the same occlusion. |
| 3579 actual_occlusion = | 3579 actual_occlusion = |
| 3580 surface_child_mask_ptr->draw_properties().occlusion_in_content_space; | 3580 surface_child_mask_ptr->draw_properties().occlusion_in_content_space; |
| 3581 EXPECT_TRUE(expected_occlusion.IsEqual(actual_occlusion)); | 3581 EXPECT_TRUE(expected_occlusion.IsEqual(actual_occlusion)); |
| 3582 } | 3582 } |
| 3583 | 3583 |
| 3584 TEST_F(LayerTreeHostCommonTest, | 3584 TEST_F(LayerTreeHostCommonTest, |
| 3585 OcclusionForLayerWithUninvertibleDrawTransform) { | 3585 OcclusionForLayerWithUninvertibleDrawTransform) { |
| 3586 FakeImplTaskRunnerProvider task_runner_provider; | 3586 FakeImplTaskRunnerProvider task_runner_provider; |
| 3587 TestSharedBitmapManager shared_bitmap_manager; | 3587 TestSharedBitmapManager shared_bitmap_manager; |
| 3588 TestTaskGraphRunner task_graph_runner; | 3588 TestTaskGraphRunner task_graph_runner; |
| 3589 std::unique_ptr<OutputSurface> output_surface = | 3589 std::unique_ptr<CompositorFrameSink> compositor_frame_sink = |
| 3590 FakeOutputSurface::CreateDelegating3d(); | 3590 FakeCompositorFrameSink::Create3d(); |
| 3591 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, | 3591 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, |
| 3592 &task_graph_runner); | 3592 &task_graph_runner); |
| 3593 | 3593 |
| 3594 std::unique_ptr<LayerImpl> root = | 3594 std::unique_ptr<LayerImpl> root = |
| 3595 LayerImpl::Create(host_impl.active_tree(), 1); | 3595 LayerImpl::Create(host_impl.active_tree(), 1); |
| 3596 std::unique_ptr<LayerImpl> child = | 3596 std::unique_ptr<LayerImpl> child = |
| 3597 LayerImpl::Create(host_impl.active_tree(), 2); | 3597 LayerImpl::Create(host_impl.active_tree(), 2); |
| 3598 std::unique_ptr<LayerImpl> grand_child = | 3598 std::unique_ptr<LayerImpl> grand_child = |
| 3599 LayerImpl::Create(host_impl.active_tree(), 3); | 3599 LayerImpl::Create(host_impl.active_tree(), 3); |
| 3600 std::unique_ptr<LayerImpl> occluding_child = | 3600 std::unique_ptr<LayerImpl> occluding_child = |
| (...skipping 23 matching lines...) Expand all Loading... |
| 3624 occluding_child->SetDrawsContent(true); | 3624 occluding_child->SetDrawsContent(true); |
| 3625 occluding_child->SetContentsOpaque(true); | 3625 occluding_child->SetContentsOpaque(true); |
| 3626 | 3626 |
| 3627 host_impl.SetViewportSize(root->bounds()); | 3627 host_impl.SetViewportSize(root->bounds()); |
| 3628 | 3628 |
| 3629 child->test_properties()->AddChild(std::move(grand_child)); | 3629 child->test_properties()->AddChild(std::move(grand_child)); |
| 3630 root->test_properties()->AddChild(std::move(child)); | 3630 root->test_properties()->AddChild(std::move(child)); |
| 3631 root->test_properties()->AddChild(std::move(occluding_child)); | 3631 root->test_properties()->AddChild(std::move(occluding_child)); |
| 3632 host_impl.active_tree()->SetRootLayerForTesting(std::move(root)); | 3632 host_impl.active_tree()->SetRootLayerForTesting(std::move(root)); |
| 3633 host_impl.SetVisible(true); | 3633 host_impl.SetVisible(true); |
| 3634 host_impl.InitializeRenderer(output_surface.get()); | 3634 host_impl.InitializeRenderer(compositor_frame_sink.get()); |
| 3635 host_impl.active_tree()->BuildLayerListAndPropertyTreesForTesting(); | 3635 host_impl.active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
| 3636 bool update_lcd_text = false; | 3636 bool update_lcd_text = false; |
| 3637 host_impl.active_tree()->UpdateDrawProperties(update_lcd_text); | 3637 host_impl.active_tree()->UpdateDrawProperties(update_lcd_text); |
| 3638 | 3638 |
| 3639 LayerImpl* grand_child_ptr = host_impl.active_tree() | 3639 LayerImpl* grand_child_ptr = host_impl.active_tree() |
| 3640 ->root_layer_for_testing() | 3640 ->root_layer_for_testing() |
| 3641 ->test_properties() | 3641 ->test_properties() |
| 3642 ->children[0] | 3642 ->children[0] |
| 3643 ->test_properties() | 3643 ->test_properties() |
| 3644 ->children[0]; | 3644 ->children[0]; |
| (...skipping 6193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9838 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); | 9838 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); |
| 9839 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); | 9839 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); |
| 9840 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); | 9840 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); |
| 9841 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); | 9841 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); |
| 9842 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); | 9842 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); |
| 9843 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); | 9843 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); |
| 9844 } | 9844 } |
| 9845 | 9845 |
| 9846 } // namespace | 9846 } // namespace |
| 9847 } // namespace cc | 9847 } // namespace cc |
| OLD | NEW |