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/layers/layer.h" | 5 #include "cc/layers/layer.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/thread_task_runner_handle.h" | 9 #include "base/thread_task_runner_handle.h" |
10 #include "cc/animation/animation_host.h" | 10 #include "cc/animation/animation_host.h" |
(...skipping 798 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
809 ASSERT_EQ(1u, layer_dest_b->children().size()); | 809 ASSERT_EQ(1u, layer_dest_b->children().size()); |
810 layer_dest_c = layer_dest_b->children()[0]; | 810 layer_dest_c = layer_dest_b->children()[0]; |
811 EXPECT_EQ(layer_src_c->id(), layer_dest_c->id()); | 811 EXPECT_EQ(layer_src_c->id(), layer_dest_c->id()); |
812 EXPECT_EQ(99, layer_dest_c->transform_tree_index_); | 812 EXPECT_EQ(99, layer_dest_c->transform_tree_index_); |
813 | 813 |
814 layer_dest_root->SetLayerTreeHost(nullptr); | 814 layer_dest_root->SetLayerTreeHost(nullptr); |
815 } | 815 } |
816 | 816 |
817 TestTaskGraphRunner task_graph_runner_; | 817 TestTaskGraphRunner task_graph_runner_; |
818 FakeLayerTreeHostClient fake_client_; | 818 FakeLayerTreeHostClient fake_client_; |
819 scoped_ptr<FakeLayerTreeHost> layer_tree_host_; | 819 std::unique_ptr<FakeLayerTreeHost> layer_tree_host_; |
820 }; | 820 }; |
821 | 821 |
822 namespace { | 822 namespace { |
823 | 823 |
824 class MockLayerTreeHost : public LayerTreeHost { | 824 class MockLayerTreeHost : public LayerTreeHost { |
825 public: | 825 public: |
826 MockLayerTreeHost(LayerTreeHostSingleThreadClient* single_thread_client, | 826 MockLayerTreeHost(LayerTreeHostSingleThreadClient* single_thread_client, |
827 LayerTreeHost::InitParams* params) | 827 LayerTreeHost::InitParams* params) |
828 : LayerTreeHost(params, CompositorMode::SINGLE_THREADED) { | 828 : LayerTreeHost(params, CompositorMode::SINGLE_THREADED) { |
829 InitializeSingleThreaded(single_thread_client, | 829 InitializeSingleThreaded(single_thread_client, |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
922 | 922 |
923 VerifyTestTreeInitialState(); | 923 VerifyTestTreeInitialState(); |
924 } | 924 } |
925 | 925 |
926 FakeImplTaskRunnerProvider task_runner_provider_; | 926 FakeImplTaskRunnerProvider task_runner_provider_; |
927 TestSharedBitmapManager shared_bitmap_manager_; | 927 TestSharedBitmapManager shared_bitmap_manager_; |
928 TestTaskGraphRunner task_graph_runner_; | 928 TestTaskGraphRunner task_graph_runner_; |
929 FakeLayerTreeHostImpl host_impl_; | 929 FakeLayerTreeHostImpl host_impl_; |
930 | 930 |
931 FakeLayerTreeHostClient fake_client_; | 931 FakeLayerTreeHostClient fake_client_; |
932 scoped_ptr<StrictMock<MockLayerTreeHost>> layer_tree_host_; | 932 std::unique_ptr<StrictMock<MockLayerTreeHost>> layer_tree_host_; |
933 scoped_refptr<Layer> parent_; | 933 scoped_refptr<Layer> parent_; |
934 scoped_refptr<Layer> child1_; | 934 scoped_refptr<Layer> child1_; |
935 scoped_refptr<Layer> child2_; | 935 scoped_refptr<Layer> child2_; |
936 scoped_refptr<Layer> child3_; | 936 scoped_refptr<Layer> child3_; |
937 scoped_refptr<Layer> grand_child1_; | 937 scoped_refptr<Layer> grand_child1_; |
938 scoped_refptr<Layer> grand_child2_; | 938 scoped_refptr<Layer> grand_child2_; |
939 scoped_refptr<Layer> grand_child3_; | 939 scoped_refptr<Layer> grand_child3_; |
940 | 940 |
941 scoped_refptr<AnimationTimeline> timeline_impl_; | 941 scoped_refptr<AnimationTimeline> timeline_impl_; |
942 | 942 |
(...skipping 23 matching lines...) Expand all Loading... |
966 | 966 |
967 layer_tree_host_->SetRootLayer(root); | 967 layer_tree_host_->SetRootLayer(root); |
968 root->AddChild(child); | 968 root->AddChild(child); |
969 root->AddChild(child2); | 969 root->AddChild(child2); |
970 child->AddChild(grand_child); | 970 child->AddChild(grand_child); |
971 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); | 971 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); |
972 child->SetForceRenderSurface(true); | 972 child->SetForceRenderSurface(true); |
973 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); | 973 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); |
974 child2->SetScrollParent(grand_child.get()); | 974 child2->SetScrollParent(grand_child.get()); |
975 SkXfermode::Mode arbitrary_blend_mode = SkXfermode::kMultiply_Mode; | 975 SkXfermode::Mode arbitrary_blend_mode = SkXfermode::kMultiply_Mode; |
976 scoped_ptr<LayerImpl> root_impl = | 976 std::unique_ptr<LayerImpl> root_impl = |
977 LayerImpl::Create(host_impl_.active_tree(), root->id()); | 977 LayerImpl::Create(host_impl_.active_tree(), root->id()); |
978 scoped_ptr<LayerImpl> child_impl = | 978 std::unique_ptr<LayerImpl> child_impl = |
979 LayerImpl::Create(host_impl_.active_tree(), child->id()); | 979 LayerImpl::Create(host_impl_.active_tree(), child->id()); |
980 scoped_ptr<LayerImpl> child2_impl = | 980 std::unique_ptr<LayerImpl> child2_impl = |
981 LayerImpl::Create(host_impl_.active_tree(), child2->id()); | 981 LayerImpl::Create(host_impl_.active_tree(), child2->id()); |
982 scoped_ptr<LayerImpl> grand_child_impl = | 982 std::unique_ptr<LayerImpl> grand_child_impl = |
983 LayerImpl::Create(host_impl_.active_tree(), grand_child->id()); | 983 LayerImpl::Create(host_impl_.active_tree(), grand_child->id()); |
984 scoped_ptr<LayerImpl> dummy_layer1_impl = | 984 std::unique_ptr<LayerImpl> dummy_layer1_impl = |
985 LayerImpl::Create(host_impl_.active_tree(), dummy_layer1->id()); | 985 LayerImpl::Create(host_impl_.active_tree(), dummy_layer1->id()); |
986 scoped_ptr<LayerImpl> dummy_layer2_impl = | 986 std::unique_ptr<LayerImpl> dummy_layer2_impl = |
987 LayerImpl::Create(host_impl_.active_tree(), dummy_layer2->id()); | 987 LayerImpl::Create(host_impl_.active_tree(), dummy_layer2->id()); |
988 | 988 |
989 EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times(1); | 989 EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times(1); |
990 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetMaskLayer(dummy_layer1.get())); | 990 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetMaskLayer(dummy_layer1.get())); |
991 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( | 991 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( |
992 root->PushPropertiesTo(root_impl.get()); | 992 root->PushPropertiesTo(root_impl.get()); |
993 child->PushPropertiesTo(child_impl.get()); | 993 child->PushPropertiesTo(child_impl.get()); |
994 child2->PushPropertiesTo(child2_impl.get()); | 994 child2->PushPropertiesTo(child2_impl.get()); |
995 grand_child->PushPropertiesTo(grand_child_impl.get()); | 995 grand_child->PushPropertiesTo(grand_child_impl.get()); |
996 dummy_layer1->PushPropertiesTo(dummy_layer1_impl.get())); | 996 dummy_layer1->PushPropertiesTo(dummy_layer1_impl.get())); |
(...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1673 | 1673 |
1674 // The above tests should not have caused a change to the needs_display flag. | 1674 // The above tests should not have caused a change to the needs_display flag. |
1675 EXPECT_FALSE(test_layer->NeedsDisplayForTesting()); | 1675 EXPECT_FALSE(test_layer->NeedsDisplayForTesting()); |
1676 | 1676 |
1677 // As layers are removed from the tree, they will cause a tree sync. | 1677 // As layers are removed from the tree, they will cause a tree sync. |
1678 EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times((AnyNumber())); | 1678 EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times((AnyNumber())); |
1679 } | 1679 } |
1680 | 1680 |
1681 TEST_F(LayerTest, PushPropertiesAccumulatesUpdateRect) { | 1681 TEST_F(LayerTest, PushPropertiesAccumulatesUpdateRect) { |
1682 scoped_refptr<Layer> test_layer = Layer::Create(); | 1682 scoped_refptr<Layer> test_layer = Layer::Create(); |
1683 scoped_ptr<LayerImpl> impl_layer = | 1683 std::unique_ptr<LayerImpl> impl_layer = |
1684 LayerImpl::Create(host_impl_.active_tree(), 1); | 1684 LayerImpl::Create(host_impl_.active_tree(), 1); |
1685 | 1685 |
1686 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, | 1686 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, |
1687 layer_tree_host_->SetRootLayer(test_layer)); | 1687 layer_tree_host_->SetRootLayer(test_layer)); |
1688 | 1688 |
1689 host_impl_.active_tree()->SetRootLayer(std::move(impl_layer)); | 1689 host_impl_.active_tree()->SetRootLayer(std::move(impl_layer)); |
1690 LayerImpl* impl_layer_ptr = host_impl_.active_tree()->LayerById(1); | 1690 LayerImpl* impl_layer_ptr = host_impl_.active_tree()->LayerById(1); |
1691 test_layer->SetNeedsDisplayRect(gfx::Rect(5, 5)); | 1691 test_layer->SetNeedsDisplayRect(gfx::Rect(5, 5)); |
1692 test_layer->PushPropertiesTo(impl_layer_ptr); | 1692 test_layer->PushPropertiesTo(impl_layer_ptr); |
1693 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0.f, 0.f, 5.f, 5.f), | 1693 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0.f, 0.f, 5.f, 5.f), |
(...skipping 11 matching lines...) Expand all Loading... |
1705 host_impl_.active_tree()->ResetAllChangeTracking( | 1705 host_impl_.active_tree()->ResetAllChangeTracking( |
1706 PropertyTrees::ResetFlags::ALL_TREES); | 1706 PropertyTrees::ResetFlags::ALL_TREES); |
1707 test_layer->SetNeedsDisplayRect(gfx::Rect(10, 10, 5, 5)); | 1707 test_layer->SetNeedsDisplayRect(gfx::Rect(10, 10, 5, 5)); |
1708 test_layer->PushPropertiesTo(impl_layer_ptr); | 1708 test_layer->PushPropertiesTo(impl_layer_ptr); |
1709 EXPECT_FLOAT_RECT_EQ(gfx::RectF(10.f, 10.f, 5.f, 5.f), | 1709 EXPECT_FLOAT_RECT_EQ(gfx::RectF(10.f, 10.f, 5.f, 5.f), |
1710 impl_layer_ptr->update_rect()); | 1710 impl_layer_ptr->update_rect()); |
1711 } | 1711 } |
1712 | 1712 |
1713 TEST_F(LayerTest, PushPropertiesCausesLayerPropertyChangedForTransform) { | 1713 TEST_F(LayerTest, PushPropertiesCausesLayerPropertyChangedForTransform) { |
1714 scoped_refptr<Layer> test_layer = Layer::Create(); | 1714 scoped_refptr<Layer> test_layer = Layer::Create(); |
1715 scoped_ptr<LayerImpl> impl_layer = | 1715 std::unique_ptr<LayerImpl> impl_layer = |
1716 LayerImpl::Create(host_impl_.active_tree(), 1); | 1716 LayerImpl::Create(host_impl_.active_tree(), 1); |
1717 | 1717 |
1718 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, | 1718 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, |
1719 layer_tree_host_->SetRootLayer(test_layer)); | 1719 layer_tree_host_->SetRootLayer(test_layer)); |
1720 | 1720 |
1721 gfx::Transform transform; | 1721 gfx::Transform transform; |
1722 transform.Rotate(45.0); | 1722 transform.Rotate(45.0); |
1723 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetTransform(transform)); | 1723 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetTransform(transform)); |
1724 | 1724 |
1725 EXPECT_FALSE(impl_layer->LayerPropertyChanged()); | 1725 EXPECT_FALSE(impl_layer->LayerPropertyChanged()); |
1726 | 1726 |
1727 test_layer->PushPropertiesTo(impl_layer.get()); | 1727 test_layer->PushPropertiesTo(impl_layer.get()); |
1728 | 1728 |
1729 EXPECT_TRUE(impl_layer->LayerPropertyChanged()); | 1729 EXPECT_TRUE(impl_layer->LayerPropertyChanged()); |
1730 } | 1730 } |
1731 | 1731 |
1732 TEST_F(LayerTest, PushPropertiesCausesLayerPropertyChangedForOpacity) { | 1732 TEST_F(LayerTest, PushPropertiesCausesLayerPropertyChangedForOpacity) { |
1733 scoped_refptr<Layer> test_layer = Layer::Create(); | 1733 scoped_refptr<Layer> test_layer = Layer::Create(); |
1734 scoped_ptr<LayerImpl> impl_layer = | 1734 std::unique_ptr<LayerImpl> impl_layer = |
1735 LayerImpl::Create(host_impl_.active_tree(), 1); | 1735 LayerImpl::Create(host_impl_.active_tree(), 1); |
1736 | 1736 |
1737 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, | 1737 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, |
1738 layer_tree_host_->SetRootLayer(test_layer)); | 1738 layer_tree_host_->SetRootLayer(test_layer)); |
1739 | 1739 |
1740 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetOpacity(0.5f)); | 1740 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetOpacity(0.5f)); |
1741 | 1741 |
1742 EXPECT_FALSE(impl_layer->LayerPropertyChanged()); | 1742 EXPECT_FALSE(impl_layer->LayerPropertyChanged()); |
1743 | 1743 |
1744 test_layer->PushPropertiesTo(impl_layer.get()); | 1744 test_layer->PushPropertiesTo(impl_layer.get()); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1776 | 1776 |
1777 child->SetReplicaLayer(replica_replacement.get()); | 1777 child->SetReplicaLayer(replica_replacement.get()); |
1778 EXPECT_EQ(nullptr, replica->parent()); | 1778 EXPECT_EQ(nullptr, replica->parent()); |
1779 EXPECT_EQ(child.get(), replica_replacement->parent()); | 1779 EXPECT_EQ(child.get(), replica_replacement->parent()); |
1780 | 1780 |
1781 EXPECT_EQ(replica.get(), replica->mask_layer()->parent()); | 1781 EXPECT_EQ(replica.get(), replica->mask_layer()->parent()); |
1782 } | 1782 } |
1783 | 1783 |
1784 TEST_F(LayerTest, CheckTransformIsInvertible) { | 1784 TEST_F(LayerTest, CheckTransformIsInvertible) { |
1785 scoped_refptr<Layer> layer = Layer::Create(); | 1785 scoped_refptr<Layer> layer = Layer::Create(); |
1786 scoped_ptr<LayerImpl> impl_layer = | 1786 std::unique_ptr<LayerImpl> impl_layer = |
1787 LayerImpl::Create(host_impl_.active_tree(), 1); | 1787 LayerImpl::Create(host_impl_.active_tree(), 1); |
1788 EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times(1); | 1788 EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times(1); |
1789 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber()); | 1789 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber()); |
1790 layer_tree_host_->SetRootLayer(layer); | 1790 layer_tree_host_->SetRootLayer(layer); |
1791 | 1791 |
1792 EXPECT_TRUE(layer->transform_is_invertible()); | 1792 EXPECT_TRUE(layer->transform_is_invertible()); |
1793 | 1793 |
1794 gfx::Transform singular_transform; | 1794 gfx::Transform singular_transform; |
1795 singular_transform.Scale3d( | 1795 singular_transform.Scale3d( |
1796 SkDoubleToMScalar(1.0), SkDoubleToMScalar(1.0), SkDoubleToMScalar(0.0)); | 1796 SkDoubleToMScalar(1.0), SkDoubleToMScalar(1.0), SkDoubleToMScalar(0.0)); |
(...skipping 10 matching lines...) Expand all Loading... |
1807 layer->SetTransform(rotation_transform); | 1807 layer->SetTransform(rotation_transform); |
1808 layer->PushPropertiesTo(impl_layer.get()); | 1808 layer->PushPropertiesTo(impl_layer.get()); |
1809 EXPECT_TRUE(layer->transform_is_invertible()); | 1809 EXPECT_TRUE(layer->transform_is_invertible()); |
1810 EXPECT_TRUE(impl_layer->transform_is_invertible()); | 1810 EXPECT_TRUE(impl_layer->transform_is_invertible()); |
1811 | 1811 |
1812 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 1812 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
1813 } | 1813 } |
1814 | 1814 |
1815 TEST_F(LayerTest, TransformIsInvertibleAnimation) { | 1815 TEST_F(LayerTest, TransformIsInvertibleAnimation) { |
1816 scoped_refptr<Layer> layer = Layer::Create(); | 1816 scoped_refptr<Layer> layer = Layer::Create(); |
1817 scoped_ptr<LayerImpl> impl_layer = | 1817 std::unique_ptr<LayerImpl> impl_layer = |
1818 LayerImpl::Create(host_impl_.active_tree(), 1); | 1818 LayerImpl::Create(host_impl_.active_tree(), 1); |
1819 EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times(1); | 1819 EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times(1); |
1820 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber()); | 1820 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber()); |
1821 layer_tree_host_->SetRootLayer(layer); | 1821 layer_tree_host_->SetRootLayer(layer); |
1822 | 1822 |
1823 EXPECT_TRUE(layer->transform_is_invertible()); | 1823 EXPECT_TRUE(layer->transform_is_invertible()); |
1824 | 1824 |
1825 gfx::Transform singular_transform; | 1825 gfx::Transform singular_transform; |
1826 singular_transform.Scale3d( | 1826 singular_transform.Scale3d( |
1827 SkDoubleToMScalar(1.0), SkDoubleToMScalar(1.0), SkDoubleToMScalar(0.0)); | 1827 SkDoubleToMScalar(1.0), SkDoubleToMScalar(1.0), SkDoubleToMScalar(0.0)); |
(...skipping 13 matching lines...) Expand all Loading... |
1841 EXPECT_FALSE(layer->transform_is_invertible()); | 1841 EXPECT_FALSE(layer->transform_is_invertible()); |
1842 EXPECT_FALSE(impl_layer->transform_is_invertible()); | 1842 EXPECT_FALSE(impl_layer->transform_is_invertible()); |
1843 | 1843 |
1844 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 1844 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
1845 } | 1845 } |
1846 | 1846 |
1847 class LayerTreeHostFactory { | 1847 class LayerTreeHostFactory { |
1848 public: | 1848 public: |
1849 LayerTreeHostFactory() : client_(FakeLayerTreeHostClient::DIRECT_3D) {} | 1849 LayerTreeHostFactory() : client_(FakeLayerTreeHostClient::DIRECT_3D) {} |
1850 | 1850 |
1851 scoped_ptr<LayerTreeHost> Create() { return Create(LayerTreeSettings()); } | 1851 std::unique_ptr<LayerTreeHost> Create() { |
| 1852 return Create(LayerTreeSettings()); |
| 1853 } |
1852 | 1854 |
1853 scoped_ptr<LayerTreeHost> Create(LayerTreeSettings settings) { | 1855 std::unique_ptr<LayerTreeHost> Create(LayerTreeSettings settings) { |
1854 LayerTreeHost::InitParams params; | 1856 LayerTreeHost::InitParams params; |
1855 params.client = &client_; | 1857 params.client = &client_; |
1856 params.shared_bitmap_manager = &shared_bitmap_manager_; | 1858 params.shared_bitmap_manager = &shared_bitmap_manager_; |
1857 params.task_graph_runner = &task_graph_runner_; | 1859 params.task_graph_runner = &task_graph_runner_; |
1858 params.gpu_memory_buffer_manager = &gpu_memory_buffer_manager_; | 1860 params.gpu_memory_buffer_manager = &gpu_memory_buffer_manager_; |
1859 params.settings = &settings; | 1861 params.settings = &settings; |
1860 params.main_task_runner = base::ThreadTaskRunnerHandle::Get(); | 1862 params.main_task_runner = base::ThreadTaskRunnerHandle::Get(); |
1861 return LayerTreeHost::CreateSingleThreaded(&client_, ¶ms); | 1863 return LayerTreeHost::CreateSingleThreaded(&client_, ¶ms); |
1862 } | 1864 } |
1863 | 1865 |
(...skipping 29 matching lines...) Expand all Loading... |
1893 // Set up a detached tree of layers. The host pointer should be nil for these | 1895 // Set up a detached tree of layers. The host pointer should be nil for these |
1894 // layers. | 1896 // layers. |
1895 parent->AddChild(child); | 1897 parent->AddChild(child); |
1896 child->SetMaskLayer(mask.get()); | 1898 child->SetMaskLayer(mask.get()); |
1897 child->SetReplicaLayer(replica.get()); | 1899 child->SetReplicaLayer(replica.get()); |
1898 replica->SetMaskLayer(replica_mask.get()); | 1900 replica->SetMaskLayer(replica_mask.get()); |
1899 | 1901 |
1900 AssertLayerTreeHostMatchesForSubtree(parent.get(), nullptr); | 1902 AssertLayerTreeHostMatchesForSubtree(parent.get(), nullptr); |
1901 | 1903 |
1902 LayerTreeHostFactory factory; | 1904 LayerTreeHostFactory factory; |
1903 scoped_ptr<LayerTreeHost> layer_tree_host = factory.Create(); | 1905 std::unique_ptr<LayerTreeHost> layer_tree_host = factory.Create(); |
1904 // Setting the root layer should set the host pointer for all layers in the | 1906 // Setting the root layer should set the host pointer for all layers in the |
1905 // tree. | 1907 // tree. |
1906 layer_tree_host->SetRootLayer(parent.get()); | 1908 layer_tree_host->SetRootLayer(parent.get()); |
1907 | 1909 |
1908 AssertLayerTreeHostMatchesForSubtree(parent.get(), layer_tree_host.get()); | 1910 AssertLayerTreeHostMatchesForSubtree(parent.get(), layer_tree_host.get()); |
1909 | 1911 |
1910 // Clearing the root layer should also clear out the host pointers for all | 1912 // Clearing the root layer should also clear out the host pointers for all |
1911 // layers in the tree. | 1913 // layers in the tree. |
1912 layer_tree_host->SetRootLayer(nullptr); | 1914 layer_tree_host->SetRootLayer(nullptr); |
1913 | 1915 |
1914 AssertLayerTreeHostMatchesForSubtree(parent.get(), nullptr); | 1916 AssertLayerTreeHostMatchesForSubtree(parent.get(), nullptr); |
1915 } | 1917 } |
1916 | 1918 |
1917 TEST_F(LayerLayerTreeHostTest, AddingLayerSubtree) { | 1919 TEST_F(LayerLayerTreeHostTest, AddingLayerSubtree) { |
1918 scoped_refptr<Layer> parent = Layer::Create(); | 1920 scoped_refptr<Layer> parent = Layer::Create(); |
1919 LayerTreeHostFactory factory; | 1921 LayerTreeHostFactory factory; |
1920 scoped_ptr<LayerTreeHost> layer_tree_host = factory.Create(); | 1922 std::unique_ptr<LayerTreeHost> layer_tree_host = factory.Create(); |
1921 | 1923 |
1922 layer_tree_host->SetRootLayer(parent.get()); | 1924 layer_tree_host->SetRootLayer(parent.get()); |
1923 | 1925 |
1924 EXPECT_EQ(parent->layer_tree_host(), layer_tree_host.get()); | 1926 EXPECT_EQ(parent->layer_tree_host(), layer_tree_host.get()); |
1925 | 1927 |
1926 // Adding a subtree to a layer already associated with a host should set the | 1928 // Adding a subtree to a layer already associated with a host should set the |
1927 // host pointer on all layers in that subtree. | 1929 // host pointer on all layers in that subtree. |
1928 scoped_refptr<Layer> child = Layer::Create(); | 1930 scoped_refptr<Layer> child = Layer::Create(); |
1929 scoped_refptr<Layer> grand_child = Layer::Create(); | 1931 scoped_refptr<Layer> grand_child = Layer::Create(); |
1930 child->AddChild(grand_child); | 1932 child->AddChild(grand_child); |
(...skipping 19 matching lines...) Expand all Loading... |
1950 scoped_refptr<Layer> replica = Layer::Create(); | 1952 scoped_refptr<Layer> replica = Layer::Create(); |
1951 scoped_refptr<Layer> replica_mask = Layer::Create(); | 1953 scoped_refptr<Layer> replica_mask = Layer::Create(); |
1952 | 1954 |
1953 // Same setup as the previous test. | 1955 // Same setup as the previous test. |
1954 parent->AddChild(child); | 1956 parent->AddChild(child); |
1955 child->SetMaskLayer(mask.get()); | 1957 child->SetMaskLayer(mask.get()); |
1956 child->SetReplicaLayer(replica.get()); | 1958 child->SetReplicaLayer(replica.get()); |
1957 replica->SetMaskLayer(replica_mask.get()); | 1959 replica->SetMaskLayer(replica_mask.get()); |
1958 | 1960 |
1959 LayerTreeHostFactory factory; | 1961 LayerTreeHostFactory factory; |
1960 scoped_ptr<LayerTreeHost> first_layer_tree_host = factory.Create(); | 1962 std::unique_ptr<LayerTreeHost> first_layer_tree_host = factory.Create(); |
1961 first_layer_tree_host->SetRootLayer(parent.get()); | 1963 first_layer_tree_host->SetRootLayer(parent.get()); |
1962 | 1964 |
1963 AssertLayerTreeHostMatchesForSubtree(parent.get(), | 1965 AssertLayerTreeHostMatchesForSubtree(parent.get(), |
1964 first_layer_tree_host.get()); | 1966 first_layer_tree_host.get()); |
1965 | 1967 |
1966 // Now re-root the tree to a new host (simulating what we do on a context lost | 1968 // Now re-root the tree to a new host (simulating what we do on a context lost |
1967 // event). This should update the host pointers for all layers in the tree. | 1969 // event). This should update the host pointers for all layers in the tree. |
1968 scoped_ptr<LayerTreeHost> second_layer_tree_host = factory.Create(); | 1970 std::unique_ptr<LayerTreeHost> second_layer_tree_host = factory.Create(); |
1969 second_layer_tree_host->SetRootLayer(parent.get()); | 1971 second_layer_tree_host->SetRootLayer(parent.get()); |
1970 | 1972 |
1971 AssertLayerTreeHostMatchesForSubtree(parent.get(), | 1973 AssertLayerTreeHostMatchesForSubtree(parent.get(), |
1972 second_layer_tree_host.get()); | 1974 second_layer_tree_host.get()); |
1973 | 1975 |
1974 second_layer_tree_host->SetRootLayer(nullptr); | 1976 second_layer_tree_host->SetRootLayer(nullptr); |
1975 } | 1977 } |
1976 | 1978 |
1977 TEST_F(LayerLayerTreeHostTest, ChangeHostInSubtree) { | 1979 TEST_F(LayerLayerTreeHostTest, ChangeHostInSubtree) { |
1978 scoped_refptr<Layer> first_parent = Layer::Create(); | 1980 scoped_refptr<Layer> first_parent = Layer::Create(); |
1979 scoped_refptr<Layer> first_child = Layer::Create(); | 1981 scoped_refptr<Layer> first_child = Layer::Create(); |
1980 scoped_refptr<Layer> second_parent = Layer::Create(); | 1982 scoped_refptr<Layer> second_parent = Layer::Create(); |
1981 scoped_refptr<Layer> second_child = Layer::Create(); | 1983 scoped_refptr<Layer> second_child = Layer::Create(); |
1982 scoped_refptr<Layer> second_grand_child = Layer::Create(); | 1984 scoped_refptr<Layer> second_grand_child = Layer::Create(); |
1983 | 1985 |
1984 // First put all children under the first parent and set the first host. | 1986 // First put all children under the first parent and set the first host. |
1985 first_parent->AddChild(first_child); | 1987 first_parent->AddChild(first_child); |
1986 second_child->AddChild(second_grand_child); | 1988 second_child->AddChild(second_grand_child); |
1987 first_parent->AddChild(second_child); | 1989 first_parent->AddChild(second_child); |
1988 | 1990 |
1989 LayerTreeHostFactory factory; | 1991 LayerTreeHostFactory factory; |
1990 scoped_ptr<LayerTreeHost> first_layer_tree_host = factory.Create(); | 1992 std::unique_ptr<LayerTreeHost> first_layer_tree_host = factory.Create(); |
1991 first_layer_tree_host->SetRootLayer(first_parent.get()); | 1993 first_layer_tree_host->SetRootLayer(first_parent.get()); |
1992 | 1994 |
1993 AssertLayerTreeHostMatchesForSubtree(first_parent.get(), | 1995 AssertLayerTreeHostMatchesForSubtree(first_parent.get(), |
1994 first_layer_tree_host.get()); | 1996 first_layer_tree_host.get()); |
1995 | 1997 |
1996 // Now reparent the subtree starting at second_child to a layer in a different | 1998 // Now reparent the subtree starting at second_child to a layer in a different |
1997 // tree. | 1999 // tree. |
1998 scoped_ptr<LayerTreeHost> second_layer_tree_host = factory.Create(); | 2000 std::unique_ptr<LayerTreeHost> second_layer_tree_host = factory.Create(); |
1999 second_layer_tree_host->SetRootLayer(second_parent.get()); | 2001 second_layer_tree_host->SetRootLayer(second_parent.get()); |
2000 | 2002 |
2001 second_parent->AddChild(second_child); | 2003 second_parent->AddChild(second_child); |
2002 | 2004 |
2003 // The moved layer and its children should point to the new host. | 2005 // The moved layer and its children should point to the new host. |
2004 EXPECT_EQ(second_layer_tree_host.get(), second_child->layer_tree_host()); | 2006 EXPECT_EQ(second_layer_tree_host.get(), second_child->layer_tree_host()); |
2005 EXPECT_EQ(second_layer_tree_host.get(), | 2007 EXPECT_EQ(second_layer_tree_host.get(), |
2006 second_grand_child->layer_tree_host()); | 2008 second_grand_child->layer_tree_host()); |
2007 | 2009 |
2008 // Test over, cleanup time. | 2010 // Test over, cleanup time. |
2009 first_layer_tree_host->SetRootLayer(nullptr); | 2011 first_layer_tree_host->SetRootLayer(nullptr); |
2010 second_layer_tree_host->SetRootLayer(nullptr); | 2012 second_layer_tree_host->SetRootLayer(nullptr); |
2011 } | 2013 } |
2012 | 2014 |
2013 TEST_F(LayerLayerTreeHostTest, ReplaceMaskAndReplicaLayer) { | 2015 TEST_F(LayerLayerTreeHostTest, ReplaceMaskAndReplicaLayer) { |
2014 scoped_refptr<Layer> parent = Layer::Create(); | 2016 scoped_refptr<Layer> parent = Layer::Create(); |
2015 scoped_refptr<Layer> mask = Layer::Create(); | 2017 scoped_refptr<Layer> mask = Layer::Create(); |
2016 scoped_refptr<Layer> replica = Layer::Create(); | 2018 scoped_refptr<Layer> replica = Layer::Create(); |
2017 scoped_refptr<Layer> mask_child = Layer::Create(); | 2019 scoped_refptr<Layer> mask_child = Layer::Create(); |
2018 scoped_refptr<Layer> replica_child = Layer::Create(); | 2020 scoped_refptr<Layer> replica_child = Layer::Create(); |
2019 scoped_refptr<Layer> mask_replacement = Layer::Create(); | 2021 scoped_refptr<Layer> mask_replacement = Layer::Create(); |
2020 scoped_refptr<Layer> replica_replacement = Layer::Create(); | 2022 scoped_refptr<Layer> replica_replacement = Layer::Create(); |
2021 | 2023 |
2022 parent->SetMaskLayer(mask.get()); | 2024 parent->SetMaskLayer(mask.get()); |
2023 parent->SetReplicaLayer(replica.get()); | 2025 parent->SetReplicaLayer(replica.get()); |
2024 mask->AddChild(mask_child); | 2026 mask->AddChild(mask_child); |
2025 replica->AddChild(replica_child); | 2027 replica->AddChild(replica_child); |
2026 | 2028 |
2027 LayerTreeHostFactory factory; | 2029 LayerTreeHostFactory factory; |
2028 scoped_ptr<LayerTreeHost> layer_tree_host = factory.Create(); | 2030 std::unique_ptr<LayerTreeHost> layer_tree_host = factory.Create(); |
2029 layer_tree_host->SetRootLayer(parent.get()); | 2031 layer_tree_host->SetRootLayer(parent.get()); |
2030 | 2032 |
2031 AssertLayerTreeHostMatchesForSubtree(parent.get(), layer_tree_host.get()); | 2033 AssertLayerTreeHostMatchesForSubtree(parent.get(), layer_tree_host.get()); |
2032 | 2034 |
2033 // Replacing the mask should clear out the old mask's subtree's host pointers. | 2035 // Replacing the mask should clear out the old mask's subtree's host pointers. |
2034 parent->SetMaskLayer(mask_replacement.get()); | 2036 parent->SetMaskLayer(mask_replacement.get()); |
2035 EXPECT_EQ(nullptr, mask->layer_tree_host()); | 2037 EXPECT_EQ(nullptr, mask->layer_tree_host()); |
2036 EXPECT_EQ(nullptr, mask_child->layer_tree_host()); | 2038 EXPECT_EQ(nullptr, mask_child->layer_tree_host()); |
2037 | 2039 |
2038 // Same for replacing a replica layer. | 2040 // Same for replacing a replica layer. |
2039 parent->SetReplicaLayer(replica_replacement.get()); | 2041 parent->SetReplicaLayer(replica_replacement.get()); |
2040 EXPECT_EQ(nullptr, replica->layer_tree_host()); | 2042 EXPECT_EQ(nullptr, replica->layer_tree_host()); |
2041 EXPECT_EQ(nullptr, replica_child->layer_tree_host()); | 2043 EXPECT_EQ(nullptr, replica_child->layer_tree_host()); |
2042 | 2044 |
2043 // Test over, cleanup time. | 2045 // Test over, cleanup time. |
2044 layer_tree_host->SetRootLayer(nullptr); | 2046 layer_tree_host->SetRootLayer(nullptr); |
2045 } | 2047 } |
2046 | 2048 |
2047 TEST_F(LayerLayerTreeHostTest, DestroyHostWithNonNullRootLayer) { | 2049 TEST_F(LayerLayerTreeHostTest, DestroyHostWithNonNullRootLayer) { |
2048 scoped_refptr<Layer> root = Layer::Create(); | 2050 scoped_refptr<Layer> root = Layer::Create(); |
2049 scoped_refptr<Layer> child = Layer::Create(); | 2051 scoped_refptr<Layer> child = Layer::Create(); |
2050 root->AddChild(child); | 2052 root->AddChild(child); |
2051 LayerTreeHostFactory factory; | 2053 LayerTreeHostFactory factory; |
2052 scoped_ptr<LayerTreeHost> layer_tree_host = factory.Create(); | 2054 std::unique_ptr<LayerTreeHost> layer_tree_host = factory.Create(); |
2053 layer_tree_host->SetRootLayer(root); | 2055 layer_tree_host->SetRootLayer(root); |
2054 } | 2056 } |
2055 | 2057 |
2056 TEST_F(LayerTest, SafeOpaqueBackgroundColor) { | 2058 TEST_F(LayerTest, SafeOpaqueBackgroundColor) { |
2057 LayerTreeHostFactory factory; | 2059 LayerTreeHostFactory factory; |
2058 scoped_ptr<LayerTreeHost> layer_tree_host = factory.Create(); | 2060 std::unique_ptr<LayerTreeHost> layer_tree_host = factory.Create(); |
2059 | 2061 |
2060 scoped_refptr<Layer> layer = Layer::Create(); | 2062 scoped_refptr<Layer> layer = Layer::Create(); |
2061 layer_tree_host->SetRootLayer(layer); | 2063 layer_tree_host->SetRootLayer(layer); |
2062 | 2064 |
2063 for (int contents_opaque = 0; contents_opaque < 2; ++contents_opaque) { | 2065 for (int contents_opaque = 0; contents_opaque < 2; ++contents_opaque) { |
2064 for (int layer_opaque = 0; layer_opaque < 2; ++layer_opaque) { | 2066 for (int layer_opaque = 0; layer_opaque < 2; ++layer_opaque) { |
2065 for (int host_opaque = 0; host_opaque < 2; ++host_opaque) { | 2067 for (int host_opaque = 0; host_opaque < 2; ++host_opaque) { |
2066 layer->SetContentsOpaque(!!contents_opaque); | 2068 layer->SetContentsOpaque(!!contents_opaque); |
2067 layer->SetBackgroundColor(layer_opaque ? SK_ColorRED | 2069 layer->SetBackgroundColor(layer_opaque ? SK_ColorRED |
2068 : SK_ColorTRANSPARENT); | 2070 : SK_ColorTRANSPARENT); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2125 EXPECT_EQ(0, root_layer->NumDescendantsThatDrawContent()); | 2127 EXPECT_EQ(0, root_layer->NumDescendantsThatDrawContent()); |
2126 root_layer->AddChild(becomes_not_draws_content); | 2128 root_layer->AddChild(becomes_not_draws_content); |
2127 EXPECT_EQ(0, root_layer->NumDescendantsThatDrawContent()); | 2129 EXPECT_EQ(0, root_layer->NumDescendantsThatDrawContent()); |
2128 | 2130 |
2129 becomes_draws_content->SetIsDrawable(true); | 2131 becomes_draws_content->SetIsDrawable(true); |
2130 root_layer->AddChild(becomes_draws_content); | 2132 root_layer->AddChild(becomes_draws_content); |
2131 EXPECT_EQ(1, root_layer->NumDescendantsThatDrawContent()); | 2133 EXPECT_EQ(1, root_layer->NumDescendantsThatDrawContent()); |
2132 } | 2134 } |
2133 | 2135 |
2134 void ReceiveCopyOutputResult(int* result_count, | 2136 void ReceiveCopyOutputResult(int* result_count, |
2135 scoped_ptr<CopyOutputResult> result) { | 2137 std::unique_ptr<CopyOutputResult> result) { |
2136 ++(*result_count); | 2138 ++(*result_count); |
2137 } | 2139 } |
2138 | 2140 |
2139 TEST_F(LayerTest, DedupesCopyOutputRequestsBySource) { | 2141 TEST_F(LayerTest, DedupesCopyOutputRequestsBySource) { |
2140 scoped_refptr<Layer> layer = Layer::Create(); | 2142 scoped_refptr<Layer> layer = Layer::Create(); |
2141 int result_count = 0; | 2143 int result_count = 0; |
2142 | 2144 |
2143 // Create identical requests without the source being set, and expect the | 2145 // Create identical requests without the source being set, and expect the |
2144 // layer does not abort either one. | 2146 // layer does not abort either one. |
2145 scoped_ptr<CopyOutputRequest> request = CopyOutputRequest::CreateRequest( | 2147 std::unique_ptr<CopyOutputRequest> request = CopyOutputRequest::CreateRequest( |
2146 base::Bind(&ReceiveCopyOutputResult, &result_count)); | 2148 base::Bind(&ReceiveCopyOutputResult, &result_count)); |
2147 layer->RequestCopyOfOutput(std::move(request)); | 2149 layer->RequestCopyOfOutput(std::move(request)); |
2148 EXPECT_EQ(0, result_count); | 2150 EXPECT_EQ(0, result_count); |
2149 request = CopyOutputRequest::CreateRequest( | 2151 request = CopyOutputRequest::CreateRequest( |
2150 base::Bind(&ReceiveCopyOutputResult, &result_count)); | 2152 base::Bind(&ReceiveCopyOutputResult, &result_count)); |
2151 layer->RequestCopyOfOutput(std::move(request)); | 2153 layer->RequestCopyOfOutput(std::move(request)); |
2152 EXPECT_EQ(0, result_count); | 2154 EXPECT_EQ(0, result_count); |
2153 | 2155 |
2154 // When the layer is destroyed, expect both requests to be aborted. | 2156 // When the layer is destroyed, expect both requests to be aborted. |
2155 layer = nullptr; | 2157 layer = nullptr; |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2488 TEST_F(LayerSerializationTest, AllMembersChanged) { | 2490 TEST_F(LayerSerializationTest, AllMembersChanged) { |
2489 RunAllMembersChangedTest(); | 2491 RunAllMembersChangedTest(); |
2490 } | 2492 } |
2491 | 2493 |
2492 TEST_F(LayerSerializationTest, ScrollAndClipLayers) { | 2494 TEST_F(LayerSerializationTest, ScrollAndClipLayers) { |
2493 RunScrollAndClipLayersTest(); | 2495 RunScrollAndClipLayersTest(); |
2494 } | 2496 } |
2495 | 2497 |
2496 TEST_F(LayerTest, ElementIdAndMutablePropertiesArePushed) { | 2498 TEST_F(LayerTest, ElementIdAndMutablePropertiesArePushed) { |
2497 scoped_refptr<Layer> test_layer = Layer::Create(); | 2499 scoped_refptr<Layer> test_layer = Layer::Create(); |
2498 scoped_ptr<LayerImpl> impl_layer = | 2500 std::unique_ptr<LayerImpl> impl_layer = |
2499 LayerImpl::Create(host_impl_.active_tree(), 1); | 2501 LayerImpl::Create(host_impl_.active_tree(), 1); |
2500 | 2502 |
2501 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, | 2503 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, |
2502 layer_tree_host_->SetRootLayer(test_layer)); | 2504 layer_tree_host_->SetRootLayer(test_layer)); |
2503 | 2505 |
2504 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(2); | 2506 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(2); |
2505 | 2507 |
2506 test_layer->SetElementId(2); | 2508 test_layer->SetElementId(2); |
2507 test_layer->SetMutableProperties(MutableProperty::kTransform); | 2509 test_layer->SetMutableProperties(MutableProperty::kTransform); |
2508 | 2510 |
2509 EXPECT_EQ(0lu, impl_layer->element_id()); | 2511 EXPECT_EQ(0lu, impl_layer->element_id()); |
2510 EXPECT_EQ(MutableProperty::kNone, impl_layer->mutable_properties()); | 2512 EXPECT_EQ(MutableProperty::kNone, impl_layer->mutable_properties()); |
2511 | 2513 |
2512 test_layer->PushPropertiesTo(impl_layer.get()); | 2514 test_layer->PushPropertiesTo(impl_layer.get()); |
2513 | 2515 |
2514 EXPECT_EQ(2lu, impl_layer->element_id()); | 2516 EXPECT_EQ(2lu, impl_layer->element_id()); |
2515 EXPECT_EQ(MutableProperty::kTransform, impl_layer->mutable_properties()); | 2517 EXPECT_EQ(MutableProperty::kTransform, impl_layer->mutable_properties()); |
2516 } | 2518 } |
2517 | 2519 |
2518 } // namespace | 2520 } // namespace |
2519 } // namespace cc | 2521 } // namespace cc |
OLD | NEW |