| 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 "cc/layers/heads_up_display_layer_impl.h" | 7 #include "cc/layers/heads_up_display_layer_impl.h" |
| 8 #include "cc/layers/layer.h" | 8 #include "cc/layers/layer.h" |
| 9 #include "cc/layers/solid_color_scrollbar_layer_impl.h" | 9 #include "cc/layers/solid_color_scrollbar_layer_impl.h" |
| 10 #include "cc/test/fake_impl_task_runner_provider.h" | 10 #include "cc/test/fake_impl_task_runner_provider.h" |
| (...skipping 1054 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1065 std::unique_ptr<LayerImpl> root = | 1065 std::unique_ptr<LayerImpl> root = |
| 1066 LayerImpl::Create(host_impl().active_tree(), 1); | 1066 LayerImpl::Create(host_impl().active_tree(), 1); |
| 1067 | 1067 |
| 1068 gfx::Transform identity_matrix; | 1068 gfx::Transform identity_matrix; |
| 1069 gfx::Point3F transform_origin; | 1069 gfx::Point3F transform_origin; |
| 1070 gfx::PointF position; | 1070 gfx::PointF position; |
| 1071 gfx::Size bounds(100, 100); | 1071 gfx::Size bounds(100, 100); |
| 1072 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, | 1072 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, |
| 1073 position, bounds, true, false, true); | 1073 position, bounds, true, false, true); |
| 1074 root->SetDrawsContent(true); | 1074 root->SetDrawsContent(true); |
| 1075 root->SetShouldFlattenTransform(false); | 1075 root->test_properties()->should_flatten_transform = false; |
| 1076 root->Set3dSortingContextId(1); | 1076 root->Set3dSortingContextId(1); |
| 1077 { | 1077 { |
| 1078 // child 1 and child2 are initialized to overlap between x=50 and x=60. | 1078 // child 1 and child2 are initialized to overlap between x=50 and x=60. |
| 1079 // grand_child is set to overlap both child1 and child2 between y=50 and | 1079 // grand_child is set to overlap both child1 and child2 between y=50 and |
| 1080 // y=60. The expected stacking order is: (front) child2, (second) | 1080 // y=60. The expected stacking order is: (front) child2, (second) |
| 1081 // grand_child, (third) child1, and (back) the root layer behind all other | 1081 // grand_child, (third) child1, and (back) the root layer behind all other |
| 1082 // layers. | 1082 // layers. |
| 1083 | 1083 |
| 1084 std::unique_ptr<LayerImpl> child1 = | 1084 std::unique_ptr<LayerImpl> child1 = |
| 1085 LayerImpl::Create(host_impl().active_tree(), 2); | 1085 LayerImpl::Create(host_impl().active_tree(), 2); |
| 1086 std::unique_ptr<LayerImpl> child2 = | 1086 std::unique_ptr<LayerImpl> child2 = |
| 1087 LayerImpl::Create(host_impl().active_tree(), 3); | 1087 LayerImpl::Create(host_impl().active_tree(), 3); |
| 1088 std::unique_ptr<LayerImpl> grand_child1 = | 1088 std::unique_ptr<LayerImpl> grand_child1 = |
| 1089 LayerImpl::Create(host_impl().active_tree(), 4); | 1089 LayerImpl::Create(host_impl().active_tree(), 4); |
| 1090 | 1090 |
| 1091 position = gfx::PointF(10.f, 10.f); | 1091 position = gfx::PointF(10.f, 10.f); |
| 1092 bounds = gfx::Size(50, 50); | 1092 bounds = gfx::Size(50, 50); |
| 1093 SetLayerPropertiesForTesting(child1.get(), identity_matrix, | 1093 SetLayerPropertiesForTesting(child1.get(), identity_matrix, |
| 1094 transform_origin, position, bounds, true, | 1094 transform_origin, position, bounds, true, |
| 1095 false, false); | 1095 false, false); |
| 1096 child1->SetDrawsContent(true); | 1096 child1->SetDrawsContent(true); |
| 1097 child1->SetShouldFlattenTransform(false); | 1097 child1->test_properties()->should_flatten_transform = false; |
| 1098 child1->Set3dSortingContextId(1); | 1098 child1->Set3dSortingContextId(1); |
| 1099 | 1099 |
| 1100 position = gfx::PointF(50.f, 10.f); | 1100 position = gfx::PointF(50.f, 10.f); |
| 1101 bounds = gfx::Size(50, 50); | 1101 bounds = gfx::Size(50, 50); |
| 1102 gfx::Transform translate_z; | 1102 gfx::Transform translate_z; |
| 1103 translate_z.Translate3d(0, 0, 10.f); | 1103 translate_z.Translate3d(0, 0, 10.f); |
| 1104 SetLayerPropertiesForTesting(child2.get(), translate_z, transform_origin, | 1104 SetLayerPropertiesForTesting(child2.get(), translate_z, transform_origin, |
| 1105 position, bounds, true, false, false); | 1105 position, bounds, true, false, false); |
| 1106 child2->SetDrawsContent(true); | 1106 child2->SetDrawsContent(true); |
| 1107 child2->SetShouldFlattenTransform(false); | 1107 child2->test_properties()->should_flatten_transform = false; |
| 1108 child2->Set3dSortingContextId(1); | 1108 child2->Set3dSortingContextId(1); |
| 1109 | 1109 |
| 1110 // Remember that grand_child is positioned with respect to its parent (i.e. | 1110 // Remember that grand_child is positioned with respect to its parent (i.e. |
| 1111 // child1). In screen space, the intended position is (10, 50), with size | 1111 // child1). In screen space, the intended position is (10, 50), with size |
| 1112 // 100 x 50. | 1112 // 100 x 50. |
| 1113 position = gfx::PointF(0.f, 40.f); | 1113 position = gfx::PointF(0.f, 40.f); |
| 1114 bounds = gfx::Size(100, 50); | 1114 bounds = gfx::Size(100, 50); |
| 1115 SetLayerPropertiesForTesting(grand_child1.get(), identity_matrix, | 1115 SetLayerPropertiesForTesting(grand_child1.get(), identity_matrix, |
| 1116 transform_origin, position, bounds, true, | 1116 transform_origin, position, bounds, true, |
| 1117 false, false); | 1117 false, false); |
| 1118 grand_child1->SetDrawsContent(true); | 1118 grand_child1->SetDrawsContent(true); |
| 1119 grand_child1->SetShouldFlattenTransform(false); | 1119 grand_child1->test_properties()->should_flatten_transform = false; |
| 1120 | 1120 |
| 1121 child1->AddChild(std::move(grand_child1)); | 1121 child1->AddChild(std::move(grand_child1)); |
| 1122 root->AddChild(std::move(child1)); | 1122 root->AddChild(std::move(child1)); |
| 1123 root->AddChild(std::move(child2)); | 1123 root->AddChild(std::move(child2)); |
| 1124 } | 1124 } |
| 1125 | 1125 |
| 1126 LayerImpl* child1 = root->children()[0]; | 1126 LayerImpl* child1 = root->children()[0]; |
| 1127 LayerImpl* child2 = root->children()[1]; | 1127 LayerImpl* child2 = root->children()[1]; |
| 1128 LayerImpl* grand_child1 = child1->children()[0]; | 1128 LayerImpl* grand_child1 = child1->children()[0]; |
| 1129 | 1129 |
| (...skipping 1323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2453 gfx::PointF test_point = gfx::PointF(1.f, 1.f); | 2453 gfx::PointF test_point = gfx::PointF(1.f, 1.f); |
| 2454 LayerImpl* result_layer = | 2454 LayerImpl* result_layer = |
| 2455 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 2455 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); |
| 2456 | 2456 |
| 2457 CHECK(result_layer); | 2457 CHECK(result_layer); |
| 2458 EXPECT_EQ(2, result_layer->id()); | 2458 EXPECT_EQ(2, result_layer->id()); |
| 2459 } | 2459 } |
| 2460 | 2460 |
| 2461 } // namespace | 2461 } // namespace |
| 2462 } // namespace cc | 2462 } // namespace cc |
| OLD | NEW |