OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/trees/layer_tree_host_common.h" | 5 #include "cc/trees/layer_tree_host_common.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <set> | 10 #include <set> |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 ->property_trees() | 352 ->property_trees() |
353 ->scroll_tree.UpdateScrollOffsetBaseForTesting(scroll_layer_raw_ptr->id(), | 353 ->scroll_tree.UpdateScrollOffsetBaseForTesting(scroll_layer_raw_ptr->id(), |
354 kScrollOffset); | 354 kScrollOffset); |
355 | 355 |
356 scoped_ptr<LayerImpl> root(LayerImpl::Create(host_impl.active_tree(), 3)); | 356 scoped_ptr<LayerImpl> root(LayerImpl::Create(host_impl.active_tree(), 3)); |
357 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), | 357 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), |
358 gfx::PointF(), gfx::Size(3, 4), true, false, | 358 gfx::PointF(), gfx::Size(3, 4), true, false, |
359 false); | 359 false); |
360 root->AddChild(std::move(clip_layer_scoped_ptr)); | 360 root->AddChild(std::move(clip_layer_scoped_ptr)); |
361 root->SetHasRenderSurface(true); | 361 root->SetHasRenderSurface(true); |
| 362 LayerImpl* root_layer = root.get(); |
| 363 host_impl.active_tree()->SetRootLayer(std::move(root)); |
362 | 364 |
363 ExecuteCalculateDrawProperties( | 365 ExecuteCalculateDrawProperties(root_layer, kDeviceScale, kPageScale, |
364 root.get(), kDeviceScale, kPageScale, scroll_layer->parent()); | 366 scroll_layer->parent()); |
365 gfx::Transform expected_transform = identity_matrix; | 367 gfx::Transform expected_transform = identity_matrix; |
366 gfx::PointF sub_layer_screen_position = kScrollLayerPosition - kScrollDelta; | 368 gfx::PointF sub_layer_screen_position = kScrollLayerPosition - kScrollDelta; |
367 expected_transform.Translate(MathUtil::Round(sub_layer_screen_position.x() * | 369 expected_transform.Translate(MathUtil::Round(sub_layer_screen_position.x() * |
368 kPageScale * kDeviceScale), | 370 kPageScale * kDeviceScale), |
369 MathUtil::Round(sub_layer_screen_position.y() * | 371 MathUtil::Round(sub_layer_screen_position.y() * |
370 kPageScale * kDeviceScale)); | 372 kPageScale * kDeviceScale)); |
371 expected_transform.Scale(kPageScale * kDeviceScale, | 373 expected_transform.Scale(kPageScale * kDeviceScale, |
372 kPageScale * kDeviceScale); | 374 kPageScale * kDeviceScale); |
373 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_transform, | 375 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_transform, |
374 sublayer->DrawTransform()); | 376 sublayer->DrawTransform()); |
375 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_transform, | 377 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_transform, |
376 sublayer->ScreenSpaceTransform()); | 378 sublayer->ScreenSpaceTransform()); |
377 | 379 |
378 gfx::Transform arbitrary_translate; | 380 gfx::Transform arbitrary_translate; |
379 const float kTranslateX = 10.6f; | 381 const float kTranslateX = 10.6f; |
380 const float kTranslateY = 20.6f; | 382 const float kTranslateY = 20.6f; |
381 arbitrary_translate.Translate(kTranslateX, kTranslateY); | 383 arbitrary_translate.Translate(kTranslateX, kTranslateY); |
382 SetLayerPropertiesForTesting(scroll_layer, arbitrary_translate, | 384 SetLayerPropertiesForTesting(scroll_layer, arbitrary_translate, |
383 gfx::Point3F(), gfx::PointF(), gfx::Size(10, 20), | 385 gfx::Point3F(), gfx::PointF(), gfx::Size(10, 20), |
384 true, false, false); | 386 true, false, false); |
385 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 387 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = true; |
386 ExecuteCalculateDrawProperties( | 388 ExecuteCalculateDrawProperties(root_layer, kDeviceScale, kPageScale, |
387 root.get(), kDeviceScale, kPageScale, scroll_layer->parent()); | 389 scroll_layer->parent()); |
388 expected_transform.MakeIdentity(); | 390 expected_transform.MakeIdentity(); |
389 expected_transform.Translate( | 391 expected_transform.Translate( |
390 MathUtil::Round(kTranslateX * kPageScale * kDeviceScale + | 392 MathUtil::Round(kTranslateX * kPageScale * kDeviceScale + |
391 sub_layer_screen_position.x() * kPageScale * | 393 sub_layer_screen_position.x() * kPageScale * |
392 kDeviceScale), | 394 kDeviceScale), |
393 MathUtil::Round(kTranslateY * kPageScale * kDeviceScale + | 395 MathUtil::Round(kTranslateY * kPageScale * kDeviceScale + |
394 sub_layer_screen_position.y() * kPageScale * | 396 sub_layer_screen_position.y() * kPageScale * |
395 kDeviceScale)); | 397 kDeviceScale)); |
396 expected_transform.Scale(kPageScale * kDeviceScale, | 398 expected_transform.Scale(kPageScale * kDeviceScale, |
397 kPageScale * kDeviceScale); | 399 kPageScale * kDeviceScale); |
(...skipping 5179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5577 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, | 5579 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, |
5578 &task_graph_runner); | 5580 &task_graph_runner); |
5579 host_impl.CreatePendingTree(); | 5581 host_impl.CreatePendingTree(); |
5580 const gfx::Transform identity_matrix; | 5582 const gfx::Transform identity_matrix; |
5581 | 5583 |
5582 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl.pending_tree(), 1); | 5584 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl.pending_tree(), 1); |
5583 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), | 5585 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), |
5584 gfx::PointF(), gfx::Size(50, 50), true, false, | 5586 gfx::PointF(), gfx::Size(50, 50), true, false, |
5585 true); | 5587 true); |
5586 root->SetDrawsContent(true); | 5588 root->SetDrawsContent(true); |
| 5589 LayerImpl* root_layer = root.get(); |
5587 | 5590 |
5588 scoped_ptr<LayerImpl> child = LayerImpl::Create(host_impl.pending_tree(), 2); | 5591 scoped_ptr<LayerImpl> child = LayerImpl::Create(host_impl.pending_tree(), 2); |
5589 SetLayerPropertiesForTesting(child.get(), identity_matrix, gfx::Point3F(), | 5592 SetLayerPropertiesForTesting(child.get(), identity_matrix, gfx::Point3F(), |
5590 gfx::PointF(), gfx::Size(40, 40), true, false, | 5593 gfx::PointF(), gfx::Size(40, 40), true, false, |
5591 false); | 5594 false); |
5592 child->SetDrawsContent(true); | 5595 child->SetDrawsContent(true); |
5593 child->SetHideLayerAndSubtree(true); | 5596 child->SetHideLayerAndSubtree(true); |
5594 | 5597 |
5595 scoped_ptr<LayerImpl> grand_child = | 5598 scoped_ptr<LayerImpl> grand_child = |
5596 LayerImpl::Create(host_impl.pending_tree(), 3); | 5599 LayerImpl::Create(host_impl.pending_tree(), 3); |
5597 SetLayerPropertiesForTesting(grand_child.get(), identity_matrix, | 5600 SetLayerPropertiesForTesting(grand_child.get(), identity_matrix, |
5598 gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30), | 5601 gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30), |
5599 true, false, false); | 5602 true, false, false); |
5600 grand_child->SetDrawsContent(true); | 5603 grand_child->SetDrawsContent(true); |
5601 | 5604 |
5602 child->AddChild(std::move(grand_child)); | 5605 child->AddChild(std::move(grand_child)); |
5603 root->AddChild(std::move(child)); | 5606 root->AddChild(std::move(child)); |
| 5607 host_impl.pending_tree()->SetRootLayer(std::move(root)); |
5604 | 5608 |
5605 LayerImplList render_surface_layer_list; | 5609 LayerImplList render_surface_layer_list; |
5606 root->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); | 5610 root_layer->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); |
5607 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 5611 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
5608 root.get(), root->bounds(), &render_surface_layer_list, | 5612 root_layer, root_layer->bounds(), &render_surface_layer_list, |
5609 root->layer_tree_impl()->current_render_surface_list_id()); | 5613 root_layer->layer_tree_impl()->current_render_surface_list_id()); |
5610 inputs.can_adjust_raster_scales = true; | 5614 inputs.can_adjust_raster_scales = true; |
5611 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 5615 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
5612 | 5616 |
5613 // We should have one render surface and one layers. The child has | 5617 // We should have one render surface and one layers. The child has |
5614 // hidden itself and the grand child. | 5618 // hidden itself and the grand child. |
5615 ASSERT_EQ(1u, render_surface_layer_list.size()); | 5619 ASSERT_EQ(1u, render_surface_layer_list.size()); |
5616 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); | 5620 ASSERT_EQ(1u, root_layer->render_surface()->layer_list().size()); |
5617 EXPECT_EQ(1, root->render_surface()->layer_list().at(0)->id()); | 5621 EXPECT_EQ(1, root_layer->render_surface()->layer_list().at(0)->id()); |
5618 } | 5622 } |
5619 | 5623 |
5620 void EmptyCopyOutputCallback(scoped_ptr<CopyOutputResult> result) {} | 5624 void EmptyCopyOutputCallback(scoped_ptr<CopyOutputResult> result) {} |
5621 | 5625 |
5622 TEST_F(LayerTreeHostCommonTest, SubtreeHiddenWithCopyRequest) { | 5626 TEST_F(LayerTreeHostCommonTest, SubtreeHiddenWithCopyRequest) { |
5623 FakeImplTaskRunnerProvider task_runner_provider; | 5627 FakeImplTaskRunnerProvider task_runner_provider; |
5624 TestSharedBitmapManager shared_bitmap_manager; | 5628 TestSharedBitmapManager shared_bitmap_manager; |
5625 TestTaskGraphRunner task_graph_runner; | 5629 TestTaskGraphRunner task_graph_runner; |
5626 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, | 5630 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, |
5627 &task_graph_runner); | 5631 &task_graph_runner); |
5628 host_impl.CreatePendingTree(); | 5632 host_impl.CreatePendingTree(); |
5629 const gfx::Transform identity_matrix; | 5633 const gfx::Transform identity_matrix; |
5630 | 5634 |
5631 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl.pending_tree(), 1); | 5635 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl.pending_tree(), 1); |
5632 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), | 5636 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), |
5633 gfx::PointF(), gfx::Size(50, 50), true, false, | 5637 gfx::PointF(), gfx::Size(50, 50), true, false, |
5634 true); | 5638 true); |
5635 root->SetDrawsContent(true); | 5639 root->SetDrawsContent(true); |
| 5640 LayerImpl* root_layer = root.get(); |
5636 | 5641 |
5637 scoped_ptr<LayerImpl> copy_grand_parent = | 5642 scoped_ptr<LayerImpl> copy_grand_parent = |
5638 LayerImpl::Create(host_impl.pending_tree(), 2); | 5643 LayerImpl::Create(host_impl.pending_tree(), 2); |
5639 SetLayerPropertiesForTesting(copy_grand_parent.get(), identity_matrix, | 5644 SetLayerPropertiesForTesting(copy_grand_parent.get(), identity_matrix, |
5640 gfx::Point3F(), gfx::PointF(), gfx::Size(40, 40), | 5645 gfx::Point3F(), gfx::PointF(), gfx::Size(40, 40), |
5641 true, false, false); | 5646 true, false, false); |
5642 copy_grand_parent->SetDrawsContent(true); | 5647 copy_grand_parent->SetDrawsContent(true); |
5643 LayerImpl* copy_grand_parent_layer = copy_grand_parent.get(); | 5648 LayerImpl* copy_grand_parent_layer = copy_grand_parent.get(); |
5644 | 5649 |
5645 scoped_ptr<LayerImpl> copy_parent = | 5650 scoped_ptr<LayerImpl> copy_parent = |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5692 LayerImpl* copy_grand_parent_sibling_after_layer = | 5697 LayerImpl* copy_grand_parent_sibling_after_layer = |
5693 copy_grand_parent_sibling_after.get(); | 5698 copy_grand_parent_sibling_after.get(); |
5694 | 5699 |
5695 copy_child->AddChild(std::move(copy_grand_child)); | 5700 copy_child->AddChild(std::move(copy_grand_child)); |
5696 copy_request->AddChild(std::move(copy_child)); | 5701 copy_request->AddChild(std::move(copy_child)); |
5697 copy_parent->AddChild(std::move(copy_request)); | 5702 copy_parent->AddChild(std::move(copy_request)); |
5698 copy_grand_parent->AddChild(std::move(copy_parent)); | 5703 copy_grand_parent->AddChild(std::move(copy_parent)); |
5699 root->AddChild(std::move(copy_grand_parent_sibling_before)); | 5704 root->AddChild(std::move(copy_grand_parent_sibling_before)); |
5700 root->AddChild(std::move(copy_grand_parent)); | 5705 root->AddChild(std::move(copy_grand_parent)); |
5701 root->AddChild(std::move(copy_grand_parent_sibling_after)); | 5706 root->AddChild(std::move(copy_grand_parent_sibling_after)); |
| 5707 host_impl.pending_tree()->SetRootLayer(std::move(root)); |
5702 | 5708 |
5703 // Hide the copy_grand_parent and its subtree. But make a copy request in that | 5709 // Hide the copy_grand_parent and its subtree. But make a copy request in that |
5704 // hidden subtree on copy_layer. Also hide the copy grand child and its | 5710 // hidden subtree on copy_layer. Also hide the copy grand child and its |
5705 // subtree. | 5711 // subtree. |
5706 copy_grand_parent_layer->SetHideLayerAndSubtree(true); | 5712 copy_grand_parent_layer->SetHideLayerAndSubtree(true); |
5707 copy_grand_parent_sibling_before_layer->SetHideLayerAndSubtree(true); | 5713 copy_grand_parent_sibling_before_layer->SetHideLayerAndSubtree(true); |
5708 copy_grand_parent_sibling_after_layer->SetHideLayerAndSubtree(true); | 5714 copy_grand_parent_sibling_after_layer->SetHideLayerAndSubtree(true); |
5709 copy_grand_child_layer->SetHideLayerAndSubtree(true); | 5715 copy_grand_child_layer->SetHideLayerAndSubtree(true); |
5710 | 5716 |
5711 std::vector<scoped_ptr<CopyOutputRequest>> copy_requests; | 5717 std::vector<scoped_ptr<CopyOutputRequest>> copy_requests; |
5712 copy_requests.push_back( | 5718 copy_requests.push_back( |
5713 CopyOutputRequest::CreateRequest(base::Bind(&EmptyCopyOutputCallback))); | 5719 CopyOutputRequest::CreateRequest(base::Bind(&EmptyCopyOutputCallback))); |
5714 copy_layer->PassCopyRequests(©_requests); | 5720 copy_layer->PassCopyRequests(©_requests); |
5715 EXPECT_TRUE(copy_layer->HasCopyRequest()); | 5721 EXPECT_TRUE(copy_layer->HasCopyRequest()); |
5716 | 5722 |
5717 LayerImplList render_surface_layer_list; | 5723 LayerImplList render_surface_layer_list; |
5718 root->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); | 5724 root_layer->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); |
5719 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 5725 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
5720 root.get(), root->bounds(), &render_surface_layer_list, | 5726 root_layer, root_layer->bounds(), &render_surface_layer_list, |
5721 root->layer_tree_impl()->current_render_surface_list_id()); | 5727 root_layer->layer_tree_impl()->current_render_surface_list_id()); |
5722 inputs.can_adjust_raster_scales = true; | 5728 inputs.can_adjust_raster_scales = true; |
5723 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 5729 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
5724 | 5730 |
5725 EXPECT_GT(root->num_copy_requests_in_target_subtree(), 0); | 5731 EXPECT_GT(root_layer->num_copy_requests_in_target_subtree(), 0); |
5726 EXPECT_GT(copy_grand_parent_layer->num_copy_requests_in_target_subtree(), 0); | 5732 EXPECT_GT(copy_grand_parent_layer->num_copy_requests_in_target_subtree(), 0); |
5727 EXPECT_GT(copy_parent_layer->num_copy_requests_in_target_subtree(), 0); | 5733 EXPECT_GT(copy_parent_layer->num_copy_requests_in_target_subtree(), 0); |
5728 EXPECT_GT(copy_layer->num_copy_requests_in_target_subtree(), 0); | 5734 EXPECT_GT(copy_layer->num_copy_requests_in_target_subtree(), 0); |
5729 | 5735 |
5730 // We should have four render surfaces, one for the root, one for the grand | 5736 // We should have four render surfaces, one for the root, one for the grand |
5731 // parent since it has opacity and two drawing descendants, one for the parent | 5737 // parent since it has opacity and two drawing descendants, one for the parent |
5732 // since it owns a surface, and one for the copy_layer. | 5738 // since it owns a surface, and one for the copy_layer. |
5733 ASSERT_EQ(4u, render_surface_layer_list.size()); | 5739 ASSERT_EQ(4u, render_surface_layer_list.size()); |
5734 EXPECT_EQ(root->id(), render_surface_layer_list.at(0)->id()); | 5740 EXPECT_EQ(root_layer->id(), render_surface_layer_list.at(0)->id()); |
5735 EXPECT_EQ(copy_grand_parent_layer->id(), | 5741 EXPECT_EQ(copy_grand_parent_layer->id(), |
5736 render_surface_layer_list.at(1)->id()); | 5742 render_surface_layer_list.at(1)->id()); |
5737 EXPECT_EQ(copy_parent_layer->id(), render_surface_layer_list.at(2)->id()); | 5743 EXPECT_EQ(copy_parent_layer->id(), render_surface_layer_list.at(2)->id()); |
5738 EXPECT_EQ(copy_layer->id(), render_surface_layer_list.at(3)->id()); | 5744 EXPECT_EQ(copy_layer->id(), render_surface_layer_list.at(3)->id()); |
5739 | 5745 |
5740 // The root render surface should have 2 contributing layers. | 5746 // The root render surface should have 2 contributing layers. |
5741 ASSERT_EQ(2u, root->render_surface()->layer_list().size()); | 5747 ASSERT_EQ(2u, root_layer->render_surface()->layer_list().size()); |
5742 EXPECT_EQ(root->id(), root->render_surface()->layer_list().at(0)->id()); | 5748 EXPECT_EQ(root_layer->id(), |
| 5749 root_layer->render_surface()->layer_list().at(0)->id()); |
5743 EXPECT_EQ(copy_grand_parent_layer->id(), | 5750 EXPECT_EQ(copy_grand_parent_layer->id(), |
5744 root->render_surface()->layer_list().at(1)->id()); | 5751 root_layer->render_surface()->layer_list().at(1)->id()); |
5745 | 5752 |
5746 // Nothing actually draws into the copy parent, so only the copy_layer will | 5753 // Nothing actually draws into the copy parent, so only the copy_layer will |
5747 // appear in its list, since it needs to be drawn for the copy request. | 5754 // appear in its list, since it needs to be drawn for the copy request. |
5748 ASSERT_EQ(1u, copy_parent_layer->render_surface()->layer_list().size()); | 5755 ASSERT_EQ(1u, copy_parent_layer->render_surface()->layer_list().size()); |
5749 EXPECT_EQ(copy_layer->id(), | 5756 EXPECT_EQ(copy_layer->id(), |
5750 copy_layer->render_surface()->layer_list().at(0)->id()); | 5757 copy_layer->render_surface()->layer_list().at(0)->id()); |
5751 | 5758 |
5752 // The copy_layer's render surface should have two contributing layers. | 5759 // The copy_layer's render surface should have two contributing layers. |
5753 ASSERT_EQ(2u, copy_layer->render_surface()->layer_list().size()); | 5760 ASSERT_EQ(2u, copy_layer->render_surface()->layer_list().size()); |
5754 EXPECT_EQ(copy_layer->id(), | 5761 EXPECT_EQ(copy_layer->id(), |
5755 copy_layer->render_surface()->layer_list().at(0)->id()); | 5762 copy_layer->render_surface()->layer_list().at(0)->id()); |
5756 EXPECT_EQ(copy_child_layer->id(), | 5763 EXPECT_EQ(copy_child_layer->id(), |
5757 copy_layer->render_surface()->layer_list().at(1)->id()); | 5764 copy_layer->render_surface()->layer_list().at(1)->id()); |
5758 | 5765 |
5759 // copy_grand_parent, copy_parent shouldn't be drawn because they are hidden, | 5766 // copy_grand_parent, copy_parent shouldn't be drawn because they are hidden, |
5760 // but the copy_layer and copy_child should be drawn for the copy request. | 5767 // but the copy_layer and copy_child should be drawn for the copy request. |
5761 // copy grand child should not be drawn as its hidden even in the copy | 5768 // copy grand child should not be drawn as its hidden even in the copy |
5762 // request. | 5769 // request. |
5763 EffectTree tree = root->layer_tree_impl()->property_trees()->effect_tree; | 5770 EffectTree tree = |
| 5771 root_layer->layer_tree_impl()->property_trees()->effect_tree; |
5764 EffectNode* node = tree.Node(copy_grand_parent_layer->effect_tree_index()); | 5772 EffectNode* node = tree.Node(copy_grand_parent_layer->effect_tree_index()); |
5765 EXPECT_FALSE(node->data.is_drawn); | 5773 EXPECT_FALSE(node->data.is_drawn); |
5766 node = tree.Node(copy_parent_layer->effect_tree_index()); | 5774 node = tree.Node(copy_parent_layer->effect_tree_index()); |
5767 EXPECT_FALSE(node->data.is_drawn); | 5775 EXPECT_FALSE(node->data.is_drawn); |
5768 node = tree.Node(copy_layer->effect_tree_index()); | 5776 node = tree.Node(copy_layer->effect_tree_index()); |
5769 EXPECT_TRUE(node->data.is_drawn); | 5777 EXPECT_TRUE(node->data.is_drawn); |
5770 node = tree.Node(copy_child_layer->effect_tree_index()); | 5778 node = tree.Node(copy_child_layer->effect_tree_index()); |
5771 EXPECT_TRUE(node->data.is_drawn); | 5779 EXPECT_TRUE(node->data.is_drawn); |
5772 node = tree.Node(copy_grand_child_layer->effect_tree_index()); | 5780 node = tree.Node(copy_grand_child_layer->effect_tree_index()); |
5773 EXPECT_FALSE(node->data.is_drawn); | 5781 EXPECT_FALSE(node->data.is_drawn); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5816 | 5824 |
5817 std::vector<scoped_ptr<CopyOutputRequest>> copy_requests; | 5825 std::vector<scoped_ptr<CopyOutputRequest>> copy_requests; |
5818 copy_requests.push_back( | 5826 copy_requests.push_back( |
5819 CopyOutputRequest::CreateRequest(base::Bind(&EmptyCopyOutputCallback))); | 5827 CopyOutputRequest::CreateRequest(base::Bind(&EmptyCopyOutputCallback))); |
5820 copy_layer->PassCopyRequests(©_requests); | 5828 copy_layer->PassCopyRequests(©_requests); |
5821 EXPECT_TRUE(copy_layer->HasCopyRequest()); | 5829 EXPECT_TRUE(copy_layer->HasCopyRequest()); |
5822 | 5830 |
5823 copy_layer->AddChild(std::move(copy_child)); | 5831 copy_layer->AddChild(std::move(copy_child)); |
5824 copy_parent->AddChild(std::move(copy_layer)); | 5832 copy_parent->AddChild(std::move(copy_layer)); |
5825 root->AddChild(std::move(copy_parent)); | 5833 root->AddChild(std::move(copy_parent)); |
| 5834 host_impl.pending_tree()->SetRootLayer(std::move(root)); |
| 5835 LayerImpl* root_ptr = host_impl.pending_tree()->root_layer(); |
5826 | 5836 |
5827 LayerImplList render_surface_layer_list; | 5837 LayerImplList render_surface_layer_list; |
5828 root->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); | 5838 root_ptr->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); |
5829 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 5839 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
5830 root.get(), root->bounds(), &render_surface_layer_list, | 5840 root_ptr, root_ptr->bounds(), &render_surface_layer_list, |
5831 root->layer_tree_impl()->current_render_surface_list_id()); | 5841 root_ptr->layer_tree_impl()->current_render_surface_list_id()); |
5832 inputs.can_adjust_raster_scales = true; | 5842 inputs.can_adjust_raster_scales = true; |
5833 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 5843 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
5834 | 5844 |
5835 // We should have two render surface, as the others are clipped out. | 5845 // We should have two render surface, as the others are clipped out. |
5836 ASSERT_EQ(2u, render_surface_layer_list.size()); | 5846 ASSERT_EQ(2u, render_surface_layer_list.size()); |
5837 EXPECT_EQ(root->id(), render_surface_layer_list.at(0)->id()); | 5847 EXPECT_EQ(root_ptr->id(), render_surface_layer_list.at(0)->id()); |
5838 | 5848 |
5839 // The root render surface should only have 2 contributing layer, since the | 5849 // The root render surface should only have 2 contributing layer, since the |
5840 // other layers are empty/clipped away. | 5850 // other layers are empty/clipped away. |
5841 ASSERT_EQ(2u, root->render_surface()->layer_list().size()); | 5851 ASSERT_EQ(2u, root_ptr->render_surface()->layer_list().size()); |
5842 EXPECT_EQ(root->id(), root->render_surface()->layer_list().at(0)->id()); | 5852 EXPECT_EQ(root_ptr->id(), |
| 5853 root_ptr->render_surface()->layer_list().at(0)->id()); |
5843 } | 5854 } |
5844 | 5855 |
5845 TEST_F(LayerTreeHostCommonTest, VisibleContentRectInsideSurface) { | 5856 TEST_F(LayerTreeHostCommonTest, VisibleContentRectInsideSurface) { |
5846 FakeImplTaskRunnerProvider task_runner_provider; | 5857 FakeImplTaskRunnerProvider task_runner_provider; |
5847 TestSharedBitmapManager shared_bitmap_manager; | 5858 TestSharedBitmapManager shared_bitmap_manager; |
5848 TestTaskGraphRunner task_graph_runner; | 5859 TestTaskGraphRunner task_graph_runner; |
5849 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, | 5860 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, |
5850 &task_graph_runner); | 5861 &task_graph_runner); |
5851 host_impl.CreatePendingTree(); | 5862 host_impl.CreatePendingTree(); |
5852 const gfx::Transform identity_matrix; | 5863 const gfx::Transform identity_matrix; |
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6379 SetLayerPropertiesForTesting(child3.get(), identity_matrix, transform_origin, | 6390 SetLayerPropertiesForTesting(child3.get(), identity_matrix, transform_origin, |
6380 position, bounds, true, false, false); | 6391 position, bounds, true, false, false); |
6381 child3->SetDrawsContent(true); | 6392 child3->SetDrawsContent(true); |
6382 | 6393 |
6383 child2->Set3dSortingContextId(1); | 6394 child2->Set3dSortingContextId(1); |
6384 child3->Set3dSortingContextId(1); | 6395 child3->Set3dSortingContextId(1); |
6385 | 6396 |
6386 child2->AddChild(std::move(child3)); | 6397 child2->AddChild(std::move(child3)); |
6387 child1->AddChild(std::move(child2)); | 6398 child1->AddChild(std::move(child2)); |
6388 root->AddChild(std::move(child1)); | 6399 root->AddChild(std::move(child1)); |
| 6400 host_impl.active_tree()->SetRootLayer(std::move(root)); |
| 6401 LayerImpl* root_ptr = host_impl.active_tree()->root_layer(); |
6389 | 6402 |
6390 { | 6403 { |
6391 LayerImplList render_surface_layer_list; | 6404 LayerImplList render_surface_layer_list; |
6392 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren(root.get()); | 6405 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren(root_ptr); |
6393 root->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); | 6406 root_ptr->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); |
6394 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 6407 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
6395 root.get(), root->bounds(), &render_surface_layer_list, | 6408 root_ptr, root_ptr->bounds(), &render_surface_layer_list, |
6396 root->layer_tree_impl()->current_render_surface_list_id()); | 6409 root_ptr->layer_tree_impl()->current_render_surface_list_id()); |
6397 inputs.can_render_to_separate_surface = true; | 6410 inputs.can_render_to_separate_surface = true; |
6398 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 6411 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
6399 | 6412 |
6400 EXPECT_EQ(2u, render_surface_layer_list.size()); | 6413 EXPECT_EQ(2u, render_surface_layer_list.size()); |
6401 | 6414 |
6402 int count_represents_target_render_surface = 0; | 6415 int count_represents_target_render_surface = 0; |
6403 int count_represents_contributing_render_surface = 0; | 6416 int count_represents_contributing_render_surface = 0; |
6404 int count_represents_itself = 0; | 6417 int count_represents_itself = 0; |
6405 LayerIterator end = LayerIterator::End(&render_surface_layer_list); | 6418 LayerIterator end = LayerIterator::End(&render_surface_layer_list); |
6406 for (LayerIterator it = LayerIterator::Begin(&render_surface_layer_list); | 6419 for (LayerIterator it = LayerIterator::Begin(&render_surface_layer_list); |
6407 it != end; ++it) { | 6420 it != end; ++it) { |
6408 if (it.represents_target_render_surface()) | 6421 if (it.represents_target_render_surface()) |
6409 count_represents_target_render_surface++; | 6422 count_represents_target_render_surface++; |
6410 if (it.represents_contributing_render_surface()) | 6423 if (it.represents_contributing_render_surface()) |
6411 count_represents_contributing_render_surface++; | 6424 count_represents_contributing_render_surface++; |
6412 if (it.represents_itself()) | 6425 if (it.represents_itself()) |
6413 count_represents_itself++; | 6426 count_represents_itself++; |
6414 } | 6427 } |
6415 | 6428 |
6416 // Two render surfaces. | 6429 // Two render surfaces. |
6417 EXPECT_EQ(2, count_represents_target_render_surface); | 6430 EXPECT_EQ(2, count_represents_target_render_surface); |
6418 // Second render surface contributes to root render surface. | 6431 // Second render surface contributes to root render surface. |
6419 EXPECT_EQ(1, count_represents_contributing_render_surface); | 6432 EXPECT_EQ(1, count_represents_contributing_render_surface); |
6420 // All 4 layers represent itself. | 6433 // All 4 layers represent itself. |
6421 EXPECT_EQ(4, count_represents_itself); | 6434 EXPECT_EQ(4, count_represents_itself); |
6422 } | 6435 } |
6423 | 6436 |
6424 { | 6437 { |
6425 LayerImplList render_surface_layer_list; | 6438 LayerImplList render_surface_layer_list; |
6426 root->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); | 6439 root_ptr->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); |
6427 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 6440 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
6428 root.get(), root->bounds(), &render_surface_layer_list, | 6441 root_ptr, root_ptr->bounds(), &render_surface_layer_list, |
6429 root->layer_tree_impl()->current_render_surface_list_id()); | 6442 root_ptr->layer_tree_impl()->current_render_surface_list_id()); |
6430 inputs.can_render_to_separate_surface = false; | 6443 inputs.can_render_to_separate_surface = false; |
6431 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 6444 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
6432 | 6445 |
6433 EXPECT_EQ(1u, render_surface_layer_list.size()); | 6446 EXPECT_EQ(1u, render_surface_layer_list.size()); |
6434 | 6447 |
6435 int count_represents_target_render_surface = 0; | 6448 int count_represents_target_render_surface = 0; |
6436 int count_represents_contributing_render_surface = 0; | 6449 int count_represents_contributing_render_surface = 0; |
6437 int count_represents_itself = 0; | 6450 int count_represents_itself = 0; |
6438 LayerIterator end = LayerIterator::End(&render_surface_layer_list); | 6451 LayerIterator end = LayerIterator::End(&render_surface_layer_list); |
6439 for (LayerIterator it = LayerIterator::Begin(&render_surface_layer_list); | 6452 for (LayerIterator it = LayerIterator::Begin(&render_surface_layer_list); |
(...skipping 868 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7308 scoped_ptr<AnimationScaleFactorTrackingLayerImpl> parent = | 7321 scoped_ptr<AnimationScaleFactorTrackingLayerImpl> parent = |
7309 AnimationScaleFactorTrackingLayerImpl::Create(host_impl.active_tree(), 2); | 7322 AnimationScaleFactorTrackingLayerImpl::Create(host_impl.active_tree(), 2); |
7310 scoped_ptr<AnimationScaleFactorTrackingLayerImpl> child = | 7323 scoped_ptr<AnimationScaleFactorTrackingLayerImpl> child = |
7311 AnimationScaleFactorTrackingLayerImpl::Create(host_impl.active_tree(), 3); | 7324 AnimationScaleFactorTrackingLayerImpl::Create(host_impl.active_tree(), 3); |
7312 scoped_ptr<AnimationScaleFactorTrackingLayerImpl> grand_child = | 7325 scoped_ptr<AnimationScaleFactorTrackingLayerImpl> grand_child = |
7313 AnimationScaleFactorTrackingLayerImpl::Create(host_impl.active_tree(), 4); | 7326 AnimationScaleFactorTrackingLayerImpl::Create(host_impl.active_tree(), 4); |
7314 | 7327 |
7315 AnimationScaleFactorTrackingLayerImpl* parent_raw = parent.get(); | 7328 AnimationScaleFactorTrackingLayerImpl* parent_raw = parent.get(); |
7316 AnimationScaleFactorTrackingLayerImpl* child_raw = child.get(); | 7329 AnimationScaleFactorTrackingLayerImpl* child_raw = child.get(); |
7317 AnimationScaleFactorTrackingLayerImpl* grand_child_raw = grand_child.get(); | 7330 AnimationScaleFactorTrackingLayerImpl* grand_child_raw = grand_child.get(); |
| 7331 AnimationScaleFactorTrackingLayerImpl* grand_parent_raw = grand_parent.get(); |
7318 | 7332 |
7319 child->AddChild(std::move(grand_child)); | 7333 child->AddChild(std::move(grand_child)); |
7320 parent->AddChild(std::move(child)); | 7334 parent->AddChild(std::move(child)); |
7321 grand_parent->AddChild(std::move(parent)); | 7335 grand_parent->AddChild(std::move(parent)); |
| 7336 host_impl.active_tree()->SetRootLayer(std::move(grand_parent)); |
7322 | 7337 |
7323 SetLayerPropertiesForTesting(grand_parent.get(), identity_matrix, | 7338 SetLayerPropertiesForTesting(grand_parent_raw, identity_matrix, |
7324 gfx::Point3F(), gfx::PointF(), gfx::Size(1, 2), | 7339 gfx::Point3F(), gfx::PointF(), gfx::Size(1, 2), |
7325 true, false, true); | 7340 true, false, true); |
7326 SetLayerPropertiesForTesting(parent_raw, identity_matrix, gfx::Point3F(), | 7341 SetLayerPropertiesForTesting(parent_raw, identity_matrix, gfx::Point3F(), |
7327 gfx::PointF(), gfx::Size(1, 2), true, false, | 7342 gfx::PointF(), gfx::Size(1, 2), true, false, |
7328 false); | 7343 false); |
7329 SetLayerPropertiesForTesting(child_raw, identity_matrix, gfx::Point3F(), | 7344 SetLayerPropertiesForTesting(child_raw, identity_matrix, gfx::Point3F(), |
7330 gfx::PointF(), gfx::Size(1, 2), true, false, | 7345 gfx::PointF(), gfx::Size(1, 2), true, false, |
7331 false); | 7346 false); |
7332 | 7347 |
7333 SetLayerPropertiesForTesting(grand_child_raw, identity_matrix, gfx::Point3F(), | 7348 SetLayerPropertiesForTesting(grand_child_raw, identity_matrix, gfx::Point3F(), |
7334 gfx::PointF(), gfx::Size(1, 2), true, false, | 7349 gfx::PointF(), gfx::Size(1, 2), true, false, |
7335 false); | 7350 false); |
7336 | 7351 |
7337 ExecuteCalculateDrawProperties(grand_parent.get()); | 7352 ExecuteCalculateDrawProperties(grand_parent_raw); |
7338 | 7353 |
7339 // No layers have animations. | 7354 // No layers have animations. |
7340 EXPECT_EQ(0.f, | 7355 EXPECT_EQ( |
7341 grand_parent->draw_properties().maximum_animation_contents_scale); | 7356 0.f, |
| 7357 grand_parent_raw->draw_properties().maximum_animation_contents_scale); |
7342 EXPECT_EQ(0.f, | 7358 EXPECT_EQ(0.f, |
7343 parent_raw->draw_properties().maximum_animation_contents_scale); | 7359 parent_raw->draw_properties().maximum_animation_contents_scale); |
7344 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale); | 7360 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale); |
7345 EXPECT_EQ( | 7361 EXPECT_EQ( |
7346 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); | 7362 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); |
7347 | 7363 |
7348 EXPECT_EQ(0.f, | 7364 EXPECT_EQ( |
7349 grand_parent->draw_properties().starting_animation_contents_scale); | 7365 0.f, |
| 7366 grand_parent_raw->draw_properties().starting_animation_contents_scale); |
7350 EXPECT_EQ(0.f, | 7367 EXPECT_EQ(0.f, |
7351 parent_raw->draw_properties().starting_animation_contents_scale); | 7368 parent_raw->draw_properties().starting_animation_contents_scale); |
7352 EXPECT_EQ(0.f, | 7369 EXPECT_EQ(0.f, |
7353 child_raw->draw_properties().starting_animation_contents_scale); | 7370 child_raw->draw_properties().starting_animation_contents_scale); |
7354 EXPECT_EQ( | 7371 EXPECT_EQ( |
7355 0.f, | 7372 0.f, |
7356 grand_child_raw->draw_properties().starting_animation_contents_scale); | 7373 grand_child_raw->draw_properties().starting_animation_contents_scale); |
7357 | 7374 |
7358 TransformOperations translation; | 7375 TransformOperations translation; |
7359 translation.AppendTranslate(1.f, 2.f, 3.f); | 7376 translation.AppendTranslate(1.f, 2.f, 3.f); |
7360 | 7377 |
7361 scoped_refptr<AnimationTimeline> timeline; | 7378 scoped_refptr<AnimationTimeline> timeline; |
7362 timeline = AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); | 7379 timeline = AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); |
7363 host_impl.animation_host()->AddAnimationTimeline(timeline); | 7380 host_impl.animation_host()->AddAnimationTimeline(timeline); |
7364 | 7381 |
7365 AddAnimatedTransformToLayerWithPlayer(parent_raw->id(), timeline, 1.0, | 7382 AddAnimatedTransformToLayerWithPlayer(parent_raw->id(), timeline, 1.0, |
7366 TransformOperations(), translation); | 7383 TransformOperations(), translation); |
7367 | 7384 |
7368 // No layers have scale-affecting animations. | 7385 // No layers have scale-affecting animations. |
7369 EXPECT_EQ(0.f, | 7386 EXPECT_EQ( |
7370 grand_parent->draw_properties().maximum_animation_contents_scale); | 7387 0.f, |
| 7388 grand_parent_raw->draw_properties().maximum_animation_contents_scale); |
7371 EXPECT_EQ(0.f, | 7389 EXPECT_EQ(0.f, |
7372 parent_raw->draw_properties().maximum_animation_contents_scale); | 7390 parent_raw->draw_properties().maximum_animation_contents_scale); |
7373 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale); | 7391 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale); |
7374 EXPECT_EQ( | 7392 EXPECT_EQ( |
7375 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); | 7393 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); |
7376 | 7394 |
7377 EXPECT_EQ(0.f, | 7395 EXPECT_EQ( |
7378 grand_parent->draw_properties().starting_animation_contents_scale); | 7396 0.f, |
| 7397 grand_parent_raw->draw_properties().starting_animation_contents_scale); |
7379 EXPECT_EQ(0.f, | 7398 EXPECT_EQ(0.f, |
7380 parent_raw->draw_properties().starting_animation_contents_scale); | 7399 parent_raw->draw_properties().starting_animation_contents_scale); |
7381 EXPECT_EQ(0.f, | 7400 EXPECT_EQ(0.f, |
7382 child_raw->draw_properties().starting_animation_contents_scale); | 7401 child_raw->draw_properties().starting_animation_contents_scale); |
7383 EXPECT_EQ( | 7402 EXPECT_EQ( |
7384 0.f, | 7403 0.f, |
7385 grand_child_raw->draw_properties().starting_animation_contents_scale); | 7404 grand_child_raw->draw_properties().starting_animation_contents_scale); |
7386 | 7405 |
7387 TransformOperations scale; | 7406 TransformOperations scale; |
7388 scale.AppendScale(5.f, 4.f, 3.f); | 7407 scale.AppendScale(5.f, 4.f, 3.f); |
7389 | 7408 |
7390 AddAnimatedTransformToLayerWithPlayer(child_raw->id(), timeline, 1.0, | 7409 AddAnimatedTransformToLayerWithPlayer(child_raw->id(), timeline, 1.0, |
7391 TransformOperations(), scale); | 7410 TransformOperations(), scale); |
7392 child_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; | 7411 child_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; |
7393 ExecuteCalculateDrawProperties(grand_parent.get()); | 7412 ExecuteCalculateDrawProperties(grand_parent_raw); |
7394 | 7413 |
7395 // Only |child| has a scale-affecting animation. | 7414 // Only |child| has a scale-affecting animation. |
7396 EXPECT_EQ(0.f, | 7415 EXPECT_EQ( |
7397 grand_parent->draw_properties().maximum_animation_contents_scale); | 7416 0.f, |
| 7417 grand_parent_raw->draw_properties().maximum_animation_contents_scale); |
7398 EXPECT_EQ(0.f, | 7418 EXPECT_EQ(0.f, |
7399 parent_raw->draw_properties().maximum_animation_contents_scale); | 7419 parent_raw->draw_properties().maximum_animation_contents_scale); |
7400 EXPECT_EQ(5.f, child_raw->draw_properties().maximum_animation_contents_scale); | 7420 EXPECT_EQ(5.f, child_raw->draw_properties().maximum_animation_contents_scale); |
7401 EXPECT_EQ( | 7421 EXPECT_EQ( |
7402 5.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); | 7422 5.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); |
7403 | 7423 |
7404 EXPECT_EQ(0.f, | 7424 EXPECT_EQ( |
7405 grand_parent->draw_properties().starting_animation_contents_scale); | 7425 0.f, |
| 7426 grand_parent_raw->draw_properties().starting_animation_contents_scale); |
7406 EXPECT_EQ(0.f, | 7427 EXPECT_EQ(0.f, |
7407 parent_raw->draw_properties().starting_animation_contents_scale); | 7428 parent_raw->draw_properties().starting_animation_contents_scale); |
7408 EXPECT_EQ(1.f, | 7429 EXPECT_EQ(1.f, |
7409 child_raw->draw_properties().starting_animation_contents_scale); | 7430 child_raw->draw_properties().starting_animation_contents_scale); |
7410 EXPECT_EQ( | 7431 EXPECT_EQ( |
7411 1.f, | 7432 1.f, |
7412 grand_child_raw->draw_properties().starting_animation_contents_scale); | 7433 grand_child_raw->draw_properties().starting_animation_contents_scale); |
7413 | 7434 |
7414 AddAnimatedTransformToLayerWithPlayer(grand_parent->id(), timeline, 1.0, | 7435 AddAnimatedTransformToLayerWithPlayer(grand_parent_raw->id(), timeline, 1.0, |
7415 TransformOperations(), scale); | 7436 TransformOperations(), scale); |
7416 grand_parent->layer_tree_impl()->property_trees()->needs_rebuild = true; | 7437 grand_parent_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; |
7417 ExecuteCalculateDrawProperties(grand_parent.get()); | 7438 ExecuteCalculateDrawProperties(grand_parent_raw); |
7418 | 7439 |
7419 // |grand_parent| and |child| have scale-affecting animations. | 7440 // |grand_parent| and |child| have scale-affecting animations. |
7420 EXPECT_EQ(5.f, | 7441 EXPECT_EQ( |
7421 grand_parent->draw_properties().maximum_animation_contents_scale); | 7442 5.f, |
| 7443 grand_parent_raw->draw_properties().maximum_animation_contents_scale); |
7422 EXPECT_EQ(5.f, | 7444 EXPECT_EQ(5.f, |
7423 parent_raw->draw_properties().maximum_animation_contents_scale); | 7445 parent_raw->draw_properties().maximum_animation_contents_scale); |
7424 // We don't support combining animated scales from two nodes; 0.f means | 7446 // We don't support combining animated scales from two nodes; 0.f means |
7425 // that the maximum scale could not be computed. | 7447 // that the maximum scale could not be computed. |
7426 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale); | 7448 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale); |
7427 EXPECT_EQ( | 7449 EXPECT_EQ( |
7428 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); | 7450 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); |
7429 | 7451 |
7430 EXPECT_EQ(1.f, | 7452 EXPECT_EQ( |
7431 grand_parent->draw_properties().starting_animation_contents_scale); | 7453 1.f, |
| 7454 grand_parent_raw->draw_properties().starting_animation_contents_scale); |
7432 EXPECT_EQ(1.f, | 7455 EXPECT_EQ(1.f, |
7433 parent_raw->draw_properties().starting_animation_contents_scale); | 7456 parent_raw->draw_properties().starting_animation_contents_scale); |
7434 EXPECT_EQ(0.f, | 7457 EXPECT_EQ(0.f, |
7435 child_raw->draw_properties().starting_animation_contents_scale); | 7458 child_raw->draw_properties().starting_animation_contents_scale); |
7436 EXPECT_EQ( | 7459 EXPECT_EQ( |
7437 0.f, | 7460 0.f, |
7438 grand_child_raw->draw_properties().starting_animation_contents_scale); | 7461 grand_child_raw->draw_properties().starting_animation_contents_scale); |
7439 | 7462 |
7440 AddAnimatedTransformToLayerWithPlayer(parent_raw->id(), timeline, 1.0, | 7463 AddAnimatedTransformToLayerWithPlayer(parent_raw->id(), timeline, 1.0, |
7441 TransformOperations(), scale); | 7464 TransformOperations(), scale); |
7442 parent_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; | 7465 parent_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; |
7443 ExecuteCalculateDrawProperties(grand_parent.get()); | 7466 ExecuteCalculateDrawProperties(grand_parent_raw); |
7444 | 7467 |
7445 // |grand_parent|, |parent|, and |child| have scale-affecting animations. | 7468 // |grand_parent|, |parent|, and |child| have scale-affecting animations. |
7446 EXPECT_EQ(5.f, | 7469 EXPECT_EQ( |
7447 grand_parent->draw_properties().maximum_animation_contents_scale); | 7470 5.f, |
| 7471 grand_parent_raw->draw_properties().maximum_animation_contents_scale); |
7448 EXPECT_EQ(0.f, | 7472 EXPECT_EQ(0.f, |
7449 parent_raw->draw_properties().maximum_animation_contents_scale); | 7473 parent_raw->draw_properties().maximum_animation_contents_scale); |
7450 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale); | 7474 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale); |
7451 EXPECT_EQ( | 7475 EXPECT_EQ( |
7452 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); | 7476 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); |
7453 | 7477 |
7454 EXPECT_EQ(1.f, | 7478 EXPECT_EQ( |
7455 grand_parent->draw_properties().starting_animation_contents_scale); | 7479 1.f, |
| 7480 grand_parent_raw->draw_properties().starting_animation_contents_scale); |
7456 EXPECT_EQ(0.f, | 7481 EXPECT_EQ(0.f, |
7457 parent_raw->draw_properties().starting_animation_contents_scale); | 7482 parent_raw->draw_properties().starting_animation_contents_scale); |
7458 EXPECT_EQ(0.f, | 7483 EXPECT_EQ(0.f, |
7459 child_raw->draw_properties().starting_animation_contents_scale); | 7484 child_raw->draw_properties().starting_animation_contents_scale); |
7460 EXPECT_EQ( | 7485 EXPECT_EQ( |
7461 0.f, | 7486 0.f, |
7462 grand_child_raw->draw_properties().starting_animation_contents_scale); | 7487 grand_child_raw->draw_properties().starting_animation_contents_scale); |
7463 | 7488 |
7464 AbortAnimationsOnLayerWithPlayer(grand_parent->id(), timeline, | 7489 AbortAnimationsOnLayerWithPlayer(grand_parent_raw->id(), timeline, |
7465 TargetProperty::TRANSFORM); | 7490 TargetProperty::TRANSFORM); |
7466 AbortAnimationsOnLayerWithPlayer(parent_raw->id(), timeline, | 7491 AbortAnimationsOnLayerWithPlayer(parent_raw->id(), timeline, |
7467 TargetProperty::TRANSFORM); | 7492 TargetProperty::TRANSFORM); |
7468 AbortAnimationsOnLayerWithPlayer(child_raw->id(), timeline, | 7493 AbortAnimationsOnLayerWithPlayer(child_raw->id(), timeline, |
7469 TargetProperty::TRANSFORM); | 7494 TargetProperty::TRANSFORM); |
7470 | 7495 |
7471 TransformOperations perspective; | 7496 TransformOperations perspective; |
7472 perspective.AppendPerspective(10.f); | 7497 perspective.AppendPerspective(10.f); |
7473 | 7498 |
7474 AddAnimatedTransformToLayerWithPlayer(child_raw->id(), timeline, 1.0, | 7499 AddAnimatedTransformToLayerWithPlayer(child_raw->id(), timeline, 1.0, |
7475 TransformOperations(), perspective); | 7500 TransformOperations(), perspective); |
7476 child_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; | 7501 child_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; |
7477 ExecuteCalculateDrawProperties(grand_parent.get()); | 7502 ExecuteCalculateDrawProperties(grand_parent_raw); |
7478 | 7503 |
7479 // |child| has a scale-affecting animation but computing the maximum of this | 7504 // |child| has a scale-affecting animation but computing the maximum of this |
7480 // animation is not supported. | 7505 // animation is not supported. |
7481 EXPECT_EQ(0.f, | 7506 EXPECT_EQ( |
7482 grand_parent->draw_properties().maximum_animation_contents_scale); | 7507 0.f, |
| 7508 grand_parent_raw->draw_properties().maximum_animation_contents_scale); |
7483 EXPECT_EQ(0.f, | 7509 EXPECT_EQ(0.f, |
7484 parent_raw->draw_properties().maximum_animation_contents_scale); | 7510 parent_raw->draw_properties().maximum_animation_contents_scale); |
7485 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale); | 7511 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale); |
7486 EXPECT_EQ( | 7512 EXPECT_EQ( |
7487 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); | 7513 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); |
7488 | 7514 |
7489 EXPECT_EQ(0.f, | 7515 EXPECT_EQ( |
7490 grand_parent->draw_properties().starting_animation_contents_scale); | 7516 0.f, |
| 7517 grand_parent_raw->draw_properties().starting_animation_contents_scale); |
7491 EXPECT_EQ(0.f, | 7518 EXPECT_EQ(0.f, |
7492 parent_raw->draw_properties().starting_animation_contents_scale); | 7519 parent_raw->draw_properties().starting_animation_contents_scale); |
7493 EXPECT_EQ(0.f, | 7520 EXPECT_EQ(0.f, |
7494 child_raw->draw_properties().starting_animation_contents_scale); | 7521 child_raw->draw_properties().starting_animation_contents_scale); |
7495 EXPECT_EQ( | 7522 EXPECT_EQ( |
7496 0.f, | 7523 0.f, |
7497 grand_child_raw->draw_properties().starting_animation_contents_scale); | 7524 grand_child_raw->draw_properties().starting_animation_contents_scale); |
7498 | 7525 |
7499 AbortAnimationsOnLayerWithPlayer(child_raw->id(), timeline, | 7526 AbortAnimationsOnLayerWithPlayer(child_raw->id(), timeline, |
7500 TargetProperty::TRANSFORM); | 7527 TargetProperty::TRANSFORM); |
7501 gfx::Transform scale_matrix; | 7528 gfx::Transform scale_matrix; |
7502 scale_matrix.Scale(1.f, 2.f); | 7529 scale_matrix.Scale(1.f, 2.f); |
7503 grand_parent->SetTransform(scale_matrix); | 7530 grand_parent_raw->SetTransform(scale_matrix); |
7504 parent_raw->SetTransform(scale_matrix); | 7531 parent_raw->SetTransform(scale_matrix); |
7505 grand_parent->layer_tree_impl()->property_trees()->needs_rebuild = true; | 7532 grand_parent_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; |
7506 | 7533 |
7507 AddAnimatedTransformToLayerWithPlayer(parent_raw->id(), timeline, 1.0, | 7534 AddAnimatedTransformToLayerWithPlayer(parent_raw->id(), timeline, 1.0, |
7508 TransformOperations(), scale); | 7535 TransformOperations(), scale); |
7509 ExecuteCalculateDrawProperties(grand_parent.get()); | 7536 ExecuteCalculateDrawProperties(grand_parent_raw); |
7510 | 7537 |
7511 // |grand_parent| and |parent| each have scale 2.f. |parent| has a scale | 7538 // |grand_parent| and |parent| each have scale 2.f. |parent| has a scale |
7512 // animation with maximum scale 5.f. | 7539 // animation with maximum scale 5.f. |
7513 EXPECT_EQ(0.f, | 7540 EXPECT_EQ( |
7514 grand_parent->draw_properties().maximum_animation_contents_scale); | 7541 0.f, |
| 7542 grand_parent_raw->draw_properties().maximum_animation_contents_scale); |
7515 EXPECT_EQ(10.f, | 7543 EXPECT_EQ(10.f, |
7516 parent_raw->draw_properties().maximum_animation_contents_scale); | 7544 parent_raw->draw_properties().maximum_animation_contents_scale); |
7517 EXPECT_EQ(10.f, | 7545 EXPECT_EQ(10.f, |
7518 child_raw->draw_properties().maximum_animation_contents_scale); | 7546 child_raw->draw_properties().maximum_animation_contents_scale); |
7519 EXPECT_EQ( | 7547 EXPECT_EQ( |
7520 10.f, | 7548 10.f, |
7521 grand_child_raw->draw_properties().maximum_animation_contents_scale); | 7549 grand_child_raw->draw_properties().maximum_animation_contents_scale); |
7522 | 7550 |
7523 EXPECT_EQ(0.f, | 7551 EXPECT_EQ( |
7524 grand_parent->draw_properties().starting_animation_contents_scale); | 7552 0.f, |
| 7553 grand_parent_raw->draw_properties().starting_animation_contents_scale); |
7525 EXPECT_EQ(2.f, | 7554 EXPECT_EQ(2.f, |
7526 parent_raw->draw_properties().starting_animation_contents_scale); | 7555 parent_raw->draw_properties().starting_animation_contents_scale); |
7527 EXPECT_EQ(2.f, | 7556 EXPECT_EQ(2.f, |
7528 child_raw->draw_properties().starting_animation_contents_scale); | 7557 child_raw->draw_properties().starting_animation_contents_scale); |
7529 EXPECT_EQ( | 7558 EXPECT_EQ( |
7530 2.f, | 7559 2.f, |
7531 grand_child_raw->draw_properties().starting_animation_contents_scale); | 7560 grand_child_raw->draw_properties().starting_animation_contents_scale); |
7532 | 7561 |
7533 gfx::Transform perspective_matrix; | 7562 gfx::Transform perspective_matrix; |
7534 perspective_matrix.ApplyPerspectiveDepth(2.f); | 7563 perspective_matrix.ApplyPerspectiveDepth(2.f); |
7535 child_raw->SetTransform(perspective_matrix); | 7564 child_raw->SetTransform(perspective_matrix); |
7536 grand_parent->layer_tree_impl()->property_trees()->needs_rebuild = true; | 7565 grand_parent_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; |
7537 ExecuteCalculateDrawProperties(grand_parent.get()); | 7566 ExecuteCalculateDrawProperties(grand_parent_raw); |
7538 | 7567 |
7539 // |child| has a transform that's neither a translation nor a scale. | 7568 // |child| has a transform that's neither a translation nor a scale. |
7540 EXPECT_EQ(0.f, | 7569 EXPECT_EQ( |
7541 grand_parent->draw_properties().maximum_animation_contents_scale); | 7570 0.f, |
| 7571 grand_parent_raw->draw_properties().maximum_animation_contents_scale); |
7542 EXPECT_EQ(10.f, | 7572 EXPECT_EQ(10.f, |
7543 parent_raw->draw_properties().maximum_animation_contents_scale); | 7573 parent_raw->draw_properties().maximum_animation_contents_scale); |
7544 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale); | 7574 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale); |
7545 EXPECT_EQ( | 7575 EXPECT_EQ( |
7546 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); | 7576 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); |
7547 | 7577 |
7548 EXPECT_EQ(0.f, | 7578 EXPECT_EQ( |
7549 grand_parent->draw_properties().starting_animation_contents_scale); | 7579 0.f, |
| 7580 grand_parent_raw->draw_properties().starting_animation_contents_scale); |
7550 EXPECT_EQ(2.f, | 7581 EXPECT_EQ(2.f, |
7551 parent_raw->draw_properties().starting_animation_contents_scale); | 7582 parent_raw->draw_properties().starting_animation_contents_scale); |
7552 EXPECT_EQ(0.f, | 7583 EXPECT_EQ(0.f, |
7553 child_raw->draw_properties().starting_animation_contents_scale); | 7584 child_raw->draw_properties().starting_animation_contents_scale); |
7554 EXPECT_EQ( | 7585 EXPECT_EQ( |
7555 0.f, | 7586 0.f, |
7556 grand_child_raw->draw_properties().starting_animation_contents_scale); | 7587 grand_child_raw->draw_properties().starting_animation_contents_scale); |
7557 | 7588 |
7558 parent_raw->SetTransform(perspective_matrix); | 7589 parent_raw->SetTransform(perspective_matrix); |
7559 grand_parent->layer_tree_impl()->property_trees()->needs_rebuild = true; | 7590 grand_parent_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; |
7560 ExecuteCalculateDrawProperties(grand_parent.get()); | 7591 ExecuteCalculateDrawProperties(grand_parent_raw); |
7561 | 7592 |
7562 // |parent| and |child| have transforms that are neither translations nor | 7593 // |parent| and |child| have transforms that are neither translations nor |
7563 // scales. | 7594 // scales. |
7564 EXPECT_EQ(0.f, | 7595 EXPECT_EQ( |
7565 grand_parent->draw_properties().maximum_animation_contents_scale); | 7596 0.f, |
| 7597 grand_parent_raw->draw_properties().maximum_animation_contents_scale); |
7566 EXPECT_EQ(0.f, | 7598 EXPECT_EQ(0.f, |
7567 parent_raw->draw_properties().maximum_animation_contents_scale); | 7599 parent_raw->draw_properties().maximum_animation_contents_scale); |
7568 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale); | 7600 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale); |
7569 EXPECT_EQ( | 7601 EXPECT_EQ( |
7570 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); | 7602 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); |
7571 | 7603 |
7572 EXPECT_EQ(0.f, | 7604 EXPECT_EQ( |
7573 grand_parent->draw_properties().starting_animation_contents_scale); | 7605 0.f, |
| 7606 grand_parent_raw->draw_properties().starting_animation_contents_scale); |
7574 EXPECT_EQ(0.f, | 7607 EXPECT_EQ(0.f, |
7575 parent_raw->draw_properties().starting_animation_contents_scale); | 7608 parent_raw->draw_properties().starting_animation_contents_scale); |
7576 EXPECT_EQ(0.f, | 7609 EXPECT_EQ(0.f, |
7577 child_raw->draw_properties().starting_animation_contents_scale); | 7610 child_raw->draw_properties().starting_animation_contents_scale); |
7578 EXPECT_EQ( | 7611 EXPECT_EQ( |
7579 0.f, | 7612 0.f, |
7580 grand_child_raw->draw_properties().starting_animation_contents_scale); | 7613 grand_child_raw->draw_properties().starting_animation_contents_scale); |
7581 | 7614 |
7582 parent_raw->SetTransform(identity_matrix); | 7615 parent_raw->SetTransform(identity_matrix); |
7583 child_raw->SetTransform(identity_matrix); | 7616 child_raw->SetTransform(identity_matrix); |
7584 grand_parent->SetTransform(perspective_matrix); | 7617 grand_parent_raw->SetTransform(perspective_matrix); |
7585 grand_parent->layer_tree_impl()->property_trees()->needs_rebuild = true; | 7618 grand_parent_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; |
7586 | 7619 |
7587 ExecuteCalculateDrawProperties(grand_parent.get()); | 7620 ExecuteCalculateDrawProperties(grand_parent_raw); |
7588 | 7621 |
7589 // |grand_parent| has a transform that's neither a translation nor a scale. | 7622 // |grand_parent| has a transform that's neither a translation nor a scale. |
7590 EXPECT_EQ(0.f, | 7623 EXPECT_EQ( |
7591 grand_parent->draw_properties().maximum_animation_contents_scale); | 7624 0.f, |
| 7625 grand_parent_raw->draw_properties().maximum_animation_contents_scale); |
7592 EXPECT_EQ(0.f, | 7626 EXPECT_EQ(0.f, |
7593 parent_raw->draw_properties().maximum_animation_contents_scale); | 7627 parent_raw->draw_properties().maximum_animation_contents_scale); |
7594 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale); | 7628 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale); |
7595 EXPECT_EQ( | 7629 EXPECT_EQ( |
7596 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); | 7630 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); |
7597 | 7631 |
7598 EXPECT_EQ(0.f, | 7632 EXPECT_EQ( |
7599 grand_parent->draw_properties().starting_animation_contents_scale); | 7633 0.f, |
| 7634 grand_parent_raw->draw_properties().starting_animation_contents_scale); |
7600 EXPECT_EQ(0.f, | 7635 EXPECT_EQ(0.f, |
7601 parent_raw->draw_properties().starting_animation_contents_scale); | 7636 parent_raw->draw_properties().starting_animation_contents_scale); |
7602 EXPECT_EQ(0.f, | 7637 EXPECT_EQ(0.f, |
7603 child_raw->draw_properties().starting_animation_contents_scale); | 7638 child_raw->draw_properties().starting_animation_contents_scale); |
7604 EXPECT_EQ( | 7639 EXPECT_EQ( |
7605 0.f, | 7640 0.f, |
7606 grand_child_raw->draw_properties().starting_animation_contents_scale); | 7641 grand_child_raw->draw_properties().starting_animation_contents_scale); |
7607 } | 7642 } |
7608 | 7643 |
7609 static int membership_id(LayerImpl* layer) { | 7644 static int membership_id(LayerImpl* layer) { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7649 LayerImpl* grand_parent_raw = grand_parent.get(); | 7684 LayerImpl* grand_parent_raw = grand_parent.get(); |
7650 LayerImpl* parent_raw = parent.get(); | 7685 LayerImpl* parent_raw = parent.get(); |
7651 LayerImpl* child_raw = child.get(); | 7686 LayerImpl* child_raw = child.get(); |
7652 LayerImpl* grand_child1_raw = grand_child1.get(); | 7687 LayerImpl* grand_child1_raw = grand_child1.get(); |
7653 LayerImpl* grand_child2_raw = grand_child2.get(); | 7688 LayerImpl* grand_child2_raw = grand_child2.get(); |
7654 | 7689 |
7655 child->AddChild(std::move(grand_child1)); | 7690 child->AddChild(std::move(grand_child1)); |
7656 child->AddChild(std::move(grand_child2)); | 7691 child->AddChild(std::move(grand_child2)); |
7657 parent->AddChild(std::move(child)); | 7692 parent->AddChild(std::move(child)); |
7658 grand_parent->AddChild(std::move(parent)); | 7693 grand_parent->AddChild(std::move(parent)); |
| 7694 host_impl.active_tree()->SetRootLayer(std::move(grand_parent)); |
7659 | 7695 |
7660 SetLayerPropertiesForTesting(grand_parent_raw, identity_matrix, | 7696 SetLayerPropertiesForTesting(grand_parent_raw, identity_matrix, |
7661 gfx::Point3F(), gfx::PointF(), gfx::Size(1, 2), | 7697 gfx::Point3F(), gfx::PointF(), gfx::Size(1, 2), |
7662 true, false, true); | 7698 true, false, true); |
7663 SetLayerPropertiesForTesting(parent_raw, identity_matrix, gfx::Point3F(), | 7699 SetLayerPropertiesForTesting(parent_raw, identity_matrix, gfx::Point3F(), |
7664 gfx::PointF(), gfx::Size(1, 2), true, false, | 7700 gfx::PointF(), gfx::Size(1, 2), true, false, |
7665 false); | 7701 false); |
7666 | 7702 |
7667 SetLayerPropertiesForTesting(child_raw, identity_matrix, gfx::Point3F(), | 7703 SetLayerPropertiesForTesting(child_raw, identity_matrix, gfx::Point3F(), |
7668 gfx::PointF(), gfx::Size(1, 2), true, false, | 7704 gfx::PointF(), gfx::Size(1, 2), true, false, |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7892 LayerImpl* root_layer = root.get(); | 7928 LayerImpl* root_layer = root.get(); |
7893 scoped_ptr<LayerImpl> child1 = LayerImpl::Create(host_impl.active_tree(), 2); | 7929 scoped_ptr<LayerImpl> child1 = LayerImpl::Create(host_impl.active_tree(), 2); |
7894 LayerImpl* child1_layer = child1.get(); | 7930 LayerImpl* child1_layer = child1.get(); |
7895 scoped_ptr<LayerImpl> child2 = LayerImpl::Create(host_impl.active_tree(), 3); | 7931 scoped_ptr<LayerImpl> child2 = LayerImpl::Create(host_impl.active_tree(), 3); |
7896 LayerImpl* child2_layer = child2.get(); | 7932 LayerImpl* child2_layer = child2.get(); |
7897 | 7933 |
7898 root->AddChild(std::move(child1)); | 7934 root->AddChild(std::move(child1)); |
7899 root->AddChild(std::move(child2)); | 7935 root->AddChild(std::move(child2)); |
7900 root->SetForceRenderSurface(true); | 7936 root->SetForceRenderSurface(true); |
7901 root->SetDrawsContent(true); | 7937 root->SetDrawsContent(true); |
| 7938 host_impl.active_tree()->SetRootLayer(std::move(root)); |
7902 | 7939 |
7903 gfx::Transform identity_matrix, scale_transform_child1, | 7940 gfx::Transform identity_matrix, scale_transform_child1, |
7904 scale_transform_child2; | 7941 scale_transform_child2; |
7905 scale_transform_child1.Scale(2, 3); | 7942 scale_transform_child1.Scale(2, 3); |
7906 scale_transform_child2.Scale(4, 5); | 7943 scale_transform_child2.Scale(4, 5); |
7907 | 7944 |
7908 SetLayerPropertiesForTesting(root_layer, identity_matrix, gfx::Point3F(), | 7945 SetLayerPropertiesForTesting(root_layer, identity_matrix, gfx::Point3F(), |
7909 gfx::PointF(), gfx::Size(1, 1), true, false, | 7946 gfx::PointF(), gfx::Size(1, 1), true, false, |
7910 true); | 7947 true); |
7911 SetLayerPropertiesForTesting(child1_layer, scale_transform_child1, | 7948 SetLayerPropertiesForTesting(child1_layer, scale_transform_child1, |
(...skipping 19 matching lines...) Expand all Loading... |
7931 host_impl.animation_host()->AddAnimationTimeline(timeline); | 7968 host_impl.animation_host()->AddAnimationTimeline(timeline); |
7932 | 7969 |
7933 AddAnimatedTransformToLayerWithPlayer(child2_layer->id(), timeline, 1.0, | 7970 AddAnimatedTransformToLayerWithPlayer(child2_layer->id(), timeline, 1.0, |
7934 TransformOperations(), scale); | 7971 TransformOperations(), scale); |
7935 | 7972 |
7936 SetLayerPropertiesForTesting(child2_layer, scale_transform_child2, | 7973 SetLayerPropertiesForTesting(child2_layer, scale_transform_child2, |
7937 gfx::Point3F(), gfx::PointF(), gfx::Size(1, 1), | 7974 gfx::Point3F(), gfx::PointF(), gfx::Size(1, 1), |
7938 true, false, false); | 7975 true, false, false); |
7939 child2_layer->SetDrawsContent(true); | 7976 child2_layer->SetDrawsContent(true); |
7940 | 7977 |
7941 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 7978 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = true; |
7942 ExecuteCalculateDrawProperties(root_layer); | 7979 ExecuteCalculateDrawProperties(root_layer); |
7943 | 7980 |
7944 EXPECT_FLOAT_EQ(1.f, root_layer->GetIdealContentsScale()); | 7981 EXPECT_FLOAT_EQ(1.f, root_layer->GetIdealContentsScale()); |
7945 EXPECT_FLOAT_EQ(3.f, child1_layer->GetIdealContentsScale()); | 7982 EXPECT_FLOAT_EQ(3.f, child1_layer->GetIdealContentsScale()); |
7946 EXPECT_FLOAT_EQ(3.f, child1_layer->mask_layer()->GetIdealContentsScale()); | 7983 EXPECT_FLOAT_EQ(3.f, child1_layer->mask_layer()->GetIdealContentsScale()); |
7947 EXPECT_FLOAT_EQ(5.f, child2_layer->GetIdealContentsScale()); | 7984 EXPECT_FLOAT_EQ(5.f, child2_layer->GetIdealContentsScale()); |
7948 | 7985 |
7949 EXPECT_FLOAT_EQ( | 7986 EXPECT_FLOAT_EQ( |
7950 0.f, root_layer->draw_properties().maximum_animation_contents_scale); | 7987 0.f, root_layer->draw_properties().maximum_animation_contents_scale); |
7951 EXPECT_FLOAT_EQ( | 7988 EXPECT_FLOAT_EQ( |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8004 .maximum_animation_contents_scale); | 8041 .maximum_animation_contents_scale); |
8005 EXPECT_FLOAT_EQ( | 8042 EXPECT_FLOAT_EQ( |
8006 24.f, child2_layer->draw_properties().maximum_animation_contents_scale); | 8043 24.f, child2_layer->draw_properties().maximum_animation_contents_scale); |
8007 | 8044 |
8008 // Changing device-scale would affect ideal_contents_scale and | 8045 // Changing device-scale would affect ideal_contents_scale and |
8009 // maximum_animation_contents_scale. | 8046 // maximum_animation_contents_scale. |
8010 | 8047 |
8011 device_scale_factor = 4.0f; | 8048 device_scale_factor = 4.0f; |
8012 inputs.device_scale_factor = device_scale_factor; | 8049 inputs.device_scale_factor = device_scale_factor; |
8013 inputs.can_adjust_raster_scales = true; | 8050 inputs.can_adjust_raster_scales = true; |
8014 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 8051 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = true; |
8015 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 8052 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
8016 | 8053 |
8017 EXPECT_FLOAT_EQ(12.f, root_layer->GetIdealContentsScale()); | 8054 EXPECT_FLOAT_EQ(12.f, root_layer->GetIdealContentsScale()); |
8018 EXPECT_FLOAT_EQ(36.f, child1_layer->GetIdealContentsScale()); | 8055 EXPECT_FLOAT_EQ(36.f, child1_layer->GetIdealContentsScale()); |
8019 EXPECT_FLOAT_EQ(36.f, child1_layer->mask_layer()->GetIdealContentsScale()); | 8056 EXPECT_FLOAT_EQ(36.f, child1_layer->mask_layer()->GetIdealContentsScale()); |
8020 EXPECT_FLOAT_EQ( | 8057 EXPECT_FLOAT_EQ( |
8021 36.f, | 8058 36.f, |
8022 child1_layer->replica_layer()->mask_layer()->GetIdealContentsScale()); | 8059 child1_layer->replica_layer()->mask_layer()->GetIdealContentsScale()); |
8023 EXPECT_FLOAT_EQ(60.f, child2_layer->GetIdealContentsScale()); | 8060 EXPECT_FLOAT_EQ(60.f, child2_layer->GetIdealContentsScale()); |
8024 | 8061 |
(...skipping 828 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8853 SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(), | 8890 SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(), |
8854 gfx::PointF(), gfx::Size(100, 100), true, false, | 8891 gfx::PointF(), gfx::Size(100, 100), true, false, |
8855 true); | 8892 true); |
8856 SetLayerPropertiesForTesting(child.get(), identity, gfx::Point3F(), | 8893 SetLayerPropertiesForTesting(child.get(), identity, gfx::Point3F(), |
8857 gfx::PointF(), gfx::Size(10, 10), true, false, | 8894 gfx::PointF(), gfx::Size(10, 10), true, false, |
8858 false); | 8895 false); |
8859 SetLayerPropertiesForTesting(grandchild.get(), identity, gfx::Point3F(), | 8896 SetLayerPropertiesForTesting(grandchild.get(), identity, gfx::Point3F(), |
8860 gfx::PointF(), gfx::Size(10, 10), true, false, | 8897 gfx::PointF(), gfx::Size(10, 10), true, false, |
8861 false); | 8898 false); |
8862 | 8899 |
| 8900 LayerImpl* root_ptr = root.get(); |
8863 LayerImpl* child_ptr = child.get(); | 8901 LayerImpl* child_ptr = child.get(); |
8864 LayerImpl* grandchild_ptr = grandchild.get(); | 8902 LayerImpl* grandchild_ptr = grandchild.get(); |
8865 | 8903 |
8866 child->AddChild(std::move(grandchild)); | 8904 child->AddChild(std::move(grandchild)); |
8867 root->AddChild(std::move(child)); | 8905 root->AddChild(std::move(child)); |
| 8906 host_impl.active_tree()->SetRootLayer(std::move(root)); |
8868 | 8907 |
8869 // Check the non-skipped case. | 8908 // Check the non-skipped case. |
8870 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8909 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); |
8871 EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect()); | 8910 EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect()); |
8872 | 8911 |
8873 // Now we will reset the visible rect from property trees for the grandchild, | 8912 // Now we will reset the visible rect from property trees for the grandchild, |
8874 // and we will configure |child| in several ways that should force the subtree | 8913 // and we will configure |child| in several ways that should force the subtree |
8875 // to be skipped. The visible content rect for |grandchild| should, therefore, | 8914 // to be skipped. The visible content rect for |grandchild| should, therefore, |
8876 // remain empty. | 8915 // remain empty. |
8877 grandchild_ptr->set_visible_layer_rect(gfx::Rect()); | 8916 grandchild_ptr->set_visible_layer_rect(gfx::Rect()); |
8878 gfx::Transform singular; | 8917 gfx::Transform singular; |
8879 singular.matrix().set(0, 0, 0); | 8918 singular.matrix().set(0, 0, 0); |
8880 | 8919 |
8881 child_ptr->SetTransform(singular); | 8920 child_ptr->SetTransform(singular); |
8882 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8921 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); |
8883 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); | 8922 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); |
8884 child_ptr->SetTransform(identity); | 8923 child_ptr->SetTransform(identity); |
8885 | 8924 |
8886 child_ptr->SetHideLayerAndSubtree(true); | 8925 child_ptr->SetHideLayerAndSubtree(true); |
8887 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8926 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); |
8888 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); | 8927 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); |
8889 child_ptr->SetHideLayerAndSubtree(false); | 8928 child_ptr->SetHideLayerAndSubtree(false); |
8890 | 8929 |
8891 child_ptr->SetOpacity(0.f); | 8930 child_ptr->SetOpacity(0.f); |
8892 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8931 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); |
8893 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); | 8932 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); |
8894 | 8933 |
8895 // Now, even though child has zero opacity, we will configure |grandchild| and | 8934 // Now, even though child has zero opacity, we will configure |grandchild| and |
8896 // |greatgrandchild| in several ways that should force the subtree to be | 8935 // |greatgrandchild| in several ways that should force the subtree to be |
8897 // processed anyhow. | 8936 // processed anyhow. |
8898 std::vector<scoped_ptr<CopyOutputRequest>> requests; | 8937 std::vector<scoped_ptr<CopyOutputRequest>> requests; |
8899 requests.push_back(CopyOutputRequest::CreateEmptyRequest()); | 8938 requests.push_back(CopyOutputRequest::CreateEmptyRequest()); |
8900 | 8939 |
8901 grandchild_ptr->PassCopyRequests(&requests); | 8940 grandchild_ptr->PassCopyRequests(&requests); |
8902 root.get()->layer_tree_impl()->property_trees()->needs_rebuild = true; | 8941 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true; |
8903 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8942 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); |
8904 EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect()); | 8943 EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect()); |
8905 } | 8944 } |
8906 | 8945 |
8907 TEST_F(LayerTreeHostCommonTest, SkippingLayer) { | 8946 TEST_F(LayerTreeHostCommonTest, SkippingLayer) { |
8908 gfx::Transform identity; | 8947 gfx::Transform identity; |
8909 scoped_refptr<Layer> root = Layer::Create(); | 8948 scoped_refptr<Layer> root = Layer::Create(); |
8910 FakeContentLayerClient client; | 8949 FakeContentLayerClient client; |
8911 client.set_bounds(root->bounds()); | 8950 client.set_bounds(root->bounds()); |
8912 scoped_refptr<LayerWithForcedDrawsContent> child = | 8951 scoped_refptr<LayerWithForcedDrawsContent> child = |
8913 make_scoped_refptr(new LayerWithForcedDrawsContent()); | 8952 make_scoped_refptr(new LayerWithForcedDrawsContent()); |
(...skipping 1028 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9942 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); | 9981 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); |
9943 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); | 9982 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); |
9944 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); | 9983 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); |
9945 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); | 9984 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); |
9946 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); | 9985 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); |
9947 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); | 9986 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); |
9948 } | 9987 } |
9949 | 9988 |
9950 } // namespace | 9989 } // namespace |
9951 } // namespace cc | 9990 } // namespace cc |
OLD | NEW |