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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 float right_child_depth); | 47 float right_child_depth); |
48 | 48 |
49 const LayerImplList& RenderSurfaceLayerList() const { | 49 const LayerImplList& RenderSurfaceLayerList() const { |
50 return host_impl_->active_tree()->RenderSurfaceLayerList(); | 50 return host_impl_->active_tree()->RenderSurfaceLayerList(); |
51 } | 51 } |
52 | 52 |
53 private: | 53 private: |
54 TestSharedBitmapManager shared_bitmap_manager_; | 54 TestSharedBitmapManager shared_bitmap_manager_; |
55 TestTaskGraphRunner task_graph_runner_; | 55 TestTaskGraphRunner task_graph_runner_; |
56 FakeImplTaskRunnerProvider task_runner_provider_; | 56 FakeImplTaskRunnerProvider task_runner_provider_; |
57 scoped_ptr<OutputSurface> output_surface_; | 57 std::unique_ptr<OutputSurface> output_surface_; |
58 scoped_ptr<FakeLayerTreeHostImpl> host_impl_; | 58 std::unique_ptr<FakeLayerTreeHostImpl> host_impl_; |
59 }; | 59 }; |
60 | 60 |
61 TEST_F(LayerTreeImplTest, HitTestingForSingleLayer) { | 61 TEST_F(LayerTreeImplTest, HitTestingForSingleLayer) { |
62 scoped_ptr<LayerImpl> root = | 62 std::unique_ptr<LayerImpl> root = |
63 LayerImpl::Create(host_impl().active_tree(), 12345); | 63 LayerImpl::Create(host_impl().active_tree(), 12345); |
64 | 64 |
65 gfx::Transform identity_matrix; | 65 gfx::Transform identity_matrix; |
66 gfx::Point3F transform_origin; | 66 gfx::Point3F transform_origin; |
67 gfx::PointF position; | 67 gfx::PointF position; |
68 gfx::Size bounds(100, 100); | 68 gfx::Size bounds(100, 100); |
69 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, | 69 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, |
70 position, bounds, true, false, true); | 70 position, bounds, true, false, true); |
71 root->SetDrawsContent(true); | 71 root->SetDrawsContent(true); |
72 | 72 |
(...skipping 29 matching lines...) Expand all Loading... |
102 ASSERT_TRUE(result_layer); | 102 ASSERT_TRUE(result_layer); |
103 EXPECT_EQ(12345, result_layer->id()); | 103 EXPECT_EQ(12345, result_layer->id()); |
104 } | 104 } |
105 | 105 |
106 TEST_F(LayerTreeImplTest, UpdateViewportAndHitTest) { | 106 TEST_F(LayerTreeImplTest, UpdateViewportAndHitTest) { |
107 // Ensures that the viewport rect is correctly updated by the clip tree. | 107 // Ensures that the viewport rect is correctly updated by the clip tree. |
108 TestSharedBitmapManager shared_bitmap_manager; | 108 TestSharedBitmapManager shared_bitmap_manager; |
109 TestTaskGraphRunner task_graph_runner; | 109 TestTaskGraphRunner task_graph_runner; |
110 FakeImplTaskRunnerProvider task_runner_provider; | 110 FakeImplTaskRunnerProvider task_runner_provider; |
111 LayerTreeSettings settings; | 111 LayerTreeSettings settings; |
112 scoped_ptr<OutputSurface> output_surface = FakeOutputSurface::Create3d(); | 112 std::unique_ptr<OutputSurface> output_surface = FakeOutputSurface::Create3d(); |
113 scoped_ptr<FakeLayerTreeHostImpl> host_impl; | 113 std::unique_ptr<FakeLayerTreeHostImpl> host_impl; |
114 host_impl.reset(new FakeLayerTreeHostImpl(settings, &task_runner_provider, | 114 host_impl.reset(new FakeLayerTreeHostImpl(settings, &task_runner_provider, |
115 &shared_bitmap_manager, | 115 &shared_bitmap_manager, |
116 &task_graph_runner)); | 116 &task_graph_runner)); |
117 host_impl->SetVisible(true); | 117 host_impl->SetVisible(true); |
118 EXPECT_TRUE(host_impl->InitializeRenderer(output_surface.get())); | 118 EXPECT_TRUE(host_impl->InitializeRenderer(output_surface.get())); |
119 scoped_ptr<LayerImpl> root = | 119 std::unique_ptr<LayerImpl> root = |
120 LayerImpl::Create(host_impl->active_tree(), 12345); | 120 LayerImpl::Create(host_impl->active_tree(), 12345); |
121 | 121 |
122 gfx::Transform identity_matrix; | 122 gfx::Transform identity_matrix; |
123 gfx::Point3F transform_origin; | 123 gfx::Point3F transform_origin; |
124 gfx::PointF position; | 124 gfx::PointF position; |
125 gfx::Size bounds(100, 100); | 125 gfx::Size bounds(100, 100); |
126 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, | 126 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, |
127 position, bounds, true, false, true); | 127 position, bounds, true, false, true); |
128 root->SetDrawsContent(true); | 128 root->SetDrawsContent(true); |
129 | 129 |
(...skipping 10 matching lines...) Expand all Loading... |
140 gfx::PointF test_point(51.f, 51.f); | 140 gfx::PointF test_point(51.f, 51.f); |
141 host_impl->active_tree()->FindLayerThatIsHitByPoint(test_point); | 141 host_impl->active_tree()->FindLayerThatIsHitByPoint(test_point); |
142 EXPECT_EQ( | 142 EXPECT_EQ( |
143 gfx::RectF(gfx::SizeF(new_bounds)), | 143 gfx::RectF(gfx::SizeF(new_bounds)), |
144 host_impl->active_tree()->property_trees()->clip_tree.ViewportClip()); | 144 host_impl->active_tree()->property_trees()->clip_tree.ViewportClip()); |
145 EXPECT_EQ(gfx::Rect(new_bounds), | 145 EXPECT_EQ(gfx::Rect(new_bounds), |
146 host_impl->RootLayer()->visible_layer_rect()); | 146 host_impl->RootLayer()->visible_layer_rect()); |
147 } | 147 } |
148 | 148 |
149 TEST_F(LayerTreeImplTest, HitTestingForSingleLayerAndHud) { | 149 TEST_F(LayerTreeImplTest, HitTestingForSingleLayerAndHud) { |
150 scoped_ptr<LayerImpl> root = | 150 std::unique_ptr<LayerImpl> root = |
151 LayerImpl::Create(host_impl().active_tree(), 12345); | 151 LayerImpl::Create(host_impl().active_tree(), 12345); |
152 scoped_ptr<HeadsUpDisplayLayerImpl> hud = | 152 std::unique_ptr<HeadsUpDisplayLayerImpl> hud = |
153 HeadsUpDisplayLayerImpl::Create(host_impl().active_tree(), 11111); | 153 HeadsUpDisplayLayerImpl::Create(host_impl().active_tree(), 11111); |
154 | 154 |
155 gfx::Transform identity_matrix; | 155 gfx::Transform identity_matrix; |
156 gfx::Point3F transform_origin; | 156 gfx::Point3F transform_origin; |
157 gfx::PointF position; | 157 gfx::PointF position; |
158 gfx::Size bounds(100, 100); | 158 gfx::Size bounds(100, 100); |
159 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, | 159 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, |
160 position, bounds, true, false, true); | 160 position, bounds, true, false, true); |
161 root->SetDrawsContent(true); | 161 root->SetDrawsContent(true); |
162 | 162 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 EXPECT_EQ(12345, result_layer->id()); | 197 EXPECT_EQ(12345, result_layer->id()); |
198 | 198 |
199 test_point = gfx::PointF(99.f, 99.f); | 199 test_point = gfx::PointF(99.f, 99.f); |
200 result_layer = | 200 result_layer = |
201 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 201 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); |
202 ASSERT_TRUE(result_layer); | 202 ASSERT_TRUE(result_layer); |
203 EXPECT_EQ(12345, result_layer->id()); | 203 EXPECT_EQ(12345, result_layer->id()); |
204 } | 204 } |
205 | 205 |
206 TEST_F(LayerTreeImplTest, HitTestingForUninvertibleTransform) { | 206 TEST_F(LayerTreeImplTest, HitTestingForUninvertibleTransform) { |
207 scoped_ptr<LayerImpl> root = | 207 std::unique_ptr<LayerImpl> root = |
208 LayerImpl::Create(host_impl().active_tree(), 12345); | 208 LayerImpl::Create(host_impl().active_tree(), 12345); |
209 | 209 |
210 gfx::Transform uninvertible_transform; | 210 gfx::Transform uninvertible_transform; |
211 uninvertible_transform.matrix().set(0, 0, 0.0); | 211 uninvertible_transform.matrix().set(0, 0, 0.0); |
212 uninvertible_transform.matrix().set(1, 1, 0.0); | 212 uninvertible_transform.matrix().set(1, 1, 0.0); |
213 uninvertible_transform.matrix().set(2, 2, 0.0); | 213 uninvertible_transform.matrix().set(2, 2, 0.0); |
214 uninvertible_transform.matrix().set(3, 3, 0.0); | 214 uninvertible_transform.matrix().set(3, 3, 0.0); |
215 ASSERT_FALSE(uninvertible_transform.IsInvertible()); | 215 ASSERT_FALSE(uninvertible_transform.IsInvertible()); |
216 | 216 |
217 gfx::Transform identity_matrix; | 217 gfx::Transform identity_matrix; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 264 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); |
265 EXPECT_FALSE(result_layer); | 265 EXPECT_FALSE(result_layer); |
266 | 266 |
267 test_point = gfx::PointF(-1.f, -1.f); | 267 test_point = gfx::PointF(-1.f, -1.f); |
268 result_layer = | 268 result_layer = |
269 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 269 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); |
270 EXPECT_FALSE(result_layer); | 270 EXPECT_FALSE(result_layer); |
271 } | 271 } |
272 | 272 |
273 TEST_F(LayerTreeImplTest, HitTestingForSinglePositionedLayer) { | 273 TEST_F(LayerTreeImplTest, HitTestingForSinglePositionedLayer) { |
274 scoped_ptr<LayerImpl> root = | 274 std::unique_ptr<LayerImpl> root = |
275 LayerImpl::Create(host_impl().active_tree(), 12345); | 275 LayerImpl::Create(host_impl().active_tree(), 12345); |
276 | 276 |
277 gfx::Transform identity_matrix; | 277 gfx::Transform identity_matrix; |
278 gfx::Point3F transform_origin; | 278 gfx::Point3F transform_origin; |
279 // this layer is positioned, and hit testing should correctly know where the | 279 // this layer is positioned, and hit testing should correctly know where the |
280 // layer is located. | 280 // layer is located. |
281 gfx::PointF position(50.f, 50.f); | 281 gfx::PointF position(50.f, 50.f); |
282 gfx::Size bounds(100, 100); | 282 gfx::Size bounds(100, 100); |
283 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, | 283 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, |
284 position, bounds, true, false, true); | 284 position, bounds, true, false, true); |
(...skipping 28 matching lines...) Expand all Loading... |
313 EXPECT_EQ(12345, result_layer->id()); | 313 EXPECT_EQ(12345, result_layer->id()); |
314 | 314 |
315 test_point = gfx::PointF(99.f, 99.f); | 315 test_point = gfx::PointF(99.f, 99.f); |
316 result_layer = | 316 result_layer = |
317 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 317 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); |
318 ASSERT_TRUE(result_layer); | 318 ASSERT_TRUE(result_layer); |
319 EXPECT_EQ(12345, result_layer->id()); | 319 EXPECT_EQ(12345, result_layer->id()); |
320 } | 320 } |
321 | 321 |
322 TEST_F(LayerTreeImplTest, HitTestingForSingleRotatedLayer) { | 322 TEST_F(LayerTreeImplTest, HitTestingForSingleRotatedLayer) { |
323 scoped_ptr<LayerImpl> root = | 323 std::unique_ptr<LayerImpl> root = |
324 LayerImpl::Create(host_impl().active_tree(), 12345); | 324 LayerImpl::Create(host_impl().active_tree(), 12345); |
325 | 325 |
326 gfx::Transform identity_matrix; | 326 gfx::Transform identity_matrix; |
327 gfx::Transform rotation45_degrees_about_center; | 327 gfx::Transform rotation45_degrees_about_center; |
328 rotation45_degrees_about_center.Translate(50.0, 50.0); | 328 rotation45_degrees_about_center.Translate(50.0, 50.0); |
329 rotation45_degrees_about_center.RotateAboutZAxis(45.0); | 329 rotation45_degrees_about_center.RotateAboutZAxis(45.0); |
330 rotation45_degrees_about_center.Translate(-50.0, -50.0); | 330 rotation45_degrees_about_center.Translate(-50.0, -50.0); |
331 gfx::Point3F transform_origin; | 331 gfx::Point3F transform_origin; |
332 gfx::PointF position; | 332 gfx::PointF position; |
333 gfx::Size bounds(100, 100); | 333 gfx::Size bounds(100, 100); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 test_point = gfx::PointF(-1.f, 50.f); | 374 test_point = gfx::PointF(-1.f, 50.f); |
375 result_layer = | 375 result_layer = |
376 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 376 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); |
377 ASSERT_FALSE(result_layer); | 377 ASSERT_FALSE(result_layer); |
378 } | 378 } |
379 | 379 |
380 TEST_F(LayerTreeImplTest, HitTestingClipNodeDifferentTransformAndTargetIds) { | 380 TEST_F(LayerTreeImplTest, HitTestingClipNodeDifferentTransformAndTargetIds) { |
381 // Tests hit testing on a layer whose clip node has different transform and | 381 // Tests hit testing on a layer whose clip node has different transform and |
382 // target id. | 382 // target id. |
383 gfx::Transform identity_matrix; | 383 gfx::Transform identity_matrix; |
384 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); | 384 std::unique_ptr<LayerImpl> root = |
| 385 LayerImpl::Create(host_impl().active_tree(), 1); |
385 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), | 386 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), |
386 gfx::PointF(), gfx::Size(500, 500), true, false, | 387 gfx::PointF(), gfx::Size(500, 500), true, false, |
387 true); | 388 true); |
388 gfx::Transform translation; | 389 gfx::Transform translation; |
389 translation.Translate(100, 100); | 390 translation.Translate(100, 100); |
390 scoped_ptr<LayerImpl> render_surface = | 391 std::unique_ptr<LayerImpl> render_surface = |
391 LayerImpl::Create(host_impl().active_tree(), 2); | 392 LayerImpl::Create(host_impl().active_tree(), 2); |
392 SetLayerPropertiesForTesting(render_surface.get(), translation, | 393 SetLayerPropertiesForTesting(render_surface.get(), translation, |
393 gfx::Point3F(), gfx::PointF(), | 394 gfx::Point3F(), gfx::PointF(), |
394 gfx::Size(100, 100), true, false, true); | 395 gfx::Size(100, 100), true, false, true); |
395 | 396 |
396 gfx::Transform scale_matrix; | 397 gfx::Transform scale_matrix; |
397 scale_matrix.Scale(2, 2); | 398 scale_matrix.Scale(2, 2); |
398 scoped_ptr<LayerImpl> scale = LayerImpl::Create(host_impl().active_tree(), 3); | 399 std::unique_ptr<LayerImpl> scale = |
| 400 LayerImpl::Create(host_impl().active_tree(), 3); |
399 SetLayerPropertiesForTesting(scale.get(), scale_matrix, gfx::Point3F(), | 401 SetLayerPropertiesForTesting(scale.get(), scale_matrix, gfx::Point3F(), |
400 gfx::PointF(), gfx::Size(50, 50), true, false, | 402 gfx::PointF(), gfx::Size(50, 50), true, false, |
401 false); | 403 false); |
402 | 404 |
403 scoped_ptr<LayerImpl> clip = LayerImpl::Create(host_impl().active_tree(), 4); | 405 std::unique_ptr<LayerImpl> clip = |
| 406 LayerImpl::Create(host_impl().active_tree(), 4); |
404 SetLayerPropertiesForTesting(clip.get(), identity_matrix, gfx::Point3F(), | 407 SetLayerPropertiesForTesting(clip.get(), identity_matrix, gfx::Point3F(), |
405 gfx::PointF(), gfx::Size(25, 25), true, false, | 408 gfx::PointF(), gfx::Size(25, 25), true, false, |
406 false); | 409 false); |
407 clip->SetMasksToBounds(true); | 410 clip->SetMasksToBounds(true); |
408 | 411 |
409 scoped_ptr<LayerImpl> test = LayerImpl::Create(host_impl().active_tree(), 5); | 412 std::unique_ptr<LayerImpl> test = |
| 413 LayerImpl::Create(host_impl().active_tree(), 5); |
410 SetLayerPropertiesForTesting(test.get(), identity_matrix, gfx::Point3F(), | 414 SetLayerPropertiesForTesting(test.get(), identity_matrix, gfx::Point3F(), |
411 gfx::PointF(), gfx::Size(100, 100), true, false, | 415 gfx::PointF(), gfx::Size(100, 100), true, false, |
412 false); | 416 false); |
413 test->SetDrawsContent(true); | 417 test->SetDrawsContent(true); |
414 | 418 |
415 clip->AddChild(std::move(test)); | 419 clip->AddChild(std::move(test)); |
416 scale->AddChild(std::move(clip)); | 420 scale->AddChild(std::move(clip)); |
417 render_surface->AddChild(std::move(scale)); | 421 render_surface->AddChild(std::move(scale)); |
418 root->AddChild(std::move(render_surface)); | 422 root->AddChild(std::move(render_surface)); |
419 | 423 |
(...skipping 13 matching lines...) Expand all Loading... |
433 EXPECT_EQ(5, result_layer->id()); | 437 EXPECT_EQ(5, result_layer->id()); |
434 | 438 |
435 ClipTree clip_tree = host_impl().active_tree()->property_trees()->clip_tree; | 439 ClipTree clip_tree = host_impl().active_tree()->property_trees()->clip_tree; |
436 ClipNode* clip_node = clip_tree.Node(result_layer->clip_tree_index()); | 440 ClipNode* clip_node = clip_tree.Node(result_layer->clip_tree_index()); |
437 EXPECT_NE(clip_node->data.transform_id, clip_node->data.target_id); | 441 EXPECT_NE(clip_node->data.transform_id, clip_node->data.target_id); |
438 } | 442 } |
439 | 443 |
440 TEST_F(LayerTreeImplTest, HitTestingSiblings) { | 444 TEST_F(LayerTreeImplTest, HitTestingSiblings) { |
441 // This tests hit testing when the test point hits only one of the siblings. | 445 // This tests hit testing when the test point hits only one of the siblings. |
442 gfx::Transform identity_matrix; | 446 gfx::Transform identity_matrix; |
443 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); | 447 std::unique_ptr<LayerImpl> root = |
| 448 LayerImpl::Create(host_impl().active_tree(), 1); |
444 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), | 449 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), |
445 gfx::PointF(), gfx::Size(100, 100), true, false, | 450 gfx::PointF(), gfx::Size(100, 100), true, false, |
446 true); | 451 true); |
447 scoped_ptr<LayerImpl> child1 = | 452 std::unique_ptr<LayerImpl> child1 = |
448 LayerImpl::Create(host_impl().active_tree(), 2); | 453 LayerImpl::Create(host_impl().active_tree(), 2); |
449 SetLayerPropertiesForTesting(child1.get(), identity_matrix, gfx::Point3F(), | 454 SetLayerPropertiesForTesting(child1.get(), identity_matrix, gfx::Point3F(), |
450 gfx::PointF(), gfx::Size(25, 25), true, false, | 455 gfx::PointF(), gfx::Size(25, 25), true, false, |
451 false); | 456 false); |
452 child1->SetMasksToBounds(true); | 457 child1->SetMasksToBounds(true); |
453 child1->SetDrawsContent(true); | 458 child1->SetDrawsContent(true); |
454 scoped_ptr<LayerImpl> child2 = | 459 std::unique_ptr<LayerImpl> child2 = |
455 LayerImpl::Create(host_impl().active_tree(), 3); | 460 LayerImpl::Create(host_impl().active_tree(), 3); |
456 SetLayerPropertiesForTesting(child2.get(), identity_matrix, gfx::Point3F(), | 461 SetLayerPropertiesForTesting(child2.get(), identity_matrix, gfx::Point3F(), |
457 gfx::PointF(), gfx::Size(75, 75), true, false, | 462 gfx::PointF(), gfx::Size(75, 75), true, false, |
458 false); | 463 false); |
459 child2->SetMasksToBounds(true); | 464 child2->SetMasksToBounds(true); |
460 child2->SetDrawsContent(true); | 465 child2->SetDrawsContent(true); |
461 root->AddChild(std::move(child1)); | 466 root->AddChild(std::move(child1)); |
462 root->AddChild(std::move(child2)); | 467 root->AddChild(std::move(child2)); |
463 | 468 |
464 host_impl().SetViewportSize(root->bounds()); | 469 host_impl().SetViewportSize(root->bounds()); |
465 host_impl().active_tree()->SetRootLayer(std::move(root)); | 470 host_impl().active_tree()->SetRootLayer(std::move(root)); |
466 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 471 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
467 | 472 |
468 gfx::PointF test_point(50.f, 50.f); | 473 gfx::PointF test_point(50.f, 50.f); |
469 LayerImpl* result_layer = | 474 LayerImpl* result_layer = |
470 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 475 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); |
471 ASSERT_TRUE(result_layer); | 476 ASSERT_TRUE(result_layer); |
472 EXPECT_EQ(3, result_layer->id()); | 477 EXPECT_EQ(3, result_layer->id()); |
473 } | 478 } |
474 | 479 |
475 TEST_F(LayerTreeImplTest, HitTestingPointOutsideMaxTextureSize) { | 480 TEST_F(LayerTreeImplTest, HitTestingPointOutsideMaxTextureSize) { |
476 gfx::Transform identity_matrix; | 481 gfx::Transform identity_matrix; |
477 int max_texture_size = | 482 int max_texture_size = |
478 host_impl().active_tree()->resource_provider()->max_texture_size(); | 483 host_impl().active_tree()->resource_provider()->max_texture_size(); |
479 gfx::Size bounds(max_texture_size + 100, max_texture_size + 100); | 484 gfx::Size bounds(max_texture_size + 100, max_texture_size + 100); |
480 | 485 |
481 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); | 486 std::unique_ptr<LayerImpl> root = |
| 487 LayerImpl::Create(host_impl().active_tree(), 1); |
482 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), | 488 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), |
483 gfx::PointF(), bounds, true, false, true); | 489 gfx::PointF(), bounds, true, false, true); |
484 | 490 |
485 scoped_ptr<LayerImpl> surface = | 491 std::unique_ptr<LayerImpl> surface = |
486 LayerImpl::Create(host_impl().active_tree(), 2); | 492 LayerImpl::Create(host_impl().active_tree(), 2); |
487 SetLayerPropertiesForTesting(surface.get(), identity_matrix, gfx::Point3F(), | 493 SetLayerPropertiesForTesting(surface.get(), identity_matrix, gfx::Point3F(), |
488 gfx::PointF(), bounds, true, false, true); | 494 gfx::PointF(), bounds, true, false, true); |
489 surface->SetMasksToBounds(true); | 495 surface->SetMasksToBounds(true); |
490 surface->SetDrawsContent(true); | 496 surface->SetDrawsContent(true); |
491 | 497 |
492 root->AddChild(std::move(surface)); | 498 root->AddChild(std::move(surface)); |
493 host_impl().SetViewportSize(root->bounds()); | 499 host_impl().SetViewportSize(root->bounds()); |
494 host_impl().active_tree()->SetRootLayer(std::move(root)); | 500 host_impl().active_tree()->SetRootLayer(std::move(root)); |
495 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 501 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
496 | 502 |
497 gfx::PointF test_point(max_texture_size - 50, max_texture_size - 50); | 503 gfx::PointF test_point(max_texture_size - 50, max_texture_size - 50); |
498 LayerImpl* result_layer = | 504 LayerImpl* result_layer = |
499 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 505 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); |
500 EXPECT_TRUE(result_layer); | 506 EXPECT_TRUE(result_layer); |
501 | 507 |
502 test_point = gfx::PointF(max_texture_size + 50, max_texture_size + 50); | 508 test_point = gfx::PointF(max_texture_size + 50, max_texture_size + 50); |
503 result_layer = | 509 result_layer = |
504 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 510 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); |
505 EXPECT_FALSE(result_layer); | 511 EXPECT_FALSE(result_layer); |
506 } | 512 } |
507 | 513 |
508 TEST_F(LayerTreeImplTest, HitTestingForSinglePerspectiveLayer) { | 514 TEST_F(LayerTreeImplTest, HitTestingForSinglePerspectiveLayer) { |
509 scoped_ptr<LayerImpl> root = | 515 std::unique_ptr<LayerImpl> root = |
510 LayerImpl::Create(host_impl().active_tree(), 12345); | 516 LayerImpl::Create(host_impl().active_tree(), 12345); |
511 | 517 |
512 gfx::Transform identity_matrix; | 518 gfx::Transform identity_matrix; |
513 | 519 |
514 // perspective_projection_about_center * translation_by_z is designed so that | 520 // perspective_projection_about_center * translation_by_z is designed so that |
515 // the 100 x 100 layer becomes 50 x 50, and remains centered at (50, 50). | 521 // the 100 x 100 layer becomes 50 x 50, and remains centered at (50, 50). |
516 gfx::Transform perspective_projection_about_center; | 522 gfx::Transform perspective_projection_about_center; |
517 perspective_projection_about_center.Translate(50.0, 50.0); | 523 perspective_projection_about_center.Translate(50.0, 50.0); |
518 perspective_projection_about_center.ApplyPerspectiveDepth(1.0); | 524 perspective_projection_about_center.ApplyPerspectiveDepth(1.0); |
519 perspective_projection_about_center.Translate(-50.0, -50.0); | 525 perspective_projection_about_center.Translate(-50.0, -50.0); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
563 EXPECT_EQ(12345, result_layer->id()); | 569 EXPECT_EQ(12345, result_layer->id()); |
564 } | 570 } |
565 | 571 |
566 TEST_F(LayerTreeImplTest, HitTestingForSimpleClippedLayer) { | 572 TEST_F(LayerTreeImplTest, HitTestingForSimpleClippedLayer) { |
567 // Test that hit-testing will only work for the visible portion of a layer, | 573 // Test that hit-testing will only work for the visible portion of a layer, |
568 // and not the entire layer bounds. Here we just test the simple axis-aligned | 574 // and not the entire layer bounds. Here we just test the simple axis-aligned |
569 // case. | 575 // case. |
570 gfx::Transform identity_matrix; | 576 gfx::Transform identity_matrix; |
571 gfx::Point3F transform_origin; | 577 gfx::Point3F transform_origin; |
572 | 578 |
573 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); | 579 std::unique_ptr<LayerImpl> root = |
| 580 LayerImpl::Create(host_impl().active_tree(), 1); |
574 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, | 581 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, |
575 gfx::PointF(), gfx::Size(100, 100), true, false, | 582 gfx::PointF(), gfx::Size(100, 100), true, false, |
576 true); | 583 true); |
577 { | 584 { |
578 scoped_ptr<LayerImpl> clipping_layer = | 585 std::unique_ptr<LayerImpl> clipping_layer = |
579 LayerImpl::Create(host_impl().active_tree(), 123); | 586 LayerImpl::Create(host_impl().active_tree(), 123); |
580 // this layer is positioned, and hit testing should correctly know where the | 587 // this layer is positioned, and hit testing should correctly know where the |
581 // layer is located. | 588 // layer is located. |
582 gfx::PointF position(25.f, 25.f); | 589 gfx::PointF position(25.f, 25.f); |
583 gfx::Size bounds(50, 50); | 590 gfx::Size bounds(50, 50); |
584 SetLayerPropertiesForTesting(clipping_layer.get(), identity_matrix, | 591 SetLayerPropertiesForTesting(clipping_layer.get(), identity_matrix, |
585 transform_origin, position, bounds, true, | 592 transform_origin, position, bounds, true, |
586 false, false); | 593 false, false); |
587 clipping_layer->SetMasksToBounds(true); | 594 clipping_layer->SetMasksToBounds(true); |
588 | 595 |
589 scoped_ptr<LayerImpl> child = | 596 std::unique_ptr<LayerImpl> child = |
590 LayerImpl::Create(host_impl().active_tree(), 456); | 597 LayerImpl::Create(host_impl().active_tree(), 456); |
591 position = gfx::PointF(-50.f, -50.f); | 598 position = gfx::PointF(-50.f, -50.f); |
592 bounds = gfx::Size(300, 300); | 599 bounds = gfx::Size(300, 300); |
593 SetLayerPropertiesForTesting(child.get(), identity_matrix, transform_origin, | 600 SetLayerPropertiesForTesting(child.get(), identity_matrix, transform_origin, |
594 position, bounds, true, false, false); | 601 position, bounds, true, false, false); |
595 child->SetDrawsContent(true); | 602 child->SetDrawsContent(true); |
596 clipping_layer->AddChild(std::move(child)); | 603 clipping_layer->AddChild(std::move(child)); |
597 root->AddChild(std::move(clipping_layer)); | 604 root->AddChild(std::move(clipping_layer)); |
598 } | 605 } |
599 | 606 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
639 // This test checks whether hit testing correctly avoids hit testing with | 646 // This test checks whether hit testing correctly avoids hit testing with |
640 // multiple ancestors that clip in non axis-aligned ways. To pass this test, | 647 // multiple ancestors that clip in non axis-aligned ways. To pass this test, |
641 // the hit testing algorithm needs to recognize that multiple parent layers | 648 // the hit testing algorithm needs to recognize that multiple parent layers |
642 // may clip the layer, and should not actually hit those clipped areas. | 649 // may clip the layer, and should not actually hit those clipped areas. |
643 // | 650 // |
644 // The child and grand_child layers are both initialized to clip the | 651 // The child and grand_child layers are both initialized to clip the |
645 // rotated_leaf. The child layer is rotated about the top-left corner, so that | 652 // rotated_leaf. The child layer is rotated about the top-left corner, so that |
646 // the root + child clips combined create a triangle. The rotated_leaf will | 653 // the root + child clips combined create a triangle. The rotated_leaf will |
647 // only be visible where it overlaps this triangle. | 654 // only be visible where it overlaps this triangle. |
648 // | 655 // |
649 scoped_ptr<LayerImpl> root = | 656 std::unique_ptr<LayerImpl> root = |
650 LayerImpl::Create(host_impl().active_tree(), 123); | 657 LayerImpl::Create(host_impl().active_tree(), 123); |
651 LayerImpl* root_layer = root.get(); | 658 LayerImpl* root_layer = root.get(); |
652 | 659 |
653 gfx::Transform identity_matrix; | 660 gfx::Transform identity_matrix; |
654 gfx::Point3F transform_origin; | 661 gfx::Point3F transform_origin; |
655 gfx::PointF position; | 662 gfx::PointF position; |
656 gfx::Size bounds(100, 100); | 663 gfx::Size bounds(100, 100); |
657 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, | 664 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, |
658 position, bounds, true, false, true); | 665 position, bounds, true, false, true); |
659 root->SetMasksToBounds(true); | 666 root->SetMasksToBounds(true); |
660 { | 667 { |
661 scoped_ptr<LayerImpl> child = | 668 std::unique_ptr<LayerImpl> child = |
662 LayerImpl::Create(host_impl().active_tree(), 456); | 669 LayerImpl::Create(host_impl().active_tree(), 456); |
663 scoped_ptr<LayerImpl> grand_child = | 670 std::unique_ptr<LayerImpl> grand_child = |
664 LayerImpl::Create(host_impl().active_tree(), 789); | 671 LayerImpl::Create(host_impl().active_tree(), 789); |
665 scoped_ptr<LayerImpl> rotated_leaf = | 672 std::unique_ptr<LayerImpl> rotated_leaf = |
666 LayerImpl::Create(host_impl().active_tree(), 2468); | 673 LayerImpl::Create(host_impl().active_tree(), 2468); |
667 | 674 |
668 position = gfx::PointF(10.f, 10.f); | 675 position = gfx::PointF(10.f, 10.f); |
669 bounds = gfx::Size(80, 80); | 676 bounds = gfx::Size(80, 80); |
670 SetLayerPropertiesForTesting(child.get(), identity_matrix, transform_origin, | 677 SetLayerPropertiesForTesting(child.get(), identity_matrix, transform_origin, |
671 position, bounds, true, false, false); | 678 position, bounds, true, false, false); |
672 child->SetMasksToBounds(true); | 679 child->SetMasksToBounds(true); |
673 | 680 |
674 gfx::Transform rotation45_degrees_about_corner; | 681 gfx::Transform rotation45_degrees_about_corner; |
675 rotation45_degrees_about_corner.RotateAboutZAxis(45.0); | 682 rotation45_degrees_about_corner.RotateAboutZAxis(45.0); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
756 ASSERT_TRUE(result_layer); | 763 ASSERT_TRUE(result_layer); |
757 EXPECT_EQ(2468, result_layer->id()); | 764 EXPECT_EQ(2468, result_layer->id()); |
758 } | 765 } |
759 | 766 |
760 TEST_F(LayerTreeImplTest, HitTestingForNonClippingIntermediateLayer) { | 767 TEST_F(LayerTreeImplTest, HitTestingForNonClippingIntermediateLayer) { |
761 // This test checks that hit testing code does not accidentally clip to layer | 768 // This test checks that hit testing code does not accidentally clip to layer |
762 // bounds for a layer that actually does not clip. | 769 // bounds for a layer that actually does not clip. |
763 gfx::Transform identity_matrix; | 770 gfx::Transform identity_matrix; |
764 gfx::Point3F transform_origin; | 771 gfx::Point3F transform_origin; |
765 | 772 |
766 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); | 773 std::unique_ptr<LayerImpl> root = |
| 774 LayerImpl::Create(host_impl().active_tree(), 1); |
767 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, | 775 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, |
768 gfx::PointF(), gfx::Size(100, 100), true, false, | 776 gfx::PointF(), gfx::Size(100, 100), true, false, |
769 true); | 777 true); |
770 { | 778 { |
771 scoped_ptr<LayerImpl> intermediate_layer = | 779 std::unique_ptr<LayerImpl> intermediate_layer = |
772 LayerImpl::Create(host_impl().active_tree(), 123); | 780 LayerImpl::Create(host_impl().active_tree(), 123); |
773 // this layer is positioned, and hit testing should correctly know where the | 781 // this layer is positioned, and hit testing should correctly know where the |
774 // layer is located. | 782 // layer is located. |
775 gfx::PointF position(10.f, 10.f); | 783 gfx::PointF position(10.f, 10.f); |
776 gfx::Size bounds(50, 50); | 784 gfx::Size bounds(50, 50); |
777 SetLayerPropertiesForTesting(intermediate_layer.get(), identity_matrix, | 785 SetLayerPropertiesForTesting(intermediate_layer.get(), identity_matrix, |
778 transform_origin, position, bounds, true, | 786 transform_origin, position, bounds, true, |
779 false, false); | 787 false, false); |
780 // Sanity check the intermediate layer should not clip. | 788 // Sanity check the intermediate layer should not clip. |
781 ASSERT_FALSE(intermediate_layer->masks_to_bounds()); | 789 ASSERT_FALSE(intermediate_layer->masks_to_bounds()); |
782 ASSERT_FALSE(intermediate_layer->mask_layer()); | 790 ASSERT_FALSE(intermediate_layer->mask_layer()); |
783 | 791 |
784 // The child of the intermediate_layer is translated so that it does not | 792 // The child of the intermediate_layer is translated so that it does not |
785 // overlap intermediate_layer at all. If child is incorrectly clipped, we | 793 // overlap intermediate_layer at all. If child is incorrectly clipped, we |
786 // would not be able to hit it successfully. | 794 // would not be able to hit it successfully. |
787 scoped_ptr<LayerImpl> child = | 795 std::unique_ptr<LayerImpl> child = |
788 LayerImpl::Create(host_impl().active_tree(), 456); | 796 LayerImpl::Create(host_impl().active_tree(), 456); |
789 position = gfx::PointF(60.f, 60.f); // 70, 70 in screen space | 797 position = gfx::PointF(60.f, 60.f); // 70, 70 in screen space |
790 bounds = gfx::Size(20, 20); | 798 bounds = gfx::Size(20, 20); |
791 SetLayerPropertiesForTesting(child.get(), identity_matrix, transform_origin, | 799 SetLayerPropertiesForTesting(child.get(), identity_matrix, transform_origin, |
792 position, bounds, true, false, false); | 800 position, bounds, true, false, false); |
793 child->SetDrawsContent(true); | 801 child->SetDrawsContent(true); |
794 intermediate_layer->AddChild(std::move(child)); | 802 intermediate_layer->AddChild(std::move(child)); |
795 root->AddChild(std::move(intermediate_layer)); | 803 root->AddChild(std::move(intermediate_layer)); |
796 } | 804 } |
797 | 805 |
(...skipping 25 matching lines...) Expand all Loading... |
823 EXPECT_EQ(456, result_layer->id()); | 831 EXPECT_EQ(456, result_layer->id()); |
824 | 832 |
825 test_point = gfx::PointF(89.f, 89.f); | 833 test_point = gfx::PointF(89.f, 89.f); |
826 result_layer = | 834 result_layer = |
827 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 835 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); |
828 ASSERT_TRUE(result_layer); | 836 ASSERT_TRUE(result_layer); |
829 EXPECT_EQ(456, result_layer->id()); | 837 EXPECT_EQ(456, result_layer->id()); |
830 } | 838 } |
831 | 839 |
832 TEST_F(LayerTreeImplTest, HitTestingForMultipleLayers) { | 840 TEST_F(LayerTreeImplTest, HitTestingForMultipleLayers) { |
833 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); | 841 std::unique_ptr<LayerImpl> root = |
| 842 LayerImpl::Create(host_impl().active_tree(), 1); |
834 LayerImpl* root_layer = root.get(); | 843 LayerImpl* root_layer = root.get(); |
835 | 844 |
836 gfx::Transform identity_matrix; | 845 gfx::Transform identity_matrix; |
837 gfx::Point3F transform_origin; | 846 gfx::Point3F transform_origin; |
838 gfx::PointF position; | 847 gfx::PointF position; |
839 gfx::Size bounds(100, 100); | 848 gfx::Size bounds(100, 100); |
840 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, | 849 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, |
841 position, bounds, true, false, true); | 850 position, bounds, true, false, true); |
842 root->SetDrawsContent(true); | 851 root->SetDrawsContent(true); |
843 { | 852 { |
844 // child 1 and child2 are initialized to overlap between x=50 and x=60. | 853 // child 1 and child2 are initialized to overlap between x=50 and x=60. |
845 // grand_child is set to overlap both child1 and child2 between y=50 and | 854 // grand_child is set to overlap both child1 and child2 between y=50 and |
846 // y=60. The expected stacking order is: (front) child2, (second) | 855 // y=60. The expected stacking order is: (front) child2, (second) |
847 // grand_child, (third) child1, and (back) the root layer behind all other | 856 // grand_child, (third) child1, and (back) the root layer behind all other |
848 // layers. | 857 // layers. |
849 | 858 |
850 scoped_ptr<LayerImpl> child1 = | 859 std::unique_ptr<LayerImpl> child1 = |
851 LayerImpl::Create(host_impl().active_tree(), 2); | 860 LayerImpl::Create(host_impl().active_tree(), 2); |
852 scoped_ptr<LayerImpl> child2 = | 861 std::unique_ptr<LayerImpl> child2 = |
853 LayerImpl::Create(host_impl().active_tree(), 3); | 862 LayerImpl::Create(host_impl().active_tree(), 3); |
854 scoped_ptr<LayerImpl> grand_child1 = | 863 std::unique_ptr<LayerImpl> grand_child1 = |
855 LayerImpl::Create(host_impl().active_tree(), 4); | 864 LayerImpl::Create(host_impl().active_tree(), 4); |
856 | 865 |
857 position = gfx::PointF(10.f, 10.f); | 866 position = gfx::PointF(10.f, 10.f); |
858 bounds = gfx::Size(50, 50); | 867 bounds = gfx::Size(50, 50); |
859 SetLayerPropertiesForTesting(child1.get(), identity_matrix, | 868 SetLayerPropertiesForTesting(child1.get(), identity_matrix, |
860 transform_origin, position, bounds, true, | 869 transform_origin, position, bounds, true, |
861 false, false); | 870 false, false); |
862 child1->SetDrawsContent(true); | 871 child1->SetDrawsContent(true); |
863 | 872 |
864 position = gfx::PointF(50.f, 10.f); | 873 position = gfx::PointF(50.f, 10.f); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
956 | 965 |
957 int LayerTreeImplTest::HitTestSimpleTree(int root_id, | 966 int LayerTreeImplTest::HitTestSimpleTree(int root_id, |
958 int left_child_id, | 967 int left_child_id, |
959 int right_child_id, | 968 int right_child_id, |
960 int root_sorting_context, | 969 int root_sorting_context, |
961 int left_child_sorting_context, | 970 int left_child_sorting_context, |
962 int right_child_sorting_context, | 971 int right_child_sorting_context, |
963 float root_depth, | 972 float root_depth, |
964 float left_child_depth, | 973 float left_child_depth, |
965 float right_child_depth) { | 974 float right_child_depth) { |
966 scoped_ptr<LayerImpl> root = | 975 std::unique_ptr<LayerImpl> root = |
967 LayerImpl::Create(host_impl().active_tree(), root_id); | 976 LayerImpl::Create(host_impl().active_tree(), root_id); |
968 scoped_ptr<LayerImpl> left_child = | 977 std::unique_ptr<LayerImpl> left_child = |
969 LayerImpl::Create(host_impl().active_tree(), left_child_id); | 978 LayerImpl::Create(host_impl().active_tree(), left_child_id); |
970 scoped_ptr<LayerImpl> right_child = | 979 std::unique_ptr<LayerImpl> right_child = |
971 LayerImpl::Create(host_impl().active_tree(), right_child_id); | 980 LayerImpl::Create(host_impl().active_tree(), right_child_id); |
972 | 981 |
973 gfx::Point3F transform_origin; | 982 gfx::Point3F transform_origin; |
974 gfx::PointF position; | 983 gfx::PointF position; |
975 gfx::Size bounds(100, 100); | 984 gfx::Size bounds(100, 100); |
976 { | 985 { |
977 gfx::Transform translate_z; | 986 gfx::Transform translate_z; |
978 translate_z.Translate3d(0, 0, root_depth); | 987 translate_z.Translate3d(0, 0, root_depth); |
979 SetLayerPropertiesForTesting(root.get(), translate_z, transform_origin, | 988 SetLayerPropertiesForTesting(root.get(), translate_z, transform_origin, |
980 position, bounds, false, false, true); | 989 position, bounds, false, false, true); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1046 } | 1055 } |
1047 | 1056 |
1048 TEST_F(LayerTreeImplTest, HitTestingSameSortingContextParentWins) { | 1057 TEST_F(LayerTreeImplTest, HitTestingSameSortingContextParentWins) { |
1049 int hit_layer_id = HitTestSimpleTree(/* ids */ 1, 2, 3, | 1058 int hit_layer_id = HitTestSimpleTree(/* ids */ 1, 2, 3, |
1050 /* sorting_contexts */ 10, 10, 10, | 1059 /* sorting_contexts */ 10, 10, 10, |
1051 /* depths */ 0, -1, -1); | 1060 /* depths */ 0, -1, -1); |
1052 EXPECT_EQ(1, hit_layer_id); | 1061 EXPECT_EQ(1, hit_layer_id); |
1053 } | 1062 } |
1054 | 1063 |
1055 TEST_F(LayerTreeImplTest, HitTestingForMultipleLayersAtVaryingDepths) { | 1064 TEST_F(LayerTreeImplTest, HitTestingForMultipleLayersAtVaryingDepths) { |
1056 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); | 1065 std::unique_ptr<LayerImpl> root = |
| 1066 LayerImpl::Create(host_impl().active_tree(), 1); |
1057 | 1067 |
1058 gfx::Transform identity_matrix; | 1068 gfx::Transform identity_matrix; |
1059 gfx::Point3F transform_origin; | 1069 gfx::Point3F transform_origin; |
1060 gfx::PointF position; | 1070 gfx::PointF position; |
1061 gfx::Size bounds(100, 100); | 1071 gfx::Size bounds(100, 100); |
1062 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, | 1072 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, |
1063 position, bounds, true, false, true); | 1073 position, bounds, true, false, true); |
1064 root->SetDrawsContent(true); | 1074 root->SetDrawsContent(true); |
1065 root->SetShouldFlattenTransform(false); | 1075 root->SetShouldFlattenTransform(false); |
1066 root->Set3dSortingContextId(1); | 1076 root->Set3dSortingContextId(1); |
1067 { | 1077 { |
1068 // child 1 and child2 are initialized to overlap between x=50 and x=60. | 1078 // child 1 and child2 are initialized to overlap between x=50 and x=60. |
1069 // grand_child is set to overlap both child1 and child2 between y=50 and | 1079 // grand_child is set to overlap both child1 and child2 between y=50 and |
1070 // y=60. The expected stacking order is: (front) child2, (second) | 1080 // y=60. The expected stacking order is: (front) child2, (second) |
1071 // grand_child, (third) child1, and (back) the root layer behind all other | 1081 // grand_child, (third) child1, and (back) the root layer behind all other |
1072 // layers. | 1082 // layers. |
1073 | 1083 |
1074 scoped_ptr<LayerImpl> child1 = | 1084 std::unique_ptr<LayerImpl> child1 = |
1075 LayerImpl::Create(host_impl().active_tree(), 2); | 1085 LayerImpl::Create(host_impl().active_tree(), 2); |
1076 scoped_ptr<LayerImpl> child2 = | 1086 std::unique_ptr<LayerImpl> child2 = |
1077 LayerImpl::Create(host_impl().active_tree(), 3); | 1087 LayerImpl::Create(host_impl().active_tree(), 3); |
1078 scoped_ptr<LayerImpl> grand_child1 = | 1088 std::unique_ptr<LayerImpl> grand_child1 = |
1079 LayerImpl::Create(host_impl().active_tree(), 4); | 1089 LayerImpl::Create(host_impl().active_tree(), 4); |
1080 | 1090 |
1081 position = gfx::PointF(10.f, 10.f); | 1091 position = gfx::PointF(10.f, 10.f); |
1082 bounds = gfx::Size(50, 50); | 1092 bounds = gfx::Size(50, 50); |
1083 SetLayerPropertiesForTesting(child1.get(), identity_matrix, | 1093 SetLayerPropertiesForTesting(child1.get(), identity_matrix, |
1084 transform_origin, position, bounds, true, | 1094 transform_origin, position, bounds, true, |
1085 false, false); | 1095 false, false); |
1086 child1->SetDrawsContent(true); | 1096 child1->SetDrawsContent(true); |
1087 child1->SetShouldFlattenTransform(false); | 1097 child1->SetShouldFlattenTransform(false); |
1088 child1->Set3dSortingContextId(1); | 1098 child1->Set3dSortingContextId(1); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1170 // At (20, 51), child1 and grand_child1 overlap. grand_child1 is expected to | 1180 // At (20, 51), child1 and grand_child1 overlap. grand_child1 is expected to |
1171 // be on top, as it descends from child1. | 1181 // be on top, as it descends from child1. |
1172 test_point = gfx::PointF(20.f, 51.f); | 1182 test_point = gfx::PointF(20.f, 51.f); |
1173 result_layer = | 1183 result_layer = |
1174 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 1184 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); |
1175 ASSERT_TRUE(result_layer); | 1185 ASSERT_TRUE(result_layer); |
1176 EXPECT_EQ(4, result_layer->id()); | 1186 EXPECT_EQ(4, result_layer->id()); |
1177 } | 1187 } |
1178 | 1188 |
1179 TEST_F(LayerTreeImplTest, HitTestingRespectsClipParents) { | 1189 TEST_F(LayerTreeImplTest, HitTestingRespectsClipParents) { |
1180 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); | 1190 std::unique_ptr<LayerImpl> root = |
| 1191 LayerImpl::Create(host_impl().active_tree(), 1); |
1181 gfx::Transform identity_matrix; | 1192 gfx::Transform identity_matrix; |
1182 gfx::Point3F transform_origin; | 1193 gfx::Point3F transform_origin; |
1183 gfx::PointF position; | 1194 gfx::PointF position; |
1184 gfx::Size bounds(100, 100); | 1195 gfx::Size bounds(100, 100); |
1185 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, | 1196 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, |
1186 position, bounds, true, false, true); | 1197 position, bounds, true, false, true); |
1187 root->SetDrawsContent(true); | 1198 root->SetDrawsContent(true); |
1188 { | 1199 { |
1189 scoped_ptr<LayerImpl> child = | 1200 std::unique_ptr<LayerImpl> child = |
1190 LayerImpl::Create(host_impl().active_tree(), 2); | 1201 LayerImpl::Create(host_impl().active_tree(), 2); |
1191 scoped_ptr<LayerImpl> grand_child = | 1202 std::unique_ptr<LayerImpl> grand_child = |
1192 LayerImpl::Create(host_impl().active_tree(), 4); | 1203 LayerImpl::Create(host_impl().active_tree(), 4); |
1193 | 1204 |
1194 position = gfx::PointF(10.f, 10.f); | 1205 position = gfx::PointF(10.f, 10.f); |
1195 bounds = gfx::Size(1, 1); | 1206 bounds = gfx::Size(1, 1); |
1196 SetLayerPropertiesForTesting(child.get(), identity_matrix, transform_origin, | 1207 SetLayerPropertiesForTesting(child.get(), identity_matrix, transform_origin, |
1197 position, bounds, true, false, false); | 1208 position, bounds, true, false, false); |
1198 child->SetDrawsContent(true); | 1209 child->SetDrawsContent(true); |
1199 child->SetMasksToBounds(true); | 1210 child->SetMasksToBounds(true); |
1200 | 1211 |
1201 position = gfx::PointF(0.f, 40.f); | 1212 position = gfx::PointF(0.f, 40.f); |
1202 bounds = gfx::Size(100, 50); | 1213 bounds = gfx::Size(100, 50); |
1203 SetLayerPropertiesForTesting(grand_child.get(), identity_matrix, | 1214 SetLayerPropertiesForTesting(grand_child.get(), identity_matrix, |
1204 transform_origin, position, bounds, true, | 1215 transform_origin, position, bounds, true, |
1205 false, false); | 1216 false, false); |
1206 grand_child->SetDrawsContent(true); | 1217 grand_child->SetDrawsContent(true); |
1207 grand_child->SetHasRenderSurface(true); | 1218 grand_child->SetHasRenderSurface(true); |
1208 | 1219 |
1209 // This should let |grand_child| "escape" |child|'s clip. | 1220 // This should let |grand_child| "escape" |child|'s clip. |
1210 grand_child->SetClipParent(root.get()); | 1221 grand_child->SetClipParent(root.get()); |
1211 scoped_ptr<std::set<LayerImpl*>> clip_children(new std::set<LayerImpl*>); | 1222 std::unique_ptr<std::set<LayerImpl*>> clip_children( |
| 1223 new std::set<LayerImpl*>); |
1212 clip_children->insert(grand_child.get()); | 1224 clip_children->insert(grand_child.get()); |
1213 root->SetClipChildren(clip_children.release()); | 1225 root->SetClipChildren(clip_children.release()); |
1214 | 1226 |
1215 child->AddChild(std::move(grand_child)); | 1227 child->AddChild(std::move(grand_child)); |
1216 root->AddChild(std::move(child)); | 1228 root->AddChild(std::move(child)); |
1217 } | 1229 } |
1218 | 1230 |
1219 host_impl().SetViewportSize(root->bounds()); | 1231 host_impl().SetViewportSize(root->bounds()); |
1220 host_impl().active_tree()->SetRootLayer(std::move(root)); | 1232 host_impl().active_tree()->SetRootLayer(std::move(root)); |
1221 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 1233 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
1222 | 1234 |
1223 gfx::PointF test_point(12.f, 52.f); | 1235 gfx::PointF test_point(12.f, 52.f); |
1224 LayerImpl* result_layer = | 1236 LayerImpl* result_layer = |
1225 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 1237 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); |
1226 ASSERT_TRUE(result_layer); | 1238 ASSERT_TRUE(result_layer); |
1227 EXPECT_EQ(4, result_layer->id()); | 1239 EXPECT_EQ(4, result_layer->id()); |
1228 } | 1240 } |
1229 | 1241 |
1230 TEST_F(LayerTreeImplTest, HitTestingRespectsScrollParents) { | 1242 TEST_F(LayerTreeImplTest, HitTestingRespectsScrollParents) { |
1231 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); | 1243 std::unique_ptr<LayerImpl> root = |
| 1244 LayerImpl::Create(host_impl().active_tree(), 1); |
1232 gfx::Transform identity_matrix; | 1245 gfx::Transform identity_matrix; |
1233 gfx::Point3F transform_origin; | 1246 gfx::Point3F transform_origin; |
1234 gfx::PointF position; | 1247 gfx::PointF position; |
1235 gfx::Size bounds(100, 100); | 1248 gfx::Size bounds(100, 100); |
1236 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, | 1249 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, |
1237 position, bounds, true, false, true); | 1250 position, bounds, true, false, true); |
1238 root->SetDrawsContent(true); | 1251 root->SetDrawsContent(true); |
1239 { | 1252 { |
1240 scoped_ptr<LayerImpl> child = | 1253 std::unique_ptr<LayerImpl> child = |
1241 LayerImpl::Create(host_impl().active_tree(), 2); | 1254 LayerImpl::Create(host_impl().active_tree(), 2); |
1242 scoped_ptr<LayerImpl> scroll_child = | 1255 std::unique_ptr<LayerImpl> scroll_child = |
1243 LayerImpl::Create(host_impl().active_tree(), 3); | 1256 LayerImpl::Create(host_impl().active_tree(), 3); |
1244 scoped_ptr<LayerImpl> grand_child = | 1257 std::unique_ptr<LayerImpl> grand_child = |
1245 LayerImpl::Create(host_impl().active_tree(), 4); | 1258 LayerImpl::Create(host_impl().active_tree(), 4); |
1246 | 1259 |
1247 position = gfx::PointF(10.f, 10.f); | 1260 position = gfx::PointF(10.f, 10.f); |
1248 bounds = gfx::Size(1, 1); | 1261 bounds = gfx::Size(1, 1); |
1249 SetLayerPropertiesForTesting(child.get(), identity_matrix, transform_origin, | 1262 SetLayerPropertiesForTesting(child.get(), identity_matrix, transform_origin, |
1250 position, bounds, true, false, false); | 1263 position, bounds, true, false, false); |
1251 child->SetDrawsContent(true); | 1264 child->SetDrawsContent(true); |
1252 child->SetMasksToBounds(true); | 1265 child->SetMasksToBounds(true); |
1253 | 1266 |
1254 position = gfx::PointF(); | 1267 position = gfx::PointF(); |
1255 bounds = gfx::Size(200, 200); | 1268 bounds = gfx::Size(200, 200); |
1256 SetLayerPropertiesForTesting(scroll_child.get(), identity_matrix, | 1269 SetLayerPropertiesForTesting(scroll_child.get(), identity_matrix, |
1257 transform_origin, position, bounds, true, | 1270 transform_origin, position, bounds, true, |
1258 false, false); | 1271 false, false); |
1259 scroll_child->SetDrawsContent(true); | 1272 scroll_child->SetDrawsContent(true); |
1260 | 1273 |
1261 // This should cause scroll child and its descendants to be affected by | 1274 // This should cause scroll child and its descendants to be affected by |
1262 // |child|'s clip. | 1275 // |child|'s clip. |
1263 scroll_child->SetScrollParent(child.get()); | 1276 scroll_child->SetScrollParent(child.get()); |
1264 scoped_ptr<std::set<LayerImpl*>> scroll_children(new std::set<LayerImpl*>); | 1277 std::unique_ptr<std::set<LayerImpl*>> scroll_children( |
| 1278 new std::set<LayerImpl*>); |
1265 scroll_children->insert(scroll_child.get()); | 1279 scroll_children->insert(scroll_child.get()); |
1266 child->SetScrollChildren(scroll_children.release()); | 1280 child->SetScrollChildren(scroll_children.release()); |
1267 | 1281 |
1268 SetLayerPropertiesForTesting(grand_child.get(), identity_matrix, | 1282 SetLayerPropertiesForTesting(grand_child.get(), identity_matrix, |
1269 transform_origin, position, bounds, true, | 1283 transform_origin, position, bounds, true, |
1270 false, false); | 1284 false, false); |
1271 grand_child->SetDrawsContent(true); | 1285 grand_child->SetDrawsContent(true); |
1272 grand_child->SetHasRenderSurface(true); | 1286 grand_child->SetHasRenderSurface(true); |
1273 | 1287 |
1274 scroll_child->AddChild(std::move(grand_child)); | 1288 scroll_child->AddChild(std::move(grand_child)); |
(...skipping 11 matching lines...) Expand all Loading... |
1286 // The |test_point| should have been clipped away by |child|, the scroll | 1300 // The |test_point| should have been clipped away by |child|, the scroll |
1287 // parent, so the only thing that should be hit is |root|. | 1301 // parent, so the only thing that should be hit is |root|. |
1288 ASSERT_TRUE(result_layer); | 1302 ASSERT_TRUE(result_layer); |
1289 ASSERT_EQ(1, result_layer->id()); | 1303 ASSERT_EQ(1, result_layer->id()); |
1290 } | 1304 } |
1291 TEST_F(LayerTreeImplTest, HitTestingForMultipleLayerLists) { | 1305 TEST_F(LayerTreeImplTest, HitTestingForMultipleLayerLists) { |
1292 // | 1306 // |
1293 // The geometry is set up similarly to the previous case, but | 1307 // The geometry is set up similarly to the previous case, but |
1294 // all layers are forced to be render surfaces now. | 1308 // all layers are forced to be render surfaces now. |
1295 // | 1309 // |
1296 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); | 1310 std::unique_ptr<LayerImpl> root = |
| 1311 LayerImpl::Create(host_impl().active_tree(), 1); |
1297 LayerImpl* root_layer = root.get(); | 1312 LayerImpl* root_layer = root.get(); |
1298 | 1313 |
1299 gfx::Transform identity_matrix; | 1314 gfx::Transform identity_matrix; |
1300 gfx::Point3F transform_origin; | 1315 gfx::Point3F transform_origin; |
1301 gfx::PointF position; | 1316 gfx::PointF position; |
1302 gfx::Size bounds(100, 100); | 1317 gfx::Size bounds(100, 100); |
1303 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, | 1318 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, |
1304 position, bounds, true, false, true); | 1319 position, bounds, true, false, true); |
1305 root->SetDrawsContent(true); | 1320 root->SetDrawsContent(true); |
1306 { | 1321 { |
1307 // child 1 and child2 are initialized to overlap between x=50 and x=60. | 1322 // child 1 and child2 are initialized to overlap between x=50 and x=60. |
1308 // grand_child is set to overlap both child1 and child2 between y=50 and | 1323 // grand_child is set to overlap both child1 and child2 between y=50 and |
1309 // y=60. The expected stacking order is: (front) child2, (second) | 1324 // y=60. The expected stacking order is: (front) child2, (second) |
1310 // grand_child, (third) child1, and (back) the root layer behind all other | 1325 // grand_child, (third) child1, and (back) the root layer behind all other |
1311 // layers. | 1326 // layers. |
1312 | 1327 |
1313 scoped_ptr<LayerImpl> child1 = | 1328 std::unique_ptr<LayerImpl> child1 = |
1314 LayerImpl::Create(host_impl().active_tree(), 2); | 1329 LayerImpl::Create(host_impl().active_tree(), 2); |
1315 scoped_ptr<LayerImpl> child2 = | 1330 std::unique_ptr<LayerImpl> child2 = |
1316 LayerImpl::Create(host_impl().active_tree(), 3); | 1331 LayerImpl::Create(host_impl().active_tree(), 3); |
1317 scoped_ptr<LayerImpl> grand_child1 = | 1332 std::unique_ptr<LayerImpl> grand_child1 = |
1318 LayerImpl::Create(host_impl().active_tree(), 4); | 1333 LayerImpl::Create(host_impl().active_tree(), 4); |
1319 | 1334 |
1320 position = gfx::PointF(10.f, 10.f); | 1335 position = gfx::PointF(10.f, 10.f); |
1321 bounds = gfx::Size(50, 50); | 1336 bounds = gfx::Size(50, 50); |
1322 SetLayerPropertiesForTesting(child1.get(), identity_matrix, | 1337 SetLayerPropertiesForTesting(child1.get(), identity_matrix, |
1323 transform_origin, position, bounds, true, | 1338 transform_origin, position, bounds, true, |
1324 false, false); | 1339 false, false); |
1325 child1->SetDrawsContent(true); | 1340 child1->SetDrawsContent(true); |
1326 child1->SetForceRenderSurface(true); | 1341 child1->SetForceRenderSurface(true); |
1327 | 1342 |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1421 // At (20, 51), child1 and grand_child1 overlap. grand_child1 is expected to | 1436 // At (20, 51), child1 and grand_child1 overlap. grand_child1 is expected to |
1422 // be on top. | 1437 // be on top. |
1423 test_point = gfx::PointF(20.f, 51.f); | 1438 test_point = gfx::PointF(20.f, 51.f); |
1424 result_layer = | 1439 result_layer = |
1425 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 1440 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); |
1426 ASSERT_TRUE(result_layer); | 1441 ASSERT_TRUE(result_layer); |
1427 EXPECT_EQ(4, result_layer->id()); | 1442 EXPECT_EQ(4, result_layer->id()); |
1428 } | 1443 } |
1429 | 1444 |
1430 TEST_F(LayerTreeImplTest, HitCheckingTouchHandlerRegionsForSingleLayer) { | 1445 TEST_F(LayerTreeImplTest, HitCheckingTouchHandlerRegionsForSingleLayer) { |
1431 scoped_ptr<LayerImpl> root = | 1446 std::unique_ptr<LayerImpl> root = |
1432 LayerImpl::Create(host_impl().active_tree(), 12345); | 1447 LayerImpl::Create(host_impl().active_tree(), 12345); |
1433 | 1448 |
1434 gfx::Transform identity_matrix; | 1449 gfx::Transform identity_matrix; |
1435 Region touch_handler_region(gfx::Rect(10, 10, 50, 50)); | 1450 Region touch_handler_region(gfx::Rect(10, 10, 50, 50)); |
1436 gfx::Point3F transform_origin; | 1451 gfx::Point3F transform_origin; |
1437 gfx::PointF position; | 1452 gfx::PointF position; |
1438 gfx::Size bounds(100, 100); | 1453 gfx::Size bounds(100, 100); |
1439 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, | 1454 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, |
1440 position, bounds, true, false, true); | 1455 position, bounds, true, false, true); |
1441 root->SetDrawsContent(true); | 1456 root->SetDrawsContent(true); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1497 test_point = gfx::PointF(59.f, 59.f); | 1512 test_point = gfx::PointF(59.f, 59.f); |
1498 result_layer = | 1513 result_layer = |
1499 host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 1514 host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( |
1500 test_point); | 1515 test_point); |
1501 ASSERT_TRUE(result_layer); | 1516 ASSERT_TRUE(result_layer); |
1502 EXPECT_EQ(12345, result_layer->id()); | 1517 EXPECT_EQ(12345, result_layer->id()); |
1503 } | 1518 } |
1504 | 1519 |
1505 TEST_F(LayerTreeImplTest, | 1520 TEST_F(LayerTreeImplTest, |
1506 HitCheckingTouchHandlerRegionsForUninvertibleTransform) { | 1521 HitCheckingTouchHandlerRegionsForUninvertibleTransform) { |
1507 scoped_ptr<LayerImpl> root = | 1522 std::unique_ptr<LayerImpl> root = |
1508 LayerImpl::Create(host_impl().active_tree(), 12345); | 1523 LayerImpl::Create(host_impl().active_tree(), 12345); |
1509 | 1524 |
1510 gfx::Transform uninvertible_transform; | 1525 gfx::Transform uninvertible_transform; |
1511 uninvertible_transform.matrix().set(0, 0, 0.0); | 1526 uninvertible_transform.matrix().set(0, 0, 0.0); |
1512 uninvertible_transform.matrix().set(1, 1, 0.0); | 1527 uninvertible_transform.matrix().set(1, 1, 0.0); |
1513 uninvertible_transform.matrix().set(2, 2, 0.0); | 1528 uninvertible_transform.matrix().set(2, 2, 0.0); |
1514 uninvertible_transform.matrix().set(3, 3, 0.0); | 1529 uninvertible_transform.matrix().set(3, 3, 0.0); |
1515 ASSERT_FALSE(uninvertible_transform.IsInvertible()); | 1530 ASSERT_FALSE(uninvertible_transform.IsInvertible()); |
1516 | 1531 |
1517 gfx::Transform identity_matrix; | 1532 gfx::Transform identity_matrix; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1576 | 1591 |
1577 test_point = gfx::PointF(-1.f, -1.f); | 1592 test_point = gfx::PointF(-1.f, -1.f); |
1578 result_layer = | 1593 result_layer = |
1579 host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 1594 host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( |
1580 test_point); | 1595 test_point); |
1581 EXPECT_FALSE(result_layer); | 1596 EXPECT_FALSE(result_layer); |
1582 } | 1597 } |
1583 | 1598 |
1584 TEST_F(LayerTreeImplTest, | 1599 TEST_F(LayerTreeImplTest, |
1585 HitCheckingTouchHandlerRegionsForSinglePositionedLayer) { | 1600 HitCheckingTouchHandlerRegionsForSinglePositionedLayer) { |
1586 scoped_ptr<LayerImpl> root = | 1601 std::unique_ptr<LayerImpl> root = |
1587 LayerImpl::Create(host_impl().active_tree(), 12345); | 1602 LayerImpl::Create(host_impl().active_tree(), 12345); |
1588 | 1603 |
1589 gfx::Transform identity_matrix; | 1604 gfx::Transform identity_matrix; |
1590 Region touch_handler_region(gfx::Rect(10, 10, 50, 50)); | 1605 Region touch_handler_region(gfx::Rect(10, 10, 50, 50)); |
1591 gfx::Point3F transform_origin; | 1606 gfx::Point3F transform_origin; |
1592 // this layer is positioned, and hit testing should correctly know where the | 1607 // this layer is positioned, and hit testing should correctly know where the |
1593 // layer is located. | 1608 // layer is located. |
1594 gfx::PointF position(50.f, 50.f); | 1609 gfx::PointF position(50.f, 50.f); |
1595 gfx::Size bounds(100, 100); | 1610 gfx::Size bounds(100, 100); |
1596 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, | 1611 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1644 test_point); | 1659 test_point); |
1645 ASSERT_TRUE(result_layer); | 1660 ASSERT_TRUE(result_layer); |
1646 EXPECT_EQ(12345, result_layer->id()); | 1661 EXPECT_EQ(12345, result_layer->id()); |
1647 } | 1662 } |
1648 | 1663 |
1649 TEST_F(LayerTreeImplTest, | 1664 TEST_F(LayerTreeImplTest, |
1650 HitCheckingTouchHandlerRegionsForSingleLayerWithDeviceScale) { | 1665 HitCheckingTouchHandlerRegionsForSingleLayerWithDeviceScale) { |
1651 // The layer's device_scale_factor and page_scale_factor should scale the | 1666 // The layer's device_scale_factor and page_scale_factor should scale the |
1652 // content rect and we should be able to hit the touch handler region by | 1667 // content rect and we should be able to hit the touch handler region by |
1653 // scaling the points accordingly. | 1668 // scaling the points accordingly. |
1654 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); | 1669 std::unique_ptr<LayerImpl> root = |
| 1670 LayerImpl::Create(host_impl().active_tree(), 1); |
1655 | 1671 |
1656 gfx::Transform identity_matrix; | 1672 gfx::Transform identity_matrix; |
1657 gfx::Point3F transform_origin; | 1673 gfx::Point3F transform_origin; |
1658 // Set the bounds of the root layer big enough to fit the child when scaled. | 1674 // Set the bounds of the root layer big enough to fit the child when scaled. |
1659 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, | 1675 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, |
1660 gfx::PointF(), gfx::Size(100, 100), true, false, | 1676 gfx::PointF(), gfx::Size(100, 100), true, false, |
1661 true); | 1677 true); |
1662 { | 1678 { |
1663 Region touch_handler_region(gfx::Rect(10, 10, 30, 30)); | 1679 Region touch_handler_region(gfx::Rect(10, 10, 30, 30)); |
1664 gfx::PointF position(25.f, 25.f); | 1680 gfx::PointF position(25.f, 25.f); |
1665 gfx::Size bounds(50, 50); | 1681 gfx::Size bounds(50, 50); |
1666 scoped_ptr<LayerImpl> test_layer = | 1682 std::unique_ptr<LayerImpl> test_layer = |
1667 LayerImpl::Create(host_impl().active_tree(), 12345); | 1683 LayerImpl::Create(host_impl().active_tree(), 12345); |
1668 SetLayerPropertiesForTesting(test_layer.get(), identity_matrix, | 1684 SetLayerPropertiesForTesting(test_layer.get(), identity_matrix, |
1669 transform_origin, position, bounds, true, | 1685 transform_origin, position, bounds, true, |
1670 false, false); | 1686 false, false); |
1671 | 1687 |
1672 test_layer->SetDrawsContent(true); | 1688 test_layer->SetDrawsContent(true); |
1673 test_layer->SetTouchEventHandlerRegion(touch_handler_region); | 1689 test_layer->SetTouchEventHandlerRegion(touch_handler_region); |
1674 root->AddChild(std::move(test_layer)); | 1690 root->AddChild(std::move(test_layer)); |
1675 } | 1691 } |
1676 | 1692 |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1793 EXPECT_EQ(12345, result_layer->id()); | 1809 EXPECT_EQ(12345, result_layer->id()); |
1794 } | 1810 } |
1795 | 1811 |
1796 TEST_F(LayerTreeImplTest, HitCheckingTouchHandlerRegionsForSimpleClippedLayer) { | 1812 TEST_F(LayerTreeImplTest, HitCheckingTouchHandlerRegionsForSimpleClippedLayer) { |
1797 // Test that hit-checking will only work for the visible portion of a layer, | 1813 // Test that hit-checking will only work for the visible portion of a layer, |
1798 // and not the entire layer bounds. Here we just test the simple axis-aligned | 1814 // and not the entire layer bounds. Here we just test the simple axis-aligned |
1799 // case. | 1815 // case. |
1800 gfx::Transform identity_matrix; | 1816 gfx::Transform identity_matrix; |
1801 gfx::Point3F transform_origin; | 1817 gfx::Point3F transform_origin; |
1802 | 1818 |
1803 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); | 1819 std::unique_ptr<LayerImpl> root = |
| 1820 LayerImpl::Create(host_impl().active_tree(), 1); |
1804 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, | 1821 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, |
1805 gfx::PointF(), gfx::Size(100, 100), true, false, | 1822 gfx::PointF(), gfx::Size(100, 100), true, false, |
1806 true); | 1823 true); |
1807 { | 1824 { |
1808 scoped_ptr<LayerImpl> clipping_layer = | 1825 std::unique_ptr<LayerImpl> clipping_layer = |
1809 LayerImpl::Create(host_impl().active_tree(), 123); | 1826 LayerImpl::Create(host_impl().active_tree(), 123); |
1810 // this layer is positioned, and hit testing should correctly know where the | 1827 // this layer is positioned, and hit testing should correctly know where the |
1811 // layer is located. | 1828 // layer is located. |
1812 gfx::PointF position(25.f, 25.f); | 1829 gfx::PointF position(25.f, 25.f); |
1813 gfx::Size bounds(50, 50); | 1830 gfx::Size bounds(50, 50); |
1814 SetLayerPropertiesForTesting(clipping_layer.get(), identity_matrix, | 1831 SetLayerPropertiesForTesting(clipping_layer.get(), identity_matrix, |
1815 transform_origin, position, bounds, true, | 1832 transform_origin, position, bounds, true, |
1816 false, false); | 1833 false, false); |
1817 clipping_layer->SetMasksToBounds(true); | 1834 clipping_layer->SetMasksToBounds(true); |
1818 | 1835 |
1819 scoped_ptr<LayerImpl> child = | 1836 std::unique_ptr<LayerImpl> child = |
1820 LayerImpl::Create(host_impl().active_tree(), 456); | 1837 LayerImpl::Create(host_impl().active_tree(), 456); |
1821 Region touch_handler_region(gfx::Rect(10, 10, 50, 50)); | 1838 Region touch_handler_region(gfx::Rect(10, 10, 50, 50)); |
1822 position = gfx::PointF(-50.f, -50.f); | 1839 position = gfx::PointF(-50.f, -50.f); |
1823 bounds = gfx::Size(300, 300); | 1840 bounds = gfx::Size(300, 300); |
1824 SetLayerPropertiesForTesting(child.get(), identity_matrix, transform_origin, | 1841 SetLayerPropertiesForTesting(child.get(), identity_matrix, transform_origin, |
1825 position, bounds, true, false, false); | 1842 position, bounds, true, false, false); |
1826 child->SetDrawsContent(true); | 1843 child->SetDrawsContent(true); |
1827 child->SetTouchEventHandlerRegion(touch_handler_region); | 1844 child->SetTouchEventHandlerRegion(touch_handler_region); |
1828 clipping_layer->AddChild(std::move(child)); | 1845 clipping_layer->AddChild(std::move(child)); |
1829 root->AddChild(std::move(clipping_layer)); | 1846 root->AddChild(std::move(clipping_layer)); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1875 host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 1892 host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( |
1876 test_point); | 1893 test_point); |
1877 ASSERT_TRUE(result_layer); | 1894 ASSERT_TRUE(result_layer); |
1878 EXPECT_EQ(456, result_layer->id()); | 1895 EXPECT_EQ(456, result_layer->id()); |
1879 } | 1896 } |
1880 | 1897 |
1881 TEST_F(LayerTreeImplTest, HitCheckingTouchHandlerOverlappingRegions) { | 1898 TEST_F(LayerTreeImplTest, HitCheckingTouchHandlerOverlappingRegions) { |
1882 gfx::Transform identity_matrix; | 1899 gfx::Transform identity_matrix; |
1883 gfx::Point3F transform_origin; | 1900 gfx::Point3F transform_origin; |
1884 | 1901 |
1885 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); | 1902 std::unique_ptr<LayerImpl> root = |
| 1903 LayerImpl::Create(host_impl().active_tree(), 1); |
1886 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, | 1904 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, |
1887 gfx::PointF(), gfx::Size(100, 100), true, false, | 1905 gfx::PointF(), gfx::Size(100, 100), true, false, |
1888 true); | 1906 true); |
1889 { | 1907 { |
1890 scoped_ptr<LayerImpl> touch_layer = | 1908 std::unique_ptr<LayerImpl> touch_layer = |
1891 LayerImpl::Create(host_impl().active_tree(), 123); | 1909 LayerImpl::Create(host_impl().active_tree(), 123); |
1892 // this layer is positioned, and hit testing should correctly know where the | 1910 // this layer is positioned, and hit testing should correctly know where the |
1893 // layer is located. | 1911 // layer is located. |
1894 gfx::PointF position; | 1912 gfx::PointF position; |
1895 gfx::Size bounds(50, 50); | 1913 gfx::Size bounds(50, 50); |
1896 SetLayerPropertiesForTesting(touch_layer.get(), identity_matrix, | 1914 SetLayerPropertiesForTesting(touch_layer.get(), identity_matrix, |
1897 transform_origin, position, bounds, true, | 1915 transform_origin, position, bounds, true, |
1898 false, false); | 1916 false, false); |
1899 touch_layer->SetDrawsContent(true); | 1917 touch_layer->SetDrawsContent(true); |
1900 touch_layer->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 50, 50)); | 1918 touch_layer->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 50, 50)); |
1901 root->AddChild(std::move(touch_layer)); | 1919 root->AddChild(std::move(touch_layer)); |
1902 } | 1920 } |
1903 | 1921 |
1904 { | 1922 { |
1905 scoped_ptr<LayerImpl> notouch_layer = | 1923 std::unique_ptr<LayerImpl> notouch_layer = |
1906 LayerImpl::Create(host_impl().active_tree(), 1234); | 1924 LayerImpl::Create(host_impl().active_tree(), 1234); |
1907 // this layer is positioned, and hit testing should correctly know where the | 1925 // this layer is positioned, and hit testing should correctly know where the |
1908 // layer is located. | 1926 // layer is located. |
1909 gfx::PointF position(0, 25); | 1927 gfx::PointF position(0, 25); |
1910 gfx::Size bounds(50, 50); | 1928 gfx::Size bounds(50, 50); |
1911 SetLayerPropertiesForTesting(notouch_layer.get(), identity_matrix, | 1929 SetLayerPropertiesForTesting(notouch_layer.get(), identity_matrix, |
1912 transform_origin, position, bounds, true, | 1930 transform_origin, position, bounds, true, |
1913 false, false); | 1931 false, false); |
1914 notouch_layer->SetDrawsContent(true); | 1932 notouch_layer->SetDrawsContent(true); |
1915 root->AddChild(std::move(notouch_layer)); | 1933 root->AddChild(std::move(notouch_layer)); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1953 EXPECT_EQ(123, result_layer->id()); | 1971 EXPECT_EQ(123, result_layer->id()); |
1954 | 1972 |
1955 test_point = gfx::PointF(35.f, 65.f); | 1973 test_point = gfx::PointF(35.f, 65.f); |
1956 result_layer = | 1974 result_layer = |
1957 host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 1975 host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( |
1958 test_point); | 1976 test_point); |
1959 EXPECT_FALSE(result_layer); | 1977 EXPECT_FALSE(result_layer); |
1960 } | 1978 } |
1961 | 1979 |
1962 TEST_F(LayerTreeImplTest, HitTestingTouchHandlerRegionsForLayerThatIsNotDrawn) { | 1980 TEST_F(LayerTreeImplTest, HitTestingTouchHandlerRegionsForLayerThatIsNotDrawn) { |
1963 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); | 1981 std::unique_ptr<LayerImpl> root = |
| 1982 LayerImpl::Create(host_impl().active_tree(), 1); |
1964 | 1983 |
1965 gfx::Transform identity_matrix; | 1984 gfx::Transform identity_matrix; |
1966 gfx::Point3F transform_origin; | 1985 gfx::Point3F transform_origin; |
1967 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, | 1986 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, |
1968 gfx::PointF(), gfx::Size(100, 100), true, false, | 1987 gfx::PointF(), gfx::Size(100, 100), true, false, |
1969 true); | 1988 true); |
1970 root->SetDrawsContent(true); | 1989 root->SetDrawsContent(true); |
1971 { | 1990 { |
1972 Region touch_handler_region(gfx::Rect(10, 10, 30, 30)); | 1991 Region touch_handler_region(gfx::Rect(10, 10, 30, 30)); |
1973 gfx::PointF position; | 1992 gfx::PointF position; |
1974 gfx::Size bounds(50, 50); | 1993 gfx::Size bounds(50, 50); |
1975 scoped_ptr<LayerImpl> test_layer = | 1994 std::unique_ptr<LayerImpl> test_layer = |
1976 LayerImpl::Create(host_impl().active_tree(), 12345); | 1995 LayerImpl::Create(host_impl().active_tree(), 12345); |
1977 SetLayerPropertiesForTesting(test_layer.get(), identity_matrix, | 1996 SetLayerPropertiesForTesting(test_layer.get(), identity_matrix, |
1978 transform_origin, position, bounds, true, | 1997 transform_origin, position, bounds, true, |
1979 false, false); | 1998 false, false); |
1980 | 1999 |
1981 test_layer->SetDrawsContent(false); | 2000 test_layer->SetDrawsContent(false); |
1982 test_layer->SetTouchEventHandlerRegion(touch_handler_region); | 2001 test_layer->SetTouchEventHandlerRegion(touch_handler_region); |
1983 root->AddChild(std::move(test_layer)); | 2002 root->AddChild(std::move(test_layer)); |
1984 } | 2003 } |
1985 host_impl().SetViewportSize(root->bounds()); | 2004 host_impl().SetViewportSize(root->bounds()); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2034 EXPECT_FALSE(result_layer->IsDrawnRenderSurfaceLayerListMember()); | 2053 EXPECT_FALSE(result_layer->IsDrawnRenderSurfaceLayerListMember()); |
2035 EXPECT_TRANSFORMATION_MATRIX_EQ( | 2054 EXPECT_TRANSFORMATION_MATRIX_EQ( |
2036 expected_screen_space_transform, | 2055 expected_screen_space_transform, |
2037 draw_property_utils::ScreenSpaceTransform( | 2056 draw_property_utils::ScreenSpaceTransform( |
2038 test_layer, | 2057 test_layer, |
2039 host_impl().active_tree()->property_trees()->transform_tree)); | 2058 host_impl().active_tree()->property_trees()->transform_tree)); |
2040 } | 2059 } |
2041 | 2060 |
2042 TEST_F(LayerTreeImplTest, SelectionBoundsForSingleLayer) { | 2061 TEST_F(LayerTreeImplTest, SelectionBoundsForSingleLayer) { |
2043 int root_layer_id = 12345; | 2062 int root_layer_id = 12345; |
2044 scoped_ptr<LayerImpl> root = | 2063 std::unique_ptr<LayerImpl> root = |
2045 LayerImpl::Create(host_impl().active_tree(), root_layer_id); | 2064 LayerImpl::Create(host_impl().active_tree(), root_layer_id); |
2046 | 2065 |
2047 gfx::Transform identity_matrix; | 2066 gfx::Transform identity_matrix; |
2048 gfx::Point3F transform_origin; | 2067 gfx::Point3F transform_origin; |
2049 gfx::PointF position; | 2068 gfx::PointF position; |
2050 gfx::Size bounds(100, 100); | 2069 gfx::Size bounds(100, 100); |
2051 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, | 2070 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, |
2052 position, bounds, true, false, true); | 2071 position, bounds, true, false, true); |
2053 root->SetDrawsContent(true); | 2072 root->SetDrawsContent(true); |
2054 | 2073 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2113 EXPECT_EQ(insertion_input.is_empty_text_form_control, | 2132 EXPECT_EQ(insertion_input.is_empty_text_form_control, |
2114 output.is_empty_text_form_control); | 2133 output.is_empty_text_form_control); |
2115 EXPECT_TRUE(output.start.visible); | 2134 EXPECT_TRUE(output.start.visible); |
2116 EXPECT_EQ(output.start, output.end); | 2135 EXPECT_EQ(output.start, output.end); |
2117 } | 2136 } |
2118 | 2137 |
2119 TEST_F(LayerTreeImplTest, SelectionBoundsForPartialOccludedLayers) { | 2138 TEST_F(LayerTreeImplTest, SelectionBoundsForPartialOccludedLayers) { |
2120 int root_layer_id = 12345; | 2139 int root_layer_id = 12345; |
2121 int clip_layer_id = 1234; | 2140 int clip_layer_id = 1234; |
2122 int clipped_layer_id = 123; | 2141 int clipped_layer_id = 123; |
2123 scoped_ptr<LayerImpl> root = | 2142 std::unique_ptr<LayerImpl> root = |
2124 LayerImpl::Create(host_impl().active_tree(), root_layer_id); | 2143 LayerImpl::Create(host_impl().active_tree(), root_layer_id); |
2125 root->SetDrawsContent(true); | 2144 root->SetDrawsContent(true); |
2126 | 2145 |
2127 gfx::Transform identity_matrix; | 2146 gfx::Transform identity_matrix; |
2128 gfx::Point3F transform_origin; | 2147 gfx::Point3F transform_origin; |
2129 gfx::PointF position; | 2148 gfx::PointF position; |
2130 gfx::Size bounds(100, 100); | 2149 gfx::Size bounds(100, 100); |
2131 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, | 2150 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, |
2132 position, bounds, true, false, true); | 2151 position, bounds, true, false, true); |
2133 | 2152 |
2134 gfx::Vector2dF clipping_offset(10, 10); | 2153 gfx::Vector2dF clipping_offset(10, 10); |
2135 { | 2154 { |
2136 scoped_ptr<LayerImpl> clipping_layer = | 2155 std::unique_ptr<LayerImpl> clipping_layer = |
2137 LayerImpl::Create(host_impl().active_tree(), clip_layer_id); | 2156 LayerImpl::Create(host_impl().active_tree(), clip_layer_id); |
2138 // The clipping layer should occlude the right selection bound. | 2157 // The clipping layer should occlude the right selection bound. |
2139 gfx::PointF position = gfx::PointF() + clipping_offset; | 2158 gfx::PointF position = gfx::PointF() + clipping_offset; |
2140 gfx::Size bounds(50, 50); | 2159 gfx::Size bounds(50, 50); |
2141 SetLayerPropertiesForTesting(clipping_layer.get(), identity_matrix, | 2160 SetLayerPropertiesForTesting(clipping_layer.get(), identity_matrix, |
2142 transform_origin, position, bounds, true, | 2161 transform_origin, position, bounds, true, |
2143 false, false); | 2162 false, false); |
2144 clipping_layer->SetMasksToBounds(true); | 2163 clipping_layer->SetMasksToBounds(true); |
2145 | 2164 |
2146 scoped_ptr<LayerImpl> clipped_layer = | 2165 std::unique_ptr<LayerImpl> clipped_layer = |
2147 LayerImpl::Create(host_impl().active_tree(), clipped_layer_id); | 2166 LayerImpl::Create(host_impl().active_tree(), clipped_layer_id); |
2148 position = gfx::PointF(); | 2167 position = gfx::PointF(); |
2149 bounds = gfx::Size(100, 100); | 2168 bounds = gfx::Size(100, 100); |
2150 SetLayerPropertiesForTesting(clipped_layer.get(), identity_matrix, | 2169 SetLayerPropertiesForTesting(clipped_layer.get(), identity_matrix, |
2151 transform_origin, position, bounds, true, | 2170 transform_origin, position, bounds, true, |
2152 false, false); | 2171 false, false); |
2153 clipped_layer->SetDrawsContent(true); | 2172 clipped_layer->SetDrawsContent(true); |
2154 clipping_layer->AddChild(std::move(clipped_layer)); | 2173 clipping_layer->AddChild(std::move(clipped_layer)); |
2155 root->AddChild(std::move(clipping_layer)); | 2174 root->AddChild(std::move(clipping_layer)); |
2156 } | 2175 } |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2211 input.start.edge_top = gfx::Point(0, -20); | 2230 input.start.edge_top = gfx::Point(0, -20); |
2212 input.start.edge_bottom = gfx::Point(0, 1); | 2231 input.start.edge_bottom = gfx::Point(0, 1); |
2213 host_impl().active_tree()->RegisterSelection(input); | 2232 host_impl().active_tree()->RegisterSelection(input); |
2214 host_impl().active_tree()->GetViewportSelection(&output); | 2233 host_impl().active_tree()->GetViewportSelection(&output); |
2215 EXPECT_TRUE(output.start.visible); | 2234 EXPECT_TRUE(output.start.visible); |
2216 } | 2235 } |
2217 | 2236 |
2218 TEST_F(LayerTreeImplTest, SelectionBoundsForScaledLayers) { | 2237 TEST_F(LayerTreeImplTest, SelectionBoundsForScaledLayers) { |
2219 int root_layer_id = 1; | 2238 int root_layer_id = 1; |
2220 int sub_layer_id = 2; | 2239 int sub_layer_id = 2; |
2221 scoped_ptr<LayerImpl> root = | 2240 std::unique_ptr<LayerImpl> root = |
2222 LayerImpl::Create(host_impl().active_tree(), root_layer_id); | 2241 LayerImpl::Create(host_impl().active_tree(), root_layer_id); |
2223 root->SetDrawsContent(true); | 2242 root->SetDrawsContent(true); |
2224 | 2243 |
2225 gfx::Transform identity_matrix; | 2244 gfx::Transform identity_matrix; |
2226 gfx::Point3F transform_origin; | 2245 gfx::Point3F transform_origin; |
2227 gfx::PointF position; | 2246 gfx::PointF position; |
2228 gfx::Size bounds(100, 100); | 2247 gfx::Size bounds(100, 100); |
2229 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, | 2248 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, |
2230 position, bounds, true, false, true); | 2249 position, bounds, true, false, true); |
2231 | 2250 |
2232 gfx::Vector2dF sub_layer_offset(10, 0); | 2251 gfx::Vector2dF sub_layer_offset(10, 0); |
2233 { | 2252 { |
2234 scoped_ptr<LayerImpl> sub_layer = | 2253 std::unique_ptr<LayerImpl> sub_layer = |
2235 LayerImpl::Create(host_impl().active_tree(), sub_layer_id); | 2254 LayerImpl::Create(host_impl().active_tree(), sub_layer_id); |
2236 gfx::PointF position = gfx::PointF() + sub_layer_offset; | 2255 gfx::PointF position = gfx::PointF() + sub_layer_offset; |
2237 gfx::Size bounds(50, 50); | 2256 gfx::Size bounds(50, 50); |
2238 SetLayerPropertiesForTesting(sub_layer.get(), identity_matrix, | 2257 SetLayerPropertiesForTesting(sub_layer.get(), identity_matrix, |
2239 transform_origin, position, bounds, true, | 2258 transform_origin, position, bounds, true, |
2240 false, false); | 2259 false, false); |
2241 sub_layer->SetDrawsContent(true); | 2260 sub_layer->SetDrawsContent(true); |
2242 root->AddChild(std::move(sub_layer)); | 2261 root->AddChild(std::move(sub_layer)); |
2243 } | 2262 } |
2244 | 2263 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2297 EXPECT_EQ(expected_output_end_top, output.end.edge_top); | 2316 EXPECT_EQ(expected_output_end_top, output.end.edge_top); |
2298 EXPECT_EQ(expected_output_end_bottom, output.end.edge_bottom); | 2317 EXPECT_EQ(expected_output_end_bottom, output.end.edge_bottom); |
2299 EXPECT_TRUE(output.end.visible); | 2318 EXPECT_TRUE(output.end.visible); |
2300 } | 2319 } |
2301 | 2320 |
2302 TEST_F(LayerTreeImplTest, SelectionBoundsWithLargeTransforms) { | 2321 TEST_F(LayerTreeImplTest, SelectionBoundsWithLargeTransforms) { |
2303 int root_id = 1; | 2322 int root_id = 1; |
2304 int child_id = 2; | 2323 int child_id = 2; |
2305 int grand_child_id = 3; | 2324 int grand_child_id = 3; |
2306 | 2325 |
2307 scoped_ptr<LayerImpl> root = | 2326 std::unique_ptr<LayerImpl> root = |
2308 LayerImpl::Create(host_impl().active_tree(), root_id); | 2327 LayerImpl::Create(host_impl().active_tree(), root_id); |
2309 gfx::Size bounds(100, 100); | 2328 gfx::Size bounds(100, 100); |
2310 gfx::Transform identity_matrix; | 2329 gfx::Transform identity_matrix; |
2311 gfx::Point3F transform_origin; | 2330 gfx::Point3F transform_origin; |
2312 gfx::PointF position; | 2331 gfx::PointF position; |
2313 | 2332 |
2314 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, | 2333 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, |
2315 position, bounds, true, false, true); | 2334 position, bounds, true, false, true); |
2316 | 2335 |
2317 gfx::Transform large_transform; | 2336 gfx::Transform large_transform; |
2318 large_transform.Scale(SkDoubleToMScalar(1e37), SkDoubleToMScalar(1e37)); | 2337 large_transform.Scale(SkDoubleToMScalar(1e37), SkDoubleToMScalar(1e37)); |
2319 large_transform.RotateAboutYAxis(30); | 2338 large_transform.RotateAboutYAxis(30); |
2320 | 2339 |
2321 { | 2340 { |
2322 scoped_ptr<LayerImpl> child = | 2341 std::unique_ptr<LayerImpl> child = |
2323 LayerImpl::Create(host_impl().active_tree(), child_id); | 2342 LayerImpl::Create(host_impl().active_tree(), child_id); |
2324 SetLayerPropertiesForTesting(child.get(), large_transform, transform_origin, | 2343 SetLayerPropertiesForTesting(child.get(), large_transform, transform_origin, |
2325 position, bounds, true, false, false); | 2344 position, bounds, true, false, false); |
2326 | 2345 |
2327 scoped_ptr<LayerImpl> grand_child = | 2346 std::unique_ptr<LayerImpl> grand_child = |
2328 LayerImpl::Create(host_impl().active_tree(), grand_child_id); | 2347 LayerImpl::Create(host_impl().active_tree(), grand_child_id); |
2329 SetLayerPropertiesForTesting(grand_child.get(), large_transform, | 2348 SetLayerPropertiesForTesting(grand_child.get(), large_transform, |
2330 transform_origin, position, bounds, true, | 2349 transform_origin, position, bounds, true, |
2331 false, false); | 2350 false, false); |
2332 grand_child->SetDrawsContent(true); | 2351 grand_child->SetDrawsContent(true); |
2333 | 2352 |
2334 child->AddChild(std::move(grand_child)); | 2353 child->AddChild(std::move(grand_child)); |
2335 root->AddChild(std::move(child)); | 2354 root->AddChild(std::move(child)); |
2336 } | 2355 } |
2337 | 2356 |
(...skipping 19 matching lines...) Expand all Loading... |
2357 host_impl().active_tree()->GetViewportSelection(&output); | 2376 host_impl().active_tree()->GetViewportSelection(&output); |
2358 | 2377 |
2359 // edge_bottom and edge_top aren't allowed to have NaNs, so the selection | 2378 // edge_bottom and edge_top aren't allowed to have NaNs, so the selection |
2360 // should be empty. | 2379 // should be empty. |
2361 EXPECT_EQ(ViewportSelectionBound(), output.start); | 2380 EXPECT_EQ(ViewportSelectionBound(), output.start); |
2362 EXPECT_EQ(ViewportSelectionBound(), output.end); | 2381 EXPECT_EQ(ViewportSelectionBound(), output.end); |
2363 } | 2382 } |
2364 | 2383 |
2365 TEST_F(LayerTreeImplTest, NumLayersTestOne) { | 2384 TEST_F(LayerTreeImplTest, NumLayersTestOne) { |
2366 EXPECT_EQ(0u, host_impl().active_tree()->NumLayers()); | 2385 EXPECT_EQ(0u, host_impl().active_tree()->NumLayers()); |
2367 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); | 2386 std::unique_ptr<LayerImpl> root = |
| 2387 LayerImpl::Create(host_impl().active_tree(), 1); |
2368 EXPECT_EQ(1u, host_impl().active_tree()->NumLayers()); | 2388 EXPECT_EQ(1u, host_impl().active_tree()->NumLayers()); |
2369 } | 2389 } |
2370 | 2390 |
2371 TEST_F(LayerTreeImplTest, NumLayersSmallTree) { | 2391 TEST_F(LayerTreeImplTest, NumLayersSmallTree) { |
2372 EXPECT_EQ(0u, host_impl().active_tree()->NumLayers()); | 2392 EXPECT_EQ(0u, host_impl().active_tree()->NumLayers()); |
2373 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); | 2393 std::unique_ptr<LayerImpl> root = |
| 2394 LayerImpl::Create(host_impl().active_tree(), 1); |
2374 root->AddChild(LayerImpl::Create(host_impl().active_tree(), 2)); | 2395 root->AddChild(LayerImpl::Create(host_impl().active_tree(), 2)); |
2375 root->AddChild(LayerImpl::Create(host_impl().active_tree(), 3)); | 2396 root->AddChild(LayerImpl::Create(host_impl().active_tree(), 3)); |
2376 root->child_at(1)->AddChild(LayerImpl::Create(host_impl().active_tree(), 4)); | 2397 root->child_at(1)->AddChild(LayerImpl::Create(host_impl().active_tree(), 4)); |
2377 EXPECT_EQ(4u, host_impl().active_tree()->NumLayers()); | 2398 EXPECT_EQ(4u, host_impl().active_tree()->NumLayers()); |
2378 } | 2399 } |
2379 | 2400 |
2380 TEST_F(LayerTreeImplTest, DeviceScaleFactorNeedsDrawPropertiesUpdate) { | 2401 TEST_F(LayerTreeImplTest, DeviceScaleFactorNeedsDrawPropertiesUpdate) { |
2381 host_impl().active_tree()->SetDeviceScaleFactor(1.f); | 2402 host_impl().active_tree()->SetDeviceScaleFactor(1.f); |
2382 host_impl().active_tree()->UpdateDrawProperties(false); | 2403 host_impl().active_tree()->UpdateDrawProperties(false); |
2383 EXPECT_FALSE(host_impl().active_tree()->needs_update_draw_properties()); | 2404 EXPECT_FALSE(host_impl().active_tree()->needs_update_draw_properties()); |
2384 host_impl().active_tree()->SetDeviceScaleFactor(2.f); | 2405 host_impl().active_tree()->SetDeviceScaleFactor(2.f); |
2385 EXPECT_TRUE(host_impl().active_tree()->needs_update_draw_properties()); | 2406 EXPECT_TRUE(host_impl().active_tree()->needs_update_draw_properties()); |
2386 } | 2407 } |
2387 | 2408 |
2388 TEST_F(LayerTreeImplTest, HitTestingCorrectLayerWheelListener) { | 2409 TEST_F(LayerTreeImplTest, HitTestingCorrectLayerWheelListener) { |
2389 host_impl().active_tree()->set_event_listener_properties( | 2410 host_impl().active_tree()->set_event_listener_properties( |
2390 EventListenerClass::kMouseWheel, EventListenerProperties::kBlocking); | 2411 EventListenerClass::kMouseWheel, EventListenerProperties::kBlocking); |
2391 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); | 2412 std::unique_ptr<LayerImpl> root = |
2392 scoped_ptr<LayerImpl> left_child = | 2413 LayerImpl::Create(host_impl().active_tree(), 1); |
| 2414 std::unique_ptr<LayerImpl> left_child = |
2393 LayerImpl::Create(host_impl().active_tree(), 2); | 2415 LayerImpl::Create(host_impl().active_tree(), 2); |
2394 scoped_ptr<LayerImpl> right_child = | 2416 std::unique_ptr<LayerImpl> right_child = |
2395 LayerImpl::Create(host_impl().active_tree(), 3); | 2417 LayerImpl::Create(host_impl().active_tree(), 3); |
2396 | 2418 |
2397 gfx::Point3F transform_origin; | 2419 gfx::Point3F transform_origin; |
2398 gfx::PointF position; | 2420 gfx::PointF position; |
2399 gfx::Size bounds(100, 100); | 2421 gfx::Size bounds(100, 100); |
2400 { | 2422 { |
2401 gfx::Transform translate_z; | 2423 gfx::Transform translate_z; |
2402 translate_z.Translate3d(0, 0, 10); | 2424 translate_z.Translate3d(0, 0, 10); |
2403 SetLayerPropertiesForTesting(root.get(), translate_z, transform_origin, | 2425 SetLayerPropertiesForTesting(root.get(), translate_z, transform_origin, |
2404 position, bounds, false, false, true); | 2426 position, bounds, false, false, true); |
(...skipping 26 matching lines...) Expand all Loading... |
2431 gfx::PointF test_point = gfx::PointF(1.f, 1.f); | 2453 gfx::PointF test_point = gfx::PointF(1.f, 1.f); |
2432 LayerImpl* result_layer = | 2454 LayerImpl* result_layer = |
2433 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 2455 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); |
2434 | 2456 |
2435 CHECK(result_layer); | 2457 CHECK(result_layer); |
2436 EXPECT_EQ(2, result_layer->id()); | 2458 EXPECT_EQ(2, result_layer->id()); |
2437 } | 2459 } |
2438 | 2460 |
2439 } // namespace | 2461 } // namespace |
2440 } // namespace cc | 2462 } // namespace cc |
OLD | NEW |