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

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: comments 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
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
3706 surface->SetDrawsContent(true);
3707 surface_child->SetDrawsContent(true);
3708 surface_sibling->SetDrawsContent(true);
3709 surface->SetContentsOpaque(true);
3710 surface_child->SetContentsOpaque(true);
3711 surface_sibling->SetContentsOpaque(true);
3712
3713 surface->test_properties()->opacity = 0.5f;
3714 surface_child->test_properties()->opacity = 0.6f;
3715
3716 gfx::Transform identity_matrix;
3717 gfx::Transform translate;
3718 translate.Translate(20.f, 20.f);
3719
3720 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(),
3721 gfx::PointF(), gfx::Size(1000, 1000), true,
3722 false, true);
3723 SetLayerPropertiesForTesting(child.get(), identity_matrix, gfx::Point3F(),
3724 gfx::PointF(), gfx::Size(300, 300), false, true,
3725 false);
3726 SetLayerPropertiesForTesting(surface.get(), translate, gfx::Point3F(),
3727 gfx::PointF(), gfx::Size(300, 300), false, true,
3728 true);
3729 SetLayerPropertiesForTesting(surface_child.get(), identity_matrix,
3730 gfx::Point3F(), gfx::PointF(),
3731 gfx::Size(300, 300), false, false, true);
3732 SetLayerPropertiesForTesting(surface_sibling.get(), identity_matrix,
3733 gfx::Point3F(), gfx::PointF(),
3734 gfx::Size(200, 200), false, false, false);
3735
3736 LayerImpl* surface_ptr = surface.get();
3737 LayerImpl* surface_child_ptr = surface_child.get();
3738
3739 host_impl.SetViewportSize(root->bounds());
3740
3741 surface->test_properties()->AddChild(std::move(surface_child));
3742 child->test_properties()->AddChild(std::move(surface));
3743 child->test_properties()->AddChild(std::move(surface_sibling));
3744 root->test_properties()->AddChild(std::move(child));
3745 host_impl.active_tree()->SetRootLayerForTesting(std::move(root));
3746 host_impl.SetVisible(true);
3747 host_impl.InitializeRenderer(output_surface.get());
3748 host_impl.active_tree()->BuildLayerListAndPropertyTreesForTesting();
3749 bool update_lcd_text = false;
3750 host_impl.active_tree()->UpdateDrawProperties(update_lcd_text);
3751
3752 EXPECT_TRANSFORMATION_MATRIX_EQ(
3753 surface_ptr->render_surface()->draw_transform(), translate);
3754 // surface_sibling draws into the root render surface and occludes
3755 // surface_child's contents.
3756 Occlusion actual_occlusion =
3757 surface_child_ptr->render_surface()->occlusion_in_content_space();
3758 Occlusion expected_occlusion(translate, SimpleEnclosedRegion(gfx::Rect()),
3759 SimpleEnclosedRegion(gfx::Rect(200, 200)));
3760 EXPECT_TRUE(expected_occlusion.IsEqual(actual_occlusion));
3761 }
3762
3686 TEST_F(LayerTreeHostCommonTest, 3763 TEST_F(LayerTreeHostCommonTest,
3687 OcclusionForLayerWithUninvertibleDrawTransform) { 3764 OcclusionForLayerWithUninvertibleDrawTransform) {
3688 FakeImplTaskRunnerProvider task_runner_provider; 3765 FakeImplTaskRunnerProvider task_runner_provider;
3689 TestSharedBitmapManager shared_bitmap_manager; 3766 TestSharedBitmapManager shared_bitmap_manager;
3690 TestTaskGraphRunner task_graph_runner; 3767 TestTaskGraphRunner task_graph_runner;
3691 std::unique_ptr<OutputSurface> output_surface = FakeOutputSurface::Create3d(); 3768 std::unique_ptr<OutputSurface> output_surface = FakeOutputSurface::Create3d();
3692 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, 3769 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager,
3693 &task_graph_runner); 3770 &task_graph_runner);
3771
3694 std::unique_ptr<LayerImpl> root = 3772 std::unique_ptr<LayerImpl> root =
3695 LayerImpl::Create(host_impl.active_tree(), 1); 3773 LayerImpl::Create(host_impl.active_tree(), 1);
3696 std::unique_ptr<LayerImpl> child = 3774 std::unique_ptr<LayerImpl> child =
3697 LayerImpl::Create(host_impl.active_tree(), 2); 3775 LayerImpl::Create(host_impl.active_tree(), 2);
3698 std::unique_ptr<LayerImpl> grand_child = 3776 std::unique_ptr<LayerImpl> grand_child =
3699 LayerImpl::Create(host_impl.active_tree(), 3); 3777 LayerImpl::Create(host_impl.active_tree(), 3);
3700 std::unique_ptr<LayerImpl> occluding_child = 3778 std::unique_ptr<LayerImpl> occluding_child =
3701 LayerImpl::Create(host_impl.active_tree(), 4); 3779 LayerImpl::Create(host_impl.active_tree(), 4);
3702 child->SetDrawsContent(true); 3780 child->SetDrawsContent(true);
3703 grand_child->SetDrawsContent(true); 3781 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()); 10510 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index());
10433 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); 10511 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index());
10434 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); 10512 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index());
10435 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); 10513 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index());
10436 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); 10514 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index());
10437 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); 10515 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index());
10438 } 10516 }
10439 10517
10440 } // namespace 10518 } // namespace
10441 } // namespace cc 10519 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698