| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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_host_common.h" | 5 #include "cc/trees/layer_tree_host_common.h" |
| 6 | 6 |
| 7 #include "cc/animation/layer_animation_controller.h" | 7 #include "cc/animation/layer_animation_controller.h" |
| 8 #include "cc/base/math_util.h" | 8 #include "cc/base/math_util.h" |
| 9 #include "cc/base/thread.h" | 9 #include "cc/base/thread.h" |
| 10 #include "cc/layers/content_layer.h" | 10 #include "cc/layers/content_layer.h" |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 gfx::Transform identity_matrix; | 112 gfx::Transform identity_matrix; |
| 113 LayerImplList dummy_render_surface_layer_list; | 113 LayerImplList dummy_render_surface_layer_list; |
| 114 int dummy_max_texture_size = 512; | 114 int dummy_max_texture_size = 512; |
| 115 gfx::Size device_viewport_size = | 115 gfx::Size device_viewport_size = |
| 116 gfx::Size(root_layer->bounds().width() * device_scale_factor, | 116 gfx::Size(root_layer->bounds().width() * device_scale_factor, |
| 117 root_layer->bounds().height() * device_scale_factor); | 117 root_layer->bounds().height() * device_scale_factor); |
| 118 | 118 |
| 119 // We are probably not testing what is intended if the root_layer bounds are | 119 // We are probably not testing what is intended if the root_layer bounds are |
| 120 // empty. | 120 // empty. |
| 121 DCHECK(!root_layer->bounds().IsEmpty()); | 121 DCHECK(!root_layer->bounds().IsEmpty()); |
| 122 LayerTreeHostCommon::CalculateDrawProperties(root_layer, | 122 LayerTreeHostCommon::CalculateDrawProperties( |
| 123 device_viewport_size, | 123 root_layer, |
| 124 device_scale_factor, | 124 device_viewport_size, |
| 125 page_scale_factor, | 125 device_scale_factor, |
| 126 dummy_max_texture_size, | 126 page_scale_factor, |
| 127 can_use_lcd_text, | 127 dummy_max_texture_size, |
| 128 &dummy_render_surface_layer_list, | 128 can_use_lcd_text, |
| 129 false); | 129 &dummy_render_surface_layer_list); |
| 130 } | 130 } |
| 131 | 131 |
| 132 template <class LayerType> | 132 template <class LayerType> |
| 133 void ExecuteCalculateDrawProperties(LayerType* root_layer) { | 133 void ExecuteCalculateDrawProperties(LayerType* root_layer) { |
| 134 ExecuteCalculateDrawProperties(root_layer, 1.f, 1.f, false); | 134 ExecuteCalculateDrawProperties(root_layer, 1.f, 1.f, false); |
| 135 } | 135 } |
| 136 | 136 |
| 137 template <class LayerType> | 137 template <class LayerType> |
| 138 void ExecuteCalculateDrawProperties(LayerType* root_layer, | 138 void ExecuteCalculateDrawProperties(LayerType* root_layer, |
| 139 float device_scale_factor) { | 139 float device_scale_factor) { |
| (...skipping 3946 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4086 root->SetDrawsContent(true); | 4086 root->SetDrawsContent(true); |
| 4087 | 4087 |
| 4088 LayerImplList render_surface_layer_list; | 4088 LayerImplList render_surface_layer_list; |
| 4089 int dummy_max_texture_size = 512; | 4089 int dummy_max_texture_size = 512; |
| 4090 LayerTreeHostCommon::CalculateDrawProperties(root.get(), | 4090 LayerTreeHostCommon::CalculateDrawProperties(root.get(), |
| 4091 root->bounds(), | 4091 root->bounds(), |
| 4092 1.f, | 4092 1.f, |
| 4093 1.f, | 4093 1.f, |
| 4094 dummy_max_texture_size, | 4094 dummy_max_texture_size, |
| 4095 false, | 4095 false, |
| 4096 &render_surface_layer_list, | 4096 &render_surface_layer_list); |
| 4097 false); | |
| 4098 | 4097 |
| 4099 // Sanity check the scenario we just created. | 4098 // Sanity check the scenario we just created. |
| 4100 ASSERT_EQ(1u, render_surface_layer_list.size()); | 4099 ASSERT_EQ(1u, render_surface_layer_list.size()); |
| 4101 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); | 4100 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); |
| 4102 | 4101 |
| 4103 // Hit testing for a point outside the layer should return a null pointer. | 4102 // Hit testing for a point outside the layer should return a null pointer. |
| 4104 gfx::Point test_point(101, 101); | 4103 gfx::Point test_point(101, 101); |
| 4105 LayerImpl* result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | 4104 LayerImpl* result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( |
| 4106 test_point, render_surface_layer_list); | 4105 test_point, render_surface_layer_list); |
| 4107 EXPECT_FALSE(result_layer); | 4106 EXPECT_FALSE(result_layer); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4161 root->AddChild(hud.PassAs<LayerImpl>()); | 4160 root->AddChild(hud.PassAs<LayerImpl>()); |
| 4162 | 4161 |
| 4163 LayerImplList render_surface_layer_list; | 4162 LayerImplList render_surface_layer_list; |
| 4164 int dummy_max_texture_size = 512; | 4163 int dummy_max_texture_size = 512; |
| 4165 LayerTreeHostCommon::CalculateDrawProperties(root.get(), | 4164 LayerTreeHostCommon::CalculateDrawProperties(root.get(), |
| 4166 hud_bounds, | 4165 hud_bounds, |
| 4167 1.f, | 4166 1.f, |
| 4168 1.f, | 4167 1.f, |
| 4169 dummy_max_texture_size, | 4168 dummy_max_texture_size, |
| 4170 false, | 4169 false, |
| 4171 &render_surface_layer_list, | 4170 &render_surface_layer_list); |
| 4172 false); | |
| 4173 | 4171 |
| 4174 // Sanity check the scenario we just created. | 4172 // Sanity check the scenario we just created. |
| 4175 ASSERT_EQ(1u, render_surface_layer_list.size()); | 4173 ASSERT_EQ(1u, render_surface_layer_list.size()); |
| 4176 ASSERT_EQ(2u, root->render_surface()->layer_list().size()); | 4174 ASSERT_EQ(2u, root->render_surface()->layer_list().size()); |
| 4177 | 4175 |
| 4178 // Hit testing for a point inside HUD, but outside root should return null | 4176 // Hit testing for a point inside HUD, but outside root should return null |
| 4179 gfx::Point test_point(101, 101); | 4177 gfx::Point test_point(101, 101); |
| 4180 LayerImpl* result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | 4178 LayerImpl* result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( |
| 4181 test_point, render_surface_layer_list); | 4179 test_point, render_surface_layer_list); |
| 4182 EXPECT_FALSE(result_layer); | 4180 EXPECT_FALSE(result_layer); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4228 root->SetDrawsContent(true); | 4226 root->SetDrawsContent(true); |
| 4229 | 4227 |
| 4230 LayerImplList render_surface_layer_list; | 4228 LayerImplList render_surface_layer_list; |
| 4231 int dummy_max_texture_size = 512; | 4229 int dummy_max_texture_size = 512; |
| 4232 LayerTreeHostCommon::CalculateDrawProperties(root.get(), | 4230 LayerTreeHostCommon::CalculateDrawProperties(root.get(), |
| 4233 root->bounds(), | 4231 root->bounds(), |
| 4234 1.f, | 4232 1.f, |
| 4235 1.f, | 4233 1.f, |
| 4236 dummy_max_texture_size, | 4234 dummy_max_texture_size, |
| 4237 false, | 4235 false, |
| 4238 &render_surface_layer_list, | 4236 &render_surface_layer_list); |
| 4239 false); | |
| 4240 | 4237 |
| 4241 // Sanity check the scenario we just created. | 4238 // Sanity check the scenario we just created. |
| 4242 ASSERT_EQ(1u, render_surface_layer_list.size()); | 4239 ASSERT_EQ(1u, render_surface_layer_list.size()); |
| 4243 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); | 4240 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); |
| 4244 ASSERT_FALSE(root->screen_space_transform().IsInvertible()); | 4241 ASSERT_FALSE(root->screen_space_transform().IsInvertible()); |
| 4245 | 4242 |
| 4246 // Hit testing any point should not hit the layer. If the invertible matrix is | 4243 // Hit testing any point should not hit the layer. If the invertible matrix is |
| 4247 // accidentally ignored and treated like an identity, then the hit testing | 4244 // accidentally ignored and treated like an identity, then the hit testing |
| 4248 // will incorrectly hit the layer when it shouldn't. | 4245 // will incorrectly hit the layer when it shouldn't. |
| 4249 gfx::Point test_point(1, 1); | 4246 gfx::Point test_point(1, 1); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4304 root->SetDrawsContent(true); | 4301 root->SetDrawsContent(true); |
| 4305 | 4302 |
| 4306 LayerImplList render_surface_layer_list; | 4303 LayerImplList render_surface_layer_list; |
| 4307 int dummy_max_texture_size = 512; | 4304 int dummy_max_texture_size = 512; |
| 4308 LayerTreeHostCommon::CalculateDrawProperties(root.get(), | 4305 LayerTreeHostCommon::CalculateDrawProperties(root.get(), |
| 4309 root->bounds(), | 4306 root->bounds(), |
| 4310 1.f, | 4307 1.f, |
| 4311 1.f, | 4308 1.f, |
| 4312 dummy_max_texture_size, | 4309 dummy_max_texture_size, |
| 4313 false, | 4310 false, |
| 4314 &render_surface_layer_list, | 4311 &render_surface_layer_list); |
| 4315 false); | |
| 4316 | 4312 |
| 4317 // Sanity check the scenario we just created. | 4313 // Sanity check the scenario we just created. |
| 4318 ASSERT_EQ(1u, render_surface_layer_list.size()); | 4314 ASSERT_EQ(1u, render_surface_layer_list.size()); |
| 4319 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); | 4315 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); |
| 4320 | 4316 |
| 4321 // Hit testing for a point outside the layer should return a null pointer. | 4317 // Hit testing for a point outside the layer should return a null pointer. |
| 4322 gfx::Point test_point(49, 49); | 4318 gfx::Point test_point(49, 49); |
| 4323 LayerImpl* result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | 4319 LayerImpl* result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( |
| 4324 test_point, render_surface_layer_list); | 4320 test_point, render_surface_layer_list); |
| 4325 EXPECT_FALSE(result_layer); | 4321 EXPECT_FALSE(result_layer); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4369 root->SetDrawsContent(true); | 4365 root->SetDrawsContent(true); |
| 4370 | 4366 |
| 4371 LayerImplList render_surface_layer_list; | 4367 LayerImplList render_surface_layer_list; |
| 4372 int dummy_max_texture_size = 512; | 4368 int dummy_max_texture_size = 512; |
| 4373 LayerTreeHostCommon::CalculateDrawProperties(root.get(), | 4369 LayerTreeHostCommon::CalculateDrawProperties(root.get(), |
| 4374 root->bounds(), | 4370 root->bounds(), |
| 4375 1.f, | 4371 1.f, |
| 4376 1.f, | 4372 1.f, |
| 4377 dummy_max_texture_size, | 4373 dummy_max_texture_size, |
| 4378 false, | 4374 false, |
| 4379 &render_surface_layer_list, | 4375 &render_surface_layer_list); |
| 4380 false); | |
| 4381 | 4376 |
| 4382 // Sanity check the scenario we just created. | 4377 // Sanity check the scenario we just created. |
| 4383 ASSERT_EQ(1u, render_surface_layer_list.size()); | 4378 ASSERT_EQ(1u, render_surface_layer_list.size()); |
| 4384 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); | 4379 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); |
| 4385 | 4380 |
| 4386 // Hit testing for points outside the layer. | 4381 // Hit testing for points outside the layer. |
| 4387 // These corners would have been inside the un-transformed layer, but they | 4382 // These corners would have been inside the un-transformed layer, but they |
| 4388 // should not hit the correctly transformed layer. | 4383 // should not hit the correctly transformed layer. |
| 4389 gfx::Point test_point(99, 99); | 4384 gfx::Point test_point(99, 99); |
| 4390 LayerImpl* result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | 4385 LayerImpl* result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4447 root->SetDrawsContent(true); | 4442 root->SetDrawsContent(true); |
| 4448 | 4443 |
| 4449 LayerImplList render_surface_layer_list; | 4444 LayerImplList render_surface_layer_list; |
| 4450 int dummy_max_texture_size = 512; | 4445 int dummy_max_texture_size = 512; |
| 4451 LayerTreeHostCommon::CalculateDrawProperties(root.get(), | 4446 LayerTreeHostCommon::CalculateDrawProperties(root.get(), |
| 4452 root->bounds(), | 4447 root->bounds(), |
| 4453 1.f, | 4448 1.f, |
| 4454 1.f, | 4449 1.f, |
| 4455 dummy_max_texture_size, | 4450 dummy_max_texture_size, |
| 4456 false, | 4451 false, |
| 4457 &render_surface_layer_list, | 4452 &render_surface_layer_list); |
| 4458 false); | |
| 4459 | 4453 |
| 4460 // Sanity check the scenario we just created. | 4454 // Sanity check the scenario we just created. |
| 4461 ASSERT_EQ(1u, render_surface_layer_list.size()); | 4455 ASSERT_EQ(1u, render_surface_layer_list.size()); |
| 4462 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); | 4456 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); |
| 4463 | 4457 |
| 4464 // Hit testing for points outside the layer. | 4458 // Hit testing for points outside the layer. |
| 4465 // These corners would have been inside the un-transformed layer, but they | 4459 // These corners would have been inside the un-transformed layer, but they |
| 4466 // should not hit the correctly transformed layer. | 4460 // should not hit the correctly transformed layer. |
| 4467 gfx::Point test_point(24, 24); | 4461 gfx::Point test_point(24, 24); |
| 4468 LayerImpl* result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | 4462 LayerImpl* result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4536 } | 4530 } |
| 4537 | 4531 |
| 4538 LayerImplList render_surface_layer_list; | 4532 LayerImplList render_surface_layer_list; |
| 4539 int dummy_max_texture_size = 512; | 4533 int dummy_max_texture_size = 512; |
| 4540 LayerTreeHostCommon::CalculateDrawProperties(root.get(), | 4534 LayerTreeHostCommon::CalculateDrawProperties(root.get(), |
| 4541 root->bounds(), | 4535 root->bounds(), |
| 4542 1.f, | 4536 1.f, |
| 4543 1.f, | 4537 1.f, |
| 4544 dummy_max_texture_size, | 4538 dummy_max_texture_size, |
| 4545 false, | 4539 false, |
| 4546 &render_surface_layer_list, | 4540 &render_surface_layer_list); |
| 4547 false); | |
| 4548 | 4541 |
| 4549 // Sanity check the scenario we just created. | 4542 // Sanity check the scenario we just created. |
| 4550 // The visible content rect for test_layer is actually 100x100, even though | 4543 // The visible content rect for test_layer is actually 100x100, even though |
| 4551 // its layout size is 50x50, positioned at 25x25. | 4544 // its layout size is 50x50, positioned at 25x25. |
| 4552 LayerImpl* test_layer = root->children()[0]; | 4545 LayerImpl* test_layer = root->children()[0]; |
| 4553 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), | 4546 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), |
| 4554 test_layer->visible_content_rect()); | 4547 test_layer->visible_content_rect()); |
| 4555 ASSERT_EQ(1u, render_surface_layer_list.size()); | 4548 ASSERT_EQ(1u, render_surface_layer_list.size()); |
| 4556 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); | 4549 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); |
| 4557 | 4550 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4636 } | 4629 } |
| 4637 | 4630 |
| 4638 LayerImplList render_surface_layer_list; | 4631 LayerImplList render_surface_layer_list; |
| 4639 int dummy_max_texture_size = 512; | 4632 int dummy_max_texture_size = 512; |
| 4640 LayerTreeHostCommon::CalculateDrawProperties(root.get(), | 4633 LayerTreeHostCommon::CalculateDrawProperties(root.get(), |
| 4641 root->bounds(), | 4634 root->bounds(), |
| 4642 1.f, | 4635 1.f, |
| 4643 1.f, | 4636 1.f, |
| 4644 dummy_max_texture_size, | 4637 dummy_max_texture_size, |
| 4645 false, | 4638 false, |
| 4646 &render_surface_layer_list, | 4639 &render_surface_layer_list); |
| 4647 false); | |
| 4648 | 4640 |
| 4649 // Sanity check the scenario we just created. | 4641 // Sanity check the scenario we just created. |
| 4650 ASSERT_EQ(1u, render_surface_layer_list.size()); | 4642 ASSERT_EQ(1u, render_surface_layer_list.size()); |
| 4651 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); | 4643 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); |
| 4652 ASSERT_EQ(456, root->render_surface()->layer_list()[0]->id()); | 4644 ASSERT_EQ(456, root->render_surface()->layer_list()[0]->id()); |
| 4653 | 4645 |
| 4654 // Hit testing for a point outside the layer should return a null pointer. | 4646 // Hit testing for a point outside the layer should return a null pointer. |
| 4655 // Despite the child layer being very large, it should be clipped to the root | 4647 // Despite the child layer being very large, it should be clipped to the root |
| 4656 // layer's bounds. | 4648 // layer's bounds. |
| 4657 gfx::Point test_point(24, 24); | 4649 gfx::Point test_point(24, 24); |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4769 } | 4761 } |
| 4770 | 4762 |
| 4771 LayerImplList render_surface_layer_list; | 4763 LayerImplList render_surface_layer_list; |
| 4772 int dummy_max_texture_size = 512; | 4764 int dummy_max_texture_size = 512; |
| 4773 LayerTreeHostCommon::CalculateDrawProperties(root.get(), | 4765 LayerTreeHostCommon::CalculateDrawProperties(root.get(), |
| 4774 root->bounds(), | 4766 root->bounds(), |
| 4775 1.f, | 4767 1.f, |
| 4776 1.f, | 4768 1.f, |
| 4777 dummy_max_texture_size, | 4769 dummy_max_texture_size, |
| 4778 false, | 4770 false, |
| 4779 &render_surface_layer_list, | 4771 &render_surface_layer_list); |
| 4780 false); | |
| 4781 | 4772 |
| 4782 // Sanity check the scenario we just created. | 4773 // Sanity check the scenario we just created. |
| 4783 // The grand_child is expected to create a render surface because it | 4774 // The grand_child is expected to create a render surface because it |
| 4784 // masksToBounds and is not axis aligned. | 4775 // masksToBounds and is not axis aligned. |
| 4785 ASSERT_EQ(2u, render_surface_layer_list.size()); | 4776 ASSERT_EQ(2u, render_surface_layer_list.size()); |
| 4786 ASSERT_EQ( | 4777 ASSERT_EQ( |
| 4787 1u, render_surface_layer_list[0]->render_surface()->layer_list().size()); | 4778 1u, render_surface_layer_list[0]->render_surface()->layer_list().size()); |
| 4788 ASSERT_EQ(789, | 4779 ASSERT_EQ(789, |
| 4789 render_surface_layer_list[0]->render_surface()->layer_list()[0] | 4780 render_surface_layer_list[0]->render_surface()->layer_list()[0] |
| 4790 ->id()); // grand_child's surface. | 4781 ->id()); // grand_child's surface. |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4895 } | 4886 } |
| 4896 | 4887 |
| 4897 LayerImplList render_surface_layer_list; | 4888 LayerImplList render_surface_layer_list; |
| 4898 int dummy_max_texture_size = 512; | 4889 int dummy_max_texture_size = 512; |
| 4899 LayerTreeHostCommon::CalculateDrawProperties(root.get(), | 4890 LayerTreeHostCommon::CalculateDrawProperties(root.get(), |
| 4900 root->bounds(), | 4891 root->bounds(), |
| 4901 1.f, | 4892 1.f, |
| 4902 1.f, | 4893 1.f, |
| 4903 dummy_max_texture_size, | 4894 dummy_max_texture_size, |
| 4904 false, | 4895 false, |
| 4905 &render_surface_layer_list, | 4896 &render_surface_layer_list); |
| 4906 false); | |
| 4907 | 4897 |
| 4908 // Sanity check the scenario we just created. | 4898 // Sanity check the scenario we just created. |
| 4909 ASSERT_EQ(1u, render_surface_layer_list.size()); | 4899 ASSERT_EQ(1u, render_surface_layer_list.size()); |
| 4910 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); | 4900 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); |
| 4911 ASSERT_EQ(456, root->render_surface()->layer_list()[0]->id()); | 4901 ASSERT_EQ(456, root->render_surface()->layer_list()[0]->id()); |
| 4912 | 4902 |
| 4913 // Hit testing for a point outside the layer should return a null pointer. | 4903 // Hit testing for a point outside the layer should return a null pointer. |
| 4914 gfx::Point test_point(69, 69); | 4904 gfx::Point test_point(69, 69); |
| 4915 LayerImpl* result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | 4905 LayerImpl* result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( |
| 4916 test_point, render_surface_layer_list); | 4906 test_point, render_surface_layer_list); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5012 LayerImpl* grand_child1 = child1->children()[0]; | 5002 LayerImpl* grand_child1 = child1->children()[0]; |
| 5013 | 5003 |
| 5014 LayerImplList render_surface_layer_list; | 5004 LayerImplList render_surface_layer_list; |
| 5015 int dummy_max_texture_size = 512; | 5005 int dummy_max_texture_size = 512; |
| 5016 LayerTreeHostCommon::CalculateDrawProperties(root.get(), | 5006 LayerTreeHostCommon::CalculateDrawProperties(root.get(), |
| 5017 root->bounds(), | 5007 root->bounds(), |
| 5018 1.f, | 5008 1.f, |
| 5019 1.f, | 5009 1.f, |
| 5020 dummy_max_texture_size, | 5010 dummy_max_texture_size, |
| 5021 false, | 5011 false, |
| 5022 &render_surface_layer_list, | 5012 &render_surface_layer_list); |
| 5023 false); | |
| 5024 | 5013 |
| 5025 // Sanity check the scenario we just created. | 5014 // Sanity check the scenario we just created. |
| 5026 ASSERT_TRUE(child1); | 5015 ASSERT_TRUE(child1); |
| 5027 ASSERT_TRUE(child2); | 5016 ASSERT_TRUE(child2); |
| 5028 ASSERT_TRUE(grand_child1); | 5017 ASSERT_TRUE(grand_child1); |
| 5029 ASSERT_EQ(1u, render_surface_layer_list.size()); | 5018 ASSERT_EQ(1u, render_surface_layer_list.size()); |
| 5030 ASSERT_EQ(4u, root->render_surface()->layer_list().size()); | 5019 ASSERT_EQ(4u, root->render_surface()->layer_list().size()); |
| 5031 ASSERT_EQ(1, root->render_surface()->layer_list()[0]->id()); // root layer | 5020 ASSERT_EQ(1, root->render_surface()->layer_list()[0]->id()); // root layer |
| 5032 ASSERT_EQ(2, root->render_surface()->layer_list()[1]->id()); // child1 | 5021 ASSERT_EQ(2, root->render_surface()->layer_list()[1]->id()); // child1 |
| 5033 ASSERT_EQ(4, root->render_surface()->layer_list()[2]->id()); // grand_child1 | 5022 ASSERT_EQ(4, root->render_surface()->layer_list()[2]->id()); // grand_child1 |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5165 LayerImpl* grand_child1 = child1->children()[0]; | 5154 LayerImpl* grand_child1 = child1->children()[0]; |
| 5166 | 5155 |
| 5167 LayerImplList render_surface_layer_list; | 5156 LayerImplList render_surface_layer_list; |
| 5168 int dummy_max_texture_size = 512; | 5157 int dummy_max_texture_size = 512; |
| 5169 LayerTreeHostCommon::CalculateDrawProperties(root.get(), | 5158 LayerTreeHostCommon::CalculateDrawProperties(root.get(), |
| 5170 root->bounds(), | 5159 root->bounds(), |
| 5171 1.f, | 5160 1.f, |
| 5172 1.f, | 5161 1.f, |
| 5173 dummy_max_texture_size, | 5162 dummy_max_texture_size, |
| 5174 false, | 5163 false, |
| 5175 &render_surface_layer_list, | 5164 &render_surface_layer_list); |
| 5176 false); | |
| 5177 | 5165 |
| 5178 // Sanity check the scenario we just created. | 5166 // Sanity check the scenario we just created. |
| 5179 ASSERT_TRUE(child1); | 5167 ASSERT_TRUE(child1); |
| 5180 ASSERT_TRUE(child2); | 5168 ASSERT_TRUE(child2); |
| 5181 ASSERT_TRUE(grand_child1); | 5169 ASSERT_TRUE(grand_child1); |
| 5182 ASSERT_TRUE(child1->render_surface()); | 5170 ASSERT_TRUE(child1->render_surface()); |
| 5183 ASSERT_TRUE(child2->render_surface()); | 5171 ASSERT_TRUE(child2->render_surface()); |
| 5184 ASSERT_TRUE(grand_child1->render_surface()); | 5172 ASSERT_TRUE(grand_child1->render_surface()); |
| 5185 ASSERT_EQ(4u, render_surface_layer_list.size()); | 5173 ASSERT_EQ(4u, render_surface_layer_list.size()); |
| 5186 // The root surface has the root layer, and child1's and child2's render | 5174 // The root surface has the root layer, and child1's and child2's render |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5282 root->SetDrawsContent(true); | 5270 root->SetDrawsContent(true); |
| 5283 | 5271 |
| 5284 LayerImplList render_surface_layer_list; | 5272 LayerImplList render_surface_layer_list; |
| 5285 int dummy_max_texture_size = 512; | 5273 int dummy_max_texture_size = 512; |
| 5286 LayerTreeHostCommon::CalculateDrawProperties(root.get(), | 5274 LayerTreeHostCommon::CalculateDrawProperties(root.get(), |
| 5287 root->bounds(), | 5275 root->bounds(), |
| 5288 1.f, | 5276 1.f, |
| 5289 1.f, | 5277 1.f, |
| 5290 dummy_max_texture_size, | 5278 dummy_max_texture_size, |
| 5291 false, | 5279 false, |
| 5292 &render_surface_layer_list, | 5280 &render_surface_layer_list); |
| 5293 false); | |
| 5294 | 5281 |
| 5295 // Sanity check the scenario we just created. | 5282 // Sanity check the scenario we just created. |
| 5296 ASSERT_EQ(1u, render_surface_layer_list.size()); | 5283 ASSERT_EQ(1u, render_surface_layer_list.size()); |
| 5297 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); | 5284 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); |
| 5298 | 5285 |
| 5299 // Hit checking for any point should return a null pointer for a layer without | 5286 // Hit checking for any point should return a null pointer for a layer without |
| 5300 // any touch event handler regions. | 5287 // any touch event handler regions. |
| 5301 gfx::Point test_point(11, 11); | 5288 gfx::Point test_point(11, 11); |
| 5302 LayerImpl* result_layer = | 5289 LayerImpl* result_layer = |
| 5303 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( | 5290 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5379 root->SetTouchEventHandlerRegion(touch_handler_region); | 5366 root->SetTouchEventHandlerRegion(touch_handler_region); |
| 5380 | 5367 |
| 5381 LayerImplList render_surface_layer_list; | 5368 LayerImplList render_surface_layer_list; |
| 5382 int dummy_max_texture_size = 512; | 5369 int dummy_max_texture_size = 512; |
| 5383 LayerTreeHostCommon::CalculateDrawProperties(root.get(), | 5370 LayerTreeHostCommon::CalculateDrawProperties(root.get(), |
| 5384 root->bounds(), | 5371 root->bounds(), |
| 5385 1.f, | 5372 1.f, |
| 5386 1.f, | 5373 1.f, |
| 5387 dummy_max_texture_size, | 5374 dummy_max_texture_size, |
| 5388 false, | 5375 false, |
| 5389 &render_surface_layer_list, | 5376 &render_surface_layer_list); |
| 5390 false); | |
| 5391 | 5377 |
| 5392 // Sanity check the scenario we just created. | 5378 // Sanity check the scenario we just created. |
| 5393 ASSERT_EQ(1u, render_surface_layer_list.size()); | 5379 ASSERT_EQ(1u, render_surface_layer_list.size()); |
| 5394 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); | 5380 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); |
| 5395 ASSERT_FALSE(root->screen_space_transform().IsInvertible()); | 5381 ASSERT_FALSE(root->screen_space_transform().IsInvertible()); |
| 5396 | 5382 |
| 5397 // Hit checking any point should not hit the touch handler region on the | 5383 // Hit checking any point should not hit the touch handler region on the |
| 5398 // layer. If the invertible matrix is accidentally ignored and treated like an | 5384 // layer. If the invertible matrix is accidentally ignored and treated like an |
| 5399 // identity, then the hit testing will incorrectly hit the layer when it | 5385 // identity, then the hit testing will incorrectly hit the layer when it |
| 5400 // shouldn't. | 5386 // shouldn't. |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5466 root->SetTouchEventHandlerRegion(touch_handler_region); | 5452 root->SetTouchEventHandlerRegion(touch_handler_region); |
| 5467 | 5453 |
| 5468 LayerImplList render_surface_layer_list; | 5454 LayerImplList render_surface_layer_list; |
| 5469 int dummy_max_texture_size = 512; | 5455 int dummy_max_texture_size = 512; |
| 5470 LayerTreeHostCommon::CalculateDrawProperties(root.get(), | 5456 LayerTreeHostCommon::CalculateDrawProperties(root.get(), |
| 5471 root->bounds(), | 5457 root->bounds(), |
| 5472 1.f, | 5458 1.f, |
| 5473 1.f, | 5459 1.f, |
| 5474 dummy_max_texture_size, | 5460 dummy_max_texture_size, |
| 5475 false, | 5461 false, |
| 5476 &render_surface_layer_list, | 5462 &render_surface_layer_list); |
| 5477 false); | |
| 5478 | 5463 |
| 5479 // Sanity check the scenario we just created. | 5464 // Sanity check the scenario we just created. |
| 5480 ASSERT_EQ(1u, render_surface_layer_list.size()); | 5465 ASSERT_EQ(1u, render_surface_layer_list.size()); |
| 5481 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); | 5466 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); |
| 5482 | 5467 |
| 5483 // Hit checking for a point outside the layer should return a null pointer. | 5468 // Hit checking for a point outside the layer should return a null pointer. |
| 5484 gfx::Point test_point(49, 49); | 5469 gfx::Point test_point(49, 49); |
| 5485 LayerImpl* result_layer = | 5470 LayerImpl* result_layer = |
| 5486 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( | 5471 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( |
| 5487 test_point, render_surface_layer_list); | 5472 test_point, render_surface_layer_list); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5571 } | 5556 } |
| 5572 | 5557 |
| 5573 LayerImplList render_surface_layer_list; | 5558 LayerImplList render_surface_layer_list; |
| 5574 int dummy_max_texture_size = 512; | 5559 int dummy_max_texture_size = 512; |
| 5575 LayerTreeHostCommon::CalculateDrawProperties(root.get(), | 5560 LayerTreeHostCommon::CalculateDrawProperties(root.get(), |
| 5576 root->bounds(), | 5561 root->bounds(), |
| 5577 1.f, | 5562 1.f, |
| 5578 1.f, | 5563 1.f, |
| 5579 dummy_max_texture_size, | 5564 dummy_max_texture_size, |
| 5580 false, | 5565 false, |
| 5581 &render_surface_layer_list, | 5566 &render_surface_layer_list); |
| 5582 false); | |
| 5583 | 5567 |
| 5584 // Sanity check the scenario we just created. | 5568 // Sanity check the scenario we just created. |
| 5585 // The visible content rect for test_layer is actually 100x100, even though | 5569 // The visible content rect for test_layer is actually 100x100, even though |
| 5586 // its layout size is 50x50, positioned at 25x25. | 5570 // its layout size is 50x50, positioned at 25x25. |
| 5587 LayerImpl* test_layer = root->children()[0]; | 5571 LayerImpl* test_layer = root->children()[0]; |
| 5588 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), test_layer->visible_content_rect()); | 5572 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), test_layer->visible_content_rect()); |
| 5589 ASSERT_EQ(1u, render_surface_layer_list.size()); | 5573 ASSERT_EQ(1u, render_surface_layer_list.size()); |
| 5590 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); | 5574 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); |
| 5591 | 5575 |
| 5592 // Hit checking for a point outside the layer should return a null pointer | 5576 // Hit checking for a point outside the layer should return a null pointer |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5687 // Applying the page_scale_factor through impl_transform. | 5671 // Applying the page_scale_factor through impl_transform. |
| 5688 root->SetImplTransform(page_scale_transform); | 5672 root->SetImplTransform(page_scale_transform); |
| 5689 gfx::Size scaled_bounds_for_root = gfx::ToCeiledSize( | 5673 gfx::Size scaled_bounds_for_root = gfx::ToCeiledSize( |
| 5690 gfx::ScaleSize(root->bounds(), device_scale_factor * page_scale_factor)); | 5674 gfx::ScaleSize(root->bounds(), device_scale_factor * page_scale_factor)); |
| 5691 LayerTreeHostCommon::CalculateDrawProperties(root.get(), | 5675 LayerTreeHostCommon::CalculateDrawProperties(root.get(), |
| 5692 scaled_bounds_for_root, | 5676 scaled_bounds_for_root, |
| 5693 device_scale_factor, | 5677 device_scale_factor, |
| 5694 1, | 5678 1, |
| 5695 dummy_max_texture_size, | 5679 dummy_max_texture_size, |
| 5696 false, | 5680 false, |
| 5697 &render_surface_layer_list, | 5681 &render_surface_layer_list); |
| 5698 false); | |
| 5699 | 5682 |
| 5700 // Sanity check the scenario we just created. | 5683 // Sanity check the scenario we just created. |
| 5701 // The visible content rect for test_layer is actually 100x100, even though | 5684 // The visible content rect for test_layer is actually 100x100, even though |
| 5702 // its layout size is 50x50, positioned at 25x25. | 5685 // its layout size is 50x50, positioned at 25x25. |
| 5703 LayerImpl* test_layer = root->children()[0]; | 5686 LayerImpl* test_layer = root->children()[0]; |
| 5704 ASSERT_EQ(1u, render_surface_layer_list.size()); | 5687 ASSERT_EQ(1u, render_surface_layer_list.size()); |
| 5705 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); | 5688 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); |
| 5706 | 5689 |
| 5707 // Check whether the child layer fits into the root after scaled. | 5690 // Check whether the child layer fits into the root after scaled. |
| 5708 EXPECT_RECT_EQ(gfx::Rect(test_layer->content_bounds()), | 5691 EXPECT_RECT_EQ(gfx::Rect(test_layer->content_bounds()), |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5826 } | 5809 } |
| 5827 | 5810 |
| 5828 LayerImplList render_surface_layer_list; | 5811 LayerImplList render_surface_layer_list; |
| 5829 int dummy_max_texture_size = 512; | 5812 int dummy_max_texture_size = 512; |
| 5830 LayerTreeHostCommon::CalculateDrawProperties(root.get(), | 5813 LayerTreeHostCommon::CalculateDrawProperties(root.get(), |
| 5831 root->bounds(), | 5814 root->bounds(), |
| 5832 1.f, | 5815 1.f, |
| 5833 1.f, | 5816 1.f, |
| 5834 dummy_max_texture_size, | 5817 dummy_max_texture_size, |
| 5835 false, | 5818 false, |
| 5836 &render_surface_layer_list, | 5819 &render_surface_layer_list); |
| 5837 false); | |
| 5838 | 5820 |
| 5839 // Sanity check the scenario we just created. | 5821 // Sanity check the scenario we just created. |
| 5840 ASSERT_EQ(1u, render_surface_layer_list.size()); | 5822 ASSERT_EQ(1u, render_surface_layer_list.size()); |
| 5841 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); | 5823 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); |
| 5842 ASSERT_EQ(456, root->render_surface()->layer_list()[0]->id()); | 5824 ASSERT_EQ(456, root->render_surface()->layer_list()[0]->id()); |
| 5843 | 5825 |
| 5844 // Hit checking for a point outside the layer should return a null pointer. | 5826 // Hit checking for a point outside the layer should return a null pointer. |
| 5845 // Despite the child layer being very large, it should be clipped to the root | 5827 // Despite the child layer being very large, it should be clipped to the root |
| 5846 // layer's bounds. | 5828 // layer's bounds. |
| 5847 gfx::Point test_point(24, 24); | 5829 gfx::Point test_point(24, 24); |
| (...skipping 1439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7287 root->AddChild(child.Pass()); | 7269 root->AddChild(child.Pass()); |
| 7288 | 7270 |
| 7289 std::vector<LayerImpl*> render_surface_layer_list; | 7271 std::vector<LayerImpl*> render_surface_layer_list; |
| 7290 int dummy_max_texture_size = 512; | 7272 int dummy_max_texture_size = 512; |
| 7291 LayerTreeHostCommon::CalculateDrawProperties(root.get(), | 7273 LayerTreeHostCommon::CalculateDrawProperties(root.get(), |
| 7292 root->bounds(), | 7274 root->bounds(), |
| 7293 1.f, | 7275 1.f, |
| 7294 1.f, | 7276 1.f, |
| 7295 dummy_max_texture_size, | 7277 dummy_max_texture_size, |
| 7296 false, | 7278 false, |
| 7297 &render_surface_layer_list, | 7279 &render_surface_layer_list); |
| 7298 false); | |
| 7299 | 7280 |
| 7300 // We should have one render surface and two layers. The child | 7281 // We should have one render surface and two layers. The child |
| 7301 // layer should be included even though it is transparent. | 7282 // layer should be included even though it is transparent. |
| 7302 ASSERT_EQ(1u, render_surface_layer_list.size()); | 7283 ASSERT_EQ(1u, render_surface_layer_list.size()); |
| 7303 ASSERT_EQ(2u, root->render_surface()->layer_list().size()); | 7284 ASSERT_EQ(2u, root->render_surface()->layer_list().size()); |
| 7304 } | 7285 } |
| 7305 | 7286 |
| 7306 typedef std::tr1::tuple<bool, bool> LCDTextTestParam; | 7287 typedef std::tr1::tuple<bool, bool> LCDTextTestParam; |
| 7307 class LCDTextTest : public testing::TestWithParam<LCDTextTestParam> { | 7288 class LCDTextTest : public testing::TestWithParam<LCDTextTestParam> { |
| 7308 protected: | 7289 protected: |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7436 EXPECT_EQ(can_use_lcd_text_, child_->can_use_lcd_text()); | 7417 EXPECT_EQ(can_use_lcd_text_, child_->can_use_lcd_text()); |
| 7437 EXPECT_EQ(can_use_lcd_text_, grand_child_->can_use_lcd_text()); | 7418 EXPECT_EQ(can_use_lcd_text_, grand_child_->can_use_lcd_text()); |
| 7438 } | 7419 } |
| 7439 | 7420 |
| 7440 INSTANTIATE_TEST_CASE_P(LayerTreeHostCommonTest, | 7421 INSTANTIATE_TEST_CASE_P(LayerTreeHostCommonTest, |
| 7441 LCDTextTest, | 7422 LCDTextTest, |
| 7442 testing::Combine(testing::Bool(), testing::Bool())); | 7423 testing::Combine(testing::Bool(), testing::Bool())); |
| 7443 | 7424 |
| 7444 } // namespace | 7425 } // namespace |
| 7445 } // namespace cc | 7426 } // namespace cc |
| OLD | NEW |