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 18 matching lines...) Expand all Loading... |
29 }; | 29 }; |
30 | 30 |
31 class LayerTreeImplTest : public testing::Test { | 31 class LayerTreeImplTest : public testing::Test { |
32 public: | 32 public: |
33 LayerTreeImplTest() : impl_test_(LayerTreeImplTestSettings()) {} | 33 LayerTreeImplTest() : impl_test_(LayerTreeImplTestSettings()) {} |
34 | 34 |
35 FakeLayerTreeHostImpl& host_impl() const { return *impl_test_.host_impl(); } | 35 FakeLayerTreeHostImpl& host_impl() const { return *impl_test_.host_impl(); } |
36 | 36 |
37 LayerImpl* root_layer() { return impl_test_.root_layer_for_testing(); } | 37 LayerImpl* root_layer() { return impl_test_.root_layer_for_testing(); } |
38 | 38 |
39 const LayerImplList& RenderSurfaceLayerList() const { | 39 const RenderSurfaceList& GetRenderSurfaceList() const { |
40 return host_impl().active_tree()->RenderSurfaceLayerList(); | 40 return host_impl().active_tree()->GetRenderSurfaceList(); |
41 } | 41 } |
42 | 42 |
43 void ExecuteCalculateDrawProperties(LayerImpl* root_layer) { | 43 void ExecuteCalculateDrawProperties(LayerImpl* root_layer) { |
44 // We are probably not testing what is intended if the root_layer bounds are | 44 // We are probably not testing what is intended if the root_layer bounds are |
45 // empty. | 45 // empty. |
46 DCHECK(!root_layer->bounds().IsEmpty()); | 46 DCHECK(!root_layer->bounds().IsEmpty()); |
47 | 47 |
48 render_surface_layer_list_impl_.clear(); | 48 render_surface_list_impl_.clear(); |
49 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 49 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
50 root_layer, root_layer->bounds(), &render_surface_layer_list_impl_); | 50 root_layer, root_layer->bounds(), &render_surface_list_impl_); |
51 inputs.can_adjust_raster_scales = true; | 51 inputs.can_adjust_raster_scales = true; |
52 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); | 52 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); |
53 } | 53 } |
54 | 54 |
55 int HitTestSimpleTree(int root_id, | 55 int HitTestSimpleTree(int root_id, |
56 int left_child_id, | 56 int left_child_id, |
57 int right_child_id, | 57 int right_child_id, |
58 int root_sorting_context, | 58 int root_sorting_context, |
59 int left_child_sorting_context, | 59 int left_child_sorting_context, |
60 int right_child_sorting_context, | 60 int right_child_sorting_context, |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 right_child->SetBounds(bounds); | 98 right_child->SetBounds(bounds); |
99 right_child->SetDrawsContent(true); | 99 right_child->SetDrawsContent(true); |
100 } | 100 } |
101 | 101 |
102 root->test_properties()->AddChild(std::move(left_child)); | 102 root->test_properties()->AddChild(std::move(left_child)); |
103 root->test_properties()->AddChild(std::move(right_child)); | 103 root->test_properties()->AddChild(std::move(right_child)); |
104 | 104 |
105 host_impl().SetViewportSize(root->bounds()); | 105 host_impl().SetViewportSize(root->bounds()); |
106 host_impl().active_tree()->SetRootLayerForTesting(std::move(root)); | 106 host_impl().active_tree()->SetRootLayerForTesting(std::move(root)); |
107 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 107 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
108 CHECK_EQ(1u, RenderSurfaceLayerList().size()); | 108 CHECK_EQ(1u, GetRenderSurfaceList().size()); |
109 | 109 |
110 gfx::PointF test_point = gfx::PointF(1.f, 1.f); | 110 gfx::PointF test_point = gfx::PointF(1.f, 1.f); |
111 LayerImpl* result_layer = | 111 LayerImpl* result_layer = |
112 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 112 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); |
113 | 113 |
114 CHECK(result_layer); | 114 CHECK(result_layer); |
115 return result_layer->id(); | 115 return result_layer->id(); |
116 } | 116 } |
117 | 117 |
118 private: | 118 private: |
119 LayerTestCommon::LayerImplTest impl_test_; | 119 LayerTestCommon::LayerImplTest impl_test_; |
120 std::vector<LayerImpl*> render_surface_layer_list_impl_; | 120 RenderSurfaceList render_surface_list_impl_; |
121 }; | 121 }; |
122 | 122 |
123 TEST_F(LayerTreeImplTest, HitTestingForSingleLayer) { | 123 TEST_F(LayerTreeImplTest, HitTestingForSingleLayer) { |
124 gfx::Size bounds(100, 100); | 124 gfx::Size bounds(100, 100); |
125 LayerImpl* root = root_layer(); | 125 LayerImpl* root = root_layer(); |
126 root->SetBounds(bounds); | 126 root->SetBounds(bounds); |
127 root->SetDrawsContent(true); | 127 root->SetDrawsContent(true); |
128 | 128 |
129 host_impl().SetViewportSize(root->bounds()); | 129 host_impl().SetViewportSize(root->bounds()); |
130 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 130 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
131 | 131 |
132 // Sanity check the scenario we just created. | 132 // Sanity check the scenario we just created. |
133 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 133 ASSERT_EQ(1u, GetRenderSurfaceList().size()); |
134 ASSERT_EQ(1u, root_layer()->GetRenderSurface()->layer_list().size()); | 134 ASSERT_EQ(1, root_layer()->GetRenderSurface()->num_contributors()); |
135 | 135 |
136 // Hit testing for a point outside the layer should return a null pointer. | 136 // Hit testing for a point outside the layer should return a null pointer. |
137 gfx::PointF test_point(101.f, 101.f); | 137 gfx::PointF test_point(101.f, 101.f); |
138 LayerImpl* result_layer = | 138 LayerImpl* result_layer = |
139 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 139 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); |
140 EXPECT_FALSE(result_layer); | 140 EXPECT_FALSE(result_layer); |
141 | 141 |
142 test_point = gfx::PointF(-1.f, -1.f); | 142 test_point = gfx::PointF(-1.f, -1.f); |
143 result_layer = | 143 result_layer = |
144 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 144 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 HeadsUpDisplayLayerImpl::Create(host_impl().active_tree(), 11111); | 192 HeadsUpDisplayLayerImpl::Create(host_impl().active_tree(), 11111); |
193 hud->SetBounds(gfx::Size(200, 200)); | 193 hud->SetBounds(gfx::Size(200, 200)); |
194 hud->SetDrawsContent(true); | 194 hud->SetDrawsContent(true); |
195 | 195 |
196 host_impl().SetViewportSize(hud->bounds()); | 196 host_impl().SetViewportSize(hud->bounds()); |
197 host_impl().active_tree()->set_hud_layer(hud.get()); | 197 host_impl().active_tree()->set_hud_layer(hud.get()); |
198 root->test_properties()->AddChild(std::move(hud)); | 198 root->test_properties()->AddChild(std::move(hud)); |
199 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 199 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
200 | 200 |
201 // Sanity check the scenario we just created. | 201 // Sanity check the scenario we just created. |
202 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 202 ASSERT_EQ(1u, GetRenderSurfaceList().size()); |
203 ASSERT_EQ(2u, root_layer()->GetRenderSurface()->layer_list().size()); | 203 ASSERT_EQ(2, root_layer()->GetRenderSurface()->num_contributors()); |
204 | 204 |
205 // Hit testing for a point inside HUD, but outside root should return null | 205 // Hit testing for a point inside HUD, but outside root should return null |
206 gfx::PointF test_point(101.f, 101.f); | 206 gfx::PointF test_point(101.f, 101.f); |
207 LayerImpl* result_layer = | 207 LayerImpl* result_layer = |
208 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 208 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); |
209 EXPECT_FALSE(result_layer); | 209 EXPECT_FALSE(result_layer); |
210 | 210 |
211 test_point = gfx::PointF(-1.f, -1.f); | 211 test_point = gfx::PointF(-1.f, -1.f); |
212 result_layer = | 212 result_layer = |
213 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 213 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); |
(...skipping 23 matching lines...) Expand all Loading... |
237 ASSERT_FALSE(uninvertible_transform.IsInvertible()); | 237 ASSERT_FALSE(uninvertible_transform.IsInvertible()); |
238 | 238 |
239 LayerImpl* root = root_layer(); | 239 LayerImpl* root = root_layer(); |
240 root->test_properties()->transform = uninvertible_transform; | 240 root->test_properties()->transform = uninvertible_transform; |
241 root->SetBounds(gfx::Size(100, 100)); | 241 root->SetBounds(gfx::Size(100, 100)); |
242 root->SetDrawsContent(true); | 242 root->SetDrawsContent(true); |
243 | 243 |
244 host_impl().SetViewportSize(root->bounds()); | 244 host_impl().SetViewportSize(root->bounds()); |
245 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 245 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
246 // Sanity check the scenario we just created. | 246 // Sanity check the scenario we just created. |
247 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 247 ASSERT_EQ(1u, GetRenderSurfaceList().size()); |
248 ASSERT_EQ(1u, root_layer()->GetRenderSurface()->layer_list().size()); | 248 ASSERT_EQ(1, root_layer()->GetRenderSurface()->num_contributors()); |
249 ASSERT_FALSE(root_layer()->ScreenSpaceTransform().IsInvertible()); | 249 ASSERT_FALSE(root_layer()->ScreenSpaceTransform().IsInvertible()); |
250 | 250 |
251 // Hit testing any point should not hit the layer. If the invertible matrix is | 251 // Hit testing any point should not hit the layer. If the invertible matrix is |
252 // accidentally ignored and treated like an identity, then the hit testing | 252 // accidentally ignored and treated like an identity, then the hit testing |
253 // will incorrectly hit the layer when it shouldn't. | 253 // will incorrectly hit the layer when it shouldn't. |
254 gfx::PointF test_point(1.f, 1.f); | 254 gfx::PointF test_point(1.f, 1.f); |
255 LayerImpl* result_layer = | 255 LayerImpl* result_layer = |
256 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 256 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); |
257 EXPECT_FALSE(result_layer); | 257 EXPECT_FALSE(result_layer); |
258 | 258 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 // layer is located. | 292 // layer is located. |
293 LayerImpl* root = root_layer(); | 293 LayerImpl* root = root_layer(); |
294 root->SetPosition(gfx::PointF(50.f, 50.f)); | 294 root->SetPosition(gfx::PointF(50.f, 50.f)); |
295 root->SetBounds(gfx::Size(100, 100)); | 295 root->SetBounds(gfx::Size(100, 100)); |
296 root->SetDrawsContent(true); | 296 root->SetDrawsContent(true); |
297 | 297 |
298 host_impl().SetViewportSize(root->bounds()); | 298 host_impl().SetViewportSize(root->bounds()); |
299 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 299 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
300 | 300 |
301 // Sanity check the scenario we just created. | 301 // Sanity check the scenario we just created. |
302 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 302 ASSERT_EQ(1u, GetRenderSurfaceList().size()); |
303 ASSERT_EQ(1u, root_layer()->GetRenderSurface()->layer_list().size()); | 303 ASSERT_EQ(1, root_layer()->GetRenderSurface()->num_contributors()); |
304 | 304 |
305 // Hit testing for a point outside the layer should return a null pointer. | 305 // Hit testing for a point outside the layer should return a null pointer. |
306 gfx::PointF test_point(49.f, 49.f); | 306 gfx::PointF test_point(49.f, 49.f); |
307 LayerImpl* result_layer = | 307 LayerImpl* result_layer = |
308 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 308 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); |
309 EXPECT_FALSE(result_layer); | 309 EXPECT_FALSE(result_layer); |
310 | 310 |
311 // Even though the layer exists at (101, 101), it should not be visible there | 311 // Even though the layer exists at (101, 101), it should not be visible there |
312 // since the root render surface would clamp it. | 312 // since the root render surface would clamp it. |
313 test_point = gfx::PointF(101.f, 101.f); | 313 test_point = gfx::PointF(101.f, 101.f); |
(...skipping 23 matching lines...) Expand all Loading... |
337 | 337 |
338 LayerImpl* root = root_layer(); | 338 LayerImpl* root = root_layer(); |
339 root->test_properties()->transform = rotation45_degrees_about_center; | 339 root->test_properties()->transform = rotation45_degrees_about_center; |
340 root->SetBounds(gfx::Size(100, 100)); | 340 root->SetBounds(gfx::Size(100, 100)); |
341 root->SetDrawsContent(true); | 341 root->SetDrawsContent(true); |
342 | 342 |
343 host_impl().SetViewportSize(root->bounds()); | 343 host_impl().SetViewportSize(root->bounds()); |
344 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 344 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
345 | 345 |
346 // Sanity check the scenario we just created. | 346 // Sanity check the scenario we just created. |
347 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 347 ASSERT_EQ(1u, GetRenderSurfaceList().size()); |
348 ASSERT_EQ(1u, root_layer()->GetRenderSurface()->layer_list().size()); | 348 ASSERT_EQ(1, root_layer()->GetRenderSurface()->num_contributors()); |
349 | 349 |
350 // Hit testing for points outside the layer. | 350 // Hit testing for points outside the layer. |
351 // These corners would have been inside the un-transformed layer, but they | 351 // These corners would have been inside the un-transformed layer, but they |
352 // should not hit the correctly transformed layer. | 352 // should not hit the correctly transformed layer. |
353 gfx::PointF test_point(99.f, 99.f); | 353 gfx::PointF test_point(99.f, 99.f); |
354 LayerImpl* result_layer = | 354 LayerImpl* result_layer = |
355 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 355 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); |
356 EXPECT_FALSE(result_layer); | 356 EXPECT_FALSE(result_layer); |
357 | 357 |
358 test_point = gfx::PointF(1.f, 1.f); | 358 test_point = gfx::PointF(1.f, 1.f); |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
505 LayerImpl* root = root_layer(); | 505 LayerImpl* root = root_layer(); |
506 root->test_properties()->transform = | 506 root->test_properties()->transform = |
507 (perspective_projection_about_center * translation_by_z); | 507 (perspective_projection_about_center * translation_by_z); |
508 root->SetBounds(gfx::Size(100, 100)); | 508 root->SetBounds(gfx::Size(100, 100)); |
509 root->SetDrawsContent(true); | 509 root->SetDrawsContent(true); |
510 | 510 |
511 host_impl().SetViewportSize(root->bounds()); | 511 host_impl().SetViewportSize(root->bounds()); |
512 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 512 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
513 | 513 |
514 // Sanity check the scenario we just created. | 514 // Sanity check the scenario we just created. |
515 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 515 ASSERT_EQ(1u, GetRenderSurfaceList().size()); |
516 ASSERT_EQ(1u, root_layer()->GetRenderSurface()->layer_list().size()); | 516 ASSERT_EQ(1, root_layer()->GetRenderSurface()->num_contributors()); |
517 | 517 |
518 // Hit testing for points outside the layer. | 518 // Hit testing for points outside the layer. |
519 // These corners would have been inside the un-transformed layer, but they | 519 // These corners would have been inside the un-transformed layer, but they |
520 // should not hit the correctly transformed layer. | 520 // should not hit the correctly transformed layer. |
521 gfx::PointF test_point(24.f, 24.f); | 521 gfx::PointF test_point(24.f, 24.f); |
522 LayerImpl* result_layer = | 522 LayerImpl* result_layer = |
523 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 523 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); |
524 EXPECT_FALSE(result_layer); | 524 EXPECT_FALSE(result_layer); |
525 | 525 |
526 test_point = gfx::PointF(76.f, 76.f); | 526 test_point = gfx::PointF(76.f, 76.f); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
563 child->SetBounds(gfx::Size(300, 300)); | 563 child->SetBounds(gfx::Size(300, 300)); |
564 child->SetDrawsContent(true); | 564 child->SetDrawsContent(true); |
565 clipping_layer->test_properties()->AddChild(std::move(child)); | 565 clipping_layer->test_properties()->AddChild(std::move(child)); |
566 root->test_properties()->AddChild(std::move(clipping_layer)); | 566 root->test_properties()->AddChild(std::move(clipping_layer)); |
567 } | 567 } |
568 | 568 |
569 host_impl().SetViewportSize(root->bounds()); | 569 host_impl().SetViewportSize(root->bounds()); |
570 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 570 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
571 | 571 |
572 // Sanity check the scenario we just created. | 572 // Sanity check the scenario we just created. |
573 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 573 ASSERT_EQ(1u, GetRenderSurfaceList().size()); |
574 ASSERT_EQ(1u, root_layer()->GetRenderSurface()->layer_list().size()); | 574 ASSERT_EQ(1, root_layer()->GetRenderSurface()->num_contributors()); |
575 ASSERT_EQ(456, root_layer()->GetRenderSurface()->layer_list().at(0)->id()); | 575 LayerImpl* child_layer = host_impl().active_tree()->LayerById(456); |
| 576 EXPECT_TRUE(child_layer->is_drawn_render_surface_layer_list_member()); |
576 | 577 |
577 // Hit testing for a point outside the layer should return a null pointer. | 578 // Hit testing for a point outside the layer should return a null pointer. |
578 // Despite the child layer being very large, it should be clipped to the root | 579 // Despite the child layer being very large, it should be clipped to the root |
579 // layer's bounds. | 580 // layer's bounds. |
580 gfx::PointF test_point(24.f, 24.f); | 581 gfx::PointF test_point(24.f, 24.f); |
581 LayerImpl* result_layer = | 582 LayerImpl* result_layer = |
582 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 583 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); |
583 EXPECT_FALSE(result_layer); | 584 EXPECT_FALSE(result_layer); |
584 | 585 |
585 // Even though the layer exists at (101, 101), it should not be visible there | 586 // Even though the layer exists at (101, 101), it should not be visible there |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
740 child->SetBounds(gfx::Size(20, 20)); | 741 child->SetBounds(gfx::Size(20, 20)); |
741 child->SetDrawsContent(true); | 742 child->SetDrawsContent(true); |
742 intermediate_layer->test_properties()->AddChild(std::move(child)); | 743 intermediate_layer->test_properties()->AddChild(std::move(child)); |
743 root->test_properties()->AddChild(std::move(intermediate_layer)); | 744 root->test_properties()->AddChild(std::move(intermediate_layer)); |
744 } | 745 } |
745 | 746 |
746 host_impl().SetViewportSize(root->bounds()); | 747 host_impl().SetViewportSize(root->bounds()); |
747 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 748 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
748 | 749 |
749 // Sanity check the scenario we just created. | 750 // Sanity check the scenario we just created. |
750 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 751 ASSERT_EQ(1u, GetRenderSurfaceList().size()); |
751 ASSERT_EQ(1u, root_layer()->GetRenderSurface()->layer_list().size()); | 752 ASSERT_EQ(1, root_layer()->GetRenderSurface()->num_contributors()); |
752 ASSERT_EQ(456, root_layer()->GetRenderSurface()->layer_list().at(0)->id()); | 753 LayerImpl* child_layer = host_impl().active_tree()->LayerById(456); |
| 754 EXPECT_TRUE(child_layer->is_drawn_render_surface_layer_list_member()); |
753 | 755 |
754 // Hit testing for a point outside the layer should return a null pointer. | 756 // Hit testing for a point outside the layer should return a null pointer. |
755 gfx::PointF test_point(69.f, 69.f); | 757 gfx::PointF test_point(69.f, 69.f); |
756 LayerImpl* result_layer = | 758 LayerImpl* result_layer = |
757 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 759 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); |
758 EXPECT_FALSE(result_layer); | 760 EXPECT_FALSE(result_layer); |
759 | 761 |
760 test_point = gfx::PointF(91.f, 91.f); | 762 test_point = gfx::PointF(91.f, 91.f); |
761 result_layer = | 763 result_layer = |
762 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 764 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
820 LayerImpl* child2 = root->test_properties()->children[1]; | 822 LayerImpl* child2 = root->test_properties()->children[1]; |
821 LayerImpl* grand_child1 = child1->test_properties()->children[0]; | 823 LayerImpl* grand_child1 = child1->test_properties()->children[0]; |
822 | 824 |
823 host_impl().SetViewportSize(root->bounds()); | 825 host_impl().SetViewportSize(root->bounds()); |
824 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 826 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
825 | 827 |
826 // Sanity check the scenario we just created. | 828 // Sanity check the scenario we just created. |
827 ASSERT_TRUE(child1); | 829 ASSERT_TRUE(child1); |
828 ASSERT_TRUE(child2); | 830 ASSERT_TRUE(child2); |
829 ASSERT_TRUE(grand_child1); | 831 ASSERT_TRUE(grand_child1); |
830 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 832 ASSERT_EQ(1u, GetRenderSurfaceList().size()); |
831 | 833 |
832 RenderSurfaceImpl* root_render_surface = root->GetRenderSurface(); | 834 RenderSurfaceImpl* root_render_surface = root->GetRenderSurface(); |
833 ASSERT_EQ(4u, root_render_surface->layer_list().size()); | 835 ASSERT_EQ(4, root_render_surface->num_contributors()); |
834 ASSERT_EQ(1, root_render_surface->layer_list().at(0)->id()); // root layer | 836 EXPECT_TRUE(root_layer()->is_drawn_render_surface_layer_list_member()); |
835 ASSERT_EQ(2, root_render_surface->layer_list().at(1)->id()); // child1 | 837 EXPECT_TRUE(child1->is_drawn_render_surface_layer_list_member()); |
836 ASSERT_EQ(4, root_render_surface->layer_list().at(2)->id()); // grand_child1 | 838 EXPECT_TRUE(child2->is_drawn_render_surface_layer_list_member()); |
837 ASSERT_EQ(3, root_render_surface->layer_list().at(3)->id()); // child2 | 839 EXPECT_TRUE(grand_child1->is_drawn_render_surface_layer_list_member()); |
838 | 840 |
839 // Nothing overlaps the root at (1, 1), so hit testing there should find | 841 // Nothing overlaps the root at (1, 1), so hit testing there should find |
840 // the root layer. | 842 // the root layer. |
841 gfx::PointF test_point = gfx::PointF(1.f, 1.f); | 843 gfx::PointF test_point = gfx::PointF(1.f, 1.f); |
842 LayerImpl* result_layer = | 844 LayerImpl* result_layer = |
843 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 845 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); |
844 ASSERT_TRUE(result_layer); | 846 ASSERT_TRUE(result_layer); |
845 EXPECT_EQ(1, result_layer->id()); | 847 EXPECT_EQ(1, result_layer->id()); |
846 | 848 |
847 // At (15, 15), child1 and root are the only layers. child1 is expected to be | 849 // At (15, 15), child1 and root are the only layers. child1 is expected to be |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
972 LayerImpl* child2 = root->test_properties()->children[1]; | 974 LayerImpl* child2 = root->test_properties()->children[1]; |
973 LayerImpl* grand_child1 = child1->test_properties()->children[0]; | 975 LayerImpl* grand_child1 = child1->test_properties()->children[0]; |
974 | 976 |
975 host_impl().SetViewportSize(root->bounds()); | 977 host_impl().SetViewportSize(root->bounds()); |
976 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 978 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
977 | 979 |
978 // Sanity check the scenario we just created. | 980 // Sanity check the scenario we just created. |
979 ASSERT_TRUE(child1); | 981 ASSERT_TRUE(child1); |
980 ASSERT_TRUE(child2); | 982 ASSERT_TRUE(child2); |
981 ASSERT_TRUE(grand_child1); | 983 ASSERT_TRUE(grand_child1); |
982 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 984 ASSERT_EQ(1u, GetRenderSurfaceList().size()); |
983 | 985 |
984 // Nothing overlaps the root_layer at (1, 1), so hit testing there should find | 986 // Nothing overlaps the root_layer at (1, 1), so hit testing there should find |
985 // the root layer. | 987 // the root layer. |
986 gfx::PointF test_point = gfx::PointF(1.f, 1.f); | 988 gfx::PointF test_point = gfx::PointF(1.f, 1.f); |
987 LayerImpl* result_layer = | 989 LayerImpl* result_layer = |
988 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 990 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); |
989 ASSERT_TRUE(result_layer); | 991 ASSERT_TRUE(result_layer); |
990 EXPECT_EQ(1, result_layer->id()); | 992 EXPECT_EQ(1, result_layer->id()); |
991 | 993 |
992 // At (15, 15), child1 and root are the only layers. child1 is expected to be | 994 // At (15, 15), child1 and root are the only layers. child1 is expected to be |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1172 host_impl().SetViewportSize(root->bounds()); | 1174 host_impl().SetViewportSize(root->bounds()); |
1173 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 1175 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
1174 | 1176 |
1175 // Sanity check the scenario we just created. | 1177 // Sanity check the scenario we just created. |
1176 ASSERT_TRUE(child1); | 1178 ASSERT_TRUE(child1); |
1177 ASSERT_TRUE(child2); | 1179 ASSERT_TRUE(child2); |
1178 ASSERT_TRUE(grand_child1); | 1180 ASSERT_TRUE(grand_child1); |
1179 ASSERT_TRUE(child1->GetRenderSurface()); | 1181 ASSERT_TRUE(child1->GetRenderSurface()); |
1180 ASSERT_TRUE(child2->GetRenderSurface()); | 1182 ASSERT_TRUE(child2->GetRenderSurface()); |
1181 ASSERT_TRUE(grand_child1->GetRenderSurface()); | 1183 ASSERT_TRUE(grand_child1->GetRenderSurface()); |
1182 ASSERT_EQ(4u, RenderSurfaceLayerList().size()); | 1184 ASSERT_EQ(4u, GetRenderSurfaceList().size()); |
1183 // The root surface has the root layer, and child1's and child2's render | 1185 // The root surface has the root layer, and child1's and child2's render |
1184 // surfaces. | 1186 // surfaces. |
1185 ASSERT_EQ(3u, root->GetRenderSurface()->layer_list().size()); | 1187 ASSERT_EQ(3, root->GetRenderSurface()->num_contributors()); |
1186 // The child1 surface has the child1 layer and grand_child1's render surface. | 1188 // The child1 surface has the child1 layer and grand_child1's render surface. |
1187 ASSERT_EQ(2u, child1->GetRenderSurface()->layer_list().size()); | 1189 ASSERT_EQ(2, child1->GetRenderSurface()->num_contributors()); |
1188 ASSERT_EQ(1u, child2->GetRenderSurface()->layer_list().size()); | 1190 ASSERT_EQ(1, child2->GetRenderSurface()->num_contributors()); |
1189 ASSERT_EQ(1u, grand_child1->GetRenderSurface()->layer_list().size()); | 1191 ASSERT_EQ(1, grand_child1->GetRenderSurface()->num_contributors()); |
1190 ASSERT_EQ(1, RenderSurfaceLayerList().at(0)->id()); // root layer | 1192 EXPECT_TRUE(root_layer()->is_drawn_render_surface_layer_list_member()); |
1191 ASSERT_EQ(2, RenderSurfaceLayerList()[1]->id()); // child1 | 1193 EXPECT_TRUE(child1->is_drawn_render_surface_layer_list_member()); |
1192 ASSERT_EQ(4, RenderSurfaceLayerList().at(2)->id()); // grand_child1 | 1194 EXPECT_TRUE(grand_child1->is_drawn_render_surface_layer_list_member()); |
1193 ASSERT_EQ(3, RenderSurfaceLayerList()[3]->id()); // child2 | 1195 EXPECT_TRUE(child2->is_drawn_render_surface_layer_list_member()); |
1194 | 1196 |
1195 // Nothing overlaps the root at (1, 1), so hit testing there should find | 1197 // Nothing overlaps the root at (1, 1), so hit testing there should find |
1196 // the root layer. | 1198 // the root layer. |
1197 gfx::PointF test_point(1.f, 1.f); | 1199 gfx::PointF test_point(1.f, 1.f); |
1198 LayerImpl* result_layer = | 1200 LayerImpl* result_layer = |
1199 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 1201 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); |
1200 ASSERT_TRUE(result_layer); | 1202 ASSERT_TRUE(result_layer); |
1201 EXPECT_EQ(1, result_layer->id()); | 1203 EXPECT_EQ(1, result_layer->id()); |
1202 | 1204 |
1203 // At (15, 15), child1 and root are the only layers. child1 is expected to be | 1205 // At (15, 15), child1 and root are the only layers. child1 is expected to be |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1244 Region touch_handler_region(gfx::Rect(10, 10, 50, 50)); | 1246 Region touch_handler_region(gfx::Rect(10, 10, 50, 50)); |
1245 | 1247 |
1246 LayerImpl* root = root_layer(); | 1248 LayerImpl* root = root_layer(); |
1247 root->SetBounds(gfx::Size(100, 100)); | 1249 root->SetBounds(gfx::Size(100, 100)); |
1248 root->SetDrawsContent(true); | 1250 root->SetDrawsContent(true); |
1249 | 1251 |
1250 host_impl().SetViewportSize(root->bounds()); | 1252 host_impl().SetViewportSize(root->bounds()); |
1251 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 1253 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
1252 | 1254 |
1253 // Sanity check the scenario we just created. | 1255 // Sanity check the scenario we just created. |
1254 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 1256 ASSERT_EQ(1u, GetRenderSurfaceList().size()); |
1255 ASSERT_EQ(1u, root->GetRenderSurface()->layer_list().size()); | 1257 ASSERT_EQ(1, root->GetRenderSurface()->num_contributors()); |
1256 | 1258 |
1257 // Hit checking for any point should return a null pointer for a layer without | 1259 // Hit checking for any point should return a null pointer for a layer without |
1258 // any touch event handler regions. | 1260 // any touch event handler regions. |
1259 gfx::PointF test_point(11.f, 11.f); | 1261 gfx::PointF test_point(11.f, 11.f); |
1260 LayerImpl* result_layer = | 1262 LayerImpl* result_layer = |
1261 host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 1263 host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( |
1262 test_point); | 1264 test_point); |
1263 EXPECT_FALSE(result_layer); | 1265 EXPECT_FALSE(result_layer); |
1264 | 1266 |
1265 root->SetTouchEventHandlerRegion(touch_handler_region); | 1267 root->SetTouchEventHandlerRegion(touch_handler_region); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1321 LayerImpl* root = root_layer(); | 1323 LayerImpl* root = root_layer(); |
1322 root->test_properties()->transform = uninvertible_transform; | 1324 root->test_properties()->transform = uninvertible_transform; |
1323 root->SetBounds(gfx::Size(100, 100)); | 1325 root->SetBounds(gfx::Size(100, 100)); |
1324 root->SetDrawsContent(true); | 1326 root->SetDrawsContent(true); |
1325 root->SetTouchEventHandlerRegion(touch_handler_region); | 1327 root->SetTouchEventHandlerRegion(touch_handler_region); |
1326 | 1328 |
1327 host_impl().SetViewportSize(root->bounds()); | 1329 host_impl().SetViewportSize(root->bounds()); |
1328 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 1330 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
1329 | 1331 |
1330 // Sanity check the scenario we just created. | 1332 // Sanity check the scenario we just created. |
1331 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 1333 ASSERT_EQ(1u, GetRenderSurfaceList().size()); |
1332 ASSERT_EQ(1u, root->GetRenderSurface()->layer_list().size()); | 1334 ASSERT_EQ(1, root->GetRenderSurface()->num_contributors()); |
1333 ASSERT_FALSE(root->ScreenSpaceTransform().IsInvertible()); | 1335 ASSERT_FALSE(root->ScreenSpaceTransform().IsInvertible()); |
1334 | 1336 |
1335 // Hit checking any point should not hit the touch handler region on the | 1337 // Hit checking any point should not hit the touch handler region on the |
1336 // layer. If the invertible matrix is accidentally ignored and treated like an | 1338 // layer. If the invertible matrix is accidentally ignored and treated like an |
1337 // identity, then the hit testing will incorrectly hit the layer when it | 1339 // identity, then the hit testing will incorrectly hit the layer when it |
1338 // shouldn't. | 1340 // shouldn't. |
1339 gfx::PointF test_point(1.f, 1.f); | 1341 gfx::PointF test_point(1.f, 1.f); |
1340 LayerImpl* result_layer = | 1342 LayerImpl* result_layer = |
1341 host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 1343 host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( |
1342 test_point); | 1344 test_point); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1388 LayerImpl* root = root_layer(); | 1390 LayerImpl* root = root_layer(); |
1389 root->SetPosition(gfx::PointF(50.f, 50.f)); | 1391 root->SetPosition(gfx::PointF(50.f, 50.f)); |
1390 root->SetBounds(gfx::Size(100, 100)); | 1392 root->SetBounds(gfx::Size(100, 100)); |
1391 root->SetDrawsContent(true); | 1393 root->SetDrawsContent(true); |
1392 root->SetTouchEventHandlerRegion(touch_handler_region); | 1394 root->SetTouchEventHandlerRegion(touch_handler_region); |
1393 | 1395 |
1394 host_impl().SetViewportSize(root->bounds()); | 1396 host_impl().SetViewportSize(root->bounds()); |
1395 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 1397 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
1396 | 1398 |
1397 // Sanity check the scenario we just created. | 1399 // Sanity check the scenario we just created. |
1398 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 1400 ASSERT_EQ(1u, GetRenderSurfaceList().size()); |
1399 ASSERT_EQ(1u, root->GetRenderSurface()->layer_list().size()); | 1401 ASSERT_EQ(1, root->GetRenderSurface()->num_contributors()); |
1400 | 1402 |
1401 // Hit checking for a point outside the layer should return a null pointer. | 1403 // Hit checking for a point outside the layer should return a null pointer. |
1402 gfx::PointF test_point(49.f, 49.f); | 1404 gfx::PointF test_point(49.f, 49.f); |
1403 LayerImpl* result_layer = | 1405 LayerImpl* result_layer = |
1404 host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 1406 host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( |
1405 test_point); | 1407 test_point); |
1406 EXPECT_FALSE(result_layer); | 1408 EXPECT_FALSE(result_layer); |
1407 | 1409 |
1408 // Even though the layer has a touch handler region containing (101, 101), it | 1410 // Even though the layer has a touch handler region containing (101, 101), it |
1409 // should not be visible there since the root render surface would clamp it. | 1411 // should not be visible there since the root render surface would clamp it. |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1473 host_impl().active_tree()->BuildLayerListAndPropertyTreesForTesting(); | 1475 host_impl().active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
1474 host_impl().active_tree()->PushPageScaleFromMainThread( | 1476 host_impl().active_tree()->PushPageScaleFromMainThread( |
1475 page_scale_factor, page_scale_factor, max_page_scale_factor); | 1477 page_scale_factor, page_scale_factor, max_page_scale_factor); |
1476 host_impl().active_tree()->SetPageScaleOnActiveTree(page_scale_factor); | 1478 host_impl().active_tree()->SetPageScaleOnActiveTree(page_scale_factor); |
1477 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 1479 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
1478 | 1480 |
1479 // Sanity check the scenario we just created. | 1481 // Sanity check the scenario we just created. |
1480 // The visible content rect for test_layer is actually 100x100, even though | 1482 // The visible content rect for test_layer is actually 100x100, even though |
1481 // its layout size is 50x50, positioned at 25x25. | 1483 // its layout size is 50x50, positioned at 25x25. |
1482 LayerImpl* test_layer = root->test_properties()->children[0]; | 1484 LayerImpl* test_layer = root->test_properties()->children[0]; |
1483 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 1485 ASSERT_EQ(1u, GetRenderSurfaceList().size()); |
1484 ASSERT_EQ(1u, root->GetRenderSurface()->layer_list().size()); | 1486 ASSERT_EQ(1, root->GetRenderSurface()->num_contributors()); |
1485 | 1487 |
1486 // Check whether the child layer fits into the root after scaled. | 1488 // Check whether the child layer fits into the root after scaled. |
1487 EXPECT_EQ(gfx::Rect(test_layer->bounds()), test_layer->visible_layer_rect()); | 1489 EXPECT_EQ(gfx::Rect(test_layer->bounds()), test_layer->visible_layer_rect()); |
1488 | 1490 |
1489 // Hit checking for a point outside the layer should return a null pointer | 1491 // Hit checking for a point outside the layer should return a null pointer |
1490 // (the root layer does not have a touch event handler, so it will not be | 1492 // (the root layer does not have a touch event handler, so it will not be |
1491 // tested either). | 1493 // tested either). |
1492 gfx::PointF test_point(76.f, 76.f); | 1494 gfx::PointF test_point(76.f, 76.f); |
1493 test_point = | 1495 test_point = |
1494 gfx::ScalePoint(test_point, device_scale_factor * page_scale_factor); | 1496 gfx::ScalePoint(test_point, device_scale_factor * page_scale_factor); |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1600 child->SetDrawsContent(true); | 1602 child->SetDrawsContent(true); |
1601 child->SetTouchEventHandlerRegion(touch_handler_region); | 1603 child->SetTouchEventHandlerRegion(touch_handler_region); |
1602 clipping_layer->test_properties()->AddChild(std::move(child)); | 1604 clipping_layer->test_properties()->AddChild(std::move(child)); |
1603 root->test_properties()->AddChild(std::move(clipping_layer)); | 1605 root->test_properties()->AddChild(std::move(clipping_layer)); |
1604 } | 1606 } |
1605 | 1607 |
1606 host_impl().SetViewportSize(root->bounds()); | 1608 host_impl().SetViewportSize(root->bounds()); |
1607 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 1609 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
1608 | 1610 |
1609 // Sanity check the scenario we just created. | 1611 // Sanity check the scenario we just created. |
1610 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 1612 ASSERT_EQ(1u, GetRenderSurfaceList().size()); |
1611 ASSERT_EQ(1u, root->GetRenderSurface()->layer_list().size()); | 1613 ASSERT_EQ(1, root->GetRenderSurface()->num_contributors()); |
1612 ASSERT_EQ(456, root->GetRenderSurface()->layer_list().at(0)->id()); | 1614 LayerImpl* child_layer = host_impl().active_tree()->LayerById(456); |
| 1615 EXPECT_TRUE(child_layer->is_drawn_render_surface_layer_list_member()); |
1613 | 1616 |
1614 // Hit checking for a point outside the layer should return a null pointer. | 1617 // Hit checking for a point outside the layer should return a null pointer. |
1615 // Despite the child layer being very large, it should be clipped to the root | 1618 // Despite the child layer being very large, it should be clipped to the root |
1616 // layer's bounds. | 1619 // layer's bounds. |
1617 gfx::PointF test_point(24.f, 24.f); | 1620 gfx::PointF test_point(24.f, 24.f); |
1618 LayerImpl* result_layer = | 1621 LayerImpl* result_layer = |
1619 host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 1622 host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( |
1620 test_point); | 1623 test_point); |
1621 EXPECT_FALSE(result_layer); | 1624 EXPECT_FALSE(result_layer); |
1622 | 1625 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1696 host_impl().active_tree()->SetDeviceScaleFactor(device_scale_factor); | 1699 host_impl().active_tree()->SetDeviceScaleFactor(device_scale_factor); |
1697 host_impl().active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 1, | 1700 host_impl().active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 1, |
1698 Layer::INVALID_ID); | 1701 Layer::INVALID_ID); |
1699 host_impl().active_tree()->BuildLayerListAndPropertyTreesForTesting(); | 1702 host_impl().active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
1700 host_impl().active_tree()->PushPageScaleFromMainThread( | 1703 host_impl().active_tree()->PushPageScaleFromMainThread( |
1701 page_scale_factor, page_scale_factor, max_page_scale_factor); | 1704 page_scale_factor, page_scale_factor, max_page_scale_factor); |
1702 host_impl().active_tree()->SetPageScaleOnActiveTree(page_scale_factor); | 1705 host_impl().active_tree()->SetPageScaleOnActiveTree(page_scale_factor); |
1703 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 1706 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
1704 | 1707 |
1705 // Sanity check the scenario we just created. | 1708 // Sanity check the scenario we just created. |
1706 ASSERT_EQ(2u, RenderSurfaceLayerList().size()); | 1709 ASSERT_EQ(2u, GetRenderSurfaceList().size()); |
1707 | 1710 |
1708 // Hit checking for a point outside the layer should return a null pointer. | 1711 // Hit checking for a point outside the layer should return a null pointer. |
1709 // Despite the child layer being very large, it should be clipped to the root | 1712 // Despite the child layer being very large, it should be clipped to the root |
1710 // layer's bounds. | 1713 // layer's bounds. |
1711 gfx::PointF test_point(24.f, 24.f); | 1714 gfx::PointF test_point(24.f, 24.f); |
1712 test_point = | 1715 test_point = |
1713 gfx::ScalePoint(test_point, device_scale_factor * page_scale_factor); | 1716 gfx::ScalePoint(test_point, device_scale_factor * page_scale_factor); |
1714 LayerImpl* result_layer = | 1717 LayerImpl* result_layer = |
1715 host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 1718 host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( |
1716 test_point); | 1719 test_point); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1753 notouch_layer->SetPosition(gfx::PointF(0, 25)); | 1756 notouch_layer->SetPosition(gfx::PointF(0, 25)); |
1754 notouch_layer->SetBounds(gfx::Size(50, 50)); | 1757 notouch_layer->SetBounds(gfx::Size(50, 50)); |
1755 notouch_layer->SetDrawsContent(true); | 1758 notouch_layer->SetDrawsContent(true); |
1756 root->test_properties()->AddChild(std::move(notouch_layer)); | 1759 root->test_properties()->AddChild(std::move(notouch_layer)); |
1757 } | 1760 } |
1758 | 1761 |
1759 host_impl().SetViewportSize(root->bounds()); | 1762 host_impl().SetViewportSize(root->bounds()); |
1760 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 1763 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
1761 | 1764 |
1762 // Sanity check the scenario we just created. | 1765 // Sanity check the scenario we just created. |
1763 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 1766 ASSERT_EQ(1u, GetRenderSurfaceList().size()); |
1764 ASSERT_EQ(2u, root->GetRenderSurface()->layer_list().size()); | 1767 ASSERT_EQ(2, root->GetRenderSurface()->num_contributors()); |
1765 ASSERT_EQ(123, root->GetRenderSurface()->layer_list().at(0)->id()); | 1768 LayerImpl* touch_layer = host_impl().active_tree()->LayerById(123); |
1766 ASSERT_EQ(1234, root->GetRenderSurface()->layer_list().at(1)->id()); | 1769 LayerImpl* notouch_layer = host_impl().active_tree()->LayerById(1234); |
| 1770 EXPECT_TRUE(touch_layer->is_drawn_render_surface_layer_list_member()); |
| 1771 EXPECT_TRUE(notouch_layer->is_drawn_render_surface_layer_list_member()); |
1767 | 1772 |
1768 gfx::PointF test_point(35.f, 35.f); | 1773 gfx::PointF test_point(35.f, 35.f); |
1769 LayerImpl* result_layer = | 1774 LayerImpl* result_layer = |
1770 host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 1775 host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( |
1771 test_point); | 1776 test_point); |
1772 | 1777 |
1773 // We should have passed through the no-touch layer and found the layer | 1778 // We should have passed through the no-touch layer and found the layer |
1774 // behind it. | 1779 // behind it. |
1775 EXPECT_TRUE(result_layer); | 1780 EXPECT_TRUE(result_layer); |
1776 | 1781 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1809 LayerImpl::Create(host_impl().active_tree(), 12345); | 1814 LayerImpl::Create(host_impl().active_tree(), 12345); |
1810 test_layer->SetBounds(gfx::Size(50, 50)); | 1815 test_layer->SetBounds(gfx::Size(50, 50)); |
1811 test_layer->SetDrawsContent(false); | 1816 test_layer->SetDrawsContent(false); |
1812 test_layer->SetTouchEventHandlerRegion(touch_handler_region); | 1817 test_layer->SetTouchEventHandlerRegion(touch_handler_region); |
1813 root->test_properties()->AddChild(std::move(test_layer)); | 1818 root->test_properties()->AddChild(std::move(test_layer)); |
1814 } | 1819 } |
1815 host_impl().SetViewportSize(root->bounds()); | 1820 host_impl().SetViewportSize(root->bounds()); |
1816 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 1821 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
1817 | 1822 |
1818 LayerImpl* test_layer = root->test_properties()->children[0]; | 1823 LayerImpl* test_layer = root->test_properties()->children[0]; |
1819 // As test_layer doesn't draw content, the layer list of root's render surface | 1824 // As test_layer doesn't draw content, it shouldn't contribute content to the |
1820 // should contain only the root layer. | 1825 // root surface. |
1821 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 1826 ASSERT_EQ(1u, GetRenderSurfaceList().size()); |
1822 ASSERT_EQ(1u, root->GetRenderSurface()->layer_list().size()); | 1827 EXPECT_FALSE(test_layer->is_drawn_render_surface_layer_list_member()); |
1823 | 1828 |
1824 // Hit testing for a point outside the test layer should return null pointer. | 1829 // Hit testing for a point outside the test layer should return null pointer. |
1825 // We also implicitly check that the updated screen space transform of a layer | 1830 // We also implicitly check that the updated screen space transform of a layer |
1826 // that is not in drawn render surface layer list (test_layer) is used during | 1831 // that is not in drawn render surface layer list (test_layer) is used during |
1827 // hit testing (becuase the point is inside test_layer with respect to the old | 1832 // hit testing (becuase the point is inside test_layer with respect to the old |
1828 // screen space transform). | 1833 // screen space transform). |
1829 gfx::PointF test_point(24.f, 24.f); | 1834 gfx::PointF test_point(24.f, 24.f); |
1830 test_layer->SetPosition(gfx::PointF(25.f, 25.f)); | 1835 test_layer->SetPosition(gfx::PointF(25.f, 25.f)); |
1831 gfx::Transform expected_screen_space_transform; | 1836 gfx::Transform expected_screen_space_transform; |
1832 expected_screen_space_transform.Translate(25.f, 25.f); | 1837 expected_screen_space_transform.Translate(25.f, 25.f); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1869 | 1874 |
1870 TEST_F(LayerTreeImplTest, SelectionBoundsForSingleLayer) { | 1875 TEST_F(LayerTreeImplTest, SelectionBoundsForSingleLayer) { |
1871 LayerImpl* root = root_layer(); | 1876 LayerImpl* root = root_layer(); |
1872 root->SetBounds(gfx::Size(100, 100)); | 1877 root->SetBounds(gfx::Size(100, 100)); |
1873 root->SetDrawsContent(true); | 1878 root->SetDrawsContent(true); |
1874 | 1879 |
1875 host_impl().SetViewportSize(root->bounds()); | 1880 host_impl().SetViewportSize(root->bounds()); |
1876 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 1881 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
1877 | 1882 |
1878 // Sanity check the scenario we just created. | 1883 // Sanity check the scenario we just created. |
1879 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 1884 ASSERT_EQ(1u, GetRenderSurfaceList().size()); |
1880 ASSERT_EQ(1u, root->GetRenderSurface()->layer_list().size()); | 1885 ASSERT_EQ(1, root->GetRenderSurface()->num_contributors()); |
1881 | 1886 |
1882 LayerSelection input; | 1887 LayerSelection input; |
1883 | 1888 |
1884 input.start.type = gfx::SelectionBound::LEFT; | 1889 input.start.type = gfx::SelectionBound::LEFT; |
1885 input.start.edge_top = gfx::Point(10, 10); | 1890 input.start.edge_top = gfx::Point(10, 10); |
1886 input.start.edge_bottom = gfx::Point(10, 20); | 1891 input.start.edge_bottom = gfx::Point(10, 20); |
1887 input.start.layer_id = root->id(); | 1892 input.start.layer_id = root->id(); |
1888 | 1893 |
1889 input.end.type = gfx::SelectionBound::RIGHT; | 1894 input.end.type = gfx::SelectionBound::RIGHT; |
1890 input.end.edge_top = gfx::Point(50, 10); | 1895 input.end.edge_top = gfx::Point(50, 10); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1950 clipped_layer->SetBounds(gfx::Size(100, 100)); | 1955 clipped_layer->SetBounds(gfx::Size(100, 100)); |
1951 clipped_layer->SetDrawsContent(true); | 1956 clipped_layer->SetDrawsContent(true); |
1952 clipping_layer->test_properties()->AddChild(std::move(clipped_layer)); | 1957 clipping_layer->test_properties()->AddChild(std::move(clipped_layer)); |
1953 root->test_properties()->AddChild(std::move(clipping_layer)); | 1958 root->test_properties()->AddChild(std::move(clipping_layer)); |
1954 } | 1959 } |
1955 | 1960 |
1956 host_impl().SetViewportSize(root->bounds()); | 1961 host_impl().SetViewportSize(root->bounds()); |
1957 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 1962 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
1958 | 1963 |
1959 // Sanity check the scenario we just created. | 1964 // Sanity check the scenario we just created. |
1960 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 1965 ASSERT_EQ(1u, GetRenderSurfaceList().size()); |
1961 | 1966 |
1962 LayerSelection input; | 1967 LayerSelection input; |
1963 input.start.type = gfx::SelectionBound::LEFT; | 1968 input.start.type = gfx::SelectionBound::LEFT; |
1964 input.start.edge_top = gfx::Point(25, 10); | 1969 input.start.edge_top = gfx::Point(25, 10); |
1965 input.start.edge_bottom = gfx::Point(25, 30); | 1970 input.start.edge_bottom = gfx::Point(25, 30); |
1966 input.start.layer_id = clipped_layer_id; | 1971 input.start.layer_id = clipped_layer_id; |
1967 | 1972 |
1968 input.end.type = gfx::SelectionBound::RIGHT; | 1973 input.end.type = gfx::SelectionBound::RIGHT; |
1969 input.end.edge_top = gfx::Point(75, 10); | 1974 input.end.edge_top = gfx::Point(75, 10); |
1970 input.end.edge_bottom = gfx::Point(75, 30); | 1975 input.end.edge_bottom = gfx::Point(75, 30); |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2088 host_impl().active_tree()->SetDeviceScaleFactor(device_scale_factor); | 2093 host_impl().active_tree()->SetDeviceScaleFactor(device_scale_factor); |
2089 host_impl().active_tree()->SetPageScaleOnActiveTree(page_scale_factor); | 2094 host_impl().active_tree()->SetPageScaleOnActiveTree(page_scale_factor); |
2090 host_impl().active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 1, | 2095 host_impl().active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 1, |
2091 Layer::INVALID_ID); | 2096 Layer::INVALID_ID); |
2092 host_impl().active_tree()->PushPageScaleFromMainThread( | 2097 host_impl().active_tree()->PushPageScaleFromMainThread( |
2093 page_scale_factor, page_scale_factor, page_scale_factor); | 2098 page_scale_factor, page_scale_factor, page_scale_factor); |
2094 host_impl().active_tree()->SetPageScaleOnActiveTree(page_scale_factor); | 2099 host_impl().active_tree()->SetPageScaleOnActiveTree(page_scale_factor); |
2095 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 2100 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
2096 | 2101 |
2097 // Sanity check the scenario we just created. | 2102 // Sanity check the scenario we just created. |
2098 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 2103 ASSERT_EQ(1u, GetRenderSurfaceList().size()); |
2099 | 2104 |
2100 LayerSelection input; | 2105 LayerSelection input; |
2101 input.start.type = gfx::SelectionBound::LEFT; | 2106 input.start.type = gfx::SelectionBound::LEFT; |
2102 input.start.edge_top = gfx::Point(10, 10); | 2107 input.start.edge_top = gfx::Point(10, 10); |
2103 input.start.edge_bottom = gfx::Point(10, 30); | 2108 input.start.edge_bottom = gfx::Point(10, 30); |
2104 input.start.layer_id = root_layer_id; | 2109 input.start.layer_id = root_layer_id; |
2105 | 2110 |
2106 input.end.type = gfx::SelectionBound::RIGHT; | 2111 input.end.type = gfx::SelectionBound::RIGHT; |
2107 input.end.edge_top = gfx::Point(0, 0); | 2112 input.end.edge_top = gfx::Point(0, 0); |
2108 input.end.edge_bottom = gfx::Point(0, 20); | 2113 input.end.edge_bottom = gfx::Point(0, 20); |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2256 translate_z.Translate3d(0, 0, 10); | 2261 translate_z.Translate3d(0, 0, 10); |
2257 right_child->test_properties()->transform = translate_z; | 2262 right_child->test_properties()->transform = translate_z; |
2258 right_child->SetBounds(gfx::Size(100, 100)); | 2263 right_child->SetBounds(gfx::Size(100, 100)); |
2259 } | 2264 } |
2260 | 2265 |
2261 root->test_properties()->AddChild(std::move(left_child)); | 2266 root->test_properties()->AddChild(std::move(left_child)); |
2262 root->test_properties()->AddChild(std::move(right_child)); | 2267 root->test_properties()->AddChild(std::move(right_child)); |
2263 | 2268 |
2264 host_impl().SetViewportSize(root->bounds()); | 2269 host_impl().SetViewportSize(root->bounds()); |
2265 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 2270 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
2266 CHECK_EQ(1u, RenderSurfaceLayerList().size()); | 2271 CHECK_EQ(1u, GetRenderSurfaceList().size()); |
2267 | 2272 |
2268 gfx::PointF test_point = gfx::PointF(1.f, 1.f); | 2273 gfx::PointF test_point = gfx::PointF(1.f, 1.f); |
2269 LayerImpl* result_layer = | 2274 LayerImpl* result_layer = |
2270 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 2275 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); |
2271 | 2276 |
2272 CHECK(result_layer); | 2277 CHECK(result_layer); |
2273 EXPECT_EQ(2, result_layer->id()); | 2278 EXPECT_EQ(2, result_layer->id()); |
2274 } | 2279 } |
2275 | 2280 |
2276 namespace { | 2281 namespace { |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2376 auto weak_promise = promise->AsWeakPtr(); | 2381 auto weak_promise = promise->AsWeakPtr(); |
2377 host_impl().active_tree()->QueueSwapPromise(std::move(promise)); | 2382 host_impl().active_tree()->QueueSwapPromise(std::move(promise)); |
2378 host_impl().active_tree()->BreakSwapPromises( | 2383 host_impl().active_tree()->BreakSwapPromises( |
2379 SwapPromise::DidNotSwapReason::SWAP_FAILS); | 2384 SwapPromise::DidNotSwapReason::SWAP_FAILS); |
2380 EXPECT_FALSE(weak_promise); | 2385 EXPECT_FALSE(weak_promise); |
2381 } | 2386 } |
2382 } | 2387 } |
2383 | 2388 |
2384 } // namespace | 2389 } // namespace |
2385 } // namespace cc | 2390 } // namespace cc |
OLD | NEW |