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

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

Issue 2179263002: cc: Remove SetLayerPropertiesForTesting from LayerTreeHostCommonTestBase (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lthcommontest-harness
Patch Set: lthcommontest-harness2: rebase Created 4 years, 5 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
« no previous file with comments | « cc/trees/layer_tree_host_common_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 TestTaskGraphRunner task_graph_runner_; 61 TestTaskGraphRunner task_graph_runner_;
62 FakeImplTaskRunnerProvider task_runner_provider_; 62 FakeImplTaskRunnerProvider task_runner_provider_;
63 std::unique_ptr<OutputSurface> output_surface_; 63 std::unique_ptr<OutputSurface> output_surface_;
64 std::unique_ptr<FakeLayerTreeHostImpl> host_impl_; 64 std::unique_ptr<FakeLayerTreeHostImpl> host_impl_;
65 }; 65 };
66 66
67 TEST_F(LayerTreeImplTest, HitTestingForSingleLayer) { 67 TEST_F(LayerTreeImplTest, HitTestingForSingleLayer) {
68 std::unique_ptr<LayerImpl> root = 68 std::unique_ptr<LayerImpl> root =
69 LayerImpl::Create(host_impl().active_tree(), 12345); 69 LayerImpl::Create(host_impl().active_tree(), 12345);
70 70
71 gfx::Transform identity_matrix;
72 gfx::Point3F transform_origin;
73 gfx::PointF position;
74 gfx::Size bounds(100, 100); 71 gfx::Size bounds(100, 100);
75 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, 72 root->SetBounds(bounds);
76 position, bounds, true, false, true);
77 root->SetDrawsContent(true); 73 root->SetDrawsContent(true);
78 74
79 host_impl().SetViewportSize(root->bounds()); 75 host_impl().SetViewportSize(root->bounds());
80 host_impl().active_tree()->SetRootLayerForTesting(std::move(root)); 76 host_impl().active_tree()->SetRootLayerForTesting(std::move(root));
81 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); 77 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
82 78
83 // Sanity check the scenario we just created. 79 // Sanity check the scenario we just created.
84 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); 80 ASSERT_EQ(1u, RenderSurfaceLayerList().size());
85 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); 81 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size());
86 82
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 FakeOutputSurface::CreateDelegating3d(); 117 FakeOutputSurface::CreateDelegating3d();
122 std::unique_ptr<FakeLayerTreeHostImpl> host_impl; 118 std::unique_ptr<FakeLayerTreeHostImpl> host_impl;
123 host_impl.reset(new FakeLayerTreeHostImpl(settings, &task_runner_provider, 119 host_impl.reset(new FakeLayerTreeHostImpl(settings, &task_runner_provider,
124 &shared_bitmap_manager, 120 &shared_bitmap_manager,
125 &task_graph_runner)); 121 &task_graph_runner));
126 host_impl->SetVisible(true); 122 host_impl->SetVisible(true);
127 EXPECT_TRUE(host_impl->InitializeRenderer(output_surface.get())); 123 EXPECT_TRUE(host_impl->InitializeRenderer(output_surface.get()));
128 std::unique_ptr<LayerImpl> root = 124 std::unique_ptr<LayerImpl> root =
129 LayerImpl::Create(host_impl->active_tree(), 12345); 125 LayerImpl::Create(host_impl->active_tree(), 12345);
130 126
131 gfx::Transform identity_matrix;
132 gfx::Point3F transform_origin;
133 gfx::PointF position;
134 gfx::Size bounds(100, 100); 127 gfx::Size bounds(100, 100);
135 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, 128 root->SetBounds(bounds);
136 position, bounds, true, false, true);
137 root->SetDrawsContent(true); 129 root->SetDrawsContent(true);
138 130
139 host_impl->SetViewportSize(root->bounds()); 131 host_impl->SetViewportSize(root->bounds());
140 host_impl->active_tree()->SetRootLayerForTesting(std::move(root)); 132 host_impl->active_tree()->SetRootLayerForTesting(std::move(root));
141 host_impl->UpdateNumChildrenAndDrawPropertiesForActiveTree(); 133 host_impl->UpdateNumChildrenAndDrawPropertiesForActiveTree();
142 EXPECT_EQ( 134 EXPECT_EQ(
143 gfx::RectF(gfx::SizeF(bounds)), 135 gfx::RectF(gfx::SizeF(bounds)),
144 host_impl->active_tree()->property_trees()->clip_tree.ViewportClip()); 136 host_impl->active_tree()->property_trees()->clip_tree.ViewportClip());
145 EXPECT_EQ( 137 EXPECT_EQ(
146 gfx::Rect(bounds), 138 gfx::Rect(bounds),
(...skipping 10 matching lines...) Expand all
157 gfx::Rect(new_bounds), 149 gfx::Rect(new_bounds),
158 host_impl->active_tree()->root_layer_for_testing()->visible_layer_rect()); 150 host_impl->active_tree()->root_layer_for_testing()->visible_layer_rect());
159 } 151 }
160 152
161 TEST_F(LayerTreeImplTest, HitTestingForSingleLayerAndHud) { 153 TEST_F(LayerTreeImplTest, HitTestingForSingleLayerAndHud) {
162 std::unique_ptr<LayerImpl> root = 154 std::unique_ptr<LayerImpl> root =
163 LayerImpl::Create(host_impl().active_tree(), 12345); 155 LayerImpl::Create(host_impl().active_tree(), 12345);
164 std::unique_ptr<HeadsUpDisplayLayerImpl> hud = 156 std::unique_ptr<HeadsUpDisplayLayerImpl> hud =
165 HeadsUpDisplayLayerImpl::Create(host_impl().active_tree(), 11111); 157 HeadsUpDisplayLayerImpl::Create(host_impl().active_tree(), 11111);
166 158
167 gfx::Transform identity_matrix; 159 root->SetBounds(gfx::Size(100, 100));
168 gfx::Point3F transform_origin;
169 gfx::PointF position;
170 gfx::Size bounds(100, 100);
171 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin,
172 position, bounds, true, false, true);
173 root->SetDrawsContent(true); 160 root->SetDrawsContent(true);
174 161
175 // Create hud and add it as a child of root. 162 // Create hud and add it as a child of root.
176 gfx::Size hud_bounds(200, 200); 163 hud->SetBounds(gfx::Size(200, 200));
177 SetLayerPropertiesForTesting(hud.get(), identity_matrix, transform_origin,
178 position, hud_bounds, true, false, false);
179 hud->SetDrawsContent(true); 164 hud->SetDrawsContent(true);
180 165
166 host_impl().SetViewportSize(hud->bounds());
181 host_impl().active_tree()->set_hud_layer(hud.get()); 167 host_impl().active_tree()->set_hud_layer(hud.get());
182 root->test_properties()->AddChild(std::move(hud)); 168 root->test_properties()->AddChild(std::move(hud));
183
184 host_impl().SetViewportSize(hud_bounds);
185 host_impl().active_tree()->SetRootLayerForTesting(std::move(root)); 169 host_impl().active_tree()->SetRootLayerForTesting(std::move(root));
186 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); 170 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
187 171
188 // Sanity check the scenario we just created. 172 // Sanity check the scenario we just created.
189 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); 173 ASSERT_EQ(1u, RenderSurfaceLayerList().size());
190 ASSERT_EQ(2u, root_layer()->render_surface()->layer_list().size()); 174 ASSERT_EQ(2u, root_layer()->render_surface()->layer_list().size());
191 175
192 // Hit testing for a point inside HUD, but outside root should return null 176 // Hit testing for a point inside HUD, but outside root should return null
193 gfx::PointF test_point(101.f, 101.f); 177 gfx::PointF test_point(101.f, 101.f);
194 LayerImpl* result_layer = 178 LayerImpl* result_layer =
(...skipping 24 matching lines...) Expand all
219 std::unique_ptr<LayerImpl> root = 203 std::unique_ptr<LayerImpl> root =
220 LayerImpl::Create(host_impl().active_tree(), 12345); 204 LayerImpl::Create(host_impl().active_tree(), 12345);
221 205
222 gfx::Transform uninvertible_transform; 206 gfx::Transform uninvertible_transform;
223 uninvertible_transform.matrix().set(0, 0, 0.0); 207 uninvertible_transform.matrix().set(0, 0, 0.0);
224 uninvertible_transform.matrix().set(1, 1, 0.0); 208 uninvertible_transform.matrix().set(1, 1, 0.0);
225 uninvertible_transform.matrix().set(2, 2, 0.0); 209 uninvertible_transform.matrix().set(2, 2, 0.0);
226 uninvertible_transform.matrix().set(3, 3, 0.0); 210 uninvertible_transform.matrix().set(3, 3, 0.0);
227 ASSERT_FALSE(uninvertible_transform.IsInvertible()); 211 ASSERT_FALSE(uninvertible_transform.IsInvertible());
228 212
229 gfx::Transform identity_matrix; 213 root->SetTransform(uninvertible_transform);
230 gfx::Point3F transform_origin; 214 root->SetBounds(gfx::Size(100, 100));
231 gfx::PointF position;
232 gfx::Size bounds(100, 100);
233 SetLayerPropertiesForTesting(root.get(), uninvertible_transform,
234 transform_origin, position, bounds, true, false,
235 true);
236 root->SetDrawsContent(true); 215 root->SetDrawsContent(true);
237 216
238 host_impl().SetViewportSize(root->bounds()); 217 host_impl().SetViewportSize(root->bounds());
239 host_impl().active_tree()->SetRootLayerForTesting(std::move(root)); 218 host_impl().active_tree()->SetRootLayerForTesting(std::move(root));
240 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); 219 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
241 // Sanity check the scenario we just created. 220 // Sanity check the scenario we just created.
242 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); 221 ASSERT_EQ(1u, RenderSurfaceLayerList().size());
243 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); 222 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size());
244 ASSERT_FALSE(root_layer()->ScreenSpaceTransform().IsInvertible()); 223 ASSERT_FALSE(root_layer()->ScreenSpaceTransform().IsInvertible());
245 224
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 test_point = gfx::PointF(-1.f, -1.f); 258 test_point = gfx::PointF(-1.f, -1.f);
280 result_layer = 259 result_layer =
281 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); 260 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point);
282 EXPECT_FALSE(result_layer); 261 EXPECT_FALSE(result_layer);
283 } 262 }
284 263
285 TEST_F(LayerTreeImplTest, HitTestingForSinglePositionedLayer) { 264 TEST_F(LayerTreeImplTest, HitTestingForSinglePositionedLayer) {
286 std::unique_ptr<LayerImpl> root = 265 std::unique_ptr<LayerImpl> root =
287 LayerImpl::Create(host_impl().active_tree(), 12345); 266 LayerImpl::Create(host_impl().active_tree(), 12345);
288 267
289 gfx::Transform identity_matrix; 268 // This layer is positioned, and hit testing should correctly know where the
290 gfx::Point3F transform_origin;
291 // this layer is positioned, and hit testing should correctly know where the
292 // layer is located. 269 // layer is located.
293 gfx::PointF position(50.f, 50.f); 270 root->SetPosition(gfx::PointF(50.f, 50.f));
294 gfx::Size bounds(100, 100); 271 root->SetBounds(gfx::Size(100, 100));
295 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin,
296 position, bounds, true, false, true);
297 root->SetDrawsContent(true); 272 root->SetDrawsContent(true);
298 273
299 host_impl().SetViewportSize(root->bounds()); 274 host_impl().SetViewportSize(root->bounds());
300 host_impl().active_tree()->SetRootLayerForTesting(std::move(root)); 275 host_impl().active_tree()->SetRootLayerForTesting(std::move(root));
301 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); 276 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
302 277
303 // Sanity check the scenario we just created. 278 // Sanity check the scenario we just created.
304 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); 279 ASSERT_EQ(1u, RenderSurfaceLayerList().size());
305 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); 280 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size());
306 281
(...skipping 21 matching lines...) Expand all
328 result_layer = 303 result_layer =
329 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); 304 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point);
330 ASSERT_TRUE(result_layer); 305 ASSERT_TRUE(result_layer);
331 EXPECT_EQ(12345, result_layer->id()); 306 EXPECT_EQ(12345, result_layer->id());
332 } 307 }
333 308
334 TEST_F(LayerTreeImplTest, HitTestingForSingleRotatedLayer) { 309 TEST_F(LayerTreeImplTest, HitTestingForSingleRotatedLayer) {
335 std::unique_ptr<LayerImpl> root = 310 std::unique_ptr<LayerImpl> root =
336 LayerImpl::Create(host_impl().active_tree(), 12345); 311 LayerImpl::Create(host_impl().active_tree(), 12345);
337 312
338 gfx::Transform identity_matrix;
339 gfx::Transform rotation45_degrees_about_center; 313 gfx::Transform rotation45_degrees_about_center;
340 rotation45_degrees_about_center.Translate(50.0, 50.0); 314 rotation45_degrees_about_center.Translate(50.0, 50.0);
341 rotation45_degrees_about_center.RotateAboutZAxis(45.0); 315 rotation45_degrees_about_center.RotateAboutZAxis(45.0);
342 rotation45_degrees_about_center.Translate(-50.0, -50.0); 316 rotation45_degrees_about_center.Translate(-50.0, -50.0);
343 gfx::Point3F transform_origin; 317
344 gfx::PointF position; 318 root->SetTransform(rotation45_degrees_about_center);
345 gfx::Size bounds(100, 100); 319 root->SetBounds(gfx::Size(100, 100));
346 SetLayerPropertiesForTesting(root.get(), rotation45_degrees_about_center,
347 transform_origin, position, bounds, true, false,
348 true);
349 root->SetDrawsContent(true); 320 root->SetDrawsContent(true);
350 321
351 host_impl().SetViewportSize(root->bounds()); 322 host_impl().SetViewportSize(root->bounds());
352 host_impl().active_tree()->SetRootLayerForTesting(std::move(root)); 323 host_impl().active_tree()->SetRootLayerForTesting(std::move(root));
353 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); 324 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
354 325
355 // Sanity check the scenario we just created. 326 // Sanity check the scenario we just created.
356 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); 327 ASSERT_EQ(1u, RenderSurfaceLayerList().size());
357 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); 328 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size());
358 329
(...skipping 26 matching lines...) Expand all
385 356
386 test_point = gfx::PointF(-1.f, 50.f); 357 test_point = gfx::PointF(-1.f, 50.f);
387 result_layer = 358 result_layer =
388 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); 359 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point);
389 ASSERT_FALSE(result_layer); 360 ASSERT_FALSE(result_layer);
390 } 361 }
391 362
392 TEST_F(LayerTreeImplTest, HitTestingClipNodeDifferentTransformAndTargetIds) { 363 TEST_F(LayerTreeImplTest, HitTestingClipNodeDifferentTransformAndTargetIds) {
393 // Tests hit testing on a layer whose clip node has different transform and 364 // Tests hit testing on a layer whose clip node has different transform and
394 // target id. 365 // target id.
395 gfx::Transform identity_matrix;
396 std::unique_ptr<LayerImpl> root = 366 std::unique_ptr<LayerImpl> root =
397 LayerImpl::Create(host_impl().active_tree(), 1); 367 LayerImpl::Create(host_impl().active_tree(), 1);
398 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), 368 root->SetBounds(gfx::Size(500, 500));
399 gfx::PointF(), gfx::Size(500, 500), true, false, 369
400 true);
401 gfx::Transform translation; 370 gfx::Transform translation;
402 translation.Translate(100, 100); 371 translation.Translate(100, 100);
403 std::unique_ptr<LayerImpl> render_surface = 372 std::unique_ptr<LayerImpl> render_surface =
404 LayerImpl::Create(host_impl().active_tree(), 2); 373 LayerImpl::Create(host_impl().active_tree(), 2);
405 SetLayerPropertiesForTesting(render_surface.get(), translation, 374 render_surface->SetTransform(translation);
406 gfx::Point3F(), gfx::PointF(), 375 render_surface->SetBounds(gfx::Size(100, 100));
407 gfx::Size(100, 100), true, false, true); 376 render_surface->test_properties()->force_render_surface = true;
408 377
409 gfx::Transform scale_matrix; 378 gfx::Transform scale_matrix;
410 scale_matrix.Scale(2, 2); 379 scale_matrix.Scale(2, 2);
411 std::unique_ptr<LayerImpl> scale = 380 std::unique_ptr<LayerImpl> scale =
412 LayerImpl::Create(host_impl().active_tree(), 3); 381 LayerImpl::Create(host_impl().active_tree(), 3);
413 SetLayerPropertiesForTesting(scale.get(), scale_matrix, gfx::Point3F(), 382 scale->SetTransform(scale_matrix);
414 gfx::PointF(), gfx::Size(50, 50), true, false, 383 scale->SetBounds(gfx::Size(50, 50));
415 false);
416 384
417 std::unique_ptr<LayerImpl> clip = 385 std::unique_ptr<LayerImpl> clip =
418 LayerImpl::Create(host_impl().active_tree(), 4); 386 LayerImpl::Create(host_impl().active_tree(), 4);
419 SetLayerPropertiesForTesting(clip.get(), identity_matrix, gfx::Point3F(), 387 clip->SetBounds(gfx::Size(25, 25));
420 gfx::PointF(), gfx::Size(25, 25), true, false,
421 false);
422 clip->SetMasksToBounds(true); 388 clip->SetMasksToBounds(true);
423 389
424 std::unique_ptr<LayerImpl> test = 390 std::unique_ptr<LayerImpl> test =
425 LayerImpl::Create(host_impl().active_tree(), 5); 391 LayerImpl::Create(host_impl().active_tree(), 5);
426 SetLayerPropertiesForTesting(test.get(), identity_matrix, gfx::Point3F(), 392 test->SetBounds(gfx::Size(100, 100));
427 gfx::PointF(), gfx::Size(100, 100), true, false,
428 false);
429 test->SetDrawsContent(true); 393 test->SetDrawsContent(true);
430 394
431 clip->test_properties()->AddChild(std::move(test)); 395 clip->test_properties()->AddChild(std::move(test));
432 scale->test_properties()->AddChild(std::move(clip)); 396 scale->test_properties()->AddChild(std::move(clip));
433 render_surface->test_properties()->AddChild(std::move(scale)); 397 render_surface->test_properties()->AddChild(std::move(scale));
434 root->test_properties()->AddChild(std::move(render_surface)); 398 root->test_properties()->AddChild(std::move(render_surface));
435 399
436 host_impl().SetViewportSize(root->bounds()); 400 host_impl().SetViewportSize(root->bounds());
437 host_impl().active_tree()->SetRootLayerForTesting(std::move(root)); 401 host_impl().active_tree()->SetRootLayerForTesting(std::move(root));
438 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); 402 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
(...skipping 12 matching lines...) Expand all
451 ClipTree& clip_tree = host_impl().active_tree()->property_trees()->clip_tree; 415 ClipTree& clip_tree = host_impl().active_tree()->property_trees()->clip_tree;
452 ClipNode* clip_node = clip_tree.Node(result_layer->clip_tree_index()); 416 ClipNode* clip_node = clip_tree.Node(result_layer->clip_tree_index());
453 EXPECT_NE(clip_node->transform_id, clip_node->target_transform_id); 417 EXPECT_NE(clip_node->transform_id, clip_node->target_transform_id);
454 } 418 }
455 419
456 TEST_F(LayerTreeImplTest, HitTestingSiblings) { 420 TEST_F(LayerTreeImplTest, HitTestingSiblings) {
457 // This tests hit testing when the test point hits only one of the siblings. 421 // This tests hit testing when the test point hits only one of the siblings.
458 gfx::Transform identity_matrix; 422 gfx::Transform identity_matrix;
459 std::unique_ptr<LayerImpl> root = 423 std::unique_ptr<LayerImpl> root =
460 LayerImpl::Create(host_impl().active_tree(), 1); 424 LayerImpl::Create(host_impl().active_tree(), 1);
461 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), 425 root->SetBounds(gfx::Size(100, 100));
462 gfx::PointF(), gfx::Size(100, 100), true, false,
463 true);
464 std::unique_ptr<LayerImpl> child1 = 426 std::unique_ptr<LayerImpl> child1 =
465 LayerImpl::Create(host_impl().active_tree(), 2); 427 LayerImpl::Create(host_impl().active_tree(), 2);
466 SetLayerPropertiesForTesting(child1.get(), identity_matrix, gfx::Point3F(), 428 child1->SetBounds(gfx::Size(25, 25));
467 gfx::PointF(), gfx::Size(25, 25), true, false,
468 false);
469 child1->SetMasksToBounds(true); 429 child1->SetMasksToBounds(true);
470 child1->SetDrawsContent(true); 430 child1->SetDrawsContent(true);
471 std::unique_ptr<LayerImpl> child2 = 431 std::unique_ptr<LayerImpl> child2 =
472 LayerImpl::Create(host_impl().active_tree(), 3); 432 LayerImpl::Create(host_impl().active_tree(), 3);
473 SetLayerPropertiesForTesting(child2.get(), identity_matrix, gfx::Point3F(), 433 child2->SetBounds(gfx::Size(75, 75));
474 gfx::PointF(), gfx::Size(75, 75), true, false,
475 false);
476 child2->SetMasksToBounds(true); 434 child2->SetMasksToBounds(true);
477 child2->SetDrawsContent(true); 435 child2->SetDrawsContent(true);
478 root->test_properties()->AddChild(std::move(child1)); 436 root->test_properties()->AddChild(std::move(child1));
479 root->test_properties()->AddChild(std::move(child2)); 437 root->test_properties()->AddChild(std::move(child2));
480 438
481 host_impl().SetViewportSize(root->bounds()); 439 host_impl().SetViewportSize(root->bounds());
482 host_impl().active_tree()->SetRootLayerForTesting(std::move(root)); 440 host_impl().active_tree()->SetRootLayerForTesting(std::move(root));
483 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); 441 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
484 442
485 gfx::PointF test_point(50.f, 50.f); 443 gfx::PointF test_point(50.f, 50.f);
486 LayerImpl* result_layer = 444 LayerImpl* result_layer =
487 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); 445 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point);
488 ASSERT_TRUE(result_layer); 446 ASSERT_TRUE(result_layer);
489 EXPECT_EQ(3, result_layer->id()); 447 EXPECT_EQ(3, result_layer->id());
490 } 448 }
491 449
492 TEST_F(LayerTreeImplTest, HitTestingPointOutsideMaxTextureSize) { 450 TEST_F(LayerTreeImplTest, HitTestingPointOutsideMaxTextureSize) {
493 gfx::Transform identity_matrix; 451 gfx::Transform identity_matrix;
494 int max_texture_size = 452 int max_texture_size =
495 host_impl().active_tree()->resource_provider()->max_texture_size(); 453 host_impl().active_tree()->resource_provider()->max_texture_size();
496 gfx::Size bounds(max_texture_size + 100, max_texture_size + 100); 454 gfx::Size bounds(max_texture_size + 100, max_texture_size + 100);
497 455
498 std::unique_ptr<LayerImpl> root = 456 std::unique_ptr<LayerImpl> root =
499 LayerImpl::Create(host_impl().active_tree(), 1); 457 LayerImpl::Create(host_impl().active_tree(), 1);
500 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), 458 root->SetBounds(bounds);
501 gfx::PointF(), bounds, true, false, true);
502 459
503 std::unique_ptr<LayerImpl> surface = 460 std::unique_ptr<LayerImpl> surface =
504 LayerImpl::Create(host_impl().active_tree(), 2); 461 LayerImpl::Create(host_impl().active_tree(), 2);
505 SetLayerPropertiesForTesting(surface.get(), identity_matrix, gfx::Point3F(), 462 surface->SetBounds(bounds);
506 gfx::PointF(), bounds, true, false, true);
507 surface->SetMasksToBounds(true); 463 surface->SetMasksToBounds(true);
508 surface->SetDrawsContent(true); 464 surface->SetDrawsContent(true);
465 surface->test_properties()->force_render_surface = true;
509 466
510 root->test_properties()->AddChild(std::move(surface)); 467 root->test_properties()->AddChild(std::move(surface));
511 host_impl().SetViewportSize(root->bounds()); 468 host_impl().SetViewportSize(root->bounds());
512 host_impl().active_tree()->SetRootLayerForTesting(std::move(root)); 469 host_impl().active_tree()->SetRootLayerForTesting(std::move(root));
513 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); 470 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
514 471
515 gfx::PointF test_point(max_texture_size - 50, max_texture_size - 50); 472 gfx::PointF test_point(max_texture_size - 50, max_texture_size - 50);
516 LayerImpl* result_layer = 473 LayerImpl* result_layer =
517 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); 474 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point);
518 EXPECT_TRUE(result_layer); 475 EXPECT_TRUE(result_layer);
519 476
520 test_point = gfx::PointF(max_texture_size + 50, max_texture_size + 50); 477 test_point = gfx::PointF(max_texture_size + 50, max_texture_size + 50);
521 result_layer = 478 result_layer =
522 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); 479 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point);
523 EXPECT_FALSE(result_layer); 480 EXPECT_FALSE(result_layer);
524 } 481 }
525 482
526 TEST_F(LayerTreeImplTest, HitTestingForSinglePerspectiveLayer) { 483 TEST_F(LayerTreeImplTest, HitTestingForSinglePerspectiveLayer) {
527 std::unique_ptr<LayerImpl> root = 484 std::unique_ptr<LayerImpl> root =
528 LayerImpl::Create(host_impl().active_tree(), 12345); 485 LayerImpl::Create(host_impl().active_tree(), 12345);
529 486
530 gfx::Transform identity_matrix;
531
532 // perspective_projection_about_center * translation_by_z is designed so that 487 // perspective_projection_about_center * translation_by_z is designed so that
533 // the 100 x 100 layer becomes 50 x 50, and remains centered at (50, 50). 488 // the 100 x 100 layer becomes 50 x 50, and remains centered at (50, 50).
534 gfx::Transform perspective_projection_about_center; 489 gfx::Transform perspective_projection_about_center;
535 perspective_projection_about_center.Translate(50.0, 50.0); 490 perspective_projection_about_center.Translate(50.0, 50.0);
536 perspective_projection_about_center.ApplyPerspectiveDepth(1.0); 491 perspective_projection_about_center.ApplyPerspectiveDepth(1.0);
537 perspective_projection_about_center.Translate(-50.0, -50.0); 492 perspective_projection_about_center.Translate(-50.0, -50.0);
538 gfx::Transform translation_by_z; 493 gfx::Transform translation_by_z;
539 translation_by_z.Translate3d(0.0, 0.0, -1.0); 494 translation_by_z.Translate3d(0.0, 0.0, -1.0);
540 495
541 gfx::Point3F transform_origin; 496 root->SetTransform(perspective_projection_about_center * translation_by_z);
542 gfx::PointF position; 497 root->SetBounds(gfx::Size(100, 100));
543 gfx::Size bounds(100, 100);
544 SetLayerPropertiesForTesting(
545 root.get(), perspective_projection_about_center * translation_by_z,
546 transform_origin, position, bounds, true, false, true);
547 root->SetDrawsContent(true); 498 root->SetDrawsContent(true);
548 499
549 host_impl().SetViewportSize(root->bounds()); 500 host_impl().SetViewportSize(root->bounds());
550 host_impl().active_tree()->SetRootLayerForTesting(std::move(root)); 501 host_impl().active_tree()->SetRootLayerForTesting(std::move(root));
551 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); 502 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
552 503
553 // Sanity check the scenario we just created. 504 // Sanity check the scenario we just created.
554 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); 505 ASSERT_EQ(1u, RenderSurfaceLayerList().size());
555 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); 506 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size());
556 507
(...skipping 21 matching lines...) Expand all
578 result_layer = 529 result_layer =
579 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); 530 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point);
580 ASSERT_TRUE(result_layer); 531 ASSERT_TRUE(result_layer);
581 EXPECT_EQ(12345, result_layer->id()); 532 EXPECT_EQ(12345, result_layer->id());
582 } 533 }
583 534
584 TEST_F(LayerTreeImplTest, HitTestingForSimpleClippedLayer) { 535 TEST_F(LayerTreeImplTest, HitTestingForSimpleClippedLayer) {
585 // Test that hit-testing will only work for the visible portion of a layer, 536 // Test that hit-testing will only work for the visible portion of a layer,
586 // and not the entire layer bounds. Here we just test the simple axis-aligned 537 // and not the entire layer bounds. Here we just test the simple axis-aligned
587 // case. 538 // case.
588 gfx::Transform identity_matrix;
589 gfx::Point3F transform_origin;
590
591 std::unique_ptr<LayerImpl> root = 539 std::unique_ptr<LayerImpl> root =
592 LayerImpl::Create(host_impl().active_tree(), 1); 540 LayerImpl::Create(host_impl().active_tree(), 1);
593 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, 541 root->SetBounds(gfx::Size(100, 100));
594 gfx::PointF(), gfx::Size(100, 100), true, false,
595 true);
596 { 542 {
597 std::unique_ptr<LayerImpl> clipping_layer = 543 std::unique_ptr<LayerImpl> clipping_layer =
598 LayerImpl::Create(host_impl().active_tree(), 123); 544 LayerImpl::Create(host_impl().active_tree(), 123);
599 // this layer is positioned, and hit testing should correctly know where the 545 // this layer is positioned, and hit testing should correctly know where the
600 // layer is located. 546 // layer is located.
601 gfx::PointF position(25.f, 25.f); 547 clipping_layer->SetPosition(gfx::PointF(25.f, 25.f));
602 gfx::Size bounds(50, 50); 548 clipping_layer->SetBounds(gfx::Size(50, 50));
603 SetLayerPropertiesForTesting(clipping_layer.get(), identity_matrix,
604 transform_origin, position, bounds, true,
605 false, false);
606 clipping_layer->SetMasksToBounds(true); 549 clipping_layer->SetMasksToBounds(true);
607 550
608 std::unique_ptr<LayerImpl> child = 551 std::unique_ptr<LayerImpl> child =
609 LayerImpl::Create(host_impl().active_tree(), 456); 552 LayerImpl::Create(host_impl().active_tree(), 456);
610 position = gfx::PointF(-50.f, -50.f); 553 child->SetPosition(gfx::PointF(-50.f, -50.f));
611 bounds = gfx::Size(300, 300); 554 child->SetBounds(gfx::Size(300, 300));
612 SetLayerPropertiesForTesting(child.get(), identity_matrix, transform_origin,
613 position, bounds, true, false, false);
614 child->SetDrawsContent(true); 555 child->SetDrawsContent(true);
615 clipping_layer->test_properties()->AddChild(std::move(child)); 556 clipping_layer->test_properties()->AddChild(std::move(child));
616 root->test_properties()->AddChild(std::move(clipping_layer)); 557 root->test_properties()->AddChild(std::move(clipping_layer));
617 } 558 }
618 559
619 host_impl().SetViewportSize(root->bounds()); 560 host_impl().SetViewportSize(root->bounds());
620 host_impl().active_tree()->SetRootLayerForTesting(std::move(root)); 561 host_impl().active_tree()->SetRootLayerForTesting(std::move(root));
621 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); 562 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
622 563
623 // Sanity check the scenario we just created. 564 // Sanity check the scenario we just created.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 // 603 //
663 // The child and grand_child layers are both initialized to clip the 604 // The child and grand_child layers are both initialized to clip the
664 // rotated_leaf. The child layer is rotated about the top-left corner, so that 605 // rotated_leaf. The child layer is rotated about the top-left corner, so that
665 // the root + child clips combined create a triangle. The rotated_leaf will 606 // the root + child clips combined create a triangle. The rotated_leaf will
666 // only be visible where it overlaps this triangle. 607 // only be visible where it overlaps this triangle.
667 // 608 //
668 std::unique_ptr<LayerImpl> root = 609 std::unique_ptr<LayerImpl> root =
669 LayerImpl::Create(host_impl().active_tree(), 123); 610 LayerImpl::Create(host_impl().active_tree(), 123);
670 LayerImpl* root_layer = root.get(); 611 LayerImpl* root_layer = root.get();
671 612
672 gfx::Transform identity_matrix; 613 root->SetBounds(gfx::Size(100, 100));
673 gfx::Point3F transform_origin;
674 gfx::PointF position;
675 gfx::Size bounds(100, 100);
676 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin,
677 position, bounds, true, false, true);
678 root->SetMasksToBounds(true); 614 root->SetMasksToBounds(true);
679 { 615 {
680 std::unique_ptr<LayerImpl> child = 616 std::unique_ptr<LayerImpl> child =
681 LayerImpl::Create(host_impl().active_tree(), 456); 617 LayerImpl::Create(host_impl().active_tree(), 456);
682 std::unique_ptr<LayerImpl> grand_child = 618 std::unique_ptr<LayerImpl> grand_child =
683 LayerImpl::Create(host_impl().active_tree(), 789); 619 LayerImpl::Create(host_impl().active_tree(), 789);
684 std::unique_ptr<LayerImpl> rotated_leaf = 620 std::unique_ptr<LayerImpl> rotated_leaf =
685 LayerImpl::Create(host_impl().active_tree(), 2468); 621 LayerImpl::Create(host_impl().active_tree(), 2468);
686 622
687 position = gfx::PointF(10.f, 10.f); 623 child->SetPosition(gfx::PointF(10.f, 10.f));
688 bounds = gfx::Size(80, 80); 624 child->SetBounds(gfx::Size(80, 80));
689 SetLayerPropertiesForTesting(child.get(), identity_matrix, transform_origin,
690 position, bounds, true, false, false);
691 child->SetMasksToBounds(true); 625 child->SetMasksToBounds(true);
692 626
693 gfx::Transform rotation45_degrees_about_corner; 627 gfx::Transform rotation45_degrees_about_corner;
694 rotation45_degrees_about_corner.RotateAboutZAxis(45.0); 628 rotation45_degrees_about_corner.RotateAboutZAxis(45.0);
695 629
696 // remember, positioned with respect to its parent which is already at 10, 630 // This is positioned with respect to its parent which is already at
697 // 10 631 // position (10, 10).
698 position = gfx::PointF(); 632 // The size is to ensure it covers at least sqrt(2) * 100.
699 bounds = 633 grand_child->SetBounds(gfx::Size(200, 200));
700 gfx::Size(200, 200); // to ensure it covers at least sqrt(2) * 100. 634 grand_child->SetTransform(rotation45_degrees_about_corner);
701 SetLayerPropertiesForTesting(
702 grand_child.get(), rotation45_degrees_about_corner, transform_origin,
703 position, bounds, true, false, false);
704 grand_child->SetMasksToBounds(true); 635 grand_child->SetMasksToBounds(true);
705 636
706 // Rotates about the center of the layer 637 // Rotates about the center of the layer
707 gfx::Transform rotated_leaf_transform; 638 gfx::Transform rotated_leaf_transform;
708 rotated_leaf_transform.Translate( 639 rotated_leaf_transform.Translate(
709 -10.0, -10.0); // cancel out the grand_parent's position 640 -10.0, -10.0); // cancel out the grand_parent's position
710 rotated_leaf_transform.RotateAboutZAxis( 641 rotated_leaf_transform.RotateAboutZAxis(
711 -45.0); // cancel out the corner 45-degree rotation of the parent. 642 -45.0); // cancel out the corner 45-degree rotation of the parent.
712 rotated_leaf_transform.Translate(50.0, 50.0); 643 rotated_leaf_transform.Translate(50.0, 50.0);
713 rotated_leaf_transform.RotateAboutZAxis(45.0); 644 rotated_leaf_transform.RotateAboutZAxis(45.0);
714 rotated_leaf_transform.Translate(-50.0, -50.0); 645 rotated_leaf_transform.Translate(-50.0, -50.0);
715 position = gfx::PointF(); 646 rotated_leaf->SetBounds(gfx::Size(100, 100));
716 bounds = gfx::Size(100, 100); 647 rotated_leaf->SetTransform(rotated_leaf_transform);
717 SetLayerPropertiesForTesting(rotated_leaf.get(), rotated_leaf_transform,
718 transform_origin, position, bounds, true,
719 false, false);
720 rotated_leaf->SetDrawsContent(true); 648 rotated_leaf->SetDrawsContent(true);
721 649
722 grand_child->test_properties()->AddChild(std::move(rotated_leaf)); 650 grand_child->test_properties()->AddChild(std::move(rotated_leaf));
723 child->test_properties()->AddChild(std::move(grand_child)); 651 child->test_properties()->AddChild(std::move(grand_child));
724 root->test_properties()->AddChild(std::move(child)); 652 root->test_properties()->AddChild(std::move(child));
725 host_impl().active_tree()->SetRootLayerForTesting(std::move(root)); 653 host_impl().active_tree()->SetRootLayerForTesting(std::move(root));
726 654
727 ExecuteCalculateDrawProperties(root_layer); 655 ExecuteCalculateDrawProperties(root_layer);
728 } 656 }
729 657
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
777 } 705 }
778 706
779 TEST_F(LayerTreeImplTest, HitTestingForNonClippingIntermediateLayer) { 707 TEST_F(LayerTreeImplTest, HitTestingForNonClippingIntermediateLayer) {
780 // This test checks that hit testing code does not accidentally clip to layer 708 // This test checks that hit testing code does not accidentally clip to layer
781 // bounds for a layer that actually does not clip. 709 // bounds for a layer that actually does not clip.
782 gfx::Transform identity_matrix; 710 gfx::Transform identity_matrix;
783 gfx::Point3F transform_origin; 711 gfx::Point3F transform_origin;
784 712
785 std::unique_ptr<LayerImpl> root = 713 std::unique_ptr<LayerImpl> root =
786 LayerImpl::Create(host_impl().active_tree(), 1); 714 LayerImpl::Create(host_impl().active_tree(), 1);
787 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, 715 root->SetBounds(gfx::Size(100, 100));
788 gfx::PointF(), gfx::Size(100, 100), true, false,
789 true);
790 { 716 {
791 std::unique_ptr<LayerImpl> intermediate_layer = 717 std::unique_ptr<LayerImpl> intermediate_layer =
792 LayerImpl::Create(host_impl().active_tree(), 123); 718 LayerImpl::Create(host_impl().active_tree(), 123);
793 // this layer is positioned, and hit testing should correctly know where the 719 // this layer is positioned, and hit testing should correctly know where the
794 // layer is located. 720 // layer is located.
795 gfx::PointF position(10.f, 10.f); 721 intermediate_layer->SetPosition(gfx::PointF(10.f, 10.f));
796 gfx::Size bounds(50, 50); 722 intermediate_layer->SetBounds(gfx::Size(50, 50));
797 SetLayerPropertiesForTesting(intermediate_layer.get(), identity_matrix,
798 transform_origin, position, bounds, true,
799 false, false);
800 // Sanity check the intermediate layer should not clip. 723 // Sanity check the intermediate layer should not clip.
801 ASSERT_FALSE(intermediate_layer->masks_to_bounds()); 724 ASSERT_FALSE(intermediate_layer->masks_to_bounds());
802 ASSERT_FALSE(intermediate_layer->test_properties()->mask_layer); 725 ASSERT_FALSE(intermediate_layer->test_properties()->mask_layer);
803 726
804 // The child of the intermediate_layer is translated so that it does not 727 // The child of the intermediate_layer is translated so that it does not
805 // overlap intermediate_layer at all. If child is incorrectly clipped, we 728 // overlap intermediate_layer at all. If child is incorrectly clipped, we
806 // would not be able to hit it successfully. 729 // would not be able to hit it successfully.
807 std::unique_ptr<LayerImpl> child = 730 std::unique_ptr<LayerImpl> child =
808 LayerImpl::Create(host_impl().active_tree(), 456); 731 LayerImpl::Create(host_impl().active_tree(), 456);
809 position = gfx::PointF(60.f, 60.f); // 70, 70 in screen space 732 child->SetPosition(gfx::PointF(60.f, 60.f)); // 70, 70 in screen space
810 bounds = gfx::Size(20, 20); 733 child->SetBounds(gfx::Size(20, 20));
811 SetLayerPropertiesForTesting(child.get(), identity_matrix, transform_origin,
812 position, bounds, true, false, false);
813 child->SetDrawsContent(true); 734 child->SetDrawsContent(true);
814 intermediate_layer->test_properties()->AddChild(std::move(child)); 735 intermediate_layer->test_properties()->AddChild(std::move(child));
815 root->test_properties()->AddChild(std::move(intermediate_layer)); 736 root->test_properties()->AddChild(std::move(intermediate_layer));
816 } 737 }
817 738
818 host_impl().SetViewportSize(root->bounds()); 739 host_impl().SetViewportSize(root->bounds());
819 host_impl().active_tree()->SetRootLayerForTesting(std::move(root)); 740 host_impl().active_tree()->SetRootLayerForTesting(std::move(root));
820 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); 741 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
821 742
822 // Sanity check the scenario we just created. 743 // Sanity check the scenario we just created.
(...skipping 24 matching lines...) Expand all
847 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); 768 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point);
848 ASSERT_TRUE(result_layer); 769 ASSERT_TRUE(result_layer);
849 EXPECT_EQ(456, result_layer->id()); 770 EXPECT_EQ(456, result_layer->id());
850 } 771 }
851 772
852 TEST_F(LayerTreeImplTest, HitTestingForMultipleLayers) { 773 TEST_F(LayerTreeImplTest, HitTestingForMultipleLayers) {
853 std::unique_ptr<LayerImpl> root = 774 std::unique_ptr<LayerImpl> root =
854 LayerImpl::Create(host_impl().active_tree(), 1); 775 LayerImpl::Create(host_impl().active_tree(), 1);
855 LayerImpl* root_layer = root.get(); 776 LayerImpl* root_layer = root.get();
856 777
857 gfx::Transform identity_matrix; 778 root->SetBounds(gfx::Size(100, 100));
858 gfx::Point3F transform_origin;
859 gfx::PointF position;
860 gfx::Size bounds(100, 100);
861 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin,
862 position, bounds, true, false, true);
863 root->SetDrawsContent(true); 779 root->SetDrawsContent(true);
864 { 780 {
865 // child 1 and child2 are initialized to overlap between x=50 and x=60. 781 // child 1 and child2 are initialized to overlap between x=50 and x=60.
866 // grand_child is set to overlap both child1 and child2 between y=50 and 782 // grand_child is set to overlap both child1 and child2 between y=50 and
867 // y=60. The expected stacking order is: (front) child2, (second) 783 // y=60. The expected stacking order is: (front) child2, (second)
868 // grand_child, (third) child1, and (back) the root layer behind all other 784 // grand_child, (third) child1, and (back) the root layer behind all other
869 // layers. 785 // layers.
870 786
871 std::unique_ptr<LayerImpl> child1 = 787 std::unique_ptr<LayerImpl> child1 =
872 LayerImpl::Create(host_impl().active_tree(), 2); 788 LayerImpl::Create(host_impl().active_tree(), 2);
873 std::unique_ptr<LayerImpl> child2 = 789 std::unique_ptr<LayerImpl> child2 =
874 LayerImpl::Create(host_impl().active_tree(), 3); 790 LayerImpl::Create(host_impl().active_tree(), 3);
875 std::unique_ptr<LayerImpl> grand_child1 = 791 std::unique_ptr<LayerImpl> grand_child1 =
876 LayerImpl::Create(host_impl().active_tree(), 4); 792 LayerImpl::Create(host_impl().active_tree(), 4);
877 793
878 position = gfx::PointF(10.f, 10.f); 794 child1->SetPosition(gfx::PointF(10.f, 10.f));
879 bounds = gfx::Size(50, 50); 795 child1->SetBounds(gfx::Size(50, 50));
880 SetLayerPropertiesForTesting(child1.get(), identity_matrix,
881 transform_origin, position, bounds, true,
882 false, false);
883 child1->SetDrawsContent(true); 796 child1->SetDrawsContent(true);
884 797
885 position = gfx::PointF(50.f, 10.f); 798 child2->SetPosition(gfx::PointF(50.f, 10.f));
886 bounds = gfx::Size(50, 50); 799 child2->SetBounds(gfx::Size(50, 50));
887 SetLayerPropertiesForTesting(child2.get(), identity_matrix,
888 transform_origin, position, bounds, true,
889 false, false);
890 child2->SetDrawsContent(true); 800 child2->SetDrawsContent(true);
891 801
892 // Remember that grand_child is positioned with respect to its parent (i.e. 802 // Remember that grand_child is positioned with respect to its parent (i.e.
893 // child1). In screen space, the intended position is (10, 50), with size 803 // child1). In screen space, the intended position is (10, 50), with size
894 // 100 x 50. 804 // 100 x 50.
895 position = gfx::PointF(0.f, 40.f); 805 grand_child1->SetPosition(gfx::PointF(0.f, 40.f));
896 bounds = gfx::Size(100, 50); 806 grand_child1->SetBounds(gfx::Size(100, 50));
897 SetLayerPropertiesForTesting(grand_child1.get(), identity_matrix,
898 transform_origin, position, bounds, true,
899 false, false);
900 grand_child1->SetDrawsContent(true); 807 grand_child1->SetDrawsContent(true);
901 808
902 child1->test_properties()->AddChild(std::move(grand_child1)); 809 child1->test_properties()->AddChild(std::move(grand_child1));
903 root->test_properties()->AddChild(std::move(child1)); 810 root->test_properties()->AddChild(std::move(child1));
904 root->test_properties()->AddChild(std::move(child2)); 811 root->test_properties()->AddChild(std::move(child2));
905 host_impl().active_tree()->SetRootLayerForTesting(std::move(root)); 812 host_impl().active_tree()->SetRootLayerForTesting(std::move(root));
906 813
907 ExecuteCalculateDrawProperties(root_layer); 814 ExecuteCalculateDrawProperties(root_layer);
908 } 815 }
909 816
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
984 float root_depth, 891 float root_depth,
985 float left_child_depth, 892 float left_child_depth,
986 float right_child_depth) { 893 float right_child_depth) {
987 std::unique_ptr<LayerImpl> root = 894 std::unique_ptr<LayerImpl> root =
988 LayerImpl::Create(host_impl().active_tree(), root_id); 895 LayerImpl::Create(host_impl().active_tree(), root_id);
989 std::unique_ptr<LayerImpl> left_child = 896 std::unique_ptr<LayerImpl> left_child =
990 LayerImpl::Create(host_impl().active_tree(), left_child_id); 897 LayerImpl::Create(host_impl().active_tree(), left_child_id);
991 std::unique_ptr<LayerImpl> right_child = 898 std::unique_ptr<LayerImpl> right_child =
992 LayerImpl::Create(host_impl().active_tree(), right_child_id); 899 LayerImpl::Create(host_impl().active_tree(), right_child_id);
993 900
994 gfx::Point3F transform_origin;
995 gfx::PointF position;
996 gfx::Size bounds(100, 100); 901 gfx::Size bounds(100, 100);
997 { 902 {
998 gfx::Transform translate_z; 903 gfx::Transform translate_z;
999 translate_z.Translate3d(0, 0, root_depth); 904 translate_z.Translate3d(0, 0, root_depth);
1000 SetLayerPropertiesForTesting(root.get(), translate_z, transform_origin, 905 root->SetTransform(translate_z);
1001 position, bounds, false, false, true); 906 root->SetBounds(bounds);
1002 root->SetDrawsContent(true); 907 root->SetDrawsContent(true);
1003 root->Set3dSortingContextId(root_sorting_context); 908 root->Set3dSortingContextId(root_sorting_context);
1004 } 909 }
1005 { 910 {
1006 gfx::Transform translate_z; 911 gfx::Transform translate_z;
1007 translate_z.Translate3d(0, 0, left_child_depth); 912 translate_z.Translate3d(0, 0, left_child_depth);
1008 SetLayerPropertiesForTesting(left_child.get(), translate_z, 913 left_child->SetTransform(translate_z);
1009 transform_origin, position, bounds, false, 914 left_child->SetBounds(bounds);
1010 false, false);
1011 left_child->SetDrawsContent(true); 915 left_child->SetDrawsContent(true);
1012 left_child->Set3dSortingContextId(left_child_sorting_context); 916 left_child->Set3dSortingContextId(left_child_sorting_context);
917 left_child->test_properties()->should_flatten_transform = false;
1013 } 918 }
1014 { 919 {
1015 gfx::Transform translate_z; 920 gfx::Transform translate_z;
1016 translate_z.Translate3d(0, 0, right_child_depth); 921 translate_z.Translate3d(0, 0, right_child_depth);
1017 SetLayerPropertiesForTesting(right_child.get(), translate_z, 922 right_child->SetTransform(translate_z);
1018 transform_origin, position, bounds, false, 923 right_child->SetBounds(bounds);
1019 false, false);
1020 right_child->SetDrawsContent(true); 924 right_child->SetDrawsContent(true);
1021 right_child->Set3dSortingContextId(right_child_sorting_context); 925 right_child->Set3dSortingContextId(right_child_sorting_context);
1022 } 926 }
1023 927
1024 root->test_properties()->AddChild(std::move(left_child)); 928 root->test_properties()->AddChild(std::move(left_child));
1025 root->test_properties()->AddChild(std::move(right_child)); 929 root->test_properties()->AddChild(std::move(right_child));
1026 930
1027 host_impl().SetViewportSize(root->bounds()); 931 host_impl().SetViewportSize(root->bounds());
1028 host_impl().active_tree()->SetRootLayerForTesting(std::move(root)); 932 host_impl().active_tree()->SetRootLayerForTesting(std::move(root));
1029 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); 933 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1070 int hit_layer_id = HitTestSimpleTree(/* ids */ 1, 2, 3, 974 int hit_layer_id = HitTestSimpleTree(/* ids */ 1, 2, 3,
1071 /* sorting_contexts */ 10, 10, 10, 975 /* sorting_contexts */ 10, 10, 10,
1072 /* depths */ 0, -1, -1); 976 /* depths */ 0, -1, -1);
1073 EXPECT_EQ(1, hit_layer_id); 977 EXPECT_EQ(1, hit_layer_id);
1074 } 978 }
1075 979
1076 TEST_F(LayerTreeImplTest, HitTestingForMultipleLayersAtVaryingDepths) { 980 TEST_F(LayerTreeImplTest, HitTestingForMultipleLayersAtVaryingDepths) {
1077 std::unique_ptr<LayerImpl> root = 981 std::unique_ptr<LayerImpl> root =
1078 LayerImpl::Create(host_impl().active_tree(), 1); 982 LayerImpl::Create(host_impl().active_tree(), 1);
1079 983
1080 gfx::Transform identity_matrix; 984 root->SetBounds(gfx::Size(100, 100));
1081 gfx::Point3F transform_origin;
1082 gfx::PointF position;
1083 gfx::Size bounds(100, 100);
1084 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin,
1085 position, bounds, true, false, true);
1086 root->SetDrawsContent(true); 985 root->SetDrawsContent(true);
1087 root->test_properties()->should_flatten_transform = false; 986 root->test_properties()->should_flatten_transform = false;
1088 root->Set3dSortingContextId(1); 987 root->Set3dSortingContextId(1);
1089 { 988 {
1090 // child 1 and child2 are initialized to overlap between x=50 and x=60. 989 // child 1 and child2 are initialized to overlap between x=50 and x=60.
1091 // grand_child is set to overlap both child1 and child2 between y=50 and 990 // grand_child is set to overlap both child1 and child2 between y=50 and
1092 // y=60. The expected stacking order is: (front) child2, (second) 991 // y=60. The expected stacking order is: (front) child2, (second)
1093 // grand_child, (third) child1, and (back) the root layer behind all other 992 // grand_child, (third) child1, and (back) the root layer behind all other
1094 // layers. 993 // layers.
1095 994
1096 std::unique_ptr<LayerImpl> child1 = 995 std::unique_ptr<LayerImpl> child1 =
1097 LayerImpl::Create(host_impl().active_tree(), 2); 996 LayerImpl::Create(host_impl().active_tree(), 2);
1098 std::unique_ptr<LayerImpl> child2 = 997 std::unique_ptr<LayerImpl> child2 =
1099 LayerImpl::Create(host_impl().active_tree(), 3); 998 LayerImpl::Create(host_impl().active_tree(), 3);
1100 std::unique_ptr<LayerImpl> grand_child1 = 999 std::unique_ptr<LayerImpl> grand_child1 =
1101 LayerImpl::Create(host_impl().active_tree(), 4); 1000 LayerImpl::Create(host_impl().active_tree(), 4);
1102 1001
1103 position = gfx::PointF(10.f, 10.f); 1002 child1->SetPosition(gfx::PointF(10.f, 10.f));
1104 bounds = gfx::Size(50, 50); 1003 child1->SetBounds(gfx::Size(50, 50));
1105 SetLayerPropertiesForTesting(child1.get(), identity_matrix,
1106 transform_origin, position, bounds, true,
1107 false, false);
1108 child1->SetDrawsContent(true); 1004 child1->SetDrawsContent(true);
1109 child1->test_properties()->should_flatten_transform = false; 1005 child1->test_properties()->should_flatten_transform = false;
1110 child1->Set3dSortingContextId(1); 1006 child1->Set3dSortingContextId(1);
1111 1007
1112 position = gfx::PointF(50.f, 10.f); 1008 child2->SetPosition(gfx::PointF(50.f, 10.f));
1113 bounds = gfx::Size(50, 50); 1009 child2->SetBounds(gfx::Size(50, 50));
1114 gfx::Transform translate_z; 1010 gfx::Transform translate_z;
1115 translate_z.Translate3d(0, 0, 10.f); 1011 translate_z.Translate3d(0, 0, 10.f);
1116 SetLayerPropertiesForTesting(child2.get(), translate_z, transform_origin, 1012 child2->SetTransform(translate_z);
1117 position, bounds, true, false, false);
1118 child2->SetDrawsContent(true); 1013 child2->SetDrawsContent(true);
1119 child2->test_properties()->should_flatten_transform = false; 1014 child2->test_properties()->should_flatten_transform = false;
1120 child2->Set3dSortingContextId(1); 1015 child2->Set3dSortingContextId(1);
1121 1016
1122 // Remember that grand_child is positioned with respect to its parent (i.e. 1017 // Remember that grand_child is positioned with respect to its parent (i.e.
1123 // child1). In screen space, the intended position is (10, 50), with size 1018 // child1). In screen space, the intended position is (10, 50), with size
1124 // 100 x 50. 1019 // 100 x 50.
1125 position = gfx::PointF(0.f, 40.f); 1020 grand_child1->SetPosition(gfx::PointF(0.f, 40.f));
1126 bounds = gfx::Size(100, 50); 1021 grand_child1->SetBounds(gfx::Size(100, 50));
1127 SetLayerPropertiesForTesting(grand_child1.get(), identity_matrix,
1128 transform_origin, position, bounds, true,
1129 false, false);
1130 grand_child1->SetDrawsContent(true); 1022 grand_child1->SetDrawsContent(true);
1131 grand_child1->test_properties()->should_flatten_transform = false; 1023 grand_child1->test_properties()->should_flatten_transform = false;
1132 1024
1133 child1->test_properties()->AddChild(std::move(grand_child1)); 1025 child1->test_properties()->AddChild(std::move(grand_child1));
1134 root->test_properties()->AddChild(std::move(child1)); 1026 root->test_properties()->AddChild(std::move(child1));
1135 root->test_properties()->AddChild(std::move(child2)); 1027 root->test_properties()->AddChild(std::move(child2));
1136 } 1028 }
1137 1029
1138 LayerImpl* child1 = root->test_properties()->children[0]; 1030 LayerImpl* child1 = root->test_properties()->children[0];
1139 LayerImpl* child2 = root->test_properties()->children[1]; 1031 LayerImpl* child2 = root->test_properties()->children[1];
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1194 test_point = gfx::PointF(20.f, 51.f); 1086 test_point = gfx::PointF(20.f, 51.f);
1195 result_layer = 1087 result_layer =
1196 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); 1088 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point);
1197 ASSERT_TRUE(result_layer); 1089 ASSERT_TRUE(result_layer);
1198 EXPECT_EQ(4, result_layer->id()); 1090 EXPECT_EQ(4, result_layer->id());
1199 } 1091 }
1200 1092
1201 TEST_F(LayerTreeImplTest, HitTestingRespectsClipParents) { 1093 TEST_F(LayerTreeImplTest, HitTestingRespectsClipParents) {
1202 std::unique_ptr<LayerImpl> root = 1094 std::unique_ptr<LayerImpl> root =
1203 LayerImpl::Create(host_impl().active_tree(), 1); 1095 LayerImpl::Create(host_impl().active_tree(), 1);
1204 gfx::Transform identity_matrix; 1096
1205 gfx::Point3F transform_origin; 1097 root->SetBounds(gfx::Size(100, 100));
1206 gfx::PointF position;
1207 gfx::Size bounds(100, 100);
1208 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin,
1209 position, bounds, true, false, true);
1210 root->SetDrawsContent(true); 1098 root->SetDrawsContent(true);
1211 { 1099 {
1212 std::unique_ptr<LayerImpl> child = 1100 std::unique_ptr<LayerImpl> child =
1213 LayerImpl::Create(host_impl().active_tree(), 2); 1101 LayerImpl::Create(host_impl().active_tree(), 2);
1214 std::unique_ptr<LayerImpl> grand_child = 1102 std::unique_ptr<LayerImpl> grand_child =
1215 LayerImpl::Create(host_impl().active_tree(), 4); 1103 LayerImpl::Create(host_impl().active_tree(), 4);
1216 1104
1217 position = gfx::PointF(10.f, 10.f); 1105 child->SetPosition(gfx::PointF(10.f, 10.f));
1218 bounds = gfx::Size(1, 1); 1106 child->SetBounds(gfx::Size(1, 1));
1219 SetLayerPropertiesForTesting(child.get(), identity_matrix, transform_origin,
1220 position, bounds, true, false, false);
1221 child->SetDrawsContent(true); 1107 child->SetDrawsContent(true);
1222 child->SetMasksToBounds(true); 1108 child->SetMasksToBounds(true);
1223 1109
1224 position = gfx::PointF(0.f, 40.f); 1110 grand_child->SetPosition(gfx::PointF(0.f, 40.f));
1225 bounds = gfx::Size(100, 50); 1111 grand_child->SetBounds(gfx::Size(100, 50));
1226 SetLayerPropertiesForTesting(grand_child.get(), identity_matrix,
1227 transform_origin, position, bounds, true,
1228 false, false);
1229 grand_child->SetDrawsContent(true); 1112 grand_child->SetDrawsContent(true);
1230 grand_child->SetHasRenderSurface(true); 1113 grand_child->SetHasRenderSurface(true);
1231 1114
1232 // This should let |grand_child| "escape" |child|'s clip. 1115 // This should let |grand_child| "escape" |child|'s clip.
1233 grand_child->test_properties()->clip_parent = root.get(); 1116 grand_child->test_properties()->clip_parent = root.get();
1234 std::unique_ptr<std::set<LayerImpl*>> clip_children( 1117 std::unique_ptr<std::set<LayerImpl*>> clip_children(
1235 new std::set<LayerImpl*>); 1118 new std::set<LayerImpl*>);
1236 clip_children->insert(grand_child.get()); 1119 clip_children->insert(grand_child.get());
1237 root->test_properties()->clip_children.reset(clip_children.release()); 1120 root->test_properties()->clip_children.reset(clip_children.release());
1238 1121
1239 child->test_properties()->AddChild(std::move(grand_child)); 1122 child->test_properties()->AddChild(std::move(grand_child));
1240 root->test_properties()->AddChild(std::move(child)); 1123 root->test_properties()->AddChild(std::move(child));
1241 } 1124 }
1242 1125
1243 host_impl().SetViewportSize(root->bounds()); 1126 host_impl().SetViewportSize(root->bounds());
1244 host_impl().active_tree()->SetRootLayerForTesting(std::move(root)); 1127 host_impl().active_tree()->SetRootLayerForTesting(std::move(root));
1245 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); 1128 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
1246 1129
1247 gfx::PointF test_point(12.f, 52.f); 1130 gfx::PointF test_point(12.f, 52.f);
1248 LayerImpl* result_layer = 1131 LayerImpl* result_layer =
1249 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); 1132 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point);
1250 ASSERT_TRUE(result_layer); 1133 ASSERT_TRUE(result_layer);
1251 EXPECT_EQ(4, result_layer->id()); 1134 EXPECT_EQ(4, result_layer->id());
1252 } 1135 }
1253 1136
1254 TEST_F(LayerTreeImplTest, HitTestingRespectsScrollParents) { 1137 TEST_F(LayerTreeImplTest, HitTestingRespectsScrollParents) {
1255 std::unique_ptr<LayerImpl> root = 1138 std::unique_ptr<LayerImpl> root =
1256 LayerImpl::Create(host_impl().active_tree(), 1); 1139 LayerImpl::Create(host_impl().active_tree(), 1);
1257 gfx::Transform identity_matrix; 1140 root->SetBounds(gfx::Size(100, 100));
1258 gfx::Point3F transform_origin;
1259 gfx::PointF position;
1260 gfx::Size bounds(100, 100);
1261 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin,
1262 position, bounds, true, false, true);
1263 root->SetDrawsContent(true); 1141 root->SetDrawsContent(true);
1264 { 1142 {
1265 std::unique_ptr<LayerImpl> child = 1143 std::unique_ptr<LayerImpl> child =
1266 LayerImpl::Create(host_impl().active_tree(), 2); 1144 LayerImpl::Create(host_impl().active_tree(), 2);
1267 std::unique_ptr<LayerImpl> scroll_child = 1145 std::unique_ptr<LayerImpl> scroll_child =
1268 LayerImpl::Create(host_impl().active_tree(), 3); 1146 LayerImpl::Create(host_impl().active_tree(), 3);
1269 std::unique_ptr<LayerImpl> grand_child = 1147 std::unique_ptr<LayerImpl> grand_child =
1270 LayerImpl::Create(host_impl().active_tree(), 4); 1148 LayerImpl::Create(host_impl().active_tree(), 4);
1271 1149
1272 position = gfx::PointF(10.f, 10.f); 1150 child->SetPosition(gfx::PointF(10.f, 10.f));
1273 bounds = gfx::Size(1, 1); 1151 child->SetBounds(gfx::Size(1, 1));
1274 SetLayerPropertiesForTesting(child.get(), identity_matrix, transform_origin,
1275 position, bounds, true, false, false);
1276 child->SetDrawsContent(true); 1152 child->SetDrawsContent(true);
1277 child->SetMasksToBounds(true); 1153 child->SetMasksToBounds(true);
1278 1154
1279 position = gfx::PointF(); 1155 scroll_child->SetBounds(gfx::Size(200, 200));
1280 bounds = gfx::Size(200, 200);
1281 SetLayerPropertiesForTesting(scroll_child.get(), identity_matrix,
1282 transform_origin, position, bounds, true,
1283 false, false);
1284 scroll_child->SetDrawsContent(true); 1156 scroll_child->SetDrawsContent(true);
1285 1157
1286 // This should cause scroll child and its descendants to be affected by 1158 // This should cause scroll child and its descendants to be affected by
1287 // |child|'s clip. 1159 // |child|'s clip.
1288 scroll_child->test_properties()->scroll_parent = child.get(); 1160 scroll_child->test_properties()->scroll_parent = child.get();
1289 std::unique_ptr<std::set<LayerImpl*>> scroll_children( 1161 child->test_properties()->scroll_children =
1290 new std::set<LayerImpl*>); 1162 base::MakeUnique<std::set<LayerImpl*>>();
1291 scroll_children->insert(scroll_child.get()); 1163 child->test_properties()->scroll_children->insert(scroll_child.get());
1292 child->test_properties()->scroll_children.reset(scroll_children.release());
1293 1164
1294 SetLayerPropertiesForTesting(grand_child.get(), identity_matrix, 1165 grand_child->SetBounds(gfx::Size(200, 200));
1295 transform_origin, position, bounds, true,
1296 false, false);
1297 grand_child->SetDrawsContent(true); 1166 grand_child->SetDrawsContent(true);
1298 grand_child->SetHasRenderSurface(true); 1167 grand_child->SetHasRenderSurface(true);
1299 1168
1300 scroll_child->test_properties()->AddChild(std::move(grand_child)); 1169 scroll_child->test_properties()->AddChild(std::move(grand_child));
1301 root->test_properties()->AddChild(std::move(scroll_child)); 1170 root->test_properties()->AddChild(std::move(scroll_child));
1302 root->test_properties()->AddChild(std::move(child)); 1171 root->test_properties()->AddChild(std::move(child));
1303 } 1172 }
1304 1173
1305 host_impl().SetViewportSize(root->bounds()); 1174 host_impl().SetViewportSize(root->bounds());
1306 host_impl().active_tree()->SetRootLayerForTesting(std::move(root)); 1175 host_impl().active_tree()->SetRootLayerForTesting(std::move(root));
1307 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); 1176 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
1308 1177
1309 gfx::PointF test_point(12.f, 52.f); 1178 gfx::PointF test_point(12.f, 52.f);
1310 LayerImpl* result_layer = 1179 LayerImpl* result_layer =
1311 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); 1180 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point);
1312 // The |test_point| should have been clipped away by |child|, the scroll 1181 // The |test_point| should have been clipped away by |child|, the scroll
1313 // parent, so the only thing that should be hit is |root|. 1182 // parent, so the only thing that should be hit is |root|.
1314 ASSERT_TRUE(result_layer); 1183 ASSERT_TRUE(result_layer);
1315 ASSERT_EQ(1, result_layer->id()); 1184 ASSERT_EQ(1, result_layer->id());
1316 } 1185 }
1317 TEST_F(LayerTreeImplTest, HitTestingForMultipleLayerLists) { 1186 TEST_F(LayerTreeImplTest, HitTestingForMultipleLayerLists) {
1318 // 1187 //
1319 // The geometry is set up similarly to the previous case, but 1188 // The geometry is set up similarly to the previous case, but
1320 // all layers are forced to be render surfaces now. 1189 // all layers are forced to be render surfaces now.
1321 // 1190 //
1322 std::unique_ptr<LayerImpl> root = 1191 std::unique_ptr<LayerImpl> root =
1323 LayerImpl::Create(host_impl().active_tree(), 1); 1192 LayerImpl::Create(host_impl().active_tree(), 1);
1324 LayerImpl* root_layer = root.get(); 1193 LayerImpl* root_layer = root.get();
1325 1194
1326 gfx::Transform identity_matrix; 1195 root->SetBounds(gfx::Size(100, 100));
1327 gfx::Point3F transform_origin;
1328 gfx::PointF position;
1329 gfx::Size bounds(100, 100);
1330 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin,
1331 position, bounds, true, false, true);
1332 root->SetDrawsContent(true); 1196 root->SetDrawsContent(true);
1333 { 1197 {
1334 // child 1 and child2 are initialized to overlap between x=50 and x=60. 1198 // child 1 and child2 are initialized to overlap between x=50 and x=60.
1335 // grand_child is set to overlap both child1 and child2 between y=50 and 1199 // grand_child is set to overlap both child1 and child2 between y=50 and
1336 // y=60. The expected stacking order is: (front) child2, (second) 1200 // y=60. The expected stacking order is: (front) child2, (second)
1337 // grand_child, (third) child1, and (back) the root layer behind all other 1201 // grand_child, (third) child1, and (back) the root layer behind all other
1338 // layers. 1202 // layers.
1339 1203
1340 std::unique_ptr<LayerImpl> child1 = 1204 std::unique_ptr<LayerImpl> child1 =
1341 LayerImpl::Create(host_impl().active_tree(), 2); 1205 LayerImpl::Create(host_impl().active_tree(), 2);
1342 std::unique_ptr<LayerImpl> child2 = 1206 std::unique_ptr<LayerImpl> child2 =
1343 LayerImpl::Create(host_impl().active_tree(), 3); 1207 LayerImpl::Create(host_impl().active_tree(), 3);
1344 std::unique_ptr<LayerImpl> grand_child1 = 1208 std::unique_ptr<LayerImpl> grand_child1 =
1345 LayerImpl::Create(host_impl().active_tree(), 4); 1209 LayerImpl::Create(host_impl().active_tree(), 4);
1346 1210
1347 position = gfx::PointF(10.f, 10.f); 1211 child1->SetPosition(gfx::PointF(10.f, 10.f));
1348 bounds = gfx::Size(50, 50); 1212 child1->SetBounds(gfx::Size(50, 50));
1349 SetLayerPropertiesForTesting(child1.get(), identity_matrix,
1350 transform_origin, position, bounds, true,
1351 false, false);
1352 child1->SetDrawsContent(true); 1213 child1->SetDrawsContent(true);
1353 child1->test_properties()->force_render_surface = true; 1214 child1->test_properties()->force_render_surface = true;
1354 1215
1355 position = gfx::PointF(50.f, 10.f); 1216 child2->SetPosition(gfx::PointF(50.f, 10.f));
1356 bounds = gfx::Size(50, 50); 1217 child2->SetBounds(gfx::Size(50, 50));
1357 SetLayerPropertiesForTesting(child2.get(), identity_matrix,
1358 transform_origin, position, bounds, true,
1359 false, false);
1360 child2->SetDrawsContent(true); 1218 child2->SetDrawsContent(true);
1361 child2->test_properties()->force_render_surface = true; 1219 child2->test_properties()->force_render_surface = true;
1362 1220
1363 // Remember that grand_child is positioned with respect to its parent (i.e. 1221 // Remember that grand_child is positioned with respect to its parent (i.e.
1364 // child1). In screen space, the intended position is (10, 50), with size 1222 // child1). In screen space, the intended position is (10, 50), with size
1365 // 100 x 50. 1223 // 100 x 50.
1366 position = gfx::PointF(0.f, 40.f); 1224 grand_child1->SetPosition(gfx::PointF(0.f, 40.f));
1367 bounds = gfx::Size(100, 50); 1225 grand_child1->SetBounds(gfx::Size(100, 50));
1368 SetLayerPropertiesForTesting(grand_child1.get(), identity_matrix,
1369 transform_origin, position, bounds, true,
1370 false, false);
1371 grand_child1->SetDrawsContent(true); 1226 grand_child1->SetDrawsContent(true);
1372 grand_child1->test_properties()->force_render_surface = true; 1227 grand_child1->test_properties()->force_render_surface = true;
1373 1228
1374 child1->test_properties()->AddChild(std::move(grand_child1)); 1229 child1->test_properties()->AddChild(std::move(grand_child1));
1375 root->test_properties()->AddChild(std::move(child1)); 1230 root->test_properties()->AddChild(std::move(child1));
1376 root->test_properties()->AddChild(std::move(child2)); 1231 root->test_properties()->AddChild(std::move(child2));
1377 host_impl().active_tree()->SetRootLayerForTesting(std::move(root)); 1232 host_impl().active_tree()->SetRootLayerForTesting(std::move(root));
1378 1233
1379 ExecuteCalculateDrawProperties(root_layer); 1234 ExecuteCalculateDrawProperties(root_layer);
1380 } 1235 }
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
1451 result_layer = 1306 result_layer =
1452 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); 1307 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point);
1453 ASSERT_TRUE(result_layer); 1308 ASSERT_TRUE(result_layer);
1454 EXPECT_EQ(4, result_layer->id()); 1309 EXPECT_EQ(4, result_layer->id());
1455 } 1310 }
1456 1311
1457 TEST_F(LayerTreeImplTest, HitCheckingTouchHandlerRegionsForSingleLayer) { 1312 TEST_F(LayerTreeImplTest, HitCheckingTouchHandlerRegionsForSingleLayer) {
1458 std::unique_ptr<LayerImpl> root = 1313 std::unique_ptr<LayerImpl> root =
1459 LayerImpl::Create(host_impl().active_tree(), 12345); 1314 LayerImpl::Create(host_impl().active_tree(), 12345);
1460 1315
1461 gfx::Transform identity_matrix;
1462 Region touch_handler_region(gfx::Rect(10, 10, 50, 50)); 1316 Region touch_handler_region(gfx::Rect(10, 10, 50, 50));
1463 gfx::Point3F transform_origin; 1317
1464 gfx::PointF position; 1318 root->SetBounds(gfx::Size(100, 100));
1465 gfx::Size bounds(100, 100);
1466 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin,
1467 position, bounds, true, false, true);
1468 root->SetDrawsContent(true); 1319 root->SetDrawsContent(true);
1469 1320
1470 host_impl().SetViewportSize(root->bounds()); 1321 host_impl().SetViewportSize(root->bounds());
1471 host_impl().active_tree()->SetRootLayerForTesting(std::move(root)); 1322 host_impl().active_tree()->SetRootLayerForTesting(std::move(root));
1472 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); 1323 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
1473 1324
1474 // Sanity check the scenario we just created. 1325 // Sanity check the scenario we just created.
1475 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); 1326 ASSERT_EQ(1u, RenderSurfaceLayerList().size());
1476 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); 1327 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size());
1477 1328
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1536 std::unique_ptr<LayerImpl> root = 1387 std::unique_ptr<LayerImpl> root =
1537 LayerImpl::Create(host_impl().active_tree(), 12345); 1388 LayerImpl::Create(host_impl().active_tree(), 12345);
1538 1389
1539 gfx::Transform uninvertible_transform; 1390 gfx::Transform uninvertible_transform;
1540 uninvertible_transform.matrix().set(0, 0, 0.0); 1391 uninvertible_transform.matrix().set(0, 0, 0.0);
1541 uninvertible_transform.matrix().set(1, 1, 0.0); 1392 uninvertible_transform.matrix().set(1, 1, 0.0);
1542 uninvertible_transform.matrix().set(2, 2, 0.0); 1393 uninvertible_transform.matrix().set(2, 2, 0.0);
1543 uninvertible_transform.matrix().set(3, 3, 0.0); 1394 uninvertible_transform.matrix().set(3, 3, 0.0);
1544 ASSERT_FALSE(uninvertible_transform.IsInvertible()); 1395 ASSERT_FALSE(uninvertible_transform.IsInvertible());
1545 1396
1546 gfx::Transform identity_matrix;
1547 Region touch_handler_region(gfx::Rect(10, 10, 50, 50)); 1397 Region touch_handler_region(gfx::Rect(10, 10, 50, 50));
1548 gfx::Point3F transform_origin; 1398
1549 gfx::PointF position; 1399 root->SetTransform(uninvertible_transform);
1550 gfx::Size bounds(100, 100); 1400 root->SetBounds(gfx::Size(100, 100));
1551 SetLayerPropertiesForTesting(root.get(), uninvertible_transform,
1552 transform_origin, position, bounds, true, false,
1553 true);
1554 root->SetDrawsContent(true); 1401 root->SetDrawsContent(true);
1555 root->SetTouchEventHandlerRegion(touch_handler_region); 1402 root->SetTouchEventHandlerRegion(touch_handler_region);
1556 1403
1557 host_impl().SetViewportSize(root->bounds()); 1404 host_impl().SetViewportSize(root->bounds());
1558 host_impl().active_tree()->SetRootLayerForTesting(std::move(root)); 1405 host_impl().active_tree()->SetRootLayerForTesting(std::move(root));
1559 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); 1406 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
1560 1407
1561 // Sanity check the scenario we just created. 1408 // Sanity check the scenario we just created.
1562 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); 1409 ASSERT_EQ(1u, RenderSurfaceLayerList().size());
1563 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); 1410 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size());
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1608 host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( 1455 host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion(
1609 test_point); 1456 test_point);
1610 EXPECT_FALSE(result_layer); 1457 EXPECT_FALSE(result_layer);
1611 } 1458 }
1612 1459
1613 TEST_F(LayerTreeImplTest, 1460 TEST_F(LayerTreeImplTest,
1614 HitCheckingTouchHandlerRegionsForSinglePositionedLayer) { 1461 HitCheckingTouchHandlerRegionsForSinglePositionedLayer) {
1615 std::unique_ptr<LayerImpl> root = 1462 std::unique_ptr<LayerImpl> root =
1616 LayerImpl::Create(host_impl().active_tree(), 12345); 1463 LayerImpl::Create(host_impl().active_tree(), 12345);
1617 1464
1618 gfx::Transform identity_matrix;
1619 Region touch_handler_region(gfx::Rect(10, 10, 50, 50)); 1465 Region touch_handler_region(gfx::Rect(10, 10, 50, 50));
1620 gfx::Point3F transform_origin; 1466 // This layer is positioned, and hit testing should correctly know where the
1621 // this layer is positioned, and hit testing should correctly know where the
1622 // layer is located. 1467 // layer is located.
1623 gfx::PointF position(50.f, 50.f); 1468 root->SetPosition(gfx::PointF(50.f, 50.f));
1624 gfx::Size bounds(100, 100); 1469 root->SetBounds(gfx::Size(100, 100));
1625 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin,
1626 position, bounds, true, false, true);
1627 root->SetDrawsContent(true); 1470 root->SetDrawsContent(true);
1628 root->SetTouchEventHandlerRegion(touch_handler_region); 1471 root->SetTouchEventHandlerRegion(touch_handler_region);
1629 1472
1630 host_impl().SetViewportSize(root->bounds()); 1473 host_impl().SetViewportSize(root->bounds());
1631 host_impl().active_tree()->SetRootLayerForTesting(std::move(root)); 1474 host_impl().active_tree()->SetRootLayerForTesting(std::move(root));
1632 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); 1475 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
1633 1476
1634 // Sanity check the scenario we just created. 1477 // Sanity check the scenario we just created.
1635 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); 1478 ASSERT_EQ(1u, RenderSurfaceLayerList().size());
1636 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); 1479 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size());
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1676 } 1519 }
1677 1520
1678 TEST_F(LayerTreeImplTest, 1521 TEST_F(LayerTreeImplTest,
1679 HitCheckingTouchHandlerRegionsForSingleLayerWithDeviceScale) { 1522 HitCheckingTouchHandlerRegionsForSingleLayerWithDeviceScale) {
1680 // The layer's device_scale_factor and page_scale_factor should scale the 1523 // The layer's device_scale_factor and page_scale_factor should scale the
1681 // content rect and we should be able to hit the touch handler region by 1524 // content rect and we should be able to hit the touch handler region by
1682 // scaling the points accordingly. 1525 // scaling the points accordingly.
1683 std::unique_ptr<LayerImpl> root = 1526 std::unique_ptr<LayerImpl> root =
1684 LayerImpl::Create(host_impl().active_tree(), 1); 1527 LayerImpl::Create(host_impl().active_tree(), 1);
1685 1528
1686 gfx::Transform identity_matrix;
1687 gfx::Point3F transform_origin;
1688 // Set the bounds of the root layer big enough to fit the child when scaled. 1529 // Set the bounds of the root layer big enough to fit the child when scaled.
1689 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, 1530 root->SetBounds(gfx::Size(100, 100));
1690 gfx::PointF(), gfx::Size(100, 100), true, false,
1691 true);
1692 { 1531 {
1693 Region touch_handler_region(gfx::Rect(10, 10, 30, 30)); 1532 Region touch_handler_region(gfx::Rect(10, 10, 30, 30));
1694 gfx::PointF position(25.f, 25.f); 1533 gfx::PointF position(25.f, 25.f);
1695 gfx::Size bounds(50, 50); 1534 gfx::Size bounds(50, 50);
1696 std::unique_ptr<LayerImpl> test_layer = 1535 std::unique_ptr<LayerImpl> test_layer =
1697 LayerImpl::Create(host_impl().active_tree(), 12345); 1536 LayerImpl::Create(host_impl().active_tree(), 12345);
1698 SetLayerPropertiesForTesting(test_layer.get(), identity_matrix, 1537 test_layer->SetPosition(gfx::PointF(25.f, 25.f));
1699 transform_origin, position, bounds, true, 1538 test_layer->SetBounds(gfx::Size(50, 50));
1700 false, false);
1701
1702 test_layer->SetDrawsContent(true); 1539 test_layer->SetDrawsContent(true);
1703 test_layer->SetTouchEventHandlerRegion(touch_handler_region); 1540 test_layer->SetTouchEventHandlerRegion(touch_handler_region);
1704 root->test_properties()->AddChild(std::move(test_layer)); 1541 root->test_properties()->AddChild(std::move(test_layer));
1705 } 1542 }
1706 1543
1707 float device_scale_factor = 3.f; 1544 float device_scale_factor = 3.f;
1708 float page_scale_factor = 5.f; 1545 float page_scale_factor = 5.f;
1709 float max_page_scale_factor = 10.f; 1546 float max_page_scale_factor = 10.f;
1710 gfx::Size scaled_bounds_for_root = gfx::ScaleToCeiledSize( 1547 gfx::Size scaled_bounds_for_root = gfx::ScaleToCeiledSize(
1711 root->bounds(), device_scale_factor * page_scale_factor); 1548 root->bounds(), device_scale_factor * page_scale_factor);
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
1823 host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( 1660 host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion(
1824 test_point); 1661 test_point);
1825 ASSERT_TRUE(result_layer); 1662 ASSERT_TRUE(result_layer);
1826 EXPECT_EQ(12345, result_layer->id()); 1663 EXPECT_EQ(12345, result_layer->id());
1827 } 1664 }
1828 1665
1829 TEST_F(LayerTreeImplTest, HitCheckingTouchHandlerRegionsForSimpleClippedLayer) { 1666 TEST_F(LayerTreeImplTest, HitCheckingTouchHandlerRegionsForSimpleClippedLayer) {
1830 // Test that hit-checking will only work for the visible portion of a layer, 1667 // Test that hit-checking will only work for the visible portion of a layer,
1831 // and not the entire layer bounds. Here we just test the simple axis-aligned 1668 // and not the entire layer bounds. Here we just test the simple axis-aligned
1832 // case. 1669 // case.
1833 gfx::Transform identity_matrix;
1834 gfx::Point3F transform_origin;
1835
1836 std::unique_ptr<LayerImpl> root = 1670 std::unique_ptr<LayerImpl> root =
1837 LayerImpl::Create(host_impl().active_tree(), 1); 1671 LayerImpl::Create(host_impl().active_tree(), 1);
1838 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, 1672 root->SetBounds(gfx::Size(100, 100));
1839 gfx::PointF(), gfx::Size(100, 100), true, false,
1840 true);
1841 { 1673 {
1842 std::unique_ptr<LayerImpl> clipping_layer = 1674 std::unique_ptr<LayerImpl> clipping_layer =
1843 LayerImpl::Create(host_impl().active_tree(), 123); 1675 LayerImpl::Create(host_impl().active_tree(), 123);
1844 // this layer is positioned, and hit testing should correctly know where the 1676 // this layer is positioned, and hit testing should correctly know where the
1845 // layer is located. 1677 // layer is located.
1846 gfx::PointF position(25.f, 25.f); 1678 clipping_layer->SetPosition(gfx::PointF(25.f, 25.f));
1847 gfx::Size bounds(50, 50); 1679 clipping_layer->SetBounds(gfx::Size(50, 50));
1848 SetLayerPropertiesForTesting(clipping_layer.get(), identity_matrix,
1849 transform_origin, position, bounds, true,
1850 false, false);
1851 clipping_layer->SetMasksToBounds(true); 1680 clipping_layer->SetMasksToBounds(true);
1852 1681
1682 Region touch_handler_region(gfx::Rect(10, 10, 50, 50));
1683
1853 std::unique_ptr<LayerImpl> child = 1684 std::unique_ptr<LayerImpl> child =
1854 LayerImpl::Create(host_impl().active_tree(), 456); 1685 LayerImpl::Create(host_impl().active_tree(), 456);
1855 Region touch_handler_region(gfx::Rect(10, 10, 50, 50)); 1686 child->SetPosition(gfx::PointF(-50.f, -50.f));
1856 position = gfx::PointF(-50.f, -50.f); 1687 child->SetBounds(gfx::Size(300, 300));
1857 bounds = gfx::Size(300, 300);
1858 SetLayerPropertiesForTesting(child.get(), identity_matrix, transform_origin,
1859 position, bounds, true, false, false);
1860 child->SetDrawsContent(true); 1688 child->SetDrawsContent(true);
1861 child->SetTouchEventHandlerRegion(touch_handler_region); 1689 child->SetTouchEventHandlerRegion(touch_handler_region);
1862 clipping_layer->test_properties()->AddChild(std::move(child)); 1690 clipping_layer->test_properties()->AddChild(std::move(child));
1863 root->test_properties()->AddChild(std::move(clipping_layer)); 1691 root->test_properties()->AddChild(std::move(clipping_layer));
1864 } 1692 }
1865 1693
1866 host_impl().SetViewportSize(root->bounds()); 1694 host_impl().SetViewportSize(root->bounds());
1867 host_impl().active_tree()->SetRootLayerForTesting(std::move(root)); 1695 host_impl().active_tree()->SetRootLayerForTesting(std::move(root));
1868 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); 1696 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
1869 1697
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1912 EXPECT_EQ(456, result_layer->id()); 1740 EXPECT_EQ(456, result_layer->id());
1913 } 1741 }
1914 1742
1915 TEST_F(LayerTreeImplTest, 1743 TEST_F(LayerTreeImplTest,
1916 HitCheckingTouchHandlerRegionsForClippedLayerWithDeviceScale) { 1744 HitCheckingTouchHandlerRegionsForClippedLayerWithDeviceScale) {
1917 // The layer's device_scale_factor and page_scale_factor should scale the 1745 // The layer's device_scale_factor and page_scale_factor should scale the
1918 // content rect and we should be able to hit the touch handler region by 1746 // content rect and we should be able to hit the touch handler region by
1919 // scaling the points accordingly. 1747 // scaling the points accordingly.
1920 std::unique_ptr<LayerImpl> root = 1748 std::unique_ptr<LayerImpl> root =
1921 LayerImpl::Create(host_impl().active_tree(), 1); 1749 LayerImpl::Create(host_impl().active_tree(), 1);
1922
1923 gfx::Transform identity_matrix;
1924 gfx::Point3F transform_origin;
1925 // Set the bounds of the root layer big enough to fit the child when scaled. 1750 // Set the bounds of the root layer big enough to fit the child when scaled.
1926 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, 1751 root->SetBounds(gfx::Size(100, 100));
1927 gfx::PointF(), gfx::Size(100, 100), true, false,
1928 true);
1929 std::unique_ptr<LayerImpl> surface = 1752 std::unique_ptr<LayerImpl> surface =
1930 LayerImpl::Create(host_impl().active_tree(), 2); 1753 LayerImpl::Create(host_impl().active_tree(), 2);
1931 SetLayerPropertiesForTesting(surface.get(), identity_matrix, transform_origin, 1754 surface->SetBounds(gfx::Size(100, 100));
1932 gfx::PointF(), gfx::Size(100, 100), true, false, 1755 surface->test_properties()->force_render_surface = true;
1933 true);
1934 { 1756 {
1935 std::unique_ptr<LayerImpl> clipping_layer = 1757 std::unique_ptr<LayerImpl> clipping_layer =
1936 LayerImpl::Create(host_impl().active_tree(), 123); 1758 LayerImpl::Create(host_impl().active_tree(), 123);
1937 // This layer is positioned, and hit testing should correctly know where the 1759 // This layer is positioned, and hit testing should correctly know where the
1938 // layer is located. 1760 // layer is located.
1939 gfx::PointF position(25.f, 20.f); 1761 clipping_layer->SetPosition(gfx::PointF(25.f, 20.f));
1940 gfx::Size bounds(50, 50); 1762 clipping_layer->SetBounds(gfx::Size(50, 50));
1941 SetLayerPropertiesForTesting(clipping_layer.get(), identity_matrix,
1942 transform_origin, position, bounds, true,
1943 false, false);
1944 clipping_layer->SetMasksToBounds(true); 1763 clipping_layer->SetMasksToBounds(true);
1945 1764
1765 Region touch_handler_region(gfx::Rect(0, 0, 300, 300));
1766
1946 std::unique_ptr<LayerImpl> child = 1767 std::unique_ptr<LayerImpl> child =
1947 LayerImpl::Create(host_impl().active_tree(), 456); 1768 LayerImpl::Create(host_impl().active_tree(), 456);
1948 Region touch_handler_region(gfx::Rect(0, 0, 300, 300)); 1769 child->SetPosition(gfx::PointF(-50.f, -50.f));
1949 position = gfx::PointF(-50.f, -50.f); 1770 child->SetBounds(gfx::Size(300, 300));
1950 bounds = gfx::Size(300, 300);
1951 SetLayerPropertiesForTesting(child.get(), identity_matrix, transform_origin,
1952 position, bounds, true, false, false);
1953 child->SetDrawsContent(true); 1771 child->SetDrawsContent(true);
1954 child->SetTouchEventHandlerRegion(touch_handler_region); 1772 child->SetTouchEventHandlerRegion(touch_handler_region);
1955 clipping_layer->test_properties()->AddChild(std::move(child)); 1773 clipping_layer->test_properties()->AddChild(std::move(child));
1956 surface->test_properties()->AddChild(std::move(clipping_layer)); 1774 surface->test_properties()->AddChild(std::move(clipping_layer));
1957 root->test_properties()->AddChild(std::move(surface)); 1775 root->test_properties()->AddChild(std::move(surface));
1958 } 1776 }
1959 1777
1960 float device_scale_factor = 3.f; 1778 float device_scale_factor = 3.f;
1961 float page_scale_factor = 1.f; 1779 float page_scale_factor = 1.f;
1962 float max_page_scale_factor = 1.f; 1780 float max_page_scale_factor = 1.f;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1999 ASSERT_TRUE(result_layer); 1817 ASSERT_TRUE(result_layer);
2000 EXPECT_EQ(456, result_layer->id()); 1818 EXPECT_EQ(456, result_layer->id());
2001 } 1819 }
2002 1820
2003 TEST_F(LayerTreeImplTest, HitCheckingTouchHandlerOverlappingRegions) { 1821 TEST_F(LayerTreeImplTest, HitCheckingTouchHandlerOverlappingRegions) {
2004 gfx::Transform identity_matrix; 1822 gfx::Transform identity_matrix;
2005 gfx::Point3F transform_origin; 1823 gfx::Point3F transform_origin;
2006 1824
2007 std::unique_ptr<LayerImpl> root = 1825 std::unique_ptr<LayerImpl> root =
2008 LayerImpl::Create(host_impl().active_tree(), 1); 1826 LayerImpl::Create(host_impl().active_tree(), 1);
2009 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, 1827 root->SetBounds(gfx::Size(100, 100));
2010 gfx::PointF(), gfx::Size(100, 100), true, false,
2011 true);
2012 { 1828 {
2013 std::unique_ptr<LayerImpl> touch_layer = 1829 std::unique_ptr<LayerImpl> touch_layer =
2014 LayerImpl::Create(host_impl().active_tree(), 123); 1830 LayerImpl::Create(host_impl().active_tree(), 123);
2015 // this layer is positioned, and hit testing should correctly know where the 1831 // this layer is positioned, and hit testing should correctly know where the
2016 // layer is located. 1832 // layer is located.
2017 gfx::PointF position; 1833 touch_layer->SetBounds(gfx::Size(50, 50));
2018 gfx::Size bounds(50, 50);
2019 SetLayerPropertiesForTesting(touch_layer.get(), identity_matrix,
2020 transform_origin, position, bounds, true,
2021 false, false);
2022 touch_layer->SetDrawsContent(true); 1834 touch_layer->SetDrawsContent(true);
2023 touch_layer->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 50, 50)); 1835 touch_layer->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 50, 50));
2024 root->test_properties()->AddChild(std::move(touch_layer)); 1836 root->test_properties()->AddChild(std::move(touch_layer));
2025 } 1837 }
2026 1838
2027 { 1839 {
2028 std::unique_ptr<LayerImpl> notouch_layer = 1840 std::unique_ptr<LayerImpl> notouch_layer =
2029 LayerImpl::Create(host_impl().active_tree(), 1234); 1841 LayerImpl::Create(host_impl().active_tree(), 1234);
2030 // this layer is positioned, and hit testing should correctly know where the 1842 // this layer is positioned, and hit testing should correctly know where the
2031 // layer is located. 1843 // layer is located.
2032 gfx::PointF position(0, 25); 1844 notouch_layer->SetPosition(gfx::PointF(0, 25));
2033 gfx::Size bounds(50, 50); 1845 notouch_layer->SetBounds(gfx::Size(50, 50));
2034 SetLayerPropertiesForTesting(notouch_layer.get(), identity_matrix,
2035 transform_origin, position, bounds, true,
2036 false, false);
2037 notouch_layer->SetDrawsContent(true); 1846 notouch_layer->SetDrawsContent(true);
2038 root->test_properties()->AddChild(std::move(notouch_layer)); 1847 root->test_properties()->AddChild(std::move(notouch_layer));
2039 } 1848 }
2040 1849
2041 host_impl().SetViewportSize(root->bounds()); 1850 host_impl().SetViewportSize(root->bounds());
2042 host_impl().active_tree()->SetRootLayerForTesting(std::move(root)); 1851 host_impl().active_tree()->SetRootLayerForTesting(std::move(root));
2043 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); 1852 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
2044 1853
2045 // Sanity check the scenario we just created. 1854 // Sanity check the scenario we just created.
2046 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); 1855 ASSERT_EQ(1u, RenderSurfaceLayerList().size());
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
2078 test_point = gfx::PointF(35.f, 65.f); 1887 test_point = gfx::PointF(35.f, 65.f);
2079 result_layer = 1888 result_layer =
2080 host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( 1889 host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion(
2081 test_point); 1890 test_point);
2082 EXPECT_FALSE(result_layer); 1891 EXPECT_FALSE(result_layer);
2083 } 1892 }
2084 1893
2085 TEST_F(LayerTreeImplTest, HitTestingTouchHandlerRegionsForLayerThatIsNotDrawn) { 1894 TEST_F(LayerTreeImplTest, HitTestingTouchHandlerRegionsForLayerThatIsNotDrawn) {
2086 std::unique_ptr<LayerImpl> root = 1895 std::unique_ptr<LayerImpl> root =
2087 LayerImpl::Create(host_impl().active_tree(), 1); 1896 LayerImpl::Create(host_impl().active_tree(), 1);
2088 1897 root->SetBounds(gfx::Size(100, 100));
2089 gfx::Transform identity_matrix;
2090 gfx::Point3F transform_origin;
2091 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin,
2092 gfx::PointF(), gfx::Size(100, 100), true, false,
2093 true);
2094 root->SetDrawsContent(true); 1898 root->SetDrawsContent(true);
2095 { 1899 {
2096 Region touch_handler_region(gfx::Rect(10, 10, 30, 30)); 1900 Region touch_handler_region(gfx::Rect(10, 10, 30, 30));
2097 gfx::PointF position;
2098 gfx::Size bounds(50, 50);
2099 std::unique_ptr<LayerImpl> test_layer = 1901 std::unique_ptr<LayerImpl> test_layer =
2100 LayerImpl::Create(host_impl().active_tree(), 12345); 1902 LayerImpl::Create(host_impl().active_tree(), 12345);
2101 SetLayerPropertiesForTesting(test_layer.get(), identity_matrix, 1903 test_layer->SetBounds(gfx::Size(50, 50));
2102 transform_origin, position, bounds, true,
2103 false, false);
2104
2105 test_layer->SetDrawsContent(false); 1904 test_layer->SetDrawsContent(false);
2106 test_layer->SetTouchEventHandlerRegion(touch_handler_region); 1905 test_layer->SetTouchEventHandlerRegion(touch_handler_region);
2107 root->test_properties()->AddChild(std::move(test_layer)); 1906 root->test_properties()->AddChild(std::move(test_layer));
2108 } 1907 }
2109 host_impl().SetViewportSize(root->bounds()); 1908 host_impl().SetViewportSize(root->bounds());
2110 host_impl().active_tree()->SetRootLayerForTesting(std::move(root)); 1909 host_impl().active_tree()->SetRootLayerForTesting(std::move(root));
2111 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); 1910 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
2112 1911
2113 LayerImpl* test_layer = host_impl() 1912 LayerImpl* test_layer = host_impl()
2114 .active_tree() 1913 .active_tree()
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
2167 expected_screen_space_transform, 1966 expected_screen_space_transform,
2168 draw_property_utils::ScreenSpaceTransform( 1967 draw_property_utils::ScreenSpaceTransform(
2169 test_layer, 1968 test_layer,
2170 host_impl().active_tree()->property_trees()->transform_tree)); 1969 host_impl().active_tree()->property_trees()->transform_tree));
2171 } 1970 }
2172 1971
2173 TEST_F(LayerTreeImplTest, SelectionBoundsForSingleLayer) { 1972 TEST_F(LayerTreeImplTest, SelectionBoundsForSingleLayer) {
2174 int root_layer_id = 12345; 1973 int root_layer_id = 12345;
2175 std::unique_ptr<LayerImpl> root = 1974 std::unique_ptr<LayerImpl> root =
2176 LayerImpl::Create(host_impl().active_tree(), root_layer_id); 1975 LayerImpl::Create(host_impl().active_tree(), root_layer_id);
2177 1976 root->SetBounds(gfx::Size(100, 100));
2178 gfx::Transform identity_matrix;
2179 gfx::Point3F transform_origin;
2180 gfx::PointF position;
2181 gfx::Size bounds(100, 100);
2182 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin,
2183 position, bounds, true, false, true);
2184 root->SetDrawsContent(true); 1977 root->SetDrawsContent(true);
2185 1978
2186 host_impl().SetViewportSize(root->bounds()); 1979 host_impl().SetViewportSize(root->bounds());
2187 host_impl().active_tree()->SetRootLayerForTesting(std::move(root)); 1980 host_impl().active_tree()->SetRootLayerForTesting(std::move(root));
2188 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); 1981 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
2189 1982
2190 // Sanity check the scenario we just created. 1983 // Sanity check the scenario we just created.
2191 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); 1984 ASSERT_EQ(1u, RenderSurfaceLayerList().size());
2192 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); 1985 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size());
2193 1986
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
2248 EXPECT_EQ(output.start, output.end); 2041 EXPECT_EQ(output.start, output.end);
2249 } 2042 }
2250 2043
2251 TEST_F(LayerTreeImplTest, SelectionBoundsForPartialOccludedLayers) { 2044 TEST_F(LayerTreeImplTest, SelectionBoundsForPartialOccludedLayers) {
2252 int root_layer_id = 12345; 2045 int root_layer_id = 12345;
2253 int clip_layer_id = 1234; 2046 int clip_layer_id = 1234;
2254 int clipped_layer_id = 123; 2047 int clipped_layer_id = 123;
2255 std::unique_ptr<LayerImpl> root = 2048 std::unique_ptr<LayerImpl> root =
2256 LayerImpl::Create(host_impl().active_tree(), root_layer_id); 2049 LayerImpl::Create(host_impl().active_tree(), root_layer_id);
2257 root->SetDrawsContent(true); 2050 root->SetDrawsContent(true);
2258 2051 root->SetBounds(gfx::Size(100, 100));
2259 gfx::Transform identity_matrix;
2260 gfx::Point3F transform_origin;
2261 gfx::PointF position;
2262 gfx::Size bounds(100, 100);
2263 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin,
2264 position, bounds, true, false, true);
2265 2052
2266 gfx::Vector2dF clipping_offset(10, 10); 2053 gfx::Vector2dF clipping_offset(10, 10);
2267 { 2054 {
2268 std::unique_ptr<LayerImpl> clipping_layer = 2055 std::unique_ptr<LayerImpl> clipping_layer =
2269 LayerImpl::Create(host_impl().active_tree(), clip_layer_id); 2056 LayerImpl::Create(host_impl().active_tree(), clip_layer_id);
2270 // The clipping layer should occlude the right selection bound. 2057 // The clipping layer should occlude the right selection bound.
2271 gfx::PointF position = gfx::PointF() + clipping_offset; 2058 clipping_layer->SetPosition(gfx::PointF() + clipping_offset);
2272 gfx::Size bounds(50, 50); 2059 clipping_layer->SetBounds(gfx::Size(50, 50));
2273 SetLayerPropertiesForTesting(clipping_layer.get(), identity_matrix,
2274 transform_origin, position, bounds, true,
2275 false, false);
2276 clipping_layer->SetMasksToBounds(true); 2060 clipping_layer->SetMasksToBounds(true);
2277 2061
2278 std::unique_ptr<LayerImpl> clipped_layer = 2062 std::unique_ptr<LayerImpl> clipped_layer =
2279 LayerImpl::Create(host_impl().active_tree(), clipped_layer_id); 2063 LayerImpl::Create(host_impl().active_tree(), clipped_layer_id);
2280 position = gfx::PointF(); 2064 clipped_layer->SetBounds(gfx::Size(100, 100));
2281 bounds = gfx::Size(100, 100);
2282 SetLayerPropertiesForTesting(clipped_layer.get(), identity_matrix,
2283 transform_origin, position, bounds, true,
2284 false, false);
2285 clipped_layer->SetDrawsContent(true); 2065 clipped_layer->SetDrawsContent(true);
2286 clipping_layer->test_properties()->AddChild(std::move(clipped_layer)); 2066 clipping_layer->test_properties()->AddChild(std::move(clipped_layer));
2287 root->test_properties()->AddChild(std::move(clipping_layer)); 2067 root->test_properties()->AddChild(std::move(clipping_layer));
2288 } 2068 }
2289 2069
2290 host_impl().SetViewportSize(root->bounds()); 2070 host_impl().SetViewportSize(root->bounds());
2291 host_impl().active_tree()->SetRootLayerForTesting(std::move(root)); 2071 host_impl().active_tree()->SetRootLayerForTesting(std::move(root));
2292 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); 2072 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
2293 2073
2294 // Sanity check the scenario we just created. 2074 // Sanity check the scenario we just created.
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
2346 host_impl().active_tree()->GetViewportSelection(&output); 2126 host_impl().active_tree()->GetViewportSelection(&output);
2347 EXPECT_TRUE(output.start.visible()); 2127 EXPECT_TRUE(output.start.visible());
2348 } 2128 }
2349 2129
2350 TEST_F(LayerTreeImplTest, SelectionBoundsForScaledLayers) { 2130 TEST_F(LayerTreeImplTest, SelectionBoundsForScaledLayers) {
2351 int root_layer_id = 1; 2131 int root_layer_id = 1;
2352 int sub_layer_id = 2; 2132 int sub_layer_id = 2;
2353 std::unique_ptr<LayerImpl> root = 2133 std::unique_ptr<LayerImpl> root =
2354 LayerImpl::Create(host_impl().active_tree(), root_layer_id); 2134 LayerImpl::Create(host_impl().active_tree(), root_layer_id);
2355 root->SetDrawsContent(true); 2135 root->SetDrawsContent(true);
2356 2136 root->SetBounds(gfx::Size(100, 100));
2357 gfx::Transform identity_matrix;
2358 gfx::Point3F transform_origin;
2359 gfx::PointF position;
2360 gfx::Size bounds(100, 100);
2361 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin,
2362 position, bounds, true, false, true);
2363 2137
2364 gfx::Vector2dF sub_layer_offset(10, 0); 2138 gfx::Vector2dF sub_layer_offset(10, 0);
2365 { 2139 {
2366 std::unique_ptr<LayerImpl> sub_layer = 2140 std::unique_ptr<LayerImpl> sub_layer =
2367 LayerImpl::Create(host_impl().active_tree(), sub_layer_id); 2141 LayerImpl::Create(host_impl().active_tree(), sub_layer_id);
2368 gfx::PointF position = gfx::PointF() + sub_layer_offset; 2142 sub_layer->SetPosition(gfx::PointF() + sub_layer_offset);
2369 gfx::Size bounds(50, 50); 2143 sub_layer->SetBounds(gfx::Size(50, 50));
2370 SetLayerPropertiesForTesting(sub_layer.get(), identity_matrix,
2371 transform_origin, position, bounds, true,
2372 false, false);
2373 sub_layer->SetDrawsContent(true); 2144 sub_layer->SetDrawsContent(true);
2374 root->test_properties()->AddChild(std::move(sub_layer)); 2145 root->test_properties()->AddChild(std::move(sub_layer));
2375 } 2146 }
2376 2147
2377 float device_scale_factor = 3.f; 2148 float device_scale_factor = 3.f;
2378 float page_scale_factor = 5.f; 2149 float page_scale_factor = 5.f;
2379 gfx::Size scaled_bounds_for_root = gfx::ScaleToCeiledSize( 2150 gfx::Size scaled_bounds_for_root = gfx::ScaleToCeiledSize(
2380 root->bounds(), device_scale_factor * page_scale_factor); 2151 root->bounds(), device_scale_factor * page_scale_factor);
2381 host_impl().SetViewportSize(scaled_bounds_for_root); 2152 host_impl().SetViewportSize(scaled_bounds_for_root);
2382 2153
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
2431 EXPECT_TRUE(output.end.visible()); 2202 EXPECT_TRUE(output.end.visible());
2432 } 2203 }
2433 2204
2434 TEST_F(LayerTreeImplTest, SelectionBoundsWithLargeTransforms) { 2205 TEST_F(LayerTreeImplTest, SelectionBoundsWithLargeTransforms) {
2435 int root_id = 1; 2206 int root_id = 1;
2436 int child_id = 2; 2207 int child_id = 2;
2437 int grand_child_id = 3; 2208 int grand_child_id = 3;
2438 2209
2439 std::unique_ptr<LayerImpl> root = 2210 std::unique_ptr<LayerImpl> root =
2440 LayerImpl::Create(host_impl().active_tree(), root_id); 2211 LayerImpl::Create(host_impl().active_tree(), root_id);
2441 gfx::Size bounds(100, 100); 2212 root->SetBounds(gfx::Size(100, 100));
2442 gfx::Transform identity_matrix;
2443 gfx::Point3F transform_origin;
2444 gfx::PointF position;
2445
2446 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin,
2447 position, bounds, true, false, true);
2448 2213
2449 gfx::Transform large_transform; 2214 gfx::Transform large_transform;
2450 large_transform.Scale(SkDoubleToMScalar(1e37), SkDoubleToMScalar(1e37)); 2215 large_transform.Scale(SkDoubleToMScalar(1e37), SkDoubleToMScalar(1e37));
2451 large_transform.RotateAboutYAxis(30); 2216 large_transform.RotateAboutYAxis(30);
2452 2217
2453 { 2218 {
2454 std::unique_ptr<LayerImpl> child = 2219 std::unique_ptr<LayerImpl> child =
2455 LayerImpl::Create(host_impl().active_tree(), child_id); 2220 LayerImpl::Create(host_impl().active_tree(), child_id);
2456 SetLayerPropertiesForTesting(child.get(), large_transform, transform_origin, 2221 child->SetTransform(large_transform);
2457 position, bounds, true, false, false); 2222 child->SetBounds(gfx::Size(100, 100));
2458 2223
2459 std::unique_ptr<LayerImpl> grand_child = 2224 std::unique_ptr<LayerImpl> grand_child =
2460 LayerImpl::Create(host_impl().active_tree(), grand_child_id); 2225 LayerImpl::Create(host_impl().active_tree(), grand_child_id);
2461 SetLayerPropertiesForTesting(grand_child.get(), large_transform, 2226 grand_child->SetTransform(large_transform);
2462 transform_origin, position, bounds, true, 2227 grand_child->SetBounds(gfx::Size(100, 100));
2463 false, false);
2464 grand_child->SetDrawsContent(true); 2228 grand_child->SetDrawsContent(true);
2465 2229
2466 child->test_properties()->AddChild(std::move(grand_child)); 2230 child->test_properties()->AddChild(std::move(grand_child));
2467 root->test_properties()->AddChild(std::move(child)); 2231 root->test_properties()->AddChild(std::move(child));
2468 } 2232 }
2469 2233
2470 host_impl().SetViewportSize(root->bounds()); 2234 host_impl().SetViewportSize(root->bounds());
2471 host_impl().active_tree()->SetRootLayerForTesting(std::move(root)); 2235 host_impl().active_tree()->SetRootLayerForTesting(std::move(root));
2472 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); 2236 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
2473 2237
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
2525 TEST_F(LayerTreeImplTest, HitTestingCorrectLayerWheelListener) { 2289 TEST_F(LayerTreeImplTest, HitTestingCorrectLayerWheelListener) {
2526 host_impl().active_tree()->set_event_listener_properties( 2290 host_impl().active_tree()->set_event_listener_properties(
2527 EventListenerClass::kMouseWheel, EventListenerProperties::kBlocking); 2291 EventListenerClass::kMouseWheel, EventListenerProperties::kBlocking);
2528 std::unique_ptr<LayerImpl> root = 2292 std::unique_ptr<LayerImpl> root =
2529 LayerImpl::Create(host_impl().active_tree(), 1); 2293 LayerImpl::Create(host_impl().active_tree(), 1);
2530 std::unique_ptr<LayerImpl> left_child = 2294 std::unique_ptr<LayerImpl> left_child =
2531 LayerImpl::Create(host_impl().active_tree(), 2); 2295 LayerImpl::Create(host_impl().active_tree(), 2);
2532 std::unique_ptr<LayerImpl> right_child = 2296 std::unique_ptr<LayerImpl> right_child =
2533 LayerImpl::Create(host_impl().active_tree(), 3); 2297 LayerImpl::Create(host_impl().active_tree(), 3);
2534 2298
2535 gfx::Point3F transform_origin;
2536 gfx::PointF position;
2537 gfx::Size bounds(100, 100);
2538 { 2299 {
2539 gfx::Transform translate_z; 2300 gfx::Transform translate_z;
2540 translate_z.Translate3d(0, 0, 10); 2301 translate_z.Translate3d(0, 0, 10);
2541 SetLayerPropertiesForTesting(root.get(), translate_z, transform_origin, 2302 root->SetTransform(translate_z);
2542 position, bounds, false, false, true); 2303 root->SetBounds(gfx::Size(100, 100));
2543 root->SetDrawsContent(true); 2304 root->SetDrawsContent(true);
2544 } 2305 }
2545 { 2306 {
2546 gfx::Transform translate_z; 2307 gfx::Transform translate_z;
2547 translate_z.Translate3d(0, 0, 10); 2308 translate_z.Translate3d(0, 0, 10);
2548 SetLayerPropertiesForTesting(left_child.get(), translate_z, 2309 left_child->SetTransform(translate_z);
2549 transform_origin, position, bounds, false, 2310 left_child->SetBounds(gfx::Size(100, 100));
2550 false, false);
2551 left_child->SetDrawsContent(true); 2311 left_child->SetDrawsContent(true);
2552 } 2312 }
2553 { 2313 {
2554 gfx::Transform translate_z; 2314 gfx::Transform translate_z;
2555 translate_z.Translate3d(0, 0, 10); 2315 translate_z.Translate3d(0, 0, 10);
2556 SetLayerPropertiesForTesting(right_child.get(), translate_z, 2316 right_child->SetTransform(translate_z);
2557 transform_origin, position, bounds, false, 2317 right_child->SetBounds(gfx::Size(100, 100));
2558 false, false);
2559 } 2318 }
2560 2319
2561 root->test_properties()->AddChild(std::move(left_child)); 2320 root->test_properties()->AddChild(std::move(left_child));
2562 root->test_properties()->AddChild(std::move(right_child)); 2321 root->test_properties()->AddChild(std::move(right_child));
2563 2322
2564 host_impl().SetViewportSize(root->bounds()); 2323 host_impl().SetViewportSize(root->bounds());
2565 host_impl().active_tree()->SetRootLayerForTesting(std::move(root)); 2324 host_impl().active_tree()->SetRootLayerForTesting(std::move(root));
2566 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); 2325 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
2567 CHECK_EQ(1u, RenderSurfaceLayerList().size()); 2326 CHECK_EQ(1u, RenderSurfaceLayerList().size());
2568 2327
2569 gfx::PointF test_point = gfx::PointF(1.f, 1.f); 2328 gfx::PointF test_point = gfx::PointF(1.f, 1.f);
2570 LayerImpl* result_layer = 2329 LayerImpl* result_layer =
2571 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); 2330 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point);
2572 2331
2573 CHECK(result_layer); 2332 CHECK(result_layer);
2574 EXPECT_EQ(2, result_layer->id()); 2333 EXPECT_EQ(2, result_layer->id());
2575 } 2334 }
2576 2335
2577 } // namespace 2336 } // namespace
2578 } // namespace cc 2337 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_common_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698