| 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 30 matching lines...) Expand all Loading... |
| 41 TestSharedBitmapManager shared_bitmap_manager_; | 41 TestSharedBitmapManager shared_bitmap_manager_; |
| 42 FakeImplProxy proxy_; | 42 FakeImplProxy proxy_; |
| 43 scoped_ptr<FakeLayerTreeHostImpl> host_impl_; | 43 scoped_ptr<FakeLayerTreeHostImpl> host_impl_; |
| 44 }; | 44 }; |
| 45 | 45 |
| 46 TEST_F(LayerTreeImplTest, HitTestingForSingleLayer) { | 46 TEST_F(LayerTreeImplTest, HitTestingForSingleLayer) { |
| 47 scoped_ptr<LayerImpl> root = | 47 scoped_ptr<LayerImpl> root = |
| 48 LayerImpl::Create(host_impl().active_tree(), 12345); | 48 LayerImpl::Create(host_impl().active_tree(), 12345); |
| 49 | 49 |
| 50 gfx::Transform identity_matrix; | 50 gfx::Transform identity_matrix; |
| 51 gfx::PointF anchor; | 51 gfx::Point3F transform_origin; |
| 52 gfx::PointF position; | 52 gfx::PointF position; |
| 53 gfx::Size bounds(100, 100); | 53 gfx::Size bounds(100, 100); |
| 54 SetLayerPropertiesForTesting( | 54 SetLayerPropertiesForTesting(root.get(), |
| 55 root.get(), identity_matrix, anchor, position, bounds, true, false); | 55 identity_matrix, |
| 56 transform_origin, |
| 57 position, |
| 58 bounds, |
| 59 true, |
| 60 false); |
| 56 root->SetDrawsContent(true); | 61 root->SetDrawsContent(true); |
| 57 | 62 |
| 58 host_impl().SetViewportSize(root->bounds()); | 63 host_impl().SetViewportSize(root->bounds()); |
| 59 host_impl().active_tree()->SetRootLayer(root.Pass()); | 64 host_impl().active_tree()->SetRootLayer(root.Pass()); |
| 60 host_impl().active_tree()->UpdateDrawProperties(); | 65 host_impl().active_tree()->UpdateDrawProperties(); |
| 61 | 66 |
| 62 // Sanity check the scenario we just created. | 67 // Sanity check the scenario we just created. |
| 63 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 68 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); |
| 64 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); | 69 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); |
| 65 | 70 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 88 EXPECT_EQ(12345, result_layer->id()); | 93 EXPECT_EQ(12345, result_layer->id()); |
| 89 } | 94 } |
| 90 | 95 |
| 91 TEST_F(LayerTreeImplTest, HitTestingForSingleLayerAndHud) { | 96 TEST_F(LayerTreeImplTest, HitTestingForSingleLayerAndHud) { |
| 92 scoped_ptr<LayerImpl> root = | 97 scoped_ptr<LayerImpl> root = |
| 93 LayerImpl::Create(host_impl().active_tree(), 12345); | 98 LayerImpl::Create(host_impl().active_tree(), 12345); |
| 94 scoped_ptr<HeadsUpDisplayLayerImpl> hud = | 99 scoped_ptr<HeadsUpDisplayLayerImpl> hud = |
| 95 HeadsUpDisplayLayerImpl::Create(host_impl().active_tree(), 11111); | 100 HeadsUpDisplayLayerImpl::Create(host_impl().active_tree(), 11111); |
| 96 | 101 |
| 97 gfx::Transform identity_matrix; | 102 gfx::Transform identity_matrix; |
| 98 gfx::PointF anchor; | 103 gfx::Point3F transform_origin; |
| 99 gfx::PointF position; | 104 gfx::PointF position; |
| 100 gfx::Size bounds(100, 100); | 105 gfx::Size bounds(100, 100); |
| 101 SetLayerPropertiesForTesting( | 106 SetLayerPropertiesForTesting(root.get(), |
| 102 root.get(), identity_matrix, anchor, position, bounds, true, false); | 107 identity_matrix, |
| 108 transform_origin, |
| 109 position, |
| 110 bounds, |
| 111 true, |
| 112 false); |
| 103 root->SetDrawsContent(true); | 113 root->SetDrawsContent(true); |
| 104 | 114 |
| 105 // Create hud and add it as a child of root. | 115 // Create hud and add it as a child of root. |
| 106 gfx::Size hud_bounds(200, 200); | 116 gfx::Size hud_bounds(200, 200); |
| 107 SetLayerPropertiesForTesting( | 117 SetLayerPropertiesForTesting(hud.get(), |
| 108 hud.get(), identity_matrix, anchor, position, hud_bounds, true, false); | 118 identity_matrix, |
| 119 transform_origin, |
| 120 position, |
| 121 hud_bounds, |
| 122 true, |
| 123 false); |
| 109 hud->SetDrawsContent(true); | 124 hud->SetDrawsContent(true); |
| 110 | 125 |
| 111 host_impl().active_tree()->set_hud_layer(hud.get()); | 126 host_impl().active_tree()->set_hud_layer(hud.get()); |
| 112 root->AddChild(hud.PassAs<LayerImpl>()); | 127 root->AddChild(hud.PassAs<LayerImpl>()); |
| 113 | 128 |
| 114 host_impl().SetViewportSize(hud_bounds); | 129 host_impl().SetViewportSize(hud_bounds); |
| 115 host_impl().active_tree()->SetRootLayer(root.Pass()); | 130 host_impl().active_tree()->SetRootLayer(root.Pass()); |
| 116 host_impl().active_tree()->UpdateDrawProperties(); | 131 host_impl().active_tree()->UpdateDrawProperties(); |
| 117 | 132 |
| 118 // Sanity check the scenario we just created. | 133 // Sanity check the scenario we just created. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 LayerImpl::Create(host_impl().active_tree(), 12345); | 165 LayerImpl::Create(host_impl().active_tree(), 12345); |
| 151 | 166 |
| 152 gfx::Transform uninvertible_transform; | 167 gfx::Transform uninvertible_transform; |
| 153 uninvertible_transform.matrix().set(0, 0, 0.0); | 168 uninvertible_transform.matrix().set(0, 0, 0.0); |
| 154 uninvertible_transform.matrix().set(1, 1, 0.0); | 169 uninvertible_transform.matrix().set(1, 1, 0.0); |
| 155 uninvertible_transform.matrix().set(2, 2, 0.0); | 170 uninvertible_transform.matrix().set(2, 2, 0.0); |
| 156 uninvertible_transform.matrix().set(3, 3, 0.0); | 171 uninvertible_transform.matrix().set(3, 3, 0.0); |
| 157 ASSERT_FALSE(uninvertible_transform.IsInvertible()); | 172 ASSERT_FALSE(uninvertible_transform.IsInvertible()); |
| 158 | 173 |
| 159 gfx::Transform identity_matrix; | 174 gfx::Transform identity_matrix; |
| 160 gfx::PointF anchor; | 175 gfx::Point3F transform_origin; |
| 161 gfx::PointF position; | 176 gfx::PointF position; |
| 162 gfx::Size bounds(100, 100); | 177 gfx::Size bounds(100, 100); |
| 163 SetLayerPropertiesForTesting(root.get(), | 178 SetLayerPropertiesForTesting(root.get(), |
| 164 uninvertible_transform, | 179 uninvertible_transform, |
| 165 anchor, | 180 transform_origin, |
| 166 position, | 181 position, |
| 167 bounds, | 182 bounds, |
| 168 true, | 183 true, |
| 169 false); | 184 false); |
| 170 root->SetDrawsContent(true); | 185 root->SetDrawsContent(true); |
| 171 | 186 |
| 172 host_impl().SetViewportSize(root->bounds()); | 187 host_impl().SetViewportSize(root->bounds()); |
| 173 host_impl().active_tree()->SetRootLayer(root.Pass()); | 188 host_impl().active_tree()->SetRootLayer(root.Pass()); |
| 174 host_impl().active_tree()->UpdateDrawProperties(); | 189 host_impl().active_tree()->UpdateDrawProperties(); |
| 175 // Sanity check the scenario we just created. | 190 // Sanity check the scenario we just created. |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 result_layer = | 229 result_layer = |
| 215 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 230 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); |
| 216 EXPECT_FALSE(result_layer); | 231 EXPECT_FALSE(result_layer); |
| 217 } | 232 } |
| 218 | 233 |
| 219 TEST_F(LayerTreeImplTest, HitTestingForSinglePositionedLayer) { | 234 TEST_F(LayerTreeImplTest, HitTestingForSinglePositionedLayer) { |
| 220 scoped_ptr<LayerImpl> root = | 235 scoped_ptr<LayerImpl> root = |
| 221 LayerImpl::Create(host_impl().active_tree(), 12345); | 236 LayerImpl::Create(host_impl().active_tree(), 12345); |
| 222 | 237 |
| 223 gfx::Transform identity_matrix; | 238 gfx::Transform identity_matrix; |
| 224 gfx::PointF anchor; | 239 gfx::Point3F transform_origin; |
| 225 // this layer is positioned, and hit testing should correctly know where the | 240 // this layer is positioned, and hit testing should correctly know where the |
| 226 // layer is located. | 241 // layer is located. |
| 227 gfx::PointF position(50.f, 50.f); | 242 gfx::PointF position(50.f, 50.f); |
| 228 gfx::Size bounds(100, 100); | 243 gfx::Size bounds(100, 100); |
| 229 SetLayerPropertiesForTesting( | 244 SetLayerPropertiesForTesting(root.get(), |
| 230 root.get(), identity_matrix, anchor, position, bounds, true, false); | 245 identity_matrix, |
| 246 transform_origin, |
| 247 position, |
| 248 bounds, |
| 249 true, |
| 250 false); |
| 231 root->SetDrawsContent(true); | 251 root->SetDrawsContent(true); |
| 232 | 252 |
| 233 host_impl().SetViewportSize(root->bounds()); | 253 host_impl().SetViewportSize(root->bounds()); |
| 234 host_impl().active_tree()->SetRootLayer(root.Pass()); | 254 host_impl().active_tree()->SetRootLayer(root.Pass()); |
| 235 host_impl().active_tree()->UpdateDrawProperties(); | 255 host_impl().active_tree()->UpdateDrawProperties(); |
| 236 | 256 |
| 237 // Sanity check the scenario we just created. | 257 // Sanity check the scenario we just created. |
| 238 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 258 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); |
| 239 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); | 259 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); |
| 240 | 260 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 267 | 287 |
| 268 TEST_F(LayerTreeImplTest, HitTestingForSingleRotatedLayer) { | 288 TEST_F(LayerTreeImplTest, HitTestingForSingleRotatedLayer) { |
| 269 scoped_ptr<LayerImpl> root = | 289 scoped_ptr<LayerImpl> root = |
| 270 LayerImpl::Create(host_impl().active_tree(), 12345); | 290 LayerImpl::Create(host_impl().active_tree(), 12345); |
| 271 | 291 |
| 272 gfx::Transform identity_matrix; | 292 gfx::Transform identity_matrix; |
| 273 gfx::Transform rotation45_degrees_about_center; | 293 gfx::Transform rotation45_degrees_about_center; |
| 274 rotation45_degrees_about_center.Translate(50.0, 50.0); | 294 rotation45_degrees_about_center.Translate(50.0, 50.0); |
| 275 rotation45_degrees_about_center.RotateAboutZAxis(45.0); | 295 rotation45_degrees_about_center.RotateAboutZAxis(45.0); |
| 276 rotation45_degrees_about_center.Translate(-50.0, -50.0); | 296 rotation45_degrees_about_center.Translate(-50.0, -50.0); |
| 277 gfx::PointF anchor; | 297 gfx::Point3F transform_origin; |
| 278 gfx::PointF position; | 298 gfx::PointF position; |
| 279 gfx::Size bounds(100, 100); | 299 gfx::Size bounds(100, 100); |
| 280 SetLayerPropertiesForTesting(root.get(), | 300 SetLayerPropertiesForTesting(root.get(), |
| 281 rotation45_degrees_about_center, | 301 rotation45_degrees_about_center, |
| 282 anchor, | 302 transform_origin, |
| 283 position, | 303 position, |
| 284 bounds, | 304 bounds, |
| 285 true, | 305 true, |
| 286 false); | 306 false); |
| 287 root->SetDrawsContent(true); | 307 root->SetDrawsContent(true); |
| 288 | 308 |
| 289 host_impl().SetViewportSize(root->bounds()); | 309 host_impl().SetViewportSize(root->bounds()); |
| 290 host_impl().active_tree()->SetRootLayer(root.Pass()); | 310 host_impl().active_tree()->SetRootLayer(root.Pass()); |
| 291 host_impl().active_tree()->UpdateDrawProperties(); | 311 host_impl().active_tree()->UpdateDrawProperties(); |
| 292 | 312 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 | 355 |
| 336 // perspective_projection_about_center * translation_by_z is designed so that | 356 // perspective_projection_about_center * translation_by_z is designed so that |
| 337 // the 100 x 100 layer becomes 50 x 50, and remains centered at (50, 50). | 357 // the 100 x 100 layer becomes 50 x 50, and remains centered at (50, 50). |
| 338 gfx::Transform perspective_projection_about_center; | 358 gfx::Transform perspective_projection_about_center; |
| 339 perspective_projection_about_center.Translate(50.0, 50.0); | 359 perspective_projection_about_center.Translate(50.0, 50.0); |
| 340 perspective_projection_about_center.ApplyPerspectiveDepth(1.0); | 360 perspective_projection_about_center.ApplyPerspectiveDepth(1.0); |
| 341 perspective_projection_about_center.Translate(-50.0, -50.0); | 361 perspective_projection_about_center.Translate(-50.0, -50.0); |
| 342 gfx::Transform translation_by_z; | 362 gfx::Transform translation_by_z; |
| 343 translation_by_z.Translate3d(0.0, 0.0, -1.0); | 363 translation_by_z.Translate3d(0.0, 0.0, -1.0); |
| 344 | 364 |
| 345 gfx::PointF anchor; | 365 gfx::Point3F transform_origin; |
| 346 gfx::PointF position; | 366 gfx::PointF position; |
| 347 gfx::Size bounds(100, 100); | 367 gfx::Size bounds(100, 100); |
| 348 SetLayerPropertiesForTesting( | 368 SetLayerPropertiesForTesting( |
| 349 root.get(), | 369 root.get(), |
| 350 perspective_projection_about_center * translation_by_z, | 370 perspective_projection_about_center * translation_by_z, |
| 351 anchor, | 371 transform_origin, |
| 352 position, | 372 position, |
| 353 bounds, | 373 bounds, |
| 354 true, | 374 true, |
| 355 false); | 375 false); |
| 356 root->SetDrawsContent(true); | 376 root->SetDrawsContent(true); |
| 357 | 377 |
| 358 host_impl().SetViewportSize(root->bounds()); | 378 host_impl().SetViewportSize(root->bounds()); |
| 359 host_impl().active_tree()->SetRootLayer(root.Pass()); | 379 host_impl().active_tree()->SetRootLayer(root.Pass()); |
| 360 host_impl().active_tree()->UpdateDrawProperties(); | 380 host_impl().active_tree()->UpdateDrawProperties(); |
| 361 | 381 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 // non-identity transform between layer's content space and layer's origin | 418 // non-identity transform between layer's content space and layer's origin |
| 399 // space. The hit testing code must take this into account. | 419 // space. The hit testing code must take this into account. |
| 400 // | 420 // |
| 401 // To test this, the layer is positioned at (25, 25), and is size (50, 50). If | 421 // To test this, the layer is positioned at (25, 25), and is size (50, 50). If |
| 402 // contents scale is ignored, then hit testing will mis-interpret the visible | 422 // contents scale is ignored, then hit testing will mis-interpret the visible |
| 403 // content rect as being larger than the actual bounds of the layer. | 423 // content rect as being larger than the actual bounds of the layer. |
| 404 // | 424 // |
| 405 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); | 425 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); |
| 406 | 426 |
| 407 gfx::Transform identity_matrix; | 427 gfx::Transform identity_matrix; |
| 408 gfx::PointF anchor; | 428 gfx::Point3F transform_origin; |
| 409 | 429 |
| 410 SetLayerPropertiesForTesting(root.get(), | 430 SetLayerPropertiesForTesting(root.get(), |
| 411 identity_matrix, | 431 identity_matrix, |
| 412 anchor, | 432 transform_origin, |
| 413 gfx::PointF(), | 433 gfx::PointF(), |
| 414 gfx::Size(100, 100), | 434 gfx::Size(100, 100), |
| 415 true, | 435 true, |
| 416 false); | 436 false); |
| 417 { | 437 { |
| 418 gfx::PointF position(25.f, 25.f); | 438 gfx::PointF position(25.f, 25.f); |
| 419 gfx::Size bounds(50, 50); | 439 gfx::Size bounds(50, 50); |
| 420 scoped_ptr<LayerImpl> test_layer = | 440 scoped_ptr<LayerImpl> test_layer = |
| 421 LayerImpl::Create(host_impl().active_tree(), 12345); | 441 LayerImpl::Create(host_impl().active_tree(), 12345); |
| 422 SetLayerPropertiesForTesting(test_layer.get(), | 442 SetLayerPropertiesForTesting(test_layer.get(), |
| 423 identity_matrix, | 443 identity_matrix, |
| 424 anchor, | 444 transform_origin, |
| 425 position, | 445 position, |
| 426 bounds, | 446 bounds, |
| 427 true, | 447 true, |
| 428 false); | 448 false); |
| 429 | 449 |
| 430 // override content bounds and contents scale | 450 // override content bounds and contents scale |
| 431 test_layer->SetContentBounds(gfx::Size(100, 100)); | 451 test_layer->SetContentBounds(gfx::Size(100, 100)); |
| 432 test_layer->SetContentsScale(2, 2); | 452 test_layer->SetContentsScale(2, 2); |
| 433 | 453 |
| 434 test_layer->SetDrawsContent(true); | 454 test_layer->SetDrawsContent(true); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 497 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); |
| 478 ASSERT_TRUE(result_layer); | 498 ASSERT_TRUE(result_layer); |
| 479 EXPECT_EQ(12345, result_layer->id()); | 499 EXPECT_EQ(12345, result_layer->id()); |
| 480 } | 500 } |
| 481 | 501 |
| 482 TEST_F(LayerTreeImplTest, HitTestingForSimpleClippedLayer) { | 502 TEST_F(LayerTreeImplTest, HitTestingForSimpleClippedLayer) { |
| 483 // Test that hit-testing will only work for the visible portion of a layer, | 503 // Test that hit-testing will only work for the visible portion of a layer, |
| 484 // and not the entire layer bounds. Here we just test the simple axis-aligned | 504 // and not the entire layer bounds. Here we just test the simple axis-aligned |
| 485 // case. | 505 // case. |
| 486 gfx::Transform identity_matrix; | 506 gfx::Transform identity_matrix; |
| 487 gfx::PointF anchor; | 507 gfx::Point3F transform_origin; |
| 488 | 508 |
| 489 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); | 509 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); |
| 490 SetLayerPropertiesForTesting(root.get(), | 510 SetLayerPropertiesForTesting(root.get(), |
| 491 identity_matrix, | 511 identity_matrix, |
| 492 anchor, | 512 transform_origin, |
| 493 gfx::PointF(), | 513 gfx::PointF(), |
| 494 gfx::Size(100, 100), | 514 gfx::Size(100, 100), |
| 495 true, | 515 true, |
| 496 false); | 516 false); |
| 497 { | 517 { |
| 498 scoped_ptr<LayerImpl> clipping_layer = | 518 scoped_ptr<LayerImpl> clipping_layer = |
| 499 LayerImpl::Create(host_impl().active_tree(), 123); | 519 LayerImpl::Create(host_impl().active_tree(), 123); |
| 500 // this layer is positioned, and hit testing should correctly know where the | 520 // this layer is positioned, and hit testing should correctly know where the |
| 501 // layer is located. | 521 // layer is located. |
| 502 gfx::PointF position(25.f, 25.f); | 522 gfx::PointF position(25.f, 25.f); |
| 503 gfx::Size bounds(50, 50); | 523 gfx::Size bounds(50, 50); |
| 504 SetLayerPropertiesForTesting(clipping_layer.get(), | 524 SetLayerPropertiesForTesting(clipping_layer.get(), |
| 505 identity_matrix, | 525 identity_matrix, |
| 506 anchor, | 526 transform_origin, |
| 507 position, | 527 position, |
| 508 bounds, | 528 bounds, |
| 509 true, | 529 true, |
| 510 false); | 530 false); |
| 511 clipping_layer->SetMasksToBounds(true); | 531 clipping_layer->SetMasksToBounds(true); |
| 512 | 532 |
| 513 scoped_ptr<LayerImpl> child = | 533 scoped_ptr<LayerImpl> child = |
| 514 LayerImpl::Create(host_impl().active_tree(), 456); | 534 LayerImpl::Create(host_impl().active_tree(), 456); |
| 515 position = gfx::PointF(-50.f, -50.f); | 535 position = gfx::PointF(-50.f, -50.f); |
| 516 bounds = gfx::Size(300, 300); | 536 bounds = gfx::Size(300, 300); |
| 517 SetLayerPropertiesForTesting( | 537 SetLayerPropertiesForTesting(child.get(), |
| 518 child.get(), identity_matrix, anchor, position, bounds, true, false); | 538 identity_matrix, |
| 539 transform_origin, |
| 540 position, |
| 541 bounds, |
| 542 true, |
| 543 false); |
| 519 child->SetDrawsContent(true); | 544 child->SetDrawsContent(true); |
| 520 clipping_layer->AddChild(child.Pass()); | 545 clipping_layer->AddChild(child.Pass()); |
| 521 root->AddChild(clipping_layer.Pass()); | 546 root->AddChild(clipping_layer.Pass()); |
| 522 } | 547 } |
| 523 | 548 |
| 524 host_impl().SetViewportSize(root->bounds()); | 549 host_impl().SetViewportSize(root->bounds()); |
| 525 host_impl().active_tree()->SetRootLayer(root.Pass()); | 550 host_impl().active_tree()->SetRootLayer(root.Pass()); |
| 526 host_impl().active_tree()->UpdateDrawProperties(); | 551 host_impl().active_tree()->UpdateDrawProperties(); |
| 527 | 552 |
| 528 // Sanity check the scenario we just created. | 553 // Sanity check the scenario we just created. |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 567 // | 592 // |
| 568 // The child and grand_child layers are both initialized to clip the | 593 // The child and grand_child layers are both initialized to clip the |
| 569 // rotated_leaf. The child layer is rotated about the top-left corner, so that | 594 // rotated_leaf. The child layer is rotated about the top-left corner, so that |
| 570 // the root + child clips combined create a triangle. The rotated_leaf will | 595 // the root + child clips combined create a triangle. The rotated_leaf will |
| 571 // only be visible where it overlaps this triangle. | 596 // only be visible where it overlaps this triangle. |
| 572 // | 597 // |
| 573 scoped_ptr<LayerImpl> root = | 598 scoped_ptr<LayerImpl> root = |
| 574 LayerImpl::Create(host_impl().active_tree(), 123); | 599 LayerImpl::Create(host_impl().active_tree(), 123); |
| 575 | 600 |
| 576 gfx::Transform identity_matrix; | 601 gfx::Transform identity_matrix; |
| 577 gfx::PointF anchor; | 602 gfx::Point3F transform_origin; |
| 578 gfx::PointF position; | 603 gfx::PointF position; |
| 579 gfx::Size bounds(100, 100); | 604 gfx::Size bounds(100, 100); |
| 580 SetLayerPropertiesForTesting( | 605 SetLayerPropertiesForTesting(root.get(), |
| 581 root.get(), identity_matrix, anchor, position, bounds, true, false); | 606 identity_matrix, |
| 607 transform_origin, |
| 608 position, |
| 609 bounds, |
| 610 true, |
| 611 false); |
| 582 root->SetMasksToBounds(true); | 612 root->SetMasksToBounds(true); |
| 583 { | 613 { |
| 584 scoped_ptr<LayerImpl> child = | 614 scoped_ptr<LayerImpl> child = |
| 585 LayerImpl::Create(host_impl().active_tree(), 456); | 615 LayerImpl::Create(host_impl().active_tree(), 456); |
| 586 scoped_ptr<LayerImpl> grand_child = | 616 scoped_ptr<LayerImpl> grand_child = |
| 587 LayerImpl::Create(host_impl().active_tree(), 789); | 617 LayerImpl::Create(host_impl().active_tree(), 789); |
| 588 scoped_ptr<LayerImpl> rotated_leaf = | 618 scoped_ptr<LayerImpl> rotated_leaf = |
| 589 LayerImpl::Create(host_impl().active_tree(), 2468); | 619 LayerImpl::Create(host_impl().active_tree(), 2468); |
| 590 | 620 |
| 591 position = gfx::PointF(10.f, 10.f); | 621 position = gfx::PointF(10.f, 10.f); |
| 592 bounds = gfx::Size(80, 80); | 622 bounds = gfx::Size(80, 80); |
| 593 SetLayerPropertiesForTesting( | 623 SetLayerPropertiesForTesting(child.get(), |
| 594 child.get(), identity_matrix, anchor, position, bounds, true, false); | 624 identity_matrix, |
| 625 transform_origin, |
| 626 position, |
| 627 bounds, |
| 628 true, |
| 629 false); |
| 595 child->SetMasksToBounds(true); | 630 child->SetMasksToBounds(true); |
| 596 | 631 |
| 597 gfx::Transform rotation45_degrees_about_corner; | 632 gfx::Transform rotation45_degrees_about_corner; |
| 598 rotation45_degrees_about_corner.RotateAboutZAxis(45.0); | 633 rotation45_degrees_about_corner.RotateAboutZAxis(45.0); |
| 599 | 634 |
| 600 // remember, positioned with respect to its parent which is already at 10, | 635 // remember, positioned with respect to its parent which is already at 10, |
| 601 // 10 | 636 // 10 |
| 602 position = gfx::PointF(); | 637 position = gfx::PointF(); |
| 603 bounds = | 638 bounds = |
| 604 gfx::Size(200, 200); // to ensure it covers at least sqrt(2) * 100. | 639 gfx::Size(200, 200); // to ensure it covers at least sqrt(2) * 100. |
| 605 SetLayerPropertiesForTesting(grand_child.get(), | 640 SetLayerPropertiesForTesting(grand_child.get(), |
| 606 rotation45_degrees_about_corner, | 641 rotation45_degrees_about_corner, |
| 607 anchor, | 642 transform_origin, |
| 608 position, | 643 position, |
| 609 bounds, | 644 bounds, |
| 610 true, | 645 true, |
| 611 false); | 646 false); |
| 612 grand_child->SetMasksToBounds(true); | 647 grand_child->SetMasksToBounds(true); |
| 613 | 648 |
| 614 // Rotates about the center of the layer | 649 // Rotates about the center of the layer |
| 615 gfx::Transform rotated_leaf_transform; | 650 gfx::Transform rotated_leaf_transform; |
| 616 rotated_leaf_transform.Translate( | 651 rotated_leaf_transform.Translate( |
| 617 -10.0, -10.0); // cancel out the grand_parent's position | 652 -10.0, -10.0); // cancel out the grand_parent's position |
| 618 rotated_leaf_transform.RotateAboutZAxis( | 653 rotated_leaf_transform.RotateAboutZAxis( |
| 619 -45.0); // cancel out the corner 45-degree rotation of the parent. | 654 -45.0); // cancel out the corner 45-degree rotation of the parent. |
| 620 rotated_leaf_transform.Translate(50.0, 50.0); | 655 rotated_leaf_transform.Translate(50.0, 50.0); |
| 621 rotated_leaf_transform.RotateAboutZAxis(45.0); | 656 rotated_leaf_transform.RotateAboutZAxis(45.0); |
| 622 rotated_leaf_transform.Translate(-50.0, -50.0); | 657 rotated_leaf_transform.Translate(-50.0, -50.0); |
| 623 position = gfx::PointF(); | 658 position = gfx::PointF(); |
| 624 bounds = gfx::Size(100, 100); | 659 bounds = gfx::Size(100, 100); |
| 625 SetLayerPropertiesForTesting(rotated_leaf.get(), | 660 SetLayerPropertiesForTesting(rotated_leaf.get(), |
| 626 rotated_leaf_transform, | 661 rotated_leaf_transform, |
| 627 anchor, | 662 transform_origin, |
| 628 position, | 663 position, |
| 629 bounds, | 664 bounds, |
| 630 true, | 665 true, |
| 631 false); | 666 false); |
| 632 rotated_leaf->SetDrawsContent(true); | 667 rotated_leaf->SetDrawsContent(true); |
| 633 | 668 |
| 634 grand_child->AddChild(rotated_leaf.Pass()); | 669 grand_child->AddChild(rotated_leaf.Pass()); |
| 635 child->AddChild(grand_child.Pass()); | 670 child->AddChild(grand_child.Pass()); |
| 636 root->AddChild(child.Pass()); | 671 root->AddChild(child.Pass()); |
| 637 } | 672 } |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 705 result_layer = | 740 result_layer = |
| 706 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 741 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); |
| 707 ASSERT_TRUE(result_layer); | 742 ASSERT_TRUE(result_layer); |
| 708 EXPECT_EQ(2468, result_layer->id()); | 743 EXPECT_EQ(2468, result_layer->id()); |
| 709 } | 744 } |
| 710 | 745 |
| 711 TEST_F(LayerTreeImplTest, HitTestingForNonClippingIntermediateLayer) { | 746 TEST_F(LayerTreeImplTest, HitTestingForNonClippingIntermediateLayer) { |
| 712 // This test checks that hit testing code does not accidentally clip to layer | 747 // This test checks that hit testing code does not accidentally clip to layer |
| 713 // bounds for a layer that actually does not clip. | 748 // bounds for a layer that actually does not clip. |
| 714 gfx::Transform identity_matrix; | 749 gfx::Transform identity_matrix; |
| 715 gfx::PointF anchor; | 750 gfx::Point3F transform_origin; |
| 716 | 751 |
| 717 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); | 752 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); |
| 718 SetLayerPropertiesForTesting(root.get(), | 753 SetLayerPropertiesForTesting(root.get(), |
| 719 identity_matrix, | 754 identity_matrix, |
| 720 anchor, | 755 transform_origin, |
| 721 gfx::PointF(), | 756 gfx::PointF(), |
| 722 gfx::Size(100, 100), | 757 gfx::Size(100, 100), |
| 723 true, | 758 true, |
| 724 false); | 759 false); |
| 725 { | 760 { |
| 726 scoped_ptr<LayerImpl> intermediate_layer = | 761 scoped_ptr<LayerImpl> intermediate_layer = |
| 727 LayerImpl::Create(host_impl().active_tree(), 123); | 762 LayerImpl::Create(host_impl().active_tree(), 123); |
| 728 // this layer is positioned, and hit testing should correctly know where the | 763 // this layer is positioned, and hit testing should correctly know where the |
| 729 // layer is located. | 764 // layer is located. |
| 730 gfx::PointF position(10.f, 10.f); | 765 gfx::PointF position(10.f, 10.f); |
| 731 gfx::Size bounds(50, 50); | 766 gfx::Size bounds(50, 50); |
| 732 SetLayerPropertiesForTesting(intermediate_layer.get(), | 767 SetLayerPropertiesForTesting(intermediate_layer.get(), |
| 733 identity_matrix, | 768 identity_matrix, |
| 734 anchor, | 769 transform_origin, |
| 735 position, | 770 position, |
| 736 bounds, | 771 bounds, |
| 737 true, | 772 true, |
| 738 false); | 773 false); |
| 739 // Sanity check the intermediate layer should not clip. | 774 // Sanity check the intermediate layer should not clip. |
| 740 ASSERT_FALSE(intermediate_layer->masks_to_bounds()); | 775 ASSERT_FALSE(intermediate_layer->masks_to_bounds()); |
| 741 ASSERT_FALSE(intermediate_layer->mask_layer()); | 776 ASSERT_FALSE(intermediate_layer->mask_layer()); |
| 742 | 777 |
| 743 // The child of the intermediate_layer is translated so that it does not | 778 // The child of the intermediate_layer is translated so that it does not |
| 744 // overlap intermediate_layer at all. If child is incorrectly clipped, we | 779 // overlap intermediate_layer at all. If child is incorrectly clipped, we |
| 745 // would not be able to hit it successfully. | 780 // would not be able to hit it successfully. |
| 746 scoped_ptr<LayerImpl> child = | 781 scoped_ptr<LayerImpl> child = |
| 747 LayerImpl::Create(host_impl().active_tree(), 456); | 782 LayerImpl::Create(host_impl().active_tree(), 456); |
| 748 position = gfx::PointF(60.f, 60.f); // 70, 70 in screen space | 783 position = gfx::PointF(60.f, 60.f); // 70, 70 in screen space |
| 749 bounds = gfx::Size(20, 20); | 784 bounds = gfx::Size(20, 20); |
| 750 SetLayerPropertiesForTesting( | 785 SetLayerPropertiesForTesting(child.get(), |
| 751 child.get(), identity_matrix, anchor, position, bounds, true, false); | 786 identity_matrix, |
| 787 transform_origin, |
| 788 position, |
| 789 bounds, |
| 790 true, |
| 791 false); |
| 752 child->SetDrawsContent(true); | 792 child->SetDrawsContent(true); |
| 753 intermediate_layer->AddChild(child.Pass()); | 793 intermediate_layer->AddChild(child.Pass()); |
| 754 root->AddChild(intermediate_layer.Pass()); | 794 root->AddChild(intermediate_layer.Pass()); |
| 755 } | 795 } |
| 756 | 796 |
| 757 host_impl().SetViewportSize(root->bounds()); | 797 host_impl().SetViewportSize(root->bounds()); |
| 758 host_impl().active_tree()->SetRootLayer(root.Pass()); | 798 host_impl().active_tree()->SetRootLayer(root.Pass()); |
| 759 host_impl().active_tree()->UpdateDrawProperties(); | 799 host_impl().active_tree()->UpdateDrawProperties(); |
| 760 | 800 |
| 761 // Sanity check the scenario we just created. | 801 // Sanity check the scenario we just created. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 785 result_layer = | 825 result_layer = |
| 786 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 826 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); |
| 787 ASSERT_TRUE(result_layer); | 827 ASSERT_TRUE(result_layer); |
| 788 EXPECT_EQ(456, result_layer->id()); | 828 EXPECT_EQ(456, result_layer->id()); |
| 789 } | 829 } |
| 790 | 830 |
| 791 TEST_F(LayerTreeImplTest, HitTestingForMultipleLayers) { | 831 TEST_F(LayerTreeImplTest, HitTestingForMultipleLayers) { |
| 792 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); | 832 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); |
| 793 | 833 |
| 794 gfx::Transform identity_matrix; | 834 gfx::Transform identity_matrix; |
| 795 gfx::PointF anchor; | 835 gfx::Point3F transform_origin; |
| 796 gfx::PointF position; | 836 gfx::PointF position; |
| 797 gfx::Size bounds(100, 100); | 837 gfx::Size bounds(100, 100); |
| 798 SetLayerPropertiesForTesting( | 838 SetLayerPropertiesForTesting(root.get(), |
| 799 root.get(), identity_matrix, anchor, position, bounds, true, false); | 839 identity_matrix, |
| 840 transform_origin, |
| 841 position, |
| 842 bounds, |
| 843 true, |
| 844 false); |
| 800 root->SetDrawsContent(true); | 845 root->SetDrawsContent(true); |
| 801 { | 846 { |
| 802 // child 1 and child2 are initialized to overlap between x=50 and x=60. | 847 // child 1 and child2 are initialized to overlap between x=50 and x=60. |
| 803 // grand_child is set to overlap both child1 and child2 between y=50 and | 848 // grand_child is set to overlap both child1 and child2 between y=50 and |
| 804 // y=60. The expected stacking order is: (front) child2, (second) | 849 // y=60. The expected stacking order is: (front) child2, (second) |
| 805 // grand_child, (third) child1, and (back) the root layer behind all other | 850 // grand_child, (third) child1, and (back) the root layer behind all other |
| 806 // layers. | 851 // layers. |
| 807 | 852 |
| 808 scoped_ptr<LayerImpl> child1 = | 853 scoped_ptr<LayerImpl> child1 = |
| 809 LayerImpl::Create(host_impl().active_tree(), 2); | 854 LayerImpl::Create(host_impl().active_tree(), 2); |
| 810 scoped_ptr<LayerImpl> child2 = | 855 scoped_ptr<LayerImpl> child2 = |
| 811 LayerImpl::Create(host_impl().active_tree(), 3); | 856 LayerImpl::Create(host_impl().active_tree(), 3); |
| 812 scoped_ptr<LayerImpl> grand_child1 = | 857 scoped_ptr<LayerImpl> grand_child1 = |
| 813 LayerImpl::Create(host_impl().active_tree(), 4); | 858 LayerImpl::Create(host_impl().active_tree(), 4); |
| 814 | 859 |
| 815 position = gfx::PointF(10.f, 10.f); | 860 position = gfx::PointF(10.f, 10.f); |
| 816 bounds = gfx::Size(50, 50); | 861 bounds = gfx::Size(50, 50); |
| 817 SetLayerPropertiesForTesting( | 862 SetLayerPropertiesForTesting(child1.get(), |
| 818 child1.get(), identity_matrix, anchor, position, bounds, true, false); | 863 identity_matrix, |
| 864 transform_origin, |
| 865 position, |
| 866 bounds, |
| 867 true, |
| 868 false); |
| 819 child1->SetDrawsContent(true); | 869 child1->SetDrawsContent(true); |
| 820 | 870 |
| 821 position = gfx::PointF(50.f, 10.f); | 871 position = gfx::PointF(50.f, 10.f); |
| 822 bounds = gfx::Size(50, 50); | 872 bounds = gfx::Size(50, 50); |
| 823 SetLayerPropertiesForTesting( | 873 SetLayerPropertiesForTesting(child2.get(), |
| 824 child2.get(), identity_matrix, anchor, position, bounds, true, false); | 874 identity_matrix, |
| 875 transform_origin, |
| 876 position, |
| 877 bounds, |
| 878 true, |
| 879 false); |
| 825 child2->SetDrawsContent(true); | 880 child2->SetDrawsContent(true); |
| 826 | 881 |
| 827 // Remember that grand_child is positioned with respect to its parent (i.e. | 882 // Remember that grand_child is positioned with respect to its parent (i.e. |
| 828 // child1). In screen space, the intended position is (10, 50), with size | 883 // child1). In screen space, the intended position is (10, 50), with size |
| 829 // 100 x 50. | 884 // 100 x 50. |
| 830 position = gfx::PointF(0.f, 40.f); | 885 position = gfx::PointF(0.f, 40.f); |
| 831 bounds = gfx::Size(100, 50); | 886 bounds = gfx::Size(100, 50); |
| 832 SetLayerPropertiesForTesting(grand_child1.get(), | 887 SetLayerPropertiesForTesting(grand_child1.get(), |
| 833 identity_matrix, | 888 identity_matrix, |
| 834 anchor, | 889 transform_origin, |
| 835 position, | 890 position, |
| 836 bounds, | 891 bounds, |
| 837 true, | 892 true, |
| 838 false); | 893 false); |
| 839 grand_child1->SetDrawsContent(true); | 894 grand_child1->SetDrawsContent(true); |
| 840 | 895 |
| 841 child1->AddChild(grand_child1.Pass()); | 896 child1->AddChild(grand_child1.Pass()); |
| 842 root->AddChild(child1.Pass()); | 897 root->AddChild(child1.Pass()); |
| 843 root->AddChild(child2.Pass()); | 898 root->AddChild(child2.Pass()); |
| 844 } | 899 } |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 909 result_layer = | 964 result_layer = |
| 910 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 965 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); |
| 911 ASSERT_TRUE(result_layer); | 966 ASSERT_TRUE(result_layer); |
| 912 EXPECT_EQ(4, result_layer->id()); | 967 EXPECT_EQ(4, result_layer->id()); |
| 913 } | 968 } |
| 914 | 969 |
| 915 TEST_F(LayerTreeImplTest, HitTestingForMultipleLayersAtVaryingDepths) { | 970 TEST_F(LayerTreeImplTest, HitTestingForMultipleLayersAtVaryingDepths) { |
| 916 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); | 971 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); |
| 917 | 972 |
| 918 gfx::Transform identity_matrix; | 973 gfx::Transform identity_matrix; |
| 919 gfx::PointF anchor; | 974 gfx::Point3F transform_origin; |
| 920 gfx::PointF position; | 975 gfx::PointF position; |
| 921 gfx::Size bounds(100, 100); | 976 gfx::Size bounds(100, 100); |
| 922 SetLayerPropertiesForTesting( | 977 SetLayerPropertiesForTesting(root.get(), |
| 923 root.get(), identity_matrix, anchor, position, bounds, true, false); | 978 identity_matrix, |
| 979 transform_origin, |
| 980 position, |
| 981 bounds, |
| 982 true, |
| 983 false); |
| 924 root->SetDrawsContent(true); | 984 root->SetDrawsContent(true); |
| 925 root->SetShouldFlattenTransform(false); | 985 root->SetShouldFlattenTransform(false); |
| 926 root->SetIs3dSorted(true); | 986 root->SetIs3dSorted(true); |
| 927 { | 987 { |
| 928 // child 1 and child2 are initialized to overlap between x=50 and x=60. | 988 // child 1 and child2 are initialized to overlap between x=50 and x=60. |
| 929 // grand_child is set to overlap both child1 and child2 between y=50 and | 989 // grand_child is set to overlap both child1 and child2 between y=50 and |
| 930 // y=60. The expected stacking order is: (front) child2, (second) | 990 // y=60. The expected stacking order is: (front) child2, (second) |
| 931 // grand_child, (third) child1, and (back) the root layer behind all other | 991 // grand_child, (third) child1, and (back) the root layer behind all other |
| 932 // layers. | 992 // layers. |
| 933 | 993 |
| 934 scoped_ptr<LayerImpl> child1 = | 994 scoped_ptr<LayerImpl> child1 = |
| 935 LayerImpl::Create(host_impl().active_tree(), 2); | 995 LayerImpl::Create(host_impl().active_tree(), 2); |
| 936 scoped_ptr<LayerImpl> child2 = | 996 scoped_ptr<LayerImpl> child2 = |
| 937 LayerImpl::Create(host_impl().active_tree(), 3); | 997 LayerImpl::Create(host_impl().active_tree(), 3); |
| 938 scoped_ptr<LayerImpl> grand_child1 = | 998 scoped_ptr<LayerImpl> grand_child1 = |
| 939 LayerImpl::Create(host_impl().active_tree(), 4); | 999 LayerImpl::Create(host_impl().active_tree(), 4); |
| 940 | 1000 |
| 941 position = gfx::PointF(10.f, 10.f); | 1001 position = gfx::PointF(10.f, 10.f); |
| 942 bounds = gfx::Size(50, 50); | 1002 bounds = gfx::Size(50, 50); |
| 943 SetLayerPropertiesForTesting( | 1003 SetLayerPropertiesForTesting(child1.get(), |
| 944 child1.get(), identity_matrix, anchor, position, bounds, true, false); | 1004 identity_matrix, |
| 1005 transform_origin, |
| 1006 position, |
| 1007 bounds, |
| 1008 true, |
| 1009 false); |
| 945 child1->SetDrawsContent(true); | 1010 child1->SetDrawsContent(true); |
| 946 child1->SetShouldFlattenTransform(false); | 1011 child1->SetShouldFlattenTransform(false); |
| 947 child1->SetIs3dSorted(true); | 1012 child1->SetIs3dSorted(true); |
| 948 | 1013 |
| 949 position = gfx::PointF(50.f, 10.f); | 1014 position = gfx::PointF(50.f, 10.f); |
| 950 bounds = gfx::Size(50, 50); | 1015 bounds = gfx::Size(50, 50); |
| 951 gfx::Transform translate_z; | 1016 gfx::Transform translate_z; |
| 952 translate_z.Translate3d(0, 0, -10.f); | 1017 translate_z.Translate3d(0, 0, -10.f); |
| 953 SetLayerPropertiesForTesting( | 1018 SetLayerPropertiesForTesting(child2.get(), |
| 954 child2.get(), translate_z, anchor, position, bounds, true, false); | 1019 translate_z, |
| 1020 transform_origin, |
| 1021 position, |
| 1022 bounds, |
| 1023 true, |
| 1024 false); |
| 955 child2->SetDrawsContent(true); | 1025 child2->SetDrawsContent(true); |
| 956 child2->SetShouldFlattenTransform(false); | 1026 child2->SetShouldFlattenTransform(false); |
| 957 child2->SetIs3dSorted(true); | 1027 child2->SetIs3dSorted(true); |
| 958 | 1028 |
| 959 // Remember that grand_child is positioned with respect to its parent (i.e. | 1029 // Remember that grand_child is positioned with respect to its parent (i.e. |
| 960 // child1). In screen space, the intended position is (10, 50), with size | 1030 // child1). In screen space, the intended position is (10, 50), with size |
| 961 // 100 x 50. | 1031 // 100 x 50. |
| 962 position = gfx::PointF(0.f, 40.f); | 1032 position = gfx::PointF(0.f, 40.f); |
| 963 bounds = gfx::Size(100, 50); | 1033 bounds = gfx::Size(100, 50); |
| 964 SetLayerPropertiesForTesting(grand_child1.get(), | 1034 SetLayerPropertiesForTesting(grand_child1.get(), |
| 965 identity_matrix, | 1035 identity_matrix, |
| 966 anchor, | 1036 transform_origin, |
| 967 position, | 1037 position, |
| 968 bounds, | 1038 bounds, |
| 969 true, | 1039 true, |
| 970 false); | 1040 false); |
| 971 grand_child1->SetDrawsContent(true); | 1041 grand_child1->SetDrawsContent(true); |
| 972 grand_child1->SetShouldFlattenTransform(false); | 1042 grand_child1->SetShouldFlattenTransform(false); |
| 973 | 1043 |
| 974 child1->AddChild(grand_child1.Pass()); | 1044 child1->AddChild(grand_child1.Pass()); |
| 975 root->AddChild(child1.Pass()); | 1045 root->AddChild(child1.Pass()); |
| 976 root->AddChild(child2.Pass()); | 1046 root->AddChild(child2.Pass()); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1048 } | 1118 } |
| 1049 | 1119 |
| 1050 TEST_F(LayerTreeImplTest, HitTestingForMultipleLayerLists) { | 1120 TEST_F(LayerTreeImplTest, HitTestingForMultipleLayerLists) { |
| 1051 // | 1121 // |
| 1052 // The geometry is set up similarly to the previous case, but | 1122 // The geometry is set up similarly to the previous case, but |
| 1053 // all layers are forced to be render surfaces now. | 1123 // all layers are forced to be render surfaces now. |
| 1054 // | 1124 // |
| 1055 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); | 1125 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); |
| 1056 | 1126 |
| 1057 gfx::Transform identity_matrix; | 1127 gfx::Transform identity_matrix; |
| 1058 gfx::PointF anchor; | 1128 gfx::Point3F transform_origin; |
| 1059 gfx::PointF position; | 1129 gfx::PointF position; |
| 1060 gfx::Size bounds(100, 100); | 1130 gfx::Size bounds(100, 100); |
| 1061 SetLayerPropertiesForTesting( | 1131 SetLayerPropertiesForTesting(root.get(), |
| 1062 root.get(), identity_matrix, anchor, position, bounds, true, false); | 1132 identity_matrix, |
| 1133 transform_origin, |
| 1134 position, |
| 1135 bounds, |
| 1136 true, |
| 1137 false); |
| 1063 root->SetDrawsContent(true); | 1138 root->SetDrawsContent(true); |
| 1064 { | 1139 { |
| 1065 // child 1 and child2 are initialized to overlap between x=50 and x=60. | 1140 // child 1 and child2 are initialized to overlap between x=50 and x=60. |
| 1066 // grand_child is set to overlap both child1 and child2 between y=50 and | 1141 // grand_child is set to overlap both child1 and child2 between y=50 and |
| 1067 // y=60. The expected stacking order is: (front) child2, (second) | 1142 // y=60. The expected stacking order is: (front) child2, (second) |
| 1068 // grand_child, (third) child1, and (back) the root layer behind all other | 1143 // grand_child, (third) child1, and (back) the root layer behind all other |
| 1069 // layers. | 1144 // layers. |
| 1070 | 1145 |
| 1071 scoped_ptr<LayerImpl> child1 = | 1146 scoped_ptr<LayerImpl> child1 = |
| 1072 LayerImpl::Create(host_impl().active_tree(), 2); | 1147 LayerImpl::Create(host_impl().active_tree(), 2); |
| 1073 scoped_ptr<LayerImpl> child2 = | 1148 scoped_ptr<LayerImpl> child2 = |
| 1074 LayerImpl::Create(host_impl().active_tree(), 3); | 1149 LayerImpl::Create(host_impl().active_tree(), 3); |
| 1075 scoped_ptr<LayerImpl> grand_child1 = | 1150 scoped_ptr<LayerImpl> grand_child1 = |
| 1076 LayerImpl::Create(host_impl().active_tree(), 4); | 1151 LayerImpl::Create(host_impl().active_tree(), 4); |
| 1077 | 1152 |
| 1078 position = gfx::PointF(10.f, 10.f); | 1153 position = gfx::PointF(10.f, 10.f); |
| 1079 bounds = gfx::Size(50, 50); | 1154 bounds = gfx::Size(50, 50); |
| 1080 SetLayerPropertiesForTesting( | 1155 SetLayerPropertiesForTesting(child1.get(), |
| 1081 child1.get(), identity_matrix, anchor, position, bounds, true, false); | 1156 identity_matrix, |
| 1157 transform_origin, |
| 1158 position, |
| 1159 bounds, |
| 1160 true, |
| 1161 false); |
| 1082 child1->SetDrawsContent(true); | 1162 child1->SetDrawsContent(true); |
| 1083 child1->SetForceRenderSurface(true); | 1163 child1->SetForceRenderSurface(true); |
| 1084 | 1164 |
| 1085 position = gfx::PointF(50.f, 10.f); | 1165 position = gfx::PointF(50.f, 10.f); |
| 1086 bounds = gfx::Size(50, 50); | 1166 bounds = gfx::Size(50, 50); |
| 1087 SetLayerPropertiesForTesting( | 1167 SetLayerPropertiesForTesting(child2.get(), |
| 1088 child2.get(), identity_matrix, anchor, position, bounds, true, false); | 1168 identity_matrix, |
| 1169 transform_origin, |
| 1170 position, |
| 1171 bounds, |
| 1172 true, |
| 1173 false); |
| 1089 child2->SetDrawsContent(true); | 1174 child2->SetDrawsContent(true); |
| 1090 child2->SetForceRenderSurface(true); | 1175 child2->SetForceRenderSurface(true); |
| 1091 | 1176 |
| 1092 // Remember that grand_child is positioned with respect to its parent (i.e. | 1177 // Remember that grand_child is positioned with respect to its parent (i.e. |
| 1093 // child1). In screen space, the intended position is (10, 50), with size | 1178 // child1). In screen space, the intended position is (10, 50), with size |
| 1094 // 100 x 50. | 1179 // 100 x 50. |
| 1095 position = gfx::PointF(0.f, 40.f); | 1180 position = gfx::PointF(0.f, 40.f); |
| 1096 bounds = gfx::Size(100, 50); | 1181 bounds = gfx::Size(100, 50); |
| 1097 SetLayerPropertiesForTesting(grand_child1.get(), | 1182 SetLayerPropertiesForTesting(grand_child1.get(), |
| 1098 identity_matrix, | 1183 identity_matrix, |
| 1099 anchor, | 1184 transform_origin, |
| 1100 position, | 1185 position, |
| 1101 bounds, | 1186 bounds, |
| 1102 true, | 1187 true, |
| 1103 false); | 1188 false); |
| 1104 grand_child1->SetDrawsContent(true); | 1189 grand_child1->SetDrawsContent(true); |
| 1105 grand_child1->SetForceRenderSurface(true); | 1190 grand_child1->SetForceRenderSurface(true); |
| 1106 | 1191 |
| 1107 child1->AddChild(grand_child1.Pass()); | 1192 child1->AddChild(grand_child1.Pass()); |
| 1108 root->AddChild(child1.Pass()); | 1193 root->AddChild(child1.Pass()); |
| 1109 root->AddChild(child2.Pass()); | 1194 root->AddChild(child2.Pass()); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1184 ASSERT_TRUE(result_layer); | 1269 ASSERT_TRUE(result_layer); |
| 1185 EXPECT_EQ(4, result_layer->id()); | 1270 EXPECT_EQ(4, result_layer->id()); |
| 1186 } | 1271 } |
| 1187 | 1272 |
| 1188 TEST_F(LayerTreeImplTest, HitCheckingTouchHandlerRegionsForSingleLayer) { | 1273 TEST_F(LayerTreeImplTest, HitCheckingTouchHandlerRegionsForSingleLayer) { |
| 1189 scoped_ptr<LayerImpl> root = | 1274 scoped_ptr<LayerImpl> root = |
| 1190 LayerImpl::Create(host_impl().active_tree(), 12345); | 1275 LayerImpl::Create(host_impl().active_tree(), 12345); |
| 1191 | 1276 |
| 1192 gfx::Transform identity_matrix; | 1277 gfx::Transform identity_matrix; |
| 1193 Region touch_handler_region(gfx::Rect(10, 10, 50, 50)); | 1278 Region touch_handler_region(gfx::Rect(10, 10, 50, 50)); |
| 1194 gfx::PointF anchor; | 1279 gfx::Point3F transform_origin; |
| 1195 gfx::PointF position; | 1280 gfx::PointF position; |
| 1196 gfx::Size bounds(100, 100); | 1281 gfx::Size bounds(100, 100); |
| 1197 SetLayerPropertiesForTesting( | 1282 SetLayerPropertiesForTesting(root.get(), |
| 1198 root.get(), identity_matrix, anchor, position, bounds, true, false); | 1283 identity_matrix, |
| 1284 transform_origin, |
| 1285 position, |
| 1286 bounds, |
| 1287 true, |
| 1288 false); |
| 1199 root->SetDrawsContent(true); | 1289 root->SetDrawsContent(true); |
| 1200 | 1290 |
| 1201 host_impl().SetViewportSize(root->bounds()); | 1291 host_impl().SetViewportSize(root->bounds()); |
| 1202 host_impl().active_tree()->SetRootLayer(root.Pass()); | 1292 host_impl().active_tree()->SetRootLayer(root.Pass()); |
| 1203 host_impl().active_tree()->UpdateDrawProperties(); | 1293 host_impl().active_tree()->UpdateDrawProperties(); |
| 1204 | 1294 |
| 1205 // Sanity check the scenario we just created. | 1295 // Sanity check the scenario we just created. |
| 1206 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 1296 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); |
| 1207 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); | 1297 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); |
| 1208 | 1298 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1267 | 1357 |
| 1268 gfx::Transform uninvertible_transform; | 1358 gfx::Transform uninvertible_transform; |
| 1269 uninvertible_transform.matrix().set(0, 0, 0.0); | 1359 uninvertible_transform.matrix().set(0, 0, 0.0); |
| 1270 uninvertible_transform.matrix().set(1, 1, 0.0); | 1360 uninvertible_transform.matrix().set(1, 1, 0.0); |
| 1271 uninvertible_transform.matrix().set(2, 2, 0.0); | 1361 uninvertible_transform.matrix().set(2, 2, 0.0); |
| 1272 uninvertible_transform.matrix().set(3, 3, 0.0); | 1362 uninvertible_transform.matrix().set(3, 3, 0.0); |
| 1273 ASSERT_FALSE(uninvertible_transform.IsInvertible()); | 1363 ASSERT_FALSE(uninvertible_transform.IsInvertible()); |
| 1274 | 1364 |
| 1275 gfx::Transform identity_matrix; | 1365 gfx::Transform identity_matrix; |
| 1276 Region touch_handler_region(gfx::Rect(10, 10, 50, 50)); | 1366 Region touch_handler_region(gfx::Rect(10, 10, 50, 50)); |
| 1277 gfx::PointF anchor; | 1367 gfx::Point3F transform_origin; |
| 1278 gfx::PointF position; | 1368 gfx::PointF position; |
| 1279 gfx::Size bounds(100, 100); | 1369 gfx::Size bounds(100, 100); |
| 1280 SetLayerPropertiesForTesting(root.get(), | 1370 SetLayerPropertiesForTesting(root.get(), |
| 1281 uninvertible_transform, | 1371 uninvertible_transform, |
| 1282 anchor, | 1372 transform_origin, |
| 1283 position, | 1373 position, |
| 1284 bounds, | 1374 bounds, |
| 1285 true, | 1375 true, |
| 1286 false); | 1376 false); |
| 1287 root->SetDrawsContent(true); | 1377 root->SetDrawsContent(true); |
| 1288 root->SetTouchEventHandlerRegion(touch_handler_region); | 1378 root->SetTouchEventHandlerRegion(touch_handler_region); |
| 1289 | 1379 |
| 1290 host_impl().SetViewportSize(root->bounds()); | 1380 host_impl().SetViewportSize(root->bounds()); |
| 1291 host_impl().active_tree()->SetRootLayer(root.Pass()); | 1381 host_impl().active_tree()->SetRootLayer(root.Pass()); |
| 1292 host_impl().active_tree()->UpdateDrawProperties(); | 1382 host_impl().active_tree()->UpdateDrawProperties(); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1343 EXPECT_FALSE(result_layer); | 1433 EXPECT_FALSE(result_layer); |
| 1344 } | 1434 } |
| 1345 | 1435 |
| 1346 TEST_F(LayerTreeImplTest, | 1436 TEST_F(LayerTreeImplTest, |
| 1347 HitCheckingTouchHandlerRegionsForSinglePositionedLayer) { | 1437 HitCheckingTouchHandlerRegionsForSinglePositionedLayer) { |
| 1348 scoped_ptr<LayerImpl> root = | 1438 scoped_ptr<LayerImpl> root = |
| 1349 LayerImpl::Create(host_impl().active_tree(), 12345); | 1439 LayerImpl::Create(host_impl().active_tree(), 12345); |
| 1350 | 1440 |
| 1351 gfx::Transform identity_matrix; | 1441 gfx::Transform identity_matrix; |
| 1352 Region touch_handler_region(gfx::Rect(10, 10, 50, 50)); | 1442 Region touch_handler_region(gfx::Rect(10, 10, 50, 50)); |
| 1353 gfx::PointF anchor; | 1443 gfx::Point3F transform_origin; |
| 1354 // this layer is positioned, and hit testing should correctly know where the | 1444 // this layer is positioned, and hit testing should correctly know where the |
| 1355 // layer is located. | 1445 // layer is located. |
| 1356 gfx::PointF position(50.f, 50.f); | 1446 gfx::PointF position(50.f, 50.f); |
| 1357 gfx::Size bounds(100, 100); | 1447 gfx::Size bounds(100, 100); |
| 1358 SetLayerPropertiesForTesting( | 1448 SetLayerPropertiesForTesting(root.get(), |
| 1359 root.get(), identity_matrix, anchor, position, bounds, true, false); | 1449 identity_matrix, |
| 1450 transform_origin, |
| 1451 position, |
| 1452 bounds, |
| 1453 true, |
| 1454 false); |
| 1360 root->SetDrawsContent(true); | 1455 root->SetDrawsContent(true); |
| 1361 root->SetTouchEventHandlerRegion(touch_handler_region); | 1456 root->SetTouchEventHandlerRegion(touch_handler_region); |
| 1362 | 1457 |
| 1363 host_impl().SetViewportSize(root->bounds()); | 1458 host_impl().SetViewportSize(root->bounds()); |
| 1364 host_impl().active_tree()->SetRootLayer(root.Pass()); | 1459 host_impl().active_tree()->SetRootLayer(root.Pass()); |
| 1365 host_impl().active_tree()->UpdateDrawProperties(); | 1460 host_impl().active_tree()->UpdateDrawProperties(); |
| 1366 | 1461 |
| 1367 // Sanity check the scenario we just created. | 1462 // Sanity check the scenario we just created. |
| 1368 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 1463 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); |
| 1369 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); | 1464 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1417 // non-identity transform between layer's content space and layer's origin | 1512 // non-identity transform between layer's content space and layer's origin |
| 1418 // space. The hit testing code must take this into account. | 1513 // space. The hit testing code must take this into account. |
| 1419 // | 1514 // |
| 1420 // To test this, the layer is positioned at (25, 25), and is size (50, 50). If | 1515 // To test this, the layer is positioned at (25, 25), and is size (50, 50). If |
| 1421 // contents scale is ignored, then hit checking will mis-interpret the visible | 1516 // contents scale is ignored, then hit checking will mis-interpret the visible |
| 1422 // content rect as being larger than the actual bounds of the layer. | 1517 // content rect as being larger than the actual bounds of the layer. |
| 1423 // | 1518 // |
| 1424 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); | 1519 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); |
| 1425 | 1520 |
| 1426 gfx::Transform identity_matrix; | 1521 gfx::Transform identity_matrix; |
| 1427 gfx::PointF anchor; | 1522 gfx::Point3F transform_origin; |
| 1428 | 1523 |
| 1429 SetLayerPropertiesForTesting(root.get(), | 1524 SetLayerPropertiesForTesting(root.get(), |
| 1430 identity_matrix, | 1525 identity_matrix, |
| 1431 anchor, | 1526 transform_origin, |
| 1432 gfx::PointF(), | 1527 gfx::PointF(), |
| 1433 gfx::Size(100, 100), | 1528 gfx::Size(100, 100), |
| 1434 true, | 1529 true, |
| 1435 false); | 1530 false); |
| 1436 { | 1531 { |
| 1437 Region touch_handler_region(gfx::Rect(10, 10, 30, 30)); | 1532 Region touch_handler_region(gfx::Rect(10, 10, 30, 30)); |
| 1438 gfx::PointF position(25.f, 25.f); | 1533 gfx::PointF position(25.f, 25.f); |
| 1439 gfx::Size bounds(50, 50); | 1534 gfx::Size bounds(50, 50); |
| 1440 scoped_ptr<LayerImpl> test_layer = | 1535 scoped_ptr<LayerImpl> test_layer = |
| 1441 LayerImpl::Create(host_impl().active_tree(), 12345); | 1536 LayerImpl::Create(host_impl().active_tree(), 12345); |
| 1442 SetLayerPropertiesForTesting(test_layer.get(), | 1537 SetLayerPropertiesForTesting(test_layer.get(), |
| 1443 identity_matrix, | 1538 identity_matrix, |
| 1444 anchor, | 1539 transform_origin, |
| 1445 position, | 1540 position, |
| 1446 bounds, | 1541 bounds, |
| 1447 true, | 1542 true, |
| 1448 false); | 1543 false); |
| 1449 | 1544 |
| 1450 // override content bounds and contents scale | 1545 // override content bounds and contents scale |
| 1451 test_layer->SetContentBounds(gfx::Size(100, 100)); | 1546 test_layer->SetContentBounds(gfx::Size(100, 100)); |
| 1452 test_layer->SetContentsScale(2, 2); | 1547 test_layer->SetContentsScale(2, 2); |
| 1453 | 1548 |
| 1454 test_layer->SetDrawsContent(true); | 1549 test_layer->SetDrawsContent(true); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1521 } | 1616 } |
| 1522 | 1617 |
| 1523 TEST_F(LayerTreeImplTest, | 1618 TEST_F(LayerTreeImplTest, |
| 1524 HitCheckingTouchHandlerRegionsForSingleLayerWithDeviceScale) { | 1619 HitCheckingTouchHandlerRegionsForSingleLayerWithDeviceScale) { |
| 1525 // The layer's device_scale_factor and page_scale_factor should scale the | 1620 // The layer's device_scale_factor and page_scale_factor should scale the |
| 1526 // content rect and we should be able to hit the touch handler region by | 1621 // content rect and we should be able to hit the touch handler region by |
| 1527 // scaling the points accordingly. | 1622 // scaling the points accordingly. |
| 1528 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); | 1623 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); |
| 1529 | 1624 |
| 1530 gfx::Transform identity_matrix; | 1625 gfx::Transform identity_matrix; |
| 1531 gfx::PointF anchor; | 1626 gfx::Point3F transform_origin; |
| 1532 // Set the bounds of the root layer big enough to fit the child when scaled. | 1627 // Set the bounds of the root layer big enough to fit the child when scaled. |
| 1533 SetLayerPropertiesForTesting(root.get(), | 1628 SetLayerPropertiesForTesting(root.get(), |
| 1534 identity_matrix, | 1629 identity_matrix, |
| 1535 anchor, | 1630 transform_origin, |
| 1536 gfx::PointF(), | 1631 gfx::PointF(), |
| 1537 gfx::Size(100, 100), | 1632 gfx::Size(100, 100), |
| 1538 true, | 1633 true, |
| 1539 false); | 1634 false); |
| 1540 { | 1635 { |
| 1541 Region touch_handler_region(gfx::Rect(10, 10, 30, 30)); | 1636 Region touch_handler_region(gfx::Rect(10, 10, 30, 30)); |
| 1542 gfx::PointF position(25.f, 25.f); | 1637 gfx::PointF position(25.f, 25.f); |
| 1543 gfx::Size bounds(50, 50); | 1638 gfx::Size bounds(50, 50); |
| 1544 scoped_ptr<LayerImpl> test_layer = | 1639 scoped_ptr<LayerImpl> test_layer = |
| 1545 LayerImpl::Create(host_impl().active_tree(), 12345); | 1640 LayerImpl::Create(host_impl().active_tree(), 12345); |
| 1546 SetLayerPropertiesForTesting(test_layer.get(), | 1641 SetLayerPropertiesForTesting(test_layer.get(), |
| 1547 identity_matrix, | 1642 identity_matrix, |
| 1548 anchor, | 1643 transform_origin, |
| 1549 position, | 1644 position, |
| 1550 bounds, | 1645 bounds, |
| 1551 true, | 1646 true, |
| 1552 false); | 1647 false); |
| 1553 | 1648 |
| 1554 test_layer->SetDrawsContent(true); | 1649 test_layer->SetDrawsContent(true); |
| 1555 test_layer->SetTouchEventHandlerRegion(touch_handler_region); | 1650 test_layer->SetTouchEventHandlerRegion(touch_handler_region); |
| 1556 root->AddChild(test_layer.Pass()); | 1651 root->AddChild(test_layer.Pass()); |
| 1557 } | 1652 } |
| 1558 | 1653 |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1644 test_point); | 1739 test_point); |
| 1645 ASSERT_TRUE(result_layer); | 1740 ASSERT_TRUE(result_layer); |
| 1646 EXPECT_EQ(12345, result_layer->id()); | 1741 EXPECT_EQ(12345, result_layer->id()); |
| 1647 } | 1742 } |
| 1648 | 1743 |
| 1649 TEST_F(LayerTreeImplTest, HitCheckingTouchHandlerRegionsForSimpleClippedLayer) { | 1744 TEST_F(LayerTreeImplTest, HitCheckingTouchHandlerRegionsForSimpleClippedLayer) { |
| 1650 // Test that hit-checking will only work for the visible portion of a layer, | 1745 // Test that hit-checking will only work for the visible portion of a layer, |
| 1651 // and not the entire layer bounds. Here we just test the simple axis-aligned | 1746 // and not the entire layer bounds. Here we just test the simple axis-aligned |
| 1652 // case. | 1747 // case. |
| 1653 gfx::Transform identity_matrix; | 1748 gfx::Transform identity_matrix; |
| 1654 gfx::PointF anchor; | 1749 gfx::Point3F transform_origin; |
| 1655 | 1750 |
| 1656 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); | 1751 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); |
| 1657 SetLayerPropertiesForTesting(root.get(), | 1752 SetLayerPropertiesForTesting(root.get(), |
| 1658 identity_matrix, | 1753 identity_matrix, |
| 1659 anchor, | 1754 transform_origin, |
| 1660 gfx::PointF(), | 1755 gfx::PointF(), |
| 1661 gfx::Size(100, 100), | 1756 gfx::Size(100, 100), |
| 1662 true, | 1757 true, |
| 1663 false); | 1758 false); |
| 1664 { | 1759 { |
| 1665 scoped_ptr<LayerImpl> clipping_layer = | 1760 scoped_ptr<LayerImpl> clipping_layer = |
| 1666 LayerImpl::Create(host_impl().active_tree(), 123); | 1761 LayerImpl::Create(host_impl().active_tree(), 123); |
| 1667 // this layer is positioned, and hit testing should correctly know where the | 1762 // this layer is positioned, and hit testing should correctly know where the |
| 1668 // layer is located. | 1763 // layer is located. |
| 1669 gfx::PointF position(25.f, 25.f); | 1764 gfx::PointF position(25.f, 25.f); |
| 1670 gfx::Size bounds(50, 50); | 1765 gfx::Size bounds(50, 50); |
| 1671 SetLayerPropertiesForTesting(clipping_layer.get(), | 1766 SetLayerPropertiesForTesting(clipping_layer.get(), |
| 1672 identity_matrix, | 1767 identity_matrix, |
| 1673 anchor, | 1768 transform_origin, |
| 1674 position, | 1769 position, |
| 1675 bounds, | 1770 bounds, |
| 1676 true, | 1771 true, |
| 1677 false); | 1772 false); |
| 1678 clipping_layer->SetMasksToBounds(true); | 1773 clipping_layer->SetMasksToBounds(true); |
| 1679 | 1774 |
| 1680 scoped_ptr<LayerImpl> child = | 1775 scoped_ptr<LayerImpl> child = |
| 1681 LayerImpl::Create(host_impl().active_tree(), 456); | 1776 LayerImpl::Create(host_impl().active_tree(), 456); |
| 1682 Region touch_handler_region(gfx::Rect(10, 10, 50, 50)); | 1777 Region touch_handler_region(gfx::Rect(10, 10, 50, 50)); |
| 1683 position = gfx::PointF(-50.f, -50.f); | 1778 position = gfx::PointF(-50.f, -50.f); |
| 1684 bounds = gfx::Size(300, 300); | 1779 bounds = gfx::Size(300, 300); |
| 1685 SetLayerPropertiesForTesting( | 1780 SetLayerPropertiesForTesting(child.get(), |
| 1686 child.get(), identity_matrix, anchor, position, bounds, true, false); | 1781 identity_matrix, |
| 1782 transform_origin, |
| 1783 position, |
| 1784 bounds, |
| 1785 true, |
| 1786 false); |
| 1687 child->SetDrawsContent(true); | 1787 child->SetDrawsContent(true); |
| 1688 child->SetTouchEventHandlerRegion(touch_handler_region); | 1788 child->SetTouchEventHandlerRegion(touch_handler_region); |
| 1689 clipping_layer->AddChild(child.Pass()); | 1789 clipping_layer->AddChild(child.Pass()); |
| 1690 root->AddChild(clipping_layer.Pass()); | 1790 root->AddChild(clipping_layer.Pass()); |
| 1691 } | 1791 } |
| 1692 | 1792 |
| 1693 host_impl().SetViewportSize(root->bounds()); | 1793 host_impl().SetViewportSize(root->bounds()); |
| 1694 host_impl().active_tree()->SetRootLayer(root.Pass()); | 1794 host_impl().active_tree()->SetRootLayer(root.Pass()); |
| 1695 host_impl().active_tree()->UpdateDrawProperties(); | 1795 host_impl().active_tree()->UpdateDrawProperties(); |
| 1696 | 1796 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1734 test_point = gfx::Point(34, 34); | 1834 test_point = gfx::Point(34, 34); |
| 1735 result_layer = | 1835 result_layer = |
| 1736 host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 1836 host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( |
| 1737 test_point); | 1837 test_point); |
| 1738 ASSERT_TRUE(result_layer); | 1838 ASSERT_TRUE(result_layer); |
| 1739 EXPECT_EQ(456, result_layer->id()); | 1839 EXPECT_EQ(456, result_layer->id()); |
| 1740 } | 1840 } |
| 1741 | 1841 |
| 1742 TEST_F(LayerTreeImplTest, HitCheckingTouchHandlerOverlappingRegions) { | 1842 TEST_F(LayerTreeImplTest, HitCheckingTouchHandlerOverlappingRegions) { |
| 1743 gfx::Transform identity_matrix; | 1843 gfx::Transform identity_matrix; |
| 1744 gfx::PointF anchor; | 1844 gfx::Point3F transform_origin; |
| 1745 | 1845 |
| 1746 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); | 1846 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); |
| 1747 SetLayerPropertiesForTesting(root.get(), | 1847 SetLayerPropertiesForTesting(root.get(), |
| 1748 identity_matrix, | 1848 identity_matrix, |
| 1749 anchor, | 1849 transform_origin, |
| 1750 gfx::PointF(), | 1850 gfx::PointF(), |
| 1751 gfx::Size(100, 100), | 1851 gfx::Size(100, 100), |
| 1752 true, | 1852 true, |
| 1753 false); | 1853 false); |
| 1754 { | 1854 { |
| 1755 scoped_ptr<LayerImpl> touch_layer = | 1855 scoped_ptr<LayerImpl> touch_layer = |
| 1756 LayerImpl::Create(host_impl().active_tree(), 123); | 1856 LayerImpl::Create(host_impl().active_tree(), 123); |
| 1757 // this layer is positioned, and hit testing should correctly know where the | 1857 // this layer is positioned, and hit testing should correctly know where the |
| 1758 // layer is located. | 1858 // layer is located. |
| 1759 gfx::PointF position; | 1859 gfx::PointF position; |
| 1760 gfx::Size bounds(50, 50); | 1860 gfx::Size bounds(50, 50); |
| 1761 SetLayerPropertiesForTesting(touch_layer.get(), | 1861 SetLayerPropertiesForTesting(touch_layer.get(), |
| 1762 identity_matrix, | 1862 identity_matrix, |
| 1763 anchor, | 1863 transform_origin, |
| 1764 position, | 1864 position, |
| 1765 bounds, | 1865 bounds, |
| 1766 true, | 1866 true, |
| 1767 false); | 1867 false); |
| 1768 touch_layer->SetDrawsContent(true); | 1868 touch_layer->SetDrawsContent(true); |
| 1769 touch_layer->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 50, 50)); | 1869 touch_layer->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 50, 50)); |
| 1770 root->AddChild(touch_layer.Pass()); | 1870 root->AddChild(touch_layer.Pass()); |
| 1771 } | 1871 } |
| 1772 | 1872 |
| 1773 { | 1873 { |
| 1774 scoped_ptr<LayerImpl> notouch_layer = | 1874 scoped_ptr<LayerImpl> notouch_layer = |
| 1775 LayerImpl::Create(host_impl().active_tree(), 1234); | 1875 LayerImpl::Create(host_impl().active_tree(), 1234); |
| 1776 // this layer is positioned, and hit testing should correctly know where the | 1876 // this layer is positioned, and hit testing should correctly know where the |
| 1777 // layer is located. | 1877 // layer is located. |
| 1778 gfx::PointF position(0, 25); | 1878 gfx::PointF position(0, 25); |
| 1779 gfx::Size bounds(50, 50); | 1879 gfx::Size bounds(50, 50); |
| 1780 SetLayerPropertiesForTesting(notouch_layer.get(), | 1880 SetLayerPropertiesForTesting(notouch_layer.get(), |
| 1781 identity_matrix, | 1881 identity_matrix, |
| 1782 anchor, | 1882 transform_origin, |
| 1783 position, | 1883 position, |
| 1784 bounds, | 1884 bounds, |
| 1785 true, | 1885 true, |
| 1786 false); | 1886 false); |
| 1787 notouch_layer->SetDrawsContent(true); | 1887 notouch_layer->SetDrawsContent(true); |
| 1788 root->AddChild(notouch_layer.Pass()); | 1888 root->AddChild(notouch_layer.Pass()); |
| 1789 } | 1889 } |
| 1790 | 1890 |
| 1791 host_impl().SetViewportSize(root->bounds()); | 1891 host_impl().SetViewportSize(root->bounds()); |
| 1792 host_impl().active_tree()->SetRootLayer(root.Pass()); | 1892 host_impl().active_tree()->SetRootLayer(root.Pass()); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1827 | 1927 |
| 1828 test_point = gfx::Point(35, 65); | 1928 test_point = gfx::Point(35, 65); |
| 1829 result_layer = | 1929 result_layer = |
| 1830 host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 1930 host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( |
| 1831 test_point); | 1931 test_point); |
| 1832 EXPECT_FALSE(result_layer); | 1932 EXPECT_FALSE(result_layer); |
| 1833 } | 1933 } |
| 1834 | 1934 |
| 1835 } // namespace | 1935 } // namespace |
| 1836 } // namespace cc | 1936 } // namespace cc |
| OLD | NEW |