Chromium Code Reviews| 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 "cc/animation/layer_animation_controller.h" | 7 #include "cc/animation/layer_animation_controller.h" |
| 8 #include "cc/base/math_util.h" | 8 #include "cc/base/math_util.h" |
| 9 #include "cc/layers/content_layer.h" | 9 #include "cc/layers/content_layer.h" |
| 10 #include "cc/layers/content_layer_client.h" | 10 #include "cc/layers/content_layer_client.h" |
| (...skipping 5551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5562 EXPECT_EQ(3, result_layer->id()); | 5562 EXPECT_EQ(3, result_layer->id()); |
| 5563 | 5563 |
| 5564 // Hit testing for a point inside the mousewheel layer should return it. | 5564 // Hit testing for a point inside the mousewheel layer should return it. |
| 5565 test_point = gfx::Point(75, 75); | 5565 test_point = gfx::Point(75, 75); |
| 5566 result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | 5566 result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( |
| 5567 test_point, render_surface_layer_list); | 5567 test_point, render_surface_layer_list); |
| 5568 ASSERT_TRUE(result_layer); | 5568 ASSERT_TRUE(result_layer); |
| 5569 EXPECT_EQ(4, result_layer->id()); | 5569 EXPECT_EQ(4, result_layer->id()); |
| 5570 } | 5570 } |
| 5571 | 5571 |
| 5572 TEST_F(LayerTreeHostCommonTest, HitTestForZeroOpacityLayers) { | |
| 5573 FakeImplProxy proxy; | |
| 5574 FakeLayerTreeHostImpl host_impl(&proxy); | |
| 5575 const int kRootId = 1; | |
| 5576 const int kTouchHandlerId = 2; | |
| 5577 const int kWheelHandlerId = 3; | |
| 5578 const int kNoHandlerId = 4; | |
| 5579 const int kGrandChildWithEventId = 5; | |
| 5580 const int kGrandChildWithoutEventId = 6; | |
| 5581 | |
| 5582 scoped_ptr<LayerImpl> root = | |
| 5583 LayerImpl::Create(host_impl.active_tree(), 1); | |
| 5584 gfx::Transform identity_matrix; | |
| 5585 gfx::PointF anchor; | |
| 5586 gfx::PointF position; | |
| 5587 gfx::Size bounds(100, 100); | |
| 5588 SetLayerPropertiesForTesting(root.get(), | |
| 5589 identity_matrix, | |
| 5590 identity_matrix, | |
| 5591 anchor, | |
| 5592 position, | |
| 5593 bounds, | |
| 5594 false); | |
| 5595 root->SetDrawsContent(true); | |
| 5596 | |
| 5597 { | |
| 5598 // Child 1 - Zero opacity, without any event handler. | |
|
danakj
2013/10/08 18:32:32
Can you add a case where there is
- Opacity 0 lay
| |
| 5599 gfx::PointF position(10.f, 10.f); | |
| 5600 gfx::Size bounds(30, 30); | |
|
danakj
2013/10/08 18:32:32
Can you add a case where the touch handler layer o
| |
| 5601 scoped_ptr<LayerImpl> child = | |
| 5602 LayerImpl::Create(host_impl.active_tree(), kNoHandlerId); | |
| 5603 SetLayerPropertiesForTesting(child.get(), | |
| 5604 identity_matrix, | |
| 5605 identity_matrix, | |
| 5606 anchor, | |
| 5607 position, | |
| 5608 bounds, | |
| 5609 false); | |
| 5610 child->SetOpacity(0.f); | |
|
danakj
2013/10/08 18:32:32
Can you make all of the layers in this test DrawsC
| |
| 5611 | |
| 5612 // Grandchild - with a wheel handler. | |
| 5613 { | |
| 5614 scoped_ptr<LayerImpl> grand_child = | |
| 5615 LayerImpl::Create(host_impl.active_tree(), kGrandChildWithEventId); | |
| 5616 SetLayerPropertiesForTesting(grand_child.get(), | |
| 5617 identity_matrix, | |
| 5618 identity_matrix, | |
| 5619 gfx::PointF(), | |
| 5620 gfx::PointF(10, 10), | |
| 5621 gfx::Size(10, 10), | |
| 5622 false); | |
| 5623 grand_child->SetHaveWheelEventHandlers(true); | |
| 5624 child->AddChild(grand_child.Pass()); | |
| 5625 } | |
| 5626 | |
| 5627 // Grandchild - without any event handlers. | |
| 5628 { | |
| 5629 scoped_ptr<LayerImpl> grand_child = | |
| 5630 LayerImpl::Create(host_impl.active_tree(), kGrandChildWithoutEventId); | |
| 5631 SetLayerPropertiesForTesting(grand_child.get(), | |
| 5632 identity_matrix, | |
| 5633 identity_matrix, | |
| 5634 gfx::PointF(), | |
| 5635 gfx::PointF(20, 10), | |
| 5636 gfx::Size(10, 10), | |
| 5637 false); | |
| 5638 child->AddChild(grand_child.Pass()); | |
| 5639 } | |
| 5640 root->AddChild(child.Pass()); | |
| 5641 } | |
| 5642 | |
| 5643 { | |
| 5644 // Child 2 - Zero opacity, with touch event handler. | |
|
danakj
2013/10/08 18:32:32
Can you add multiple drawing children of this laye
| |
| 5645 gfx::PointF position(70.f, 10.f); | |
| 5646 gfx::Size bounds(30, 30); | |
| 5647 scoped_ptr<LayerImpl> child = | |
| 5648 LayerImpl::Create(host_impl.active_tree(), kTouchHandlerId); | |
| 5649 SetLayerPropertiesForTesting(child.get(), | |
| 5650 identity_matrix, | |
| 5651 identity_matrix, | |
| 5652 anchor, | |
| 5653 position, | |
| 5654 bounds, | |
| 5655 false); | |
| 5656 child->SetOpacity(0.f); | |
| 5657 child->SetTouchEventHandlerRegion(gfx::Rect(10, 10, 10, 10)); | |
| 5658 root->AddChild(child.Pass()); | |
| 5659 } | |
| 5660 | |
| 5661 { | |
| 5662 // Child 3 - Zero opacity, with wheel event handler. | |
|
danakj
2013/10/08 18:32:32
Could you split each of these 3 children cases int
| |
| 5663 gfx::PointF position(10.f, 50.f); | |
| 5664 gfx::Size bounds(30, 30); | |
| 5665 scoped_ptr<LayerImpl> child = | |
| 5666 LayerImpl::Create(host_impl.active_tree(), kWheelHandlerId); | |
| 5667 SetLayerPropertiesForTesting(child.get(), | |
| 5668 identity_matrix, | |
| 5669 identity_matrix, | |
| 5670 anchor, | |
| 5671 position, | |
| 5672 bounds, | |
| 5673 false); | |
| 5674 child->SetOpacity(0.f); | |
| 5675 child->SetHaveWheelEventHandlers(true); | |
| 5676 root->AddChild(child.Pass()); | |
| 5677 } | |
| 5678 | |
| 5679 LayerImplList render_surface_layer_list; | |
| 5680 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | |
| 5681 root.get(), root->bounds(), &render_surface_layer_list); | |
| 5682 inputs.can_adjust_raster_scales = true; | |
| 5683 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | |
| 5684 | |
| 5685 // Verify that the root layer and zero-opacity layers with touch/wheel | |
| 5686 // handlers (but not the zero-opacity layer without a touch handler) are in | |
| 5687 // the RSSL. | |
| 5688 ASSERT_EQ(1u, render_surface_layer_list.size()); | |
| 5689 EXPECT_EQ(kRootId, render_surface_layer_list[0]->id()); | |
| 5690 ASSERT_EQ(4u, root->render_surface()->layer_list().size()); | |
| 5691 | |
| 5692 EXPECT_EQ(kRootId, root->render_surface()->layer_list().at(0)->id()); | |
| 5693 EXPECT_EQ(kGrandChildWithEventId, | |
| 5694 root->render_surface()->layer_list().at(1)->id()); | |
| 5695 EXPECT_EQ(kTouchHandlerId, root->render_surface()->layer_list().at(2)->id()); | |
| 5696 EXPECT_EQ(kWheelHandlerId, root->render_surface()->layer_list().at(3)->id()); | |
| 5697 | |
| 5698 // Hit testing for a point inside the zero-opacity no-handler layer should | |
| 5699 // return the root layer. | |
| 5700 gfx::Point test_point = gfx::Point(15, 15); | |
| 5701 LayerImpl* result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | |
| 5702 test_point, render_surface_layer_list); | |
| 5703 ASSERT_TRUE(result_layer); | |
| 5704 EXPECT_EQ(kRootId, result_layer->id()); | |
| 5705 | |
| 5706 // Hit testing for a point inside the child of the zero-opacity no-handler | |
| 5707 // layer should return the child layer, since that layer has mousewheel | |
| 5708 // handler. | |
| 5709 test_point = gfx::Point(25, 25); | |
| 5710 result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | |
| 5711 test_point, render_surface_layer_list); | |
| 5712 ASSERT_TRUE(result_layer); | |
| 5713 EXPECT_EQ(kGrandChildWithEventId, result_layer->id()); | |
| 5714 | |
| 5715 // Hit testing for a point inside the touch handler layer should return it. | |
| 5716 test_point = gfx::Point(85, 25); | |
| 5717 result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | |
| 5718 test_point, render_surface_layer_list); | |
| 5719 ASSERT_TRUE(result_layer); | |
| 5720 EXPECT_EQ(kTouchHandlerId, result_layer->id()); | |
| 5721 | |
| 5722 // Hit testing for a point inside the mousewheel layer should return it. | |
| 5723 test_point = gfx::Point(15, 55); | |
| 5724 result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | |
| 5725 test_point, render_surface_layer_list); | |
| 5726 ASSERT_TRUE(result_layer); | |
| 5727 EXPECT_EQ(kWheelHandlerId, result_layer->id()); | |
| 5728 } | |
| 5729 | |
| 5572 TEST_F(LayerTreeHostCommonTest, | 5730 TEST_F(LayerTreeHostCommonTest, |
| 5573 HitCheckingTouchHandlerRegionsForEmptyLayerList) { | 5731 HitCheckingTouchHandlerRegionsForEmptyLayerList) { |
| 5574 // Hit checking on an empty render_surface_layer_list should return a null | 5732 // Hit checking on an empty render_surface_layer_list should return a null |
| 5575 // pointer. | 5733 // pointer. |
| 5576 LayerImplList render_surface_layer_list; | 5734 LayerImplList render_surface_layer_list; |
| 5577 | 5735 |
| 5578 gfx::Point test_point(0, 0); | 5736 gfx::Point test_point(0, 0); |
| 5579 LayerImpl* result_layer = | 5737 LayerImpl* result_layer = |
| 5580 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( | 5738 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( |
| 5581 test_point, render_surface_layer_list); | 5739 test_point, render_surface_layer_list); |
| (...skipping 3551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9133 ExecuteCalculateDrawProperties(root.get()); | 9291 ExecuteCalculateDrawProperties(root.get()); |
| 9134 | 9292 |
| 9135 EXPECT_EQ(1u, render_surface_layer_list()->size()); | 9293 EXPECT_EQ(1u, render_surface_layer_list()->size()); |
| 9136 EXPECT_EQ(0u, | 9294 EXPECT_EQ(0u, |
| 9137 render_surface_layer_list()->at(0) | 9295 render_surface_layer_list()->at(0) |
| 9138 ->render_surface()->layer_list().size()); | 9296 ->render_surface()->layer_list().size()); |
| 9139 } | 9297 } |
| 9140 | 9298 |
| 9141 } // namespace | 9299 } // namespace |
| 9142 } // namespace cc | 9300 } // namespace cc |
| OLD | NEW |