| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/trees/layer_tree_impl.h" | 5 #include "cc/trees/layer_tree_impl.h" |
| 6 | 6 |
| 7 #include "cc/layers/heads_up_display_layer_impl.h" | 7 #include "cc/layers/heads_up_display_layer_impl.h" |
| 8 #include "cc/layers/layer.h" | 8 #include "cc/layers/layer.h" |
| 9 #include "cc/layers/solid_color_scrollbar_layer_impl.h" | 9 #include "cc/layers/solid_color_scrollbar_layer_impl.h" |
| 10 #include "cc/test/fake_impl_task_runner_provider.h" | 10 #include "cc/test/fake_impl_task_runner_provider.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 settings.verify_clip_tree_calculations = true; | 29 settings.verify_clip_tree_calculations = true; |
| 30 host_impl_.reset(new FakeLayerTreeHostImpl(settings, &task_runner_provider_, | 30 host_impl_.reset(new FakeLayerTreeHostImpl(settings, &task_runner_provider_, |
| 31 &shared_bitmap_manager_, | 31 &shared_bitmap_manager_, |
| 32 &task_graph_runner_)); | 32 &task_graph_runner_)); |
| 33 host_impl_->SetVisible(true); | 33 host_impl_->SetVisible(true); |
| 34 EXPECT_TRUE(host_impl_->InitializeRenderer(output_surface_.get())); | 34 EXPECT_TRUE(host_impl_->InitializeRenderer(output_surface_.get())); |
| 35 } | 35 } |
| 36 | 36 |
| 37 FakeLayerTreeHostImpl& host_impl() { return *host_impl_; } | 37 FakeLayerTreeHostImpl& host_impl() { return *host_impl_; } |
| 38 | 38 |
| 39 LayerImpl* root_layer() { return host_impl_->active_tree()->root_layer(); } | 39 LayerImpl* root_layer() { |
| 40 return host_impl_->active_tree()->root_layer_for_testing(); |
| 41 } |
| 40 int HitTestSimpleTree(int root_id, | 42 int HitTestSimpleTree(int root_id, |
| 41 int left_child_id, | 43 int left_child_id, |
| 42 int right_child_id, | 44 int right_child_id, |
| 43 int root_sorting_context, | 45 int root_sorting_context, |
| 44 int left_child_sorting_context, | 46 int left_child_sorting_context, |
| 45 int right_child_sorting_context, | 47 int right_child_sorting_context, |
| 46 float root_depth, | 48 float root_depth, |
| 47 float left_child_depth, | 49 float left_child_depth, |
| 48 float right_child_depth); | 50 float right_child_depth); |
| 49 | 51 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 65 | 67 |
| 66 gfx::Transform identity_matrix; | 68 gfx::Transform identity_matrix; |
| 67 gfx::Point3F transform_origin; | 69 gfx::Point3F transform_origin; |
| 68 gfx::PointF position; | 70 gfx::PointF position; |
| 69 gfx::Size bounds(100, 100); | 71 gfx::Size bounds(100, 100); |
| 70 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, | 72 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, |
| 71 position, bounds, true, false, true); | 73 position, bounds, true, false, true); |
| 72 root->SetDrawsContent(true); | 74 root->SetDrawsContent(true); |
| 73 | 75 |
| 74 host_impl().SetViewportSize(root->bounds()); | 76 host_impl().SetViewportSize(root->bounds()); |
| 75 host_impl().active_tree()->SetRootLayer(std::move(root)); | 77 host_impl().active_tree()->SetRootLayerForTesting(std::move(root)); |
| 76 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 78 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
| 77 | 79 |
| 78 // Sanity check the scenario we just created. | 80 // Sanity check the scenario we just created. |
| 79 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 81 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); |
| 80 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); | 82 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); |
| 81 | 83 |
| 82 // Hit testing for a point outside the layer should return a null pointer. | 84 // Hit testing for a point outside the layer should return a null pointer. |
| 83 gfx::PointF test_point(101.f, 101.f); | 85 gfx::PointF test_point(101.f, 101.f); |
| 84 LayerImpl* result_layer = | 86 LayerImpl* result_layer = |
| 85 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 87 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 | 125 |
| 124 gfx::Transform identity_matrix; | 126 gfx::Transform identity_matrix; |
| 125 gfx::Point3F transform_origin; | 127 gfx::Point3F transform_origin; |
| 126 gfx::PointF position; | 128 gfx::PointF position; |
| 127 gfx::Size bounds(100, 100); | 129 gfx::Size bounds(100, 100); |
| 128 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, | 130 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, |
| 129 position, bounds, true, false, true); | 131 position, bounds, true, false, true); |
| 130 root->SetDrawsContent(true); | 132 root->SetDrawsContent(true); |
| 131 | 133 |
| 132 host_impl->SetViewportSize(root->bounds()); | 134 host_impl->SetViewportSize(root->bounds()); |
| 133 host_impl->active_tree()->SetRootLayer(std::move(root)); | 135 host_impl->active_tree()->SetRootLayerForTesting(std::move(root)); |
| 134 host_impl->UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 136 host_impl->UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
| 135 EXPECT_EQ( | 137 EXPECT_EQ( |
| 136 gfx::RectF(gfx::SizeF(bounds)), | 138 gfx::RectF(gfx::SizeF(bounds)), |
| 137 host_impl->active_tree()->property_trees()->clip_tree.ViewportClip()); | 139 host_impl->active_tree()->property_trees()->clip_tree.ViewportClip()); |
| 138 EXPECT_EQ(gfx::Rect(bounds), | 140 EXPECT_EQ( |
| 139 host_impl->active_tree()->root_layer()->visible_layer_rect()); | 141 gfx::Rect(bounds), |
| 142 host_impl->active_tree()->root_layer_for_testing()->visible_layer_rect()); |
| 140 | 143 |
| 141 gfx::Size new_bounds(50, 50); | 144 gfx::Size new_bounds(50, 50); |
| 142 host_impl->SetViewportSize(new_bounds); | 145 host_impl->SetViewportSize(new_bounds); |
| 143 gfx::PointF test_point(51.f, 51.f); | 146 gfx::PointF test_point(51.f, 51.f); |
| 144 host_impl->active_tree()->FindLayerThatIsHitByPoint(test_point); | 147 host_impl->active_tree()->FindLayerThatIsHitByPoint(test_point); |
| 145 EXPECT_EQ( | 148 EXPECT_EQ( |
| 146 gfx::RectF(gfx::SizeF(new_bounds)), | 149 gfx::RectF(gfx::SizeF(new_bounds)), |
| 147 host_impl->active_tree()->property_trees()->clip_tree.ViewportClip()); | 150 host_impl->active_tree()->property_trees()->clip_tree.ViewportClip()); |
| 148 EXPECT_EQ(gfx::Rect(new_bounds), | 151 EXPECT_EQ( |
| 149 host_impl->active_tree()->root_layer()->visible_layer_rect()); | 152 gfx::Rect(new_bounds), |
| 153 host_impl->active_tree()->root_layer_for_testing()->visible_layer_rect()); |
| 150 } | 154 } |
| 151 | 155 |
| 152 TEST_F(LayerTreeImplTest, HitTestingForSingleLayerAndHud) { | 156 TEST_F(LayerTreeImplTest, HitTestingForSingleLayerAndHud) { |
| 153 std::unique_ptr<LayerImpl> root = | 157 std::unique_ptr<LayerImpl> root = |
| 154 LayerImpl::Create(host_impl().active_tree(), 12345); | 158 LayerImpl::Create(host_impl().active_tree(), 12345); |
| 155 std::unique_ptr<HeadsUpDisplayLayerImpl> hud = | 159 std::unique_ptr<HeadsUpDisplayLayerImpl> hud = |
| 156 HeadsUpDisplayLayerImpl::Create(host_impl().active_tree(), 11111); | 160 HeadsUpDisplayLayerImpl::Create(host_impl().active_tree(), 11111); |
| 157 | 161 |
| 158 gfx::Transform identity_matrix; | 162 gfx::Transform identity_matrix; |
| 159 gfx::Point3F transform_origin; | 163 gfx::Point3F transform_origin; |
| 160 gfx::PointF position; | 164 gfx::PointF position; |
| 161 gfx::Size bounds(100, 100); | 165 gfx::Size bounds(100, 100); |
| 162 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, | 166 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, |
| 163 position, bounds, true, false, true); | 167 position, bounds, true, false, true); |
| 164 root->SetDrawsContent(true); | 168 root->SetDrawsContent(true); |
| 165 | 169 |
| 166 // Create hud and add it as a child of root. | 170 // Create hud and add it as a child of root. |
| 167 gfx::Size hud_bounds(200, 200); | 171 gfx::Size hud_bounds(200, 200); |
| 168 SetLayerPropertiesForTesting(hud.get(), identity_matrix, transform_origin, | 172 SetLayerPropertiesForTesting(hud.get(), identity_matrix, transform_origin, |
| 169 position, hud_bounds, true, false, false); | 173 position, hud_bounds, true, false, false); |
| 170 hud->SetDrawsContent(true); | 174 hud->SetDrawsContent(true); |
| 171 | 175 |
| 172 host_impl().active_tree()->set_hud_layer(hud.get()); | 176 host_impl().active_tree()->set_hud_layer(hud.get()); |
| 173 root->test_properties()->AddChild(std::move(hud)); | 177 root->test_properties()->AddChild(std::move(hud)); |
| 174 | 178 |
| 175 host_impl().SetViewportSize(hud_bounds); | 179 host_impl().SetViewportSize(hud_bounds); |
| 176 host_impl().active_tree()->SetRootLayer(std::move(root)); | 180 host_impl().active_tree()->SetRootLayerForTesting(std::move(root)); |
| 177 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 181 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
| 178 | 182 |
| 179 // Sanity check the scenario we just created. | 183 // Sanity check the scenario we just created. |
| 180 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 184 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); |
| 181 ASSERT_EQ(2u, root_layer()->render_surface()->layer_list().size()); | 185 ASSERT_EQ(2u, root_layer()->render_surface()->layer_list().size()); |
| 182 | 186 |
| 183 // Hit testing for a point inside HUD, but outside root should return null | 187 // Hit testing for a point inside HUD, but outside root should return null |
| 184 gfx::PointF test_point(101.f, 101.f); | 188 gfx::PointF test_point(101.f, 101.f); |
| 185 LayerImpl* result_layer = | 189 LayerImpl* result_layer = |
| 186 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 190 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 gfx::Transform identity_matrix; | 224 gfx::Transform identity_matrix; |
| 221 gfx::Point3F transform_origin; | 225 gfx::Point3F transform_origin; |
| 222 gfx::PointF position; | 226 gfx::PointF position; |
| 223 gfx::Size bounds(100, 100); | 227 gfx::Size bounds(100, 100); |
| 224 SetLayerPropertiesForTesting(root.get(), uninvertible_transform, | 228 SetLayerPropertiesForTesting(root.get(), uninvertible_transform, |
| 225 transform_origin, position, bounds, true, false, | 229 transform_origin, position, bounds, true, false, |
| 226 true); | 230 true); |
| 227 root->SetDrawsContent(true); | 231 root->SetDrawsContent(true); |
| 228 | 232 |
| 229 host_impl().SetViewportSize(root->bounds()); | 233 host_impl().SetViewportSize(root->bounds()); |
| 230 host_impl().active_tree()->SetRootLayer(std::move(root)); | 234 host_impl().active_tree()->SetRootLayerForTesting(std::move(root)); |
| 231 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 235 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
| 232 // Sanity check the scenario we just created. | 236 // Sanity check the scenario we just created. |
| 233 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 237 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); |
| 234 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); | 238 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); |
| 235 ASSERT_FALSE(root_layer()->ScreenSpaceTransform().IsInvertible()); | 239 ASSERT_FALSE(root_layer()->ScreenSpaceTransform().IsInvertible()); |
| 236 | 240 |
| 237 // Hit testing any point should not hit the layer. If the invertible matrix is | 241 // Hit testing any point should not hit the layer. If the invertible matrix is |
| 238 // accidentally ignored and treated like an identity, then the hit testing | 242 // accidentally ignored and treated like an identity, then the hit testing |
| 239 // will incorrectly hit the layer when it shouldn't. | 243 // will incorrectly hit the layer when it shouldn't. |
| 240 gfx::PointF test_point(1.f, 1.f); | 244 gfx::PointF test_point(1.f, 1.f); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 gfx::Point3F transform_origin; | 285 gfx::Point3F transform_origin; |
| 282 // this layer is positioned, and hit testing should correctly know where the | 286 // this layer is positioned, and hit testing should correctly know where the |
| 283 // layer is located. | 287 // layer is located. |
| 284 gfx::PointF position(50.f, 50.f); | 288 gfx::PointF position(50.f, 50.f); |
| 285 gfx::Size bounds(100, 100); | 289 gfx::Size bounds(100, 100); |
| 286 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, | 290 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, |
| 287 position, bounds, true, false, true); | 291 position, bounds, true, false, true); |
| 288 root->SetDrawsContent(true); | 292 root->SetDrawsContent(true); |
| 289 | 293 |
| 290 host_impl().SetViewportSize(root->bounds()); | 294 host_impl().SetViewportSize(root->bounds()); |
| 291 host_impl().active_tree()->SetRootLayer(std::move(root)); | 295 host_impl().active_tree()->SetRootLayerForTesting(std::move(root)); |
| 292 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 296 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
| 293 | 297 |
| 294 // Sanity check the scenario we just created. | 298 // Sanity check the scenario we just created. |
| 295 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 299 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); |
| 296 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); | 300 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); |
| 297 | 301 |
| 298 // Hit testing for a point outside the layer should return a null pointer. | 302 // Hit testing for a point outside the layer should return a null pointer. |
| 299 gfx::PointF test_point(49.f, 49.f); | 303 gfx::PointF test_point(49.f, 49.f); |
| 300 LayerImpl* result_layer = | 304 LayerImpl* result_layer = |
| 301 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 305 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 rotation45_degrees_about_center.Translate(-50.0, -50.0); | 337 rotation45_degrees_about_center.Translate(-50.0, -50.0); |
| 334 gfx::Point3F transform_origin; | 338 gfx::Point3F transform_origin; |
| 335 gfx::PointF position; | 339 gfx::PointF position; |
| 336 gfx::Size bounds(100, 100); | 340 gfx::Size bounds(100, 100); |
| 337 SetLayerPropertiesForTesting(root.get(), rotation45_degrees_about_center, | 341 SetLayerPropertiesForTesting(root.get(), rotation45_degrees_about_center, |
| 338 transform_origin, position, bounds, true, false, | 342 transform_origin, position, bounds, true, false, |
| 339 true); | 343 true); |
| 340 root->SetDrawsContent(true); | 344 root->SetDrawsContent(true); |
| 341 | 345 |
| 342 host_impl().SetViewportSize(root->bounds()); | 346 host_impl().SetViewportSize(root->bounds()); |
| 343 host_impl().active_tree()->SetRootLayer(std::move(root)); | 347 host_impl().active_tree()->SetRootLayerForTesting(std::move(root)); |
| 344 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 348 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
| 345 | 349 |
| 346 // Sanity check the scenario we just created. | 350 // Sanity check the scenario we just created. |
| 347 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 351 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); |
| 348 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); | 352 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); |
| 349 | 353 |
| 350 // Hit testing for points outside the layer. | 354 // Hit testing for points outside the layer. |
| 351 // These corners would have been inside the un-transformed layer, but they | 355 // These corners would have been inside the un-transformed layer, but they |
| 352 // should not hit the correctly transformed layer. | 356 // should not hit the correctly transformed layer. |
| 353 gfx::PointF test_point(99.f, 99.f); | 357 gfx::PointF test_point(99.f, 99.f); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 gfx::PointF(), gfx::Size(100, 100), true, false, | 422 gfx::PointF(), gfx::Size(100, 100), true, false, |
| 419 false); | 423 false); |
| 420 test->SetDrawsContent(true); | 424 test->SetDrawsContent(true); |
| 421 | 425 |
| 422 clip->test_properties()->AddChild(std::move(test)); | 426 clip->test_properties()->AddChild(std::move(test)); |
| 423 scale->test_properties()->AddChild(std::move(clip)); | 427 scale->test_properties()->AddChild(std::move(clip)); |
| 424 render_surface->test_properties()->AddChild(std::move(scale)); | 428 render_surface->test_properties()->AddChild(std::move(scale)); |
| 425 root->test_properties()->AddChild(std::move(render_surface)); | 429 root->test_properties()->AddChild(std::move(render_surface)); |
| 426 | 430 |
| 427 host_impl().SetViewportSize(root->bounds()); | 431 host_impl().SetViewportSize(root->bounds()); |
| 428 host_impl().active_tree()->SetRootLayer(std::move(root)); | 432 host_impl().active_tree()->SetRootLayerForTesting(std::move(root)); |
| 429 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 433 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
| 430 | 434 |
| 431 gfx::PointF test_point(160.f, 160.f); | 435 gfx::PointF test_point(160.f, 160.f); |
| 432 LayerImpl* result_layer = | 436 LayerImpl* result_layer = |
| 433 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 437 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); |
| 434 EXPECT_FALSE(result_layer); | 438 EXPECT_FALSE(result_layer); |
| 435 | 439 |
| 436 test_point = gfx::PointF(140.f, 140.f); | 440 test_point = gfx::PointF(140.f, 140.f); |
| 437 result_layer = | 441 result_layer = |
| 438 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 442 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 463 LayerImpl::Create(host_impl().active_tree(), 3); | 467 LayerImpl::Create(host_impl().active_tree(), 3); |
| 464 SetLayerPropertiesForTesting(child2.get(), identity_matrix, gfx::Point3F(), | 468 SetLayerPropertiesForTesting(child2.get(), identity_matrix, gfx::Point3F(), |
| 465 gfx::PointF(), gfx::Size(75, 75), true, false, | 469 gfx::PointF(), gfx::Size(75, 75), true, false, |
| 466 false); | 470 false); |
| 467 child2->SetMasksToBounds(true); | 471 child2->SetMasksToBounds(true); |
| 468 child2->SetDrawsContent(true); | 472 child2->SetDrawsContent(true); |
| 469 root->test_properties()->AddChild(std::move(child1)); | 473 root->test_properties()->AddChild(std::move(child1)); |
| 470 root->test_properties()->AddChild(std::move(child2)); | 474 root->test_properties()->AddChild(std::move(child2)); |
| 471 | 475 |
| 472 host_impl().SetViewportSize(root->bounds()); | 476 host_impl().SetViewportSize(root->bounds()); |
| 473 host_impl().active_tree()->SetRootLayer(std::move(root)); | 477 host_impl().active_tree()->SetRootLayerForTesting(std::move(root)); |
| 474 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 478 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
| 475 | 479 |
| 476 gfx::PointF test_point(50.f, 50.f); | 480 gfx::PointF test_point(50.f, 50.f); |
| 477 LayerImpl* result_layer = | 481 LayerImpl* result_layer = |
| 478 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 482 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); |
| 479 ASSERT_TRUE(result_layer); | 483 ASSERT_TRUE(result_layer); |
| 480 EXPECT_EQ(3, result_layer->id()); | 484 EXPECT_EQ(3, result_layer->id()); |
| 481 } | 485 } |
| 482 | 486 |
| 483 TEST_F(LayerTreeImplTest, HitTestingPointOutsideMaxTextureSize) { | 487 TEST_F(LayerTreeImplTest, HitTestingPointOutsideMaxTextureSize) { |
| 484 gfx::Transform identity_matrix; | 488 gfx::Transform identity_matrix; |
| 485 int max_texture_size = | 489 int max_texture_size = |
| 486 host_impl().active_tree()->resource_provider()->max_texture_size(); | 490 host_impl().active_tree()->resource_provider()->max_texture_size(); |
| 487 gfx::Size bounds(max_texture_size + 100, max_texture_size + 100); | 491 gfx::Size bounds(max_texture_size + 100, max_texture_size + 100); |
| 488 | 492 |
| 489 std::unique_ptr<LayerImpl> root = | 493 std::unique_ptr<LayerImpl> root = |
| 490 LayerImpl::Create(host_impl().active_tree(), 1); | 494 LayerImpl::Create(host_impl().active_tree(), 1); |
| 491 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), | 495 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), |
| 492 gfx::PointF(), bounds, true, false, true); | 496 gfx::PointF(), bounds, true, false, true); |
| 493 | 497 |
| 494 std::unique_ptr<LayerImpl> surface = | 498 std::unique_ptr<LayerImpl> surface = |
| 495 LayerImpl::Create(host_impl().active_tree(), 2); | 499 LayerImpl::Create(host_impl().active_tree(), 2); |
| 496 SetLayerPropertiesForTesting(surface.get(), identity_matrix, gfx::Point3F(), | 500 SetLayerPropertiesForTesting(surface.get(), identity_matrix, gfx::Point3F(), |
| 497 gfx::PointF(), bounds, true, false, true); | 501 gfx::PointF(), bounds, true, false, true); |
| 498 surface->SetMasksToBounds(true); | 502 surface->SetMasksToBounds(true); |
| 499 surface->SetDrawsContent(true); | 503 surface->SetDrawsContent(true); |
| 500 | 504 |
| 501 root->test_properties()->AddChild(std::move(surface)); | 505 root->test_properties()->AddChild(std::move(surface)); |
| 502 host_impl().SetViewportSize(root->bounds()); | 506 host_impl().SetViewportSize(root->bounds()); |
| 503 host_impl().active_tree()->SetRootLayer(std::move(root)); | 507 host_impl().active_tree()->SetRootLayerForTesting(std::move(root)); |
| 504 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 508 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
| 505 | 509 |
| 506 gfx::PointF test_point(max_texture_size - 50, max_texture_size - 50); | 510 gfx::PointF test_point(max_texture_size - 50, max_texture_size - 50); |
| 507 LayerImpl* result_layer = | 511 LayerImpl* result_layer = |
| 508 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 512 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); |
| 509 EXPECT_TRUE(result_layer); | 513 EXPECT_TRUE(result_layer); |
| 510 | 514 |
| 511 test_point = gfx::PointF(max_texture_size + 50, max_texture_size + 50); | 515 test_point = gfx::PointF(max_texture_size + 50, max_texture_size + 50); |
| 512 result_layer = | 516 result_layer = |
| 513 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 517 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 531 | 535 |
| 532 gfx::Point3F transform_origin; | 536 gfx::Point3F transform_origin; |
| 533 gfx::PointF position; | 537 gfx::PointF position; |
| 534 gfx::Size bounds(100, 100); | 538 gfx::Size bounds(100, 100); |
| 535 SetLayerPropertiesForTesting( | 539 SetLayerPropertiesForTesting( |
| 536 root.get(), perspective_projection_about_center * translation_by_z, | 540 root.get(), perspective_projection_about_center * translation_by_z, |
| 537 transform_origin, position, bounds, true, false, true); | 541 transform_origin, position, bounds, true, false, true); |
| 538 root->SetDrawsContent(true); | 542 root->SetDrawsContent(true); |
| 539 | 543 |
| 540 host_impl().SetViewportSize(root->bounds()); | 544 host_impl().SetViewportSize(root->bounds()); |
| 541 host_impl().active_tree()->SetRootLayer(std::move(root)); | 545 host_impl().active_tree()->SetRootLayerForTesting(std::move(root)); |
| 542 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 546 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
| 543 | 547 |
| 544 // Sanity check the scenario we just created. | 548 // Sanity check the scenario we just created. |
| 545 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 549 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); |
| 546 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); | 550 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); |
| 547 | 551 |
| 548 // Hit testing for points outside the layer. | 552 // Hit testing for points outside the layer. |
| 549 // These corners would have been inside the un-transformed layer, but they | 553 // These corners would have been inside the un-transformed layer, but they |
| 550 // should not hit the correctly transformed layer. | 554 // should not hit the correctly transformed layer. |
| 551 gfx::PointF test_point(24.f, 24.f); | 555 gfx::PointF test_point(24.f, 24.f); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 601 position = gfx::PointF(-50.f, -50.f); | 605 position = gfx::PointF(-50.f, -50.f); |
| 602 bounds = gfx::Size(300, 300); | 606 bounds = gfx::Size(300, 300); |
| 603 SetLayerPropertiesForTesting(child.get(), identity_matrix, transform_origin, | 607 SetLayerPropertiesForTesting(child.get(), identity_matrix, transform_origin, |
| 604 position, bounds, true, false, false); | 608 position, bounds, true, false, false); |
| 605 child->SetDrawsContent(true); | 609 child->SetDrawsContent(true); |
| 606 clipping_layer->test_properties()->AddChild(std::move(child)); | 610 clipping_layer->test_properties()->AddChild(std::move(child)); |
| 607 root->test_properties()->AddChild(std::move(clipping_layer)); | 611 root->test_properties()->AddChild(std::move(clipping_layer)); |
| 608 } | 612 } |
| 609 | 613 |
| 610 host_impl().SetViewportSize(root->bounds()); | 614 host_impl().SetViewportSize(root->bounds()); |
| 611 host_impl().active_tree()->SetRootLayer(std::move(root)); | 615 host_impl().active_tree()->SetRootLayerForTesting(std::move(root)); |
| 612 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 616 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
| 613 | 617 |
| 614 // Sanity check the scenario we just created. | 618 // Sanity check the scenario we just created. |
| 615 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 619 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); |
| 616 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); | 620 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); |
| 617 ASSERT_EQ(456, root_layer()->render_surface()->layer_list().at(0)->id()); | 621 ASSERT_EQ(456, root_layer()->render_surface()->layer_list().at(0)->id()); |
| 618 | 622 |
| 619 // Hit testing for a point outside the layer should return a null pointer. | 623 // Hit testing for a point outside the layer should return a null pointer. |
| 620 // Despite the child layer being very large, it should be clipped to the root | 624 // Despite the child layer being very large, it should be clipped to the root |
| 621 // layer's bounds. | 625 // layer's bounds. |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 706 position = gfx::PointF(); | 710 position = gfx::PointF(); |
| 707 bounds = gfx::Size(100, 100); | 711 bounds = gfx::Size(100, 100); |
| 708 SetLayerPropertiesForTesting(rotated_leaf.get(), rotated_leaf_transform, | 712 SetLayerPropertiesForTesting(rotated_leaf.get(), rotated_leaf_transform, |
| 709 transform_origin, position, bounds, true, | 713 transform_origin, position, bounds, true, |
| 710 false, false); | 714 false, false); |
| 711 rotated_leaf->SetDrawsContent(true); | 715 rotated_leaf->SetDrawsContent(true); |
| 712 | 716 |
| 713 grand_child->test_properties()->AddChild(std::move(rotated_leaf)); | 717 grand_child->test_properties()->AddChild(std::move(rotated_leaf)); |
| 714 child->test_properties()->AddChild(std::move(grand_child)); | 718 child->test_properties()->AddChild(std::move(grand_child)); |
| 715 root->test_properties()->AddChild(std::move(child)); | 719 root->test_properties()->AddChild(std::move(child)); |
| 716 host_impl().active_tree()->SetRootLayer(std::move(root)); | 720 host_impl().active_tree()->SetRootLayerForTesting(std::move(root)); |
| 717 | 721 |
| 718 ExecuteCalculateDrawProperties(root_layer); | 722 ExecuteCalculateDrawProperties(root_layer); |
| 719 } | 723 } |
| 720 | 724 |
| 721 host_impl().SetViewportSize(root_layer->bounds()); | 725 host_impl().SetViewportSize(root_layer->bounds()); |
| 722 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 726 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
| 723 // (11, 89) is close to the the bottom left corner within the clip, but it is | 727 // (11, 89) is close to the the bottom left corner within the clip, but it is |
| 724 // not inside the layer. | 728 // not inside the layer. |
| 725 gfx::PointF test_point(11.f, 89.f); | 729 gfx::PointF test_point(11.f, 89.f); |
| 726 LayerImpl* result_layer = | 730 LayerImpl* result_layer = |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 800 position = gfx::PointF(60.f, 60.f); // 70, 70 in screen space | 804 position = gfx::PointF(60.f, 60.f); // 70, 70 in screen space |
| 801 bounds = gfx::Size(20, 20); | 805 bounds = gfx::Size(20, 20); |
| 802 SetLayerPropertiesForTesting(child.get(), identity_matrix, transform_origin, | 806 SetLayerPropertiesForTesting(child.get(), identity_matrix, transform_origin, |
| 803 position, bounds, true, false, false); | 807 position, bounds, true, false, false); |
| 804 child->SetDrawsContent(true); | 808 child->SetDrawsContent(true); |
| 805 intermediate_layer->test_properties()->AddChild(std::move(child)); | 809 intermediate_layer->test_properties()->AddChild(std::move(child)); |
| 806 root->test_properties()->AddChild(std::move(intermediate_layer)); | 810 root->test_properties()->AddChild(std::move(intermediate_layer)); |
| 807 } | 811 } |
| 808 | 812 |
| 809 host_impl().SetViewportSize(root->bounds()); | 813 host_impl().SetViewportSize(root->bounds()); |
| 810 host_impl().active_tree()->SetRootLayer(std::move(root)); | 814 host_impl().active_tree()->SetRootLayerForTesting(std::move(root)); |
| 811 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 815 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
| 812 | 816 |
| 813 // Sanity check the scenario we just created. | 817 // Sanity check the scenario we just created. |
| 814 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 818 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); |
| 815 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); | 819 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); |
| 816 ASSERT_EQ(456, root_layer()->render_surface()->layer_list().at(0)->id()); | 820 ASSERT_EQ(456, root_layer()->render_surface()->layer_list().at(0)->id()); |
| 817 | 821 |
| 818 // Hit testing for a point outside the layer should return a null pointer. | 822 // Hit testing for a point outside the layer should return a null pointer. |
| 819 gfx::PointF test_point(69.f, 69.f); | 823 gfx::PointF test_point(69.f, 69.f); |
| 820 LayerImpl* result_layer = | 824 LayerImpl* result_layer = |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 886 position = gfx::PointF(0.f, 40.f); | 890 position = gfx::PointF(0.f, 40.f); |
| 887 bounds = gfx::Size(100, 50); | 891 bounds = gfx::Size(100, 50); |
| 888 SetLayerPropertiesForTesting(grand_child1.get(), identity_matrix, | 892 SetLayerPropertiesForTesting(grand_child1.get(), identity_matrix, |
| 889 transform_origin, position, bounds, true, | 893 transform_origin, position, bounds, true, |
| 890 false, false); | 894 false, false); |
| 891 grand_child1->SetDrawsContent(true); | 895 grand_child1->SetDrawsContent(true); |
| 892 | 896 |
| 893 child1->test_properties()->AddChild(std::move(grand_child1)); | 897 child1->test_properties()->AddChild(std::move(grand_child1)); |
| 894 root->test_properties()->AddChild(std::move(child1)); | 898 root->test_properties()->AddChild(std::move(child1)); |
| 895 root->test_properties()->AddChild(std::move(child2)); | 899 root->test_properties()->AddChild(std::move(child2)); |
| 896 host_impl().active_tree()->SetRootLayer(std::move(root)); | 900 host_impl().active_tree()->SetRootLayerForTesting(std::move(root)); |
| 897 | 901 |
| 898 ExecuteCalculateDrawProperties(root_layer); | 902 ExecuteCalculateDrawProperties(root_layer); |
| 899 } | 903 } |
| 900 | 904 |
| 901 LayerImpl* child1 = root_layer->test_properties()->children[0]; | 905 LayerImpl* child1 = root_layer->test_properties()->children[0]; |
| 902 LayerImpl* child2 = root_layer->test_properties()->children[1]; | 906 LayerImpl* child2 = root_layer->test_properties()->children[1]; |
| 903 LayerImpl* grand_child1 = child1->test_properties()->children[0]; | 907 LayerImpl* grand_child1 = child1->test_properties()->children[0]; |
| 904 | 908 |
| 905 host_impl().SetViewportSize(root_layer->bounds()); | 909 host_impl().SetViewportSize(root_layer->bounds()); |
| 906 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 910 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1009 transform_origin, position, bounds, false, | 1013 transform_origin, position, bounds, false, |
| 1010 false, false); | 1014 false, false); |
| 1011 right_child->SetDrawsContent(true); | 1015 right_child->SetDrawsContent(true); |
| 1012 right_child->Set3dSortingContextId(right_child_sorting_context); | 1016 right_child->Set3dSortingContextId(right_child_sorting_context); |
| 1013 } | 1017 } |
| 1014 | 1018 |
| 1015 root->test_properties()->AddChild(std::move(left_child)); | 1019 root->test_properties()->AddChild(std::move(left_child)); |
| 1016 root->test_properties()->AddChild(std::move(right_child)); | 1020 root->test_properties()->AddChild(std::move(right_child)); |
| 1017 | 1021 |
| 1018 host_impl().SetViewportSize(root->bounds()); | 1022 host_impl().SetViewportSize(root->bounds()); |
| 1019 host_impl().active_tree()->SetRootLayer(std::move(root)); | 1023 host_impl().active_tree()->SetRootLayerForTesting(std::move(root)); |
| 1020 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 1024 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
| 1021 CHECK_EQ(1u, RenderSurfaceLayerList().size()); | 1025 CHECK_EQ(1u, RenderSurfaceLayerList().size()); |
| 1022 | 1026 |
| 1023 gfx::PointF test_point = gfx::PointF(1.f, 1.f); | 1027 gfx::PointF test_point = gfx::PointF(1.f, 1.f); |
| 1024 LayerImpl* result_layer = | 1028 LayerImpl* result_layer = |
| 1025 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 1029 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); |
| 1026 | 1030 |
| 1027 CHECK(result_layer); | 1031 CHECK(result_layer); |
| 1028 return result_layer->id(); | 1032 return result_layer->id(); |
| 1029 } | 1033 } |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1124 child1->test_properties()->AddChild(std::move(grand_child1)); | 1128 child1->test_properties()->AddChild(std::move(grand_child1)); |
| 1125 root->test_properties()->AddChild(std::move(child1)); | 1129 root->test_properties()->AddChild(std::move(child1)); |
| 1126 root->test_properties()->AddChild(std::move(child2)); | 1130 root->test_properties()->AddChild(std::move(child2)); |
| 1127 } | 1131 } |
| 1128 | 1132 |
| 1129 LayerImpl* child1 = root->test_properties()->children[0]; | 1133 LayerImpl* child1 = root->test_properties()->children[0]; |
| 1130 LayerImpl* child2 = root->test_properties()->children[1]; | 1134 LayerImpl* child2 = root->test_properties()->children[1]; |
| 1131 LayerImpl* grand_child1 = child1->test_properties()->children[0]; | 1135 LayerImpl* grand_child1 = child1->test_properties()->children[0]; |
| 1132 | 1136 |
| 1133 host_impl().SetViewportSize(root->bounds()); | 1137 host_impl().SetViewportSize(root->bounds()); |
| 1134 host_impl().active_tree()->SetRootLayer(std::move(root)); | 1138 host_impl().active_tree()->SetRootLayerForTesting(std::move(root)); |
| 1135 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 1139 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
| 1136 | 1140 |
| 1137 // Sanity check the scenario we just created. | 1141 // Sanity check the scenario we just created. |
| 1138 ASSERT_TRUE(child1); | 1142 ASSERT_TRUE(child1); |
| 1139 ASSERT_TRUE(child2); | 1143 ASSERT_TRUE(child2); |
| 1140 ASSERT_TRUE(grand_child1); | 1144 ASSERT_TRUE(grand_child1); |
| 1141 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 1145 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); |
| 1142 | 1146 |
| 1143 // Nothing overlaps the root_layer at (1, 1), so hit testing there should find | 1147 // Nothing overlaps the root_layer at (1, 1), so hit testing there should find |
| 1144 // the root layer. | 1148 // the root layer. |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1225 std::unique_ptr<std::set<LayerImpl*>> clip_children( | 1229 std::unique_ptr<std::set<LayerImpl*>> clip_children( |
| 1226 new std::set<LayerImpl*>); | 1230 new std::set<LayerImpl*>); |
| 1227 clip_children->insert(grand_child.get()); | 1231 clip_children->insert(grand_child.get()); |
| 1228 root->test_properties()->clip_children.reset(clip_children.release()); | 1232 root->test_properties()->clip_children.reset(clip_children.release()); |
| 1229 | 1233 |
| 1230 child->test_properties()->AddChild(std::move(grand_child)); | 1234 child->test_properties()->AddChild(std::move(grand_child)); |
| 1231 root->test_properties()->AddChild(std::move(child)); | 1235 root->test_properties()->AddChild(std::move(child)); |
| 1232 } | 1236 } |
| 1233 | 1237 |
| 1234 host_impl().SetViewportSize(root->bounds()); | 1238 host_impl().SetViewportSize(root->bounds()); |
| 1235 host_impl().active_tree()->SetRootLayer(std::move(root)); | 1239 host_impl().active_tree()->SetRootLayerForTesting(std::move(root)); |
| 1236 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 1240 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
| 1237 | 1241 |
| 1238 gfx::PointF test_point(12.f, 52.f); | 1242 gfx::PointF test_point(12.f, 52.f); |
| 1239 LayerImpl* result_layer = | 1243 LayerImpl* result_layer = |
| 1240 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 1244 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); |
| 1241 ASSERT_TRUE(result_layer); | 1245 ASSERT_TRUE(result_layer); |
| 1242 EXPECT_EQ(4, result_layer->id()); | 1246 EXPECT_EQ(4, result_layer->id()); |
| 1243 } | 1247 } |
| 1244 | 1248 |
| 1245 TEST_F(LayerTreeImplTest, HitTestingRespectsScrollParents) { | 1249 TEST_F(LayerTreeImplTest, HitTestingRespectsScrollParents) { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1287 false, false); | 1291 false, false); |
| 1288 grand_child->SetDrawsContent(true); | 1292 grand_child->SetDrawsContent(true); |
| 1289 grand_child->SetHasRenderSurface(true); | 1293 grand_child->SetHasRenderSurface(true); |
| 1290 | 1294 |
| 1291 scroll_child->test_properties()->AddChild(std::move(grand_child)); | 1295 scroll_child->test_properties()->AddChild(std::move(grand_child)); |
| 1292 root->test_properties()->AddChild(std::move(scroll_child)); | 1296 root->test_properties()->AddChild(std::move(scroll_child)); |
| 1293 root->test_properties()->AddChild(std::move(child)); | 1297 root->test_properties()->AddChild(std::move(child)); |
| 1294 } | 1298 } |
| 1295 | 1299 |
| 1296 host_impl().SetViewportSize(root->bounds()); | 1300 host_impl().SetViewportSize(root->bounds()); |
| 1297 host_impl().active_tree()->SetRootLayer(std::move(root)); | 1301 host_impl().active_tree()->SetRootLayerForTesting(std::move(root)); |
| 1298 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 1302 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
| 1299 | 1303 |
| 1300 gfx::PointF test_point(12.f, 52.f); | 1304 gfx::PointF test_point(12.f, 52.f); |
| 1301 LayerImpl* result_layer = | 1305 LayerImpl* result_layer = |
| 1302 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 1306 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); |
| 1303 // The |test_point| should have been clipped away by |child|, the scroll | 1307 // The |test_point| should have been clipped away by |child|, the scroll |
| 1304 // parent, so the only thing that should be hit is |root|. | 1308 // parent, so the only thing that should be hit is |root|. |
| 1305 ASSERT_TRUE(result_layer); | 1309 ASSERT_TRUE(result_layer); |
| 1306 ASSERT_EQ(1, result_layer->id()); | 1310 ASSERT_EQ(1, result_layer->id()); |
| 1307 } | 1311 } |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1358 bounds = gfx::Size(100, 50); | 1362 bounds = gfx::Size(100, 50); |
| 1359 SetLayerPropertiesForTesting(grand_child1.get(), identity_matrix, | 1363 SetLayerPropertiesForTesting(grand_child1.get(), identity_matrix, |
| 1360 transform_origin, position, bounds, true, | 1364 transform_origin, position, bounds, true, |
| 1361 false, false); | 1365 false, false); |
| 1362 grand_child1->SetDrawsContent(true); | 1366 grand_child1->SetDrawsContent(true); |
| 1363 grand_child1->test_properties()->force_render_surface = true; | 1367 grand_child1->test_properties()->force_render_surface = true; |
| 1364 | 1368 |
| 1365 child1->test_properties()->AddChild(std::move(grand_child1)); | 1369 child1->test_properties()->AddChild(std::move(grand_child1)); |
| 1366 root->test_properties()->AddChild(std::move(child1)); | 1370 root->test_properties()->AddChild(std::move(child1)); |
| 1367 root->test_properties()->AddChild(std::move(child2)); | 1371 root->test_properties()->AddChild(std::move(child2)); |
| 1368 host_impl().active_tree()->SetRootLayer(std::move(root)); | 1372 host_impl().active_tree()->SetRootLayerForTesting(std::move(root)); |
| 1369 | 1373 |
| 1370 ExecuteCalculateDrawProperties(root_layer); | 1374 ExecuteCalculateDrawProperties(root_layer); |
| 1371 } | 1375 } |
| 1372 | 1376 |
| 1373 LayerImpl* child1 = root_layer->test_properties()->children[0]; | 1377 LayerImpl* child1 = root_layer->test_properties()->children[0]; |
| 1374 LayerImpl* child2 = root_layer->test_properties()->children[1]; | 1378 LayerImpl* child2 = root_layer->test_properties()->children[1]; |
| 1375 LayerImpl* grand_child1 = child1->test_properties()->children[0]; | 1379 LayerImpl* grand_child1 = child1->test_properties()->children[0]; |
| 1376 | 1380 |
| 1377 host_impl().SetViewportSize(root_layer->bounds()); | 1381 host_impl().SetViewportSize(root_layer->bounds()); |
| 1378 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 1382 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1452 gfx::Transform identity_matrix; | 1456 gfx::Transform identity_matrix; |
| 1453 Region touch_handler_region(gfx::Rect(10, 10, 50, 50)); | 1457 Region touch_handler_region(gfx::Rect(10, 10, 50, 50)); |
| 1454 gfx::Point3F transform_origin; | 1458 gfx::Point3F transform_origin; |
| 1455 gfx::PointF position; | 1459 gfx::PointF position; |
| 1456 gfx::Size bounds(100, 100); | 1460 gfx::Size bounds(100, 100); |
| 1457 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, | 1461 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, |
| 1458 position, bounds, true, false, true); | 1462 position, bounds, true, false, true); |
| 1459 root->SetDrawsContent(true); | 1463 root->SetDrawsContent(true); |
| 1460 | 1464 |
| 1461 host_impl().SetViewportSize(root->bounds()); | 1465 host_impl().SetViewportSize(root->bounds()); |
| 1462 host_impl().active_tree()->SetRootLayer(std::move(root)); | 1466 host_impl().active_tree()->SetRootLayerForTesting(std::move(root)); |
| 1463 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 1467 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
| 1464 | 1468 |
| 1465 // Sanity check the scenario we just created. | 1469 // Sanity check the scenario we just created. |
| 1466 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 1470 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); |
| 1467 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); | 1471 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); |
| 1468 | 1472 |
| 1469 // Hit checking for any point should return a null pointer for a layer without | 1473 // Hit checking for any point should return a null pointer for a layer without |
| 1470 // any touch event handler regions. | 1474 // any touch event handler regions. |
| 1471 gfx::PointF test_point(11.f, 11.f); | 1475 gfx::PointF test_point(11.f, 11.f); |
| 1472 LayerImpl* result_layer = | 1476 LayerImpl* result_layer = |
| 1473 host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 1477 host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( |
| 1474 test_point); | 1478 test_point); |
| 1475 EXPECT_FALSE(result_layer); | 1479 EXPECT_FALSE(result_layer); |
| 1476 | 1480 |
| 1477 host_impl().active_tree()->root_layer()->SetTouchEventHandlerRegion( | 1481 host_impl() |
| 1478 touch_handler_region); | 1482 .active_tree() |
| 1483 ->root_layer_for_testing() |
| 1484 ->SetTouchEventHandlerRegion(touch_handler_region); |
| 1479 // Hit checking for a point outside the layer should return a null pointer. | 1485 // Hit checking for a point outside the layer should return a null pointer. |
| 1480 test_point = gfx::PointF(101.f, 101.f); | 1486 test_point = gfx::PointF(101.f, 101.f); |
| 1481 result_layer = | 1487 result_layer = |
| 1482 host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 1488 host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( |
| 1483 test_point); | 1489 test_point); |
| 1484 EXPECT_FALSE(result_layer); | 1490 EXPECT_FALSE(result_layer); |
| 1485 | 1491 |
| 1486 test_point = gfx::PointF(-1.f, -1.f); | 1492 test_point = gfx::PointF(-1.f, -1.f); |
| 1487 result_layer = | 1493 result_layer = |
| 1488 host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 1494 host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1537 gfx::Point3F transform_origin; | 1543 gfx::Point3F transform_origin; |
| 1538 gfx::PointF position; | 1544 gfx::PointF position; |
| 1539 gfx::Size bounds(100, 100); | 1545 gfx::Size bounds(100, 100); |
| 1540 SetLayerPropertiesForTesting(root.get(), uninvertible_transform, | 1546 SetLayerPropertiesForTesting(root.get(), uninvertible_transform, |
| 1541 transform_origin, position, bounds, true, false, | 1547 transform_origin, position, bounds, true, false, |
| 1542 true); | 1548 true); |
| 1543 root->SetDrawsContent(true); | 1549 root->SetDrawsContent(true); |
| 1544 root->SetTouchEventHandlerRegion(touch_handler_region); | 1550 root->SetTouchEventHandlerRegion(touch_handler_region); |
| 1545 | 1551 |
| 1546 host_impl().SetViewportSize(root->bounds()); | 1552 host_impl().SetViewportSize(root->bounds()); |
| 1547 host_impl().active_tree()->SetRootLayer(std::move(root)); | 1553 host_impl().active_tree()->SetRootLayerForTesting(std::move(root)); |
| 1548 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 1554 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
| 1549 | 1555 |
| 1550 // Sanity check the scenario we just created. | 1556 // Sanity check the scenario we just created. |
| 1551 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 1557 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); |
| 1552 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); | 1558 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); |
| 1553 ASSERT_FALSE(root_layer()->ScreenSpaceTransform().IsInvertible()); | 1559 ASSERT_FALSE(root_layer()->ScreenSpaceTransform().IsInvertible()); |
| 1554 | 1560 |
| 1555 // Hit checking any point should not hit the touch handler region on the | 1561 // Hit checking any point should not hit the touch handler region on the |
| 1556 // layer. If the invertible matrix is accidentally ignored and treated like an | 1562 // layer. If the invertible matrix is accidentally ignored and treated like an |
| 1557 // identity, then the hit testing will incorrectly hit the layer when it | 1563 // identity, then the hit testing will incorrectly hit the layer when it |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1610 // this layer is positioned, and hit testing should correctly know where the | 1616 // this layer is positioned, and hit testing should correctly know where the |
| 1611 // layer is located. | 1617 // layer is located. |
| 1612 gfx::PointF position(50.f, 50.f); | 1618 gfx::PointF position(50.f, 50.f); |
| 1613 gfx::Size bounds(100, 100); | 1619 gfx::Size bounds(100, 100); |
| 1614 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, | 1620 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, |
| 1615 position, bounds, true, false, true); | 1621 position, bounds, true, false, true); |
| 1616 root->SetDrawsContent(true); | 1622 root->SetDrawsContent(true); |
| 1617 root->SetTouchEventHandlerRegion(touch_handler_region); | 1623 root->SetTouchEventHandlerRegion(touch_handler_region); |
| 1618 | 1624 |
| 1619 host_impl().SetViewportSize(root->bounds()); | 1625 host_impl().SetViewportSize(root->bounds()); |
| 1620 host_impl().active_tree()->SetRootLayer(std::move(root)); | 1626 host_impl().active_tree()->SetRootLayerForTesting(std::move(root)); |
| 1621 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 1627 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
| 1622 | 1628 |
| 1623 // Sanity check the scenario we just created. | 1629 // Sanity check the scenario we just created. |
| 1624 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 1630 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); |
| 1625 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); | 1631 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); |
| 1626 | 1632 |
| 1627 // Hit checking for a point outside the layer should return a null pointer. | 1633 // Hit checking for a point outside the layer should return a null pointer. |
| 1628 gfx::PointF test_point(49.f, 49.f); | 1634 gfx::PointF test_point(49.f, 49.f); |
| 1629 LayerImpl* result_layer = | 1635 LayerImpl* result_layer = |
| 1630 host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 1636 host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1694 } | 1700 } |
| 1695 | 1701 |
| 1696 float device_scale_factor = 3.f; | 1702 float device_scale_factor = 3.f; |
| 1697 float page_scale_factor = 5.f; | 1703 float page_scale_factor = 5.f; |
| 1698 float max_page_scale_factor = 10.f; | 1704 float max_page_scale_factor = 10.f; |
| 1699 gfx::Size scaled_bounds_for_root = gfx::ScaleToCeiledSize( | 1705 gfx::Size scaled_bounds_for_root = gfx::ScaleToCeiledSize( |
| 1700 root->bounds(), device_scale_factor * page_scale_factor); | 1706 root->bounds(), device_scale_factor * page_scale_factor); |
| 1701 host_impl().SetViewportSize(scaled_bounds_for_root); | 1707 host_impl().SetViewportSize(scaled_bounds_for_root); |
| 1702 | 1708 |
| 1703 host_impl().active_tree()->SetDeviceScaleFactor(device_scale_factor); | 1709 host_impl().active_tree()->SetDeviceScaleFactor(device_scale_factor); |
| 1704 host_impl().active_tree()->SetRootLayer(std::move(root)); | 1710 host_impl().active_tree()->SetRootLayerForTesting(std::move(root)); |
| 1705 host_impl().active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 1, | 1711 host_impl().active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 1, |
| 1706 Layer::INVALID_ID); | 1712 Layer::INVALID_ID); |
| 1707 host_impl().active_tree()->BuildLayerListAndPropertyTreesForTesting(); | 1713 host_impl().active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
| 1708 host_impl().active_tree()->PushPageScaleFromMainThread( | 1714 host_impl().active_tree()->PushPageScaleFromMainThread( |
| 1709 page_scale_factor, page_scale_factor, max_page_scale_factor); | 1715 page_scale_factor, page_scale_factor, max_page_scale_factor); |
| 1710 host_impl().active_tree()->SetPageScaleOnActiveTree(page_scale_factor); | 1716 host_impl().active_tree()->SetPageScaleOnActiveTree(page_scale_factor); |
| 1711 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 1717 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
| 1712 | 1718 |
| 1713 // Sanity check the scenario we just created. | 1719 // Sanity check the scenario we just created. |
| 1714 // The visible content rect for test_layer is actually 100x100, even though | 1720 // The visible content rect for test_layer is actually 100x100, even though |
| 1715 // its layout size is 50x50, positioned at 25x25. | 1721 // its layout size is 50x50, positioned at 25x25. |
| 1716 LayerImpl* test_layer = | 1722 LayerImpl* test_layer = host_impl() |
| 1717 host_impl().active_tree()->root_layer()->test_properties()->children[0]; | 1723 .active_tree() |
| 1724 ->root_layer_for_testing() |
| 1725 ->test_properties() |
| 1726 ->children[0]; |
| 1718 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 1727 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); |
| 1719 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); | 1728 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); |
| 1720 | 1729 |
| 1721 // Check whether the child layer fits into the root after scaled. | 1730 // Check whether the child layer fits into the root after scaled. |
| 1722 EXPECT_EQ(gfx::Rect(test_layer->bounds()), test_layer->visible_layer_rect()); | 1731 EXPECT_EQ(gfx::Rect(test_layer->bounds()), test_layer->visible_layer_rect()); |
| 1723 | 1732 |
| 1724 // Hit checking for a point outside the layer should return a null pointer | 1733 // Hit checking for a point outside the layer should return a null pointer |
| 1725 // (the root layer does not have a touch event handler, so it will not be | 1734 // (the root layer does not have a touch event handler, so it will not be |
| 1726 // tested either). | 1735 // tested either). |
| 1727 gfx::PointF test_point(76.f, 76.f); | 1736 gfx::PointF test_point(76.f, 76.f); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1783 result_layer = | 1792 result_layer = |
| 1784 host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 1793 host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( |
| 1785 test_point); | 1794 test_point); |
| 1786 ASSERT_TRUE(result_layer); | 1795 ASSERT_TRUE(result_layer); |
| 1787 EXPECT_EQ(12345, result_layer->id()); | 1796 EXPECT_EQ(12345, result_layer->id()); |
| 1788 | 1797 |
| 1789 // Check update of page scale factor on the active tree when page scale layer | 1798 // Check update of page scale factor on the active tree when page scale layer |
| 1790 // is also the root layer. | 1799 // is also the root layer. |
| 1791 page_scale_factor *= 1.5f; | 1800 page_scale_factor *= 1.5f; |
| 1792 host_impl().active_tree()->SetPageScaleOnActiveTree(page_scale_factor); | 1801 host_impl().active_tree()->SetPageScaleOnActiveTree(page_scale_factor); |
| 1793 EXPECT_EQ(host_impl().active_tree()->root_layer(), | 1802 EXPECT_EQ(host_impl().active_tree()->root_layer_for_testing(), |
| 1794 host_impl().active_tree()->PageScaleLayer()); | 1803 host_impl().active_tree()->PageScaleLayer()); |
| 1795 | 1804 |
| 1796 test_point = gfx::PointF(35.f, 35.f); | 1805 test_point = gfx::PointF(35.f, 35.f); |
| 1797 test_point = | 1806 test_point = |
| 1798 gfx::ScalePoint(test_point, device_scale_factor * page_scale_factor); | 1807 gfx::ScalePoint(test_point, device_scale_factor * page_scale_factor); |
| 1799 result_layer = | 1808 result_layer = |
| 1800 host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 1809 host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( |
| 1801 test_point); | 1810 test_point); |
| 1802 ASSERT_TRUE(result_layer); | 1811 ASSERT_TRUE(result_layer); |
| 1803 EXPECT_EQ(12345, result_layer->id()); | 1812 EXPECT_EQ(12345, result_layer->id()); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1843 bounds = gfx::Size(300, 300); | 1852 bounds = gfx::Size(300, 300); |
| 1844 SetLayerPropertiesForTesting(child.get(), identity_matrix, transform_origin, | 1853 SetLayerPropertiesForTesting(child.get(), identity_matrix, transform_origin, |
| 1845 position, bounds, true, false, false); | 1854 position, bounds, true, false, false); |
| 1846 child->SetDrawsContent(true); | 1855 child->SetDrawsContent(true); |
| 1847 child->SetTouchEventHandlerRegion(touch_handler_region); | 1856 child->SetTouchEventHandlerRegion(touch_handler_region); |
| 1848 clipping_layer->test_properties()->AddChild(std::move(child)); | 1857 clipping_layer->test_properties()->AddChild(std::move(child)); |
| 1849 root->test_properties()->AddChild(std::move(clipping_layer)); | 1858 root->test_properties()->AddChild(std::move(clipping_layer)); |
| 1850 } | 1859 } |
| 1851 | 1860 |
| 1852 host_impl().SetViewportSize(root->bounds()); | 1861 host_impl().SetViewportSize(root->bounds()); |
| 1853 host_impl().active_tree()->SetRootLayer(std::move(root)); | 1862 host_impl().active_tree()->SetRootLayerForTesting(std::move(root)); |
| 1854 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 1863 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
| 1855 | 1864 |
| 1856 // Sanity check the scenario we just created. | 1865 // Sanity check the scenario we just created. |
| 1857 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 1866 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); |
| 1858 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); | 1867 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); |
| 1859 ASSERT_EQ(456, root_layer()->render_surface()->layer_list().at(0)->id()); | 1868 ASSERT_EQ(456, root_layer()->render_surface()->layer_list().at(0)->id()); |
| 1860 | 1869 |
| 1861 // Hit checking for a point outside the layer should return a null pointer. | 1870 // Hit checking for a point outside the layer should return a null pointer. |
| 1862 // Despite the child layer being very large, it should be clipped to the root | 1871 // Despite the child layer being very large, it should be clipped to the root |
| 1863 // layer's bounds. | 1872 // layer's bounds. |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1944 } | 1953 } |
| 1945 | 1954 |
| 1946 float device_scale_factor = 3.f; | 1955 float device_scale_factor = 3.f; |
| 1947 float page_scale_factor = 1.f; | 1956 float page_scale_factor = 1.f; |
| 1948 float max_page_scale_factor = 1.f; | 1957 float max_page_scale_factor = 1.f; |
| 1949 gfx::Size scaled_bounds_for_root = gfx::ScaleToCeiledSize( | 1958 gfx::Size scaled_bounds_for_root = gfx::ScaleToCeiledSize( |
| 1950 root->bounds(), device_scale_factor * page_scale_factor); | 1959 root->bounds(), device_scale_factor * page_scale_factor); |
| 1951 host_impl().SetViewportSize(scaled_bounds_for_root); | 1960 host_impl().SetViewportSize(scaled_bounds_for_root); |
| 1952 | 1961 |
| 1953 host_impl().active_tree()->SetDeviceScaleFactor(device_scale_factor); | 1962 host_impl().active_tree()->SetDeviceScaleFactor(device_scale_factor); |
| 1954 host_impl().active_tree()->SetRootLayer(std::move(root)); | 1963 host_impl().active_tree()->SetRootLayerForTesting(std::move(root)); |
| 1955 host_impl().active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 1, | 1964 host_impl().active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 1, |
| 1956 Layer::INVALID_ID); | 1965 Layer::INVALID_ID); |
| 1957 host_impl().active_tree()->BuildLayerListAndPropertyTreesForTesting(); | 1966 host_impl().active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
| 1958 host_impl().active_tree()->PushPageScaleFromMainThread( | 1967 host_impl().active_tree()->PushPageScaleFromMainThread( |
| 1959 page_scale_factor, page_scale_factor, max_page_scale_factor); | 1968 page_scale_factor, page_scale_factor, max_page_scale_factor); |
| 1960 host_impl().active_tree()->SetPageScaleOnActiveTree(page_scale_factor); | 1969 host_impl().active_tree()->SetPageScaleOnActiveTree(page_scale_factor); |
| 1961 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 1970 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
| 1962 | 1971 |
| 1963 // Sanity check the scenario we just created. | 1972 // Sanity check the scenario we just created. |
| 1964 ASSERT_EQ(2u, RenderSurfaceLayerList().size()); | 1973 ASSERT_EQ(2u, RenderSurfaceLayerList().size()); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2018 gfx::PointF position(0, 25); | 2027 gfx::PointF position(0, 25); |
| 2019 gfx::Size bounds(50, 50); | 2028 gfx::Size bounds(50, 50); |
| 2020 SetLayerPropertiesForTesting(notouch_layer.get(), identity_matrix, | 2029 SetLayerPropertiesForTesting(notouch_layer.get(), identity_matrix, |
| 2021 transform_origin, position, bounds, true, | 2030 transform_origin, position, bounds, true, |
| 2022 false, false); | 2031 false, false); |
| 2023 notouch_layer->SetDrawsContent(true); | 2032 notouch_layer->SetDrawsContent(true); |
| 2024 root->test_properties()->AddChild(std::move(notouch_layer)); | 2033 root->test_properties()->AddChild(std::move(notouch_layer)); |
| 2025 } | 2034 } |
| 2026 | 2035 |
| 2027 host_impl().SetViewportSize(root->bounds()); | 2036 host_impl().SetViewportSize(root->bounds()); |
| 2028 host_impl().active_tree()->SetRootLayer(std::move(root)); | 2037 host_impl().active_tree()->SetRootLayerForTesting(std::move(root)); |
| 2029 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 2038 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
| 2030 | 2039 |
| 2031 // Sanity check the scenario we just created. | 2040 // Sanity check the scenario we just created. |
| 2032 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 2041 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); |
| 2033 ASSERT_EQ(2u, root_layer()->render_surface()->layer_list().size()); | 2042 ASSERT_EQ(2u, root_layer()->render_surface()->layer_list().size()); |
| 2034 ASSERT_EQ(123, root_layer()->render_surface()->layer_list().at(0)->id()); | 2043 ASSERT_EQ(123, root_layer()->render_surface()->layer_list().at(0)->id()); |
| 2035 ASSERT_EQ(1234, root_layer()->render_surface()->layer_list().at(1)->id()); | 2044 ASSERT_EQ(1234, root_layer()->render_surface()->layer_list().at(1)->id()); |
| 2036 | 2045 |
| 2037 gfx::PointF test_point(35.f, 35.f); | 2046 gfx::PointF test_point(35.f, 35.f); |
| 2038 LayerImpl* result_layer = | 2047 LayerImpl* result_layer = |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2086 LayerImpl::Create(host_impl().active_tree(), 12345); | 2095 LayerImpl::Create(host_impl().active_tree(), 12345); |
| 2087 SetLayerPropertiesForTesting(test_layer.get(), identity_matrix, | 2096 SetLayerPropertiesForTesting(test_layer.get(), identity_matrix, |
| 2088 transform_origin, position, bounds, true, | 2097 transform_origin, position, bounds, true, |
| 2089 false, false); | 2098 false, false); |
| 2090 | 2099 |
| 2091 test_layer->SetDrawsContent(false); | 2100 test_layer->SetDrawsContent(false); |
| 2092 test_layer->SetTouchEventHandlerRegion(touch_handler_region); | 2101 test_layer->SetTouchEventHandlerRegion(touch_handler_region); |
| 2093 root->test_properties()->AddChild(std::move(test_layer)); | 2102 root->test_properties()->AddChild(std::move(test_layer)); |
| 2094 } | 2103 } |
| 2095 host_impl().SetViewportSize(root->bounds()); | 2104 host_impl().SetViewportSize(root->bounds()); |
| 2096 host_impl().active_tree()->SetRootLayer(std::move(root)); | 2105 host_impl().active_tree()->SetRootLayerForTesting(std::move(root)); |
| 2097 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 2106 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
| 2098 | 2107 |
| 2099 LayerImpl* test_layer = | 2108 LayerImpl* test_layer = host_impl() |
| 2100 host_impl().active_tree()->root_layer()->test_properties()->children[0]; | 2109 .active_tree() |
| 2110 ->root_layer_for_testing() |
| 2111 ->test_properties() |
| 2112 ->children[0]; |
| 2101 // As test_layer doesn't draw content, the layer list of root's render surface | 2113 // As test_layer doesn't draw content, the layer list of root's render surface |
| 2102 // should contain only the root layer. | 2114 // should contain only the root layer. |
| 2103 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 2115 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); |
| 2104 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); | 2116 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); |
| 2105 | 2117 |
| 2106 // Hit testing for a point outside the test layer should return null pointer. | 2118 // Hit testing for a point outside the test layer should return null pointer. |
| 2107 // We also implicitly check that the updated screen space transform of a layer | 2119 // We also implicitly check that the updated screen space transform of a layer |
| 2108 // that is not in drawn render surface layer list (test_layer) is used during | 2120 // that is not in drawn render surface layer list (test_layer) is used during |
| 2109 // hit testing (becuase the point is inside test_layer with respect to the old | 2121 // hit testing (becuase the point is inside test_layer with respect to the old |
| 2110 // screen space transform). | 2122 // screen space transform). |
| (...skipping 10 matching lines...) Expand all Loading... |
| 2121 EXPECT_FALSE(result_layer); | 2133 EXPECT_FALSE(result_layer); |
| 2122 EXPECT_FALSE(test_layer->is_drawn_render_surface_layer_list_member()); | 2134 EXPECT_FALSE(test_layer->is_drawn_render_surface_layer_list_member()); |
| 2123 EXPECT_TRANSFORMATION_MATRIX_EQ( | 2135 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 2124 expected_screen_space_transform, | 2136 expected_screen_space_transform, |
| 2125 draw_property_utils::ScreenSpaceTransform( | 2137 draw_property_utils::ScreenSpaceTransform( |
| 2126 test_layer, | 2138 test_layer, |
| 2127 host_impl().active_tree()->property_trees()->transform_tree)); | 2139 host_impl().active_tree()->property_trees()->transform_tree)); |
| 2128 | 2140 |
| 2129 // We change the position of the test layer such that the test point is now | 2141 // We change the position of the test layer such that the test point is now |
| 2130 // inside the test_layer. | 2142 // inside the test_layer. |
| 2131 test_layer = | 2143 test_layer = host_impl() |
| 2132 host_impl().active_tree()->root_layer()->test_properties()->children[0]; | 2144 .active_tree() |
| 2145 ->root_layer_for_testing() |
| 2146 ->test_properties() |
| 2147 ->children[0]; |
| 2133 test_layer->SetPosition(gfx::PointF(10.f, 10.f)); | 2148 test_layer->SetPosition(gfx::PointF(10.f, 10.f)); |
| 2134 test_layer->NoteLayerPropertyChanged(); | 2149 test_layer->NoteLayerPropertyChanged(); |
| 2135 expected_screen_space_transform.MakeIdentity(); | 2150 expected_screen_space_transform.MakeIdentity(); |
| 2136 expected_screen_space_transform.Translate(10.f, 10.f); | 2151 expected_screen_space_transform.Translate(10.f, 10.f); |
| 2137 | 2152 |
| 2138 host_impl().active_tree()->property_trees()->needs_rebuild = true; | 2153 host_impl().active_tree()->property_trees()->needs_rebuild = true; |
| 2139 host_impl().active_tree()->BuildLayerListAndPropertyTreesForTesting(); | 2154 host_impl().active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
| 2140 result_layer = | 2155 result_layer = |
| 2141 host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 2156 host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( |
| 2142 test_point); | 2157 test_point); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 2157 | 2172 |
| 2158 gfx::Transform identity_matrix; | 2173 gfx::Transform identity_matrix; |
| 2159 gfx::Point3F transform_origin; | 2174 gfx::Point3F transform_origin; |
| 2160 gfx::PointF position; | 2175 gfx::PointF position; |
| 2161 gfx::Size bounds(100, 100); | 2176 gfx::Size bounds(100, 100); |
| 2162 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, | 2177 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, |
| 2163 position, bounds, true, false, true); | 2178 position, bounds, true, false, true); |
| 2164 root->SetDrawsContent(true); | 2179 root->SetDrawsContent(true); |
| 2165 | 2180 |
| 2166 host_impl().SetViewportSize(root->bounds()); | 2181 host_impl().SetViewportSize(root->bounds()); |
| 2167 host_impl().active_tree()->SetRootLayer(std::move(root)); | 2182 host_impl().active_tree()->SetRootLayerForTesting(std::move(root)); |
| 2168 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 2183 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
| 2169 | 2184 |
| 2170 // Sanity check the scenario we just created. | 2185 // Sanity check the scenario we just created. |
| 2171 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 2186 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); |
| 2172 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); | 2187 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); |
| 2173 | 2188 |
| 2174 LayerSelection input; | 2189 LayerSelection input; |
| 2175 | 2190 |
| 2176 input.start.type = gfx::SelectionBound::LEFT; | 2191 input.start.type = gfx::SelectionBound::LEFT; |
| 2177 input.start.edge_top = gfx::Point(10, 10); | 2192 input.start.edge_top = gfx::Point(10, 10); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2261 bounds = gfx::Size(100, 100); | 2276 bounds = gfx::Size(100, 100); |
| 2262 SetLayerPropertiesForTesting(clipped_layer.get(), identity_matrix, | 2277 SetLayerPropertiesForTesting(clipped_layer.get(), identity_matrix, |
| 2263 transform_origin, position, bounds, true, | 2278 transform_origin, position, bounds, true, |
| 2264 false, false); | 2279 false, false); |
| 2265 clipped_layer->SetDrawsContent(true); | 2280 clipped_layer->SetDrawsContent(true); |
| 2266 clipping_layer->test_properties()->AddChild(std::move(clipped_layer)); | 2281 clipping_layer->test_properties()->AddChild(std::move(clipped_layer)); |
| 2267 root->test_properties()->AddChild(std::move(clipping_layer)); | 2282 root->test_properties()->AddChild(std::move(clipping_layer)); |
| 2268 } | 2283 } |
| 2269 | 2284 |
| 2270 host_impl().SetViewportSize(root->bounds()); | 2285 host_impl().SetViewportSize(root->bounds()); |
| 2271 host_impl().active_tree()->SetRootLayer(std::move(root)); | 2286 host_impl().active_tree()->SetRootLayerForTesting(std::move(root)); |
| 2272 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 2287 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
| 2273 | 2288 |
| 2274 // Sanity check the scenario we just created. | 2289 // Sanity check the scenario we just created. |
| 2275 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 2290 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); |
| 2276 | 2291 |
| 2277 LayerSelection input; | 2292 LayerSelection input; |
| 2278 input.start.type = gfx::SelectionBound::LEFT; | 2293 input.start.type = gfx::SelectionBound::LEFT; |
| 2279 input.start.edge_top = gfx::Point(25, 10); | 2294 input.start.edge_top = gfx::Point(25, 10); |
| 2280 input.start.edge_bottom = gfx::Point(25, 30); | 2295 input.start.edge_bottom = gfx::Point(25, 30); |
| 2281 input.start.layer_id = clipped_layer_id; | 2296 input.start.layer_id = clipped_layer_id; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2355 } | 2370 } |
| 2356 | 2371 |
| 2357 float device_scale_factor = 3.f; | 2372 float device_scale_factor = 3.f; |
| 2358 float page_scale_factor = 5.f; | 2373 float page_scale_factor = 5.f; |
| 2359 gfx::Size scaled_bounds_for_root = gfx::ScaleToCeiledSize( | 2374 gfx::Size scaled_bounds_for_root = gfx::ScaleToCeiledSize( |
| 2360 root->bounds(), device_scale_factor * page_scale_factor); | 2375 root->bounds(), device_scale_factor * page_scale_factor); |
| 2361 host_impl().SetViewportSize(scaled_bounds_for_root); | 2376 host_impl().SetViewportSize(scaled_bounds_for_root); |
| 2362 | 2377 |
| 2363 host_impl().active_tree()->SetDeviceScaleFactor(device_scale_factor); | 2378 host_impl().active_tree()->SetDeviceScaleFactor(device_scale_factor); |
| 2364 host_impl().active_tree()->SetPageScaleOnActiveTree(page_scale_factor); | 2379 host_impl().active_tree()->SetPageScaleOnActiveTree(page_scale_factor); |
| 2365 host_impl().active_tree()->SetRootLayer(std::move(root)); | 2380 host_impl().active_tree()->SetRootLayerForTesting(std::move(root)); |
| 2366 host_impl().active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 1, | 2381 host_impl().active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 1, |
| 2367 Layer::INVALID_ID); | 2382 Layer::INVALID_ID); |
| 2368 host_impl().active_tree()->BuildLayerListAndPropertyTreesForTesting(); | 2383 host_impl().active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
| 2369 host_impl().active_tree()->PushPageScaleFromMainThread( | 2384 host_impl().active_tree()->PushPageScaleFromMainThread( |
| 2370 page_scale_factor, page_scale_factor, page_scale_factor); | 2385 page_scale_factor, page_scale_factor, page_scale_factor); |
| 2371 host_impl().active_tree()->SetPageScaleOnActiveTree(page_scale_factor); | 2386 host_impl().active_tree()->SetPageScaleOnActiveTree(page_scale_factor); |
| 2372 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 2387 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
| 2373 | 2388 |
| 2374 // Sanity check the scenario we just created. | 2389 // Sanity check the scenario we just created. |
| 2375 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 2390 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2441 SetLayerPropertiesForTesting(grand_child.get(), large_transform, | 2456 SetLayerPropertiesForTesting(grand_child.get(), large_transform, |
| 2442 transform_origin, position, bounds, true, | 2457 transform_origin, position, bounds, true, |
| 2443 false, false); | 2458 false, false); |
| 2444 grand_child->SetDrawsContent(true); | 2459 grand_child->SetDrawsContent(true); |
| 2445 | 2460 |
| 2446 child->test_properties()->AddChild(std::move(grand_child)); | 2461 child->test_properties()->AddChild(std::move(grand_child)); |
| 2447 root->test_properties()->AddChild(std::move(child)); | 2462 root->test_properties()->AddChild(std::move(child)); |
| 2448 } | 2463 } |
| 2449 | 2464 |
| 2450 host_impl().SetViewportSize(root->bounds()); | 2465 host_impl().SetViewportSize(root->bounds()); |
| 2451 host_impl().active_tree()->SetRootLayer(std::move(root)); | 2466 host_impl().active_tree()->SetRootLayerForTesting(std::move(root)); |
| 2452 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 2467 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
| 2453 | 2468 |
| 2454 LayerSelection input; | 2469 LayerSelection input; |
| 2455 | 2470 |
| 2456 input.start.type = gfx::SelectionBound::LEFT; | 2471 input.start.type = gfx::SelectionBound::LEFT; |
| 2457 input.start.edge_top = gfx::Point(10, 10); | 2472 input.start.edge_top = gfx::Point(10, 10); |
| 2458 input.start.edge_bottom = gfx::Point(10, 20); | 2473 input.start.edge_bottom = gfx::Point(10, 20); |
| 2459 input.start.layer_id = grand_child_id; | 2474 input.start.layer_id = grand_child_id; |
| 2460 | 2475 |
| 2461 input.end.type = gfx::SelectionBound::RIGHT; | 2476 input.end.type = gfx::SelectionBound::RIGHT; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2535 translate_z.Translate3d(0, 0, 10); | 2550 translate_z.Translate3d(0, 0, 10); |
| 2536 SetLayerPropertiesForTesting(right_child.get(), translate_z, | 2551 SetLayerPropertiesForTesting(right_child.get(), translate_z, |
| 2537 transform_origin, position, bounds, false, | 2552 transform_origin, position, bounds, false, |
| 2538 false, false); | 2553 false, false); |
| 2539 } | 2554 } |
| 2540 | 2555 |
| 2541 root->test_properties()->AddChild(std::move(left_child)); | 2556 root->test_properties()->AddChild(std::move(left_child)); |
| 2542 root->test_properties()->AddChild(std::move(right_child)); | 2557 root->test_properties()->AddChild(std::move(right_child)); |
| 2543 | 2558 |
| 2544 host_impl().SetViewportSize(root->bounds()); | 2559 host_impl().SetViewportSize(root->bounds()); |
| 2545 host_impl().active_tree()->SetRootLayer(std::move(root)); | 2560 host_impl().active_tree()->SetRootLayerForTesting(std::move(root)); |
| 2546 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 2561 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
| 2547 CHECK_EQ(1u, RenderSurfaceLayerList().size()); | 2562 CHECK_EQ(1u, RenderSurfaceLayerList().size()); |
| 2548 | 2563 |
| 2549 gfx::PointF test_point = gfx::PointF(1.f, 1.f); | 2564 gfx::PointF test_point = gfx::PointF(1.f, 1.f); |
| 2550 LayerImpl* result_layer = | 2565 LayerImpl* result_layer = |
| 2551 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 2566 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); |
| 2552 | 2567 |
| 2553 CHECK(result_layer); | 2568 CHECK(result_layer); |
| 2554 EXPECT_EQ(2, result_layer->id()); | 2569 EXPECT_EQ(2, result_layer->id()); |
| 2555 } | 2570 } |
| 2556 | 2571 |
| 2557 } // namespace | 2572 } // namespace |
| 2558 } // namespace cc | 2573 } // namespace cc |
| OLD | NEW |