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

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

Issue 328753002: Clean up PointIsClippedBySurfaceOrClipRect (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « cc/trees/layer_tree_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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, HitTestingRespectsClipParents) {
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> child =
1136 LayerImpl::Create(host_impl().active_tree(), 2);
1137 scoped_ptr<LayerImpl> grand_child =
1138 LayerImpl::Create(host_impl().active_tree(), 4);
1139
1140 position = gfx::PointF(10.f, 10.f);
1141 bounds = gfx::Size(1, 1);
1142 SetLayerPropertiesForTesting(child.get(),
1143 identity_matrix,
1144 transform_origin,
1145 position,
1146 bounds,
1147 true,
1148 false);
1149 child->SetDrawsContent(true);
1150 child->SetMasksToBounds(true);
1151
1152 position = gfx::PointF(0.f, 40.f);
1153 bounds = gfx::Size(100, 50);
1154 SetLayerPropertiesForTesting(grand_child.get(),
1155 identity_matrix,
1156 transform_origin,
1157 position,
1158 bounds,
1159 true,
1160 false);
1161 grand_child->SetDrawsContent(true);
1162 grand_child->SetForceRenderSurface(true);
1163
1164 // This should let |grand_child| "escape" |child|'s clip.
1165 grand_child->SetClipParent(root.get());
1166
1167 child->AddChild(grand_child.Pass());
1168 root->AddChild(child.Pass());
1169 }
1170
1171 host_impl().SetViewportSize(root->bounds());
1172 host_impl().active_tree()->SetRootLayer(root.Pass());
1173 host_impl().active_tree()->UpdateDrawProperties();
1174
1175 gfx::Point test_point = gfx::Point(12, 52);
1176 LayerImpl* result_layer =
1177 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point);
1178 ASSERT_TRUE(result_layer);
1179 EXPECT_EQ(4, result_layer->id());
1180 }
1181
1182 TEST_F(LayerTreeImplTest, HitTestingRespectsScrollParents) {
1183 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1);
1184 gfx::Transform identity_matrix;
1185 gfx::Point3F transform_origin;
1186 gfx::PointF position;
1187 gfx::Size bounds(100, 100);
1188 SetLayerPropertiesForTesting(root.get(),
1189 identity_matrix,
1190 transform_origin,
1191 position,
1192 bounds,
1193 true,
1194 false);
1195 root->SetDrawsContent(true);
1196 {
1197 scoped_ptr<LayerImpl> child =
1198 LayerImpl::Create(host_impl().active_tree(), 2);
1199 scoped_ptr<LayerImpl> scroll_child =
1200 LayerImpl::Create(host_impl().active_tree(), 3);
1201 scoped_ptr<LayerImpl> grand_child =
1202 LayerImpl::Create(host_impl().active_tree(), 4);
1203
1204 position = gfx::PointF(10.f, 10.f);
1205 bounds = gfx::Size(1, 1);
1206 SetLayerPropertiesForTesting(child.get(),
1207 identity_matrix,
1208 transform_origin,
1209 position,
1210 bounds,
1211 true,
1212 false);
1213 child->SetDrawsContent(true);
1214 child->SetMasksToBounds(true);
1215
1216 position = gfx::PointF();
1217 bounds = gfx::Size(200, 200);
1218 SetLayerPropertiesForTesting(scroll_child.get(),
1219 identity_matrix,
1220 transform_origin,
1221 position,
1222 bounds,
1223 true,
1224 false);
1225 scroll_child->SetDrawsContent(true);
1226
1227 // This should cause scroll child and its descendants to be affected by
1228 // |child|'s clip.
1229 scroll_child->SetScrollParent(child.get());
1230
1231 SetLayerPropertiesForTesting(grand_child.get(),
1232 identity_matrix,
1233 transform_origin,
1234 position,
1235 bounds,
1236 true,
1237 false);
1238 grand_child->SetDrawsContent(true);
1239 grand_child->SetForceRenderSurface(true);
1240
1241 scroll_child->AddChild(grand_child.Pass());
1242 root->AddChild(scroll_child.Pass());
1243 root->AddChild(child.Pass());
1244 }
1245
1246 host_impl().SetViewportSize(root->bounds());
1247 host_impl().active_tree()->SetRootLayer(root.Pass());
1248 host_impl().active_tree()->UpdateDrawProperties();
1249
1250 gfx::Point test_point = gfx::Point(12, 52);
1251 LayerImpl* result_layer =
1252 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point);
1253 // The |test_point| should have been clipped away by |child|, the scroll
1254 // parent, so the only thing that should be hit is |root|.
1255 ASSERT_TRUE(result_layer);
1256 ASSERT_EQ(1, result_layer->id());
1257 }
1120 TEST_F(LayerTreeImplTest, HitTestingForMultipleLayerLists) { 1258 TEST_F(LayerTreeImplTest, HitTestingForMultipleLayerLists) {
1121 // 1259 //
1122 // The geometry is set up similarly to the previous case, but 1260 // The geometry is set up similarly to the previous case, but
1123 // all layers are forced to be render surfaces now. 1261 // all layers are forced to be render surfaces now.
1124 // 1262 //
1125 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); 1263 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1);
1126 1264
1127 gfx::Transform identity_matrix; 1265 gfx::Transform identity_matrix;
1128 gfx::Point3F transform_origin; 1266 gfx::Point3F transform_origin;
1129 gfx::PointF position; 1267 gfx::PointF position;
(...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after
1927 2065
1928 test_point = gfx::Point(35, 65); 2066 test_point = gfx::Point(35, 65);
1929 result_layer = 2067 result_layer =
1930 host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( 2068 host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion(
1931 test_point); 2069 test_point);
1932 EXPECT_FALSE(result_layer); 2070 EXPECT_FALSE(result_layer);
1933 } 2071 }
1934 2072
1935 } // namespace 2073 } // namespace
1936 } // namespace cc 2074 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698