diff options
author | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2016-07-14 17:41:05 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2016-08-04 12:37:36 +0000 |
commit | 399c965b6064c440ddcf4015f5f8e9d131c7a0a6 (patch) | |
tree | 6b06b60ff365abef0e13b3503d593a0df48d20e8 /chromium/cc/trees/layer_tree_impl_unittest.cc | |
parent | 7366110654eec46f21b6824f302356426f48cd74 (diff) |
BASELINE: Update Chromium to 52.0.2743.76 and Ninja to 1.7.1
Change-Id: I382f51b959689505a60f8b707255ecb344f7d8b4
Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'chromium/cc/trees/layer_tree_impl_unittest.cc')
-rw-r--r-- | chromium/cc/trees/layer_tree_impl_unittest.cc | 304 |
1 files changed, 208 insertions, 96 deletions
diff --git a/chromium/cc/trees/layer_tree_impl_unittest.cc b/chromium/cc/trees/layer_tree_impl_unittest.cc index 8781d2fc702..c6afcee459f 100644 --- a/chromium/cc/trees/layer_tree_impl_unittest.cc +++ b/chromium/cc/trees/layer_tree_impl_unittest.cc @@ -26,6 +26,7 @@ class LayerTreeImplTest : public LayerTreeHostCommonTest { LayerTreeImplTest() : output_surface_(FakeOutputSurface::Create3d()) { LayerTreeSettings settings; settings.layer_transforms_should_scale_layer_contents = true; + settings.verify_clip_tree_calculations = true; host_impl_.reset(new FakeLayerTreeHostImpl(settings, &task_runner_provider_, &shared_bitmap_manager_, &task_graph_runner_)); @@ -54,12 +55,12 @@ class LayerTreeImplTest : public LayerTreeHostCommonTest { TestSharedBitmapManager shared_bitmap_manager_; TestTaskGraphRunner task_graph_runner_; FakeImplTaskRunnerProvider task_runner_provider_; - scoped_ptr<OutputSurface> output_surface_; - scoped_ptr<FakeLayerTreeHostImpl> host_impl_; + std::unique_ptr<OutputSurface> output_surface_; + std::unique_ptr<FakeLayerTreeHostImpl> host_impl_; }; TEST_F(LayerTreeImplTest, HitTestingForSingleLayer) { - scoped_ptr<LayerImpl> root = + std::unique_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 12345); gfx::Transform identity_matrix; @@ -109,14 +110,15 @@ TEST_F(LayerTreeImplTest, UpdateViewportAndHitTest) { TestTaskGraphRunner task_graph_runner; FakeImplTaskRunnerProvider task_runner_provider; LayerTreeSettings settings; - scoped_ptr<OutputSurface> output_surface = FakeOutputSurface::Create3d(); - scoped_ptr<FakeLayerTreeHostImpl> host_impl; + settings.verify_clip_tree_calculations = true; + std::unique_ptr<OutputSurface> output_surface = FakeOutputSurface::Create3d(); + std::unique_ptr<FakeLayerTreeHostImpl> host_impl; host_impl.reset(new FakeLayerTreeHostImpl(settings, &task_runner_provider, &shared_bitmap_manager, &task_graph_runner)); host_impl->SetVisible(true); EXPECT_TRUE(host_impl->InitializeRenderer(output_surface.get())); - scoped_ptr<LayerImpl> root = + std::unique_ptr<LayerImpl> root = LayerImpl::Create(host_impl->active_tree(), 12345); gfx::Transform identity_matrix; @@ -147,9 +149,9 @@ TEST_F(LayerTreeImplTest, UpdateViewportAndHitTest) { } TEST_F(LayerTreeImplTest, HitTestingForSingleLayerAndHud) { - scoped_ptr<LayerImpl> root = + std::unique_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 12345); - scoped_ptr<HeadsUpDisplayLayerImpl> hud = + std::unique_ptr<HeadsUpDisplayLayerImpl> hud = HeadsUpDisplayLayerImpl::Create(host_impl().active_tree(), 11111); gfx::Transform identity_matrix; @@ -204,7 +206,7 @@ TEST_F(LayerTreeImplTest, HitTestingForSingleLayerAndHud) { } TEST_F(LayerTreeImplTest, HitTestingForUninvertibleTransform) { - scoped_ptr<LayerImpl> root = + std::unique_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 12345); gfx::Transform uninvertible_transform; @@ -271,7 +273,7 @@ TEST_F(LayerTreeImplTest, HitTestingForUninvertibleTransform) { } TEST_F(LayerTreeImplTest, HitTestingForSinglePositionedLayer) { - scoped_ptr<LayerImpl> root = + std::unique_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 12345); gfx::Transform identity_matrix; @@ -320,7 +322,7 @@ TEST_F(LayerTreeImplTest, HitTestingForSinglePositionedLayer) { } TEST_F(LayerTreeImplTest, HitTestingForSingleRotatedLayer) { - scoped_ptr<LayerImpl> root = + std::unique_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 12345); gfx::Transform identity_matrix; @@ -381,13 +383,14 @@ TEST_F(LayerTreeImplTest, HitTestingClipNodeDifferentTransformAndTargetIds) { // Tests hit testing on a layer whose clip node has different transform and // target id. gfx::Transform identity_matrix; - scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); + std::unique_ptr<LayerImpl> root = + LayerImpl::Create(host_impl().active_tree(), 1); SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), gfx::PointF(), gfx::Size(500, 500), true, false, true); gfx::Transform translation; translation.Translate(100, 100); - scoped_ptr<LayerImpl> render_surface = + std::unique_ptr<LayerImpl> render_surface = LayerImpl::Create(host_impl().active_tree(), 2); SetLayerPropertiesForTesting(render_surface.get(), translation, gfx::Point3F(), gfx::PointF(), @@ -395,18 +398,21 @@ TEST_F(LayerTreeImplTest, HitTestingClipNodeDifferentTransformAndTargetIds) { gfx::Transform scale_matrix; scale_matrix.Scale(2, 2); - scoped_ptr<LayerImpl> scale = LayerImpl::Create(host_impl().active_tree(), 3); + std::unique_ptr<LayerImpl> scale = + LayerImpl::Create(host_impl().active_tree(), 3); SetLayerPropertiesForTesting(scale.get(), scale_matrix, gfx::Point3F(), gfx::PointF(), gfx::Size(50, 50), true, false, false); - scoped_ptr<LayerImpl> clip = LayerImpl::Create(host_impl().active_tree(), 4); + std::unique_ptr<LayerImpl> clip = + LayerImpl::Create(host_impl().active_tree(), 4); SetLayerPropertiesForTesting(clip.get(), identity_matrix, gfx::Point3F(), gfx::PointF(), gfx::Size(25, 25), true, false, false); clip->SetMasksToBounds(true); - scoped_ptr<LayerImpl> test = LayerImpl::Create(host_impl().active_tree(), 5); + std::unique_ptr<LayerImpl> test = + LayerImpl::Create(host_impl().active_tree(), 5); SetLayerPropertiesForTesting(test.get(), identity_matrix, gfx::Point3F(), gfx::PointF(), gfx::Size(100, 100), true, false, false); @@ -440,18 +446,19 @@ TEST_F(LayerTreeImplTest, HitTestingClipNodeDifferentTransformAndTargetIds) { TEST_F(LayerTreeImplTest, HitTestingSiblings) { // This tests hit testing when the test point hits only one of the siblings. gfx::Transform identity_matrix; - scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); + std::unique_ptr<LayerImpl> root = + LayerImpl::Create(host_impl().active_tree(), 1); SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), gfx::PointF(), gfx::Size(100, 100), true, false, true); - scoped_ptr<LayerImpl> child1 = + std::unique_ptr<LayerImpl> child1 = LayerImpl::Create(host_impl().active_tree(), 2); SetLayerPropertiesForTesting(child1.get(), identity_matrix, gfx::Point3F(), gfx::PointF(), gfx::Size(25, 25), true, false, false); child1->SetMasksToBounds(true); child1->SetDrawsContent(true); - scoped_ptr<LayerImpl> child2 = + std::unique_ptr<LayerImpl> child2 = LayerImpl::Create(host_impl().active_tree(), 3); SetLayerPropertiesForTesting(child2.get(), identity_matrix, gfx::Point3F(), gfx::PointF(), gfx::Size(75, 75), true, false, @@ -478,11 +485,12 @@ TEST_F(LayerTreeImplTest, HitTestingPointOutsideMaxTextureSize) { host_impl().active_tree()->resource_provider()->max_texture_size(); gfx::Size bounds(max_texture_size + 100, max_texture_size + 100); - scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); + std::unique_ptr<LayerImpl> root = + LayerImpl::Create(host_impl().active_tree(), 1); SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), gfx::PointF(), bounds, true, false, true); - scoped_ptr<LayerImpl> surface = + std::unique_ptr<LayerImpl> surface = LayerImpl::Create(host_impl().active_tree(), 2); SetLayerPropertiesForTesting(surface.get(), identity_matrix, gfx::Point3F(), gfx::PointF(), bounds, true, false, true); @@ -506,7 +514,7 @@ TEST_F(LayerTreeImplTest, HitTestingPointOutsideMaxTextureSize) { } TEST_F(LayerTreeImplTest, HitTestingForSinglePerspectiveLayer) { - scoped_ptr<LayerImpl> root = + std::unique_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 12345); gfx::Transform identity_matrix; @@ -570,12 +578,13 @@ TEST_F(LayerTreeImplTest, HitTestingForSimpleClippedLayer) { gfx::Transform identity_matrix; gfx::Point3F transform_origin; - scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); + std::unique_ptr<LayerImpl> root = + LayerImpl::Create(host_impl().active_tree(), 1); SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, gfx::PointF(), gfx::Size(100, 100), true, false, true); { - scoped_ptr<LayerImpl> clipping_layer = + std::unique_ptr<LayerImpl> clipping_layer = LayerImpl::Create(host_impl().active_tree(), 123); // this layer is positioned, and hit testing should correctly know where the // layer is located. @@ -586,7 +595,7 @@ TEST_F(LayerTreeImplTest, HitTestingForSimpleClippedLayer) { false, false); clipping_layer->SetMasksToBounds(true); - scoped_ptr<LayerImpl> child = + std::unique_ptr<LayerImpl> child = LayerImpl::Create(host_impl().active_tree(), 456); position = gfx::PointF(-50.f, -50.f); bounds = gfx::Size(300, 300); @@ -646,7 +655,7 @@ TEST_F(LayerTreeImplTest, HitTestingForMultiClippedRotatedLayer) { // the root + child clips combined create a triangle. The rotated_leaf will // only be visible where it overlaps this triangle. // - scoped_ptr<LayerImpl> root = + std::unique_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 123); LayerImpl* root_layer = root.get(); @@ -658,11 +667,11 @@ TEST_F(LayerTreeImplTest, HitTestingForMultiClippedRotatedLayer) { position, bounds, true, false, true); root->SetMasksToBounds(true); { - scoped_ptr<LayerImpl> child = + std::unique_ptr<LayerImpl> child = LayerImpl::Create(host_impl().active_tree(), 456); - scoped_ptr<LayerImpl> grand_child = + std::unique_ptr<LayerImpl> grand_child = LayerImpl::Create(host_impl().active_tree(), 789); - scoped_ptr<LayerImpl> rotated_leaf = + std::unique_ptr<LayerImpl> rotated_leaf = LayerImpl::Create(host_impl().active_tree(), 2468); position = gfx::PointF(10.f, 10.f); @@ -763,12 +772,13 @@ TEST_F(LayerTreeImplTest, HitTestingForNonClippingIntermediateLayer) { gfx::Transform identity_matrix; gfx::Point3F transform_origin; - scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); + std::unique_ptr<LayerImpl> root = + LayerImpl::Create(host_impl().active_tree(), 1); SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, gfx::PointF(), gfx::Size(100, 100), true, false, true); { - scoped_ptr<LayerImpl> intermediate_layer = + std::unique_ptr<LayerImpl> intermediate_layer = LayerImpl::Create(host_impl().active_tree(), 123); // this layer is positioned, and hit testing should correctly know where the // layer is located. @@ -784,7 +794,7 @@ TEST_F(LayerTreeImplTest, HitTestingForNonClippingIntermediateLayer) { // The child of the intermediate_layer is translated so that it does not // overlap intermediate_layer at all. If child is incorrectly clipped, we // would not be able to hit it successfully. - scoped_ptr<LayerImpl> child = + std::unique_ptr<LayerImpl> child = LayerImpl::Create(host_impl().active_tree(), 456); position = gfx::PointF(60.f, 60.f); // 70, 70 in screen space bounds = gfx::Size(20, 20); @@ -830,7 +840,8 @@ TEST_F(LayerTreeImplTest, HitTestingForNonClippingIntermediateLayer) { } TEST_F(LayerTreeImplTest, HitTestingForMultipleLayers) { - scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); + std::unique_ptr<LayerImpl> root = + LayerImpl::Create(host_impl().active_tree(), 1); LayerImpl* root_layer = root.get(); gfx::Transform identity_matrix; @@ -847,11 +858,11 @@ TEST_F(LayerTreeImplTest, HitTestingForMultipleLayers) { // grand_child, (third) child1, and (back) the root layer behind all other // layers. - scoped_ptr<LayerImpl> child1 = + std::unique_ptr<LayerImpl> child1 = LayerImpl::Create(host_impl().active_tree(), 2); - scoped_ptr<LayerImpl> child2 = + std::unique_ptr<LayerImpl> child2 = LayerImpl::Create(host_impl().active_tree(), 3); - scoped_ptr<LayerImpl> grand_child1 = + std::unique_ptr<LayerImpl> grand_child1 = LayerImpl::Create(host_impl().active_tree(), 4); position = gfx::PointF(10.f, 10.f); @@ -963,11 +974,11 @@ int LayerTreeImplTest::HitTestSimpleTree(int root_id, float root_depth, float left_child_depth, float right_child_depth) { - scoped_ptr<LayerImpl> root = + std::unique_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), root_id); - scoped_ptr<LayerImpl> left_child = + std::unique_ptr<LayerImpl> left_child = LayerImpl::Create(host_impl().active_tree(), left_child_id); - scoped_ptr<LayerImpl> right_child = + std::unique_ptr<LayerImpl> right_child = LayerImpl::Create(host_impl().active_tree(), right_child_id); gfx::Point3F transform_origin; @@ -1053,7 +1064,8 @@ TEST_F(LayerTreeImplTest, HitTestingSameSortingContextParentWins) { } TEST_F(LayerTreeImplTest, HitTestingForMultipleLayersAtVaryingDepths) { - scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); + std::unique_ptr<LayerImpl> root = + LayerImpl::Create(host_impl().active_tree(), 1); gfx::Transform identity_matrix; gfx::Point3F transform_origin; @@ -1062,7 +1074,7 @@ TEST_F(LayerTreeImplTest, HitTestingForMultipleLayersAtVaryingDepths) { SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, position, bounds, true, false, true); root->SetDrawsContent(true); - root->SetShouldFlattenTransform(false); + root->test_properties()->should_flatten_transform = false; root->Set3dSortingContextId(1); { // child 1 and child2 are initialized to overlap between x=50 and x=60. @@ -1071,11 +1083,11 @@ TEST_F(LayerTreeImplTest, HitTestingForMultipleLayersAtVaryingDepths) { // grand_child, (third) child1, and (back) the root layer behind all other // layers. - scoped_ptr<LayerImpl> child1 = + std::unique_ptr<LayerImpl> child1 = LayerImpl::Create(host_impl().active_tree(), 2); - scoped_ptr<LayerImpl> child2 = + std::unique_ptr<LayerImpl> child2 = LayerImpl::Create(host_impl().active_tree(), 3); - scoped_ptr<LayerImpl> grand_child1 = + std::unique_ptr<LayerImpl> grand_child1 = LayerImpl::Create(host_impl().active_tree(), 4); position = gfx::PointF(10.f, 10.f); @@ -1084,7 +1096,7 @@ TEST_F(LayerTreeImplTest, HitTestingForMultipleLayersAtVaryingDepths) { transform_origin, position, bounds, true, false, false); child1->SetDrawsContent(true); - child1->SetShouldFlattenTransform(false); + child1->test_properties()->should_flatten_transform = false; child1->Set3dSortingContextId(1); position = gfx::PointF(50.f, 10.f); @@ -1094,7 +1106,7 @@ TEST_F(LayerTreeImplTest, HitTestingForMultipleLayersAtVaryingDepths) { SetLayerPropertiesForTesting(child2.get(), translate_z, transform_origin, position, bounds, true, false, false); child2->SetDrawsContent(true); - child2->SetShouldFlattenTransform(false); + child2->test_properties()->should_flatten_transform = false; child2->Set3dSortingContextId(1); // Remember that grand_child is positioned with respect to its parent (i.e. @@ -1106,7 +1118,7 @@ TEST_F(LayerTreeImplTest, HitTestingForMultipleLayersAtVaryingDepths) { transform_origin, position, bounds, true, false, false); grand_child1->SetDrawsContent(true); - grand_child1->SetShouldFlattenTransform(false); + grand_child1->test_properties()->should_flatten_transform = false; child1->AddChild(std::move(grand_child1)); root->AddChild(std::move(child1)); @@ -1177,7 +1189,8 @@ TEST_F(LayerTreeImplTest, HitTestingForMultipleLayersAtVaryingDepths) { } TEST_F(LayerTreeImplTest, HitTestingRespectsClipParents) { - scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); + std::unique_ptr<LayerImpl> root = + LayerImpl::Create(host_impl().active_tree(), 1); gfx::Transform identity_matrix; gfx::Point3F transform_origin; gfx::PointF position; @@ -1186,9 +1199,9 @@ TEST_F(LayerTreeImplTest, HitTestingRespectsClipParents) { position, bounds, true, false, true); root->SetDrawsContent(true); { - scoped_ptr<LayerImpl> child = + std::unique_ptr<LayerImpl> child = LayerImpl::Create(host_impl().active_tree(), 2); - scoped_ptr<LayerImpl> grand_child = + std::unique_ptr<LayerImpl> grand_child = LayerImpl::Create(host_impl().active_tree(), 4); position = gfx::PointF(10.f, 10.f); @@ -1207,10 +1220,11 @@ TEST_F(LayerTreeImplTest, HitTestingRespectsClipParents) { grand_child->SetHasRenderSurface(true); // This should let |grand_child| "escape" |child|'s clip. - grand_child->SetClipParent(root.get()); - scoped_ptr<std::set<LayerImpl*>> clip_children(new std::set<LayerImpl*>); + grand_child->test_properties()->clip_parent = root.get(); + std::unique_ptr<std::set<LayerImpl*>> clip_children( + new std::set<LayerImpl*>); clip_children->insert(grand_child.get()); - root->SetClipChildren(clip_children.release()); + root->test_properties()->clip_children.reset(clip_children.release()); child->AddChild(std::move(grand_child)); root->AddChild(std::move(child)); @@ -1228,7 +1242,8 @@ TEST_F(LayerTreeImplTest, HitTestingRespectsClipParents) { } TEST_F(LayerTreeImplTest, HitTestingRespectsScrollParents) { - scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); + std::unique_ptr<LayerImpl> root = + LayerImpl::Create(host_impl().active_tree(), 1); gfx::Transform identity_matrix; gfx::Point3F transform_origin; gfx::PointF position; @@ -1237,11 +1252,11 @@ TEST_F(LayerTreeImplTest, HitTestingRespectsScrollParents) { position, bounds, true, false, true); root->SetDrawsContent(true); { - scoped_ptr<LayerImpl> child = + std::unique_ptr<LayerImpl> child = LayerImpl::Create(host_impl().active_tree(), 2); - scoped_ptr<LayerImpl> scroll_child = + std::unique_ptr<LayerImpl> scroll_child = LayerImpl::Create(host_impl().active_tree(), 3); - scoped_ptr<LayerImpl> grand_child = + std::unique_ptr<LayerImpl> grand_child = LayerImpl::Create(host_impl().active_tree(), 4); position = gfx::PointF(10.f, 10.f); @@ -1260,10 +1275,11 @@ TEST_F(LayerTreeImplTest, HitTestingRespectsScrollParents) { // This should cause scroll child and its descendants to be affected by // |child|'s clip. - scroll_child->SetScrollParent(child.get()); - scoped_ptr<std::set<LayerImpl*>> scroll_children(new std::set<LayerImpl*>); + scroll_child->test_properties()->scroll_parent = child.get(); + std::unique_ptr<std::set<LayerImpl*>> scroll_children( + new std::set<LayerImpl*>); scroll_children->insert(scroll_child.get()); - child->SetScrollChildren(scroll_children.release()); + child->test_properties()->scroll_children.reset(scroll_children.release()); SetLayerPropertiesForTesting(grand_child.get(), identity_matrix, transform_origin, position, bounds, true, @@ -1293,7 +1309,8 @@ TEST_F(LayerTreeImplTest, HitTestingForMultipleLayerLists) { // The geometry is set up similarly to the previous case, but // all layers are forced to be render surfaces now. // - scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); + std::unique_ptr<LayerImpl> root = + LayerImpl::Create(host_impl().active_tree(), 1); LayerImpl* root_layer = root.get(); gfx::Transform identity_matrix; @@ -1310,11 +1327,11 @@ TEST_F(LayerTreeImplTest, HitTestingForMultipleLayerLists) { // grand_child, (third) child1, and (back) the root layer behind all other // layers. - scoped_ptr<LayerImpl> child1 = + std::unique_ptr<LayerImpl> child1 = LayerImpl::Create(host_impl().active_tree(), 2); - scoped_ptr<LayerImpl> child2 = + std::unique_ptr<LayerImpl> child2 = LayerImpl::Create(host_impl().active_tree(), 3); - scoped_ptr<LayerImpl> grand_child1 = + std::unique_ptr<LayerImpl> grand_child1 = LayerImpl::Create(host_impl().active_tree(), 4); position = gfx::PointF(10.f, 10.f); @@ -1323,7 +1340,7 @@ TEST_F(LayerTreeImplTest, HitTestingForMultipleLayerLists) { transform_origin, position, bounds, true, false, false); child1->SetDrawsContent(true); - child1->SetForceRenderSurface(true); + child1->test_properties()->force_render_surface = true; position = gfx::PointF(50.f, 10.f); bounds = gfx::Size(50, 50); @@ -1331,7 +1348,7 @@ TEST_F(LayerTreeImplTest, HitTestingForMultipleLayerLists) { transform_origin, position, bounds, true, false, false); child2->SetDrawsContent(true); - child2->SetForceRenderSurface(true); + child2->test_properties()->force_render_surface = true; // Remember that grand_child is positioned with respect to its parent (i.e. // child1). In screen space, the intended position is (10, 50), with size @@ -1342,7 +1359,7 @@ TEST_F(LayerTreeImplTest, HitTestingForMultipleLayerLists) { transform_origin, position, bounds, true, false, false); grand_child1->SetDrawsContent(true); - grand_child1->SetForceRenderSurface(true); + grand_child1->test_properties()->force_render_surface = true; child1->AddChild(std::move(grand_child1)); root->AddChild(std::move(child1)); @@ -1428,7 +1445,7 @@ TEST_F(LayerTreeImplTest, HitTestingForMultipleLayerLists) { } TEST_F(LayerTreeImplTest, HitCheckingTouchHandlerRegionsForSingleLayer) { - scoped_ptr<LayerImpl> root = + std::unique_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 12345); gfx::Transform identity_matrix; @@ -1504,7 +1521,7 @@ TEST_F(LayerTreeImplTest, HitCheckingTouchHandlerRegionsForSingleLayer) { TEST_F(LayerTreeImplTest, HitCheckingTouchHandlerRegionsForUninvertibleTransform) { - scoped_ptr<LayerImpl> root = + std::unique_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 12345); gfx::Transform uninvertible_transform; @@ -1583,7 +1600,7 @@ TEST_F(LayerTreeImplTest, TEST_F(LayerTreeImplTest, HitCheckingTouchHandlerRegionsForSinglePositionedLayer) { - scoped_ptr<LayerImpl> root = + std::unique_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 12345); gfx::Transform identity_matrix; @@ -1651,7 +1668,8 @@ TEST_F(LayerTreeImplTest, // The layer's device_scale_factor and page_scale_factor should scale the // content rect and we should be able to hit the touch handler region by // scaling the points accordingly. - scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); + std::unique_ptr<LayerImpl> root = + LayerImpl::Create(host_impl().active_tree(), 1); gfx::Transform identity_matrix; gfx::Point3F transform_origin; @@ -1663,7 +1681,7 @@ TEST_F(LayerTreeImplTest, Region touch_handler_region(gfx::Rect(10, 10, 30, 30)); gfx::PointF position(25.f, 25.f); gfx::Size bounds(50, 50); - scoped_ptr<LayerImpl> test_layer = + std::unique_ptr<LayerImpl> test_layer = LayerImpl::Create(host_impl().active_tree(), 12345); SetLayerPropertiesForTesting(test_layer.get(), identity_matrix, transform_origin, position, bounds, true, @@ -1800,12 +1818,13 @@ TEST_F(LayerTreeImplTest, HitCheckingTouchHandlerRegionsForSimpleClippedLayer) { gfx::Transform identity_matrix; gfx::Point3F transform_origin; - scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); + std::unique_ptr<LayerImpl> root = + LayerImpl::Create(host_impl().active_tree(), 1); SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, gfx::PointF(), gfx::Size(100, 100), true, false, true); { - scoped_ptr<LayerImpl> clipping_layer = + std::unique_ptr<LayerImpl> clipping_layer = LayerImpl::Create(host_impl().active_tree(), 123); // this layer is positioned, and hit testing should correctly know where the // layer is located. @@ -1816,7 +1835,7 @@ TEST_F(LayerTreeImplTest, HitCheckingTouchHandlerRegionsForSimpleClippedLayer) { false, false); clipping_layer->SetMasksToBounds(true); - scoped_ptr<LayerImpl> child = + std::unique_ptr<LayerImpl> child = LayerImpl::Create(host_impl().active_tree(), 456); Region touch_handler_region(gfx::Rect(10, 10, 50, 50)); position = gfx::PointF(-50.f, -50.f); @@ -1878,16 +1897,105 @@ TEST_F(LayerTreeImplTest, HitCheckingTouchHandlerRegionsForSimpleClippedLayer) { EXPECT_EQ(456, result_layer->id()); } +TEST_F(LayerTreeImplTest, + HitCheckingTouchHandlerRegionsForClippedLayerWithDeviceScale) { + // The layer's device_scale_factor and page_scale_factor should scale the + // content rect and we should be able to hit the touch handler region by + // scaling the points accordingly. + std::unique_ptr<LayerImpl> root = + LayerImpl::Create(host_impl().active_tree(), 1); + + gfx::Transform identity_matrix; + gfx::Point3F transform_origin; + // Set the bounds of the root layer big enough to fit the child when scaled. + SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, + gfx::PointF(), gfx::Size(100, 100), true, false, + true); + std::unique_ptr<LayerImpl> surface = + LayerImpl::Create(host_impl().active_tree(), 2); + SetLayerPropertiesForTesting(surface.get(), identity_matrix, transform_origin, + gfx::PointF(), gfx::Size(100, 100), true, false, + true); + { + std::unique_ptr<LayerImpl> clipping_layer = + LayerImpl::Create(host_impl().active_tree(), 123); + // This layer is positioned, and hit testing should correctly know where the + // layer is located. + gfx::PointF position(25.f, 20.f); + gfx::Size bounds(50, 50); + SetLayerPropertiesForTesting(clipping_layer.get(), identity_matrix, + transform_origin, position, bounds, true, + false, false); + clipping_layer->SetMasksToBounds(true); + + std::unique_ptr<LayerImpl> child = + LayerImpl::Create(host_impl().active_tree(), 456); + Region touch_handler_region(gfx::Rect(0, 0, 300, 300)); + position = gfx::PointF(-50.f, -50.f); + bounds = gfx::Size(300, 300); + SetLayerPropertiesForTesting(child.get(), identity_matrix, transform_origin, + position, bounds, true, false, false); + child->SetDrawsContent(true); + child->SetTouchEventHandlerRegion(touch_handler_region); + clipping_layer->AddChild(std::move(child)); + surface->AddChild(std::move(clipping_layer)); + root->AddChild(std::move(surface)); + } + + float device_scale_factor = 3.f; + float page_scale_factor = 1.f; + float max_page_scale_factor = 1.f; + gfx::Size scaled_bounds_for_root = gfx::ScaleToCeiledSize( + root->bounds(), device_scale_factor * page_scale_factor); + host_impl().SetViewportSize(scaled_bounds_for_root); + + host_impl().active_tree()->SetDeviceScaleFactor(device_scale_factor); + host_impl().active_tree()->SetRootLayer(std::move(root)); + host_impl().active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 1, + Layer::INVALID_ID); + host_impl().active_tree()->BuildPropertyTreesForTesting(); + host_impl().active_tree()->PushPageScaleFromMainThread( + page_scale_factor, page_scale_factor, max_page_scale_factor); + host_impl().active_tree()->SetPageScaleOnActiveTree(page_scale_factor); + host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); + + // Sanity check the scenario we just created. + ASSERT_EQ(2u, RenderSurfaceLayerList().size()); + + // Hit checking for a point outside the layer should return a null pointer. + // Despite the child layer being very large, it should be clipped to the root + // layer's bounds. + gfx::PointF test_point(24.f, 24.f); + test_point = + gfx::ScalePoint(test_point, device_scale_factor * page_scale_factor); + LayerImpl* result_layer = + host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( + test_point); + EXPECT_FALSE(result_layer); + + // Hit checking for a point inside the touch event handler region should + // return the child layer. + test_point = gfx::PointF(25.f, 25.f); + test_point = + gfx::ScalePoint(test_point, device_scale_factor * page_scale_factor); + result_layer = + host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( + test_point); + ASSERT_TRUE(result_layer); + EXPECT_EQ(456, result_layer->id()); +} + TEST_F(LayerTreeImplTest, HitCheckingTouchHandlerOverlappingRegions) { gfx::Transform identity_matrix; gfx::Point3F transform_origin; - scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); + std::unique_ptr<LayerImpl> root = + LayerImpl::Create(host_impl().active_tree(), 1); SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, gfx::PointF(), gfx::Size(100, 100), true, false, true); { - scoped_ptr<LayerImpl> touch_layer = + std::unique_ptr<LayerImpl> touch_layer = LayerImpl::Create(host_impl().active_tree(), 123); // this layer is positioned, and hit testing should correctly know where the // layer is located. @@ -1902,7 +2010,7 @@ TEST_F(LayerTreeImplTest, HitCheckingTouchHandlerOverlappingRegions) { } { - scoped_ptr<LayerImpl> notouch_layer = + std::unique_ptr<LayerImpl> notouch_layer = LayerImpl::Create(host_impl().active_tree(), 1234); // this layer is positioned, and hit testing should correctly know where the // layer is located. @@ -1960,7 +2068,8 @@ TEST_F(LayerTreeImplTest, HitCheckingTouchHandlerOverlappingRegions) { } TEST_F(LayerTreeImplTest, HitTestingTouchHandlerRegionsForLayerThatIsNotDrawn) { - scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); + std::unique_ptr<LayerImpl> root = + LayerImpl::Create(host_impl().active_tree(), 1); gfx::Transform identity_matrix; gfx::Point3F transform_origin; @@ -1972,7 +2081,7 @@ TEST_F(LayerTreeImplTest, HitTestingTouchHandlerRegionsForLayerThatIsNotDrawn) { Region touch_handler_region(gfx::Rect(10, 10, 30, 30)); gfx::PointF position; gfx::Size bounds(50, 50); - scoped_ptr<LayerImpl> test_layer = + std::unique_ptr<LayerImpl> test_layer = LayerImpl::Create(host_impl().active_tree(), 12345); SetLayerPropertiesForTesting(test_layer.get(), identity_matrix, transform_origin, position, bounds, true, @@ -2009,7 +2118,7 @@ TEST_F(LayerTreeImplTest, HitTestingTouchHandlerRegionsForLayerThatIsNotDrawn) { host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( test_point); EXPECT_FALSE(result_layer); - EXPECT_FALSE(test_layer->IsDrawnRenderSurfaceLayerListMember()); + EXPECT_FALSE(test_layer->is_drawn_render_surface_layer_list_member()); EXPECT_TRANSFORMATION_MATRIX_EQ( expected_screen_space_transform, draw_property_utils::ScreenSpaceTransform( @@ -2031,7 +2140,7 @@ TEST_F(LayerTreeImplTest, HitTestingTouchHandlerRegionsForLayerThatIsNotDrawn) { test_point); ASSERT_TRUE(result_layer); ASSERT_EQ(test_layer, result_layer); - EXPECT_FALSE(result_layer->IsDrawnRenderSurfaceLayerListMember()); + EXPECT_FALSE(result_layer->is_drawn_render_surface_layer_list_member()); EXPECT_TRANSFORMATION_MATRIX_EQ( expected_screen_space_transform, draw_property_utils::ScreenSpaceTransform( @@ -2041,7 +2150,7 @@ TEST_F(LayerTreeImplTest, HitTestingTouchHandlerRegionsForLayerThatIsNotDrawn) { TEST_F(LayerTreeImplTest, SelectionBoundsForSingleLayer) { int root_layer_id = 12345; - scoped_ptr<LayerImpl> root = + std::unique_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), root_layer_id); gfx::Transform identity_matrix; @@ -2120,7 +2229,7 @@ TEST_F(LayerTreeImplTest, SelectionBoundsForPartialOccludedLayers) { int root_layer_id = 12345; int clip_layer_id = 1234; int clipped_layer_id = 123; - scoped_ptr<LayerImpl> root = + std::unique_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), root_layer_id); root->SetDrawsContent(true); @@ -2133,7 +2242,7 @@ TEST_F(LayerTreeImplTest, SelectionBoundsForPartialOccludedLayers) { gfx::Vector2dF clipping_offset(10, 10); { - scoped_ptr<LayerImpl> clipping_layer = + std::unique_ptr<LayerImpl> clipping_layer = LayerImpl::Create(host_impl().active_tree(), clip_layer_id); // The clipping layer should occlude the right selection bound. gfx::PointF position = gfx::PointF() + clipping_offset; @@ -2143,7 +2252,7 @@ TEST_F(LayerTreeImplTest, SelectionBoundsForPartialOccludedLayers) { false, false); clipping_layer->SetMasksToBounds(true); - scoped_ptr<LayerImpl> clipped_layer = + std::unique_ptr<LayerImpl> clipped_layer = LayerImpl::Create(host_impl().active_tree(), clipped_layer_id); position = gfx::PointF(); bounds = gfx::Size(100, 100); @@ -2218,7 +2327,7 @@ TEST_F(LayerTreeImplTest, SelectionBoundsForPartialOccludedLayers) { TEST_F(LayerTreeImplTest, SelectionBoundsForScaledLayers) { int root_layer_id = 1; int sub_layer_id = 2; - scoped_ptr<LayerImpl> root = + std::unique_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), root_layer_id); root->SetDrawsContent(true); @@ -2231,7 +2340,7 @@ TEST_F(LayerTreeImplTest, SelectionBoundsForScaledLayers) { gfx::Vector2dF sub_layer_offset(10, 0); { - scoped_ptr<LayerImpl> sub_layer = + std::unique_ptr<LayerImpl> sub_layer = LayerImpl::Create(host_impl().active_tree(), sub_layer_id); gfx::PointF position = gfx::PointF() + sub_layer_offset; gfx::Size bounds(50, 50); @@ -2304,7 +2413,7 @@ TEST_F(LayerTreeImplTest, SelectionBoundsWithLargeTransforms) { int child_id = 2; int grand_child_id = 3; - scoped_ptr<LayerImpl> root = + std::unique_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), root_id); gfx::Size bounds(100, 100); gfx::Transform identity_matrix; @@ -2319,12 +2428,12 @@ TEST_F(LayerTreeImplTest, SelectionBoundsWithLargeTransforms) { large_transform.RotateAboutYAxis(30); { - scoped_ptr<LayerImpl> child = + std::unique_ptr<LayerImpl> child = LayerImpl::Create(host_impl().active_tree(), child_id); SetLayerPropertiesForTesting(child.get(), large_transform, transform_origin, position, bounds, true, false, false); - scoped_ptr<LayerImpl> grand_child = + std::unique_ptr<LayerImpl> grand_child = LayerImpl::Create(host_impl().active_tree(), grand_child_id); SetLayerPropertiesForTesting(grand_child.get(), large_transform, transform_origin, position, bounds, true, @@ -2364,13 +2473,15 @@ TEST_F(LayerTreeImplTest, SelectionBoundsWithLargeTransforms) { TEST_F(LayerTreeImplTest, NumLayersTestOne) { EXPECT_EQ(0u, host_impl().active_tree()->NumLayers()); - scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); + std::unique_ptr<LayerImpl> root = + LayerImpl::Create(host_impl().active_tree(), 1); EXPECT_EQ(1u, host_impl().active_tree()->NumLayers()); } TEST_F(LayerTreeImplTest, NumLayersSmallTree) { EXPECT_EQ(0u, host_impl().active_tree()->NumLayers()); - scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); + std::unique_ptr<LayerImpl> root = + LayerImpl::Create(host_impl().active_tree(), 1); root->AddChild(LayerImpl::Create(host_impl().active_tree(), 2)); root->AddChild(LayerImpl::Create(host_impl().active_tree(), 3)); root->child_at(1)->AddChild(LayerImpl::Create(host_impl().active_tree(), 4)); @@ -2388,10 +2499,11 @@ TEST_F(LayerTreeImplTest, DeviceScaleFactorNeedsDrawPropertiesUpdate) { TEST_F(LayerTreeImplTest, HitTestingCorrectLayerWheelListener) { host_impl().active_tree()->set_event_listener_properties( EventListenerClass::kMouseWheel, EventListenerProperties::kBlocking); - scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); - scoped_ptr<LayerImpl> left_child = + std::unique_ptr<LayerImpl> root = + LayerImpl::Create(host_impl().active_tree(), 1); + std::unique_ptr<LayerImpl> left_child = LayerImpl::Create(host_impl().active_tree(), 2); - scoped_ptr<LayerImpl> right_child = + std::unique_ptr<LayerImpl> right_child = LayerImpl::Create(host_impl().active_tree(), 3); gfx::Point3F transform_origin; |