| 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 "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "cc/layers/heads_up_display_layer_impl.h" | 9 #include "cc/layers/heads_up_display_layer_impl.h" |
| 10 #include "cc/test/fake_layer_tree_host_impl.h" | 10 #include "cc/test/fake_layer_tree_host_impl.h" |
| (...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 host_impl().SetViewportSize(root->bounds()); | 454 host_impl().SetViewportSize(root->bounds()); |
| 455 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 455 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
| 456 | 456 |
| 457 gfx::PointF test_point(50.f, 50.f); | 457 gfx::PointF test_point(50.f, 50.f); |
| 458 LayerImpl* result_layer = | 458 LayerImpl* result_layer = |
| 459 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 459 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); |
| 460 ASSERT_TRUE(result_layer); | 460 ASSERT_TRUE(result_layer); |
| 461 EXPECT_EQ(3, result_layer->id()); | 461 EXPECT_EQ(3, result_layer->id()); |
| 462 } | 462 } |
| 463 | 463 |
| 464 TEST_F(LayerTreeImplTest, HitTestingPointOutsideMaxTextureSize) { | |
| 465 gfx::Transform identity_matrix; | |
| 466 int max_texture_size = | |
| 467 host_impl().active_tree()->resource_provider()->max_texture_size(); | |
| 468 gfx::Size bounds(max_texture_size + 100, max_texture_size + 100); | |
| 469 | |
| 470 LayerImpl* root = root_layer(); | |
| 471 root->SetBounds(bounds); | |
| 472 | |
| 473 std::unique_ptr<LayerImpl> surface = | |
| 474 LayerImpl::Create(host_impl().active_tree(), 2); | |
| 475 surface->SetBounds(bounds); | |
| 476 surface->SetMasksToBounds(true); | |
| 477 surface->SetDrawsContent(true); | |
| 478 surface->test_properties()->force_render_surface = true; | |
| 479 | |
| 480 root->test_properties()->AddChild(std::move(surface)); | |
| 481 host_impl().SetViewportSize(root->bounds()); | |
| 482 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | |
| 483 | |
| 484 gfx::PointF test_point(max_texture_size - 50, max_texture_size - 50); | |
| 485 LayerImpl* result_layer = | |
| 486 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | |
| 487 EXPECT_TRUE(result_layer); | |
| 488 | |
| 489 test_point = gfx::PointF(max_texture_size + 50, max_texture_size + 50); | |
| 490 result_layer = | |
| 491 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | |
| 492 EXPECT_FALSE(result_layer); | |
| 493 } | |
| 494 | |
| 495 TEST_F(LayerTreeImplTest, HitTestingForSinglePerspectiveLayer) { | 464 TEST_F(LayerTreeImplTest, HitTestingForSinglePerspectiveLayer) { |
| 496 // perspective_projection_about_center * translation_by_z is designed so that | 465 // perspective_projection_about_center * translation_by_z is designed so that |
| 497 // the 100 x 100 layer becomes 50 x 50, and remains centered at (50, 50). | 466 // the 100 x 100 layer becomes 50 x 50, and remains centered at (50, 50). |
| 498 gfx::Transform perspective_projection_about_center; | 467 gfx::Transform perspective_projection_about_center; |
| 499 perspective_projection_about_center.Translate(50.0, 50.0); | 468 perspective_projection_about_center.Translate(50.0, 50.0); |
| 500 perspective_projection_about_center.ApplyPerspectiveDepth(1.0); | 469 perspective_projection_about_center.ApplyPerspectiveDepth(1.0); |
| 501 perspective_projection_about_center.Translate(-50.0, -50.0); | 470 perspective_projection_about_center.Translate(-50.0, -50.0); |
| 502 gfx::Transform translation_by_z; | 471 gfx::Transform translation_by_z; |
| 503 translation_by_z.Translate3d(0.0, 0.0, -1.0); | 472 translation_by_z.Translate3d(0.0, 0.0, -1.0); |
| 504 | 473 |
| (...skipping 1876 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2381 auto weak_promise = promise->AsWeakPtr(); | 2350 auto weak_promise = promise->AsWeakPtr(); |
| 2382 host_impl().active_tree()->QueueSwapPromise(std::move(promise)); | 2351 host_impl().active_tree()->QueueSwapPromise(std::move(promise)); |
| 2383 host_impl().active_tree()->BreakSwapPromises( | 2352 host_impl().active_tree()->BreakSwapPromises( |
| 2384 SwapPromise::DidNotSwapReason::SWAP_FAILS); | 2353 SwapPromise::DidNotSwapReason::SWAP_FAILS); |
| 2385 EXPECT_FALSE(weak_promise); | 2354 EXPECT_FALSE(weak_promise); |
| 2386 } | 2355 } |
| 2387 } | 2356 } |
| 2388 | 2357 |
| 2389 } // namespace | 2358 } // namespace |
| 2390 } // namespace cc | 2359 } // namespace cc |
| OLD | NEW |