| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_impl.h" | 5 #include "cc/trees/layer_tree_impl.h" |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "cc/layers/heads_up_display_layer_impl.h" | 9 #include "cc/layers/heads_up_display_layer_impl.h" |
| 10 #include "cc/test/fake_layer_tree_host_impl.h" | 10 #include "cc/test/fake_layer_tree_host_impl.h" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 std::unique_ptr<LayerImpl> left_child = | 73 std::unique_ptr<LayerImpl> left_child = |
| 74 LayerImpl::Create(host_impl().active_tree(), left_child_id); | 74 LayerImpl::Create(host_impl().active_tree(), left_child_id); |
| 75 std::unique_ptr<LayerImpl> right_child = | 75 std::unique_ptr<LayerImpl> right_child = |
| 76 LayerImpl::Create(host_impl().active_tree(), right_child_id); | 76 LayerImpl::Create(host_impl().active_tree(), right_child_id); |
| 77 | 77 |
| 78 gfx::Size bounds(100, 100); | 78 gfx::Size bounds(100, 100); |
| 79 { | 79 { |
| 80 gfx::Transform translate_z; | 80 gfx::Transform translate_z; |
| 81 translate_z.Translate3d(0, 0, root_depth); | 81 translate_z.Translate3d(0, 0, root_depth); |
| 82 root->test_properties()->transform = translate_z; | 82 root->test_properties()->transform = translate_z; |
| 83 root->test_properties()->sorting_context_id = root_sorting_context; |
| 83 root->SetBounds(bounds); | 84 root->SetBounds(bounds); |
| 84 root->SetDrawsContent(true); | 85 root->SetDrawsContent(true); |
| 85 root->Set3dSortingContextId(root_sorting_context); | |
| 86 } | 86 } |
| 87 { | 87 { |
| 88 gfx::Transform translate_z; | 88 gfx::Transform translate_z; |
| 89 translate_z.Translate3d(0, 0, left_child_depth); | 89 translate_z.Translate3d(0, 0, left_child_depth); |
| 90 left_child->test_properties()->transform = translate_z; | 90 left_child->test_properties()->transform = translate_z; |
| 91 left_child->test_properties()->sorting_context_id = |
| 92 left_child_sorting_context; |
| 91 left_child->SetBounds(bounds); | 93 left_child->SetBounds(bounds); |
| 92 left_child->SetDrawsContent(true); | 94 left_child->SetDrawsContent(true); |
| 93 left_child->Set3dSortingContextId(left_child_sorting_context); | |
| 94 left_child->test_properties()->should_flatten_transform = false; | 95 left_child->test_properties()->should_flatten_transform = false; |
| 95 } | 96 } |
| 96 { | 97 { |
| 97 gfx::Transform translate_z; | 98 gfx::Transform translate_z; |
| 98 translate_z.Translate3d(0, 0, right_child_depth); | 99 translate_z.Translate3d(0, 0, right_child_depth); |
| 99 right_child->test_properties()->transform = translate_z; | 100 right_child->test_properties()->transform = translate_z; |
| 101 right_child->test_properties()->sorting_context_id = |
| 102 right_child_sorting_context; |
| 100 right_child->SetBounds(bounds); | 103 right_child->SetBounds(bounds); |
| 101 right_child->SetDrawsContent(true); | 104 right_child->SetDrawsContent(true); |
| 102 right_child->Set3dSortingContextId(right_child_sorting_context); | |
| 103 } | 105 } |
| 104 | 106 |
| 105 root->test_properties()->AddChild(std::move(left_child)); | 107 root->test_properties()->AddChild(std::move(left_child)); |
| 106 root->test_properties()->AddChild(std::move(right_child)); | 108 root->test_properties()->AddChild(std::move(right_child)); |
| 107 | 109 |
| 108 host_impl().SetViewportSize(root->bounds()); | 110 host_impl().SetViewportSize(root->bounds()); |
| 109 host_impl().active_tree()->SetRootLayerForTesting(std::move(root)); | 111 host_impl().active_tree()->SetRootLayerForTesting(std::move(root)); |
| 110 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 112 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
| 111 CHECK_EQ(1u, RenderSurfaceLayerList().size()); | 113 CHECK_EQ(1u, RenderSurfaceLayerList().size()); |
| 112 | 114 |
| (...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 934 /* sorting_contexts */ 10, 10, 10, | 936 /* sorting_contexts */ 10, 10, 10, |
| 935 /* depths */ 0, -1, -1); | 937 /* depths */ 0, -1, -1); |
| 936 EXPECT_EQ(1, hit_layer_id); | 938 EXPECT_EQ(1, hit_layer_id); |
| 937 } | 939 } |
| 938 | 940 |
| 939 TEST_F(LayerTreeImplTest, HitTestingForMultipleLayersAtVaryingDepths) { | 941 TEST_F(LayerTreeImplTest, HitTestingForMultipleLayersAtVaryingDepths) { |
| 940 LayerImpl* root = root_layer(); | 942 LayerImpl* root = root_layer(); |
| 941 root->SetBounds(gfx::Size(100, 100)); | 943 root->SetBounds(gfx::Size(100, 100)); |
| 942 root->SetDrawsContent(true); | 944 root->SetDrawsContent(true); |
| 943 root->test_properties()->should_flatten_transform = false; | 945 root->test_properties()->should_flatten_transform = false; |
| 944 root->Set3dSortingContextId(1); | 946 root->test_properties()->sorting_context_id = 1; |
| 945 { | 947 { |
| 946 // child 1 and child2 are initialized to overlap between x=50 and x=60. | 948 // child 1 and child2 are initialized to overlap between x=50 and x=60. |
| 947 // grand_child is set to overlap both child1 and child2 between y=50 and | 949 // grand_child is set to overlap both child1 and child2 between y=50 and |
| 948 // y=60. The expected stacking order is: (front) child2, (second) | 950 // y=60. The expected stacking order is: (front) child2, (second) |
| 949 // grand_child, (third) child1, and (back) the root layer behind all other | 951 // grand_child, (third) child1, and (back) the root layer behind all other |
| 950 // layers. | 952 // layers. |
| 951 | 953 |
| 952 std::unique_ptr<LayerImpl> child1 = | 954 std::unique_ptr<LayerImpl> child1 = |
| 953 LayerImpl::Create(host_impl().active_tree(), 2); | 955 LayerImpl::Create(host_impl().active_tree(), 2); |
| 954 std::unique_ptr<LayerImpl> child2 = | 956 std::unique_ptr<LayerImpl> child2 = |
| 955 LayerImpl::Create(host_impl().active_tree(), 3); | 957 LayerImpl::Create(host_impl().active_tree(), 3); |
| 956 std::unique_ptr<LayerImpl> grand_child1 = | 958 std::unique_ptr<LayerImpl> grand_child1 = |
| 957 LayerImpl::Create(host_impl().active_tree(), 4); | 959 LayerImpl::Create(host_impl().active_tree(), 4); |
| 958 | 960 |
| 959 child1->SetPosition(gfx::PointF(10.f, 10.f)); | 961 child1->SetPosition(gfx::PointF(10.f, 10.f)); |
| 960 child1->SetBounds(gfx::Size(50, 50)); | 962 child1->SetBounds(gfx::Size(50, 50)); |
| 961 child1->SetDrawsContent(true); | 963 child1->SetDrawsContent(true); |
| 962 child1->test_properties()->should_flatten_transform = false; | 964 child1->test_properties()->should_flatten_transform = false; |
| 963 child1->Set3dSortingContextId(1); | 965 child1->test_properties()->sorting_context_id = 1; |
| 964 | 966 |
| 965 child2->SetPosition(gfx::PointF(50.f, 10.f)); | 967 child2->SetPosition(gfx::PointF(50.f, 10.f)); |
| 966 child2->SetBounds(gfx::Size(50, 50)); | 968 child2->SetBounds(gfx::Size(50, 50)); |
| 967 gfx::Transform translate_z; | 969 gfx::Transform translate_z; |
| 968 translate_z.Translate3d(0, 0, 10.f); | 970 translate_z.Translate3d(0, 0, 10.f); |
| 969 child2->test_properties()->transform = translate_z; | 971 child2->test_properties()->transform = translate_z; |
| 970 child2->SetDrawsContent(true); | 972 child2->SetDrawsContent(true); |
| 971 child2->test_properties()->should_flatten_transform = false; | 973 child2->test_properties()->should_flatten_transform = false; |
| 972 child2->Set3dSortingContextId(1); | 974 child2->test_properties()->sorting_context_id = 1; |
| 973 | 975 |
| 974 // Remember that grand_child is positioned with respect to its parent (i.e. | 976 // Remember that grand_child is positioned with respect to its parent (i.e. |
| 975 // child1). In screen space, the intended position is (10, 50), with size | 977 // child1). In screen space, the intended position is (10, 50), with size |
| 976 // 100 x 50. | 978 // 100 x 50. |
| 977 grand_child1->SetPosition(gfx::PointF(0.f, 40.f)); | 979 grand_child1->SetPosition(gfx::PointF(0.f, 40.f)); |
| 978 grand_child1->SetBounds(gfx::Size(100, 50)); | 980 grand_child1->SetBounds(gfx::Size(100, 50)); |
| 979 grand_child1->SetDrawsContent(true); | 981 grand_child1->SetDrawsContent(true); |
| 980 grand_child1->test_properties()->should_flatten_transform = false; | 982 grand_child1->test_properties()->should_flatten_transform = false; |
| 981 | 983 |
| 982 child1->test_properties()->AddChild(std::move(grand_child1)); | 984 child1->test_properties()->AddChild(std::move(grand_child1)); |
| (...skipping 1424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2407 auto weak_promise = promise->AsWeakPtr(); | 2409 auto weak_promise = promise->AsWeakPtr(); |
| 2408 host_impl().active_tree()->QueueSwapPromise(std::move(promise)); | 2410 host_impl().active_tree()->QueueSwapPromise(std::move(promise)); |
| 2409 host_impl().active_tree()->BreakSwapPromises( | 2411 host_impl().active_tree()->BreakSwapPromises( |
| 2410 SwapPromise::DidNotSwapReason::SWAP_FAILS); | 2412 SwapPromise::DidNotSwapReason::SWAP_FAILS); |
| 2411 EXPECT_FALSE(weak_promise); | 2413 EXPECT_FALSE(weak_promise); |
| 2412 } | 2414 } |
| 2413 } | 2415 } |
| 2414 | 2416 |
| 2415 } // namespace | 2417 } // namespace |
| 2416 } // namespace cc | 2418 } // namespace cc |
| OLD | NEW |