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

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

Issue 2147283002: cc : Fix occlusion tracking bug for contributing surface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: mask test Created 4 years, 5 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/layer_tree_impl.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>
11 #include <set> 11 #include <set>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/memory/ptr_util.h" 14 #include "base/memory/ptr_util.h"
15 #include "cc/animation/animation_host.h" 15 #include "cc/animation/animation_host.h"
16 #include "cc/animation/animation_id_provider.h" 16 #include "cc/animation/animation_id_provider.h"
17 #include "cc/animation/animation_player.h" 17 #include "cc/animation/animation_player.h"
18 #include "cc/animation/keyframed_animation_curve.h" 18 #include "cc/animation/keyframed_animation_curve.h"
19 #include "cc/animation/transform_operations.h" 19 #include "cc/animation/transform_operations.h"
20 #include "cc/base/math_util.h" 20 #include "cc/base/math_util.h"
21 #include "cc/input/main_thread_scrolling_reason.h" 21 #include "cc/input/main_thread_scrolling_reason.h"
22 #include "cc/layers/content_layer_client.h" 22 #include "cc/layers/content_layer_client.h"
23 #include "cc/layers/layer.h" 23 #include "cc/layers/layer.h"
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/output/copy_output_request.h" 29 #include "cc/output/copy_output_request.h"
29 #include "cc/output/copy_output_result.h" 30 #include "cc/output/copy_output_result.h"
30 #include "cc/proto/begin_main_frame_and_commit_state.pb.h" 31 #include "cc/proto/begin_main_frame_and_commit_state.pb.h"
31 #include "cc/proto/gfx_conversions.h" 32 #include "cc/proto/gfx_conversions.h"
32 #include "cc/test/animation_test_common.h" 33 #include "cc/test/animation_test_common.h"
33 #include "cc/test/fake_content_layer_client.h" 34 #include "cc/test/fake_content_layer_client.h"
34 #include "cc/test/fake_impl_task_runner_provider.h" 35 #include "cc/test/fake_impl_task_runner_provider.h"
35 #include "cc/test/fake_layer_tree_host.h" 36 #include "cc/test/fake_layer_tree_host.h"
36 #include "cc/test/fake_layer_tree_host_impl.h" 37 #include "cc/test/fake_layer_tree_host_impl.h"
37 #include "cc/test/fake_output_surface.h" 38 #include "cc/test/fake_output_surface.h"
(...skipping 3638 matching lines...) Expand 10 before | Expand all | Expand 10 after
3676 EXPECT_FALSE(root->layer_tree_impl() 3677 EXPECT_FALSE(root->layer_tree_impl()
3677 ->property_trees() 3678 ->property_trees()
3678 ->transform_tree.Node(grand_child->transform_tree_index()) 3679 ->transform_tree.Node(grand_child->transform_tree_index())
3679 ->ancestors_are_invertible); 3680 ->ancestors_are_invertible);
3680 3681
3681 // CalcDrawProps skips a subtree when a layer's screen space transform is 3682 // CalcDrawProps skips a subtree when a layer's screen space transform is
3682 // uninvertible 3683 // uninvertible
3683 EXPECT_EQ(gfx::Rect(), grand_child->visible_layer_rect()); 3684 EXPECT_EQ(gfx::Rect(), grand_child->visible_layer_rect());
3684 } 3685 }
3685 3686
3687 TEST_F(LayerTreeHostCommonTest, OcclusionBySiblingOfTarget) {
3688 FakeImplTaskRunnerProvider task_runner_provider;
3689 TestSharedBitmapManager shared_bitmap_manager;
3690 TestTaskGraphRunner task_graph_runner;
3691 std::unique_ptr<OutputSurface> output_surface = FakeOutputSurface::Create3d();
3692 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager,
3693 &task_graph_runner);
3694
3695 std::unique_ptr<LayerImpl> root =
3696 LayerImpl::Create(host_impl.active_tree(), 1);
3697 std::unique_ptr<LayerImpl> child =
3698 LayerImpl::Create(host_impl.active_tree(), 2);
3699 std::unique_ptr<TextureLayerImpl> surface =
3700 TextureLayerImpl::Create(host_impl.active_tree(), 3);
3701 std::unique_ptr<TextureLayerImpl> surface_child =
3702 TextureLayerImpl::Create(host_impl.active_tree(), 4);
3703 std::unique_ptr<TextureLayerImpl> surface_sibling =
3704 TextureLayerImpl::Create(host_impl.active_tree(), 5);
3705 std::unique_ptr<TextureLayerImpl> surface_child_mask =
3706 TextureLayerImpl::Create(host_impl.active_tree(), 6);
3707
3708 surface->SetDrawsContent(true);
3709 surface_child->SetDrawsContent(true);
3710 surface_sibling->SetDrawsContent(true);
3711 surface_child_mask->SetDrawsContent(true);
3712 surface->SetContentsOpaque(true);
3713 surface_child->SetContentsOpaque(true);
3714 surface_sibling->SetContentsOpaque(true);
3715 surface_child_mask->SetContentsOpaque(true);
3716
3717 surface->test_properties()->opacity = 0.5f;
3718 surface_child->test_properties()->opacity = 0.6f;
3719
3720 gfx::Transform identity_matrix;
3721 gfx::Transform translate;
3722 translate.Translate(20.f, 20.f);
3723
3724 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(),
3725 gfx::PointF(), gfx::Size(1000, 1000), true,
3726 false, true);
3727 SetLayerPropertiesForTesting(child.get(), identity_matrix, gfx::Point3F(),
3728 gfx::PointF(), gfx::Size(300, 300), false, true,
3729 false);
3730 SetLayerPropertiesForTesting(surface.get(), translate, gfx::Point3F(),
3731 gfx::PointF(), gfx::Size(300, 300), false, true,
3732 true);
3733 SetLayerPropertiesForTesting(surface_child.get(), identity_matrix,
3734 gfx::Point3F(), gfx::PointF(),
3735 gfx::Size(300, 300), false, false, true);
3736 SetLayerPropertiesForTesting(surface_sibling.get(), identity_matrix,
3737 gfx::Point3F(), gfx::PointF(),
3738 gfx::Size(200, 200), false, false, false);
3739
3740 LayerImpl* surface_ptr = surface.get();
3741 LayerImpl* surface_child_ptr = surface_child.get();
3742 LayerImpl* surface_child_mask_ptr = surface_child_mask.get();
3743
3744 host_impl.SetViewportSize(root->bounds());
3745
3746 surface_child->test_properties()->SetMaskLayer(std::move(surface_child_mask));
3747 surface->test_properties()->AddChild(std::move(surface_child));
3748 child->test_properties()->AddChild(std::move(surface));
3749 child->test_properties()->AddChild(std::move(surface_sibling));
3750 root->test_properties()->AddChild(std::move(child));
3751 host_impl.active_tree()->SetRootLayerForTesting(std::move(root));
3752 host_impl.SetVisible(true);
3753 host_impl.InitializeRenderer(output_surface.get());
3754 host_impl.active_tree()->BuildLayerListAndPropertyTreesForTesting();
3755 bool update_lcd_text = false;
3756 host_impl.active_tree()->UpdateDrawProperties(update_lcd_text);
3757
3758 EXPECT_TRANSFORMATION_MATRIX_EQ(
3759 surface_ptr->render_surface()->draw_transform(), translate);
3760 // surface_sibling draws into the root render surface and occludes
3761 // surface_child's contents.
3762 Occlusion actual_occlusion =
3763 surface_child_ptr->render_surface()->occlusion_in_content_space();
3764 Occlusion expected_occlusion(translate, SimpleEnclosedRegion(gfx::Rect()),
3765 SimpleEnclosedRegion(gfx::Rect(200, 200)));
3766 EXPECT_TRUE(expected_occlusion.IsEqual(actual_occlusion));
3767
3768 // Mask layer should have the same occlusion.
3769 actual_occlusion =
3770 surface_child_mask_ptr->draw_properties().occlusion_in_content_space;
3771 EXPECT_TRUE(expected_occlusion.IsEqual(actual_occlusion));
3772 }
3773
3686 TEST_F(LayerTreeHostCommonTest, 3774 TEST_F(LayerTreeHostCommonTest,
3687 OcclusionForLayerWithUninvertibleDrawTransform) { 3775 OcclusionForLayerWithUninvertibleDrawTransform) {
3688 FakeImplTaskRunnerProvider task_runner_provider; 3776 FakeImplTaskRunnerProvider task_runner_provider;
3689 TestSharedBitmapManager shared_bitmap_manager; 3777 TestSharedBitmapManager shared_bitmap_manager;
3690 TestTaskGraphRunner task_graph_runner; 3778 TestTaskGraphRunner task_graph_runner;
3691 std::unique_ptr<OutputSurface> output_surface = FakeOutputSurface::Create3d(); 3779 std::unique_ptr<OutputSurface> output_surface = FakeOutputSurface::Create3d();
3692 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, 3780 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager,
3693 &task_graph_runner); 3781 &task_graph_runner);
3782
3694 std::unique_ptr<LayerImpl> root = 3783 std::unique_ptr<LayerImpl> root =
3695 LayerImpl::Create(host_impl.active_tree(), 1); 3784 LayerImpl::Create(host_impl.active_tree(), 1);
3696 std::unique_ptr<LayerImpl> child = 3785 std::unique_ptr<LayerImpl> child =
3697 LayerImpl::Create(host_impl.active_tree(), 2); 3786 LayerImpl::Create(host_impl.active_tree(), 2);
3698 std::unique_ptr<LayerImpl> grand_child = 3787 std::unique_ptr<LayerImpl> grand_child =
3699 LayerImpl::Create(host_impl.active_tree(), 3); 3788 LayerImpl::Create(host_impl.active_tree(), 3);
3700 std::unique_ptr<LayerImpl> occluding_child = 3789 std::unique_ptr<LayerImpl> occluding_child =
3701 LayerImpl::Create(host_impl.active_tree(), 4); 3790 LayerImpl::Create(host_impl.active_tree(), 4);
3702 child->SetDrawsContent(true); 3791 child->SetDrawsContent(true);
3703 grand_child->SetDrawsContent(true); 3792 grand_child->SetDrawsContent(true);
(...skipping 6728 matching lines...) Expand 10 before | Expand all | Expand 10 after
10432 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); 10521 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index());
10433 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); 10522 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index());
10434 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); 10523 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index());
10435 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); 10524 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index());
10436 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); 10525 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index());
10437 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); 10526 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index());
10438 } 10527 }
10439 10528
10440 } // namespace 10529 } // namespace
10441 } // namespace cc 10530 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/draw_property_utils.cc ('k') | cc/trees/layer_tree_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698