Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(159)

Side by Side Diff: cc/trees/layer_tree_host_common_unittest.cc

Issue 12259027: cc: Simplify the logic for deciding to update tile priorities. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add early-out and unit test Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 gfx::Transform identity_matrix; 116 gfx::Transform identity_matrix;
117 LayerImplList dummy_render_surface_layer_list; 117 LayerImplList dummy_render_surface_layer_list;
118 int dummy_max_texture_size = 512; 118 int dummy_max_texture_size = 512;
119 gfx::Size device_viewport_size = 119 gfx::Size device_viewport_size =
120 gfx::Size(root_layer->bounds().width() * device_scale_factor, 120 gfx::Size(root_layer->bounds().width() * device_scale_factor,
121 root_layer->bounds().height() * device_scale_factor); 121 root_layer->bounds().height() * device_scale_factor);
122 122
123 // We are probably not testing what is intended if the root_layer bounds are 123 // We are probably not testing what is intended if the root_layer bounds are
124 // empty. 124 // empty.
125 DCHECK(!root_layer->bounds().IsEmpty()); 125 DCHECK(!root_layer->bounds().IsEmpty());
126 LayerTreeHostCommon::CalculateDrawProperties(root_layer, 126 LayerTreeHostCommon::CalculateDrawProperties(
127 device_viewport_size, 127 root_layer,
128 device_scale_factor, 128 device_viewport_size,
129 page_scale_factor, 129 device_scale_factor,
130 page_scale_application_layer, 130 page_scale_factor,
131 dummy_max_texture_size, 131 page_scale_application_layer,
132 can_use_lcd_text, 132 dummy_max_texture_size,
133 &dummy_render_surface_layer_list, 133 can_use_lcd_text,
134 false); 134 &dummy_render_surface_layer_list);
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 LayerType* page_scale_application_layer = NULL; 139 LayerType* page_scale_application_layer = NULL;
140 ExecuteCalculateDrawProperties( 140 ExecuteCalculateDrawProperties(
141 root_layer, 1.f, 1.f, page_scale_application_layer, false); 141 root_layer, 1.f, 1.f, page_scale_application_layer, false);
142 } 142 }
143 143
144 template <class LayerType> 144 template <class LayerType>
(...skipping 3974 matching lines...) Expand 10 before | Expand all | Expand 10 after
4119 4119
4120 LayerImplList render_surface_layer_list; 4120 LayerImplList render_surface_layer_list;
4121 int dummy_max_texture_size = 512; 4121 int dummy_max_texture_size = 512;
4122 LayerTreeHostCommon::CalculateDrawProperties(root.get(), 4122 LayerTreeHostCommon::CalculateDrawProperties(root.get(),
4123 root->bounds(), 4123 root->bounds(),
4124 1.f, 4124 1.f,
4125 1.f, 4125 1.f,
4126 NULL, 4126 NULL,
4127 dummy_max_texture_size, 4127 dummy_max_texture_size,
4128 false, 4128 false,
4129 &render_surface_layer_list, 4129 &render_surface_layer_list);
4130 false);
4131 4130
4132 // Sanity check the scenario we just created. 4131 // Sanity check the scenario we just created.
4133 ASSERT_EQ(1u, render_surface_layer_list.size()); 4132 ASSERT_EQ(1u, render_surface_layer_list.size());
4134 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); 4133 ASSERT_EQ(1u, root->render_surface()->layer_list().size());
4135 4134
4136 // Hit testing for a point outside the layer should return a null pointer. 4135 // Hit testing for a point outside the layer should return a null pointer.
4137 gfx::Point test_point(101, 101); 4136 gfx::Point test_point(101, 101);
4138 LayerImpl* result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( 4137 LayerImpl* result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(
4139 test_point, render_surface_layer_list); 4138 test_point, render_surface_layer_list);
4140 EXPECT_FALSE(result_layer); 4139 EXPECT_FALSE(result_layer);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
4195 4194
4196 LayerImplList render_surface_layer_list; 4195 LayerImplList render_surface_layer_list;
4197 int dummy_max_texture_size = 512; 4196 int dummy_max_texture_size = 512;
4198 LayerTreeHostCommon::CalculateDrawProperties(root.get(), 4197 LayerTreeHostCommon::CalculateDrawProperties(root.get(),
4199 hud_bounds, 4198 hud_bounds,
4200 1.f, 4199 1.f,
4201 1.f, 4200 1.f,
4202 NULL, 4201 NULL,
4203 dummy_max_texture_size, 4202 dummy_max_texture_size,
4204 false, 4203 false,
4205 &render_surface_layer_list, 4204 &render_surface_layer_list);
4206 false);
4207 4205
4208 // Sanity check the scenario we just created. 4206 // Sanity check the scenario we just created.
4209 ASSERT_EQ(1u, render_surface_layer_list.size()); 4207 ASSERT_EQ(1u, render_surface_layer_list.size());
4210 ASSERT_EQ(2u, root->render_surface()->layer_list().size()); 4208 ASSERT_EQ(2u, root->render_surface()->layer_list().size());
4211 4209
4212 // Hit testing for a point inside HUD, but outside root should return null 4210 // Hit testing for a point inside HUD, but outside root should return null
4213 gfx::Point test_point(101, 101); 4211 gfx::Point test_point(101, 101);
4214 LayerImpl* result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( 4212 LayerImpl* result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(
4215 test_point, render_surface_layer_list); 4213 test_point, render_surface_layer_list);
4216 EXPECT_FALSE(result_layer); 4214 EXPECT_FALSE(result_layer);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
4263 4261
4264 LayerImplList render_surface_layer_list; 4262 LayerImplList render_surface_layer_list;
4265 int dummy_max_texture_size = 512; 4263 int dummy_max_texture_size = 512;
4266 LayerTreeHostCommon::CalculateDrawProperties(root.get(), 4264 LayerTreeHostCommon::CalculateDrawProperties(root.get(),
4267 root->bounds(), 4265 root->bounds(),
4268 1.f, 4266 1.f,
4269 1.f, 4267 1.f,
4270 NULL, 4268 NULL,
4271 dummy_max_texture_size, 4269 dummy_max_texture_size,
4272 false, 4270 false,
4273 &render_surface_layer_list, 4271 &render_surface_layer_list);
4274 false);
4275 4272
4276 // Sanity check the scenario we just created. 4273 // Sanity check the scenario we just created.
4277 ASSERT_EQ(1u, render_surface_layer_list.size()); 4274 ASSERT_EQ(1u, render_surface_layer_list.size());
4278 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); 4275 ASSERT_EQ(1u, root->render_surface()->layer_list().size());
4279 ASSERT_FALSE(root->screen_space_transform().IsInvertible()); 4276 ASSERT_FALSE(root->screen_space_transform().IsInvertible());
4280 4277
4281 // Hit testing any point should not hit the layer. If the invertible matrix is 4278 // Hit testing any point should not hit the layer. If the invertible matrix is
4282 // accidentally ignored and treated like an identity, then the hit testing 4279 // accidentally ignored and treated like an identity, then the hit testing
4283 // will incorrectly hit the layer when it shouldn't. 4280 // will incorrectly hit the layer when it shouldn't.
4284 gfx::Point test_point(1, 1); 4281 gfx::Point test_point(1, 1);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
4340 4337
4341 LayerImplList render_surface_layer_list; 4338 LayerImplList render_surface_layer_list;
4342 int dummy_max_texture_size = 512; 4339 int dummy_max_texture_size = 512;
4343 LayerTreeHostCommon::CalculateDrawProperties(root.get(), 4340 LayerTreeHostCommon::CalculateDrawProperties(root.get(),
4344 root->bounds(), 4341 root->bounds(),
4345 1.f, 4342 1.f,
4346 1.f, 4343 1.f,
4347 NULL, 4344 NULL,
4348 dummy_max_texture_size, 4345 dummy_max_texture_size,
4349 false, 4346 false,
4350 &render_surface_layer_list, 4347 &render_surface_layer_list);
4351 false);
4352 4348
4353 // Sanity check the scenario we just created. 4349 // Sanity check the scenario we just created.
4354 ASSERT_EQ(1u, render_surface_layer_list.size()); 4350 ASSERT_EQ(1u, render_surface_layer_list.size());
4355 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); 4351 ASSERT_EQ(1u, root->render_surface()->layer_list().size());
4356 4352
4357 // Hit testing for a point outside the layer should return a null pointer. 4353 // Hit testing for a point outside the layer should return a null pointer.
4358 gfx::Point test_point(49, 49); 4354 gfx::Point test_point(49, 49);
4359 LayerImpl* result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( 4355 LayerImpl* result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(
4360 test_point, render_surface_layer_list); 4356 test_point, render_surface_layer_list);
4361 EXPECT_FALSE(result_layer); 4357 EXPECT_FALSE(result_layer);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
4406 4402
4407 LayerImplList render_surface_layer_list; 4403 LayerImplList render_surface_layer_list;
4408 int dummy_max_texture_size = 512; 4404 int dummy_max_texture_size = 512;
4409 LayerTreeHostCommon::CalculateDrawProperties(root.get(), 4405 LayerTreeHostCommon::CalculateDrawProperties(root.get(),
4410 root->bounds(), 4406 root->bounds(),
4411 1.f, 4407 1.f,
4412 1.f, 4408 1.f,
4413 NULL, 4409 NULL,
4414 dummy_max_texture_size, 4410 dummy_max_texture_size,
4415 false, 4411 false,
4416 &render_surface_layer_list, 4412 &render_surface_layer_list);
4417 false);
4418 4413
4419 // Sanity check the scenario we just created. 4414 // Sanity check the scenario we just created.
4420 ASSERT_EQ(1u, render_surface_layer_list.size()); 4415 ASSERT_EQ(1u, render_surface_layer_list.size());
4421 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); 4416 ASSERT_EQ(1u, root->render_surface()->layer_list().size());
4422 4417
4423 // Hit testing for points outside the layer. 4418 // Hit testing for points outside the layer.
4424 // These corners would have been inside the un-transformed layer, but they 4419 // These corners would have been inside the un-transformed layer, but they
4425 // should not hit the correctly transformed layer. 4420 // should not hit the correctly transformed layer.
4426 gfx::Point test_point(99, 99); 4421 gfx::Point test_point(99, 99);
4427 LayerImpl* result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( 4422 LayerImpl* result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
4485 4480
4486 LayerImplList render_surface_layer_list; 4481 LayerImplList render_surface_layer_list;
4487 int dummy_max_texture_size = 512; 4482 int dummy_max_texture_size = 512;
4488 LayerTreeHostCommon::CalculateDrawProperties(root.get(), 4483 LayerTreeHostCommon::CalculateDrawProperties(root.get(),
4489 root->bounds(), 4484 root->bounds(),
4490 1.f, 4485 1.f,
4491 1.f, 4486 1.f,
4492 NULL, 4487 NULL,
4493 dummy_max_texture_size, 4488 dummy_max_texture_size,
4494 false, 4489 false,
4495 &render_surface_layer_list, 4490 &render_surface_layer_list);
4496 false);
4497 4491
4498 // Sanity check the scenario we just created. 4492 // Sanity check the scenario we just created.
4499 ASSERT_EQ(1u, render_surface_layer_list.size()); 4493 ASSERT_EQ(1u, render_surface_layer_list.size());
4500 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); 4494 ASSERT_EQ(1u, root->render_surface()->layer_list().size());
4501 4495
4502 // Hit testing for points outside the layer. 4496 // Hit testing for points outside the layer.
4503 // These corners would have been inside the un-transformed layer, but they 4497 // These corners would have been inside the un-transformed layer, but they
4504 // should not hit the correctly transformed layer. 4498 // should not hit the correctly transformed layer.
4505 gfx::Point test_point(24, 24); 4499 gfx::Point test_point(24, 24);
4506 LayerImpl* result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( 4500 LayerImpl* result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
4575 4569
4576 LayerImplList render_surface_layer_list; 4570 LayerImplList render_surface_layer_list;
4577 int dummy_max_texture_size = 512; 4571 int dummy_max_texture_size = 512;
4578 LayerTreeHostCommon::CalculateDrawProperties(root.get(), 4572 LayerTreeHostCommon::CalculateDrawProperties(root.get(),
4579 root->bounds(), 4573 root->bounds(),
4580 1.f, 4574 1.f,
4581 1.f, 4575 1.f,
4582 NULL, 4576 NULL,
4583 dummy_max_texture_size, 4577 dummy_max_texture_size,
4584 false, 4578 false,
4585 &render_surface_layer_list, 4579 &render_surface_layer_list);
4586 false);
4587 4580
4588 // Sanity check the scenario we just created. 4581 // Sanity check the scenario we just created.
4589 // The visible content rect for test_layer is actually 100x100, even though 4582 // The visible content rect for test_layer is actually 100x100, even though
4590 // its layout size is 50x50, positioned at 25x25. 4583 // its layout size is 50x50, positioned at 25x25.
4591 LayerImpl* test_layer = root->children()[0]; 4584 LayerImpl* test_layer = root->children()[0];
4592 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), 4585 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100),
4593 test_layer->visible_content_rect()); 4586 test_layer->visible_content_rect());
4594 ASSERT_EQ(1u, render_surface_layer_list.size()); 4587 ASSERT_EQ(1u, render_surface_layer_list.size());
4595 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); 4588 ASSERT_EQ(1u, root->render_surface()->layer_list().size());
4596 4589
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
4676 4669
4677 LayerImplList render_surface_layer_list; 4670 LayerImplList render_surface_layer_list;
4678 int dummy_max_texture_size = 512; 4671 int dummy_max_texture_size = 512;
4679 LayerTreeHostCommon::CalculateDrawProperties(root.get(), 4672 LayerTreeHostCommon::CalculateDrawProperties(root.get(),
4680 root->bounds(), 4673 root->bounds(),
4681 1.f, 4674 1.f,
4682 1.f, 4675 1.f,
4683 NULL, 4676 NULL,
4684 dummy_max_texture_size, 4677 dummy_max_texture_size,
4685 false, 4678 false,
4686 &render_surface_layer_list, 4679 &render_surface_layer_list);
4687 false);
4688 4680
4689 // Sanity check the scenario we just created. 4681 // Sanity check the scenario we just created.
4690 ASSERT_EQ(1u, render_surface_layer_list.size()); 4682 ASSERT_EQ(1u, render_surface_layer_list.size());
4691 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); 4683 ASSERT_EQ(1u, root->render_surface()->layer_list().size());
4692 ASSERT_EQ(456, root->render_surface()->layer_list()[0]->id()); 4684 ASSERT_EQ(456, root->render_surface()->layer_list()[0]->id());
4693 4685
4694 // Hit testing for a point outside the layer should return a null pointer. 4686 // Hit testing for a point outside the layer should return a null pointer.
4695 // Despite the child layer being very large, it should be clipped to the root 4687 // Despite the child layer being very large, it should be clipped to the root
4696 // layer's bounds. 4688 // layer's bounds.
4697 gfx::Point test_point(24, 24); 4689 gfx::Point test_point(24, 24);
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
4810 4802
4811 LayerImplList render_surface_layer_list; 4803 LayerImplList render_surface_layer_list;
4812 int dummy_max_texture_size = 512; 4804 int dummy_max_texture_size = 512;
4813 LayerTreeHostCommon::CalculateDrawProperties(root.get(), 4805 LayerTreeHostCommon::CalculateDrawProperties(root.get(),
4814 root->bounds(), 4806 root->bounds(),
4815 1.f, 4807 1.f,
4816 1.f, 4808 1.f,
4817 NULL, 4809 NULL,
4818 dummy_max_texture_size, 4810 dummy_max_texture_size,
4819 false, 4811 false,
4820 &render_surface_layer_list, 4812 &render_surface_layer_list);
4821 false);
4822 4813
4823 // Sanity check the scenario we just created. 4814 // Sanity check the scenario we just created.
4824 // The grand_child is expected to create a render surface because it 4815 // The grand_child is expected to create a render surface because it
4825 // masksToBounds and is not axis aligned. 4816 // masksToBounds and is not axis aligned.
4826 ASSERT_EQ(2u, render_surface_layer_list.size()); 4817 ASSERT_EQ(2u, render_surface_layer_list.size());
4827 ASSERT_EQ( 4818 ASSERT_EQ(
4828 1u, render_surface_layer_list[0]->render_surface()->layer_list().size()); 4819 1u, render_surface_layer_list[0]->render_surface()->layer_list().size());
4829 ASSERT_EQ(789, 4820 ASSERT_EQ(789,
4830 render_surface_layer_list[0]->render_surface()->layer_list()[0] 4821 render_surface_layer_list[0]->render_surface()->layer_list()[0]
4831 ->id()); // grand_child's surface. 4822 ->id()); // grand_child's surface.
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
4937 4928
4938 LayerImplList render_surface_layer_list; 4929 LayerImplList render_surface_layer_list;
4939 int dummy_max_texture_size = 512; 4930 int dummy_max_texture_size = 512;
4940 LayerTreeHostCommon::CalculateDrawProperties(root.get(), 4931 LayerTreeHostCommon::CalculateDrawProperties(root.get(),
4941 root->bounds(), 4932 root->bounds(),
4942 1.f, 4933 1.f,
4943 1.f, 4934 1.f,
4944 NULL, 4935 NULL,
4945 dummy_max_texture_size, 4936 dummy_max_texture_size,
4946 false, 4937 false,
4947 &render_surface_layer_list, 4938 &render_surface_layer_list);
4948 false);
4949 4939
4950 // Sanity check the scenario we just created. 4940 // Sanity check the scenario we just created.
4951 ASSERT_EQ(1u, render_surface_layer_list.size()); 4941 ASSERT_EQ(1u, render_surface_layer_list.size());
4952 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); 4942 ASSERT_EQ(1u, root->render_surface()->layer_list().size());
4953 ASSERT_EQ(456, root->render_surface()->layer_list()[0]->id()); 4943 ASSERT_EQ(456, root->render_surface()->layer_list()[0]->id());
4954 4944
4955 // Hit testing for a point outside the layer should return a null pointer. 4945 // Hit testing for a point outside the layer should return a null pointer.
4956 gfx::Point test_point(69, 69); 4946 gfx::Point test_point(69, 69);
4957 LayerImpl* result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( 4947 LayerImpl* result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(
4958 test_point, render_surface_layer_list); 4948 test_point, render_surface_layer_list);
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
5055 5045
5056 LayerImplList render_surface_layer_list; 5046 LayerImplList render_surface_layer_list;
5057 int dummy_max_texture_size = 512; 5047 int dummy_max_texture_size = 512;
5058 LayerTreeHostCommon::CalculateDrawProperties(root.get(), 5048 LayerTreeHostCommon::CalculateDrawProperties(root.get(),
5059 root->bounds(), 5049 root->bounds(),
5060 1.f, 5050 1.f,
5061 1.f, 5051 1.f,
5062 NULL, 5052 NULL,
5063 dummy_max_texture_size, 5053 dummy_max_texture_size,
5064 false, 5054 false,
5065 &render_surface_layer_list, 5055 &render_surface_layer_list);
5066 false);
5067 5056
5068 // Sanity check the scenario we just created. 5057 // Sanity check the scenario we just created.
5069 ASSERT_TRUE(child1); 5058 ASSERT_TRUE(child1);
5070 ASSERT_TRUE(child2); 5059 ASSERT_TRUE(child2);
5071 ASSERT_TRUE(grand_child1); 5060 ASSERT_TRUE(grand_child1);
5072 ASSERT_EQ(1u, render_surface_layer_list.size()); 5061 ASSERT_EQ(1u, render_surface_layer_list.size());
5073 ASSERT_EQ(4u, root->render_surface()->layer_list().size()); 5062 ASSERT_EQ(4u, root->render_surface()->layer_list().size());
5074 ASSERT_EQ(1, root->render_surface()->layer_list()[0]->id()); // root layer 5063 ASSERT_EQ(1, root->render_surface()->layer_list()[0]->id()); // root layer
5075 ASSERT_EQ(2, root->render_surface()->layer_list()[1]->id()); // child1 5064 ASSERT_EQ(2, root->render_surface()->layer_list()[1]->id()); // child1
5076 ASSERT_EQ(4, root->render_surface()->layer_list()[2]->id()); // grand_child1 5065 ASSERT_EQ(4, root->render_surface()->layer_list()[2]->id()); // grand_child1
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
5209 5198
5210 LayerImplList render_surface_layer_list; 5199 LayerImplList render_surface_layer_list;
5211 int dummy_max_texture_size = 512; 5200 int dummy_max_texture_size = 512;
5212 LayerTreeHostCommon::CalculateDrawProperties(root.get(), 5201 LayerTreeHostCommon::CalculateDrawProperties(root.get(),
5213 root->bounds(), 5202 root->bounds(),
5214 1.f, 5203 1.f,
5215 1.f, 5204 1.f,
5216 NULL, 5205 NULL,
5217 dummy_max_texture_size, 5206 dummy_max_texture_size,
5218 false, 5207 false,
5219 &render_surface_layer_list, 5208 &render_surface_layer_list);
5220 false);
5221 5209
5222 // Sanity check the scenario we just created. 5210 // Sanity check the scenario we just created.
5223 ASSERT_TRUE(child1); 5211 ASSERT_TRUE(child1);
5224 ASSERT_TRUE(child2); 5212 ASSERT_TRUE(child2);
5225 ASSERT_TRUE(grand_child1); 5213 ASSERT_TRUE(grand_child1);
5226 ASSERT_TRUE(child1->render_surface()); 5214 ASSERT_TRUE(child1->render_surface());
5227 ASSERT_TRUE(child2->render_surface()); 5215 ASSERT_TRUE(child2->render_surface());
5228 ASSERT_TRUE(grand_child1->render_surface()); 5216 ASSERT_TRUE(grand_child1->render_surface());
5229 ASSERT_EQ(4u, render_surface_layer_list.size()); 5217 ASSERT_EQ(4u, render_surface_layer_list.size());
5230 // The root surface has the root layer, and child1's and child2's render 5218 // The root surface has the root layer, and child1's and child2's render
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
5327 5315
5328 LayerImplList render_surface_layer_list; 5316 LayerImplList render_surface_layer_list;
5329 int dummy_max_texture_size = 512; 5317 int dummy_max_texture_size = 512;
5330 LayerTreeHostCommon::CalculateDrawProperties(root.get(), 5318 LayerTreeHostCommon::CalculateDrawProperties(root.get(),
5331 root->bounds(), 5319 root->bounds(),
5332 1.f, 5320 1.f,
5333 1.f, 5321 1.f,
5334 NULL, 5322 NULL,
5335 dummy_max_texture_size, 5323 dummy_max_texture_size,
5336 false, 5324 false,
5337 &render_surface_layer_list, 5325 &render_surface_layer_list);
5338 false);
5339 5326
5340 // Sanity check the scenario we just created. 5327 // Sanity check the scenario we just created.
5341 ASSERT_EQ(1u, render_surface_layer_list.size()); 5328 ASSERT_EQ(1u, render_surface_layer_list.size());
5342 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); 5329 ASSERT_EQ(1u, root->render_surface()->layer_list().size());
5343 5330
5344 // Hit checking for any point should return a null pointer for a layer without 5331 // Hit checking for any point should return a null pointer for a layer without
5345 // any touch event handler regions. 5332 // any touch event handler regions.
5346 gfx::Point test_point(11, 11); 5333 gfx::Point test_point(11, 11);
5347 LayerImpl* result_layer = 5334 LayerImpl* result_layer =
5348 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( 5335 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion(
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
5425 5412
5426 LayerImplList render_surface_layer_list; 5413 LayerImplList render_surface_layer_list;
5427 int dummy_max_texture_size = 512; 5414 int dummy_max_texture_size = 512;
5428 LayerTreeHostCommon::CalculateDrawProperties(root.get(), 5415 LayerTreeHostCommon::CalculateDrawProperties(root.get(),
5429 root->bounds(), 5416 root->bounds(),
5430 1.f, 5417 1.f,
5431 1.f, 5418 1.f,
5432 NULL, 5419 NULL,
5433 dummy_max_texture_size, 5420 dummy_max_texture_size,
5434 false, 5421 false,
5435 &render_surface_layer_list, 5422 &render_surface_layer_list);
5436 false);
5437 5423
5438 // Sanity check the scenario we just created. 5424 // Sanity check the scenario we just created.
5439 ASSERT_EQ(1u, render_surface_layer_list.size()); 5425 ASSERT_EQ(1u, render_surface_layer_list.size());
5440 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); 5426 ASSERT_EQ(1u, root->render_surface()->layer_list().size());
5441 ASSERT_FALSE(root->screen_space_transform().IsInvertible()); 5427 ASSERT_FALSE(root->screen_space_transform().IsInvertible());
5442 5428
5443 // Hit checking any point should not hit the touch handler region on the 5429 // Hit checking any point should not hit the touch handler region on the
5444 // layer. If the invertible matrix is accidentally ignored and treated like an 5430 // layer. If the invertible matrix is accidentally ignored and treated like an
5445 // identity, then the hit testing will incorrectly hit the layer when it 5431 // identity, then the hit testing will incorrectly hit the layer when it
5446 // shouldn't. 5432 // shouldn't.
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
5513 5499
5514 LayerImplList render_surface_layer_list; 5500 LayerImplList render_surface_layer_list;
5515 int dummy_max_texture_size = 512; 5501 int dummy_max_texture_size = 512;
5516 LayerTreeHostCommon::CalculateDrawProperties(root.get(), 5502 LayerTreeHostCommon::CalculateDrawProperties(root.get(),
5517 root->bounds(), 5503 root->bounds(),
5518 1.f, 5504 1.f,
5519 1.f, 5505 1.f,
5520 NULL, 5506 NULL,
5521 dummy_max_texture_size, 5507 dummy_max_texture_size,
5522 false, 5508 false,
5523 &render_surface_layer_list, 5509 &render_surface_layer_list);
5524 false);
5525 5510
5526 // Sanity check the scenario we just created. 5511 // Sanity check the scenario we just created.
5527 ASSERT_EQ(1u, render_surface_layer_list.size()); 5512 ASSERT_EQ(1u, render_surface_layer_list.size());
5528 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); 5513 ASSERT_EQ(1u, root->render_surface()->layer_list().size());
5529 5514
5530 // Hit checking for a point outside the layer should return a null pointer. 5515 // Hit checking for a point outside the layer should return a null pointer.
5531 gfx::Point test_point(49, 49); 5516 gfx::Point test_point(49, 49);
5532 LayerImpl* result_layer = 5517 LayerImpl* result_layer =
5533 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( 5518 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion(
5534 test_point, render_surface_layer_list); 5519 test_point, render_surface_layer_list);
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
5619 5604
5620 LayerImplList render_surface_layer_list; 5605 LayerImplList render_surface_layer_list;
5621 int dummy_max_texture_size = 512; 5606 int dummy_max_texture_size = 512;
5622 LayerTreeHostCommon::CalculateDrawProperties(root.get(), 5607 LayerTreeHostCommon::CalculateDrawProperties(root.get(),
5623 root->bounds(), 5608 root->bounds(),
5624 1.f, 5609 1.f,
5625 1.f, 5610 1.f,
5626 NULL, 5611 NULL,
5627 dummy_max_texture_size, 5612 dummy_max_texture_size,
5628 false, 5613 false,
5629 &render_surface_layer_list, 5614 &render_surface_layer_list);
5630 false);
5631 5615
5632 // Sanity check the scenario we just created. 5616 // Sanity check the scenario we just created.
5633 // The visible content rect for test_layer is actually 100x100, even though 5617 // The visible content rect for test_layer is actually 100x100, even though
5634 // its layout size is 50x50, positioned at 25x25. 5618 // its layout size is 50x50, positioned at 25x25.
5635 LayerImpl* test_layer = root->children()[0]; 5619 LayerImpl* test_layer = root->children()[0];
5636 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), test_layer->visible_content_rect()); 5620 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), test_layer->visible_content_rect());
5637 ASSERT_EQ(1u, render_surface_layer_list.size()); 5621 ASSERT_EQ(1u, render_surface_layer_list.size());
5638 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); 5622 ASSERT_EQ(1u, root->render_surface()->layer_list().size());
5639 5623
5640 // Hit checking for a point outside the layer should return a null pointer 5624 // Hit checking for a point outside the layer should return a null pointer
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
5732 float page_scale_factor = 5.f; 5716 float page_scale_factor = 5.f;
5733 gfx::Size scaled_bounds_for_root = gfx::ToCeiledSize( 5717 gfx::Size scaled_bounds_for_root = gfx::ToCeiledSize(
5734 gfx::ScaleSize(root->bounds(), device_scale_factor * page_scale_factor)); 5718 gfx::ScaleSize(root->bounds(), device_scale_factor * page_scale_factor));
5735 LayerTreeHostCommon::CalculateDrawProperties(root.get(), 5719 LayerTreeHostCommon::CalculateDrawProperties(root.get(),
5736 scaled_bounds_for_root, 5720 scaled_bounds_for_root,
5737 device_scale_factor, 5721 device_scale_factor,
5738 page_scale_factor, 5722 page_scale_factor,
5739 root.get(), 5723 root.get(),
5740 dummy_max_texture_size, 5724 dummy_max_texture_size,
5741 false, 5725 false,
5742 &render_surface_layer_list, 5726 &render_surface_layer_list);
5743 false);
5744 5727
5745 // Sanity check the scenario we just created. 5728 // Sanity check the scenario we just created.
5746 // The visible content rect for test_layer is actually 100x100, even though 5729 // The visible content rect for test_layer is actually 100x100, even though
5747 // its layout size is 50x50, positioned at 25x25. 5730 // its layout size is 50x50, positioned at 25x25.
5748 LayerImpl* test_layer = root->children()[0]; 5731 LayerImpl* test_layer = root->children()[0];
5749 ASSERT_EQ(1u, render_surface_layer_list.size()); 5732 ASSERT_EQ(1u, render_surface_layer_list.size());
5750 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); 5733 ASSERT_EQ(1u, root->render_surface()->layer_list().size());
5751 5734
5752 // Check whether the child layer fits into the root after scaled. 5735 // Check whether the child layer fits into the root after scaled.
5753 EXPECT_RECT_EQ(gfx::Rect(test_layer->content_bounds()), 5736 EXPECT_RECT_EQ(gfx::Rect(test_layer->content_bounds()),
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
5872 5855
5873 LayerImplList render_surface_layer_list; 5856 LayerImplList render_surface_layer_list;
5874 int dummy_max_texture_size = 512; 5857 int dummy_max_texture_size = 512;
5875 LayerTreeHostCommon::CalculateDrawProperties(root.get(), 5858 LayerTreeHostCommon::CalculateDrawProperties(root.get(),
5876 root->bounds(), 5859 root->bounds(),
5877 1.f, 5860 1.f,
5878 1.f, 5861 1.f,
5879 NULL, 5862 NULL,
5880 dummy_max_texture_size, 5863 dummy_max_texture_size,
5881 false, 5864 false,
5882 &render_surface_layer_list, 5865 &render_surface_layer_list);
5883 false);
5884 5866
5885 // Sanity check the scenario we just created. 5867 // Sanity check the scenario we just created.
5886 ASSERT_EQ(1u, render_surface_layer_list.size()); 5868 ASSERT_EQ(1u, render_surface_layer_list.size());
5887 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); 5869 ASSERT_EQ(1u, root->render_surface()->layer_list().size());
5888 ASSERT_EQ(456, root->render_surface()->layer_list()[0]->id()); 5870 ASSERT_EQ(456, root->render_surface()->layer_list()[0]->id());
5889 5871
5890 // Hit checking for a point outside the layer should return a null pointer. 5872 // Hit checking for a point outside the layer should return a null pointer.
5891 // Despite the child layer being very large, it should be clipped to the root 5873 // Despite the child layer being very large, it should be clipped to the root
5892 // layer's bounds. 5874 // layer's bounds.
5893 gfx::Point test_point(24, 24); 5875 gfx::Point test_point(24, 24);
(...skipping 1423 matching lines...) Expand 10 before | Expand all | Expand 10 after
7317 7299
7318 std::vector<LayerImpl*> render_surface_layer_list; 7300 std::vector<LayerImpl*> render_surface_layer_list;
7319 int dummy_max_texture_size = 512; 7301 int dummy_max_texture_size = 512;
7320 LayerTreeHostCommon::CalculateDrawProperties(root.get(), 7302 LayerTreeHostCommon::CalculateDrawProperties(root.get(),
7321 root->bounds(), 7303 root->bounds(),
7322 1.f, 7304 1.f,
7323 1.f, 7305 1.f,
7324 NULL, 7306 NULL,
7325 dummy_max_texture_size, 7307 dummy_max_texture_size,
7326 false, 7308 false,
7327 &render_surface_layer_list, 7309 &render_surface_layer_list);
7328 false);
7329 7310
7330 // We should have one render surface and two layers. The child 7311 // We should have one render surface and two layers. The child
7331 // layer should be included even though it is transparent. 7312 // layer should be included even though it is transparent.
7332 ASSERT_EQ(1u, render_surface_layer_list.size()); 7313 ASSERT_EQ(1u, render_surface_layer_list.size());
7333 ASSERT_EQ(2u, root->render_surface()->layer_list().size()); 7314 ASSERT_EQ(2u, root->render_surface()->layer_list().size());
7334 } 7315 }
7335 7316
7336 typedef std::tr1::tuple<bool, bool> LCDTextTestParam; 7317 typedef std::tr1::tuple<bool, bool> LCDTextTestParam;
7337 class LCDTextTest : public testing::TestWithParam<LCDTextTestParam> { 7318 class LCDTextTest : public testing::TestWithParam<LCDTextTestParam> {
7338 protected: 7319 protected:
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
7466 EXPECT_EQ(can_use_lcd_text_, child_->can_use_lcd_text()); 7447 EXPECT_EQ(can_use_lcd_text_, child_->can_use_lcd_text());
7467 EXPECT_EQ(can_use_lcd_text_, grand_child_->can_use_lcd_text()); 7448 EXPECT_EQ(can_use_lcd_text_, grand_child_->can_use_lcd_text());
7468 } 7449 }
7469 7450
7470 INSTANTIATE_TEST_CASE_P(LayerTreeHostCommonTest, 7451 INSTANTIATE_TEST_CASE_P(LayerTreeHostCommonTest,
7471 LCDTextTest, 7452 LCDTextTest,
7472 testing::Combine(testing::Bool(), testing::Bool())); 7453 testing::Combine(testing::Bool(), testing::Bool()));
7473 7454
7474 } // namespace 7455 } // namespace
7475 } // namespace cc 7456 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698