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/test/fake_impl_proxy.h" | 9 #include "cc/test/fake_impl_proxy.h" |
10 #include "cc/test/fake_layer_tree_host_impl.h" | 10 #include "cc/test/fake_layer_tree_host_impl.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 }; | 43 }; |
44 | 44 |
45 TEST_F(LayerTreeImplTest, HitTestingForSingleLayer) { | 45 TEST_F(LayerTreeImplTest, HitTestingForSingleLayer) { |
46 scoped_ptr<LayerImpl> root = | 46 scoped_ptr<LayerImpl> root = |
47 LayerImpl::Create(host_impl().active_tree(), 12345); | 47 LayerImpl::Create(host_impl().active_tree(), 12345); |
48 | 48 |
49 gfx::Transform identity_matrix; | 49 gfx::Transform identity_matrix; |
50 gfx::Point3F transform_origin; | 50 gfx::Point3F transform_origin; |
51 gfx::PointF position; | 51 gfx::PointF position; |
52 gfx::Size bounds(100, 100); | 52 gfx::Size bounds(100, 100); |
53 SetLayerPropertiesForTesting(root.get(), | 53 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, |
54 identity_matrix, | 54 position, bounds, true, false, true); |
55 transform_origin, | |
56 position, | |
57 bounds, | |
58 true, | |
59 false); | |
60 root->SetDrawsContent(true); | 55 root->SetDrawsContent(true); |
61 | 56 |
62 host_impl().SetViewportSize(root->bounds()); | 57 host_impl().SetViewportSize(root->bounds()); |
63 host_impl().active_tree()->SetRootLayer(root.Pass()); | 58 host_impl().active_tree()->SetRootLayer(root.Pass()); |
64 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 59 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
65 | 60 |
66 // Sanity check the scenario we just created. | 61 // Sanity check the scenario we just created. |
67 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 62 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); |
68 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); | 63 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); |
69 | 64 |
(...skipping 25 matching lines...) Expand all Loading... |
95 TEST_F(LayerTreeImplTest, HitTestingForSingleLayerAndHud) { | 90 TEST_F(LayerTreeImplTest, HitTestingForSingleLayerAndHud) { |
96 scoped_ptr<LayerImpl> root = | 91 scoped_ptr<LayerImpl> root = |
97 LayerImpl::Create(host_impl().active_tree(), 12345); | 92 LayerImpl::Create(host_impl().active_tree(), 12345); |
98 scoped_ptr<HeadsUpDisplayLayerImpl> hud = | 93 scoped_ptr<HeadsUpDisplayLayerImpl> hud = |
99 HeadsUpDisplayLayerImpl::Create(host_impl().active_tree(), 11111); | 94 HeadsUpDisplayLayerImpl::Create(host_impl().active_tree(), 11111); |
100 | 95 |
101 gfx::Transform identity_matrix; | 96 gfx::Transform identity_matrix; |
102 gfx::Point3F transform_origin; | 97 gfx::Point3F transform_origin; |
103 gfx::PointF position; | 98 gfx::PointF position; |
104 gfx::Size bounds(100, 100); | 99 gfx::Size bounds(100, 100); |
105 SetLayerPropertiesForTesting(root.get(), | 100 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, |
106 identity_matrix, | 101 position, bounds, true, false, true); |
107 transform_origin, | |
108 position, | |
109 bounds, | |
110 true, | |
111 false); | |
112 root->SetDrawsContent(true); | 102 root->SetDrawsContent(true); |
113 | 103 |
114 // Create hud and add it as a child of root. | 104 // Create hud and add it as a child of root. |
115 gfx::Size hud_bounds(200, 200); | 105 gfx::Size hud_bounds(200, 200); |
116 SetLayerPropertiesForTesting(hud.get(), | 106 SetLayerPropertiesForTesting(hud.get(), identity_matrix, transform_origin, |
117 identity_matrix, | 107 position, hud_bounds, true, false, false); |
118 transform_origin, | |
119 position, | |
120 hud_bounds, | |
121 true, | |
122 false); | |
123 hud->SetDrawsContent(true); | 108 hud->SetDrawsContent(true); |
124 | 109 |
125 host_impl().active_tree()->set_hud_layer(hud.get()); | 110 host_impl().active_tree()->set_hud_layer(hud.get()); |
126 root->AddChild(hud.Pass()); | 111 root->AddChild(hud.Pass()); |
127 | 112 |
128 host_impl().SetViewportSize(hud_bounds); | 113 host_impl().SetViewportSize(hud_bounds); |
129 host_impl().active_tree()->SetRootLayer(root.Pass()); | 114 host_impl().active_tree()->SetRootLayer(root.Pass()); |
130 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 115 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
131 | 116 |
132 // Sanity check the scenario we just created. | 117 // Sanity check the scenario we just created. |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 uninvertible_transform.matrix().set(0, 0, 0.0); | 152 uninvertible_transform.matrix().set(0, 0, 0.0); |
168 uninvertible_transform.matrix().set(1, 1, 0.0); | 153 uninvertible_transform.matrix().set(1, 1, 0.0); |
169 uninvertible_transform.matrix().set(2, 2, 0.0); | 154 uninvertible_transform.matrix().set(2, 2, 0.0); |
170 uninvertible_transform.matrix().set(3, 3, 0.0); | 155 uninvertible_transform.matrix().set(3, 3, 0.0); |
171 ASSERT_FALSE(uninvertible_transform.IsInvertible()); | 156 ASSERT_FALSE(uninvertible_transform.IsInvertible()); |
172 | 157 |
173 gfx::Transform identity_matrix; | 158 gfx::Transform identity_matrix; |
174 gfx::Point3F transform_origin; | 159 gfx::Point3F transform_origin; |
175 gfx::PointF position; | 160 gfx::PointF position; |
176 gfx::Size bounds(100, 100); | 161 gfx::Size bounds(100, 100); |
177 SetLayerPropertiesForTesting(root.get(), | 162 SetLayerPropertiesForTesting(root.get(), uninvertible_transform, |
178 uninvertible_transform, | 163 transform_origin, position, bounds, true, false, |
179 transform_origin, | 164 true); |
180 position, | |
181 bounds, | |
182 true, | |
183 false); | |
184 root->SetDrawsContent(true); | 165 root->SetDrawsContent(true); |
185 | 166 |
186 host_impl().SetViewportSize(root->bounds()); | 167 host_impl().SetViewportSize(root->bounds()); |
187 host_impl().active_tree()->SetRootLayer(root.Pass()); | 168 host_impl().active_tree()->SetRootLayer(root.Pass()); |
188 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 169 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
189 // Sanity check the scenario we just created. | 170 // Sanity check the scenario we just created. |
190 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 171 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); |
191 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); | 172 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); |
192 ASSERT_FALSE(root_layer()->screen_space_transform().IsInvertible()); | 173 ASSERT_FALSE(root_layer()->screen_space_transform().IsInvertible()); |
193 | 174 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 TEST_F(LayerTreeImplTest, HitTestingForSinglePositionedLayer) { | 214 TEST_F(LayerTreeImplTest, HitTestingForSinglePositionedLayer) { |
234 scoped_ptr<LayerImpl> root = | 215 scoped_ptr<LayerImpl> root = |
235 LayerImpl::Create(host_impl().active_tree(), 12345); | 216 LayerImpl::Create(host_impl().active_tree(), 12345); |
236 | 217 |
237 gfx::Transform identity_matrix; | 218 gfx::Transform identity_matrix; |
238 gfx::Point3F transform_origin; | 219 gfx::Point3F transform_origin; |
239 // this layer is positioned, and hit testing should correctly know where the | 220 // this layer is positioned, and hit testing should correctly know where the |
240 // layer is located. | 221 // layer is located. |
241 gfx::PointF position(50.f, 50.f); | 222 gfx::PointF position(50.f, 50.f); |
242 gfx::Size bounds(100, 100); | 223 gfx::Size bounds(100, 100); |
243 SetLayerPropertiesForTesting(root.get(), | 224 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, |
244 identity_matrix, | 225 position, bounds, true, false, true); |
245 transform_origin, | |
246 position, | |
247 bounds, | |
248 true, | |
249 false); | |
250 root->SetDrawsContent(true); | 226 root->SetDrawsContent(true); |
251 | 227 |
252 host_impl().SetViewportSize(root->bounds()); | 228 host_impl().SetViewportSize(root->bounds()); |
253 host_impl().active_tree()->SetRootLayer(root.Pass()); | 229 host_impl().active_tree()->SetRootLayer(root.Pass()); |
254 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 230 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
255 | 231 |
256 // Sanity check the scenario we just created. | 232 // Sanity check the scenario we just created. |
257 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 233 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); |
258 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); | 234 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); |
259 | 235 |
(...skipping 29 matching lines...) Expand all Loading... |
289 LayerImpl::Create(host_impl().active_tree(), 12345); | 265 LayerImpl::Create(host_impl().active_tree(), 12345); |
290 | 266 |
291 gfx::Transform identity_matrix; | 267 gfx::Transform identity_matrix; |
292 gfx::Transform rotation45_degrees_about_center; | 268 gfx::Transform rotation45_degrees_about_center; |
293 rotation45_degrees_about_center.Translate(50.0, 50.0); | 269 rotation45_degrees_about_center.Translate(50.0, 50.0); |
294 rotation45_degrees_about_center.RotateAboutZAxis(45.0); | 270 rotation45_degrees_about_center.RotateAboutZAxis(45.0); |
295 rotation45_degrees_about_center.Translate(-50.0, -50.0); | 271 rotation45_degrees_about_center.Translate(-50.0, -50.0); |
296 gfx::Point3F transform_origin; | 272 gfx::Point3F transform_origin; |
297 gfx::PointF position; | 273 gfx::PointF position; |
298 gfx::Size bounds(100, 100); | 274 gfx::Size bounds(100, 100); |
299 SetLayerPropertiesForTesting(root.get(), | 275 SetLayerPropertiesForTesting(root.get(), rotation45_degrees_about_center, |
300 rotation45_degrees_about_center, | 276 transform_origin, position, bounds, true, false, |
301 transform_origin, | 277 true); |
302 position, | |
303 bounds, | |
304 true, | |
305 false); | |
306 root->SetDrawsContent(true); | 278 root->SetDrawsContent(true); |
307 | 279 |
308 host_impl().SetViewportSize(root->bounds()); | 280 host_impl().SetViewportSize(root->bounds()); |
309 host_impl().active_tree()->SetRootLayer(root.Pass()); | 281 host_impl().active_tree()->SetRootLayer(root.Pass()); |
310 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 282 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
311 | 283 |
312 // Sanity check the scenario we just created. | 284 // Sanity check the scenario we just created. |
313 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 285 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); |
314 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); | 286 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); |
315 | 287 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 perspective_projection_about_center.Translate(50.0, 50.0); | 330 perspective_projection_about_center.Translate(50.0, 50.0); |
359 perspective_projection_about_center.ApplyPerspectiveDepth(1.0); | 331 perspective_projection_about_center.ApplyPerspectiveDepth(1.0); |
360 perspective_projection_about_center.Translate(-50.0, -50.0); | 332 perspective_projection_about_center.Translate(-50.0, -50.0); |
361 gfx::Transform translation_by_z; | 333 gfx::Transform translation_by_z; |
362 translation_by_z.Translate3d(0.0, 0.0, -1.0); | 334 translation_by_z.Translate3d(0.0, 0.0, -1.0); |
363 | 335 |
364 gfx::Point3F transform_origin; | 336 gfx::Point3F transform_origin; |
365 gfx::PointF position; | 337 gfx::PointF position; |
366 gfx::Size bounds(100, 100); | 338 gfx::Size bounds(100, 100); |
367 SetLayerPropertiesForTesting( | 339 SetLayerPropertiesForTesting( |
368 root.get(), | 340 root.get(), perspective_projection_about_center * translation_by_z, |
369 perspective_projection_about_center * translation_by_z, | 341 transform_origin, position, bounds, true, false, true); |
370 transform_origin, | |
371 position, | |
372 bounds, | |
373 true, | |
374 false); | |
375 root->SetDrawsContent(true); | 342 root->SetDrawsContent(true); |
376 | 343 |
377 host_impl().SetViewportSize(root->bounds()); | 344 host_impl().SetViewportSize(root->bounds()); |
378 host_impl().active_tree()->SetRootLayer(root.Pass()); | 345 host_impl().active_tree()->SetRootLayer(root.Pass()); |
379 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 346 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
380 | 347 |
381 // Sanity check the scenario we just created. | 348 // Sanity check the scenario we just created. |
382 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 349 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); |
383 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); | 350 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); |
384 | 351 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 // | 386 // |
420 // To test this, the layer is positioned at (25, 25), and is size (50, 50). If | 387 // To test this, the layer is positioned at (25, 25), and is size (50, 50). If |
421 // contents scale is ignored, then hit testing will mis-interpret the visible | 388 // contents scale is ignored, then hit testing will mis-interpret the visible |
422 // content rect as being larger than the actual bounds of the layer. | 389 // content rect as being larger than the actual bounds of the layer. |
423 // | 390 // |
424 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); | 391 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); |
425 | 392 |
426 gfx::Transform identity_matrix; | 393 gfx::Transform identity_matrix; |
427 gfx::Point3F transform_origin; | 394 gfx::Point3F transform_origin; |
428 | 395 |
429 SetLayerPropertiesForTesting(root.get(), | 396 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, |
430 identity_matrix, | 397 gfx::PointF(), gfx::Size(100, 100), true, false, |
431 transform_origin, | 398 true); |
432 gfx::PointF(), | |
433 gfx::Size(100, 100), | |
434 true, | |
435 false); | |
436 { | 399 { |
437 gfx::PointF position(25.f, 25.f); | 400 gfx::PointF position(25.f, 25.f); |
438 gfx::Size bounds(50, 50); | 401 gfx::Size bounds(50, 50); |
439 scoped_ptr<LayerImpl> test_layer = | 402 scoped_ptr<LayerImpl> test_layer = |
440 LayerImpl::Create(host_impl().active_tree(), 12345); | 403 LayerImpl::Create(host_impl().active_tree(), 12345); |
441 SetLayerPropertiesForTesting(test_layer.get(), | 404 SetLayerPropertiesForTesting(test_layer.get(), identity_matrix, |
442 identity_matrix, | 405 transform_origin, position, bounds, true, |
443 transform_origin, | 406 false, false); |
444 position, | |
445 bounds, | |
446 true, | |
447 false); | |
448 | 407 |
449 // override content bounds and contents scale | 408 // override content bounds and contents scale |
450 test_layer->SetContentBounds(gfx::Size(100, 100)); | 409 test_layer->SetContentBounds(gfx::Size(100, 100)); |
451 test_layer->SetContentsScale(2, 2); | 410 test_layer->SetContentsScale(2, 2); |
452 | 411 |
453 test_layer->SetDrawsContent(true); | 412 test_layer->SetDrawsContent(true); |
454 root->AddChild(test_layer.Pass()); | 413 root->AddChild(test_layer.Pass()); |
455 } | 414 } |
456 | 415 |
457 host_impl().SetViewportSize(root->bounds()); | 416 host_impl().SetViewportSize(root->bounds()); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
499 } | 458 } |
500 | 459 |
501 TEST_F(LayerTreeImplTest, HitTestingForSimpleClippedLayer) { | 460 TEST_F(LayerTreeImplTest, HitTestingForSimpleClippedLayer) { |
502 // Test that hit-testing will only work for the visible portion of a layer, | 461 // Test that hit-testing will only work for the visible portion of a layer, |
503 // and not the entire layer bounds. Here we just test the simple axis-aligned | 462 // and not the entire layer bounds. Here we just test the simple axis-aligned |
504 // case. | 463 // case. |
505 gfx::Transform identity_matrix; | 464 gfx::Transform identity_matrix; |
506 gfx::Point3F transform_origin; | 465 gfx::Point3F transform_origin; |
507 | 466 |
508 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); | 467 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); |
509 SetLayerPropertiesForTesting(root.get(), | 468 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, |
510 identity_matrix, | 469 gfx::PointF(), gfx::Size(100, 100), true, false, |
511 transform_origin, | 470 true); |
512 gfx::PointF(), | |
513 gfx::Size(100, 100), | |
514 true, | |
515 false); | |
516 { | 471 { |
517 scoped_ptr<LayerImpl> clipping_layer = | 472 scoped_ptr<LayerImpl> clipping_layer = |
518 LayerImpl::Create(host_impl().active_tree(), 123); | 473 LayerImpl::Create(host_impl().active_tree(), 123); |
519 // this layer is positioned, and hit testing should correctly know where the | 474 // this layer is positioned, and hit testing should correctly know where the |
520 // layer is located. | 475 // layer is located. |
521 gfx::PointF position(25.f, 25.f); | 476 gfx::PointF position(25.f, 25.f); |
522 gfx::Size bounds(50, 50); | 477 gfx::Size bounds(50, 50); |
523 SetLayerPropertiesForTesting(clipping_layer.get(), | 478 SetLayerPropertiesForTesting(clipping_layer.get(), identity_matrix, |
524 identity_matrix, | 479 transform_origin, position, bounds, true, |
525 transform_origin, | 480 false, false); |
526 position, | |
527 bounds, | |
528 true, | |
529 false); | |
530 clipping_layer->SetMasksToBounds(true); | 481 clipping_layer->SetMasksToBounds(true); |
531 | 482 |
532 scoped_ptr<LayerImpl> child = | 483 scoped_ptr<LayerImpl> child = |
533 LayerImpl::Create(host_impl().active_tree(), 456); | 484 LayerImpl::Create(host_impl().active_tree(), 456); |
534 position = gfx::PointF(-50.f, -50.f); | 485 position = gfx::PointF(-50.f, -50.f); |
535 bounds = gfx::Size(300, 300); | 486 bounds = gfx::Size(300, 300); |
536 SetLayerPropertiesForTesting(child.get(), | 487 SetLayerPropertiesForTesting(child.get(), identity_matrix, transform_origin, |
537 identity_matrix, | 488 position, bounds, true, false, false); |
538 transform_origin, | |
539 position, | |
540 bounds, | |
541 true, | |
542 false); | |
543 child->SetDrawsContent(true); | 489 child->SetDrawsContent(true); |
544 clipping_layer->AddChild(child.Pass()); | 490 clipping_layer->AddChild(child.Pass()); |
545 root->AddChild(clipping_layer.Pass()); | 491 root->AddChild(clipping_layer.Pass()); |
546 } | 492 } |
547 | 493 |
548 host_impl().SetViewportSize(root->bounds()); | 494 host_impl().SetViewportSize(root->bounds()); |
549 host_impl().active_tree()->SetRootLayer(root.Pass()); | 495 host_impl().active_tree()->SetRootLayer(root.Pass()); |
550 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 496 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
551 | 497 |
552 // Sanity check the scenario we just created. | 498 // Sanity check the scenario we just created. |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
594 // the root + child clips combined create a triangle. The rotated_leaf will | 540 // the root + child clips combined create a triangle. The rotated_leaf will |
595 // only be visible where it overlaps this triangle. | 541 // only be visible where it overlaps this triangle. |
596 // | 542 // |
597 scoped_ptr<LayerImpl> root = | 543 scoped_ptr<LayerImpl> root = |
598 LayerImpl::Create(host_impl().active_tree(), 123); | 544 LayerImpl::Create(host_impl().active_tree(), 123); |
599 | 545 |
600 gfx::Transform identity_matrix; | 546 gfx::Transform identity_matrix; |
601 gfx::Point3F transform_origin; | 547 gfx::Point3F transform_origin; |
602 gfx::PointF position; | 548 gfx::PointF position; |
603 gfx::Size bounds(100, 100); | 549 gfx::Size bounds(100, 100); |
604 SetLayerPropertiesForTesting(root.get(), | 550 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, |
605 identity_matrix, | 551 position, bounds, true, false, true); |
606 transform_origin, | |
607 position, | |
608 bounds, | |
609 true, | |
610 false); | |
611 root->SetMasksToBounds(true); | 552 root->SetMasksToBounds(true); |
612 { | 553 { |
613 scoped_ptr<LayerImpl> child = | 554 scoped_ptr<LayerImpl> child = |
614 LayerImpl::Create(host_impl().active_tree(), 456); | 555 LayerImpl::Create(host_impl().active_tree(), 456); |
615 scoped_ptr<LayerImpl> grand_child = | 556 scoped_ptr<LayerImpl> grand_child = |
616 LayerImpl::Create(host_impl().active_tree(), 789); | 557 LayerImpl::Create(host_impl().active_tree(), 789); |
617 scoped_ptr<LayerImpl> rotated_leaf = | 558 scoped_ptr<LayerImpl> rotated_leaf = |
618 LayerImpl::Create(host_impl().active_tree(), 2468); | 559 LayerImpl::Create(host_impl().active_tree(), 2468); |
619 | 560 |
620 position = gfx::PointF(10.f, 10.f); | 561 position = gfx::PointF(10.f, 10.f); |
621 bounds = gfx::Size(80, 80); | 562 bounds = gfx::Size(80, 80); |
622 SetLayerPropertiesForTesting(child.get(), | 563 SetLayerPropertiesForTesting(child.get(), identity_matrix, transform_origin, |
623 identity_matrix, | 564 position, bounds, true, false, false); |
624 transform_origin, | |
625 position, | |
626 bounds, | |
627 true, | |
628 false); | |
629 child->SetMasksToBounds(true); | 565 child->SetMasksToBounds(true); |
630 | 566 |
631 gfx::Transform rotation45_degrees_about_corner; | 567 gfx::Transform rotation45_degrees_about_corner; |
632 rotation45_degrees_about_corner.RotateAboutZAxis(45.0); | 568 rotation45_degrees_about_corner.RotateAboutZAxis(45.0); |
633 | 569 |
634 // remember, positioned with respect to its parent which is already at 10, | 570 // remember, positioned with respect to its parent which is already at 10, |
635 // 10 | 571 // 10 |
636 position = gfx::PointF(); | 572 position = gfx::PointF(); |
637 bounds = | 573 bounds = |
638 gfx::Size(200, 200); // to ensure it covers at least sqrt(2) * 100. | 574 gfx::Size(200, 200); // to ensure it covers at least sqrt(2) * 100. |
639 SetLayerPropertiesForTesting(grand_child.get(), | 575 SetLayerPropertiesForTesting( |
640 rotation45_degrees_about_corner, | 576 grand_child.get(), rotation45_degrees_about_corner, transform_origin, |
641 transform_origin, | 577 position, bounds, true, false, false); |
642 position, | |
643 bounds, | |
644 true, | |
645 false); | |
646 grand_child->SetMasksToBounds(true); | 578 grand_child->SetMasksToBounds(true); |
647 | 579 |
648 // Rotates about the center of the layer | 580 // Rotates about the center of the layer |
649 gfx::Transform rotated_leaf_transform; | 581 gfx::Transform rotated_leaf_transform; |
650 rotated_leaf_transform.Translate( | 582 rotated_leaf_transform.Translate( |
651 -10.0, -10.0); // cancel out the grand_parent's position | 583 -10.0, -10.0); // cancel out the grand_parent's position |
652 rotated_leaf_transform.RotateAboutZAxis( | 584 rotated_leaf_transform.RotateAboutZAxis( |
653 -45.0); // cancel out the corner 45-degree rotation of the parent. | 585 -45.0); // cancel out the corner 45-degree rotation of the parent. |
654 rotated_leaf_transform.Translate(50.0, 50.0); | 586 rotated_leaf_transform.Translate(50.0, 50.0); |
655 rotated_leaf_transform.RotateAboutZAxis(45.0); | 587 rotated_leaf_transform.RotateAboutZAxis(45.0); |
656 rotated_leaf_transform.Translate(-50.0, -50.0); | 588 rotated_leaf_transform.Translate(-50.0, -50.0); |
657 position = gfx::PointF(); | 589 position = gfx::PointF(); |
658 bounds = gfx::Size(100, 100); | 590 bounds = gfx::Size(100, 100); |
659 SetLayerPropertiesForTesting(rotated_leaf.get(), | 591 SetLayerPropertiesForTesting(rotated_leaf.get(), rotated_leaf_transform, |
660 rotated_leaf_transform, | 592 transform_origin, position, bounds, true, |
661 transform_origin, | 593 false, false); |
662 position, | |
663 bounds, | |
664 true, | |
665 false); | |
666 rotated_leaf->SetDrawsContent(true); | 594 rotated_leaf->SetDrawsContent(true); |
667 | 595 |
668 grand_child->AddChild(rotated_leaf.Pass()); | 596 grand_child->AddChild(rotated_leaf.Pass()); |
669 child->AddChild(grand_child.Pass()); | 597 child->AddChild(grand_child.Pass()); |
670 root->AddChild(child.Pass()); | 598 root->AddChild(child.Pass()); |
671 } | 599 } |
672 | 600 |
673 host_impl().SetViewportSize(root->bounds()); | 601 host_impl().SetViewportSize(root->bounds()); |
674 host_impl().active_tree()->SetRootLayer(root.Pass()); | 602 host_impl().active_tree()->SetRootLayer(root.Pass()); |
675 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 603 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
676 | 604 |
677 // Sanity check the scenario we just created. | |
678 // The grand_child is expected to create a render surface because it | |
679 // MasksToBounds and is not axis aligned. | |
680 ASSERT_EQ(2u, RenderSurfaceLayerList().size()); | |
681 ASSERT_EQ( | |
682 1u, | |
683 RenderSurfaceLayerList().at(0)->render_surface()->layer_list().size()); | |
684 ASSERT_EQ(789, | |
685 RenderSurfaceLayerList() | |
686 .at(0) | |
687 ->render_surface() | |
688 ->layer_list() | |
689 .at(0) | |
690 ->id()); // grand_child's surface. | |
691 ASSERT_EQ( | |
692 1u, | |
693 RenderSurfaceLayerList().at(1)->render_surface()->layer_list().size()); | |
694 ASSERT_EQ( | |
695 2468, | |
696 RenderSurfaceLayerList()[1]->render_surface()->layer_list().at(0)->id()); | |
697 | |
698 // (11, 89) is close to the the bottom left corner within the clip, but it is | 605 // (11, 89) is close to the the bottom left corner within the clip, but it is |
699 // not inside the layer. | 606 // not inside the layer. |
700 gfx::Point test_point(11, 89); | 607 gfx::Point test_point(11, 89); |
701 LayerImpl* result_layer = | 608 LayerImpl* result_layer = |
702 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 609 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); |
703 EXPECT_FALSE(result_layer); | 610 EXPECT_FALSE(result_layer); |
704 | 611 |
705 // Closer inwards from the bottom left will overlap the layer. | 612 // Closer inwards from the bottom left will overlap the layer. |
706 test_point = gfx::Point(25, 75); | 613 test_point = gfx::Point(25, 75); |
707 result_layer = | 614 result_layer = |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
742 EXPECT_EQ(2468, result_layer->id()); | 649 EXPECT_EQ(2468, result_layer->id()); |
743 } | 650 } |
744 | 651 |
745 TEST_F(LayerTreeImplTest, HitTestingForNonClippingIntermediateLayer) { | 652 TEST_F(LayerTreeImplTest, HitTestingForNonClippingIntermediateLayer) { |
746 // This test checks that hit testing code does not accidentally clip to layer | 653 // This test checks that hit testing code does not accidentally clip to layer |
747 // bounds for a layer that actually does not clip. | 654 // bounds for a layer that actually does not clip. |
748 gfx::Transform identity_matrix; | 655 gfx::Transform identity_matrix; |
749 gfx::Point3F transform_origin; | 656 gfx::Point3F transform_origin; |
750 | 657 |
751 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); | 658 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); |
752 SetLayerPropertiesForTesting(root.get(), | 659 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, |
753 identity_matrix, | 660 gfx::PointF(), gfx::Size(100, 100), true, false, |
754 transform_origin, | 661 true); |
755 gfx::PointF(), | |
756 gfx::Size(100, 100), | |
757 true, | |
758 false); | |
759 { | 662 { |
760 scoped_ptr<LayerImpl> intermediate_layer = | 663 scoped_ptr<LayerImpl> intermediate_layer = |
761 LayerImpl::Create(host_impl().active_tree(), 123); | 664 LayerImpl::Create(host_impl().active_tree(), 123); |
762 // this layer is positioned, and hit testing should correctly know where the | 665 // this layer is positioned, and hit testing should correctly know where the |
763 // layer is located. | 666 // layer is located. |
764 gfx::PointF position(10.f, 10.f); | 667 gfx::PointF position(10.f, 10.f); |
765 gfx::Size bounds(50, 50); | 668 gfx::Size bounds(50, 50); |
766 SetLayerPropertiesForTesting(intermediate_layer.get(), | 669 SetLayerPropertiesForTesting(intermediate_layer.get(), identity_matrix, |
767 identity_matrix, | 670 transform_origin, position, bounds, true, |
768 transform_origin, | 671 false, false); |
769 position, | |
770 bounds, | |
771 true, | |
772 false); | |
773 // Sanity check the intermediate layer should not clip. | 672 // Sanity check the intermediate layer should not clip. |
774 ASSERT_FALSE(intermediate_layer->masks_to_bounds()); | 673 ASSERT_FALSE(intermediate_layer->masks_to_bounds()); |
775 ASSERT_FALSE(intermediate_layer->mask_layer()); | 674 ASSERT_FALSE(intermediate_layer->mask_layer()); |
776 | 675 |
777 // The child of the intermediate_layer is translated so that it does not | 676 // The child of the intermediate_layer is translated so that it does not |
778 // overlap intermediate_layer at all. If child is incorrectly clipped, we | 677 // overlap intermediate_layer at all. If child is incorrectly clipped, we |
779 // would not be able to hit it successfully. | 678 // would not be able to hit it successfully. |
780 scoped_ptr<LayerImpl> child = | 679 scoped_ptr<LayerImpl> child = |
781 LayerImpl::Create(host_impl().active_tree(), 456); | 680 LayerImpl::Create(host_impl().active_tree(), 456); |
782 position = gfx::PointF(60.f, 60.f); // 70, 70 in screen space | 681 position = gfx::PointF(60.f, 60.f); // 70, 70 in screen space |
783 bounds = gfx::Size(20, 20); | 682 bounds = gfx::Size(20, 20); |
784 SetLayerPropertiesForTesting(child.get(), | 683 SetLayerPropertiesForTesting(child.get(), identity_matrix, transform_origin, |
785 identity_matrix, | 684 position, bounds, true, false, false); |
786 transform_origin, | |
787 position, | |
788 bounds, | |
789 true, | |
790 false); | |
791 child->SetDrawsContent(true); | 685 child->SetDrawsContent(true); |
792 intermediate_layer->AddChild(child.Pass()); | 686 intermediate_layer->AddChild(child.Pass()); |
793 root->AddChild(intermediate_layer.Pass()); | 687 root->AddChild(intermediate_layer.Pass()); |
794 } | 688 } |
795 | 689 |
796 host_impl().SetViewportSize(root->bounds()); | 690 host_impl().SetViewportSize(root->bounds()); |
797 host_impl().active_tree()->SetRootLayer(root.Pass()); | 691 host_impl().active_tree()->SetRootLayer(root.Pass()); |
798 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 692 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
799 | 693 |
800 // Sanity check the scenario we just created. | 694 // Sanity check the scenario we just created. |
(...skipping 26 matching lines...) Expand all Loading... |
827 EXPECT_EQ(456, result_layer->id()); | 721 EXPECT_EQ(456, result_layer->id()); |
828 } | 722 } |
829 | 723 |
830 TEST_F(LayerTreeImplTest, HitTestingForMultipleLayers) { | 724 TEST_F(LayerTreeImplTest, HitTestingForMultipleLayers) { |
831 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); | 725 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); |
832 | 726 |
833 gfx::Transform identity_matrix; | 727 gfx::Transform identity_matrix; |
834 gfx::Point3F transform_origin; | 728 gfx::Point3F transform_origin; |
835 gfx::PointF position; | 729 gfx::PointF position; |
836 gfx::Size bounds(100, 100); | 730 gfx::Size bounds(100, 100); |
837 SetLayerPropertiesForTesting(root.get(), | 731 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, |
838 identity_matrix, | 732 position, bounds, true, false, true); |
839 transform_origin, | |
840 position, | |
841 bounds, | |
842 true, | |
843 false); | |
844 root->SetDrawsContent(true); | 733 root->SetDrawsContent(true); |
845 { | 734 { |
846 // child 1 and child2 are initialized to overlap between x=50 and x=60. | 735 // child 1 and child2 are initialized to overlap between x=50 and x=60. |
847 // grand_child is set to overlap both child1 and child2 between y=50 and | 736 // grand_child is set to overlap both child1 and child2 between y=50 and |
848 // y=60. The expected stacking order is: (front) child2, (second) | 737 // y=60. The expected stacking order is: (front) child2, (second) |
849 // grand_child, (third) child1, and (back) the root layer behind all other | 738 // grand_child, (third) child1, and (back) the root layer behind all other |
850 // layers. | 739 // layers. |
851 | 740 |
852 scoped_ptr<LayerImpl> child1 = | 741 scoped_ptr<LayerImpl> child1 = |
853 LayerImpl::Create(host_impl().active_tree(), 2); | 742 LayerImpl::Create(host_impl().active_tree(), 2); |
854 scoped_ptr<LayerImpl> child2 = | 743 scoped_ptr<LayerImpl> child2 = |
855 LayerImpl::Create(host_impl().active_tree(), 3); | 744 LayerImpl::Create(host_impl().active_tree(), 3); |
856 scoped_ptr<LayerImpl> grand_child1 = | 745 scoped_ptr<LayerImpl> grand_child1 = |
857 LayerImpl::Create(host_impl().active_tree(), 4); | 746 LayerImpl::Create(host_impl().active_tree(), 4); |
858 | 747 |
859 position = gfx::PointF(10.f, 10.f); | 748 position = gfx::PointF(10.f, 10.f); |
860 bounds = gfx::Size(50, 50); | 749 bounds = gfx::Size(50, 50); |
861 SetLayerPropertiesForTesting(child1.get(), | 750 SetLayerPropertiesForTesting(child1.get(), identity_matrix, |
862 identity_matrix, | 751 transform_origin, position, bounds, true, |
863 transform_origin, | 752 false, false); |
864 position, | |
865 bounds, | |
866 true, | |
867 false); | |
868 child1->SetDrawsContent(true); | 753 child1->SetDrawsContent(true); |
869 | 754 |
870 position = gfx::PointF(50.f, 10.f); | 755 position = gfx::PointF(50.f, 10.f); |
871 bounds = gfx::Size(50, 50); | 756 bounds = gfx::Size(50, 50); |
872 SetLayerPropertiesForTesting(child2.get(), | 757 SetLayerPropertiesForTesting(child2.get(), identity_matrix, |
873 identity_matrix, | 758 transform_origin, position, bounds, true, |
874 transform_origin, | 759 false, false); |
875 position, | |
876 bounds, | |
877 true, | |
878 false); | |
879 child2->SetDrawsContent(true); | 760 child2->SetDrawsContent(true); |
880 | 761 |
881 // Remember that grand_child is positioned with respect to its parent (i.e. | 762 // Remember that grand_child is positioned with respect to its parent (i.e. |
882 // child1). In screen space, the intended position is (10, 50), with size | 763 // child1). In screen space, the intended position is (10, 50), with size |
883 // 100 x 50. | 764 // 100 x 50. |
884 position = gfx::PointF(0.f, 40.f); | 765 position = gfx::PointF(0.f, 40.f); |
885 bounds = gfx::Size(100, 50); | 766 bounds = gfx::Size(100, 50); |
886 SetLayerPropertiesForTesting(grand_child1.get(), | 767 SetLayerPropertiesForTesting(grand_child1.get(), identity_matrix, |
887 identity_matrix, | 768 transform_origin, position, bounds, true, |
888 transform_origin, | 769 false, false); |
889 position, | |
890 bounds, | |
891 true, | |
892 false); | |
893 grand_child1->SetDrawsContent(true); | 770 grand_child1->SetDrawsContent(true); |
894 | 771 |
895 child1->AddChild(grand_child1.Pass()); | 772 child1->AddChild(grand_child1.Pass()); |
896 root->AddChild(child1.Pass()); | 773 root->AddChild(child1.Pass()); |
897 root->AddChild(child2.Pass()); | 774 root->AddChild(child2.Pass()); |
898 } | 775 } |
899 | 776 |
900 LayerImpl* child1 = root->children()[0]; | 777 LayerImpl* child1 = root->children()[0]; |
901 LayerImpl* child2 = root->children()[1]; | 778 LayerImpl* child2 = root->children()[1]; |
902 LayerImpl* grand_child1 = child1->children()[0]; | 779 LayerImpl* grand_child1 = child1->children()[0]; |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
966 EXPECT_EQ(4, result_layer->id()); | 843 EXPECT_EQ(4, result_layer->id()); |
967 } | 844 } |
968 | 845 |
969 TEST_F(LayerTreeImplTest, HitTestingForMultipleLayersAtVaryingDepths) { | 846 TEST_F(LayerTreeImplTest, HitTestingForMultipleLayersAtVaryingDepths) { |
970 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); | 847 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); |
971 | 848 |
972 gfx::Transform identity_matrix; | 849 gfx::Transform identity_matrix; |
973 gfx::Point3F transform_origin; | 850 gfx::Point3F transform_origin; |
974 gfx::PointF position; | 851 gfx::PointF position; |
975 gfx::Size bounds(100, 100); | 852 gfx::Size bounds(100, 100); |
976 SetLayerPropertiesForTesting(root.get(), | 853 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, |
977 identity_matrix, | 854 position, bounds, true, false, true); |
978 transform_origin, | |
979 position, | |
980 bounds, | |
981 true, | |
982 false); | |
983 root->SetDrawsContent(true); | 855 root->SetDrawsContent(true); |
984 root->SetShouldFlattenTransform(false); | 856 root->SetShouldFlattenTransform(false); |
985 root->Set3dSortingContextId(1); | 857 root->Set3dSortingContextId(1); |
986 { | 858 { |
987 // child 1 and child2 are initialized to overlap between x=50 and x=60. | 859 // child 1 and child2 are initialized to overlap between x=50 and x=60. |
988 // grand_child is set to overlap both child1 and child2 between y=50 and | 860 // grand_child is set to overlap both child1 and child2 between y=50 and |
989 // y=60. The expected stacking order is: (front) child2, (second) | 861 // y=60. The expected stacking order is: (front) child2, (second) |
990 // grand_child, (third) child1, and (back) the root layer behind all other | 862 // grand_child, (third) child1, and (back) the root layer behind all other |
991 // layers. | 863 // layers. |
992 | 864 |
993 scoped_ptr<LayerImpl> child1 = | 865 scoped_ptr<LayerImpl> child1 = |
994 LayerImpl::Create(host_impl().active_tree(), 2); | 866 LayerImpl::Create(host_impl().active_tree(), 2); |
995 scoped_ptr<LayerImpl> child2 = | 867 scoped_ptr<LayerImpl> child2 = |
996 LayerImpl::Create(host_impl().active_tree(), 3); | 868 LayerImpl::Create(host_impl().active_tree(), 3); |
997 scoped_ptr<LayerImpl> grand_child1 = | 869 scoped_ptr<LayerImpl> grand_child1 = |
998 LayerImpl::Create(host_impl().active_tree(), 4); | 870 LayerImpl::Create(host_impl().active_tree(), 4); |
999 | 871 |
1000 position = gfx::PointF(10.f, 10.f); | 872 position = gfx::PointF(10.f, 10.f); |
1001 bounds = gfx::Size(50, 50); | 873 bounds = gfx::Size(50, 50); |
1002 SetLayerPropertiesForTesting(child1.get(), | 874 SetLayerPropertiesForTesting(child1.get(), identity_matrix, |
1003 identity_matrix, | 875 transform_origin, position, bounds, true, |
1004 transform_origin, | 876 false, false); |
1005 position, | |
1006 bounds, | |
1007 true, | |
1008 false); | |
1009 child1->SetDrawsContent(true); | 877 child1->SetDrawsContent(true); |
1010 child1->SetShouldFlattenTransform(false); | 878 child1->SetShouldFlattenTransform(false); |
1011 child1->Set3dSortingContextId(1); | 879 child1->Set3dSortingContextId(1); |
1012 | 880 |
1013 position = gfx::PointF(50.f, 10.f); | 881 position = gfx::PointF(50.f, 10.f); |
1014 bounds = gfx::Size(50, 50); | 882 bounds = gfx::Size(50, 50); |
1015 gfx::Transform translate_z; | 883 gfx::Transform translate_z; |
1016 translate_z.Translate3d(0, 0, -10.f); | 884 translate_z.Translate3d(0, 0, -10.f); |
1017 SetLayerPropertiesForTesting(child2.get(), | 885 SetLayerPropertiesForTesting(child2.get(), translate_z, transform_origin, |
1018 translate_z, | 886 position, bounds, true, false, false); |
1019 transform_origin, | |
1020 position, | |
1021 bounds, | |
1022 true, | |
1023 false); | |
1024 child2->SetDrawsContent(true); | 887 child2->SetDrawsContent(true); |
1025 child2->SetShouldFlattenTransform(false); | 888 child2->SetShouldFlattenTransform(false); |
1026 child2->Set3dSortingContextId(1); | 889 child2->Set3dSortingContextId(1); |
1027 | 890 |
1028 // Remember that grand_child is positioned with respect to its parent (i.e. | 891 // Remember that grand_child is positioned with respect to its parent (i.e. |
1029 // child1). In screen space, the intended position is (10, 50), with size | 892 // child1). In screen space, the intended position is (10, 50), with size |
1030 // 100 x 50. | 893 // 100 x 50. |
1031 position = gfx::PointF(0.f, 40.f); | 894 position = gfx::PointF(0.f, 40.f); |
1032 bounds = gfx::Size(100, 50); | 895 bounds = gfx::Size(100, 50); |
1033 SetLayerPropertiesForTesting(grand_child1.get(), | 896 SetLayerPropertiesForTesting(grand_child1.get(), identity_matrix, |
1034 identity_matrix, | 897 transform_origin, position, bounds, true, |
1035 transform_origin, | 898 false, false); |
1036 position, | |
1037 bounds, | |
1038 true, | |
1039 false); | |
1040 grand_child1->SetDrawsContent(true); | 899 grand_child1->SetDrawsContent(true); |
1041 grand_child1->SetShouldFlattenTransform(false); | 900 grand_child1->SetShouldFlattenTransform(false); |
1042 | 901 |
1043 child1->AddChild(grand_child1.Pass()); | 902 child1->AddChild(grand_child1.Pass()); |
1044 root->AddChild(child1.Pass()); | 903 root->AddChild(child1.Pass()); |
1045 root->AddChild(child2.Pass()); | 904 root->AddChild(child2.Pass()); |
1046 } | 905 } |
1047 | 906 |
1048 LayerImpl* child1 = root->children()[0]; | 907 LayerImpl* child1 = root->children()[0]; |
1049 LayerImpl* child2 = root->children()[1]; | 908 LayerImpl* child2 = root->children()[1]; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1115 ASSERT_TRUE(result_layer); | 974 ASSERT_TRUE(result_layer); |
1116 EXPECT_EQ(4, result_layer->id()); | 975 EXPECT_EQ(4, result_layer->id()); |
1117 } | 976 } |
1118 | 977 |
1119 TEST_F(LayerTreeImplTest, HitTestingRespectsClipParents) { | 978 TEST_F(LayerTreeImplTest, HitTestingRespectsClipParents) { |
1120 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); | 979 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); |
1121 gfx::Transform identity_matrix; | 980 gfx::Transform identity_matrix; |
1122 gfx::Point3F transform_origin; | 981 gfx::Point3F transform_origin; |
1123 gfx::PointF position; | 982 gfx::PointF position; |
1124 gfx::Size bounds(100, 100); | 983 gfx::Size bounds(100, 100); |
1125 SetLayerPropertiesForTesting(root.get(), | 984 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, |
1126 identity_matrix, | 985 position, bounds, true, false, true); |
1127 transform_origin, | |
1128 position, | |
1129 bounds, | |
1130 true, | |
1131 false); | |
1132 root->SetDrawsContent(true); | 986 root->SetDrawsContent(true); |
1133 { | 987 { |
1134 scoped_ptr<LayerImpl> child = | 988 scoped_ptr<LayerImpl> child = |
1135 LayerImpl::Create(host_impl().active_tree(), 2); | 989 LayerImpl::Create(host_impl().active_tree(), 2); |
1136 scoped_ptr<LayerImpl> grand_child = | 990 scoped_ptr<LayerImpl> grand_child = |
1137 LayerImpl::Create(host_impl().active_tree(), 4); | 991 LayerImpl::Create(host_impl().active_tree(), 4); |
1138 | 992 |
1139 position = gfx::PointF(10.f, 10.f); | 993 position = gfx::PointF(10.f, 10.f); |
1140 bounds = gfx::Size(1, 1); | 994 bounds = gfx::Size(1, 1); |
1141 SetLayerPropertiesForTesting(child.get(), | 995 SetLayerPropertiesForTesting(child.get(), identity_matrix, transform_origin, |
1142 identity_matrix, | 996 position, bounds, true, false, false); |
1143 transform_origin, | |
1144 position, | |
1145 bounds, | |
1146 true, | |
1147 false); | |
1148 child->SetDrawsContent(true); | 997 child->SetDrawsContent(true); |
1149 child->SetMasksToBounds(true); | 998 child->SetMasksToBounds(true); |
1150 | 999 |
1151 position = gfx::PointF(0.f, 40.f); | 1000 position = gfx::PointF(0.f, 40.f); |
1152 bounds = gfx::Size(100, 50); | 1001 bounds = gfx::Size(100, 50); |
1153 SetLayerPropertiesForTesting(grand_child.get(), | 1002 SetLayerPropertiesForTesting(grand_child.get(), identity_matrix, |
1154 identity_matrix, | 1003 transform_origin, position, bounds, true, |
1155 transform_origin, | 1004 false, false); |
1156 position, | |
1157 bounds, | |
1158 true, | |
1159 false); | |
1160 grand_child->SetDrawsContent(true); | 1005 grand_child->SetDrawsContent(true); |
1161 grand_child->SetForceRenderSurface(true); | 1006 grand_child->SetHasRenderSurface(true); |
1162 | 1007 |
1163 // This should let |grand_child| "escape" |child|'s clip. | 1008 // This should let |grand_child| "escape" |child|'s clip. |
1164 grand_child->SetClipParent(root.get()); | 1009 grand_child->SetClipParent(root.get()); |
1165 | 1010 |
1166 child->AddChild(grand_child.Pass()); | 1011 child->AddChild(grand_child.Pass()); |
1167 root->AddChild(child.Pass()); | 1012 root->AddChild(child.Pass()); |
1168 } | 1013 } |
1169 | 1014 |
1170 host_impl().SetViewportSize(root->bounds()); | 1015 host_impl().SetViewportSize(root->bounds()); |
1171 host_impl().active_tree()->SetRootLayer(root.Pass()); | 1016 host_impl().active_tree()->SetRootLayer(root.Pass()); |
1172 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 1017 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
1173 | 1018 |
1174 gfx::Point test_point = gfx::Point(12, 52); | 1019 gfx::Point test_point = gfx::Point(12, 52); |
1175 LayerImpl* result_layer = | 1020 LayerImpl* result_layer = |
1176 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 1021 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); |
1177 ASSERT_TRUE(result_layer); | 1022 ASSERT_TRUE(result_layer); |
1178 EXPECT_EQ(4, result_layer->id()); | 1023 EXPECT_EQ(4, result_layer->id()); |
1179 } | 1024 } |
1180 | 1025 |
1181 TEST_F(LayerTreeImplTest, HitTestingRespectsScrollParents) { | 1026 TEST_F(LayerTreeImplTest, HitTestingRespectsScrollParents) { |
1182 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); | 1027 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); |
1183 gfx::Transform identity_matrix; | 1028 gfx::Transform identity_matrix; |
1184 gfx::Point3F transform_origin; | 1029 gfx::Point3F transform_origin; |
1185 gfx::PointF position; | 1030 gfx::PointF position; |
1186 gfx::Size bounds(100, 100); | 1031 gfx::Size bounds(100, 100); |
1187 SetLayerPropertiesForTesting(root.get(), | 1032 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, |
1188 identity_matrix, | 1033 position, bounds, true, false, true); |
1189 transform_origin, | |
1190 position, | |
1191 bounds, | |
1192 true, | |
1193 false); | |
1194 root->SetDrawsContent(true); | 1034 root->SetDrawsContent(true); |
1195 { | 1035 { |
1196 scoped_ptr<LayerImpl> child = | 1036 scoped_ptr<LayerImpl> child = |
1197 LayerImpl::Create(host_impl().active_tree(), 2); | 1037 LayerImpl::Create(host_impl().active_tree(), 2); |
1198 scoped_ptr<LayerImpl> scroll_child = | 1038 scoped_ptr<LayerImpl> scroll_child = |
1199 LayerImpl::Create(host_impl().active_tree(), 3); | 1039 LayerImpl::Create(host_impl().active_tree(), 3); |
1200 scoped_ptr<LayerImpl> grand_child = | 1040 scoped_ptr<LayerImpl> grand_child = |
1201 LayerImpl::Create(host_impl().active_tree(), 4); | 1041 LayerImpl::Create(host_impl().active_tree(), 4); |
1202 | 1042 |
1203 position = gfx::PointF(10.f, 10.f); | 1043 position = gfx::PointF(10.f, 10.f); |
1204 bounds = gfx::Size(1, 1); | 1044 bounds = gfx::Size(1, 1); |
1205 SetLayerPropertiesForTesting(child.get(), | 1045 SetLayerPropertiesForTesting(child.get(), identity_matrix, transform_origin, |
1206 identity_matrix, | 1046 position, bounds, true, false, false); |
1207 transform_origin, | |
1208 position, | |
1209 bounds, | |
1210 true, | |
1211 false); | |
1212 child->SetDrawsContent(true); | 1047 child->SetDrawsContent(true); |
1213 child->SetMasksToBounds(true); | 1048 child->SetMasksToBounds(true); |
1214 | 1049 |
1215 position = gfx::PointF(); | 1050 position = gfx::PointF(); |
1216 bounds = gfx::Size(200, 200); | 1051 bounds = gfx::Size(200, 200); |
1217 SetLayerPropertiesForTesting(scroll_child.get(), | 1052 SetLayerPropertiesForTesting(scroll_child.get(), identity_matrix, |
1218 identity_matrix, | 1053 transform_origin, position, bounds, true, |
1219 transform_origin, | 1054 false, false); |
1220 position, | |
1221 bounds, | |
1222 true, | |
1223 false); | |
1224 scroll_child->SetDrawsContent(true); | 1055 scroll_child->SetDrawsContent(true); |
1225 | 1056 |
1226 // This should cause scroll child and its descendants to be affected by | 1057 // This should cause scroll child and its descendants to be affected by |
1227 // |child|'s clip. | 1058 // |child|'s clip. |
1228 scroll_child->SetScrollParent(child.get()); | 1059 scroll_child->SetScrollParent(child.get()); |
1229 | 1060 |
1230 SetLayerPropertiesForTesting(grand_child.get(), | 1061 SetLayerPropertiesForTesting(grand_child.get(), identity_matrix, |
1231 identity_matrix, | 1062 transform_origin, position, bounds, true, |
1232 transform_origin, | 1063 false, false); |
1233 position, | |
1234 bounds, | |
1235 true, | |
1236 false); | |
1237 grand_child->SetDrawsContent(true); | 1064 grand_child->SetDrawsContent(true); |
1238 grand_child->SetForceRenderSurface(true); | 1065 grand_child->SetHasRenderSurface(true); |
1239 | 1066 |
1240 scroll_child->AddChild(grand_child.Pass()); | 1067 scroll_child->AddChild(grand_child.Pass()); |
1241 root->AddChild(scroll_child.Pass()); | 1068 root->AddChild(scroll_child.Pass()); |
1242 root->AddChild(child.Pass()); | 1069 root->AddChild(child.Pass()); |
1243 } | 1070 } |
1244 | 1071 |
1245 host_impl().SetViewportSize(root->bounds()); | 1072 host_impl().SetViewportSize(root->bounds()); |
1246 host_impl().active_tree()->SetRootLayer(root.Pass()); | 1073 host_impl().active_tree()->SetRootLayer(root.Pass()); |
1247 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 1074 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
1248 | 1075 |
1249 gfx::Point test_point = gfx::Point(12, 52); | 1076 gfx::Point test_point = gfx::Point(12, 52); |
1250 LayerImpl* result_layer = | 1077 LayerImpl* result_layer = |
1251 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 1078 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); |
1252 // The |test_point| should have been clipped away by |child|, the scroll | 1079 // The |test_point| should have been clipped away by |child|, the scroll |
1253 // parent, so the only thing that should be hit is |root|. | 1080 // parent, so the only thing that should be hit is |root|. |
1254 ASSERT_TRUE(result_layer); | 1081 ASSERT_TRUE(result_layer); |
1255 ASSERT_EQ(1, result_layer->id()); | 1082 ASSERT_EQ(1, result_layer->id()); |
1256 } | 1083 } |
1257 TEST_F(LayerTreeImplTest, HitTestingForMultipleLayerLists) { | 1084 TEST_F(LayerTreeImplTest, HitTestingForMultipleLayerLists) { |
1258 // | 1085 // |
1259 // The geometry is set up similarly to the previous case, but | 1086 // The geometry is set up similarly to the previous case, but |
1260 // all layers are forced to be render surfaces now. | 1087 // all layers are forced to be render surfaces now. |
1261 // | 1088 // |
1262 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); | 1089 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); |
1263 | 1090 |
1264 gfx::Transform identity_matrix; | 1091 gfx::Transform identity_matrix; |
1265 gfx::Point3F transform_origin; | 1092 gfx::Point3F transform_origin; |
1266 gfx::PointF position; | 1093 gfx::PointF position; |
1267 gfx::Size bounds(100, 100); | 1094 gfx::Size bounds(100, 100); |
1268 SetLayerPropertiesForTesting(root.get(), | 1095 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, |
1269 identity_matrix, | 1096 position, bounds, true, false, true); |
1270 transform_origin, | |
1271 position, | |
1272 bounds, | |
1273 true, | |
1274 false); | |
1275 root->SetDrawsContent(true); | 1097 root->SetDrawsContent(true); |
1276 { | 1098 { |
1277 // child 1 and child2 are initialized to overlap between x=50 and x=60. | 1099 // child 1 and child2 are initialized to overlap between x=50 and x=60. |
1278 // grand_child is set to overlap both child1 and child2 between y=50 and | 1100 // grand_child is set to overlap both child1 and child2 between y=50 and |
1279 // y=60. The expected stacking order is: (front) child2, (second) | 1101 // y=60. The expected stacking order is: (front) child2, (second) |
1280 // grand_child, (third) child1, and (back) the root layer behind all other | 1102 // grand_child, (third) child1, and (back) the root layer behind all other |
1281 // layers. | 1103 // layers. |
1282 | 1104 |
1283 scoped_ptr<LayerImpl> child1 = | 1105 scoped_ptr<LayerImpl> child1 = |
1284 LayerImpl::Create(host_impl().active_tree(), 2); | 1106 LayerImpl::Create(host_impl().active_tree(), 2); |
1285 scoped_ptr<LayerImpl> child2 = | 1107 scoped_ptr<LayerImpl> child2 = |
1286 LayerImpl::Create(host_impl().active_tree(), 3); | 1108 LayerImpl::Create(host_impl().active_tree(), 3); |
1287 scoped_ptr<LayerImpl> grand_child1 = | 1109 scoped_ptr<LayerImpl> grand_child1 = |
1288 LayerImpl::Create(host_impl().active_tree(), 4); | 1110 LayerImpl::Create(host_impl().active_tree(), 4); |
1289 | 1111 |
1290 position = gfx::PointF(10.f, 10.f); | 1112 position = gfx::PointF(10.f, 10.f); |
1291 bounds = gfx::Size(50, 50); | 1113 bounds = gfx::Size(50, 50); |
1292 SetLayerPropertiesForTesting(child1.get(), | 1114 SetLayerPropertiesForTesting(child1.get(), identity_matrix, |
1293 identity_matrix, | 1115 transform_origin, position, bounds, true, |
1294 transform_origin, | 1116 false, false); |
1295 position, | |
1296 bounds, | |
1297 true, | |
1298 false); | |
1299 child1->SetDrawsContent(true); | 1117 child1->SetDrawsContent(true); |
1300 child1->SetForceRenderSurface(true); | 1118 child1->SetHasRenderSurface(true); |
1301 | 1119 |
1302 position = gfx::PointF(50.f, 10.f); | 1120 position = gfx::PointF(50.f, 10.f); |
1303 bounds = gfx::Size(50, 50); | 1121 bounds = gfx::Size(50, 50); |
1304 SetLayerPropertiesForTesting(child2.get(), | 1122 SetLayerPropertiesForTesting(child2.get(), identity_matrix, |
1305 identity_matrix, | 1123 transform_origin, position, bounds, true, |
1306 transform_origin, | 1124 false, false); |
1307 position, | |
1308 bounds, | |
1309 true, | |
1310 false); | |
1311 child2->SetDrawsContent(true); | 1125 child2->SetDrawsContent(true); |
1312 child2->SetForceRenderSurface(true); | 1126 child2->SetHasRenderSurface(true); |
1313 | 1127 |
1314 // Remember that grand_child is positioned with respect to its parent (i.e. | 1128 // Remember that grand_child is positioned with respect to its parent (i.e. |
1315 // child1). In screen space, the intended position is (10, 50), with size | 1129 // child1). In screen space, the intended position is (10, 50), with size |
1316 // 100 x 50. | 1130 // 100 x 50. |
1317 position = gfx::PointF(0.f, 40.f); | 1131 position = gfx::PointF(0.f, 40.f); |
1318 bounds = gfx::Size(100, 50); | 1132 bounds = gfx::Size(100, 50); |
1319 SetLayerPropertiesForTesting(grand_child1.get(), | 1133 SetLayerPropertiesForTesting(grand_child1.get(), identity_matrix, |
1320 identity_matrix, | 1134 transform_origin, position, bounds, true, |
1321 transform_origin, | 1135 false, false); |
1322 position, | |
1323 bounds, | |
1324 true, | |
1325 false); | |
1326 grand_child1->SetDrawsContent(true); | 1136 grand_child1->SetDrawsContent(true); |
1327 grand_child1->SetForceRenderSurface(true); | 1137 grand_child1->SetHasRenderSurface(true); |
1328 | 1138 |
1329 child1->AddChild(grand_child1.Pass()); | 1139 child1->AddChild(grand_child1.Pass()); |
1330 root->AddChild(child1.Pass()); | 1140 root->AddChild(child1.Pass()); |
1331 root->AddChild(child2.Pass()); | 1141 root->AddChild(child2.Pass()); |
1332 } | 1142 } |
1333 | 1143 |
1334 LayerImpl* child1 = root->children()[0]; | 1144 LayerImpl* child1 = root->children()[0]; |
1335 LayerImpl* child2 = root->children()[1]; | 1145 LayerImpl* child2 = root->children()[1]; |
1336 LayerImpl* grand_child1 = child1->children()[0]; | 1146 LayerImpl* grand_child1 = child1->children()[0]; |
1337 | 1147 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1409 | 1219 |
1410 TEST_F(LayerTreeImplTest, HitCheckingTouchHandlerRegionsForSingleLayer) { | 1220 TEST_F(LayerTreeImplTest, HitCheckingTouchHandlerRegionsForSingleLayer) { |
1411 scoped_ptr<LayerImpl> root = | 1221 scoped_ptr<LayerImpl> root = |
1412 LayerImpl::Create(host_impl().active_tree(), 12345); | 1222 LayerImpl::Create(host_impl().active_tree(), 12345); |
1413 | 1223 |
1414 gfx::Transform identity_matrix; | 1224 gfx::Transform identity_matrix; |
1415 Region touch_handler_region(gfx::Rect(10, 10, 50, 50)); | 1225 Region touch_handler_region(gfx::Rect(10, 10, 50, 50)); |
1416 gfx::Point3F transform_origin; | 1226 gfx::Point3F transform_origin; |
1417 gfx::PointF position; | 1227 gfx::PointF position; |
1418 gfx::Size bounds(100, 100); | 1228 gfx::Size bounds(100, 100); |
1419 SetLayerPropertiesForTesting(root.get(), | 1229 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, |
1420 identity_matrix, | 1230 position, bounds, true, false, true); |
1421 transform_origin, | |
1422 position, | |
1423 bounds, | |
1424 true, | |
1425 false); | |
1426 root->SetDrawsContent(true); | 1231 root->SetDrawsContent(true); |
1427 | 1232 |
1428 host_impl().SetViewportSize(root->bounds()); | 1233 host_impl().SetViewportSize(root->bounds()); |
1429 host_impl().active_tree()->SetRootLayer(root.Pass()); | 1234 host_impl().active_tree()->SetRootLayer(root.Pass()); |
1430 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 1235 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
1431 | 1236 |
1432 // Sanity check the scenario we just created. | 1237 // Sanity check the scenario we just created. |
1433 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 1238 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); |
1434 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); | 1239 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); |
1435 | 1240 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1497 uninvertible_transform.matrix().set(1, 1, 0.0); | 1302 uninvertible_transform.matrix().set(1, 1, 0.0); |
1498 uninvertible_transform.matrix().set(2, 2, 0.0); | 1303 uninvertible_transform.matrix().set(2, 2, 0.0); |
1499 uninvertible_transform.matrix().set(3, 3, 0.0); | 1304 uninvertible_transform.matrix().set(3, 3, 0.0); |
1500 ASSERT_FALSE(uninvertible_transform.IsInvertible()); | 1305 ASSERT_FALSE(uninvertible_transform.IsInvertible()); |
1501 | 1306 |
1502 gfx::Transform identity_matrix; | 1307 gfx::Transform identity_matrix; |
1503 Region touch_handler_region(gfx::Rect(10, 10, 50, 50)); | 1308 Region touch_handler_region(gfx::Rect(10, 10, 50, 50)); |
1504 gfx::Point3F transform_origin; | 1309 gfx::Point3F transform_origin; |
1505 gfx::PointF position; | 1310 gfx::PointF position; |
1506 gfx::Size bounds(100, 100); | 1311 gfx::Size bounds(100, 100); |
1507 SetLayerPropertiesForTesting(root.get(), | 1312 SetLayerPropertiesForTesting(root.get(), uninvertible_transform, |
1508 uninvertible_transform, | 1313 transform_origin, position, bounds, true, false, |
1509 transform_origin, | 1314 true); |
1510 position, | |
1511 bounds, | |
1512 true, | |
1513 false); | |
1514 root->SetDrawsContent(true); | 1315 root->SetDrawsContent(true); |
1515 root->SetTouchEventHandlerRegion(touch_handler_region); | 1316 root->SetTouchEventHandlerRegion(touch_handler_region); |
1516 | 1317 |
1517 host_impl().SetViewportSize(root->bounds()); | 1318 host_impl().SetViewportSize(root->bounds()); |
1518 host_impl().active_tree()->SetRootLayer(root.Pass()); | 1319 host_impl().active_tree()->SetRootLayer(root.Pass()); |
1519 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 1320 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
1520 | 1321 |
1521 // Sanity check the scenario we just created. | 1322 // Sanity check the scenario we just created. |
1522 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 1323 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); |
1523 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); | 1324 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1575 scoped_ptr<LayerImpl> root = | 1376 scoped_ptr<LayerImpl> root = |
1576 LayerImpl::Create(host_impl().active_tree(), 12345); | 1377 LayerImpl::Create(host_impl().active_tree(), 12345); |
1577 | 1378 |
1578 gfx::Transform identity_matrix; | 1379 gfx::Transform identity_matrix; |
1579 Region touch_handler_region(gfx::Rect(10, 10, 50, 50)); | 1380 Region touch_handler_region(gfx::Rect(10, 10, 50, 50)); |
1580 gfx::Point3F transform_origin; | 1381 gfx::Point3F transform_origin; |
1581 // this layer is positioned, and hit testing should correctly know where the | 1382 // this layer is positioned, and hit testing should correctly know where the |
1582 // layer is located. | 1383 // layer is located. |
1583 gfx::PointF position(50.f, 50.f); | 1384 gfx::PointF position(50.f, 50.f); |
1584 gfx::Size bounds(100, 100); | 1385 gfx::Size bounds(100, 100); |
1585 SetLayerPropertiesForTesting(root.get(), | 1386 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, |
1586 identity_matrix, | 1387 position, bounds, true, false, true); |
1587 transform_origin, | |
1588 position, | |
1589 bounds, | |
1590 true, | |
1591 false); | |
1592 root->SetDrawsContent(true); | 1388 root->SetDrawsContent(true); |
1593 root->SetTouchEventHandlerRegion(touch_handler_region); | 1389 root->SetTouchEventHandlerRegion(touch_handler_region); |
1594 | 1390 |
1595 host_impl().SetViewportSize(root->bounds()); | 1391 host_impl().SetViewportSize(root->bounds()); |
1596 host_impl().active_tree()->SetRootLayer(root.Pass()); | 1392 host_impl().active_tree()->SetRootLayer(root.Pass()); |
1597 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 1393 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
1598 | 1394 |
1599 // Sanity check the scenario we just created. | 1395 // Sanity check the scenario we just created. |
1600 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 1396 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); |
1601 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); | 1397 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1651 // | 1447 // |
1652 // To test this, the layer is positioned at (25, 25), and is size (50, 50). If | 1448 // To test this, the layer is positioned at (25, 25), and is size (50, 50). If |
1653 // contents scale is ignored, then hit checking will mis-interpret the visible | 1449 // contents scale is ignored, then hit checking will mis-interpret the visible |
1654 // content rect as being larger than the actual bounds of the layer. | 1450 // content rect as being larger than the actual bounds of the layer. |
1655 // | 1451 // |
1656 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); | 1452 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); |
1657 | 1453 |
1658 gfx::Transform identity_matrix; | 1454 gfx::Transform identity_matrix; |
1659 gfx::Point3F transform_origin; | 1455 gfx::Point3F transform_origin; |
1660 | 1456 |
1661 SetLayerPropertiesForTesting(root.get(), | 1457 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, |
1662 identity_matrix, | 1458 gfx::PointF(), gfx::Size(100, 100), true, false, |
1663 transform_origin, | 1459 true); |
1664 gfx::PointF(), | |
1665 gfx::Size(100, 100), | |
1666 true, | |
1667 false); | |
1668 { | 1460 { |
1669 Region touch_handler_region(gfx::Rect(10, 10, 30, 30)); | 1461 Region touch_handler_region(gfx::Rect(10, 10, 30, 30)); |
1670 gfx::PointF position(25.f, 25.f); | 1462 gfx::PointF position(25.f, 25.f); |
1671 gfx::Size bounds(50, 50); | 1463 gfx::Size bounds(50, 50); |
1672 scoped_ptr<LayerImpl> test_layer = | 1464 scoped_ptr<LayerImpl> test_layer = |
1673 LayerImpl::Create(host_impl().active_tree(), 12345); | 1465 LayerImpl::Create(host_impl().active_tree(), 12345); |
1674 SetLayerPropertiesForTesting(test_layer.get(), | 1466 SetLayerPropertiesForTesting(test_layer.get(), identity_matrix, |
1675 identity_matrix, | 1467 transform_origin, position, bounds, true, |
1676 transform_origin, | 1468 false, false); |
1677 position, | |
1678 bounds, | |
1679 true, | |
1680 false); | |
1681 | 1469 |
1682 // override content bounds and contents scale | 1470 // override content bounds and contents scale |
1683 test_layer->SetContentBounds(gfx::Size(100, 100)); | 1471 test_layer->SetContentBounds(gfx::Size(100, 100)); |
1684 test_layer->SetContentsScale(2, 2); | 1472 test_layer->SetContentsScale(2, 2); |
1685 | 1473 |
1686 test_layer->SetDrawsContent(true); | 1474 test_layer->SetDrawsContent(true); |
1687 test_layer->SetTouchEventHandlerRegion(touch_handler_region); | 1475 test_layer->SetTouchEventHandlerRegion(touch_handler_region); |
1688 root->AddChild(test_layer.Pass()); | 1476 root->AddChild(test_layer.Pass()); |
1689 } | 1477 } |
1690 | 1478 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1755 TEST_F(LayerTreeImplTest, | 1543 TEST_F(LayerTreeImplTest, |
1756 HitCheckingTouchHandlerRegionsForSingleLayerWithDeviceScale) { | 1544 HitCheckingTouchHandlerRegionsForSingleLayerWithDeviceScale) { |
1757 // The layer's device_scale_factor and page_scale_factor should scale the | 1545 // The layer's device_scale_factor and page_scale_factor should scale the |
1758 // content rect and we should be able to hit the touch handler region by | 1546 // content rect and we should be able to hit the touch handler region by |
1759 // scaling the points accordingly. | 1547 // scaling the points accordingly. |
1760 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); | 1548 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); |
1761 | 1549 |
1762 gfx::Transform identity_matrix; | 1550 gfx::Transform identity_matrix; |
1763 gfx::Point3F transform_origin; | 1551 gfx::Point3F transform_origin; |
1764 // Set the bounds of the root layer big enough to fit the child when scaled. | 1552 // Set the bounds of the root layer big enough to fit the child when scaled. |
1765 SetLayerPropertiesForTesting(root.get(), | 1553 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, |
1766 identity_matrix, | 1554 gfx::PointF(), gfx::Size(100, 100), true, false, |
1767 transform_origin, | 1555 true); |
1768 gfx::PointF(), | |
1769 gfx::Size(100, 100), | |
1770 true, | |
1771 false); | |
1772 { | 1556 { |
1773 Region touch_handler_region(gfx::Rect(10, 10, 30, 30)); | 1557 Region touch_handler_region(gfx::Rect(10, 10, 30, 30)); |
1774 gfx::PointF position(25.f, 25.f); | 1558 gfx::PointF position(25.f, 25.f); |
1775 gfx::Size bounds(50, 50); | 1559 gfx::Size bounds(50, 50); |
1776 scoped_ptr<LayerImpl> test_layer = | 1560 scoped_ptr<LayerImpl> test_layer = |
1777 LayerImpl::Create(host_impl().active_tree(), 12345); | 1561 LayerImpl::Create(host_impl().active_tree(), 12345); |
1778 SetLayerPropertiesForTesting(test_layer.get(), | 1562 SetLayerPropertiesForTesting(test_layer.get(), identity_matrix, |
1779 identity_matrix, | 1563 transform_origin, position, bounds, true, |
1780 transform_origin, | 1564 false, false); |
1781 position, | |
1782 bounds, | |
1783 true, | |
1784 false); | |
1785 | 1565 |
1786 test_layer->SetDrawsContent(true); | 1566 test_layer->SetDrawsContent(true); |
1787 test_layer->SetTouchEventHandlerRegion(touch_handler_region); | 1567 test_layer->SetTouchEventHandlerRegion(touch_handler_region); |
1788 root->AddChild(test_layer.Pass()); | 1568 root->AddChild(test_layer.Pass()); |
1789 } | 1569 } |
1790 | 1570 |
1791 float device_scale_factor = 3.f; | 1571 float device_scale_factor = 3.f; |
1792 float page_scale_factor = 5.f; | 1572 float page_scale_factor = 5.f; |
1793 gfx::Size scaled_bounds_for_root = gfx::ToCeiledSize( | 1573 gfx::Size scaled_bounds_for_root = gfx::ToCeiledSize( |
1794 gfx::ScaleSize(root->bounds(), device_scale_factor * page_scale_factor)); | 1574 gfx::ScaleSize(root->bounds(), device_scale_factor * page_scale_factor)); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1881 } | 1661 } |
1882 | 1662 |
1883 TEST_F(LayerTreeImplTest, HitCheckingTouchHandlerRegionsForSimpleClippedLayer) { | 1663 TEST_F(LayerTreeImplTest, HitCheckingTouchHandlerRegionsForSimpleClippedLayer) { |
1884 // Test that hit-checking will only work for the visible portion of a layer, | 1664 // Test that hit-checking will only work for the visible portion of a layer, |
1885 // and not the entire layer bounds. Here we just test the simple axis-aligned | 1665 // and not the entire layer bounds. Here we just test the simple axis-aligned |
1886 // case. | 1666 // case. |
1887 gfx::Transform identity_matrix; | 1667 gfx::Transform identity_matrix; |
1888 gfx::Point3F transform_origin; | 1668 gfx::Point3F transform_origin; |
1889 | 1669 |
1890 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); | 1670 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); |
1891 SetLayerPropertiesForTesting(root.get(), | 1671 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, |
1892 identity_matrix, | 1672 gfx::PointF(), gfx::Size(100, 100), true, false, |
1893 transform_origin, | 1673 true); |
1894 gfx::PointF(), | |
1895 gfx::Size(100, 100), | |
1896 true, | |
1897 false); | |
1898 { | 1674 { |
1899 scoped_ptr<LayerImpl> clipping_layer = | 1675 scoped_ptr<LayerImpl> clipping_layer = |
1900 LayerImpl::Create(host_impl().active_tree(), 123); | 1676 LayerImpl::Create(host_impl().active_tree(), 123); |
1901 // this layer is positioned, and hit testing should correctly know where the | 1677 // this layer is positioned, and hit testing should correctly know where the |
1902 // layer is located. | 1678 // layer is located. |
1903 gfx::PointF position(25.f, 25.f); | 1679 gfx::PointF position(25.f, 25.f); |
1904 gfx::Size bounds(50, 50); | 1680 gfx::Size bounds(50, 50); |
1905 SetLayerPropertiesForTesting(clipping_layer.get(), | 1681 SetLayerPropertiesForTesting(clipping_layer.get(), identity_matrix, |
1906 identity_matrix, | 1682 transform_origin, position, bounds, true, |
1907 transform_origin, | 1683 false, false); |
1908 position, | |
1909 bounds, | |
1910 true, | |
1911 false); | |
1912 clipping_layer->SetMasksToBounds(true); | 1684 clipping_layer->SetMasksToBounds(true); |
1913 | 1685 |
1914 scoped_ptr<LayerImpl> child = | 1686 scoped_ptr<LayerImpl> child = |
1915 LayerImpl::Create(host_impl().active_tree(), 456); | 1687 LayerImpl::Create(host_impl().active_tree(), 456); |
1916 Region touch_handler_region(gfx::Rect(10, 10, 50, 50)); | 1688 Region touch_handler_region(gfx::Rect(10, 10, 50, 50)); |
1917 position = gfx::PointF(-50.f, -50.f); | 1689 position = gfx::PointF(-50.f, -50.f); |
1918 bounds = gfx::Size(300, 300); | 1690 bounds = gfx::Size(300, 300); |
1919 SetLayerPropertiesForTesting(child.get(), | 1691 SetLayerPropertiesForTesting(child.get(), identity_matrix, transform_origin, |
1920 identity_matrix, | 1692 position, bounds, true, false, false); |
1921 transform_origin, | |
1922 position, | |
1923 bounds, | |
1924 true, | |
1925 false); | |
1926 child->SetDrawsContent(true); | 1693 child->SetDrawsContent(true); |
1927 child->SetTouchEventHandlerRegion(touch_handler_region); | 1694 child->SetTouchEventHandlerRegion(touch_handler_region); |
1928 clipping_layer->AddChild(child.Pass()); | 1695 clipping_layer->AddChild(child.Pass()); |
1929 root->AddChild(clipping_layer.Pass()); | 1696 root->AddChild(clipping_layer.Pass()); |
1930 } | 1697 } |
1931 | 1698 |
1932 host_impl().SetViewportSize(root->bounds()); | 1699 host_impl().SetViewportSize(root->bounds()); |
1933 host_impl().active_tree()->SetRootLayer(root.Pass()); | 1700 host_impl().active_tree()->SetRootLayer(root.Pass()); |
1934 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 1701 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
1935 | 1702 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1976 test_point); | 1743 test_point); |
1977 ASSERT_TRUE(result_layer); | 1744 ASSERT_TRUE(result_layer); |
1978 EXPECT_EQ(456, result_layer->id()); | 1745 EXPECT_EQ(456, result_layer->id()); |
1979 } | 1746 } |
1980 | 1747 |
1981 TEST_F(LayerTreeImplTest, HitCheckingTouchHandlerOverlappingRegions) { | 1748 TEST_F(LayerTreeImplTest, HitCheckingTouchHandlerOverlappingRegions) { |
1982 gfx::Transform identity_matrix; | 1749 gfx::Transform identity_matrix; |
1983 gfx::Point3F transform_origin; | 1750 gfx::Point3F transform_origin; |
1984 | 1751 |
1985 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); | 1752 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); |
1986 SetLayerPropertiesForTesting(root.get(), | 1753 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, |
1987 identity_matrix, | 1754 gfx::PointF(), gfx::Size(100, 100), true, false, |
1988 transform_origin, | 1755 true); |
1989 gfx::PointF(), | |
1990 gfx::Size(100, 100), | |
1991 true, | |
1992 false); | |
1993 { | 1756 { |
1994 scoped_ptr<LayerImpl> touch_layer = | 1757 scoped_ptr<LayerImpl> touch_layer = |
1995 LayerImpl::Create(host_impl().active_tree(), 123); | 1758 LayerImpl::Create(host_impl().active_tree(), 123); |
1996 // this layer is positioned, and hit testing should correctly know where the | 1759 // this layer is positioned, and hit testing should correctly know where the |
1997 // layer is located. | 1760 // layer is located. |
1998 gfx::PointF position; | 1761 gfx::PointF position; |
1999 gfx::Size bounds(50, 50); | 1762 gfx::Size bounds(50, 50); |
2000 SetLayerPropertiesForTesting(touch_layer.get(), | 1763 SetLayerPropertiesForTesting(touch_layer.get(), identity_matrix, |
2001 identity_matrix, | 1764 transform_origin, position, bounds, true, |
2002 transform_origin, | 1765 false, false); |
2003 position, | |
2004 bounds, | |
2005 true, | |
2006 false); | |
2007 touch_layer->SetDrawsContent(true); | 1766 touch_layer->SetDrawsContent(true); |
2008 touch_layer->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 50, 50)); | 1767 touch_layer->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 50, 50)); |
2009 root->AddChild(touch_layer.Pass()); | 1768 root->AddChild(touch_layer.Pass()); |
2010 } | 1769 } |
2011 | 1770 |
2012 { | 1771 { |
2013 scoped_ptr<LayerImpl> notouch_layer = | 1772 scoped_ptr<LayerImpl> notouch_layer = |
2014 LayerImpl::Create(host_impl().active_tree(), 1234); | 1773 LayerImpl::Create(host_impl().active_tree(), 1234); |
2015 // this layer is positioned, and hit testing should correctly know where the | 1774 // this layer is positioned, and hit testing should correctly know where the |
2016 // layer is located. | 1775 // layer is located. |
2017 gfx::PointF position(0, 25); | 1776 gfx::PointF position(0, 25); |
2018 gfx::Size bounds(50, 50); | 1777 gfx::Size bounds(50, 50); |
2019 SetLayerPropertiesForTesting(notouch_layer.get(), | 1778 SetLayerPropertiesForTesting(notouch_layer.get(), identity_matrix, |
2020 identity_matrix, | 1779 transform_origin, position, bounds, true, |
2021 transform_origin, | 1780 false, false); |
2022 position, | |
2023 bounds, | |
2024 true, | |
2025 false); | |
2026 notouch_layer->SetDrawsContent(true); | 1781 notouch_layer->SetDrawsContent(true); |
2027 root->AddChild(notouch_layer.Pass()); | 1782 root->AddChild(notouch_layer.Pass()); |
2028 } | 1783 } |
2029 | 1784 |
2030 host_impl().SetViewportSize(root->bounds()); | 1785 host_impl().SetViewportSize(root->bounds()); |
2031 host_impl().active_tree()->SetRootLayer(root.Pass()); | 1786 host_impl().active_tree()->SetRootLayer(root.Pass()); |
2032 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 1787 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
2033 | 1788 |
2034 // Sanity check the scenario we just created. | 1789 // Sanity check the scenario we just created. |
2035 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 1790 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2073 | 1828 |
2074 TEST_F(LayerTreeImplTest, SelectionBoundsForSingleLayer) { | 1829 TEST_F(LayerTreeImplTest, SelectionBoundsForSingleLayer) { |
2075 int root_layer_id = 12345; | 1830 int root_layer_id = 12345; |
2076 scoped_ptr<LayerImpl> root = | 1831 scoped_ptr<LayerImpl> root = |
2077 LayerImpl::Create(host_impl().active_tree(), root_layer_id); | 1832 LayerImpl::Create(host_impl().active_tree(), root_layer_id); |
2078 | 1833 |
2079 gfx::Transform identity_matrix; | 1834 gfx::Transform identity_matrix; |
2080 gfx::Point3F transform_origin; | 1835 gfx::Point3F transform_origin; |
2081 gfx::PointF position; | 1836 gfx::PointF position; |
2082 gfx::Size bounds(100, 100); | 1837 gfx::Size bounds(100, 100); |
2083 SetLayerPropertiesForTesting(root.get(), | 1838 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, |
2084 identity_matrix, | 1839 position, bounds, true, false, true); |
2085 transform_origin, | |
2086 position, | |
2087 bounds, | |
2088 true, | |
2089 false); | |
2090 root->SetDrawsContent(true); | 1840 root->SetDrawsContent(true); |
2091 | 1841 |
2092 host_impl().SetViewportSize(root->bounds()); | 1842 host_impl().SetViewportSize(root->bounds()); |
2093 host_impl().active_tree()->SetRootLayer(root.Pass()); | 1843 host_impl().active_tree()->SetRootLayer(root.Pass()); |
2094 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 1844 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
2095 | 1845 |
2096 // Sanity check the scenario we just created. | 1846 // Sanity check the scenario we just created. |
2097 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 1847 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); |
2098 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); | 1848 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); |
2099 | 1849 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2149 int clip_layer_id = 1234; | 1899 int clip_layer_id = 1234; |
2150 int clipped_layer_id = 123; | 1900 int clipped_layer_id = 123; |
2151 scoped_ptr<LayerImpl> root = | 1901 scoped_ptr<LayerImpl> root = |
2152 LayerImpl::Create(host_impl().active_tree(), root_layer_id); | 1902 LayerImpl::Create(host_impl().active_tree(), root_layer_id); |
2153 root->SetDrawsContent(true); | 1903 root->SetDrawsContent(true); |
2154 | 1904 |
2155 gfx::Transform identity_matrix; | 1905 gfx::Transform identity_matrix; |
2156 gfx::Point3F transform_origin; | 1906 gfx::Point3F transform_origin; |
2157 gfx::PointF position; | 1907 gfx::PointF position; |
2158 gfx::Size bounds(100, 100); | 1908 gfx::Size bounds(100, 100); |
2159 SetLayerPropertiesForTesting(root.get(), | 1909 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, |
2160 identity_matrix, | 1910 position, bounds, true, false, true); |
2161 transform_origin, | |
2162 position, | |
2163 bounds, | |
2164 true, | |
2165 false); | |
2166 | 1911 |
2167 gfx::Vector2dF clipping_offset(10, 10); | 1912 gfx::Vector2dF clipping_offset(10, 10); |
2168 { | 1913 { |
2169 scoped_ptr<LayerImpl> clipping_layer = | 1914 scoped_ptr<LayerImpl> clipping_layer = |
2170 LayerImpl::Create(host_impl().active_tree(), clip_layer_id); | 1915 LayerImpl::Create(host_impl().active_tree(), clip_layer_id); |
2171 // The clipping layer should occlude the right selection bound. | 1916 // The clipping layer should occlude the right selection bound. |
2172 gfx::PointF position = gfx::PointF() + clipping_offset; | 1917 gfx::PointF position = gfx::PointF() + clipping_offset; |
2173 gfx::Size bounds(50, 50); | 1918 gfx::Size bounds(50, 50); |
2174 SetLayerPropertiesForTesting(clipping_layer.get(), | 1919 SetLayerPropertiesForTesting(clipping_layer.get(), identity_matrix, |
2175 identity_matrix, | 1920 transform_origin, position, bounds, true, |
2176 transform_origin, | 1921 false, false); |
2177 position, | |
2178 bounds, | |
2179 true, | |
2180 false); | |
2181 clipping_layer->SetMasksToBounds(true); | 1922 clipping_layer->SetMasksToBounds(true); |
2182 | 1923 |
2183 scoped_ptr<LayerImpl> clipped_layer = | 1924 scoped_ptr<LayerImpl> clipped_layer = |
2184 LayerImpl::Create(host_impl().active_tree(), clipped_layer_id); | 1925 LayerImpl::Create(host_impl().active_tree(), clipped_layer_id); |
2185 position = gfx::PointF(); | 1926 position = gfx::PointF(); |
2186 bounds = gfx::Size(100, 100); | 1927 bounds = gfx::Size(100, 100); |
2187 SetLayerPropertiesForTesting(clipped_layer.get(), | 1928 SetLayerPropertiesForTesting(clipped_layer.get(), identity_matrix, |
2188 identity_matrix, | 1929 transform_origin, position, bounds, true, |
2189 transform_origin, | 1930 false, false); |
2190 position, | |
2191 bounds, | |
2192 true, | |
2193 false); | |
2194 clipped_layer->SetDrawsContent(true); | 1931 clipped_layer->SetDrawsContent(true); |
2195 clipping_layer->AddChild(clipped_layer.Pass()); | 1932 clipping_layer->AddChild(clipped_layer.Pass()); |
2196 root->AddChild(clipping_layer.Pass()); | 1933 root->AddChild(clipping_layer.Pass()); |
2197 } | 1934 } |
2198 | 1935 |
2199 host_impl().SetViewportSize(root->bounds()); | 1936 host_impl().SetViewportSize(root->bounds()); |
2200 host_impl().active_tree()->SetRootLayer(root.Pass()); | 1937 host_impl().active_tree()->SetRootLayer(root.Pass()); |
2201 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 1938 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
2202 | 1939 |
2203 // Sanity check the scenario we just created. | 1940 // Sanity check the scenario we just created. |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2261 int root_layer_id = 1; | 1998 int root_layer_id = 1; |
2262 int sub_layer_id = 2; | 1999 int sub_layer_id = 2; |
2263 scoped_ptr<LayerImpl> root = | 2000 scoped_ptr<LayerImpl> root = |
2264 LayerImpl::Create(host_impl().active_tree(), root_layer_id); | 2001 LayerImpl::Create(host_impl().active_tree(), root_layer_id); |
2265 root->SetDrawsContent(true); | 2002 root->SetDrawsContent(true); |
2266 | 2003 |
2267 gfx::Transform identity_matrix; | 2004 gfx::Transform identity_matrix; |
2268 gfx::Point3F transform_origin; | 2005 gfx::Point3F transform_origin; |
2269 gfx::PointF position; | 2006 gfx::PointF position; |
2270 gfx::Size bounds(100, 100); | 2007 gfx::Size bounds(100, 100); |
2271 SetLayerPropertiesForTesting(root.get(), | 2008 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, |
2272 identity_matrix, | 2009 position, bounds, true, false, true); |
2273 transform_origin, | |
2274 position, | |
2275 bounds, | |
2276 true, | |
2277 false); | |
2278 | 2010 |
2279 gfx::Vector2dF sub_layer_offset(10, 0); | 2011 gfx::Vector2dF sub_layer_offset(10, 0); |
2280 { | 2012 { |
2281 scoped_ptr<LayerImpl> sub_layer = | 2013 scoped_ptr<LayerImpl> sub_layer = |
2282 LayerImpl::Create(host_impl().active_tree(), sub_layer_id); | 2014 LayerImpl::Create(host_impl().active_tree(), sub_layer_id); |
2283 gfx::PointF position = gfx::PointF() + sub_layer_offset; | 2015 gfx::PointF position = gfx::PointF() + sub_layer_offset; |
2284 gfx::Size bounds(50, 50); | 2016 gfx::Size bounds(50, 50); |
2285 SetLayerPropertiesForTesting(sub_layer.get(), | 2017 SetLayerPropertiesForTesting(sub_layer.get(), identity_matrix, |
2286 identity_matrix, | 2018 transform_origin, position, bounds, true, |
2287 transform_origin, | 2019 false, false); |
2288 position, | |
2289 bounds, | |
2290 true, | |
2291 false); | |
2292 sub_layer->SetDrawsContent(true); | 2020 sub_layer->SetDrawsContent(true); |
2293 root->AddChild(sub_layer.Pass()); | 2021 root->AddChild(sub_layer.Pass()); |
2294 } | 2022 } |
2295 | 2023 |
2296 float device_scale_factor = 3.f; | 2024 float device_scale_factor = 3.f; |
2297 float page_scale_factor = 5.f; | 2025 float page_scale_factor = 5.f; |
2298 gfx::Size scaled_bounds_for_root = gfx::ToCeiledSize( | 2026 gfx::Size scaled_bounds_for_root = gfx::ToCeiledSize( |
2299 gfx::ScaleSize(root->bounds(), device_scale_factor * page_scale_factor)); | 2027 gfx::ScaleSize(root->bounds(), device_scale_factor * page_scale_factor)); |
2300 host_impl().SetViewportSize(scaled_bounds_for_root); | 2028 host_impl().SetViewportSize(scaled_bounds_for_root); |
2301 | 2029 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2360 EXPECT_EQ(0u, host_impl().active_tree()->NumLayers()); | 2088 EXPECT_EQ(0u, host_impl().active_tree()->NumLayers()); |
2361 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); | 2089 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); |
2362 root->AddChild(LayerImpl::Create(host_impl().active_tree(), 2)); | 2090 root->AddChild(LayerImpl::Create(host_impl().active_tree(), 2)); |
2363 root->AddChild(LayerImpl::Create(host_impl().active_tree(), 3)); | 2091 root->AddChild(LayerImpl::Create(host_impl().active_tree(), 3)); |
2364 root->child_at(1)->AddChild(LayerImpl::Create(host_impl().active_tree(), 4)); | 2092 root->child_at(1)->AddChild(LayerImpl::Create(host_impl().active_tree(), 4)); |
2365 EXPECT_EQ(4u, host_impl().active_tree()->NumLayers()); | 2093 EXPECT_EQ(4u, host_impl().active_tree()->NumLayers()); |
2366 } | 2094 } |
2367 | 2095 |
2368 } // namespace | 2096 } // namespace |
2369 } // namespace cc | 2097 } // namespace cc |
OLD | NEW |