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 <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 | 145 |
146 TEST_F(LayerTreeHostCommonTest, DoNotSkipLayersWithHandlers) { | 146 TEST_F(LayerTreeHostCommonTest, DoNotSkipLayersWithHandlers) { |
147 LayerImpl* parent = root_layer(); | 147 LayerImpl* parent = root_layer(); |
148 LayerImpl* child = AddChild<LayerImpl>(parent); | 148 LayerImpl* child = AddChild<LayerImpl>(parent); |
149 LayerImpl* grand_child = AddChild<LayerImpl>(child); | 149 LayerImpl* grand_child = AddChild<LayerImpl>(child); |
150 child->SetDrawsContent(true); | 150 child->SetDrawsContent(true); |
151 grand_child->SetDrawsContent(true); | 151 grand_child->SetDrawsContent(true); |
152 | 152 |
153 gfx::Transform identity_matrix; | 153 gfx::Transform identity_matrix; |
154 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(), | 154 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(), |
155 gfx::PointF(), gfx::Size(100, 100), true, false); | 155 gfx::PointF(), gfx::Size(100, 100), true, false, |
| 156 true); |
156 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(), | 157 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(), |
157 gfx::PointF(10, 10), gfx::Size(100, 100), true, | 158 gfx::PointF(10, 10), gfx::Size(100, 100), true, |
158 false); | 159 false, false); |
159 // This would have previously caused us to skip our subtree, but this would be | 160 // This would have previously caused us to skip our subtree, but this would be |
160 // wrong; we need up-to-date draw properties to do hit testing on the layers | 161 // wrong; we need up-to-date draw properties to do hit testing on the layers |
161 // with handlers. | 162 // with handlers. |
162 child->SetOpacity(0.f); | 163 child->SetOpacity(0.f); |
163 SetLayerPropertiesForTesting(grand_child, identity_matrix, gfx::Point3F(), | 164 SetLayerPropertiesForTesting(grand_child, identity_matrix, gfx::Point3F(), |
164 gfx::PointF(10, 10), gfx::Size(100, 100), true, | 165 gfx::PointF(10, 10), gfx::Size(100, 100), true, |
165 false); | 166 false, false); |
166 grand_child->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 100, 100)); | 167 grand_child->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 100, 100)); |
167 | 168 |
168 ExecuteCalculateDrawProperties(parent); | 169 ExecuteCalculateDrawProperties(parent); |
169 | 170 |
170 EXPECT_TRUE(child->has_render_surface()); | |
171 EXPECT_FALSE(grand_child->has_render_surface()); | |
172 // Check that we've computed draw properties for the subtree rooted at | 171 // Check that we've computed draw properties for the subtree rooted at |
173 // |child|. | 172 // |child|. |
174 EXPECT_TRUE(child->draw_properties().target_space_transform.IsIdentity()); | 173 EXPECT_FALSE(child->draw_properties().target_space_transform.IsIdentity()); |
175 EXPECT_FALSE(child->render_surface()->draw_transform().IsIdentity()); | |
176 EXPECT_FALSE( | 174 EXPECT_FALSE( |
177 grand_child->draw_properties().target_space_transform.IsIdentity()); | 175 grand_child->draw_properties().target_space_transform.IsIdentity()); |
178 } | 176 } |
179 | 177 |
180 TEST_F(LayerTreeHostCommonTest, TransformsForSingleLayer) { | 178 TEST_F(LayerTreeHostCommonTest, TransformsForSingleLayer) { |
181 gfx::Transform identity_matrix; | 179 gfx::Transform identity_matrix; |
182 scoped_refptr<Layer> layer = Layer::Create(layer_settings()); | 180 scoped_refptr<Layer> layer = Layer::Create(layer_settings()); |
183 | 181 |
184 scoped_refptr<Layer> root = Layer::Create(layer_settings()); | 182 scoped_refptr<Layer> root = Layer::Create(layer_settings()); |
185 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), | 183 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), |
(...skipping 1205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1391 EXPECT_EQ(1.f, root->draw_opacity()); | 1389 EXPECT_EQ(1.f, root->draw_opacity()); |
1392 EXPECT_EQ(1.f, parent->draw_opacity()); | 1390 EXPECT_EQ(1.f, parent->draw_opacity()); |
1393 EXPECT_EQ(0.5f, child1->draw_opacity()); | 1391 EXPECT_EQ(0.5f, child1->draw_opacity()); |
1394 EXPECT_EQ(1.f, child2->draw_opacity()); | 1392 EXPECT_EQ(1.f, child2->draw_opacity()); |
1395 EXPECT_EQ(0.25f, grand_child->draw_opacity()); | 1393 EXPECT_EQ(0.25f, grand_child->draw_opacity()); |
1396 EXPECT_EQ(0.125f, leaf_node1->draw_opacity()); | 1394 EXPECT_EQ(0.125f, leaf_node1->draw_opacity()); |
1397 EXPECT_EQ(0.5f, leaf_node2->draw_opacity()); | 1395 EXPECT_EQ(0.5f, leaf_node2->draw_opacity()); |
1398 } | 1396 } |
1399 | 1397 |
1400 TEST_F(LayerTreeHostCommonTest, ForceRenderSurface) { | 1398 TEST_F(LayerTreeHostCommonTest, ForceRenderSurface) { |
1401 LayerImpl* parent = root_layer(); | 1399 scoped_refptr<Layer> parent = Layer::Create(layer_settings()); |
1402 LayerImpl* render_surface1 = AddChildToRoot<LayerImpl>(); | 1400 scoped_refptr<Layer> render_surface1 = Layer::Create(layer_settings()); |
1403 LayerImpl* child = AddChild<LayerImpl>(render_surface1); | 1401 scoped_refptr<LayerWithForcedDrawsContent> child = |
| 1402 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings())); |
| 1403 render_surface1->SetForceRenderSurface(true); |
| 1404 |
| 1405 host()->SetRootLayer(parent); |
1404 | 1406 |
1405 const gfx::Transform identity_matrix; | 1407 const gfx::Transform identity_matrix; |
1406 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(), | 1408 SetLayerPropertiesForTesting(parent.get(), identity_matrix, gfx::Point3F(), |
1407 gfx::PointF(), gfx::Size(10, 10), true, false); | 1409 gfx::PointF(), gfx::Size(10, 10), true, false); |
1408 SetLayerPropertiesForTesting(render_surface1, identity_matrix, gfx::Point3F(), | 1410 SetLayerPropertiesForTesting(render_surface1.get(), identity_matrix, |
1409 gfx::PointF(), gfx::Size(10, 10), true, false); | 1411 gfx::Point3F(), gfx::PointF(), gfx::Size(10, 10), |
1410 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(), | 1412 true, false); |
| 1413 SetLayerPropertiesForTesting(child.get(), identity_matrix, gfx::Point3F(), |
1411 gfx::PointF(), gfx::Size(10, 10), true, false); | 1414 gfx::PointF(), gfx::Size(10, 10), true, false); |
1412 | 1415 |
1413 child->SetDrawsContent(true); | 1416 parent->AddChild(render_surface1); |
1414 render_surface1->SetForceRenderSurface(true); | 1417 render_surface1->AddChild(child); |
| 1418 |
| 1419 // Sanity check before the actual test |
| 1420 EXPECT_FALSE(parent->has_render_surface()); |
| 1421 EXPECT_FALSE(render_surface1->has_render_surface()); |
1415 | 1422 |
1416 { | 1423 { |
1417 ExecuteCalculateDrawPropertiesWithPropertyTrees(parent); | 1424 LayerTreeHostCommon::CalcDrawPropsMainInputs inputs(parent.get(), |
| 1425 parent->bounds()); |
| 1426 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
1418 | 1427 |
1419 // The root layer always creates a render surface | 1428 // The root layer always creates a render surface |
1420 EXPECT_TRUE(parent->has_render_surface()); | 1429 EXPECT_TRUE(parent->has_render_surface()); |
1421 EXPECT_TRUE(render_surface1->has_render_surface()); | 1430 EXPECT_TRUE(render_surface1->has_render_surface()); |
1422 } | 1431 } |
1423 | 1432 |
1424 { | 1433 { |
1425 render_surface1->SetForceRenderSurface(false); | 1434 render_surface1->SetForceRenderSurface(false); |
1426 render_surface1->layer_tree_impl()->property_trees()->needs_rebuild = true; | 1435 LayerTreeHostCommon::CalcDrawPropsMainInputs inputs(parent.get(), |
1427 ExecuteCalculateDrawPropertiesWithPropertyTrees(parent); | 1436 parent->bounds()); |
| 1437 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
1428 EXPECT_TRUE(parent->has_render_surface()); | 1438 EXPECT_TRUE(parent->has_render_surface()); |
1429 EXPECT_FALSE(render_surface1->has_render_surface()); | 1439 EXPECT_FALSE(render_surface1->has_render_surface()); |
1430 } | 1440 } |
1431 } | 1441 } |
1432 | 1442 |
1433 TEST_F(LayerTreeHostCommonTest, RenderSurfacesFlattenScreenSpaceTransform) { | 1443 TEST_F(LayerTreeHostCommonTest, RenderSurfacesFlattenScreenSpaceTransform) { |
1434 // Render surfaces act as a flattening point for their subtree, so should | 1444 // Render surfaces act as a flattening point for their subtree, so should |
1435 // always flatten the target-to-screen space transform seen by descendants. | 1445 // always flatten the target-to-screen space transform seen by descendants. |
1436 | 1446 |
1437 LayerImpl* root = root_layer(); | 1447 LayerImpl* root = root_layer(); |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1763 true); | 1773 true); |
1764 SetLayerPropertiesForTesting(leaf_node1, identity_matrix, gfx::Point3F(), | 1774 SetLayerPropertiesForTesting(leaf_node1, identity_matrix, gfx::Point3F(), |
1765 gfx::PointF(), gfx::Size(100, 100), true, false, | 1775 gfx::PointF(), gfx::Size(100, 100), true, false, |
1766 false); | 1776 false); |
1767 SetLayerPropertiesForTesting(leaf_node2, identity_matrix, gfx::Point3F(), | 1777 SetLayerPropertiesForTesting(leaf_node2, identity_matrix, gfx::Point3F(), |
1768 gfx::PointF(), gfx::Size(100, 100), true, false, | 1778 gfx::PointF(), gfx::Size(100, 100), true, false, |
1769 false); | 1779 false); |
1770 | 1780 |
1771 // Case 1: Nothing is clipped. In this case, is_clipped is always false, with | 1781 // Case 1: Nothing is clipped. In this case, is_clipped is always false, with |
1772 // or without surfaces. | 1782 // or without surfaces. |
1773 root->SetHasRenderSurface(true); | |
1774 child1->SetHasRenderSurface(true); | |
1775 grand_child->SetHasRenderSurface(true); | |
1776 ExecuteCalculateDrawProperties(root); | 1783 ExecuteCalculateDrawProperties(root); |
1777 EXPECT_FALSE(root->is_clipped()); | 1784 EXPECT_FALSE(root->is_clipped()); |
1778 EXPECT_FALSE(parent->is_clipped()); | 1785 EXPECT_FALSE(parent->is_clipped()); |
1779 EXPECT_FALSE(child1->is_clipped()); | 1786 EXPECT_FALSE(child1->is_clipped()); |
1780 EXPECT_FALSE(child2->is_clipped()); | 1787 EXPECT_FALSE(child2->is_clipped()); |
1781 EXPECT_FALSE(grand_child->is_clipped()); | 1788 EXPECT_FALSE(grand_child->is_clipped()); |
1782 EXPECT_FALSE(leaf_node1->is_clipped()); | 1789 EXPECT_FALSE(leaf_node1->is_clipped()); |
1783 EXPECT_FALSE(leaf_node2->is_clipped()); | 1790 EXPECT_FALSE(leaf_node2->is_clipped()); |
1784 | 1791 |
1785 ExecuteCalculateDrawPropertiesWithoutSeparateSurfaces(root); | 1792 ExecuteCalculateDrawPropertiesWithoutSeparateSurfaces(root); |
1786 EXPECT_FALSE(root->is_clipped()); | 1793 EXPECT_FALSE(root->is_clipped()); |
1787 EXPECT_FALSE(parent->is_clipped()); | 1794 EXPECT_FALSE(parent->is_clipped()); |
1788 EXPECT_FALSE(child1->is_clipped()); | 1795 EXPECT_FALSE(child1->is_clipped()); |
1789 EXPECT_FALSE(child2->is_clipped()); | 1796 EXPECT_FALSE(child2->is_clipped()); |
1790 EXPECT_FALSE(grand_child->is_clipped()); | 1797 EXPECT_FALSE(grand_child->is_clipped()); |
1791 EXPECT_FALSE(leaf_node1->is_clipped()); | 1798 EXPECT_FALSE(leaf_node1->is_clipped()); |
1792 EXPECT_FALSE(leaf_node2->is_clipped()); | 1799 EXPECT_FALSE(leaf_node2->is_clipped()); |
1793 | 1800 |
1794 // Case 2: The root is clipped. With surfaces, this only persists until the | 1801 // Case 2: The root is clipped. With surfaces, this only persists until the |
1795 // next render surface. Without surfaces, the entire tree is clipped. | 1802 // next render surface. Without surfaces, the entire tree is clipped. |
1796 root->SetMasksToBounds(true); | 1803 root->SetMasksToBounds(true); |
1797 host_impl()->active_tree()->property_trees()->needs_rebuild = true; | 1804 host_impl()->active_tree()->property_trees()->needs_rebuild = true; |
1798 root->SetHasRenderSurface(true); | |
1799 child1->SetHasRenderSurface(true); | |
1800 grand_child->SetHasRenderSurface(true); | |
1801 ExecuteCalculateDrawProperties(root); | 1805 ExecuteCalculateDrawProperties(root); |
1802 EXPECT_TRUE(root->is_clipped()); | 1806 EXPECT_TRUE(root->is_clipped()); |
1803 EXPECT_TRUE(parent->is_clipped()); | 1807 EXPECT_TRUE(parent->is_clipped()); |
1804 EXPECT_FALSE(child1->is_clipped()); | 1808 EXPECT_FALSE(child1->is_clipped()); |
1805 EXPECT_TRUE(child2->is_clipped()); | 1809 EXPECT_TRUE(child2->is_clipped()); |
1806 EXPECT_FALSE(grand_child->is_clipped()); | 1810 EXPECT_FALSE(grand_child->is_clipped()); |
1807 EXPECT_FALSE(leaf_node1->is_clipped()); | 1811 EXPECT_FALSE(leaf_node1->is_clipped()); |
1808 EXPECT_TRUE(leaf_node2->is_clipped()); | 1812 EXPECT_TRUE(leaf_node2->is_clipped()); |
1809 | 1813 |
1810 ExecuteCalculateDrawPropertiesWithoutSeparateSurfaces(root); | 1814 ExecuteCalculateDrawPropertiesWithoutSeparateSurfaces(root); |
1811 EXPECT_TRUE(root->is_clipped()); | 1815 EXPECT_TRUE(root->is_clipped()); |
1812 EXPECT_TRUE(parent->is_clipped()); | 1816 EXPECT_TRUE(parent->is_clipped()); |
1813 EXPECT_TRUE(child1->is_clipped()); | 1817 EXPECT_TRUE(child1->is_clipped()); |
1814 EXPECT_TRUE(child2->is_clipped()); | 1818 EXPECT_TRUE(child2->is_clipped()); |
1815 EXPECT_TRUE(grand_child->is_clipped()); | 1819 EXPECT_TRUE(grand_child->is_clipped()); |
1816 EXPECT_TRUE(leaf_node1->is_clipped()); | 1820 EXPECT_TRUE(leaf_node1->is_clipped()); |
1817 EXPECT_TRUE(leaf_node2->is_clipped()); | 1821 EXPECT_TRUE(leaf_node2->is_clipped()); |
1818 | 1822 |
1819 root->SetMasksToBounds(false); | 1823 root->SetMasksToBounds(false); |
1820 | 1824 |
1821 // Case 3: The parent is clipped. Again, with surfaces, this only persists | 1825 // Case 3: The parent is clipped. Again, with surfaces, this only persists |
1822 // until the next render surface. Without surfaces, parent's entire subtree is | 1826 // until the next render surface. Without surfaces, parent's entire subtree is |
1823 // clipped. | 1827 // clipped. |
1824 parent->SetMasksToBounds(true); | 1828 parent->SetMasksToBounds(true); |
1825 host_impl()->active_tree()->property_trees()->needs_rebuild = true; | 1829 host_impl()->active_tree()->property_trees()->needs_rebuild = true; |
1826 root->SetHasRenderSurface(true); | |
1827 child1->SetHasRenderSurface(true); | |
1828 grand_child->SetHasRenderSurface(true); | |
1829 ExecuteCalculateDrawProperties(root); | 1830 ExecuteCalculateDrawProperties(root); |
1830 EXPECT_FALSE(root->is_clipped()); | 1831 EXPECT_FALSE(root->is_clipped()); |
1831 EXPECT_TRUE(parent->is_clipped()); | 1832 EXPECT_TRUE(parent->is_clipped()); |
1832 EXPECT_FALSE(child1->is_clipped()); | 1833 EXPECT_FALSE(child1->is_clipped()); |
1833 EXPECT_TRUE(child2->is_clipped()); | 1834 EXPECT_TRUE(child2->is_clipped()); |
1834 EXPECT_FALSE(grand_child->is_clipped()); | 1835 EXPECT_FALSE(grand_child->is_clipped()); |
1835 EXPECT_FALSE(leaf_node1->is_clipped()); | 1836 EXPECT_FALSE(leaf_node1->is_clipped()); |
1836 EXPECT_TRUE(leaf_node2->is_clipped()); | 1837 EXPECT_TRUE(leaf_node2->is_clipped()); |
1837 | 1838 |
1838 ExecuteCalculateDrawPropertiesWithoutSeparateSurfaces(root); | 1839 ExecuteCalculateDrawPropertiesWithoutSeparateSurfaces(root); |
1839 EXPECT_FALSE(root->is_clipped()); | 1840 EXPECT_FALSE(root->is_clipped()); |
1840 EXPECT_TRUE(parent->is_clipped()); | 1841 EXPECT_TRUE(parent->is_clipped()); |
1841 EXPECT_TRUE(child1->is_clipped()); | 1842 EXPECT_TRUE(child1->is_clipped()); |
1842 EXPECT_TRUE(child2->is_clipped()); | 1843 EXPECT_TRUE(child2->is_clipped()); |
1843 EXPECT_TRUE(grand_child->is_clipped()); | 1844 EXPECT_TRUE(grand_child->is_clipped()); |
1844 EXPECT_TRUE(leaf_node1->is_clipped()); | 1845 EXPECT_TRUE(leaf_node1->is_clipped()); |
1845 EXPECT_TRUE(leaf_node2->is_clipped()); | 1846 EXPECT_TRUE(leaf_node2->is_clipped()); |
1846 | 1847 |
1847 parent->SetMasksToBounds(false); | 1848 parent->SetMasksToBounds(false); |
1848 | 1849 |
1849 // Case 4: child1 is clipped. With surfaces, only child1 is_clipped, since it | 1850 // Case 4: child1 is clipped. With surfaces, only child1 is_clipped, since it |
1850 // has no non-surface children. Without surfaces, child1's entire subtree is | 1851 // has no non-surface children. Without surfaces, child1's entire subtree is |
1851 // clipped. | 1852 // clipped. |
1852 child1->SetMasksToBounds(true); | 1853 child1->SetMasksToBounds(true); |
1853 host_impl()->active_tree()->property_trees()->needs_rebuild = true; | 1854 host_impl()->active_tree()->property_trees()->needs_rebuild = true; |
1854 root->SetHasRenderSurface(true); | |
1855 child1->SetHasRenderSurface(true); | |
1856 grand_child->SetHasRenderSurface(true); | |
1857 ExecuteCalculateDrawProperties(root); | 1855 ExecuteCalculateDrawProperties(root); |
1858 EXPECT_FALSE(root->is_clipped()); | 1856 EXPECT_FALSE(root->is_clipped()); |
1859 EXPECT_FALSE(parent->is_clipped()); | 1857 EXPECT_FALSE(parent->is_clipped()); |
1860 EXPECT_TRUE(child1->is_clipped()); | 1858 EXPECT_TRUE(child1->is_clipped()); |
1861 EXPECT_FALSE(child2->is_clipped()); | 1859 EXPECT_FALSE(child2->is_clipped()); |
1862 EXPECT_FALSE(grand_child->is_clipped()); | 1860 EXPECT_FALSE(grand_child->is_clipped()); |
1863 EXPECT_FALSE(leaf_node1->is_clipped()); | 1861 EXPECT_FALSE(leaf_node1->is_clipped()); |
1864 EXPECT_FALSE(leaf_node2->is_clipped()); | 1862 EXPECT_FALSE(leaf_node2->is_clipped()); |
1865 | 1863 |
1866 ExecuteCalculateDrawPropertiesWithoutSeparateSurfaces(root); | 1864 ExecuteCalculateDrawPropertiesWithoutSeparateSurfaces(root); |
1867 EXPECT_FALSE(root->is_clipped()); | 1865 EXPECT_FALSE(root->is_clipped()); |
1868 EXPECT_FALSE(parent->is_clipped()); | 1866 EXPECT_FALSE(parent->is_clipped()); |
1869 EXPECT_TRUE(child1->is_clipped()); | 1867 EXPECT_TRUE(child1->is_clipped()); |
1870 EXPECT_FALSE(child2->is_clipped()); | 1868 EXPECT_FALSE(child2->is_clipped()); |
1871 EXPECT_TRUE(grand_child->is_clipped()); | 1869 EXPECT_TRUE(grand_child->is_clipped()); |
1872 EXPECT_TRUE(leaf_node1->is_clipped()); | 1870 EXPECT_TRUE(leaf_node1->is_clipped()); |
1873 EXPECT_FALSE(leaf_node2->is_clipped()); | 1871 EXPECT_FALSE(leaf_node2->is_clipped()); |
1874 | 1872 |
1875 child1->SetMasksToBounds(false); | 1873 child1->SetMasksToBounds(false); |
1876 | 1874 |
1877 // Case 5: Only the leaf nodes are clipped. The behavior with and without | 1875 // Case 5: Only the leaf nodes are clipped. The behavior with and without |
1878 // surfaces is the same. | 1876 // surfaces is the same. |
1879 leaf_node1->SetMasksToBounds(true); | 1877 leaf_node1->SetMasksToBounds(true); |
1880 leaf_node2->SetMasksToBounds(true); | 1878 leaf_node2->SetMasksToBounds(true); |
1881 host_impl()->active_tree()->property_trees()->needs_rebuild = true; | 1879 host_impl()->active_tree()->property_trees()->needs_rebuild = true; |
1882 root->SetHasRenderSurface(true); | |
1883 child1->SetHasRenderSurface(true); | |
1884 grand_child->SetHasRenderSurface(true); | |
1885 ExecuteCalculateDrawProperties(root); | 1880 ExecuteCalculateDrawProperties(root); |
1886 EXPECT_FALSE(root->is_clipped()); | 1881 EXPECT_FALSE(root->is_clipped()); |
1887 EXPECT_FALSE(parent->is_clipped()); | 1882 EXPECT_FALSE(parent->is_clipped()); |
1888 EXPECT_FALSE(child1->is_clipped()); | 1883 EXPECT_FALSE(child1->is_clipped()); |
1889 EXPECT_FALSE(child2->is_clipped()); | 1884 EXPECT_FALSE(child2->is_clipped()); |
1890 EXPECT_FALSE(grand_child->is_clipped()); | 1885 EXPECT_FALSE(grand_child->is_clipped()); |
1891 EXPECT_TRUE(leaf_node1->is_clipped()); | 1886 EXPECT_TRUE(leaf_node1->is_clipped()); |
1892 EXPECT_TRUE(leaf_node2->is_clipped()); | 1887 EXPECT_TRUE(leaf_node2->is_clipped()); |
1893 | 1888 |
1894 ExecuteCalculateDrawPropertiesWithoutSeparateSurfaces(root); | 1889 ExecuteCalculateDrawPropertiesWithoutSeparateSurfaces(root); |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2063 child1->SetDrawsContent(true); | 2058 child1->SetDrawsContent(true); |
2064 child2->SetDrawsContent(true); | 2059 child2->SetDrawsContent(true); |
2065 grand_child->SetDrawsContent(true); | 2060 grand_child->SetDrawsContent(true); |
2066 leaf_node1->SetDrawsContent(true); | 2061 leaf_node1->SetDrawsContent(true); |
2067 leaf_node2->SetDrawsContent(true); | 2062 leaf_node2->SetDrawsContent(true); |
2068 | 2063 |
2069 const gfx::Transform identity_matrix; | 2064 const gfx::Transform identity_matrix; |
2070 | 2065 |
2071 // child1 and grand_child get render surfaces when surfaces are enabled. | 2066 // child1 and grand_child get render surfaces when surfaces are enabled. |
2072 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), | 2067 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), |
2073 gfx::PointF(), gfx::Size(100, 100), true, false); | 2068 gfx::PointF(), gfx::Size(100, 100), true, false, |
| 2069 true); |
2074 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(), | 2070 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(), |
2075 gfx::PointF(2.f, 2.f), gfx::Size(400, 400), true, | 2071 gfx::PointF(2.f, 2.f), gfx::Size(400, 400), true, |
2076 false); | 2072 false, false); |
2077 SetLayerPropertiesForTesting(child1, identity_matrix, gfx::Point3F(), | 2073 SetLayerPropertiesForTesting(child1, identity_matrix, gfx::Point3F(), |
2078 gfx::PointF(4.f, 4.f), gfx::Size(800, 800), true, | 2074 gfx::PointF(4.f, 4.f), gfx::Size(800, 800), true, |
2079 false); | 2075 false, true); |
2080 SetLayerPropertiesForTesting(child2, identity_matrix, gfx::Point3F(), | 2076 SetLayerPropertiesForTesting(child2, identity_matrix, gfx::Point3F(), |
2081 gfx::PointF(3.f, 3.f), gfx::Size(800, 800), true, | 2077 gfx::PointF(3.f, 3.f), gfx::Size(800, 800), true, |
2082 false); | 2078 false, false); |
2083 SetLayerPropertiesForTesting(grand_child, identity_matrix, gfx::Point3F(), | 2079 SetLayerPropertiesForTesting(grand_child, identity_matrix, gfx::Point3F(), |
2084 gfx::PointF(8.f, 8.f), gfx::Size(1500, 1500), | 2080 gfx::PointF(8.f, 8.f), gfx::Size(1500, 1500), |
2085 true, false); | 2081 true, false, true); |
2086 SetLayerPropertiesForTesting(leaf_node1, identity_matrix, gfx::Point3F(), | 2082 SetLayerPropertiesForTesting(leaf_node1, identity_matrix, gfx::Point3F(), |
2087 gfx::PointF(16.f, 16.f), gfx::Size(2000, 2000), | 2083 gfx::PointF(16.f, 16.f), gfx::Size(2000, 2000), |
2088 true, false); | 2084 true, false, false); |
2089 SetLayerPropertiesForTesting(leaf_node2, identity_matrix, gfx::Point3F(), | 2085 SetLayerPropertiesForTesting(leaf_node2, identity_matrix, gfx::Point3F(), |
2090 gfx::PointF(9.f, 9.f), gfx::Size(2000, 2000), | 2086 gfx::PointF(9.f, 9.f), gfx::Size(2000, 2000), |
2091 true, false); | 2087 true, false, false); |
2092 | 2088 |
2093 // Case 1: Nothing is clipped. In this case, each layer's clip rect is its | 2089 // Case 1: Nothing is clipped. In this case, each layer's clip rect is its |
2094 // bounds in target space. The only thing that changes when surfaces are | 2090 // bounds in target space. The only thing that changes when surfaces are |
2095 // disabled is that target space is always screen space. | 2091 // disabled is that target space is always screen space. |
2096 root->SetForceRenderSurface(true); | |
2097 child1->SetForceRenderSurface(true); | |
2098 grand_child->SetForceRenderSurface(true); | |
2099 ExecuteCalculateDrawProperties(root); | 2092 ExecuteCalculateDrawProperties(root); |
2100 EXPECT_TRUE(root->has_render_surface()); | |
2101 EXPECT_FALSE(parent->has_render_surface()); | |
2102 EXPECT_TRUE(child1->has_render_surface()); | |
2103 EXPECT_FALSE(child2->has_render_surface()); | |
2104 EXPECT_TRUE(grand_child->has_render_surface()); | |
2105 EXPECT_FALSE(leaf_node1->has_render_surface()); | |
2106 EXPECT_FALSE(leaf_node2->has_render_surface()); | |
2107 EXPECT_EQ(gfx::Rect(100, 100), root->clip_rect()); | 2093 EXPECT_EQ(gfx::Rect(100, 100), root->clip_rect()); |
2108 EXPECT_EQ(gfx::Rect(2, 2, 400, 400), parent->clip_rect()); | 2094 EXPECT_EQ(gfx::Rect(2, 2, 400, 400), parent->clip_rect()); |
2109 EXPECT_EQ(gfx::Rect(800, 800), child1->clip_rect()); | 2095 EXPECT_EQ(gfx::Rect(800, 800), child1->clip_rect()); |
2110 EXPECT_EQ(gfx::Rect(5, 5, 800, 800), child2->clip_rect()); | 2096 EXPECT_EQ(gfx::Rect(5, 5, 800, 800), child2->clip_rect()); |
2111 EXPECT_EQ(gfx::Rect(1500, 1500), grand_child->clip_rect()); | 2097 EXPECT_EQ(gfx::Rect(1500, 1500), grand_child->clip_rect()); |
2112 EXPECT_EQ(gfx::Rect(16, 16, 2000, 2000), leaf_node1->clip_rect()); | 2098 EXPECT_EQ(gfx::Rect(16, 16, 2000, 2000), leaf_node1->clip_rect()); |
2113 EXPECT_EQ(gfx::Rect(14, 14, 2000, 2000), leaf_node2->clip_rect()); | 2099 EXPECT_EQ(gfx::Rect(14, 14, 2000, 2000), leaf_node2->clip_rect()); |
2114 | 2100 |
2115 ExecuteCalculateDrawPropertiesWithoutSeparateSurfaces(root); | 2101 ExecuteCalculateDrawPropertiesWithoutSeparateSurfaces(root); |
2116 EXPECT_EQ(gfx::Rect(100, 100), root->clip_rect()); | 2102 EXPECT_EQ(gfx::Rect(100, 100), root->clip_rect()); |
2117 EXPECT_EQ(gfx::Rect(2, 2, 400, 400), parent->clip_rect()); | 2103 EXPECT_EQ(gfx::Rect(2, 2, 400, 400), parent->clip_rect()); |
2118 EXPECT_EQ(gfx::Rect(6, 6, 800, 800), child1->clip_rect()); | 2104 EXPECT_EQ(gfx::Rect(6, 6, 800, 800), child1->clip_rect()); |
2119 EXPECT_EQ(gfx::Rect(5, 5, 800, 800), child2->clip_rect()); | 2105 EXPECT_EQ(gfx::Rect(5, 5, 800, 800), child2->clip_rect()); |
2120 EXPECT_EQ(gfx::Rect(14, 14, 1500, 1500), grand_child->clip_rect()); | 2106 EXPECT_EQ(gfx::Rect(14, 14, 1500, 1500), grand_child->clip_rect()); |
2121 EXPECT_EQ(gfx::Rect(30, 30, 2000, 2000), leaf_node1->clip_rect()); | 2107 EXPECT_EQ(gfx::Rect(30, 30, 2000, 2000), leaf_node1->clip_rect()); |
2122 EXPECT_EQ(gfx::Rect(14, 14, 2000, 2000), leaf_node2->clip_rect()); | 2108 EXPECT_EQ(gfx::Rect(14, 14, 2000, 2000), leaf_node2->clip_rect()); |
2123 | 2109 |
2124 // Case 2: The root is clipped. In this case, layers that draw into the root | 2110 // Case 2: The root is clipped. In this case, layers that draw into the root |
2125 // render surface are clipped by the root's bounds. | 2111 // render surface are clipped by the root's bounds. |
2126 root->SetMasksToBounds(true); | 2112 root->SetMasksToBounds(true); |
2127 host_impl()->active_tree()->property_trees()->needs_rebuild = true; | 2113 host_impl()->active_tree()->property_trees()->needs_rebuild = true; |
2128 root->SetForceRenderSurface(true); | |
2129 child1->SetForceRenderSurface(true); | |
2130 grand_child->SetForceRenderSurface(true); | |
2131 ExecuteCalculateDrawProperties(root); | 2114 ExecuteCalculateDrawProperties(root); |
2132 EXPECT_TRUE(root->has_render_surface()); | |
2133 EXPECT_FALSE(parent->has_render_surface()); | |
2134 EXPECT_TRUE(child1->has_render_surface()); | |
2135 EXPECT_FALSE(child2->has_render_surface()); | |
2136 EXPECT_TRUE(grand_child->has_render_surface()); | |
2137 EXPECT_FALSE(leaf_node1->has_render_surface()); | |
2138 EXPECT_FALSE(leaf_node2->has_render_surface()); | |
2139 EXPECT_EQ(gfx::Rect(100, 100), root->clip_rect()); | 2115 EXPECT_EQ(gfx::Rect(100, 100), root->clip_rect()); |
2140 EXPECT_EQ(gfx::Rect(100, 100), parent->clip_rect()); | 2116 EXPECT_EQ(gfx::Rect(100, 100), parent->clip_rect()); |
2141 EXPECT_EQ(gfx::Rect(800, 800), child1->clip_rect()); | 2117 EXPECT_EQ(gfx::Rect(800, 800), child1->clip_rect()); |
2142 EXPECT_EQ(gfx::Rect(100, 100), child2->clip_rect()); | 2118 EXPECT_EQ(gfx::Rect(100, 100), child2->clip_rect()); |
2143 EXPECT_EQ(gfx::Rect(1500, 1500), grand_child->clip_rect()); | 2119 EXPECT_EQ(gfx::Rect(1500, 1500), grand_child->clip_rect()); |
2144 EXPECT_EQ(gfx::Rect(16, 16, 2000, 2000), leaf_node1->clip_rect()); | 2120 EXPECT_EQ(gfx::Rect(16, 16, 2000, 2000), leaf_node1->clip_rect()); |
2145 EXPECT_EQ(gfx::Rect(100, 100), leaf_node2->clip_rect()); | 2121 EXPECT_EQ(gfx::Rect(100, 100), leaf_node2->clip_rect()); |
2146 | 2122 |
2147 ExecuteCalculateDrawPropertiesWithoutSeparateSurfaces(root); | 2123 ExecuteCalculateDrawPropertiesWithoutSeparateSurfaces(root); |
2148 EXPECT_EQ(gfx::Rect(100, 100), root->clip_rect()); | 2124 EXPECT_EQ(gfx::Rect(100, 100), root->clip_rect()); |
2149 EXPECT_EQ(gfx::Rect(100, 100), parent->clip_rect()); | 2125 EXPECT_EQ(gfx::Rect(100, 100), parent->clip_rect()); |
2150 EXPECT_EQ(gfx::Rect(100, 100), child1->clip_rect()); | 2126 EXPECT_EQ(gfx::Rect(100, 100), child1->clip_rect()); |
2151 EXPECT_EQ(gfx::Rect(100, 100), child2->clip_rect()); | 2127 EXPECT_EQ(gfx::Rect(100, 100), child2->clip_rect()); |
2152 EXPECT_EQ(gfx::Rect(100, 100), grand_child->clip_rect()); | 2128 EXPECT_EQ(gfx::Rect(100, 100), grand_child->clip_rect()); |
2153 EXPECT_EQ(gfx::Rect(100, 100), leaf_node1->clip_rect()); | 2129 EXPECT_EQ(gfx::Rect(100, 100), leaf_node1->clip_rect()); |
2154 EXPECT_EQ(gfx::Rect(100, 100), leaf_node2->clip_rect()); | 2130 EXPECT_EQ(gfx::Rect(100, 100), leaf_node2->clip_rect()); |
2155 | 2131 |
2156 root->SetMasksToBounds(false); | 2132 root->SetMasksToBounds(false); |
2157 | 2133 |
2158 // Case 3: The parent and child1 are clipped. When surfaces are enabled, the | 2134 // Case 3: The parent and child1 are clipped. When surfaces are enabled, the |
2159 // parent clip rect only contributes to the subtree rooted at child2, since | 2135 // parent clip rect only contributes to the subtree rooted at child2, since |
2160 // the subtree rooted at child1 renders into a separate surface. Similarly, | 2136 // the subtree rooted at child1 renders into a separate surface. Similarly, |
2161 // child1's clip rect doesn't contribute to its descendants, since its only | 2137 // child1's clip rect doesn't contribute to its descendants, since its only |
2162 // child is a render surface. However, without surfaces, these clip rects | 2138 // child is a render surface. However, without surfaces, these clip rects |
2163 // contribute to all descendants. | 2139 // contribute to all descendants. |
2164 parent->SetMasksToBounds(true); | 2140 parent->SetMasksToBounds(true); |
2165 child1->SetMasksToBounds(true); | 2141 child1->SetMasksToBounds(true); |
2166 host_impl()->active_tree()->property_trees()->needs_rebuild = true; | 2142 host_impl()->active_tree()->property_trees()->needs_rebuild = true; |
2167 root->SetForceRenderSurface(true); | |
2168 child1->SetForceRenderSurface(true); | |
2169 grand_child->SetForceRenderSurface(true); | |
2170 ExecuteCalculateDrawProperties(root); | 2143 ExecuteCalculateDrawProperties(root); |
2171 EXPECT_TRUE(root->has_render_surface()); | |
2172 EXPECT_FALSE(parent->has_render_surface()); | |
2173 EXPECT_TRUE(child1->has_render_surface()); | |
2174 EXPECT_FALSE(child2->has_render_surface()); | |
2175 EXPECT_TRUE(grand_child->has_render_surface()); | |
2176 EXPECT_FALSE(leaf_node1->has_render_surface()); | |
2177 EXPECT_FALSE(leaf_node2->has_render_surface()); | |
2178 EXPECT_EQ(gfx::Rect(100, 100), root->clip_rect()); | 2144 EXPECT_EQ(gfx::Rect(100, 100), root->clip_rect()); |
2179 EXPECT_EQ(gfx::Rect(2, 2, 400, 400), parent->clip_rect()); | 2145 EXPECT_EQ(gfx::Rect(2, 2, 400, 400), parent->clip_rect()); |
2180 EXPECT_EQ(gfx::Rect(800, 800), child1->clip_rect()); | 2146 EXPECT_EQ(gfx::Rect(800, 800), child1->clip_rect()); |
2181 EXPECT_EQ(gfx::Rect(2, 2, 400, 400), child2->clip_rect()); | 2147 EXPECT_EQ(gfx::Rect(2, 2, 400, 400), child2->clip_rect()); |
2182 EXPECT_EQ(gfx::Rect(1500, 1500), grand_child->clip_rect()); | 2148 EXPECT_EQ(gfx::Rect(1500, 1500), grand_child->clip_rect()); |
2183 EXPECT_EQ(gfx::Rect(16, 16, 2000, 2000), leaf_node1->clip_rect()); | 2149 EXPECT_EQ(gfx::Rect(16, 16, 2000, 2000), leaf_node1->clip_rect()); |
2184 EXPECT_EQ(gfx::Rect(2, 2, 400, 400), leaf_node2->clip_rect()); | 2150 EXPECT_EQ(gfx::Rect(2, 2, 400, 400), leaf_node2->clip_rect()); |
2185 | 2151 |
2186 ExecuteCalculateDrawPropertiesWithoutSeparateSurfaces(root); | 2152 ExecuteCalculateDrawPropertiesWithoutSeparateSurfaces(root); |
2187 EXPECT_EQ(gfx::Rect(100, 100), root->clip_rect()); | 2153 EXPECT_EQ(gfx::Rect(100, 100), root->clip_rect()); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2223 SetLayerPropertiesForTesting(grand_child, identity_matrix, gfx::Point3F(), | 2189 SetLayerPropertiesForTesting(grand_child, identity_matrix, gfx::Point3F(), |
2224 gfx::PointF(8.f, 8.f), gfx::Size(1500, 1500), | 2190 gfx::PointF(8.f, 8.f), gfx::Size(1500, 1500), |
2225 true, false, true); | 2191 true, false, true); |
2226 SetLayerPropertiesForTesting(leaf_node, identity_matrix, gfx::Point3F(), | 2192 SetLayerPropertiesForTesting(leaf_node, identity_matrix, gfx::Point3F(), |
2227 gfx::PointF(16.f, 16.f), gfx::Size(2000, 2000), | 2193 gfx::PointF(16.f, 16.f), gfx::Size(2000, 2000), |
2228 true, false, false); | 2194 true, false, false); |
2229 | 2195 |
2230 parent->SetMasksToBounds(true); | 2196 parent->SetMasksToBounds(true); |
2231 child->SetMasksToBounds(true); | 2197 child->SetMasksToBounds(true); |
2232 | 2198 |
2233 root->SetHasRenderSurface(true); | |
2234 child->SetHasRenderSurface(true); | |
2235 grand_child->SetHasRenderSurface(true); | |
2236 | |
2237 gfx::Transform expected_leaf_draw_transform_with_surfaces; | 2199 gfx::Transform expected_leaf_draw_transform_with_surfaces; |
2238 expected_leaf_draw_transform_with_surfaces.Translate(16.0, 16.0); | 2200 expected_leaf_draw_transform_with_surfaces.Translate(16.0, 16.0); |
2239 | 2201 |
2240 gfx::Transform expected_leaf_draw_transform_without_surfaces; | 2202 gfx::Transform expected_leaf_draw_transform_without_surfaces; |
2241 expected_leaf_draw_transform_without_surfaces.Translate(30.0, 30.0); | 2203 expected_leaf_draw_transform_without_surfaces.Translate(30.0, 30.0); |
2242 | 2204 |
2243 ExecuteCalculateDrawProperties(root); | 2205 ExecuteCalculateDrawProperties(root); |
2244 EXPECT_EQ(gfx::Rect(16, 16, 2000, 2000), leaf_node->clip_rect()); | 2206 EXPECT_EQ(gfx::Rect(16, 16, 2000, 2000), leaf_node->clip_rect()); |
2245 EXPECT_EQ(gfx::Rect(16, 16, 2000, 2000), leaf_node->drawable_content_rect()); | 2207 EXPECT_EQ(gfx::Rect(16, 16, 2000, 2000), leaf_node->drawable_content_rect()); |
2246 EXPECT_EQ(expected_leaf_draw_transform_with_surfaces, | 2208 EXPECT_EQ(expected_leaf_draw_transform_with_surfaces, |
2247 leaf_node->DrawTransform()); | 2209 leaf_node->DrawTransform()); |
2248 | 2210 |
2249 root->SetHasRenderSurface(true); | |
2250 child->SetHasRenderSurface(true); | |
2251 grand_child->SetHasRenderSurface(true); | |
2252 | |
2253 ExecuteCalculateDrawPropertiesWithoutSeparateSurfaces(root); | 2211 ExecuteCalculateDrawPropertiesWithoutSeparateSurfaces(root); |
2254 EXPECT_EQ(gfx::Rect(6, 6, 396, 396), leaf_node->clip_rect()); | 2212 EXPECT_EQ(gfx::Rect(6, 6, 396, 396), leaf_node->clip_rect()); |
2255 EXPECT_EQ(gfx::Rect(30, 30, 372, 372), leaf_node->drawable_content_rect()); | 2213 EXPECT_EQ(gfx::Rect(30, 30, 372, 372), leaf_node->drawable_content_rect()); |
2256 EXPECT_EQ(expected_leaf_draw_transform_without_surfaces, | 2214 EXPECT_EQ(expected_leaf_draw_transform_without_surfaces, |
2257 leaf_node->DrawTransform()); | 2215 leaf_node->DrawTransform()); |
2258 | 2216 |
2259 root->SetHasRenderSurface(true); | |
2260 child->SetHasRenderSurface(true); | |
2261 grand_child->SetHasRenderSurface(true); | |
2262 | |
2263 ExecuteCalculateDrawProperties(root); | 2217 ExecuteCalculateDrawProperties(root); |
2264 EXPECT_EQ(gfx::Rect(16, 16, 2000, 2000), leaf_node->clip_rect()); | 2218 EXPECT_EQ(gfx::Rect(16, 16, 2000, 2000), leaf_node->clip_rect()); |
2265 EXPECT_EQ(gfx::Rect(16, 16, 2000, 2000), leaf_node->drawable_content_rect()); | 2219 EXPECT_EQ(gfx::Rect(16, 16, 2000, 2000), leaf_node->drawable_content_rect()); |
2266 EXPECT_EQ(expected_leaf_draw_transform_with_surfaces, | 2220 EXPECT_EQ(expected_leaf_draw_transform_with_surfaces, |
2267 leaf_node->DrawTransform()); | 2221 leaf_node->DrawTransform()); |
2268 } | 2222 } |
2269 | 2223 |
2270 TEST_F(LayerTreeHostCommonTest, AnimationsForRenderSurfaceHierarchy) { | 2224 TEST_F(LayerTreeHostCommonTest, AnimationsForRenderSurfaceHierarchy) { |
2271 LayerImpl* parent = root_layer(); | 2225 LayerImpl* parent = root_layer(); |
2272 LayerImpl* render_surface1 = AddChildToRoot<LayerImpl>(); | 2226 LayerImpl* render_surface1 = AddChildToRoot<LayerImpl>(); |
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3001 true, false, false); | 2955 true, false, false); |
3002 SetLayerPropertiesForTesting(leaf_node2, identity_matrix, gfx::Point3F(), | 2956 SetLayerPropertiesForTesting(leaf_node2, identity_matrix, gfx::Point3F(), |
3003 gfx::PointF(9.f, 9.f), gfx::Size(2000, 2000), | 2957 gfx::PointF(9.f, 9.f), gfx::Size(2000, 2000), |
3004 true, false, false); | 2958 true, false, false); |
3005 | 2959 |
3006 // Case 1: No layers clip. Visible rects are clipped by the viewport, but the | 2960 // Case 1: No layers clip. Visible rects are clipped by the viewport, but the |
3007 // viewport clip doesn't apply to layers that draw into unclipped surfaces. | 2961 // viewport clip doesn't apply to layers that draw into unclipped surfaces. |
3008 // Each layer's drawable content rect is its bounds in target space; the only | 2962 // Each layer's drawable content rect is its bounds in target space; the only |
3009 // thing that changes with surfaces disabled is that target space is always | 2963 // thing that changes with surfaces disabled is that target space is always |
3010 // screen space. | 2964 // screen space. |
3011 root->SetHasRenderSurface(true); | |
3012 child1->SetHasRenderSurface(true); | |
3013 child2->SetHasRenderSurface(true); | |
3014 ExecuteCalculateDrawProperties(root); | 2965 ExecuteCalculateDrawProperties(root); |
3015 EXPECT_EQ(gfx::Rect(100, 100), root->visible_layer_rect()); | 2966 EXPECT_EQ(gfx::Rect(100, 100), root->visible_layer_rect()); |
3016 EXPECT_EQ(gfx::Rect(0, 0, 98, 98), parent->visible_layer_rect()); | 2967 EXPECT_EQ(gfx::Rect(0, 0, 98, 98), parent->visible_layer_rect()); |
3017 EXPECT_EQ(gfx::Rect(800, 800), child1->visible_layer_rect()); | 2968 EXPECT_EQ(gfx::Rect(800, 800), child1->visible_layer_rect()); |
3018 EXPECT_EQ(gfx::Rect(800, 800), child2->visible_layer_rect()); | 2969 EXPECT_EQ(gfx::Rect(800, 800), child2->visible_layer_rect()); |
3019 EXPECT_EQ(gfx::Rect(1500, 1500), grand_child1->visible_layer_rect()); | 2970 EXPECT_EQ(gfx::Rect(1500, 1500), grand_child1->visible_layer_rect()); |
3020 EXPECT_EQ(gfx::Rect(1500, 1500), grand_child2->visible_layer_rect()); | 2971 EXPECT_EQ(gfx::Rect(1500, 1500), grand_child2->visible_layer_rect()); |
3021 EXPECT_EQ(gfx::Rect(2000, 2000), leaf_node1->visible_layer_rect()); | 2972 EXPECT_EQ(gfx::Rect(2000, 2000), leaf_node1->visible_layer_rect()); |
3022 EXPECT_EQ(gfx::Rect(2000, 2000), leaf_node2->visible_layer_rect()); | 2973 EXPECT_EQ(gfx::Rect(2000, 2000), leaf_node2->visible_layer_rect()); |
3023 | 2974 |
(...skipping 28 matching lines...) Expand all Loading... |
3052 EXPECT_EQ(gfx::Rect(21, 21, 2000, 2000), leaf_node2->drawable_content_rect()); | 3003 EXPECT_EQ(gfx::Rect(21, 21, 2000, 2000), leaf_node2->drawable_content_rect()); |
3053 | 3004 |
3054 // Case 2: The parent clips. In this case, neither surface is unclipped, so | 3005 // Case 2: The parent clips. In this case, neither surface is unclipped, so |
3055 // all visible layer rects are clipped by the intersection of all ancestor | 3006 // all visible layer rects are clipped by the intersection of all ancestor |
3056 // clips, whether or not surfaces are disabled. However, drawable content | 3007 // clips, whether or not surfaces are disabled. However, drawable content |
3057 // rects are clipped only until the next render surface is reached, so | 3008 // rects are clipped only until the next render surface is reached, so |
3058 // descendants of parent have their drawable content rects clipped only when | 3009 // descendants of parent have their drawable content rects clipped only when |
3059 // surfaces are disabled. | 3010 // surfaces are disabled. |
3060 parent->SetMasksToBounds(true); | 3011 parent->SetMasksToBounds(true); |
3061 host_impl()->active_tree()->property_trees()->needs_rebuild = true; | 3012 host_impl()->active_tree()->property_trees()->needs_rebuild = true; |
3062 root->SetHasRenderSurface(true); | |
3063 child1->SetHasRenderSurface(true); | |
3064 child2->SetHasRenderSurface(true); | |
3065 ExecuteCalculateDrawProperties(root); | 3013 ExecuteCalculateDrawProperties(root); |
3066 EXPECT_EQ(gfx::Rect(100, 100), root->visible_layer_rect()); | 3014 EXPECT_EQ(gfx::Rect(100, 100), root->visible_layer_rect()); |
3067 EXPECT_EQ(gfx::Rect(98, 98), parent->visible_layer_rect()); | 3015 EXPECT_EQ(gfx::Rect(98, 98), parent->visible_layer_rect()); |
3068 EXPECT_EQ(gfx::Rect(94, 94), child1->visible_layer_rect()); | 3016 EXPECT_EQ(gfx::Rect(94, 94), child1->visible_layer_rect()); |
3069 EXPECT_EQ(gfx::Rect(95, 95), child2->visible_layer_rect()); | 3017 EXPECT_EQ(gfx::Rect(95, 95), child2->visible_layer_rect()); |
3070 EXPECT_EQ(gfx::Rect(86, 86), grand_child1->visible_layer_rect()); | 3018 EXPECT_EQ(gfx::Rect(86, 86), grand_child1->visible_layer_rect()); |
3071 EXPECT_EQ(gfx::Rect(88, 88), grand_child2->visible_layer_rect()); | 3019 EXPECT_EQ(gfx::Rect(88, 88), grand_child2->visible_layer_rect()); |
3072 EXPECT_EQ(gfx::Rect(70, 70), leaf_node1->visible_layer_rect()); | 3020 EXPECT_EQ(gfx::Rect(70, 70), leaf_node1->visible_layer_rect()); |
3073 EXPECT_EQ(gfx::Rect(79, 79), leaf_node2->visible_layer_rect()); | 3021 EXPECT_EQ(gfx::Rect(79, 79), leaf_node2->visible_layer_rect()); |
3074 | 3022 |
(...skipping 27 matching lines...) Expand all Loading... |
3102 | 3050 |
3103 parent->SetMasksToBounds(false); | 3051 parent->SetMasksToBounds(false); |
3104 | 3052 |
3105 // Case 3: child1 and grand_child2 clip. In this case, descendants of these | 3053 // Case 3: child1 and grand_child2 clip. In this case, descendants of these |
3106 // layers have their visible rects clipped by them; without surfaces, these | 3054 // layers have their visible rects clipped by them; without surfaces, these |
3107 // rects are also clipped by the viewport. Similarly, descendants of these | 3055 // rects are also clipped by the viewport. Similarly, descendants of these |
3108 // layers have their drawable content rects clipped by them. | 3056 // layers have their drawable content rects clipped by them. |
3109 child1->SetMasksToBounds(true); | 3057 child1->SetMasksToBounds(true); |
3110 grand_child2->SetMasksToBounds(true); | 3058 grand_child2->SetMasksToBounds(true); |
3111 host_impl()->active_tree()->property_trees()->needs_rebuild = true; | 3059 host_impl()->active_tree()->property_trees()->needs_rebuild = true; |
3112 root->SetHasRenderSurface(true); | |
3113 child1->SetHasRenderSurface(true); | |
3114 child2->SetHasRenderSurface(true); | |
3115 ExecuteCalculateDrawProperties(root); | 3060 ExecuteCalculateDrawProperties(root); |
3116 EXPECT_EQ(gfx::Rect(100, 100), root->visible_layer_rect()); | 3061 EXPECT_EQ(gfx::Rect(100, 100), root->visible_layer_rect()); |
3117 EXPECT_EQ(gfx::Rect(98, 98), parent->visible_layer_rect()); | 3062 EXPECT_EQ(gfx::Rect(98, 98), parent->visible_layer_rect()); |
3118 EXPECT_EQ(gfx::Rect(800, 800), child1->visible_layer_rect()); | 3063 EXPECT_EQ(gfx::Rect(800, 800), child1->visible_layer_rect()); |
3119 EXPECT_EQ(gfx::Rect(800, 800), child2->visible_layer_rect()); | 3064 EXPECT_EQ(gfx::Rect(800, 800), child2->visible_layer_rect()); |
3120 EXPECT_EQ(gfx::Rect(792, 792), grand_child1->visible_layer_rect()); | 3065 EXPECT_EQ(gfx::Rect(792, 792), grand_child1->visible_layer_rect()); |
3121 EXPECT_EQ(gfx::Rect(1500, 1500), grand_child2->visible_layer_rect()); | 3066 EXPECT_EQ(gfx::Rect(1500, 1500), grand_child2->visible_layer_rect()); |
3122 EXPECT_EQ(gfx::Rect(776, 776), leaf_node1->visible_layer_rect()); | 3067 EXPECT_EQ(gfx::Rect(776, 776), leaf_node1->visible_layer_rect()); |
3123 EXPECT_EQ(gfx::Rect(1491, 1491), leaf_node2->visible_layer_rect()); | 3068 EXPECT_EQ(gfx::Rect(1491, 1491), leaf_node2->visible_layer_rect()); |
3124 | 3069 |
(...skipping 996 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4121 front_facing_child_of_front_facing_surface->id())); | 4066 front_facing_child_of_front_facing_surface->id())); |
4122 EXPECT_TRUE( | 4067 EXPECT_TRUE( |
4123 UpdateLayerListContains(front_facing_child_of_back_facing_surface->id())); | 4068 UpdateLayerListContains(front_facing_child_of_back_facing_surface->id())); |
4124 } | 4069 } |
4125 | 4070 |
4126 TEST_F(LayerTreeHostCommonTest, BackFaceCullingWithPreserves3d) { | 4071 TEST_F(LayerTreeHostCommonTest, BackFaceCullingWithPreserves3d) { |
4127 // Verify the behavior of back-face culling when preserves-3d transform style | 4072 // Verify the behavior of back-face culling when preserves-3d transform style |
4128 // is used. | 4073 // is used. |
4129 | 4074 |
4130 const gfx::Transform identity_matrix; | 4075 const gfx::Transform identity_matrix; |
4131 LayerImpl* parent = root_layer(); | 4076 scoped_refptr<Layer> parent = Layer::Create(layer_settings()); |
4132 LayerImpl* front_facing_child = AddChildToRoot<LayerImpl>(); | 4077 scoped_refptr<LayerWithForcedDrawsContent> front_facing_child = |
4133 LayerImpl* back_facing_child = AddChildToRoot<LayerImpl>(); | 4078 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings())); |
4134 LayerImpl* front_facing_surface = AddChildToRoot<LayerImpl>(); | 4079 scoped_refptr<LayerWithForcedDrawsContent> back_facing_child = |
4135 LayerImpl* back_facing_surface = AddChildToRoot<LayerImpl>(); | 4080 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings())); |
4136 LayerImpl* front_facing_child_of_front_facing_surface = | 4081 scoped_refptr<LayerWithForcedDrawsContent> front_facing_surface = |
4137 AddChild<LayerImpl>(front_facing_surface); | 4082 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings())); |
4138 LayerImpl* back_facing_child_of_front_facing_surface = | 4083 scoped_refptr<LayerWithForcedDrawsContent> back_facing_surface = |
4139 AddChild<LayerImpl>(front_facing_surface); | 4084 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings())); |
4140 LayerImpl* front_facing_child_of_back_facing_surface = | 4085 scoped_refptr<LayerWithForcedDrawsContent> |
4141 AddChild<LayerImpl>(back_facing_surface); | 4086 front_facing_child_of_front_facing_surface = |
4142 LayerImpl* back_facing_child_of_back_facing_surface = | 4087 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings())); |
4143 AddChild<LayerImpl>(back_facing_surface); | 4088 scoped_refptr<LayerWithForcedDrawsContent> |
4144 // Opacity will not force creation of render surfaces in this case because of | 4089 back_facing_child_of_front_facing_surface = |
4145 // the preserve-3d transform style. Instead, an example of when a surface | 4090 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings())); |
4146 // would be created with preserve-3d is when there is a replica layer. | 4091 scoped_refptr<LayerWithForcedDrawsContent> |
4147 LayerImpl* dummy_replica_layer1 = | 4092 front_facing_child_of_back_facing_surface = |
4148 AddReplicaLayer<LayerImpl>(front_facing_surface); | 4093 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings())); |
4149 LayerImpl* dummy_replica_layer2 = | 4094 scoped_refptr<LayerWithForcedDrawsContent> |
4150 AddReplicaLayer<LayerImpl>(back_facing_surface); | 4095 back_facing_child_of_back_facing_surface = |
| 4096 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings())); |
| 4097 scoped_refptr<LayerWithForcedDrawsContent> dummy_replica_layer1 = |
| 4098 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings())); |
| 4099 scoped_refptr<LayerWithForcedDrawsContent> dummy_replica_layer2 = |
| 4100 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings())); |
| 4101 |
| 4102 parent->AddChild(front_facing_child); |
| 4103 parent->AddChild(back_facing_child); |
| 4104 parent->AddChild(front_facing_surface); |
| 4105 parent->AddChild(back_facing_surface); |
| 4106 front_facing_surface->AddChild(front_facing_child_of_front_facing_surface); |
| 4107 front_facing_surface->AddChild(back_facing_child_of_front_facing_surface); |
| 4108 back_facing_surface->AddChild(front_facing_child_of_back_facing_surface); |
| 4109 back_facing_surface->AddChild(back_facing_child_of_back_facing_surface); |
| 4110 |
| 4111 host()->SetRootLayer(parent); |
4151 | 4112 |
4152 // Nothing is double-sided | 4113 // Nothing is double-sided |
4153 front_facing_child->SetDoubleSided(false); | 4114 front_facing_child->SetDoubleSided(false); |
4154 back_facing_child->SetDoubleSided(false); | 4115 back_facing_child->SetDoubleSided(false); |
4155 front_facing_surface->SetDoubleSided(false); | 4116 front_facing_surface->SetDoubleSided(false); |
4156 back_facing_surface->SetDoubleSided(false); | 4117 back_facing_surface->SetDoubleSided(false); |
4157 front_facing_child_of_front_facing_surface->SetDoubleSided(false); | 4118 front_facing_child_of_front_facing_surface->SetDoubleSided(false); |
4158 back_facing_child_of_front_facing_surface->SetDoubleSided(false); | 4119 back_facing_child_of_front_facing_surface->SetDoubleSided(false); |
4159 front_facing_child_of_back_facing_surface->SetDoubleSided(false); | 4120 front_facing_child_of_back_facing_surface->SetDoubleSided(false); |
4160 back_facing_child_of_back_facing_surface->SetDoubleSided(false); | 4121 back_facing_child_of_back_facing_surface->SetDoubleSided(false); |
4161 | 4122 |
4162 // Everything draws content. | |
4163 front_facing_child->SetDrawsContent(true); | |
4164 back_facing_child->SetDrawsContent(true); | |
4165 front_facing_surface->SetDrawsContent(true); | |
4166 back_facing_surface->SetDrawsContent(true); | |
4167 front_facing_child_of_front_facing_surface->SetDrawsContent(true); | |
4168 back_facing_child_of_front_facing_surface->SetDrawsContent(true); | |
4169 front_facing_child_of_back_facing_surface->SetDrawsContent(true); | |
4170 back_facing_child_of_back_facing_surface->SetDrawsContent(true); | |
4171 dummy_replica_layer1->SetDrawsContent(true); | |
4172 dummy_replica_layer2->SetDrawsContent(true); | |
4173 | |
4174 gfx::Transform backface_matrix; | 4123 gfx::Transform backface_matrix; |
4175 backface_matrix.Translate(50.0, 50.0); | 4124 backface_matrix.Translate(50.0, 50.0); |
4176 backface_matrix.RotateAboutYAxis(180.0); | 4125 backface_matrix.RotateAboutYAxis(180.0); |
4177 backface_matrix.Translate(-50.0, -50.0); | 4126 backface_matrix.Translate(-50.0, -50.0); |
4178 | 4127 |
| 4128 // Opacity will not force creation of render surfaces in this case because of |
| 4129 // the preserve-3d transform style. Instead, an example of when a surface |
| 4130 // would be created with preserve-3d is when there is a replica layer. |
| 4131 front_facing_surface->SetReplicaLayer(dummy_replica_layer1.get()); |
| 4132 back_facing_surface->SetReplicaLayer(dummy_replica_layer2.get()); |
| 4133 |
4179 // Each surface creates its own new 3d rendering context (as defined by W3C | 4134 // Each surface creates its own new 3d rendering context (as defined by W3C |
4180 // spec). According to current W3C CSS gfx::Transforms spec, layers in a 3d | 4135 // spec). According to current W3C CSS gfx::Transforms spec, layers in a 3d |
4181 // rendering context should use the transform with respect to that context. | 4136 // rendering context should use the transform with respect to that context. |
4182 // This 3d rendering context occurs when (a) parent's transform style is flat | 4137 // This 3d rendering context occurs when (a) parent's transform style is flat |
4183 // and (b) the layer's transform style is preserve-3d. | 4138 // and (b) the layer's transform style is preserve-3d. |
4184 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(), | 4139 SetLayerPropertiesForTesting(parent.get(), identity_matrix, gfx::Point3F(), |
4185 gfx::PointF(), gfx::Size(100, 100), true, | 4140 gfx::PointF(), gfx::Size(100, 100), true, |
4186 false); // parent transform style is flat. | 4141 false); // parent transform style is flat. |
4187 SetLayerPropertiesForTesting(front_facing_child, identity_matrix, | 4142 SetLayerPropertiesForTesting(front_facing_child.get(), identity_matrix, |
4188 gfx::Point3F(), gfx::PointF(), | 4143 gfx::Point3F(), gfx::PointF(), |
4189 gfx::Size(100, 100), true, false); | 4144 gfx::Size(100, 100), true, false); |
4190 SetLayerPropertiesForTesting(back_facing_child, backface_matrix, | 4145 SetLayerPropertiesForTesting(back_facing_child.get(), backface_matrix, |
4191 gfx::Point3F(), gfx::PointF(), | 4146 gfx::Point3F(), gfx::PointF(), |
4192 gfx::Size(100, 100), true, false); | 4147 gfx::Size(100, 100), true, false); |
4193 // surface transform style is preserve-3d. | 4148 // surface transform style is preserve-3d. |
4194 SetLayerPropertiesForTesting(front_facing_surface, identity_matrix, | 4149 SetLayerPropertiesForTesting(front_facing_surface.get(), identity_matrix, |
4195 gfx::Point3F(), gfx::PointF(), | 4150 gfx::Point3F(), gfx::PointF(), |
4196 gfx::Size(100, 100), false, true); | 4151 gfx::Size(100, 100), false, true); |
4197 // surface transform style is preserve-3d. | 4152 // surface transform style is preserve-3d. |
4198 SetLayerPropertiesForTesting(back_facing_surface, backface_matrix, | 4153 SetLayerPropertiesForTesting(back_facing_surface.get(), backface_matrix, |
4199 gfx::Point3F(), gfx::PointF(), | 4154 gfx::Point3F(), gfx::PointF(), |
4200 gfx::Size(100, 100), false, true); | 4155 gfx::Size(100, 100), false, true); |
4201 SetLayerPropertiesForTesting(front_facing_child_of_front_facing_surface, | 4156 SetLayerPropertiesForTesting(front_facing_child_of_front_facing_surface.get(), |
4202 identity_matrix, gfx::Point3F(), gfx::PointF(), | 4157 identity_matrix, gfx::Point3F(), gfx::PointF(), |
4203 gfx::Size(100, 100), true, true); | 4158 gfx::Size(100, 100), true, true); |
4204 SetLayerPropertiesForTesting(back_facing_child_of_front_facing_surface, | 4159 SetLayerPropertiesForTesting(back_facing_child_of_front_facing_surface.get(), |
4205 backface_matrix, gfx::Point3F(), gfx::PointF(), | 4160 backface_matrix, gfx::Point3F(), gfx::PointF(), |
4206 gfx::Size(100, 100), true, true); | 4161 gfx::Size(100, 100), true, true); |
4207 SetLayerPropertiesForTesting(front_facing_child_of_back_facing_surface, | 4162 SetLayerPropertiesForTesting(front_facing_child_of_back_facing_surface.get(), |
4208 identity_matrix, gfx::Point3F(), gfx::PointF(), | 4163 identity_matrix, gfx::Point3F(), gfx::PointF(), |
4209 gfx::Size(100, 100), true, true); | 4164 gfx::Size(100, 100), true, true); |
4210 SetLayerPropertiesForTesting(back_facing_child_of_back_facing_surface, | 4165 SetLayerPropertiesForTesting(back_facing_child_of_back_facing_surface.get(), |
4211 backface_matrix, gfx::Point3F(), gfx::PointF(), | 4166 backface_matrix, gfx::Point3F(), gfx::PointF(), |
4212 gfx::Size(100, 100), true, true); | 4167 gfx::Size(100, 100), true, true); |
4213 | 4168 |
4214 ExecuteCalculateDrawPropertiesWithPropertyTrees(parent); | 4169 ExecuteCalculateDrawPropertiesWithPropertyTrees(parent.get()); |
4215 | 4170 |
4216 // Verify which render surfaces were created and used. | 4171 // Verify which render surfaces were created and used. |
4217 EXPECT_FALSE(front_facing_child->has_render_surface()); | 4172 EXPECT_FALSE(front_facing_child->has_render_surface()); |
4218 EXPECT_FALSE(back_facing_child->has_render_surface()); | 4173 EXPECT_FALSE(back_facing_child->has_render_surface()); |
4219 EXPECT_TRUE(front_facing_surface->has_render_surface()); | 4174 EXPECT_TRUE(front_facing_surface->has_render_surface()); |
4220 // We expect that a has_render_surface was created but not used. | 4175 // We expect that a has_render_surface was created but not used. |
4221 EXPECT_TRUE(back_facing_surface->has_render_surface()); | 4176 EXPECT_TRUE(back_facing_surface->has_render_surface()); |
4222 EXPECT_FALSE( | 4177 EXPECT_FALSE( |
4223 front_facing_child_of_front_facing_surface->has_render_surface()); | 4178 front_facing_child_of_front_facing_surface->has_render_surface()); |
4224 EXPECT_FALSE(back_facing_child_of_front_facing_surface->has_render_surface()); | 4179 EXPECT_FALSE(back_facing_child_of_front_facing_surface->has_render_surface()); |
4225 EXPECT_FALSE(front_facing_child_of_back_facing_surface->has_render_surface()); | 4180 EXPECT_FALSE(front_facing_child_of_back_facing_surface->has_render_surface()); |
4226 EXPECT_FALSE(back_facing_child_of_back_facing_surface->has_render_surface()); | 4181 EXPECT_FALSE(back_facing_child_of_back_facing_surface->has_render_surface()); |
4227 | 4182 |
4228 EXPECT_EQ(3u, update_layer_list_impl()->size()); | 4183 EXPECT_EQ(3u, update_layer_list().size()); |
4229 | 4184 |
4230 EXPECT_TRUE(UpdateLayerListImplContains(front_facing_child->id())); | 4185 EXPECT_TRUE(UpdateLayerListContains(front_facing_child->id())); |
4231 EXPECT_TRUE(UpdateLayerListImplContains(front_facing_surface->id())); | 4186 EXPECT_TRUE(UpdateLayerListContains(front_facing_surface->id())); |
4232 EXPECT_TRUE(UpdateLayerListImplContains( | 4187 EXPECT_TRUE(UpdateLayerListContains( |
4233 front_facing_child_of_front_facing_surface->id())); | 4188 front_facing_child_of_front_facing_surface->id())); |
4234 } | 4189 } |
4235 | 4190 |
4236 TEST_F(LayerTreeHostCommonTest, BackFaceCullingWithAnimatingTransforms) { | 4191 TEST_F(LayerTreeHostCommonTest, BackFaceCullingWithAnimatingTransforms) { |
4237 // Verify that layers are appropriately culled when their back face is showing | 4192 // Verify that layers are appropriately culled when their back face is showing |
4238 // and they are not double sided, while animations are going on. | 4193 // and they are not double sided, while animations are going on. |
4239 // | 4194 // |
4240 // Layers that are animating do not get culled on the main thread, as their | 4195 // Layers that are animating do not get culled on the main thread, as their |
4241 // transforms should be treated as "unknown" so we can not be sure that their | 4196 // transforms should be treated as "unknown" so we can not be sure that their |
4242 // back face is really showing. | 4197 // back face is really showing. |
(...skipping 1727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5970 | 5925 |
5971 // Sanity check our num_unclipped_descendants values. | 5926 // Sanity check our num_unclipped_descendants values. |
5972 EXPECT_EQ(1u, render_surface1->num_unclipped_descendants()); | 5927 EXPECT_EQ(1u, render_surface1->num_unclipped_descendants()); |
5973 EXPECT_EQ(0u, render_surface2->num_unclipped_descendants()); | 5928 EXPECT_EQ(0u, render_surface2->num_unclipped_descendants()); |
5974 } | 5929 } |
5975 | 5930 |
5976 TEST_F(LayerTreeHostCommonTest, | 5931 TEST_F(LayerTreeHostCommonTest, |
5977 CreateRenderSurfaceWhenFlattenInsideRenderingContext) { | 5932 CreateRenderSurfaceWhenFlattenInsideRenderingContext) { |
5978 // Verifies that Render Surfaces are created at the edge of rendering context. | 5933 // Verifies that Render Surfaces are created at the edge of rendering context. |
5979 | 5934 |
5980 LayerImpl* root = root_layer(); | 5935 scoped_refptr<LayerWithForcedDrawsContent> parent = |
5981 LayerImpl* child1 = AddChildToRoot<LayerImpl>(); | 5936 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings())); |
5982 LayerImpl* child2 = AddChild<LayerImpl>(child1); | 5937 Layer* root = parent.get(); |
5983 LayerImpl* child3 = AddChild<LayerImpl>(child2); | 5938 scoped_refptr<LayerWithForcedDrawsContent> child_1 = |
5984 root->SetDrawsContent(true); | 5939 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings())); |
| 5940 Layer* child1 = child_1.get(); |
| 5941 scoped_refptr<LayerWithForcedDrawsContent> child_2 = |
| 5942 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings())); |
| 5943 Layer* child2 = child_2.get(); |
| 5944 scoped_refptr<LayerWithForcedDrawsContent> child_3 = |
| 5945 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings())); |
| 5946 Layer* child3 = child_3.get(); |
| 5947 |
| 5948 parent->AddChild(std::move(child_1)); |
| 5949 child1->AddChild(std::move(child_2)); |
| 5950 child2->AddChild(std::move(child_3)); |
| 5951 |
| 5952 host()->SetRootLayer(root); |
5985 | 5953 |
5986 const gfx::Transform identity_matrix; | 5954 const gfx::Transform identity_matrix; |
5987 gfx::Point3F transform_origin; | 5955 gfx::Point3F transform_origin; |
5988 gfx::PointF position; | 5956 gfx::PointF position; |
5989 gfx::Size bounds(100, 100); | 5957 gfx::Size bounds(100, 100); |
5990 | 5958 |
5991 SetLayerPropertiesForTesting(root, identity_matrix, transform_origin, | 5959 SetLayerPropertiesForTesting(root, identity_matrix, transform_origin, |
5992 position, bounds, true, false); | 5960 position, bounds, true, false); |
5993 SetLayerPropertiesForTesting(child1, identity_matrix, transform_origin, | 5961 SetLayerPropertiesForTesting(child1, identity_matrix, transform_origin, |
5994 position, bounds, false, true); | 5962 position, bounds, false, true); |
5995 child1->SetDrawsContent(true); | |
5996 SetLayerPropertiesForTesting(child2, identity_matrix, transform_origin, | 5963 SetLayerPropertiesForTesting(child2, identity_matrix, transform_origin, |
5997 position, bounds, true, false); | 5964 position, bounds, true, false); |
5998 child2->SetDrawsContent(true); | |
5999 SetLayerPropertiesForTesting(child3, identity_matrix, transform_origin, | 5965 SetLayerPropertiesForTesting(child3, identity_matrix, transform_origin, |
6000 position, bounds, true, false); | 5966 position, bounds, true, false); |
6001 child3->SetDrawsContent(true); | |
6002 | 5967 |
6003 child2->Set3dSortingContextId(1); | 5968 child2->Set3dSortingContextId(1); |
6004 child3->Set3dSortingContextId(1); | 5969 child3->Set3dSortingContextId(1); |
6005 | 5970 |
6006 ExecuteCalculateDrawPropertiesWithPropertyTrees(root); | 5971 ExecuteCalculateDrawPropertiesWithPropertyTrees(parent.get()); |
6007 | 5972 |
6008 // Verify which render surfaces were created. | 5973 // Verify which render surfaces were created. |
6009 EXPECT_TRUE(root->has_render_surface()); | 5974 EXPECT_TRUE(root->has_render_surface()); |
6010 EXPECT_FALSE(child1->has_render_surface()); | 5975 EXPECT_FALSE(child1->has_render_surface()); |
6011 EXPECT_TRUE(child2->has_render_surface()); | 5976 EXPECT_TRUE(child2->has_render_surface()); |
6012 EXPECT_FALSE(child3->has_render_surface()); | 5977 EXPECT_FALSE(child3->has_render_surface()); |
6013 } | 5978 } |
6014 | 5979 |
6015 TEST_F(LayerTreeHostCommonTest, CanRenderToSeparateSurface) { | 5980 TEST_F(LayerTreeHostCommonTest, CanRenderToSeparateSurface) { |
6016 FakeImplTaskRunnerProvider task_runner_provider; | 5981 FakeImplTaskRunnerProvider task_runner_provider; |
6017 TestSharedBitmapManager shared_bitmap_manager; | 5982 TestSharedBitmapManager shared_bitmap_manager; |
6018 TestTaskGraphRunner task_graph_runner; | 5983 TestTaskGraphRunner task_graph_runner; |
6019 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, | 5984 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, |
6020 &task_graph_runner); | 5985 &task_graph_runner); |
6021 | |
6022 scoped_ptr<LayerImpl> root = | 5986 scoped_ptr<LayerImpl> root = |
6023 LayerImpl::Create(host_impl.active_tree(), 12345); | 5987 LayerImpl::Create(host_impl.active_tree(), 12345); |
6024 scoped_ptr<LayerImpl> child1 = | 5988 scoped_ptr<LayerImpl> child1 = |
6025 LayerImpl::Create(host_impl.active_tree(), 123456); | 5989 LayerImpl::Create(host_impl.active_tree(), 123456); |
6026 scoped_ptr<LayerImpl> child2 = | 5990 scoped_ptr<LayerImpl> child2 = |
6027 LayerImpl::Create(host_impl.active_tree(), 1234567); | 5991 LayerImpl::Create(host_impl.active_tree(), 1234567); |
6028 scoped_ptr<LayerImpl> child3 = | 5992 scoped_ptr<LayerImpl> child3 = |
6029 LayerImpl::Create(host_impl.active_tree(), 12345678); | 5993 LayerImpl::Create(host_impl.active_tree(), 12345678); |
6030 | 5994 |
6031 gfx::Transform identity_matrix; | 5995 gfx::Transform identity_matrix; |
(...skipping 1474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7506 | 7470 |
7507 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl.active_tree(), 1); | 7471 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl.active_tree(), 1); |
7508 LayerImpl* root_layer = root.get(); | 7472 LayerImpl* root_layer = root.get(); |
7509 scoped_ptr<LayerImpl> child1 = LayerImpl::Create(host_impl.active_tree(), 2); | 7473 scoped_ptr<LayerImpl> child1 = LayerImpl::Create(host_impl.active_tree(), 2); |
7510 LayerImpl* child1_layer = child1.get(); | 7474 LayerImpl* child1_layer = child1.get(); |
7511 scoped_ptr<LayerImpl> child2 = LayerImpl::Create(host_impl.active_tree(), 3); | 7475 scoped_ptr<LayerImpl> child2 = LayerImpl::Create(host_impl.active_tree(), 3); |
7512 LayerImpl* child2_layer = child2.get(); | 7476 LayerImpl* child2_layer = child2.get(); |
7513 | 7477 |
7514 root->AddChild(std::move(child1)); | 7478 root->AddChild(std::move(child1)); |
7515 root->AddChild(std::move(child2)); | 7479 root->AddChild(std::move(child2)); |
7516 root->SetForceRenderSurface(true); | 7480 root->SetHasRenderSurface(true); |
7517 root->SetDrawsContent(true); | 7481 root->SetDrawsContent(true); |
7518 | 7482 |
7519 gfx::Transform identity_matrix, scale_transform_child1, | 7483 gfx::Transform identity_matrix, scale_transform_child1, |
7520 scale_transform_child2; | 7484 scale_transform_child2; |
7521 scale_transform_child1.Scale(2, 3); | 7485 scale_transform_child1.Scale(2, 3); |
7522 scale_transform_child2.Scale(4, 5); | 7486 scale_transform_child2.Scale(4, 5); |
7523 | 7487 |
7524 SetLayerPropertiesForTesting(root_layer, identity_matrix, gfx::Point3F(), | 7488 SetLayerPropertiesForTesting(root_layer, identity_matrix, gfx::Point3F(), |
7525 gfx::PointF(), gfx::Size(1, 1), true, false, | 7489 gfx::PointF(), gfx::Size(1, 1), true, false, |
7526 true); | 7490 true); |
7527 SetLayerPropertiesForTesting(child1_layer, scale_transform_child1, | 7491 SetLayerPropertiesForTesting(child1_layer, scale_transform_child1, |
7528 gfx::Point3F(), gfx::PointF(), gfx::Size(1, 1), | 7492 gfx::Point3F(), gfx::PointF(), gfx::Size(1, 1), |
7529 true, false, false); | 7493 true, false, false); |
7530 | 7494 |
7531 child1_layer->SetMaskLayer(LayerImpl::Create(host_impl.active_tree(), 4)); | 7495 child1_layer->SetMaskLayer(LayerImpl::Create(host_impl.active_tree(), 4)); |
7532 child1_layer->SetDrawsContent(true); | 7496 child1_layer->SetDrawsContent(true); |
7533 | 7497 |
7534 scoped_ptr<LayerImpl> replica_layer = | 7498 scoped_ptr<LayerImpl> replica_layer = |
7535 LayerImpl::Create(host_impl.active_tree(), 5); | 7499 LayerImpl::Create(host_impl.active_tree(), 5); |
| 7500 replica_layer->SetHasRenderSurface(true); |
7536 replica_layer->SetMaskLayer(LayerImpl::Create(host_impl.active_tree(), 6)); | 7501 replica_layer->SetMaskLayer(LayerImpl::Create(host_impl.active_tree(), 6)); |
7537 child1_layer->SetReplicaLayer(std::move(replica_layer)); | 7502 child1_layer->SetReplicaLayer(std::move(replica_layer)); |
7538 child1_layer->SetHasRenderSurface(true); | 7503 child1_layer->SetHasRenderSurface(true); |
7539 | 7504 |
7540 ExecuteCalculateDrawProperties(root_layer); | 7505 ExecuteCalculateDrawProperties(root_layer); |
7541 | 7506 |
7542 TransformOperations scale; | 7507 TransformOperations scale; |
7543 scale.AppendScale(5.f, 8.f, 3.f); | 7508 scale.AppendScale(5.f, 8.f, 3.f); |
7544 | 7509 |
7545 AddAnimatedTransformToLayer(child2_layer, 1.0, TransformOperations(), scale); | 7510 AddAnimatedTransformToLayer(child2_layer, 1.0, TransformOperations(), scale); |
(...skipping 1194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8740 transform1.RotateAboutXAxis(30); | 8705 transform1.RotateAboutXAxis(30); |
8741 // This transform should be a 3d transform as we want the render surface | 8706 // This transform should be a 3d transform as we want the render surface |
8742 // to flatten the transform | 8707 // to flatten the transform |
8743 gfx::Transform transform2; | 8708 gfx::Transform transform2; |
8744 transform2.Translate3d(10, 10, 10); | 8709 transform2.Translate3d(10, 10, 10); |
8745 | 8710 |
8746 layer_clips_subtree->SetMasksToBounds(true); | 8711 layer_clips_subtree->SetMasksToBounds(true); |
8747 test_layer->SetDrawsContent(true); | 8712 test_layer->SetDrawsContent(true); |
8748 | 8713 |
8749 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), | 8714 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), |
8750 gfx::PointF(), gfx::Size(30, 30), true, false); | 8715 gfx::PointF(), gfx::Size(30, 30), true, false, |
| 8716 true); |
8751 SetLayerPropertiesForTesting(significant_transform, transform1, | 8717 SetLayerPropertiesForTesting(significant_transform, transform1, |
8752 gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30), | 8718 gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30), |
8753 true, false); | 8719 true, false, false); |
8754 SetLayerPropertiesForTesting(layer_clips_subtree, identity_matrix, | 8720 SetLayerPropertiesForTesting(layer_clips_subtree, identity_matrix, |
8755 gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30), | 8721 gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30), |
8756 true, false); | 8722 true, false, false); |
8757 SetLayerPropertiesForTesting(render_surface, transform2, gfx::Point3F(), | 8723 SetLayerPropertiesForTesting(render_surface, transform2, gfx::Point3F(), |
8758 gfx::PointF(), gfx::Size(30, 30), true, false); | 8724 gfx::PointF(), gfx::Size(30, 30), true, false, |
| 8725 true); |
8759 SetLayerPropertiesForTesting(test_layer, identity_matrix, gfx::Point3F(), | 8726 SetLayerPropertiesForTesting(test_layer, identity_matrix, gfx::Point3F(), |
8760 gfx::PointF(), gfx::Size(30, 30), true, false); | 8727 gfx::PointF(), gfx::Size(30, 30), true, false, |
| 8728 false); |
8761 | 8729 |
8762 root->SetForceRenderSurface(true); | |
8763 significant_transform->SetForceRenderSurface(false); | |
8764 layer_clips_subtree->SetForceRenderSurface(true); | |
8765 render_surface->SetForceRenderSurface(true); | |
8766 test_layer->SetForceRenderSurface(false); | |
8767 ExecuteCalculateDrawProperties(root); | 8730 ExecuteCalculateDrawProperties(root); |
8768 | 8731 |
8769 TransformTree transform_tree = | 8732 TransformTree transform_tree = |
8770 root->layer_tree_impl()->property_trees()->transform_tree; | 8733 root->layer_tree_impl()->property_trees()->transform_tree; |
8771 TransformNode* transform_node = | 8734 TransformNode* transform_node = |
8772 transform_tree.Node(significant_transform->transform_tree_index()); | 8735 transform_tree.Node(significant_transform->transform_tree_index()); |
8773 EXPECT_EQ(transform_node->owner_id, significant_transform->id()); | 8736 EXPECT_EQ(transform_node->owner_id, significant_transform->id()); |
8774 | 8737 |
8775 EXPECT_TRUE(root->has_render_surface()); | |
8776 EXPECT_FALSE(significant_transform->has_render_surface()); | |
8777 EXPECT_TRUE(layer_clips_subtree->has_render_surface()); | |
8778 EXPECT_TRUE(render_surface->has_render_surface()); | |
8779 EXPECT_FALSE(test_layer->has_render_surface()); | |
8780 | |
8781 ClipTree clip_tree = root->layer_tree_impl()->property_trees()->clip_tree; | 8738 ClipTree clip_tree = root->layer_tree_impl()->property_trees()->clip_tree; |
8782 ClipNode* clip_node = clip_tree.Node(render_surface->clip_tree_index()); | 8739 ClipNode* clip_node = clip_tree.Node(render_surface->clip_tree_index()); |
8783 EXPECT_FALSE(clip_node->data.applies_local_clip); | 8740 EXPECT_FALSE(clip_node->data.applies_local_clip); |
8784 EXPECT_EQ(gfx::Rect(22, 21), test_layer->visible_rect_from_property_trees()); | 8741 EXPECT_EQ(gfx::Rect(30, 21), test_layer->visible_rect_from_property_trees()); |
8785 } | 8742 } |
8786 | 8743 |
8787 TEST_F(LayerTreeHostCommonTest, TransformOfParentClipNodeAncestorOfTarget) { | 8744 TEST_F(LayerTreeHostCommonTest, TransformOfParentClipNodeAncestorOfTarget) { |
8788 // Ensure that when parent clip node's transform is an ancestor of current | 8745 // Ensure that when parent clip node's transform is an ancestor of current |
8789 // clip node's target, clip is 'projected' from parent space to current | 8746 // clip node's target, clip is 'projected' from parent space to current |
8790 // target space and visible rects are calculated correctly. | 8747 // target space and visible rects are calculated correctly. |
8791 LayerImpl* root = root_layer(); | 8748 LayerImpl* root = root_layer(); |
8792 LayerImpl* clip_layer = AddChild<LayerImpl>(root); | 8749 LayerImpl* clip_layer = AddChild<LayerImpl>(root); |
8793 LayerImpl* target_layer = AddChild<LayerImpl>(clip_layer); | 8750 LayerImpl* target_layer = AddChild<LayerImpl>(clip_layer); |
8794 LayerImpl* test_layer = AddChild<LayerImpl>(target_layer); | 8751 LayerImpl* test_layer = AddChild<LayerImpl>(target_layer); |
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9303 bool root_in_rsll = | 9260 bool root_in_rsll = |
9304 std::find(rsll->begin(), rsll->end(), root) != rsll->end(); | 9261 std::find(rsll->begin(), rsll->end(), root) != rsll->end(); |
9305 EXPECT_TRUE(root_in_rsll); | 9262 EXPECT_TRUE(root_in_rsll); |
9306 bool render_surface2_in_rsll = | 9263 bool render_surface2_in_rsll = |
9307 std::find(rsll->begin(), rsll->end(), render_surface2) != rsll->end(); | 9264 std::find(rsll->begin(), rsll->end(), render_surface2) != rsll->end(); |
9308 EXPECT_FALSE(render_surface2_in_rsll); | 9265 EXPECT_FALSE(render_surface2_in_rsll); |
9309 } | 9266 } |
9310 | 9267 |
9311 } // namespace | 9268 } // namespace |
9312 } // namespace cc | 9269 } // namespace cc |
OLD | NEW |