Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/trees/layer_tree_impl.h" | 5 #include "cc/trees/layer_tree_impl.h" |
| 6 | 6 |
| 7 #include "cc/layers/heads_up_display_layer_impl.h" | 7 #include "cc/layers/heads_up_display_layer_impl.h" |
| 8 #include "cc/layers/layer.h" | 8 #include "cc/layers/layer.h" |
| 9 #include "cc/layers/solid_color_scrollbar_layer_impl.h" | 9 #include "cc/layers/solid_color_scrollbar_layer_impl.h" |
| 10 #include "cc/test/fake_impl_task_runner_provider.h" | 10 #include "cc/test/fake_impl_task_runner_provider.h" |
| (...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 373 result_layer = | 373 result_layer = |
| 374 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 374 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); |
| 375 ASSERT_FALSE(result_layer); | 375 ASSERT_FALSE(result_layer); |
| 376 | 376 |
| 377 test_point = gfx::PointF(-1.f, 50.f); | 377 test_point = gfx::PointF(-1.f, 50.f); |
| 378 result_layer = | 378 result_layer = |
| 379 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 379 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); |
| 380 ASSERT_FALSE(result_layer); | 380 ASSERT_FALSE(result_layer); |
| 381 } | 381 } |
| 382 | 382 |
| 383 TEST_F(LayerTreeImplTest, HitTestingSiblings) { | |
| 384 // This tests hit testing when the test point hits only one of the siblings. | |
| 385 gfx::Transform identity_matrix; | |
| 386 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); | |
| 387 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), | |
| 388 gfx::PointF(), gfx::Size(100, 100), true, false, | |
| 389 true); | |
| 390 scoped_ptr<LayerImpl> child1 = | |
| 391 LayerImpl::Create(host_impl().active_tree(), 2); | |
| 392 SetLayerPropertiesForTesting(child1.get(), identity_matrix, gfx::Point3F(), | |
| 393 gfx::PointF(), gfx::Size(25, 25), true, false, | |
| 394 false); | |
| 395 child1->SetMasksToBounds(true); | |
| 396 child1->SetDrawsContent(true); | |
| 397 scoped_ptr<LayerImpl> child2 = | |
| 398 LayerImpl::Create(host_impl().active_tree(), 3); | |
| 399 SetLayerPropertiesForTesting(child2.get(), identity_matrix, gfx::Point3F(), | |
| 400 gfx::PointF(), gfx::Size(75, 75), true, false, | |
| 401 false); | |
| 402 child2->SetMasksToBounds(true); | |
| 403 child2->SetDrawsContent(true); | |
| 404 root->AddChild(std::move(child1)); | |
| 405 root->AddChild(std::move(child2)); | |
| 406 | |
| 407 host_impl().SetViewportSize(root->bounds()); | |
| 408 host_impl().active_tree()->SetRootLayer(std::move(root)); | |
| 409 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | |
| 410 | |
| 411 gfx::PointF test_point(50.f, 50.f); | |
| 412 LayerImpl* result_layer = | |
| 413 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | |
| 414 ASSERT_TRUE(result_layer); | |
| 415 EXPECT_EQ(3, result_layer->id()); | |
| 416 } | |
| 417 | |
| 418 TEST_F(LayerTreeImplTest, HitTestingPointOutsideMaxTextureSize) { | |
| 419 gfx::Transform identity_matrix; | |
| 420 int max_texture_size = | |
| 421 host_impl().active_tree()->resource_provider()->max_texture_size(); | |
| 422 gfx::Size bounds(max_texture_size + 100, max_texture_size + 100); | |
| 423 | |
| 424 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); | |
| 425 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), | |
| 426 gfx::PointF(), bounds, true, false, true); | |
| 427 | |
| 428 scoped_ptr<LayerImpl> surface = | |
| 429 LayerImpl::Create(host_impl().active_tree(), 2); | |
| 430 SetLayerPropertiesForTesting(surface.get(), identity_matrix, gfx::Point3F(), | |
| 431 gfx::PointF(), bounds, true, false, true); | |
| 432 surface->SetMasksToBounds(true); | |
| 433 surface->SetDrawsContent(true); | |
| 434 | |
| 435 root->AddChild(std::move(surface)); | |
| 436 host_impl().SetViewportSize(root->bounds()); | |
| 437 host_impl().active_tree()->SetRootLayer(std::move(root)); | |
| 438 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | |
| 439 | |
| 440 gfx::PointF test_point(max_texture_size - 50, max_texture_size - 50); | |
| 441 LayerImpl* result_layer = | |
| 442 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | |
| 443 ASSERT_TRUE(result_layer); | |
|
ajuma
2016/01/06 14:18:55
EXPECT_TRUE
(it would make sense to use ASSERT if
jaydasika
2016/01/06 19:31:20
Done.
| |
| 444 | |
| 445 test_point = gfx::PointF(max_texture_size + 50, max_texture_size + 50); | |
| 446 result_layer = | |
| 447 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | |
| 448 ASSERT_FALSE(result_layer); | |
|
ajuma
2016/01/06 14:18:55
EXPECT_FALSE
jaydasika
2016/01/06 19:31:20
Done.
| |
| 449 } | |
| 450 | |
| 383 TEST_F(LayerTreeImplTest, HitTestingForSinglePerspectiveLayer) { | 451 TEST_F(LayerTreeImplTest, HitTestingForSinglePerspectiveLayer) { |
| 384 scoped_ptr<LayerImpl> root = | 452 scoped_ptr<LayerImpl> root = |
| 385 LayerImpl::Create(host_impl().active_tree(), 12345); | 453 LayerImpl::Create(host_impl().active_tree(), 12345); |
| 386 | 454 |
| 387 gfx::Transform identity_matrix; | 455 gfx::Transform identity_matrix; |
| 388 | 456 |
| 389 // perspective_projection_about_center * translation_by_z is designed so that | 457 // perspective_projection_about_center * translation_by_z is designed so that |
| 390 // the 100 x 100 layer becomes 50 x 50, and remains centered at (50, 50). | 458 // the 100 x 100 layer becomes 50 x 50, and remains centered at (50, 50). |
| 391 gfx::Transform perspective_projection_about_center; | 459 gfx::Transform perspective_projection_about_center; |
| 392 perspective_projection_about_center.Translate(50.0, 50.0); | 460 perspective_projection_about_center.Translate(50.0, 50.0); |
| (...skipping 1844 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2237 EXPECT_EQ(0u, host_impl().active_tree()->NumLayers()); | 2305 EXPECT_EQ(0u, host_impl().active_tree()->NumLayers()); |
| 2238 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); | 2306 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); |
| 2239 root->AddChild(LayerImpl::Create(host_impl().active_tree(), 2)); | 2307 root->AddChild(LayerImpl::Create(host_impl().active_tree(), 2)); |
| 2240 root->AddChild(LayerImpl::Create(host_impl().active_tree(), 3)); | 2308 root->AddChild(LayerImpl::Create(host_impl().active_tree(), 3)); |
| 2241 root->child_at(1)->AddChild(LayerImpl::Create(host_impl().active_tree(), 4)); | 2309 root->child_at(1)->AddChild(LayerImpl::Create(host_impl().active_tree(), 4)); |
| 2242 EXPECT_EQ(4u, host_impl().active_tree()->NumLayers()); | 2310 EXPECT_EQ(4u, host_impl().active_tree()->NumLayers()); |
| 2243 } | 2311 } |
| 2244 | 2312 |
| 2245 } // namespace | 2313 } // namespace |
| 2246 } // namespace cc | 2314 } // namespace cc |
| OLD | NEW |