| OLD | NEW |
| 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 <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "cc/animation/layer_animation_controller.h" | 9 #include "cc/animation/layer_animation_controller.h" |
| 10 #include "cc/animation/transform_operations.h" | 10 #include "cc/animation/transform_operations.h" |
| (...skipping 4122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4133 render_surface_layer_list.at(1)->render_surface()->layer_list().size()); | 4133 render_surface_layer_list.at(1)->render_surface()->layer_list().size()); |
| 4134 EXPECT_EQ(front_facing_surface->id(), | 4134 EXPECT_EQ(front_facing_surface->id(), |
| 4135 render_surface_layer_list.at(1) | 4135 render_surface_layer_list.at(1) |
| 4136 ->render_surface()->layer_list().at(0)->id()); | 4136 ->render_surface()->layer_list().at(0)->id()); |
| 4137 EXPECT_EQ(child1->id(), | 4137 EXPECT_EQ(child1->id(), |
| 4138 render_surface_layer_list.at(1) | 4138 render_surface_layer_list.at(1) |
| 4139 ->render_surface()->layer_list().at(1)->id()); | 4139 ->render_surface()->layer_list().at(1)->id()); |
| 4140 } | 4140 } |
| 4141 | 4141 |
| 4142 | 4142 |
| 4143 TEST_F(LayerTreeHostCommonTest, HitTestingForEmptyLayerList) { | |
| 4144 // Hit testing on an empty render_surface_layer_list should return a null | |
| 4145 // pointer. | |
| 4146 LayerImplList render_surface_layer_list; | |
| 4147 | |
| 4148 gfx::Point test_point(0, 0); | |
| 4149 LayerImpl* result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | |
| 4150 test_point, render_surface_layer_list); | |
| 4151 EXPECT_FALSE(result_layer); | |
| 4152 | |
| 4153 test_point = gfx::Point(10, 20); | |
| 4154 result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | |
| 4155 test_point, render_surface_layer_list); | |
| 4156 EXPECT_FALSE(result_layer); | |
| 4157 } | |
| 4158 | |
| 4159 TEST_F(LayerTreeHostCommonTest, HitTestingForSingleLayer) { | 4143 TEST_F(LayerTreeHostCommonTest, HitTestingForSingleLayer) { |
| 4160 FakeImplProxy proxy; | 4144 FakeImplProxy proxy; |
| 4161 TestSharedBitmapManager shared_bitmap_manager; | 4145 TestSharedBitmapManager shared_bitmap_manager; |
| 4162 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); | 4146 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); |
| 4163 scoped_ptr<LayerImpl> root = | 4147 scoped_ptr<LayerImpl> root = |
| 4164 LayerImpl::Create(host_impl.active_tree(), 12345); | 4148 LayerImpl::Create(host_impl.active_tree(), 12345); |
| 4165 | 4149 |
| 4166 gfx::Transform identity_matrix; | 4150 gfx::Transform identity_matrix; |
| 4167 gfx::PointF anchor; | 4151 gfx::PointF anchor; |
| 4168 gfx::PointF position; | 4152 gfx::PointF position; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 4181 root.get(), root->bounds(), &render_surface_layer_list); | 4165 root.get(), root->bounds(), &render_surface_layer_list); |
| 4182 inputs.can_adjust_raster_scales = true; | 4166 inputs.can_adjust_raster_scales = true; |
| 4183 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 4167 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
| 4184 | 4168 |
| 4185 // Sanity check the scenario we just created. | 4169 // Sanity check the scenario we just created. |
| 4186 ASSERT_EQ(1u, render_surface_layer_list.size()); | 4170 ASSERT_EQ(1u, render_surface_layer_list.size()); |
| 4187 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); | 4171 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); |
| 4188 | 4172 |
| 4189 // Hit testing for a point outside the layer should return a null pointer. | 4173 // Hit testing for a point outside the layer should return a null pointer. |
| 4190 gfx::Point test_point(101, 101); | 4174 gfx::Point test_point(101, 101); |
| 4191 LayerImpl* result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | 4175 LayerImpl* result_layer = |
| 4192 test_point, render_surface_layer_list); | 4176 LayerTreeHostCommon::FindLayerThatIsHitByPoint(test_point, root.get()); |
| 4193 EXPECT_FALSE(result_layer); | 4177 EXPECT_FALSE(result_layer); |
| 4194 | 4178 |
| 4195 test_point = gfx::Point(-1, -1); | 4179 test_point = gfx::Point(-1, -1); |
| 4196 result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | 4180 result_layer = |
| 4197 test_point, render_surface_layer_list); | 4181 LayerTreeHostCommon::FindLayerThatIsHitByPoint(test_point, root.get()); |
| 4198 EXPECT_FALSE(result_layer); | 4182 EXPECT_FALSE(result_layer); |
| 4199 | 4183 |
| 4200 // Hit testing for a point inside should return the root layer. | 4184 // Hit testing for a point inside should return the root layer. |
| 4201 test_point = gfx::Point(1, 1); | 4185 test_point = gfx::Point(1, 1); |
| 4202 result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | 4186 result_layer = |
| 4203 test_point, render_surface_layer_list); | 4187 LayerTreeHostCommon::FindLayerThatIsHitByPoint(test_point, root.get()); |
| 4204 ASSERT_TRUE(result_layer); | 4188 ASSERT_TRUE(result_layer); |
| 4205 EXPECT_EQ(12345, result_layer->id()); | 4189 EXPECT_EQ(12345, result_layer->id()); |
| 4206 | 4190 |
| 4207 test_point = gfx::Point(99, 99); | 4191 test_point = gfx::Point(99, 99); |
| 4208 result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | 4192 result_layer = |
| 4209 test_point, render_surface_layer_list); | 4193 LayerTreeHostCommon::FindLayerThatIsHitByPoint(test_point, root.get()); |
| 4210 ASSERT_TRUE(result_layer); | 4194 ASSERT_TRUE(result_layer); |
| 4211 EXPECT_EQ(12345, result_layer->id()); | 4195 EXPECT_EQ(12345, result_layer->id()); |
| 4212 } | 4196 } |
| 4213 | 4197 |
| 4214 TEST_F(LayerTreeHostCommonTest, HitTestingForSingleLayerAndHud) { | 4198 TEST_F(LayerTreeHostCommonTest, HitTestingForSingleLayerAndHud) { |
| 4215 FakeImplProxy proxy; | 4199 FakeImplProxy proxy; |
| 4216 TestSharedBitmapManager shared_bitmap_manager; | 4200 TestSharedBitmapManager shared_bitmap_manager; |
| 4217 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); | 4201 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); |
| 4218 scoped_ptr<LayerImpl> root = | 4202 scoped_ptr<LayerImpl> root = |
| 4219 LayerImpl::Create(host_impl.active_tree(), 12345); | 4203 LayerImpl::Create(host_impl.active_tree(), 12345); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4252 root.get(), hud_bounds, &render_surface_layer_list); | 4236 root.get(), hud_bounds, &render_surface_layer_list); |
| 4253 inputs.can_adjust_raster_scales = true; | 4237 inputs.can_adjust_raster_scales = true; |
| 4254 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 4238 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
| 4255 | 4239 |
| 4256 // Sanity check the scenario we just created. | 4240 // Sanity check the scenario we just created. |
| 4257 ASSERT_EQ(1u, render_surface_layer_list.size()); | 4241 ASSERT_EQ(1u, render_surface_layer_list.size()); |
| 4258 ASSERT_EQ(2u, root->render_surface()->layer_list().size()); | 4242 ASSERT_EQ(2u, root->render_surface()->layer_list().size()); |
| 4259 | 4243 |
| 4260 // Hit testing for a point inside HUD, but outside root should return null | 4244 // Hit testing for a point inside HUD, but outside root should return null |
| 4261 gfx::Point test_point(101, 101); | 4245 gfx::Point test_point(101, 101); |
| 4262 LayerImpl* result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | 4246 LayerImpl* result_layer = |
| 4263 test_point, render_surface_layer_list); | 4247 LayerTreeHostCommon::FindLayerThatIsHitByPoint(test_point, root.get()); |
| 4264 EXPECT_FALSE(result_layer); | 4248 EXPECT_FALSE(result_layer); |
| 4265 | 4249 |
| 4266 test_point = gfx::Point(-1, -1); | 4250 test_point = gfx::Point(-1, -1); |
| 4267 result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | 4251 result_layer = |
| 4268 test_point, render_surface_layer_list); | 4252 LayerTreeHostCommon::FindLayerThatIsHitByPoint(test_point, root.get()); |
| 4269 EXPECT_FALSE(result_layer); | 4253 EXPECT_FALSE(result_layer); |
| 4270 | 4254 |
| 4271 // Hit testing for a point inside should return the root layer, never the HUD | 4255 // Hit testing for a point inside should return the root layer, never the HUD |
| 4272 // layer. | 4256 // layer. |
| 4273 test_point = gfx::Point(1, 1); | 4257 test_point = gfx::Point(1, 1); |
| 4274 result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | 4258 result_layer = |
| 4275 test_point, render_surface_layer_list); | 4259 LayerTreeHostCommon::FindLayerThatIsHitByPoint(test_point, root.get()); |
| 4276 ASSERT_TRUE(result_layer); | 4260 ASSERT_TRUE(result_layer); |
| 4277 EXPECT_EQ(12345, result_layer->id()); | 4261 EXPECT_EQ(12345, result_layer->id()); |
| 4278 | 4262 |
| 4279 test_point = gfx::Point(99, 99); | 4263 test_point = gfx::Point(99, 99); |
| 4280 result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | 4264 result_layer = |
| 4281 test_point, render_surface_layer_list); | 4265 LayerTreeHostCommon::FindLayerThatIsHitByPoint(test_point, root.get()); |
| 4282 ASSERT_TRUE(result_layer); | 4266 ASSERT_TRUE(result_layer); |
| 4283 EXPECT_EQ(12345, result_layer->id()); | 4267 EXPECT_EQ(12345, result_layer->id()); |
| 4284 } | 4268 } |
| 4285 | 4269 |
| 4286 TEST_F(LayerTreeHostCommonTest, HitTestingForUninvertibleTransform) { | 4270 TEST_F(LayerTreeHostCommonTest, HitTestingForUninvertibleTransform) { |
| 4287 FakeImplProxy proxy; | 4271 FakeImplProxy proxy; |
| 4288 TestSharedBitmapManager shared_bitmap_manager; | 4272 TestSharedBitmapManager shared_bitmap_manager; |
| 4289 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); | 4273 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); |
| 4290 scoped_ptr<LayerImpl> root = | 4274 scoped_ptr<LayerImpl> root = |
| 4291 LayerImpl::Create(host_impl.active_tree(), 12345); | 4275 LayerImpl::Create(host_impl.active_tree(), 12345); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 4318 | 4302 |
| 4319 // Sanity check the scenario we just created. | 4303 // Sanity check the scenario we just created. |
| 4320 ASSERT_EQ(1u, render_surface_layer_list.size()); | 4304 ASSERT_EQ(1u, render_surface_layer_list.size()); |
| 4321 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); | 4305 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); |
| 4322 ASSERT_FALSE(root->screen_space_transform().IsInvertible()); | 4306 ASSERT_FALSE(root->screen_space_transform().IsInvertible()); |
| 4323 | 4307 |
| 4324 // Hit testing any point should not hit the layer. If the invertible matrix is | 4308 // Hit testing any point should not hit the layer. If the invertible matrix is |
| 4325 // accidentally ignored and treated like an identity, then the hit testing | 4309 // accidentally ignored and treated like an identity, then the hit testing |
| 4326 // will incorrectly hit the layer when it shouldn't. | 4310 // will incorrectly hit the layer when it shouldn't. |
| 4327 gfx::Point test_point(1, 1); | 4311 gfx::Point test_point(1, 1); |
| 4328 LayerImpl* result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | 4312 LayerImpl* result_layer = |
| 4329 test_point, render_surface_layer_list); | 4313 LayerTreeHostCommon::FindLayerThatIsHitByPoint(test_point, root.get()); |
| 4330 EXPECT_FALSE(result_layer); | 4314 EXPECT_FALSE(result_layer); |
| 4331 | 4315 |
| 4332 test_point = gfx::Point(10, 10); | 4316 test_point = gfx::Point(10, 10); |
| 4333 result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | 4317 result_layer = |
| 4334 test_point, render_surface_layer_list); | 4318 LayerTreeHostCommon::FindLayerThatIsHitByPoint(test_point, root.get()); |
| 4335 EXPECT_FALSE(result_layer); | 4319 EXPECT_FALSE(result_layer); |
| 4336 | 4320 |
| 4337 test_point = gfx::Point(10, 30); | 4321 test_point = gfx::Point(10, 30); |
| 4338 result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | 4322 result_layer = |
| 4339 test_point, render_surface_layer_list); | 4323 LayerTreeHostCommon::FindLayerThatIsHitByPoint(test_point, root.get()); |
| 4340 EXPECT_FALSE(result_layer); | 4324 EXPECT_FALSE(result_layer); |
| 4341 | 4325 |
| 4342 test_point = gfx::Point(50, 50); | 4326 test_point = gfx::Point(50, 50); |
| 4343 result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | 4327 result_layer = |
| 4344 test_point, render_surface_layer_list); | 4328 LayerTreeHostCommon::FindLayerThatIsHitByPoint(test_point, root.get()); |
| 4345 EXPECT_FALSE(result_layer); | 4329 EXPECT_FALSE(result_layer); |
| 4346 | 4330 |
| 4347 test_point = gfx::Point(67, 48); | 4331 test_point = gfx::Point(67, 48); |
| 4348 result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | 4332 result_layer = |
| 4349 test_point, render_surface_layer_list); | 4333 LayerTreeHostCommon::FindLayerThatIsHitByPoint(test_point, root.get()); |
| 4350 EXPECT_FALSE(result_layer); | 4334 EXPECT_FALSE(result_layer); |
| 4351 | 4335 |
| 4352 test_point = gfx::Point(99, 99); | 4336 test_point = gfx::Point(99, 99); |
| 4353 result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | 4337 result_layer = |
| 4354 test_point, render_surface_layer_list); | 4338 LayerTreeHostCommon::FindLayerThatIsHitByPoint(test_point, root.get()); |
| 4355 EXPECT_FALSE(result_layer); | 4339 EXPECT_FALSE(result_layer); |
| 4356 | 4340 |
| 4357 test_point = gfx::Point(-1, -1); | 4341 test_point = gfx::Point(-1, -1); |
| 4358 result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | 4342 result_layer = |
| 4359 test_point, render_surface_layer_list); | 4343 LayerTreeHostCommon::FindLayerThatIsHitByPoint(test_point, root.get()); |
| 4360 EXPECT_FALSE(result_layer); | 4344 EXPECT_FALSE(result_layer); |
| 4361 } | 4345 } |
| 4362 | 4346 |
| 4363 TEST_F(LayerTreeHostCommonTest, HitTestingForSinglePositionedLayer) { | 4347 TEST_F(LayerTreeHostCommonTest, HitTestingForSinglePositionedLayer) { |
| 4364 FakeImplProxy proxy; | 4348 FakeImplProxy proxy; |
| 4365 TestSharedBitmapManager shared_bitmap_manager; | 4349 TestSharedBitmapManager shared_bitmap_manager; |
| 4366 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); | 4350 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); |
| 4367 scoped_ptr<LayerImpl> root = | 4351 scoped_ptr<LayerImpl> root = |
| 4368 LayerImpl::Create(host_impl.active_tree(), 12345); | 4352 LayerImpl::Create(host_impl.active_tree(), 12345); |
| 4369 | 4353 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 4387 root.get(), root->bounds(), &render_surface_layer_list); | 4371 root.get(), root->bounds(), &render_surface_layer_list); |
| 4388 inputs.can_adjust_raster_scales = true; | 4372 inputs.can_adjust_raster_scales = true; |
| 4389 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 4373 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
| 4390 | 4374 |
| 4391 // Sanity check the scenario we just created. | 4375 // Sanity check the scenario we just created. |
| 4392 ASSERT_EQ(1u, render_surface_layer_list.size()); | 4376 ASSERT_EQ(1u, render_surface_layer_list.size()); |
| 4393 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); | 4377 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); |
| 4394 | 4378 |
| 4395 // Hit testing for a point outside the layer should return a null pointer. | 4379 // Hit testing for a point outside the layer should return a null pointer. |
| 4396 gfx::Point test_point(49, 49); | 4380 gfx::Point test_point(49, 49); |
| 4397 LayerImpl* result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | 4381 LayerImpl* result_layer = |
| 4398 test_point, render_surface_layer_list); | 4382 LayerTreeHostCommon::FindLayerThatIsHitByPoint(test_point, root.get()); |
| 4399 EXPECT_FALSE(result_layer); | 4383 EXPECT_FALSE(result_layer); |
| 4400 | 4384 |
| 4401 // Even though the layer exists at (101, 101), it should not be visible there | 4385 // Even though the layer exists at (101, 101), it should not be visible there |
| 4402 // since the root render surface would clamp it. | 4386 // since the root render surface would clamp it. |
| 4403 test_point = gfx::Point(101, 101); | 4387 test_point = gfx::Point(101, 101); |
| 4404 result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | 4388 result_layer = |
| 4405 test_point, render_surface_layer_list); | 4389 LayerTreeHostCommon::FindLayerThatIsHitByPoint(test_point, root.get()); |
| 4406 EXPECT_FALSE(result_layer); | 4390 EXPECT_FALSE(result_layer); |
| 4407 | 4391 |
| 4408 // Hit testing for a point inside should return the root layer. | 4392 // Hit testing for a point inside should return the root layer. |
| 4409 test_point = gfx::Point(51, 51); | 4393 test_point = gfx::Point(51, 51); |
| 4410 result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | 4394 result_layer = |
| 4411 test_point, render_surface_layer_list); | 4395 LayerTreeHostCommon::FindLayerThatIsHitByPoint(test_point, root.get()); |
| 4412 ASSERT_TRUE(result_layer); | 4396 ASSERT_TRUE(result_layer); |
| 4413 EXPECT_EQ(12345, result_layer->id()); | 4397 EXPECT_EQ(12345, result_layer->id()); |
| 4414 | 4398 |
| 4415 test_point = gfx::Point(99, 99); | 4399 test_point = gfx::Point(99, 99); |
| 4416 result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | 4400 result_layer = |
| 4417 test_point, render_surface_layer_list); | 4401 LayerTreeHostCommon::FindLayerThatIsHitByPoint(test_point, root.get()); |
| 4418 ASSERT_TRUE(result_layer); | 4402 ASSERT_TRUE(result_layer); |
| 4419 EXPECT_EQ(12345, result_layer->id()); | 4403 EXPECT_EQ(12345, result_layer->id()); |
| 4420 } | 4404 } |
| 4421 | 4405 |
| 4422 TEST_F(LayerTreeHostCommonTest, HitTestingForSingleRotatedLayer) { | 4406 TEST_F(LayerTreeHostCommonTest, HitTestingForSingleRotatedLayer) { |
| 4423 FakeImplProxy proxy; | 4407 FakeImplProxy proxy; |
| 4424 TestSharedBitmapManager shared_bitmap_manager; | 4408 TestSharedBitmapManager shared_bitmap_manager; |
| 4425 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); | 4409 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); |
| 4426 scoped_ptr<LayerImpl> root = | 4410 scoped_ptr<LayerImpl> root = |
| 4427 LayerImpl::Create(host_impl.active_tree(), 12345); | 4411 LayerImpl::Create(host_impl.active_tree(), 12345); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 4450 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 4434 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
| 4451 | 4435 |
| 4452 // Sanity check the scenario we just created. | 4436 // Sanity check the scenario we just created. |
| 4453 ASSERT_EQ(1u, render_surface_layer_list.size()); | 4437 ASSERT_EQ(1u, render_surface_layer_list.size()); |
| 4454 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); | 4438 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); |
| 4455 | 4439 |
| 4456 // Hit testing for points outside the layer. | 4440 // Hit testing for points outside the layer. |
| 4457 // These corners would have been inside the un-transformed layer, but they | 4441 // These corners would have been inside the un-transformed layer, but they |
| 4458 // should not hit the correctly transformed layer. | 4442 // should not hit the correctly transformed layer. |
| 4459 gfx::Point test_point(99, 99); | 4443 gfx::Point test_point(99, 99); |
| 4460 LayerImpl* result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | 4444 LayerImpl* result_layer = |
| 4461 test_point, render_surface_layer_list); | 4445 LayerTreeHostCommon::FindLayerThatIsHitByPoint(test_point, root.get()); |
| 4462 EXPECT_FALSE(result_layer); | 4446 EXPECT_FALSE(result_layer); |
| 4463 | 4447 |
| 4464 test_point = gfx::Point(1, 1); | 4448 test_point = gfx::Point(1, 1); |
| 4465 result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | 4449 result_layer = |
| 4466 test_point, render_surface_layer_list); | 4450 LayerTreeHostCommon::FindLayerThatIsHitByPoint(test_point, root.get()); |
| 4467 EXPECT_FALSE(result_layer); | 4451 EXPECT_FALSE(result_layer); |
| 4468 | 4452 |
| 4469 // Hit testing for a point inside should return the root layer. | 4453 // Hit testing for a point inside should return the root layer. |
| 4470 test_point = gfx::Point(1, 50); | 4454 test_point = gfx::Point(1, 50); |
| 4471 result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | 4455 result_layer = |
| 4472 test_point, render_surface_layer_list); | 4456 LayerTreeHostCommon::FindLayerThatIsHitByPoint(test_point, root.get()); |
| 4473 ASSERT_TRUE(result_layer); | 4457 ASSERT_TRUE(result_layer); |
| 4474 EXPECT_EQ(12345, result_layer->id()); | 4458 EXPECT_EQ(12345, result_layer->id()); |
| 4475 | 4459 |
| 4476 // Hit testing the corners that would overlap the unclipped layer, but are | 4460 // Hit testing the corners that would overlap the unclipped layer, but are |
| 4477 // outside the clipped region. | 4461 // outside the clipped region. |
| 4478 test_point = gfx::Point(50, -1); | 4462 test_point = gfx::Point(50, -1); |
| 4479 result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | 4463 result_layer = |
| 4480 test_point, render_surface_layer_list); | 4464 LayerTreeHostCommon::FindLayerThatIsHitByPoint(test_point, root.get()); |
| 4481 ASSERT_FALSE(result_layer); | 4465 ASSERT_FALSE(result_layer); |
| 4482 | 4466 |
| 4483 test_point = gfx::Point(-1, 50); | 4467 test_point = gfx::Point(-1, 50); |
| 4484 result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | 4468 result_layer = |
| 4485 test_point, render_surface_layer_list); | 4469 LayerTreeHostCommon::FindLayerThatIsHitByPoint(test_point, root.get()); |
| 4486 ASSERT_FALSE(result_layer); | 4470 ASSERT_FALSE(result_layer); |
| 4487 } | 4471 } |
| 4488 | 4472 |
| 4489 TEST_F(LayerTreeHostCommonTest, HitTestingForSinglePerspectiveLayer) { | 4473 TEST_F(LayerTreeHostCommonTest, HitTestingForSinglePerspectiveLayer) { |
| 4490 FakeImplProxy proxy; | 4474 FakeImplProxy proxy; |
| 4491 TestSharedBitmapManager shared_bitmap_manager; | 4475 TestSharedBitmapManager shared_bitmap_manager; |
| 4492 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); | 4476 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); |
| 4493 scoped_ptr<LayerImpl> root = | 4477 scoped_ptr<LayerImpl> root = |
| 4494 LayerImpl::Create(host_impl.active_tree(), 12345); | 4478 LayerImpl::Create(host_impl.active_tree(), 12345); |
| 4495 | 4479 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 4524 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 4508 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
| 4525 | 4509 |
| 4526 // Sanity check the scenario we just created. | 4510 // Sanity check the scenario we just created. |
| 4527 ASSERT_EQ(1u, render_surface_layer_list.size()); | 4511 ASSERT_EQ(1u, render_surface_layer_list.size()); |
| 4528 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); | 4512 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); |
| 4529 | 4513 |
| 4530 // Hit testing for points outside the layer. | 4514 // Hit testing for points outside the layer. |
| 4531 // These corners would have been inside the un-transformed layer, but they | 4515 // These corners would have been inside the un-transformed layer, but they |
| 4532 // should not hit the correctly transformed layer. | 4516 // should not hit the correctly transformed layer. |
| 4533 gfx::Point test_point(24, 24); | 4517 gfx::Point test_point(24, 24); |
| 4534 LayerImpl* result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | 4518 LayerImpl* result_layer = |
| 4535 test_point, render_surface_layer_list); | 4519 LayerTreeHostCommon::FindLayerThatIsHitByPoint(test_point, root.get()); |
| 4536 EXPECT_FALSE(result_layer); | 4520 EXPECT_FALSE(result_layer); |
| 4537 | 4521 |
| 4538 test_point = gfx::Point(76, 76); | 4522 test_point = gfx::Point(76, 76); |
| 4539 result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | 4523 result_layer = |
| 4540 test_point, render_surface_layer_list); | 4524 LayerTreeHostCommon::FindLayerThatIsHitByPoint(test_point, root.get()); |
| 4541 EXPECT_FALSE(result_layer); | 4525 EXPECT_FALSE(result_layer); |
| 4542 | 4526 |
| 4543 // Hit testing for a point inside should return the root layer. | 4527 // Hit testing for a point inside should return the root layer. |
| 4544 test_point = gfx::Point(26, 26); | 4528 test_point = gfx::Point(26, 26); |
| 4545 result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | 4529 result_layer = |
| 4546 test_point, render_surface_layer_list); | 4530 LayerTreeHostCommon::FindLayerThatIsHitByPoint(test_point, root.get()); |
| 4547 ASSERT_TRUE(result_layer); | 4531 ASSERT_TRUE(result_layer); |
| 4548 EXPECT_EQ(12345, result_layer->id()); | 4532 EXPECT_EQ(12345, result_layer->id()); |
| 4549 | 4533 |
| 4550 test_point = gfx::Point(74, 74); | 4534 test_point = gfx::Point(74, 74); |
| 4551 result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | 4535 result_layer = |
| 4552 test_point, render_surface_layer_list); | 4536 LayerTreeHostCommon::FindLayerThatIsHitByPoint(test_point, root.get()); |
| 4553 ASSERT_TRUE(result_layer); | 4537 ASSERT_TRUE(result_layer); |
| 4554 EXPECT_EQ(12345, result_layer->id()); | 4538 EXPECT_EQ(12345, result_layer->id()); |
| 4555 } | 4539 } |
| 4556 | 4540 |
| 4557 TEST_F(LayerTreeHostCommonTest, HitTestingForSingleLayerWithScaledContents) { | 4541 TEST_F(LayerTreeHostCommonTest, HitTestingForSingleLayerWithScaledContents) { |
| 4558 // A layer's visible content rect is actually in the layer's content space. | 4542 // A layer's visible content rect is actually in the layer's content space. |
| 4559 // The screen space transform converts from the layer's origin space to screen | 4543 // The screen space transform converts from the layer's origin space to screen |
| 4560 // space. This test makes sure that hit testing works correctly accounts for | 4544 // space. This test makes sure that hit testing works correctly accounts for |
| 4561 // the contents scale. A contents scale that is not 1 effectively forces a | 4545 // the contents scale. A contents scale that is not 1 effectively forces a |
| 4562 // non-identity transform between layer's content space and layer's origin | 4546 // non-identity transform between layer's content space and layer's origin |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4613 // its layout size is 50x50, positioned at 25x25. | 4597 // its layout size is 50x50, positioned at 25x25. |
| 4614 LayerImpl* test_layer = root->children()[0]; | 4598 LayerImpl* test_layer = root->children()[0]; |
| 4615 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), | 4599 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), |
| 4616 test_layer->visible_content_rect()); | 4600 test_layer->visible_content_rect()); |
| 4617 ASSERT_EQ(1u, render_surface_layer_list.size()); | 4601 ASSERT_EQ(1u, render_surface_layer_list.size()); |
| 4618 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); | 4602 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); |
| 4619 | 4603 |
| 4620 // Hit testing for a point outside the layer should return a null pointer (the | 4604 // Hit testing for a point outside the layer should return a null pointer (the |
| 4621 // root layer does not draw content, so it will not be hit tested either). | 4605 // root layer does not draw content, so it will not be hit tested either). |
| 4622 gfx::Point test_point(101, 101); | 4606 gfx::Point test_point(101, 101); |
| 4623 LayerImpl* result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | 4607 LayerImpl* result_layer = |
| 4624 test_point, render_surface_layer_list); | 4608 LayerTreeHostCommon::FindLayerThatIsHitByPoint(test_point, root.get()); |
| 4625 EXPECT_FALSE(result_layer); | 4609 EXPECT_FALSE(result_layer); |
| 4626 | 4610 |
| 4627 test_point = gfx::Point(24, 24); | 4611 test_point = gfx::Point(24, 24); |
| 4628 result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | 4612 result_layer = |
| 4629 test_point, render_surface_layer_list); | 4613 LayerTreeHostCommon::FindLayerThatIsHitByPoint(test_point, root.get()); |
| 4630 EXPECT_FALSE(result_layer); | 4614 EXPECT_FALSE(result_layer); |
| 4631 | 4615 |
| 4632 test_point = gfx::Point(76, 76); | 4616 test_point = gfx::Point(76, 76); |
| 4633 result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | 4617 result_layer = |
| 4634 test_point, render_surface_layer_list); | 4618 LayerTreeHostCommon::FindLayerThatIsHitByPoint(test_point, root.get()); |
| 4635 EXPECT_FALSE(result_layer); | 4619 EXPECT_FALSE(result_layer); |
| 4636 | 4620 |
| 4637 // Hit testing for a point inside should return the test layer. | 4621 // Hit testing for a point inside should return the test layer. |
| 4638 test_point = gfx::Point(26, 26); | 4622 test_point = gfx::Point(26, 26); |
| 4639 result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | 4623 result_layer = |
| 4640 test_point, render_surface_layer_list); | 4624 LayerTreeHostCommon::FindLayerThatIsHitByPoint(test_point, root.get()); |
| 4641 ASSERT_TRUE(result_layer); | 4625 ASSERT_TRUE(result_layer); |
| 4642 EXPECT_EQ(12345, result_layer->id()); | 4626 EXPECT_EQ(12345, result_layer->id()); |
| 4643 | 4627 |
| 4644 test_point = gfx::Point(74, 74); | 4628 test_point = gfx::Point(74, 74); |
| 4645 result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | 4629 result_layer = |
| 4646 test_point, render_surface_layer_list); | 4630 LayerTreeHostCommon::FindLayerThatIsHitByPoint(test_point, root.get()); |
| 4647 ASSERT_TRUE(result_layer); | 4631 ASSERT_TRUE(result_layer); |
| 4648 EXPECT_EQ(12345, result_layer->id()); | 4632 EXPECT_EQ(12345, result_layer->id()); |
| 4649 } | 4633 } |
| 4650 | 4634 |
| 4651 TEST_F(LayerTreeHostCommonTest, HitTestingForSimpleClippedLayer) { | 4635 TEST_F(LayerTreeHostCommonTest, HitTestingForSimpleClippedLayer) { |
| 4652 // Test that hit-testing will only work for the visible portion of a layer, | 4636 // Test that hit-testing will only work for the visible portion of a layer, |
| 4653 // and not the entire layer bounds. Here we just test the simple axis-aligned | 4637 // and not the entire layer bounds. Here we just test the simple axis-aligned |
| 4654 // case. | 4638 // case. |
| 4655 gfx::Transform identity_matrix; | 4639 gfx::Transform identity_matrix; |
| 4656 gfx::PointF anchor; | 4640 gfx::PointF anchor; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4706 | 4690 |
| 4707 // Sanity check the scenario we just created. | 4691 // Sanity check the scenario we just created. |
| 4708 ASSERT_EQ(1u, render_surface_layer_list.size()); | 4692 ASSERT_EQ(1u, render_surface_layer_list.size()); |
| 4709 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); | 4693 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); |
| 4710 ASSERT_EQ(456, root->render_surface()->layer_list().at(0)->id()); | 4694 ASSERT_EQ(456, root->render_surface()->layer_list().at(0)->id()); |
| 4711 | 4695 |
| 4712 // Hit testing for a point outside the layer should return a null pointer. | 4696 // Hit testing for a point outside the layer should return a null pointer. |
| 4713 // Despite the child layer being very large, it should be clipped to the root | 4697 // Despite the child layer being very large, it should be clipped to the root |
| 4714 // layer's bounds. | 4698 // layer's bounds. |
| 4715 gfx::Point test_point(24, 24); | 4699 gfx::Point test_point(24, 24); |
| 4716 LayerImpl* result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | 4700 LayerImpl* result_layer = |
| 4717 test_point, render_surface_layer_list); | 4701 LayerTreeHostCommon::FindLayerThatIsHitByPoint(test_point, root.get()); |
| 4718 EXPECT_FALSE(result_layer); | 4702 EXPECT_FALSE(result_layer); |
| 4719 | 4703 |
| 4720 // Even though the layer exists at (101, 101), it should not be visible there | 4704 // Even though the layer exists at (101, 101), it should not be visible there |
| 4721 // since the clipping_layer would clamp it. | 4705 // since the clipping_layer would clamp it. |
| 4722 test_point = gfx::Point(76, 76); | 4706 test_point = gfx::Point(76, 76); |
| 4723 result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | 4707 result_layer = |
| 4724 test_point, render_surface_layer_list); | 4708 LayerTreeHostCommon::FindLayerThatIsHitByPoint(test_point, root.get()); |
| 4725 EXPECT_FALSE(result_layer); | 4709 EXPECT_FALSE(result_layer); |
| 4726 | 4710 |
| 4727 // Hit testing for a point inside should return the child layer. | 4711 // Hit testing for a point inside should return the child layer. |
| 4728 test_point = gfx::Point(26, 26); | 4712 test_point = gfx::Point(26, 26); |
| 4729 result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | 4713 result_layer = |
| 4730 test_point, render_surface_layer_list); | 4714 LayerTreeHostCommon::FindLayerThatIsHitByPoint(test_point, root.get()); |
| 4731 ASSERT_TRUE(result_layer); | 4715 ASSERT_TRUE(result_layer); |
| 4732 EXPECT_EQ(456, result_layer->id()); | 4716 EXPECT_EQ(456, result_layer->id()); |
| 4733 | 4717 |
| 4734 test_point = gfx::Point(74, 74); | 4718 test_point = gfx::Point(74, 74); |
| 4735 result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | 4719 result_layer = |
| 4736 test_point, render_surface_layer_list); | 4720 LayerTreeHostCommon::FindLayerThatIsHitByPoint(test_point, root.get()); |
| 4737 ASSERT_TRUE(result_layer); | 4721 ASSERT_TRUE(result_layer); |
| 4738 EXPECT_EQ(456, result_layer->id()); | 4722 EXPECT_EQ(456, result_layer->id()); |
| 4739 } | 4723 } |
| 4740 | 4724 |
| 4741 TEST_F(LayerTreeHostCommonTest, HitTestingForMultiClippedRotatedLayer) { | 4725 TEST_F(LayerTreeHostCommonTest, HitTestingForMultiClippedRotatedLayer) { |
| 4742 // This test checks whether hit testing correctly avoids hit testing with | 4726 // This test checks whether hit testing correctly avoids hit testing with |
| 4743 // multiple ancestors that clip in non axis-aligned ways. To pass this test, | 4727 // multiple ancestors that clip in non axis-aligned ways. To pass this test, |
| 4744 // the hit testing algorithm needs to recognize that multiple parent layers | 4728 // the hit testing algorithm needs to recognize that multiple parent layers |
| 4745 // may clip the layer, and should not actually hit those clipped areas. | 4729 // may clip the layer, and should not actually hit those clipped areas. |
| 4746 // | 4730 // |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4846 ASSERT_EQ( | 4830 ASSERT_EQ( |
| 4847 1u, | 4831 1u, |
| 4848 render_surface_layer_list.at(1)->render_surface()->layer_list().size()); | 4832 render_surface_layer_list.at(1)->render_surface()->layer_list().size()); |
| 4849 ASSERT_EQ( | 4833 ASSERT_EQ( |
| 4850 2468, | 4834 2468, |
| 4851 render_surface_layer_list[1]->render_surface()->layer_list().at(0)->id()); | 4835 render_surface_layer_list[1]->render_surface()->layer_list().at(0)->id()); |
| 4852 | 4836 |
| 4853 // (11, 89) is close to the the bottom left corner within the clip, but it is | 4837 // (11, 89) is close to the the bottom left corner within the clip, but it is |
| 4854 // not inside the layer. | 4838 // not inside the layer. |
| 4855 gfx::Point test_point(11, 89); | 4839 gfx::Point test_point(11, 89); |
| 4856 LayerImpl* result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | 4840 LayerImpl* result_layer = |
| 4857 test_point, render_surface_layer_list); | 4841 LayerTreeHostCommon::FindLayerThatIsHitByPoint(test_point, root.get()); |
| 4858 EXPECT_FALSE(result_layer); | 4842 EXPECT_FALSE(result_layer); |
| 4859 | 4843 |
| 4860 // Closer inwards from the bottom left will overlap the layer. | 4844 // Closer inwards from the bottom left will overlap the layer. |
| 4861 test_point = gfx::Point(25, 75); | 4845 test_point = gfx::Point(25, 75); |
| 4862 result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | 4846 result_layer = |
| 4863 test_point, render_surface_layer_list); | 4847 LayerTreeHostCommon::FindLayerThatIsHitByPoint(test_point, root.get()); |
| 4864 ASSERT_TRUE(result_layer); | 4848 ASSERT_TRUE(result_layer); |
| 4865 EXPECT_EQ(2468, result_layer->id()); | 4849 EXPECT_EQ(2468, result_layer->id()); |
| 4866 | 4850 |
| 4867 // (4, 50) is inside the unclipped layer, but that corner of the layer should | 4851 // (4, 50) is inside the unclipped layer, but that corner of the layer should |
| 4868 // be clipped away by the grandparent and should not get hit. If hit testing | 4852 // be clipped away by the grandparent and should not get hit. If hit testing |
| 4869 // blindly uses visible content rect without considering how parent may clip | 4853 // blindly uses visible content rect without considering how parent may clip |
| 4870 // the layer, then hit testing would accidentally think that the point | 4854 // the layer, then hit testing would accidentally think that the point |
| 4871 // successfully hits the layer. | 4855 // successfully hits the layer. |
| 4872 test_point = gfx::Point(4, 50); | 4856 test_point = gfx::Point(4, 50); |
| 4873 result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | 4857 result_layer = |
| 4874 test_point, render_surface_layer_list); | 4858 LayerTreeHostCommon::FindLayerThatIsHitByPoint(test_point, root.get()); |
| 4875 EXPECT_FALSE(result_layer); | 4859 EXPECT_FALSE(result_layer); |
| 4876 | 4860 |
| 4877 // (11, 50) is inside the layer and within the clipped area. | 4861 // (11, 50) is inside the layer and within the clipped area. |
| 4878 test_point = gfx::Point(11, 50); | 4862 test_point = gfx::Point(11, 50); |
| 4879 result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | 4863 result_layer = |
| 4880 test_point, render_surface_layer_list); | 4864 LayerTreeHostCommon::FindLayerThatIsHitByPoint(test_point, root.get()); |
| 4881 ASSERT_TRUE(result_layer); | 4865 ASSERT_TRUE(result_layer); |
| 4882 EXPECT_EQ(2468, result_layer->id()); | 4866 EXPECT_EQ(2468, result_layer->id()); |
| 4883 | 4867 |
| 4884 // Around the middle, just to the right and up, would have hit the layer | 4868 // Around the middle, just to the right and up, would have hit the layer |
| 4885 // except that that area should be clipped away by the parent. | 4869 // except that that area should be clipped away by the parent. |
| 4886 test_point = gfx::Point(51, 49); | 4870 test_point = gfx::Point(51, 49); |
| 4887 result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | 4871 result_layer = |
| 4888 test_point, render_surface_layer_list); | 4872 LayerTreeHostCommon::FindLayerThatIsHitByPoint(test_point, root.get()); |
| 4889 EXPECT_FALSE(result_layer); | 4873 EXPECT_FALSE(result_layer); |
| 4890 | 4874 |
| 4891 // Around the middle, just to the left and down, should successfully hit the | 4875 // Around the middle, just to the left and down, should successfully hit the |
| 4892 // layer. | 4876 // layer. |
| 4893 test_point = gfx::Point(49, 51); | 4877 test_point = gfx::Point(49, 51); |
| 4894 result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | 4878 result_layer = |
| 4895 test_point, render_surface_layer_list); | 4879 LayerTreeHostCommon::FindLayerThatIsHitByPoint(test_point, root.get()); |
| 4896 ASSERT_TRUE(result_layer); | 4880 ASSERT_TRUE(result_layer); |
| 4897 EXPECT_EQ(2468, result_layer->id()); | 4881 EXPECT_EQ(2468, result_layer->id()); |
| 4898 } | 4882 } |
| 4899 | 4883 |
| 4900 TEST_F(LayerTreeHostCommonTest, HitTestingForNonClippingIntermediateLayer) { | 4884 TEST_F(LayerTreeHostCommonTest, HitTestingForNonClippingIntermediateLayer) { |
| 4901 // This test checks that hit testing code does not accidentally clip to layer | 4885 // This test checks that hit testing code does not accidentally clip to layer |
| 4902 // bounds for a layer that actually does not clip. | 4886 // bounds for a layer that actually does not clip. |
| 4903 gfx::Transform identity_matrix; | 4887 gfx::Transform identity_matrix; |
| 4904 gfx::PointF anchor; | 4888 gfx::PointF anchor; |
| 4905 | 4889 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4957 inputs.can_adjust_raster_scales = true; | 4941 inputs.can_adjust_raster_scales = true; |
| 4958 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 4942 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
| 4959 | 4943 |
| 4960 // Sanity check the scenario we just created. | 4944 // Sanity check the scenario we just created. |
| 4961 ASSERT_EQ(1u, render_surface_layer_list.size()); | 4945 ASSERT_EQ(1u, render_surface_layer_list.size()); |
| 4962 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); | 4946 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); |
| 4963 ASSERT_EQ(456, root->render_surface()->layer_list().at(0)->id()); | 4947 ASSERT_EQ(456, root->render_surface()->layer_list().at(0)->id()); |
| 4964 | 4948 |
| 4965 // Hit testing for a point outside the layer should return a null pointer. | 4949 // Hit testing for a point outside the layer should return a null pointer. |
| 4966 gfx::Point test_point(69, 69); | 4950 gfx::Point test_point(69, 69); |
| 4967 LayerImpl* result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | 4951 LayerImpl* result_layer = |
| 4968 test_point, render_surface_layer_list); | 4952 LayerTreeHostCommon::FindLayerThatIsHitByPoint(test_point, root.get()); |
| 4969 EXPECT_FALSE(result_layer); | 4953 EXPECT_FALSE(result_layer); |
| 4970 | 4954 |
| 4971 test_point = gfx::Point(91, 91); | 4955 test_point = gfx::Point(91, 91); |
| 4972 result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | 4956 result_layer = |
| 4973 test_point, render_surface_layer_list); | 4957 LayerTreeHostCommon::FindLayerThatIsHitByPoint(test_point, root.get()); |
| 4974 EXPECT_FALSE(result_layer); | 4958 EXPECT_FALSE(result_layer); |
| 4975 | 4959 |
| 4976 // Hit testing for a point inside should return the child layer. | 4960 // Hit testing for a point inside should return the child layer. |
| 4977 test_point = gfx::Point(71, 71); | 4961 test_point = gfx::Point(71, 71); |
| 4978 result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | 4962 result_layer = |
| 4979 test_point, render_surface_layer_list); | 4963 LayerTreeHostCommon::FindLayerThatIsHitByPoint(test_point, root.get()); |
| 4980 ASSERT_TRUE(result_layer); | 4964 ASSERT_TRUE(result_layer); |
| 4981 EXPECT_EQ(456, result_layer->id()); | 4965 EXPECT_EQ(456, result_layer->id()); |
| 4982 | 4966 |
| 4983 test_point = gfx::Point(89, 89); | 4967 test_point = gfx::Point(89, 89); |
| 4984 result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | 4968 result_layer = |
| 4985 test_point, render_surface_layer_list); | 4969 LayerTreeHostCommon::FindLayerThatIsHitByPoint(test_point, root.get()); |
| 4986 ASSERT_TRUE(result_layer); | 4970 ASSERT_TRUE(result_layer); |
| 4987 EXPECT_EQ(456, result_layer->id()); | 4971 EXPECT_EQ(456, result_layer->id()); |
| 4988 } | 4972 } |
| 4989 | 4973 |
| 4990 TEST_F(LayerTreeHostCommonTest, HitTestingForMultipleLayers) { | 4974 TEST_F(LayerTreeHostCommonTest, HitTestingForMultipleLayers) { |
| 4991 FakeImplProxy proxy; | 4975 FakeImplProxy proxy; |
| 4992 TestSharedBitmapManager shared_bitmap_manager; | 4976 TestSharedBitmapManager shared_bitmap_manager; |
| 4993 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); | 4977 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); |
| 4994 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl.active_tree(), 1); | 4978 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl.active_tree(), 1); |
| 4995 | 4979 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5079 RenderSurfaceImpl* root_render_surface = root->render_surface(); | 5063 RenderSurfaceImpl* root_render_surface = root->render_surface(); |
| 5080 ASSERT_EQ(4u, root_render_surface->layer_list().size()); | 5064 ASSERT_EQ(4u, root_render_surface->layer_list().size()); |
| 5081 ASSERT_EQ(1, root_render_surface->layer_list().at(0)->id()); // root layer | 5065 ASSERT_EQ(1, root_render_surface->layer_list().at(0)->id()); // root layer |
| 5082 ASSERT_EQ(2, root_render_surface->layer_list().at(1)->id()); // child1 | 5066 ASSERT_EQ(2, root_render_surface->layer_list().at(1)->id()); // child1 |
| 5083 ASSERT_EQ(4, root_render_surface->layer_list().at(2)->id()); // grand_child1 | 5067 ASSERT_EQ(4, root_render_surface->layer_list().at(2)->id()); // grand_child1 |
| 5084 ASSERT_EQ(3, root_render_surface->layer_list().at(3)->id()); // child2 | 5068 ASSERT_EQ(3, root_render_surface->layer_list().at(3)->id()); // child2 |
| 5085 | 5069 |
| 5086 // Nothing overlaps the root_layer at (1, 1), so hit testing there should find | 5070 // Nothing overlaps the root_layer at (1, 1), so hit testing there should find |
| 5087 // the root layer. | 5071 // the root layer. |
| 5088 gfx::Point test_point = gfx::Point(1, 1); | 5072 gfx::Point test_point = gfx::Point(1, 1); |
| 5089 LayerImpl* result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | 5073 LayerImpl* result_layer = |
| 5090 test_point, render_surface_layer_list); | 5074 LayerTreeHostCommon::FindLayerThatIsHitByPoint(test_point, root.get()); |
| 5091 ASSERT_TRUE(result_layer); | 5075 ASSERT_TRUE(result_layer); |
| 5092 EXPECT_EQ(1, result_layer->id()); | 5076 EXPECT_EQ(1, result_layer->id()); |
| 5093 | 5077 |
| 5094 // At (15, 15), child1 and root are the only layers. child1 is expected to be | 5078 // At (15, 15), child1 and root are the only layers. child1 is expected to be |
| 5095 // on top. | 5079 // on top. |
| 5096 test_point = gfx::Point(15, 15); | 5080 test_point = gfx::Point(15, 15); |
| 5097 result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | 5081 result_layer = |
| 5098 test_point, render_surface_layer_list); | 5082 LayerTreeHostCommon::FindLayerThatIsHitByPoint(test_point, root.get()); |
| 5099 ASSERT_TRUE(result_layer); | 5083 ASSERT_TRUE(result_layer); |
| 5100 EXPECT_EQ(2, result_layer->id()); | 5084 EXPECT_EQ(2, result_layer->id()); |
| 5101 | 5085 |
| 5102 // At (51, 20), child1 and child2 overlap. child2 is expected to be on top. | 5086 // At (51, 20), child1 and child2 overlap. child2 is expected to be on top. |
| 5103 test_point = gfx::Point(51, 20); | 5087 test_point = gfx::Point(51, 20); |
| 5104 result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | 5088 result_layer = |
| 5105 test_point, render_surface_layer_list); | 5089 LayerTreeHostCommon::FindLayerThatIsHitByPoint(test_point, root.get()); |
| 5106 ASSERT_TRUE(result_layer); | 5090 ASSERT_TRUE(result_layer); |
| 5107 EXPECT_EQ(3, result_layer->id()); | 5091 EXPECT_EQ(3, result_layer->id()); |
| 5108 | 5092 |
| 5109 // At (80, 51), child2 and grand_child1 overlap. child2 is expected to be on | 5093 // At (80, 51), child2 and grand_child1 overlap. child2 is expected to be on |
| 5110 // top. | 5094 // top. |
| 5111 test_point = gfx::Point(80, 51); | 5095 test_point = gfx::Point(80, 51); |
| 5112 result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | 5096 result_layer = |
| 5113 test_point, render_surface_layer_list); | 5097 LayerTreeHostCommon::FindLayerThatIsHitByPoint(test_point, root.get()); |
| 5114 ASSERT_TRUE(result_layer); | 5098 ASSERT_TRUE(result_layer); |
| 5115 EXPECT_EQ(3, result_layer->id()); | 5099 EXPECT_EQ(3, result_layer->id()); |
| 5116 | 5100 |
| 5117 // At (51, 51), all layers overlap each other. child2 is expected to be on top | 5101 // At (51, 51), all layers overlap each other. child2 is expected to be on top |
| 5118 // of all other layers. | 5102 // of all other layers. |
| 5119 test_point = gfx::Point(51, 51); | 5103 test_point = gfx::Point(51, 51); |
| 5120 result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | 5104 result_layer = |
| 5121 test_point, render_surface_layer_list); | 5105 LayerTreeHostCommon::FindLayerThatIsHitByPoint(test_point, root.get()); |
| 5122 ASSERT_TRUE(result_layer); | 5106 ASSERT_TRUE(result_layer); |
| 5123 EXPECT_EQ(3, result_layer->id()); | 5107 EXPECT_EQ(3, result_layer->id()); |
| 5124 | 5108 |
| 5125 // At (20, 51), child1 and grand_child1 overlap. grand_child1 is expected to | 5109 // At (20, 51), child1 and grand_child1 overlap. grand_child1 is expected to |
| 5126 // be on top. | 5110 // be on top. |
| 5127 test_point = gfx::Point(20, 51); | 5111 test_point = gfx::Point(20, 51); |
| 5128 result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | 5112 result_layer = |
| 5129 test_point, render_surface_layer_list); | 5113 LayerTreeHostCommon::FindLayerThatIsHitByPoint(test_point, root.get()); |
| 5130 ASSERT_TRUE(result_layer); | 5114 ASSERT_TRUE(result_layer); |
| 5131 EXPECT_EQ(4, result_layer->id()); | 5115 EXPECT_EQ(4, result_layer->id()); |
| 5132 } | 5116 } |
| 5133 | 5117 |
| 5134 TEST_F(LayerTreeHostCommonTest, HitTestingForMultipleLayerLists) { | 5118 TEST_F(LayerTreeHostCommonTest, HitTestingForMultipleLayerLists) { |
| 5135 // | 5119 // |
| 5136 // The geometry is set up similarly to the previous case, but | 5120 // The geometry is set up similarly to the previous case, but |
| 5137 // all layers are forced to be render surfaces now. | 5121 // all layers are forced to be render surfaces now. |
| 5138 // | 5122 // |
| 5139 FakeImplProxy proxy; | 5123 FakeImplProxy proxy; |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5237 ASSERT_EQ(1u, child2->render_surface()->layer_list().size()); | 5221 ASSERT_EQ(1u, child2->render_surface()->layer_list().size()); |
| 5238 ASSERT_EQ(1u, grand_child1->render_surface()->layer_list().size()); | 5222 ASSERT_EQ(1u, grand_child1->render_surface()->layer_list().size()); |
| 5239 ASSERT_EQ(1, render_surface_layer_list.at(0)->id()); // root layer | 5223 ASSERT_EQ(1, render_surface_layer_list.at(0)->id()); // root layer |
| 5240 ASSERT_EQ(2, render_surface_layer_list[1]->id()); // child1 | 5224 ASSERT_EQ(2, render_surface_layer_list[1]->id()); // child1 |
| 5241 ASSERT_EQ(4, render_surface_layer_list.at(2)->id()); // grand_child1 | 5225 ASSERT_EQ(4, render_surface_layer_list.at(2)->id()); // grand_child1 |
| 5242 ASSERT_EQ(3, render_surface_layer_list[3]->id()); // child2 | 5226 ASSERT_EQ(3, render_surface_layer_list[3]->id()); // child2 |
| 5243 | 5227 |
| 5244 // Nothing overlaps the root_layer at (1, 1), so hit testing there should find | 5228 // Nothing overlaps the root_layer at (1, 1), so hit testing there should find |
| 5245 // the root layer. | 5229 // the root layer. |
| 5246 gfx::Point test_point = gfx::Point(1, 1); | 5230 gfx::Point test_point = gfx::Point(1, 1); |
| 5247 LayerImpl* result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | 5231 LayerImpl* result_layer = |
| 5248 test_point, render_surface_layer_list); | 5232 LayerTreeHostCommon::FindLayerThatIsHitByPoint(test_point, root.get()); |
| 5249 ASSERT_TRUE(result_layer); | 5233 ASSERT_TRUE(result_layer); |
| 5250 EXPECT_EQ(1, result_layer->id()); | 5234 EXPECT_EQ(1, result_layer->id()); |
| 5251 | 5235 |
| 5252 // At (15, 15), child1 and root are the only layers. child1 is expected to be | 5236 // At (15, 15), child1 and root are the only layers. child1 is expected to be |
| 5253 // on top. | 5237 // on top. |
| 5254 test_point = gfx::Point(15, 15); | 5238 test_point = gfx::Point(15, 15); |
| 5255 result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | 5239 result_layer = |
| 5256 test_point, render_surface_layer_list); | 5240 LayerTreeHostCommon::FindLayerThatIsHitByPoint(test_point, root.get()); |
| 5257 ASSERT_TRUE(result_layer); | 5241 ASSERT_TRUE(result_layer); |
| 5258 EXPECT_EQ(2, result_layer->id()); | 5242 EXPECT_EQ(2, result_layer->id()); |
| 5259 | 5243 |
| 5260 // At (51, 20), child1 and child2 overlap. child2 is expected to be on top. | 5244 // At (51, 20), child1 and child2 overlap. child2 is expected to be on top. |
| 5261 test_point = gfx::Point(51, 20); | 5245 test_point = gfx::Point(51, 20); |
| 5262 result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | 5246 result_layer = |
| 5263 test_point, render_surface_layer_list); | 5247 LayerTreeHostCommon::FindLayerThatIsHitByPoint(test_point, root.get()); |
| 5264 ASSERT_TRUE(result_layer); | 5248 ASSERT_TRUE(result_layer); |
| 5265 EXPECT_EQ(3, result_layer->id()); | 5249 EXPECT_EQ(3, result_layer->id()); |
| 5266 | 5250 |
| 5267 // At (80, 51), child2 and grand_child1 overlap. child2 is expected to be on | 5251 // At (80, 51), child2 and grand_child1 overlap. child2 is expected to be on |
| 5268 // top. | 5252 // top. |
| 5269 test_point = gfx::Point(80, 51); | 5253 test_point = gfx::Point(80, 51); |
| 5270 result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | 5254 result_layer = |
| 5271 test_point, render_surface_layer_list); | 5255 LayerTreeHostCommon::FindLayerThatIsHitByPoint(test_point, root.get()); |
| 5272 ASSERT_TRUE(result_layer); | 5256 ASSERT_TRUE(result_layer); |
| 5273 EXPECT_EQ(3, result_layer->id()); | 5257 EXPECT_EQ(3, result_layer->id()); |
| 5274 | 5258 |
| 5275 // At (51, 51), all layers overlap each other. child2 is expected to be on top | 5259 // At (51, 51), all layers overlap each other. child2 is expected to be on top |
| 5276 // of all other layers. | 5260 // of all other layers. |
| 5277 test_point = gfx::Point(51, 51); | 5261 test_point = gfx::Point(51, 51); |
| 5278 result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | 5262 result_layer = |
| 5279 test_point, render_surface_layer_list); | 5263 LayerTreeHostCommon::FindLayerThatIsHitByPoint(test_point, root.get()); |
| 5280 ASSERT_TRUE(result_layer); | 5264 ASSERT_TRUE(result_layer); |
| 5281 EXPECT_EQ(3, result_layer->id()); | 5265 EXPECT_EQ(3, result_layer->id()); |
| 5282 | 5266 |
| 5283 // At (20, 51), child1 and grand_child1 overlap. grand_child1 is expected to | 5267 // At (20, 51), child1 and grand_child1 overlap. grand_child1 is expected to |
| 5284 // be on top. | 5268 // be on top. |
| 5285 test_point = gfx::Point(20, 51); | 5269 test_point = gfx::Point(20, 51); |
| 5286 result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | 5270 result_layer = |
| 5287 test_point, render_surface_layer_list); | 5271 LayerTreeHostCommon::FindLayerThatIsHitByPoint(test_point, root.get()); |
| 5288 ASSERT_TRUE(result_layer); | 5272 ASSERT_TRUE(result_layer); |
| 5289 EXPECT_EQ(4, result_layer->id()); | 5273 EXPECT_EQ(4, result_layer->id()); |
| 5290 } | 5274 } |
| 5291 | 5275 |
| 5292 TEST_F(LayerTreeHostCommonTest, HitTestingForEmptyLayers) { | 5276 TEST_F(LayerTreeHostCommonTest, HitTestingForEmptyLayers) { |
| 5293 FakeImplProxy proxy; | 5277 FakeImplProxy proxy; |
| 5294 TestSharedBitmapManager shared_bitmap_manager; | 5278 TestSharedBitmapManager shared_bitmap_manager; |
| 5295 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); | 5279 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); |
| 5296 | 5280 |
| 5297 // Layer 1 - root | 5281 // Layer 1 - root |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5378 ASSERT_EQ(1u, render_surface_layer_list.size()); | 5362 ASSERT_EQ(1u, render_surface_layer_list.size()); |
| 5379 EXPECT_EQ(1, render_surface_layer_list[0]->id()); | 5363 EXPECT_EQ(1, render_surface_layer_list[0]->id()); |
| 5380 ASSERT_EQ(3u, root->render_surface()->layer_list().size()); | 5364 ASSERT_EQ(3u, root->render_surface()->layer_list().size()); |
| 5381 EXPECT_EQ(1, root->render_surface()->layer_list().at(0)->id()); | 5365 EXPECT_EQ(1, root->render_surface()->layer_list().at(0)->id()); |
| 5382 EXPECT_EQ(3, root->render_surface()->layer_list().at(1)->id()); | 5366 EXPECT_EQ(3, root->render_surface()->layer_list().at(1)->id()); |
| 5383 EXPECT_EQ(4, root->render_surface()->layer_list().at(2)->id()); | 5367 EXPECT_EQ(4, root->render_surface()->layer_list().at(2)->id()); |
| 5384 | 5368 |
| 5385 // Hit testing for a point inside the empty no-handlers layer should return | 5369 // Hit testing for a point inside the empty no-handlers layer should return |
| 5386 // the root layer. | 5370 // the root layer. |
| 5387 gfx::Point test_point = gfx::Point(15, 15); | 5371 gfx::Point test_point = gfx::Point(15, 15); |
| 5388 LayerImpl* result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | 5372 LayerImpl* result_layer = |
| 5389 test_point, render_surface_layer_list); | 5373 LayerTreeHostCommon::FindLayerThatIsHitByPoint(test_point, root.get()); |
| 5390 ASSERT_TRUE(result_layer); | 5374 ASSERT_TRUE(result_layer); |
| 5391 EXPECT_EQ(1, result_layer->id()); | 5375 EXPECT_EQ(1, result_layer->id()); |
| 5392 | 5376 |
| 5393 // Hit testing for a point inside the touch handler layer should return it. | 5377 // Hit testing for a point inside the touch handler layer should return it. |
| 5394 test_point = gfx::Point(15, 75); | 5378 test_point = gfx::Point(15, 75); |
| 5395 result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | 5379 result_layer = |
| 5396 test_point, render_surface_layer_list); | 5380 LayerTreeHostCommon::FindLayerThatIsHitByPoint(test_point, root.get()); |
| 5397 ASSERT_TRUE(result_layer); | 5381 ASSERT_TRUE(result_layer); |
| 5398 EXPECT_EQ(3, result_layer->id()); | 5382 EXPECT_EQ(3, result_layer->id()); |
| 5399 | 5383 |
| 5400 // Hit testing for a point inside the mousewheel layer should return it. | 5384 // Hit testing for a point inside the mousewheel layer should return it. |
| 5401 test_point = gfx::Point(75, 75); | 5385 test_point = gfx::Point(75, 75); |
| 5402 result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | 5386 result_layer = |
| 5403 test_point, render_surface_layer_list); | 5387 LayerTreeHostCommon::FindLayerThatIsHitByPoint(test_point, root.get()); |
| 5404 ASSERT_TRUE(result_layer); | 5388 ASSERT_TRUE(result_layer); |
| 5405 EXPECT_EQ(4, result_layer->id()); | 5389 EXPECT_EQ(4, result_layer->id()); |
| 5406 } | 5390 } |
| 5407 | 5391 |
| 5408 TEST_F(LayerTreeHostCommonTest, | |
| 5409 HitCheckingTouchHandlerRegionsForEmptyLayerList) { | |
| 5410 // Hit checking on an empty render_surface_layer_list should return a null | |
| 5411 // pointer. | |
| 5412 LayerImplList render_surface_layer_list; | |
| 5413 | |
| 5414 gfx::Point test_point(0, 0); | |
| 5415 LayerImpl* result_layer = | |
| 5416 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( | |
| 5417 test_point, render_surface_layer_list); | |
| 5418 EXPECT_FALSE(result_layer); | |
| 5419 | |
| 5420 test_point = gfx::Point(10, 20); | |
| 5421 result_layer = | |
| 5422 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( | |
| 5423 test_point, render_surface_layer_list); | |
| 5424 EXPECT_FALSE(result_layer); | |
| 5425 } | |
| 5426 | |
| 5427 TEST_F(LayerTreeHostCommonTest, HitCheckingTouchHandlerRegionsForSingleLayer) { | 5392 TEST_F(LayerTreeHostCommonTest, HitCheckingTouchHandlerRegionsForSingleLayer) { |
| 5428 FakeImplProxy proxy; | 5393 FakeImplProxy proxy; |
| 5429 TestSharedBitmapManager shared_bitmap_manager; | 5394 TestSharedBitmapManager shared_bitmap_manager; |
| 5430 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); | 5395 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); |
| 5431 scoped_ptr<LayerImpl> root = | 5396 scoped_ptr<LayerImpl> root = |
| 5432 LayerImpl::Create(host_impl.active_tree(), 12345); | 5397 LayerImpl::Create(host_impl.active_tree(), 12345); |
| 5433 | 5398 |
| 5434 gfx::Transform identity_matrix; | 5399 gfx::Transform identity_matrix; |
| 5435 Region touch_handler_region(gfx::Rect(10, 10, 50, 50)); | 5400 Region touch_handler_region(gfx::Rect(10, 10, 50, 50)); |
| 5436 gfx::PointF anchor; | 5401 gfx::PointF anchor; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 5453 | 5418 |
| 5454 // Sanity check the scenario we just created. | 5419 // Sanity check the scenario we just created. |
| 5455 ASSERT_EQ(1u, render_surface_layer_list.size()); | 5420 ASSERT_EQ(1u, render_surface_layer_list.size()); |
| 5456 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); | 5421 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); |
| 5457 | 5422 |
| 5458 // Hit checking for any point should return a null pointer for a layer without | 5423 // Hit checking for any point should return a null pointer for a layer without |
| 5459 // any touch event handler regions. | 5424 // any touch event handler regions. |
| 5460 gfx::Point test_point(11, 11); | 5425 gfx::Point test_point(11, 11); |
| 5461 LayerImpl* result_layer = | 5426 LayerImpl* result_layer = |
| 5462 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( | 5427 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( |
| 5463 test_point, render_surface_layer_list); | 5428 test_point, root.get()); |
| 5464 EXPECT_FALSE(result_layer); | 5429 EXPECT_FALSE(result_layer); |
| 5465 | 5430 |
| 5466 root->SetTouchEventHandlerRegion(touch_handler_region); | 5431 root->SetTouchEventHandlerRegion(touch_handler_region); |
| 5467 // Hit checking for a point outside the layer should return a null pointer. | 5432 // Hit checking for a point outside the layer should return a null pointer. |
| 5468 test_point = gfx::Point(101, 101); | 5433 test_point = gfx::Point(101, 101); |
| 5469 result_layer = | 5434 result_layer = |
| 5470 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( | 5435 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( |
| 5471 test_point, render_surface_layer_list); | 5436 test_point, root.get()); |
| 5472 EXPECT_FALSE(result_layer); | 5437 EXPECT_FALSE(result_layer); |
| 5473 | 5438 |
| 5474 test_point = gfx::Point(-1, -1); | 5439 test_point = gfx::Point(-1, -1); |
| 5475 result_layer = | 5440 result_layer = |
| 5476 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( | 5441 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( |
| 5477 test_point, render_surface_layer_list); | 5442 test_point, root.get()); |
| 5478 EXPECT_FALSE(result_layer); | 5443 EXPECT_FALSE(result_layer); |
| 5479 | 5444 |
| 5480 // Hit checking for a point inside the layer, but outside the touch handler | 5445 // Hit checking for a point inside the layer, but outside the touch handler |
| 5481 // region should return a null pointer. | 5446 // region should return a null pointer. |
| 5482 test_point = gfx::Point(1, 1); | 5447 test_point = gfx::Point(1, 1); |
| 5483 result_layer = | 5448 result_layer = |
| 5484 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( | 5449 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( |
| 5485 test_point, render_surface_layer_list); | 5450 test_point, root.get()); |
| 5486 EXPECT_FALSE(result_layer); | 5451 EXPECT_FALSE(result_layer); |
| 5487 | 5452 |
| 5488 test_point = gfx::Point(99, 99); | 5453 test_point = gfx::Point(99, 99); |
| 5489 result_layer = | 5454 result_layer = |
| 5490 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( | 5455 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( |
| 5491 test_point, render_surface_layer_list); | 5456 test_point, root.get()); |
| 5492 EXPECT_FALSE(result_layer); | 5457 EXPECT_FALSE(result_layer); |
| 5493 | 5458 |
| 5494 // Hit checking for a point inside the touch event handler region should | 5459 // Hit checking for a point inside the touch event handler region should |
| 5495 // return the root layer. | 5460 // return the root layer. |
| 5496 test_point = gfx::Point(11, 11); | 5461 test_point = gfx::Point(11, 11); |
| 5497 result_layer = | 5462 result_layer = |
| 5498 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( | 5463 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( |
| 5499 test_point, render_surface_layer_list); | 5464 test_point, root.get()); |
| 5500 ASSERT_TRUE(result_layer); | 5465 ASSERT_TRUE(result_layer); |
| 5501 EXPECT_EQ(12345, result_layer->id()); | 5466 EXPECT_EQ(12345, result_layer->id()); |
| 5502 | 5467 |
| 5503 test_point = gfx::Point(59, 59); | 5468 test_point = gfx::Point(59, 59); |
| 5504 result_layer = | 5469 result_layer = |
| 5505 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( | 5470 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( |
| 5506 test_point, render_surface_layer_list); | 5471 test_point, root.get()); |
| 5507 ASSERT_TRUE(result_layer); | 5472 ASSERT_TRUE(result_layer); |
| 5508 EXPECT_EQ(12345, result_layer->id()); | 5473 EXPECT_EQ(12345, result_layer->id()); |
| 5509 } | 5474 } |
| 5510 | 5475 |
| 5511 TEST_F(LayerTreeHostCommonTest, | 5476 TEST_F(LayerTreeHostCommonTest, |
| 5512 HitCheckingTouchHandlerRegionsForUninvertibleTransform) { | 5477 HitCheckingTouchHandlerRegionsForUninvertibleTransform) { |
| 5513 FakeImplProxy proxy; | 5478 FakeImplProxy proxy; |
| 5514 TestSharedBitmapManager shared_bitmap_manager; | 5479 TestSharedBitmapManager shared_bitmap_manager; |
| 5515 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); | 5480 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); |
| 5516 scoped_ptr<LayerImpl> root = | 5481 scoped_ptr<LayerImpl> root = |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5549 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); | 5514 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); |
| 5550 ASSERT_FALSE(root->screen_space_transform().IsInvertible()); | 5515 ASSERT_FALSE(root->screen_space_transform().IsInvertible()); |
| 5551 | 5516 |
| 5552 // Hit checking any point should not hit the touch handler region on the | 5517 // Hit checking any point should not hit the touch handler region on the |
| 5553 // layer. If the invertible matrix is accidentally ignored and treated like an | 5518 // layer. If the invertible matrix is accidentally ignored and treated like an |
| 5554 // identity, then the hit testing will incorrectly hit the layer when it | 5519 // identity, then the hit testing will incorrectly hit the layer when it |
| 5555 // shouldn't. | 5520 // shouldn't. |
| 5556 gfx::Point test_point(1, 1); | 5521 gfx::Point test_point(1, 1); |
| 5557 LayerImpl* result_layer = | 5522 LayerImpl* result_layer = |
| 5558 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( | 5523 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( |
| 5559 test_point, render_surface_layer_list); | 5524 test_point, root.get()); |
| 5560 EXPECT_FALSE(result_layer); | 5525 EXPECT_FALSE(result_layer); |
| 5561 | 5526 |
| 5562 test_point = gfx::Point(10, 10); | 5527 test_point = gfx::Point(10, 10); |
| 5563 result_layer = | 5528 result_layer = |
| 5564 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( | 5529 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( |
| 5565 test_point, render_surface_layer_list); | 5530 test_point, root.get()); |
| 5566 EXPECT_FALSE(result_layer); | 5531 EXPECT_FALSE(result_layer); |
| 5567 | 5532 |
| 5568 test_point = gfx::Point(10, 30); | 5533 test_point = gfx::Point(10, 30); |
| 5569 result_layer = | 5534 result_layer = |
| 5570 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( | 5535 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( |
| 5571 test_point, render_surface_layer_list); | 5536 test_point, root.get()); |
| 5572 EXPECT_FALSE(result_layer); | 5537 EXPECT_FALSE(result_layer); |
| 5573 | 5538 |
| 5574 test_point = gfx::Point(50, 50); | 5539 test_point = gfx::Point(50, 50); |
| 5575 result_layer = | 5540 result_layer = |
| 5576 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( | 5541 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( |
| 5577 test_point, render_surface_layer_list); | 5542 test_point, root.get()); |
| 5578 EXPECT_FALSE(result_layer); | 5543 EXPECT_FALSE(result_layer); |
| 5579 | 5544 |
| 5580 test_point = gfx::Point(67, 48); | 5545 test_point = gfx::Point(67, 48); |
| 5581 result_layer = | 5546 result_layer = |
| 5582 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( | 5547 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( |
| 5583 test_point, render_surface_layer_list); | 5548 test_point, root.get()); |
| 5584 EXPECT_FALSE(result_layer); | 5549 EXPECT_FALSE(result_layer); |
| 5585 | 5550 |
| 5586 test_point = gfx::Point(99, 99); | 5551 test_point = gfx::Point(99, 99); |
| 5587 result_layer = | 5552 result_layer = |
| 5588 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( | 5553 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( |
| 5589 test_point, render_surface_layer_list); | 5554 test_point, root.get()); |
| 5590 EXPECT_FALSE(result_layer); | 5555 EXPECT_FALSE(result_layer); |
| 5591 | 5556 |
| 5592 test_point = gfx::Point(-1, -1); | 5557 test_point = gfx::Point(-1, -1); |
| 5593 result_layer = | 5558 result_layer = |
| 5594 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( | 5559 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( |
| 5595 test_point, render_surface_layer_list); | 5560 test_point, root.get()); |
| 5596 EXPECT_FALSE(result_layer); | 5561 EXPECT_FALSE(result_layer); |
| 5597 } | 5562 } |
| 5598 | 5563 |
| 5599 TEST_F(LayerTreeHostCommonTest, | 5564 TEST_F(LayerTreeHostCommonTest, |
| 5600 HitCheckingTouchHandlerRegionsForSinglePositionedLayer) { | 5565 HitCheckingTouchHandlerRegionsForSinglePositionedLayer) { |
| 5601 FakeImplProxy proxy; | 5566 FakeImplProxy proxy; |
| 5602 TestSharedBitmapManager shared_bitmap_manager; | 5567 TestSharedBitmapManager shared_bitmap_manager; |
| 5603 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); | 5568 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); |
| 5604 scoped_ptr<LayerImpl> root = | 5569 scoped_ptr<LayerImpl> root = |
| 5605 LayerImpl::Create(host_impl.active_tree(), 12345); | 5570 LayerImpl::Create(host_impl.active_tree(), 12345); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 5628 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 5593 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
| 5629 | 5594 |
| 5630 // Sanity check the scenario we just created. | 5595 // Sanity check the scenario we just created. |
| 5631 ASSERT_EQ(1u, render_surface_layer_list.size()); | 5596 ASSERT_EQ(1u, render_surface_layer_list.size()); |
| 5632 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); | 5597 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); |
| 5633 | 5598 |
| 5634 // Hit checking for a point outside the layer should return a null pointer. | 5599 // Hit checking for a point outside the layer should return a null pointer. |
| 5635 gfx::Point test_point(49, 49); | 5600 gfx::Point test_point(49, 49); |
| 5636 LayerImpl* result_layer = | 5601 LayerImpl* result_layer = |
| 5637 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( | 5602 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( |
| 5638 test_point, render_surface_layer_list); | 5603 test_point, root.get()); |
| 5639 EXPECT_FALSE(result_layer); | 5604 EXPECT_FALSE(result_layer); |
| 5640 | 5605 |
| 5641 // Even though the layer has a touch handler region containing (101, 101), it | 5606 // Even though the layer has a touch handler region containing (101, 101), it |
| 5642 // should not be visible there since the root render surface would clamp it. | 5607 // should not be visible there since the root render surface would clamp it. |
| 5643 test_point = gfx::Point(101, 101); | 5608 test_point = gfx::Point(101, 101); |
| 5644 result_layer = | 5609 result_layer = |
| 5645 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( | 5610 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( |
| 5646 test_point, render_surface_layer_list); | 5611 test_point, root.get()); |
| 5647 EXPECT_FALSE(result_layer); | 5612 EXPECT_FALSE(result_layer); |
| 5648 | 5613 |
| 5649 // Hit checking for a point inside the layer, but outside the touch handler | 5614 // Hit checking for a point inside the layer, but outside the touch handler |
| 5650 // region should return a null pointer. | 5615 // region should return a null pointer. |
| 5651 test_point = gfx::Point(51, 51); | 5616 test_point = gfx::Point(51, 51); |
| 5652 result_layer = | 5617 result_layer = |
| 5653 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( | 5618 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( |
| 5654 test_point, render_surface_layer_list); | 5619 test_point, root.get()); |
| 5655 EXPECT_FALSE(result_layer); | 5620 EXPECT_FALSE(result_layer); |
| 5656 | 5621 |
| 5657 // Hit checking for a point inside the touch event handler region should | 5622 // Hit checking for a point inside the touch event handler region should |
| 5658 // return the root layer. | 5623 // return the root layer. |
| 5659 test_point = gfx::Point(61, 61); | 5624 test_point = gfx::Point(61, 61); |
| 5660 result_layer = | 5625 result_layer = |
| 5661 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( | 5626 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( |
| 5662 test_point, render_surface_layer_list); | 5627 test_point, root.get()); |
| 5663 ASSERT_TRUE(result_layer); | 5628 ASSERT_TRUE(result_layer); |
| 5664 EXPECT_EQ(12345, result_layer->id()); | 5629 EXPECT_EQ(12345, result_layer->id()); |
| 5665 | 5630 |
| 5666 test_point = gfx::Point(99, 99); | 5631 test_point = gfx::Point(99, 99); |
| 5667 result_layer = | 5632 result_layer = |
| 5668 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( | 5633 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( |
| 5669 test_point, render_surface_layer_list); | 5634 test_point, root.get()); |
| 5670 ASSERT_TRUE(result_layer); | 5635 ASSERT_TRUE(result_layer); |
| 5671 EXPECT_EQ(12345, result_layer->id()); | 5636 EXPECT_EQ(12345, result_layer->id()); |
| 5672 } | 5637 } |
| 5673 | 5638 |
| 5674 TEST_F(LayerTreeHostCommonTest, | 5639 TEST_F(LayerTreeHostCommonTest, |
| 5675 HitCheckingTouchHandlerRegionsForSingleLayerWithScaledContents) { | 5640 HitCheckingTouchHandlerRegionsForSingleLayerWithScaledContents) { |
| 5676 // A layer's visible content rect is actually in the layer's content space. | 5641 // A layer's visible content rect is actually in the layer's content space. |
| 5677 // The screen space transform converts from the layer's origin space to screen | 5642 // The screen space transform converts from the layer's origin space to screen |
| 5678 // space. This test makes sure that hit testing works correctly accounts for | 5643 // space. This test makes sure that hit testing works correctly accounts for |
| 5679 // the contents scale. A contents scale that is not 1 effectively forces a | 5644 // the contents scale. A contents scale that is not 1 effectively forces a |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5734 LayerImpl* test_layer = root->children()[0]; | 5699 LayerImpl* test_layer = root->children()[0]; |
| 5735 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), test_layer->visible_content_rect()); | 5700 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), test_layer->visible_content_rect()); |
| 5736 ASSERT_EQ(1u, render_surface_layer_list.size()); | 5701 ASSERT_EQ(1u, render_surface_layer_list.size()); |
| 5737 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); | 5702 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); |
| 5738 | 5703 |
| 5739 // Hit checking for a point outside the layer should return a null pointer | 5704 // Hit checking for a point outside the layer should return a null pointer |
| 5740 // (the root layer does not draw content, so it will not be tested either). | 5705 // (the root layer does not draw content, so it will not be tested either). |
| 5741 gfx::Point test_point(76, 76); | 5706 gfx::Point test_point(76, 76); |
| 5742 LayerImpl* result_layer = | 5707 LayerImpl* result_layer = |
| 5743 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( | 5708 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( |
| 5744 test_point, render_surface_layer_list); | 5709 test_point, root.get()); |
| 5745 EXPECT_FALSE(result_layer); | 5710 EXPECT_FALSE(result_layer); |
| 5746 | 5711 |
| 5747 // Hit checking for a point inside the layer, but outside the touch handler | 5712 // Hit checking for a point inside the layer, but outside the touch handler |
| 5748 // region should return a null pointer. | 5713 // region should return a null pointer. |
| 5749 test_point = gfx::Point(26, 26); | 5714 test_point = gfx::Point(26, 26); |
| 5750 result_layer = | 5715 result_layer = |
| 5751 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( | 5716 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( |
| 5752 test_point, render_surface_layer_list); | 5717 test_point, root.get()); |
| 5753 EXPECT_FALSE(result_layer); | 5718 EXPECT_FALSE(result_layer); |
| 5754 | 5719 |
| 5755 test_point = gfx::Point(34, 34); | 5720 test_point = gfx::Point(34, 34); |
| 5756 result_layer = | 5721 result_layer = |
| 5757 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( | 5722 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( |
| 5758 test_point, render_surface_layer_list); | 5723 test_point, root.get()); |
| 5759 EXPECT_FALSE(result_layer); | 5724 EXPECT_FALSE(result_layer); |
| 5760 | 5725 |
| 5761 test_point = gfx::Point(65, 65); | 5726 test_point = gfx::Point(65, 65); |
| 5762 result_layer = | 5727 result_layer = |
| 5763 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( | 5728 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( |
| 5764 test_point, render_surface_layer_list); | 5729 test_point, root.get()); |
| 5765 EXPECT_FALSE(result_layer); | 5730 EXPECT_FALSE(result_layer); |
| 5766 | 5731 |
| 5767 test_point = gfx::Point(74, 74); | 5732 test_point = gfx::Point(74, 74); |
| 5768 result_layer = | 5733 result_layer = |
| 5769 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( | 5734 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( |
| 5770 test_point, render_surface_layer_list); | 5735 test_point, root.get()); |
| 5771 EXPECT_FALSE(result_layer); | 5736 EXPECT_FALSE(result_layer); |
| 5772 | 5737 |
| 5773 // Hit checking for a point inside the touch event handler region should | 5738 // Hit checking for a point inside the touch event handler region should |
| 5774 // return the root layer. | 5739 // return the root layer. |
| 5775 test_point = gfx::Point(35, 35); | 5740 test_point = gfx::Point(35, 35); |
| 5776 result_layer = | 5741 result_layer = |
| 5777 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( | 5742 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( |
| 5778 test_point, render_surface_layer_list); | 5743 test_point, root.get()); |
| 5779 ASSERT_TRUE(result_layer); | 5744 ASSERT_TRUE(result_layer); |
| 5780 EXPECT_EQ(12345, result_layer->id()); | 5745 EXPECT_EQ(12345, result_layer->id()); |
| 5781 | 5746 |
| 5782 test_point = gfx::Point(64, 64); | 5747 test_point = gfx::Point(64, 64); |
| 5783 result_layer = | 5748 result_layer = |
| 5784 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( | 5749 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( |
| 5785 test_point, render_surface_layer_list); | 5750 test_point, root.get()); |
| 5786 ASSERT_TRUE(result_layer); | 5751 ASSERT_TRUE(result_layer); |
| 5787 EXPECT_EQ(12345, result_layer->id()); | 5752 EXPECT_EQ(12345, result_layer->id()); |
| 5788 } | 5753 } |
| 5789 | 5754 |
| 5790 TEST_F(LayerTreeHostCommonTest, | 5755 TEST_F(LayerTreeHostCommonTest, |
| 5791 HitCheckingTouchHandlerRegionsForSingleLayerWithDeviceScale) { | 5756 HitCheckingTouchHandlerRegionsForSingleLayerWithDeviceScale) { |
| 5792 // The layer's device_scale_factor and page_scale_factor should scale the | 5757 // The layer's device_scale_factor and page_scale_factor should scale the |
| 5793 // content rect and we should be able to hit the touch handler region by | 5758 // content rect and we should be able to hit the touch handler region by |
| 5794 // scaling the points accordingly. | 5759 // scaling the points accordingly. |
| 5795 FakeImplProxy proxy; | 5760 FakeImplProxy proxy; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5851 EXPECT_RECT_EQ(gfx::Rect(test_layer->content_bounds()), | 5816 EXPECT_RECT_EQ(gfx::Rect(test_layer->content_bounds()), |
| 5852 test_layer->visible_content_rect()); | 5817 test_layer->visible_content_rect()); |
| 5853 | 5818 |
| 5854 // Hit checking for a point outside the layer should return a null pointer | 5819 // Hit checking for a point outside the layer should return a null pointer |
| 5855 // (the root layer does not draw content, so it will not be tested either). | 5820 // (the root layer does not draw content, so it will not be tested either). |
| 5856 gfx::PointF test_point(76.f, 76.f); | 5821 gfx::PointF test_point(76.f, 76.f); |
| 5857 test_point = | 5822 test_point = |
| 5858 gfx::ScalePoint(test_point, device_scale_factor * page_scale_factor); | 5823 gfx::ScalePoint(test_point, device_scale_factor * page_scale_factor); |
| 5859 LayerImpl* result_layer = | 5824 LayerImpl* result_layer = |
| 5860 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( | 5825 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( |
| 5861 test_point, render_surface_layer_list); | 5826 test_point, root.get()); |
| 5862 EXPECT_FALSE(result_layer); | 5827 EXPECT_FALSE(result_layer); |
| 5863 | 5828 |
| 5864 // Hit checking for a point inside the layer, but outside the touch handler | 5829 // Hit checking for a point inside the layer, but outside the touch handler |
| 5865 // region should return a null pointer. | 5830 // region should return a null pointer. |
| 5866 test_point = gfx::Point(26, 26); | 5831 test_point = gfx::Point(26, 26); |
| 5867 test_point = | 5832 test_point = |
| 5868 gfx::ScalePoint(test_point, device_scale_factor * page_scale_factor); | 5833 gfx::ScalePoint(test_point, device_scale_factor * page_scale_factor); |
| 5869 result_layer = | 5834 result_layer = |
| 5870 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( | 5835 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( |
| 5871 test_point, render_surface_layer_list); | 5836 test_point, root.get()); |
| 5872 EXPECT_FALSE(result_layer); | 5837 EXPECT_FALSE(result_layer); |
| 5873 | 5838 |
| 5874 test_point = gfx::Point(34, 34); | 5839 test_point = gfx::Point(34, 34); |
| 5875 test_point = | 5840 test_point = |
| 5876 gfx::ScalePoint(test_point, device_scale_factor * page_scale_factor); | 5841 gfx::ScalePoint(test_point, device_scale_factor * page_scale_factor); |
| 5877 result_layer = | 5842 result_layer = |
| 5878 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( | 5843 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( |
| 5879 test_point, render_surface_layer_list); | 5844 test_point, root.get()); |
| 5880 EXPECT_FALSE(result_layer); | 5845 EXPECT_FALSE(result_layer); |
| 5881 | 5846 |
| 5882 test_point = gfx::Point(65, 65); | 5847 test_point = gfx::Point(65, 65); |
| 5883 test_point = | 5848 test_point = |
| 5884 gfx::ScalePoint(test_point, device_scale_factor * page_scale_factor); | 5849 gfx::ScalePoint(test_point, device_scale_factor * page_scale_factor); |
| 5885 result_layer = | 5850 result_layer = |
| 5886 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( | 5851 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( |
| 5887 test_point, render_surface_layer_list); | 5852 test_point, root.get()); |
| 5888 EXPECT_FALSE(result_layer); | 5853 EXPECT_FALSE(result_layer); |
| 5889 | 5854 |
| 5890 test_point = gfx::Point(74, 74); | 5855 test_point = gfx::Point(74, 74); |
| 5891 test_point = | 5856 test_point = |
| 5892 gfx::ScalePoint(test_point, device_scale_factor * page_scale_factor); | 5857 gfx::ScalePoint(test_point, device_scale_factor * page_scale_factor); |
| 5893 result_layer = | 5858 result_layer = |
| 5894 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( | 5859 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( |
| 5895 test_point, render_surface_layer_list); | 5860 test_point, root.get()); |
| 5896 EXPECT_FALSE(result_layer); | 5861 EXPECT_FALSE(result_layer); |
| 5897 | 5862 |
| 5898 // Hit checking for a point inside the touch event handler region should | 5863 // Hit checking for a point inside the touch event handler region should |
| 5899 // return the root layer. | 5864 // return the root layer. |
| 5900 test_point = gfx::Point(35, 35); | 5865 test_point = gfx::Point(35, 35); |
| 5901 test_point = | 5866 test_point = |
| 5902 gfx::ScalePoint(test_point, device_scale_factor * page_scale_factor); | 5867 gfx::ScalePoint(test_point, device_scale_factor * page_scale_factor); |
| 5903 result_layer = | 5868 result_layer = |
| 5904 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( | 5869 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( |
| 5905 test_point, render_surface_layer_list); | 5870 test_point, root.get()); |
| 5906 ASSERT_TRUE(result_layer); | 5871 ASSERT_TRUE(result_layer); |
| 5907 EXPECT_EQ(12345, result_layer->id()); | 5872 EXPECT_EQ(12345, result_layer->id()); |
| 5908 | 5873 |
| 5909 test_point = gfx::Point(64, 64); | 5874 test_point = gfx::Point(64, 64); |
| 5910 test_point = | 5875 test_point = |
| 5911 gfx::ScalePoint(test_point, device_scale_factor * page_scale_factor); | 5876 gfx::ScalePoint(test_point, device_scale_factor * page_scale_factor); |
| 5912 result_layer = | 5877 result_layer = |
| 5913 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( | 5878 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( |
| 5914 test_point, render_surface_layer_list); | 5879 test_point, root.get()); |
| 5915 ASSERT_TRUE(result_layer); | 5880 ASSERT_TRUE(result_layer); |
| 5916 EXPECT_EQ(12345, result_layer->id()); | 5881 EXPECT_EQ(12345, result_layer->id()); |
| 5917 } | 5882 } |
| 5918 | 5883 |
| 5919 TEST_F(LayerTreeHostCommonTest, | 5884 TEST_F(LayerTreeHostCommonTest, |
| 5920 HitCheckingTouchHandlerRegionsForSimpleClippedLayer) { | 5885 HitCheckingTouchHandlerRegionsForSimpleClippedLayer) { |
| 5921 // Test that hit-checking will only work for the visible portion of a layer, | 5886 // Test that hit-checking will only work for the visible portion of a layer, |
| 5922 // and not the entire layer bounds. Here we just test the simple axis-aligned | 5887 // and not the entire layer bounds. Here we just test the simple axis-aligned |
| 5923 // case. | 5888 // case. |
| 5924 gfx::Transform identity_matrix; | 5889 gfx::Transform identity_matrix; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5979 ASSERT_EQ(1u, render_surface_layer_list.size()); | 5944 ASSERT_EQ(1u, render_surface_layer_list.size()); |
| 5980 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); | 5945 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); |
| 5981 ASSERT_EQ(456, root->render_surface()->layer_list().at(0)->id()); | 5946 ASSERT_EQ(456, root->render_surface()->layer_list().at(0)->id()); |
| 5982 | 5947 |
| 5983 // Hit checking for a point outside the layer should return a null pointer. | 5948 // Hit checking for a point outside the layer should return a null pointer. |
| 5984 // Despite the child layer being very large, it should be clipped to the root | 5949 // Despite the child layer being very large, it should be clipped to the root |
| 5985 // layer's bounds. | 5950 // layer's bounds. |
| 5986 gfx::Point test_point(24, 24); | 5951 gfx::Point test_point(24, 24); |
| 5987 LayerImpl* result_layer = | 5952 LayerImpl* result_layer = |
| 5988 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( | 5953 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( |
| 5989 test_point, render_surface_layer_list); | 5954 test_point, root.get()); |
| 5990 EXPECT_FALSE(result_layer); | 5955 EXPECT_FALSE(result_layer); |
| 5991 | 5956 |
| 5992 // Hit checking for a point inside the layer, but outside the touch handler | 5957 // Hit checking for a point inside the layer, but outside the touch handler |
| 5993 // region should return a null pointer. | 5958 // region should return a null pointer. |
| 5994 test_point = gfx::Point(35, 35); | 5959 test_point = gfx::Point(35, 35); |
| 5995 result_layer = | 5960 result_layer = |
| 5996 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( | 5961 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( |
| 5997 test_point, render_surface_layer_list); | 5962 test_point, root.get()); |
| 5998 EXPECT_FALSE(result_layer); | 5963 EXPECT_FALSE(result_layer); |
| 5999 | 5964 |
| 6000 test_point = gfx::Point(74, 74); | 5965 test_point = gfx::Point(74, 74); |
| 6001 result_layer = | 5966 result_layer = |
| 6002 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( | 5967 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( |
| 6003 test_point, render_surface_layer_list); | 5968 test_point, root.get()); |
| 6004 EXPECT_FALSE(result_layer); | 5969 EXPECT_FALSE(result_layer); |
| 6005 | 5970 |
| 6006 // Hit checking for a point inside the touch event handler region should | 5971 // Hit checking for a point inside the touch event handler region should |
| 6007 // return the root layer. | 5972 // return the root layer. |
| 6008 test_point = gfx::Point(25, 25); | 5973 test_point = gfx::Point(25, 25); |
| 6009 result_layer = | 5974 result_layer = |
| 6010 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( | 5975 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( |
| 6011 test_point, render_surface_layer_list); | 5976 test_point, root.get()); |
| 6012 ASSERT_TRUE(result_layer); | 5977 ASSERT_TRUE(result_layer); |
| 6013 EXPECT_EQ(456, result_layer->id()); | 5978 EXPECT_EQ(456, result_layer->id()); |
| 6014 | 5979 |
| 6015 test_point = gfx::Point(34, 34); | 5980 test_point = gfx::Point(34, 34); |
| 6016 result_layer = | 5981 result_layer = |
| 6017 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( | 5982 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( |
| 6018 test_point, render_surface_layer_list); | 5983 test_point, root.get()); |
| 6019 ASSERT_TRUE(result_layer); | 5984 ASSERT_TRUE(result_layer); |
| 6020 EXPECT_EQ(456, result_layer->id()); | 5985 EXPECT_EQ(456, result_layer->id()); |
| 6021 } | 5986 } |
| 6022 | 5987 |
| 6023 TEST_F(LayerTreeHostCommonTest, | 5988 TEST_F(LayerTreeHostCommonTest, |
| 6024 HitCheckingTouchHandlerOverlappingRegions) { | 5989 HitCheckingTouchHandlerOverlappingRegions) { |
| 6025 gfx::Transform identity_matrix; | 5990 gfx::Transform identity_matrix; |
| 6026 gfx::PointF anchor; | 5991 gfx::PointF anchor; |
| 6027 | 5992 |
| 6028 FakeImplProxy proxy; | 5993 FakeImplProxy proxy; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6081 | 6046 |
| 6082 // Sanity check the scenario we just created. | 6047 // Sanity check the scenario we just created. |
| 6083 ASSERT_EQ(1u, render_surface_layer_list.size()); | 6048 ASSERT_EQ(1u, render_surface_layer_list.size()); |
| 6084 ASSERT_EQ(2u, root->render_surface()->layer_list().size()); | 6049 ASSERT_EQ(2u, root->render_surface()->layer_list().size()); |
| 6085 ASSERT_EQ(123, root->render_surface()->layer_list().at(0)->id()); | 6050 ASSERT_EQ(123, root->render_surface()->layer_list().at(0)->id()); |
| 6086 ASSERT_EQ(1234, root->render_surface()->layer_list().at(1)->id()); | 6051 ASSERT_EQ(1234, root->render_surface()->layer_list().at(1)->id()); |
| 6087 | 6052 |
| 6088 gfx::Point test_point(35, 35); | 6053 gfx::Point test_point(35, 35); |
| 6089 LayerImpl* result_layer = | 6054 LayerImpl* result_layer = |
| 6090 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( | 6055 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( |
| 6091 test_point, render_surface_layer_list); | 6056 test_point, root.get()); |
| 6092 | 6057 |
| 6093 // We should have passed through the no-touch layer and found the layer | 6058 // We should have passed through the no-touch layer and found the layer |
| 6094 // behind it. | 6059 // behind it. |
| 6095 EXPECT_TRUE(result_layer); | 6060 EXPECT_TRUE(result_layer); |
| 6096 | 6061 |
| 6097 host_impl.active_tree()->LayerById(1234)->SetContentsOpaque(true); | 6062 host_impl.active_tree()->LayerById(1234)->SetContentsOpaque(true); |
| 6098 result_layer = | 6063 result_layer = |
| 6099 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( | 6064 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( |
| 6100 test_point, render_surface_layer_list); | 6065 test_point, root.get()); |
| 6101 | 6066 |
| 6102 // Even with an opaque layer in the middle, we should still find the layer | 6067 // Even with an opaque layer in the middle, we should still find the layer |
| 6103 // with | 6068 // with |
| 6104 // the touch handler behind it (since we can't assume that opaque layers are | 6069 // the touch handler behind it (since we can't assume that opaque layers are |
| 6105 // opaque to hit testing). | 6070 // opaque to hit testing). |
| 6106 EXPECT_TRUE(result_layer); | 6071 EXPECT_TRUE(result_layer); |
| 6107 | 6072 |
| 6108 test_point = gfx::Point(35, 15); | 6073 test_point = gfx::Point(35, 15); |
| 6109 result_layer = | 6074 result_layer = |
| 6110 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( | 6075 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( |
| 6111 test_point, render_surface_layer_list); | 6076 test_point, root.get()); |
| 6112 ASSERT_TRUE(result_layer); | 6077 ASSERT_TRUE(result_layer); |
| 6113 EXPECT_EQ(123, result_layer->id()); | 6078 EXPECT_EQ(123, result_layer->id()); |
| 6114 | 6079 |
| 6115 test_point = gfx::Point(35, 65); | 6080 test_point = gfx::Point(35, 65); |
| 6116 result_layer = | 6081 result_layer = |
| 6117 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( | 6082 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( |
| 6118 test_point, render_surface_layer_list); | 6083 test_point, root.get()); |
| 6119 EXPECT_FALSE(result_layer); | 6084 EXPECT_FALSE(result_layer); |
| 6120 } | 6085 } |
| 6121 | 6086 |
| 6122 class NoScaleContentLayer : public ContentLayer { | 6087 class NoScaleContentLayer : public ContentLayer { |
| 6123 public: | 6088 public: |
| 6124 static scoped_refptr<NoScaleContentLayer> Create(ContentLayerClient* client) { | 6089 static scoped_refptr<NoScaleContentLayer> Create(ContentLayerClient* client) { |
| 6125 return make_scoped_refptr(new NoScaleContentLayer(client)); | 6090 return make_scoped_refptr(new NoScaleContentLayer(client)); |
| 6126 } | 6091 } |
| 6127 | 6092 |
| 6128 virtual void CalculateContentsScale(float ideal_contents_scale, | 6093 virtual void CalculateContentsScale(float ideal_contents_scale, |
| (...skipping 4018 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10147 | 10112 |
| 10148 // |grand_parent| has a transform that's neither a translation nor a scale. | 10113 // |grand_parent| has a transform that's neither a translation nor a scale. |
| 10149 EXPECT_EQ(0.f, grand_parent->last_maximum_animation_contents_scale()); | 10114 EXPECT_EQ(0.f, grand_parent->last_maximum_animation_contents_scale()); |
| 10150 EXPECT_EQ(0.f, parent_raw->last_maximum_animation_contents_scale()); | 10115 EXPECT_EQ(0.f, parent_raw->last_maximum_animation_contents_scale()); |
| 10151 EXPECT_EQ(0.f, child_raw->last_maximum_animation_contents_scale()); | 10116 EXPECT_EQ(0.f, child_raw->last_maximum_animation_contents_scale()); |
| 10152 EXPECT_EQ(0.f, grand_child_raw->last_maximum_animation_contents_scale()); | 10117 EXPECT_EQ(0.f, grand_child_raw->last_maximum_animation_contents_scale()); |
| 10153 } | 10118 } |
| 10154 | 10119 |
| 10155 } // namespace | 10120 } // namespace |
| 10156 } // namespace cc | 10121 } // namespace cc |
| OLD | NEW |