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/test/fake_impl_proxy.h" | 9 #include "cc/test/fake_impl_proxy.h" |
10 #include "cc/test/fake_layer_tree_host_impl.h" | 10 #include "cc/test/fake_layer_tree_host_impl.h" |
(...skipping 1099 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1110 | 1110 |
1111 // At (20, 51), child1 and grand_child1 overlap. grand_child1 is expected to | 1111 // At (20, 51), child1 and grand_child1 overlap. grand_child1 is expected to |
1112 // be on top. | 1112 // be on top. |
1113 test_point = gfx::Point(20, 51); | 1113 test_point = gfx::Point(20, 51); |
1114 result_layer = | 1114 result_layer = |
1115 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 1115 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); |
1116 ASSERT_TRUE(result_layer); | 1116 ASSERT_TRUE(result_layer); |
1117 EXPECT_EQ(4, result_layer->id()); | 1117 EXPECT_EQ(4, result_layer->id()); |
1118 } | 1118 } |
1119 | 1119 |
1120 TEST_F(LayerTreeImplTest, HitTestingWithUntargetedClippedLayer) { | |
1121 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); | |
1122 gfx::Transform identity_matrix; | |
1123 gfx::Point3F transform_origin; | |
1124 gfx::PointF position; | |
1125 gfx::Size bounds(100, 100); | |
1126 SetLayerPropertiesForTesting(root.get(), | |
1127 identity_matrix, | |
1128 transform_origin, | |
1129 position, | |
1130 bounds, | |
1131 true, | |
1132 false); | |
1133 root->SetDrawsContent(true); | |
1134 { | |
1135 scoped_ptr<LayerImpl> child1 = | |
1136 LayerImpl::Create(host_impl().active_tree(), 2); | |
1137 scoped_ptr<LayerImpl> grand_child1 = | |
1138 LayerImpl::Create(host_impl().active_tree(), 4); | |
1139 | |
1140 position = gfx::PointF(10.f, 10.f); | |
1141 bounds = gfx::Size(50, 50); | |
1142 SetLayerPropertiesForTesting(child1.get(), | |
1143 identity_matrix, | |
1144 transform_origin, | |
1145 position, | |
1146 bounds, | |
1147 true, | |
1148 false); | |
1149 child1->SetDrawsContent(true); | |
1150 child1->SetForceRenderSurface(true); | |
1151 child1->SetMasksToBounds(true); | |
1152 | |
1153 position = gfx::PointF(0.f, 40.f); | |
1154 bounds = gfx::Size(100, 50); | |
1155 SetLayerPropertiesForTesting(grand_child1.get(), | |
1156 identity_matrix, | |
1157 transform_origin, | |
1158 position, | |
1159 bounds, | |
1160 true, | |
1161 false); | |
1162 grand_child1->SetDrawsContent(true); | |
1163 grand_child1->SetForceRenderSurface(true); | |
1164 | |
1165 child1->AddChild(grand_child1.Pass()); | |
1166 root->AddChild(child1.Pass()); | |
1167 } | |
1168 | |
1169 LayerImpl* child1 = root->children()[0]; | |
1170 LayerImpl* grand_child1 = child1->children()[0]; | |
1171 | |
1172 host_impl().SetViewportSize(root->bounds()); | |
1173 host_impl().active_tree()->SetRootLayer(root.Pass()); | |
1174 host_impl().active_tree()->UpdateDrawProperties(); | |
1175 | |
1176 child1->draw_properties().render_target = NULL; | |
danakj
2014/06/10 14:59:26
This seems artificial, we don't clear the render t
| |
1177 | |
1178 // Attempt to hit test on a clipped layer with no render target. | |
1179 gfx::Point test_point = gfx::Point(1, 1); | |
1180 LayerImpl* result_layer = | |
1181 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | |
1182 ASSERT_TRUE(result_layer); | |
1183 EXPECT_EQ(1, result_layer->id()); | |
1184 } | |
1185 | |
1120 TEST_F(LayerTreeImplTest, HitTestingForMultipleLayerLists) { | 1186 TEST_F(LayerTreeImplTest, HitTestingForMultipleLayerLists) { |
1121 // | 1187 // |
1122 // The geometry is set up similarly to the previous case, but | 1188 // The geometry is set up similarly to the previous case, but |
1123 // all layers are forced to be render surfaces now. | 1189 // all layers are forced to be render surfaces now. |
1124 // | 1190 // |
1125 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); | 1191 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); |
1126 | 1192 |
1127 gfx::Transform identity_matrix; | 1193 gfx::Transform identity_matrix; |
1128 gfx::Point3F transform_origin; | 1194 gfx::Point3F transform_origin; |
1129 gfx::PointF position; | 1195 gfx::PointF position; |
(...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1927 | 1993 |
1928 test_point = gfx::Point(35, 65); | 1994 test_point = gfx::Point(35, 65); |
1929 result_layer = | 1995 result_layer = |
1930 host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 1996 host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( |
1931 test_point); | 1997 test_point); |
1932 EXPECT_FALSE(result_layer); | 1998 EXPECT_FALSE(result_layer); |
1933 } | 1999 } |
1934 | 2000 |
1935 } // namespace | 2001 } // namespace |
1936 } // namespace cc | 2002 } // namespace cc |
OLD | NEW |