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

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

Issue 1491033002: Create RenderSurface on Effect Tree (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@alwayspt
Patch Set: rebase on master Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 146
147 TEST_F(LayerTreeHostCommonTest, DoNotSkipLayersWithHandlers) { 147 TEST_F(LayerTreeHostCommonTest, DoNotSkipLayersWithHandlers) {
148 LayerImpl* parent = root_layer(); 148 LayerImpl* parent = root_layer();
149 LayerImpl* child = AddChild<LayerImpl>(parent); 149 LayerImpl* child = AddChild<LayerImpl>(parent);
150 LayerImpl* grand_child = AddChild<LayerImpl>(child); 150 LayerImpl* grand_child = AddChild<LayerImpl>(child);
151 child->SetDrawsContent(true); 151 child->SetDrawsContent(true);
152 grand_child->SetDrawsContent(true); 152 grand_child->SetDrawsContent(true);
153 153
154 gfx::Transform identity_matrix; 154 gfx::Transform identity_matrix;
155 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(), 155 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(),
156 gfx::PointF(), gfx::Size(100, 100), true, false, 156 gfx::PointF(), gfx::Size(100, 100), true, false);
157 true);
158 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(), 157 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(),
159 gfx::PointF(10, 10), gfx::Size(100, 100), true, 158 gfx::PointF(10, 10), gfx::Size(100, 100), true,
160 false, false); 159 false);
161 // 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
162 // 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
163 // with handlers. 162 // with handlers.
164 child->SetOpacity(0.f); 163 child->SetOpacity(0.f);
165 SetLayerPropertiesForTesting(grand_child, identity_matrix, gfx::Point3F(), 164 SetLayerPropertiesForTesting(grand_child, identity_matrix, gfx::Point3F(),
166 gfx::PointF(10, 10), gfx::Size(100, 100), true, 165 gfx::PointF(10, 10), gfx::Size(100, 100), true,
167 false, false); 166 false);
168 grand_child->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 100, 100)); 167 grand_child->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 100, 100));
169 168
170 ExecuteCalculateDrawProperties(parent); 169 ExecuteCalculateDrawProperties(parent);
171 170
171 EXPECT_TRUE(child->has_render_surface());
172 EXPECT_FALSE(grand_child->has_render_surface());
172 // Check that we've computed draw properties for the subtree rooted at 173 // Check that we've computed draw properties for the subtree rooted at
173 // |child|. 174 // |child|.
174 EXPECT_FALSE(child->draw_properties().target_space_transform.IsIdentity()); 175 EXPECT_TRUE(child->draw_properties().target_space_transform.IsIdentity());
176 EXPECT_FALSE(child->render_surface()->draw_transform().IsIdentity());
175 EXPECT_FALSE( 177 EXPECT_FALSE(
176 grand_child->draw_properties().target_space_transform.IsIdentity()); 178 grand_child->draw_properties().target_space_transform.IsIdentity());
177 } 179 }
178 180
179 TEST_F(LayerTreeHostCommonTest, TransformsForSingleLayer) { 181 TEST_F(LayerTreeHostCommonTest, TransformsForSingleLayer) {
180 gfx::Transform identity_matrix; 182 gfx::Transform identity_matrix;
181 scoped_refptr<Layer> layer = Layer::Create(layer_settings()); 183 scoped_refptr<Layer> layer = Layer::Create(layer_settings());
182 184
183 scoped_refptr<Layer> root = Layer::Create(layer_settings()); 185 scoped_refptr<Layer> root = Layer::Create(layer_settings());
184 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), 186 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(),
(...skipping 1205 matching lines...) Expand 10 before | Expand all | Expand 10 after
1390 EXPECT_EQ(1.f, root->draw_opacity()); 1392 EXPECT_EQ(1.f, root->draw_opacity());
1391 EXPECT_EQ(1.f, parent->draw_opacity()); 1393 EXPECT_EQ(1.f, parent->draw_opacity());
1392 EXPECT_EQ(0.5f, child1->draw_opacity()); 1394 EXPECT_EQ(0.5f, child1->draw_opacity());
1393 EXPECT_EQ(1.f, child2->draw_opacity()); 1395 EXPECT_EQ(1.f, child2->draw_opacity());
1394 EXPECT_EQ(0.25f, grand_child->draw_opacity()); 1396 EXPECT_EQ(0.25f, grand_child->draw_opacity());
1395 EXPECT_EQ(0.125f, leaf_node1->draw_opacity()); 1397 EXPECT_EQ(0.125f, leaf_node1->draw_opacity());
1396 EXPECT_EQ(0.5f, leaf_node2->draw_opacity()); 1398 EXPECT_EQ(0.5f, leaf_node2->draw_opacity());
1397 } 1399 }
1398 1400
1399 TEST_F(LayerTreeHostCommonTest, ForceRenderSurface) { 1401 TEST_F(LayerTreeHostCommonTest, ForceRenderSurface) {
1400 scoped_refptr<Layer> parent = Layer::Create(layer_settings()); 1402 LayerImpl* parent = root_layer();
1401 scoped_refptr<Layer> render_surface1 = Layer::Create(layer_settings()); 1403 LayerImpl* render_surface1 = AddChildToRoot<LayerImpl>();
1402 scoped_refptr<LayerWithForcedDrawsContent> child = 1404 LayerImpl* child = AddChild<LayerImpl>(render_surface1);
1403 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings())); 1405
1406 const gfx::Transform identity_matrix;
1407 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(),
1408 gfx::PointF(), gfx::Size(10, 10), true, false);
1409 SetLayerPropertiesForTesting(render_surface1, identity_matrix, gfx::Point3F(),
1410 gfx::PointF(), gfx::Size(10, 10), true, false);
1411 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(),
1412 gfx::PointF(), gfx::Size(10, 10), true, false);
1413
1414 child->SetDrawsContent(true);
1404 render_surface1->SetForceRenderSurface(true); 1415 render_surface1->SetForceRenderSurface(true);
1405 1416
1406 host()->SetRootLayer(parent);
1407
1408 const gfx::Transform identity_matrix;
1409 SetLayerPropertiesForTesting(parent.get(),
1410 identity_matrix,
1411 gfx::Point3F(),
1412 gfx::PointF(),
1413 gfx::Size(10, 10),
1414 true,
1415 false);
1416 SetLayerPropertiesForTesting(render_surface1.get(),
1417 identity_matrix,
1418 gfx::Point3F(),
1419 gfx::PointF(),
1420 gfx::Size(10, 10),
1421 true,
1422 false);
1423 SetLayerPropertiesForTesting(child.get(),
1424 identity_matrix,
1425 gfx::Point3F(),
1426 gfx::PointF(),
1427 gfx::Size(10, 10),
1428 true,
1429 false);
1430
1431 parent->AddChild(render_surface1);
1432 render_surface1->AddChild(child);
1433
1434 // Sanity check before the actual test
1435 EXPECT_FALSE(parent->has_render_surface());
1436 EXPECT_FALSE(render_surface1->has_render_surface());
1437
1438 { 1417 {
1439 LayerTreeHostCommon::CalcDrawPropsMainInputs inputs(parent.get(), 1418 ExecuteCalculateDrawPropertiesWithPropertyTrees(parent);
1440 parent->bounds());
1441 LayerTreeHostCommon::CalculateDrawProperties(&inputs);
1442 1419
1443 // The root layer always creates a render surface 1420 // The root layer always creates a render surface
1444 EXPECT_TRUE(parent->has_render_surface()); 1421 EXPECT_TRUE(parent->has_render_surface());
1445 EXPECT_TRUE(render_surface1->has_render_surface()); 1422 EXPECT_TRUE(render_surface1->has_render_surface());
1446 } 1423 }
1447 1424
1448 { 1425 {
1449 render_surface1->SetForceRenderSurface(false); 1426 render_surface1->SetForceRenderSurface(false);
1450 LayerTreeHostCommon::CalcDrawPropsMainInputs inputs(parent.get(), 1427 render_surface1->layer_tree_impl()->property_trees()->needs_rebuild = true;
1451 parent->bounds()); 1428 ExecuteCalculateDrawPropertiesWithPropertyTrees(parent);
1452 LayerTreeHostCommon::CalculateDrawProperties(&inputs);
1453 EXPECT_TRUE(parent->has_render_surface()); 1429 EXPECT_TRUE(parent->has_render_surface());
1454 EXPECT_FALSE(render_surface1->has_render_surface()); 1430 EXPECT_FALSE(render_surface1->has_render_surface());
1455 } 1431 }
1456 } 1432 }
1457 1433
1458 TEST_F(LayerTreeHostCommonTest, RenderSurfacesFlattenScreenSpaceTransform) { 1434 TEST_F(LayerTreeHostCommonTest, RenderSurfacesFlattenScreenSpaceTransform) {
1459 // Render surfaces act as a flattening point for their subtree, so should 1435 // Render surfaces act as a flattening point for their subtree, so should
1460 // always flatten the target-to-screen space transform seen by descendants. 1436 // always flatten the target-to-screen space transform seen by descendants.
1461 1437
1462 LayerImpl* root = root_layer(); 1438 LayerImpl* root = root_layer();
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
1788 true); 1764 true);
1789 SetLayerPropertiesForTesting(leaf_node1, identity_matrix, gfx::Point3F(), 1765 SetLayerPropertiesForTesting(leaf_node1, identity_matrix, gfx::Point3F(),
1790 gfx::PointF(), gfx::Size(100, 100), true, false, 1766 gfx::PointF(), gfx::Size(100, 100), true, false,
1791 false); 1767 false);
1792 SetLayerPropertiesForTesting(leaf_node2, identity_matrix, gfx::Point3F(), 1768 SetLayerPropertiesForTesting(leaf_node2, identity_matrix, gfx::Point3F(),
1793 gfx::PointF(), gfx::Size(100, 100), true, false, 1769 gfx::PointF(), gfx::Size(100, 100), true, false,
1794 false); 1770 false);
1795 1771
1796 // Case 1: Nothing is clipped. In this case, is_clipped is always false, with 1772 // Case 1: Nothing is clipped. In this case, is_clipped is always false, with
1797 // or without surfaces. 1773 // or without surfaces.
1774 root->SetHasRenderSurface(true);
1775 child1->SetHasRenderSurface(true);
1776 grand_child->SetHasRenderSurface(true);
1798 ExecuteCalculateDrawProperties(root); 1777 ExecuteCalculateDrawProperties(root);
1799 EXPECT_FALSE(root->is_clipped()); 1778 EXPECT_FALSE(root->is_clipped());
1800 EXPECT_FALSE(parent->is_clipped()); 1779 EXPECT_FALSE(parent->is_clipped());
1801 EXPECT_FALSE(child1->is_clipped()); 1780 EXPECT_FALSE(child1->is_clipped());
1802 EXPECT_FALSE(child2->is_clipped()); 1781 EXPECT_FALSE(child2->is_clipped());
1803 EXPECT_FALSE(grand_child->is_clipped()); 1782 EXPECT_FALSE(grand_child->is_clipped());
1804 EXPECT_FALSE(leaf_node1->is_clipped()); 1783 EXPECT_FALSE(leaf_node1->is_clipped());
1805 EXPECT_FALSE(leaf_node2->is_clipped()); 1784 EXPECT_FALSE(leaf_node2->is_clipped());
1806 1785
1807 ExecuteCalculateDrawPropertiesWithoutSeparateSurfaces(root); 1786 ExecuteCalculateDrawPropertiesWithoutSeparateSurfaces(root);
1808 EXPECT_FALSE(root->is_clipped()); 1787 EXPECT_FALSE(root->is_clipped());
1809 EXPECT_FALSE(parent->is_clipped()); 1788 EXPECT_FALSE(parent->is_clipped());
1810 EXPECT_FALSE(child1->is_clipped()); 1789 EXPECT_FALSE(child1->is_clipped());
1811 EXPECT_FALSE(child2->is_clipped()); 1790 EXPECT_FALSE(child2->is_clipped());
1812 EXPECT_FALSE(grand_child->is_clipped()); 1791 EXPECT_FALSE(grand_child->is_clipped());
1813 EXPECT_FALSE(leaf_node1->is_clipped()); 1792 EXPECT_FALSE(leaf_node1->is_clipped());
1814 EXPECT_FALSE(leaf_node2->is_clipped()); 1793 EXPECT_FALSE(leaf_node2->is_clipped());
1815 1794
1816 // Case 2: The root is clipped. With surfaces, this only persists until the 1795 // Case 2: The root is clipped. With surfaces, this only persists until the
1817 // next render surface. Without surfaces, the entire tree is clipped. 1796 // next render surface. Without surfaces, the entire tree is clipped.
1818 root->SetMasksToBounds(true); 1797 root->SetMasksToBounds(true);
1819 host_impl()->active_tree()->property_trees()->needs_rebuild = true; 1798 host_impl()->active_tree()->property_trees()->needs_rebuild = true;
1799 root->SetHasRenderSurface(true);
1800 child1->SetHasRenderSurface(true);
1801 grand_child->SetHasRenderSurface(true);
1820 ExecuteCalculateDrawProperties(root); 1802 ExecuteCalculateDrawProperties(root);
1821 EXPECT_TRUE(root->is_clipped()); 1803 EXPECT_TRUE(root->is_clipped());
1822 EXPECT_TRUE(parent->is_clipped()); 1804 EXPECT_TRUE(parent->is_clipped());
1823 EXPECT_FALSE(child1->is_clipped()); 1805 EXPECT_FALSE(child1->is_clipped());
1824 EXPECT_TRUE(child2->is_clipped()); 1806 EXPECT_TRUE(child2->is_clipped());
1825 EXPECT_FALSE(grand_child->is_clipped()); 1807 EXPECT_FALSE(grand_child->is_clipped());
1826 EXPECT_FALSE(leaf_node1->is_clipped()); 1808 EXPECT_FALSE(leaf_node1->is_clipped());
1827 EXPECT_TRUE(leaf_node2->is_clipped()); 1809 EXPECT_TRUE(leaf_node2->is_clipped());
1828 1810
1829 ExecuteCalculateDrawPropertiesWithoutSeparateSurfaces(root); 1811 ExecuteCalculateDrawPropertiesWithoutSeparateSurfaces(root);
1830 EXPECT_TRUE(root->is_clipped()); 1812 EXPECT_TRUE(root->is_clipped());
1831 EXPECT_TRUE(parent->is_clipped()); 1813 EXPECT_TRUE(parent->is_clipped());
1832 EXPECT_TRUE(child1->is_clipped()); 1814 EXPECT_TRUE(child1->is_clipped());
1833 EXPECT_TRUE(child2->is_clipped()); 1815 EXPECT_TRUE(child2->is_clipped());
1834 EXPECT_TRUE(grand_child->is_clipped()); 1816 EXPECT_TRUE(grand_child->is_clipped());
1835 EXPECT_TRUE(leaf_node1->is_clipped()); 1817 EXPECT_TRUE(leaf_node1->is_clipped());
1836 EXPECT_TRUE(leaf_node2->is_clipped()); 1818 EXPECT_TRUE(leaf_node2->is_clipped());
1837 1819
1838 root->SetMasksToBounds(false); 1820 root->SetMasksToBounds(false);
1839 1821
1840 // Case 3: The parent is clipped. Again, with surfaces, this only persists 1822 // Case 3: The parent is clipped. Again, with surfaces, this only persists
1841 // until the next render surface. Without surfaces, parent's entire subtree is 1823 // until the next render surface. Without surfaces, parent's entire subtree is
1842 // clipped. 1824 // clipped.
1843 parent->SetMasksToBounds(true); 1825 parent->SetMasksToBounds(true);
1844 host_impl()->active_tree()->property_trees()->needs_rebuild = true; 1826 host_impl()->active_tree()->property_trees()->needs_rebuild = true;
1827 root->SetHasRenderSurface(true);
1828 child1->SetHasRenderSurface(true);
1829 grand_child->SetHasRenderSurface(true);
1845 ExecuteCalculateDrawProperties(root); 1830 ExecuteCalculateDrawProperties(root);
1846 EXPECT_FALSE(root->is_clipped()); 1831 EXPECT_FALSE(root->is_clipped());
1847 EXPECT_TRUE(parent->is_clipped()); 1832 EXPECT_TRUE(parent->is_clipped());
1848 EXPECT_FALSE(child1->is_clipped()); 1833 EXPECT_FALSE(child1->is_clipped());
1849 EXPECT_TRUE(child2->is_clipped()); 1834 EXPECT_TRUE(child2->is_clipped());
1850 EXPECT_FALSE(grand_child->is_clipped()); 1835 EXPECT_FALSE(grand_child->is_clipped());
1851 EXPECT_FALSE(leaf_node1->is_clipped()); 1836 EXPECT_FALSE(leaf_node1->is_clipped());
1852 EXPECT_TRUE(leaf_node2->is_clipped()); 1837 EXPECT_TRUE(leaf_node2->is_clipped());
1853 1838
1854 ExecuteCalculateDrawPropertiesWithoutSeparateSurfaces(root); 1839 ExecuteCalculateDrawPropertiesWithoutSeparateSurfaces(root);
1855 EXPECT_FALSE(root->is_clipped()); 1840 EXPECT_FALSE(root->is_clipped());
1856 EXPECT_TRUE(parent->is_clipped()); 1841 EXPECT_TRUE(parent->is_clipped());
1857 EXPECT_TRUE(child1->is_clipped()); 1842 EXPECT_TRUE(child1->is_clipped());
1858 EXPECT_TRUE(child2->is_clipped()); 1843 EXPECT_TRUE(child2->is_clipped());
1859 EXPECT_TRUE(grand_child->is_clipped()); 1844 EXPECT_TRUE(grand_child->is_clipped());
1860 EXPECT_TRUE(leaf_node1->is_clipped()); 1845 EXPECT_TRUE(leaf_node1->is_clipped());
1861 EXPECT_TRUE(leaf_node2->is_clipped()); 1846 EXPECT_TRUE(leaf_node2->is_clipped());
1862 1847
1863 parent->SetMasksToBounds(false); 1848 parent->SetMasksToBounds(false);
1864 1849
1865 // 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
1866 // 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
1867 // clipped. 1852 // clipped.
1868 child1->SetMasksToBounds(true); 1853 child1->SetMasksToBounds(true);
1869 host_impl()->active_tree()->property_trees()->needs_rebuild = true; 1854 host_impl()->active_tree()->property_trees()->needs_rebuild = true;
1855 root->SetHasRenderSurface(true);
1856 child1->SetHasRenderSurface(true);
1857 grand_child->SetHasRenderSurface(true);
1870 ExecuteCalculateDrawProperties(root); 1858 ExecuteCalculateDrawProperties(root);
1871 EXPECT_FALSE(root->is_clipped()); 1859 EXPECT_FALSE(root->is_clipped());
1872 EXPECT_FALSE(parent->is_clipped()); 1860 EXPECT_FALSE(parent->is_clipped());
1873 EXPECT_TRUE(child1->is_clipped()); 1861 EXPECT_TRUE(child1->is_clipped());
1874 EXPECT_FALSE(child2->is_clipped()); 1862 EXPECT_FALSE(child2->is_clipped());
1875 EXPECT_FALSE(grand_child->is_clipped()); 1863 EXPECT_FALSE(grand_child->is_clipped());
1876 EXPECT_FALSE(leaf_node1->is_clipped()); 1864 EXPECT_FALSE(leaf_node1->is_clipped());
1877 EXPECT_FALSE(leaf_node2->is_clipped()); 1865 EXPECT_FALSE(leaf_node2->is_clipped());
1878 1866
1879 ExecuteCalculateDrawPropertiesWithoutSeparateSurfaces(root); 1867 ExecuteCalculateDrawPropertiesWithoutSeparateSurfaces(root);
1880 EXPECT_FALSE(root->is_clipped()); 1868 EXPECT_FALSE(root->is_clipped());
1881 EXPECT_FALSE(parent->is_clipped()); 1869 EXPECT_FALSE(parent->is_clipped());
1882 EXPECT_TRUE(child1->is_clipped()); 1870 EXPECT_TRUE(child1->is_clipped());
1883 EXPECT_FALSE(child2->is_clipped()); 1871 EXPECT_FALSE(child2->is_clipped());
1884 EXPECT_TRUE(grand_child->is_clipped()); 1872 EXPECT_TRUE(grand_child->is_clipped());
1885 EXPECT_TRUE(leaf_node1->is_clipped()); 1873 EXPECT_TRUE(leaf_node1->is_clipped());
1886 EXPECT_FALSE(leaf_node2->is_clipped()); 1874 EXPECT_FALSE(leaf_node2->is_clipped());
1887 1875
1888 child1->SetMasksToBounds(false); 1876 child1->SetMasksToBounds(false);
1889 1877
1890 // Case 5: Only the leaf nodes are clipped. The behavior with and without 1878 // Case 5: Only the leaf nodes are clipped. The behavior with and without
1891 // surfaces is the same. 1879 // surfaces is the same.
1892 leaf_node1->SetMasksToBounds(true); 1880 leaf_node1->SetMasksToBounds(true);
1893 leaf_node2->SetMasksToBounds(true); 1881 leaf_node2->SetMasksToBounds(true);
1894 host_impl()->active_tree()->property_trees()->needs_rebuild = true; 1882 host_impl()->active_tree()->property_trees()->needs_rebuild = true;
1883 root->SetHasRenderSurface(true);
1884 child1->SetHasRenderSurface(true);
1885 grand_child->SetHasRenderSurface(true);
1895 ExecuteCalculateDrawProperties(root); 1886 ExecuteCalculateDrawProperties(root);
1896 EXPECT_FALSE(root->is_clipped()); 1887 EXPECT_FALSE(root->is_clipped());
1897 EXPECT_FALSE(parent->is_clipped()); 1888 EXPECT_FALSE(parent->is_clipped());
1898 EXPECT_FALSE(child1->is_clipped()); 1889 EXPECT_FALSE(child1->is_clipped());
1899 EXPECT_FALSE(child2->is_clipped()); 1890 EXPECT_FALSE(child2->is_clipped());
1900 EXPECT_FALSE(grand_child->is_clipped()); 1891 EXPECT_FALSE(grand_child->is_clipped());
1901 EXPECT_TRUE(leaf_node1->is_clipped()); 1892 EXPECT_TRUE(leaf_node1->is_clipped());
1902 EXPECT_TRUE(leaf_node2->is_clipped()); 1893 EXPECT_TRUE(leaf_node2->is_clipped());
1903 1894
1904 ExecuteCalculateDrawPropertiesWithoutSeparateSurfaces(root); 1895 ExecuteCalculateDrawPropertiesWithoutSeparateSurfaces(root);
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
2073 child1->SetDrawsContent(true); 2064 child1->SetDrawsContent(true);
2074 child2->SetDrawsContent(true); 2065 child2->SetDrawsContent(true);
2075 grand_child->SetDrawsContent(true); 2066 grand_child->SetDrawsContent(true);
2076 leaf_node1->SetDrawsContent(true); 2067 leaf_node1->SetDrawsContent(true);
2077 leaf_node2->SetDrawsContent(true); 2068 leaf_node2->SetDrawsContent(true);
2078 2069
2079 const gfx::Transform identity_matrix; 2070 const gfx::Transform identity_matrix;
2080 2071
2081 // child1 and grand_child get render surfaces when surfaces are enabled. 2072 // child1 and grand_child get render surfaces when surfaces are enabled.
2082 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), 2073 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(),
2083 gfx::PointF(), gfx::Size(100, 100), true, false, 2074 gfx::PointF(), gfx::Size(100, 100), true, false);
2084 true);
2085 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(), 2075 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(),
2086 gfx::PointF(2.f, 2.f), gfx::Size(400, 400), true, 2076 gfx::PointF(2.f, 2.f), gfx::Size(400, 400), true,
2087 false, false); 2077 false);
2088 SetLayerPropertiesForTesting(child1, identity_matrix, gfx::Point3F(), 2078 SetLayerPropertiesForTesting(child1, identity_matrix, gfx::Point3F(),
2089 gfx::PointF(4.f, 4.f), gfx::Size(800, 800), true, 2079 gfx::PointF(4.f, 4.f), gfx::Size(800, 800), true,
2090 false, true); 2080 false);
2091 SetLayerPropertiesForTesting(child2, identity_matrix, gfx::Point3F(), 2081 SetLayerPropertiesForTesting(child2, identity_matrix, gfx::Point3F(),
2092 gfx::PointF(3.f, 3.f), gfx::Size(800, 800), true, 2082 gfx::PointF(3.f, 3.f), gfx::Size(800, 800), true,
2093 false, false); 2083 false);
2094 SetLayerPropertiesForTesting(grand_child, identity_matrix, gfx::Point3F(), 2084 SetLayerPropertiesForTesting(grand_child, identity_matrix, gfx::Point3F(),
2095 gfx::PointF(8.f, 8.f), gfx::Size(1500, 1500), 2085 gfx::PointF(8.f, 8.f), gfx::Size(1500, 1500),
2096 true, false, true); 2086 true, false);
2097 SetLayerPropertiesForTesting(leaf_node1, identity_matrix, gfx::Point3F(), 2087 SetLayerPropertiesForTesting(leaf_node1, identity_matrix, gfx::Point3F(),
2098 gfx::PointF(16.f, 16.f), gfx::Size(2000, 2000), 2088 gfx::PointF(16.f, 16.f), gfx::Size(2000, 2000),
2099 true, false, false); 2089 true, false);
2100 SetLayerPropertiesForTesting(leaf_node2, identity_matrix, gfx::Point3F(), 2090 SetLayerPropertiesForTesting(leaf_node2, identity_matrix, gfx::Point3F(),
2101 gfx::PointF(9.f, 9.f), gfx::Size(2000, 2000), 2091 gfx::PointF(9.f, 9.f), gfx::Size(2000, 2000),
2102 true, false, false); 2092 true, false);
2103 2093
2104 // Case 1: Nothing is clipped. In this case, each layer's clip rect is its 2094 // Case 1: Nothing is clipped. In this case, each layer's clip rect is its
2105 // bounds in target space. The only thing that changes when surfaces are 2095 // bounds in target space. The only thing that changes when surfaces are
2106 // disabled is that target space is always screen space. 2096 // disabled is that target space is always screen space.
2097 root->SetForceRenderSurface(true);
2098 child1->SetForceRenderSurface(true);
2099 grand_child->SetForceRenderSurface(true);
2107 ExecuteCalculateDrawProperties(root); 2100 ExecuteCalculateDrawProperties(root);
2101 EXPECT_TRUE(root->has_render_surface());
2102 EXPECT_FALSE(parent->has_render_surface());
2103 EXPECT_TRUE(child1->has_render_surface());
2104 EXPECT_FALSE(child2->has_render_surface());
2105 EXPECT_TRUE(grand_child->has_render_surface());
2106 EXPECT_FALSE(leaf_node1->has_render_surface());
2107 EXPECT_FALSE(leaf_node2->has_render_surface());
2108 EXPECT_EQ(gfx::Rect(100, 100), root->clip_rect()); 2108 EXPECT_EQ(gfx::Rect(100, 100), root->clip_rect());
2109 EXPECT_EQ(gfx::Rect(2, 2, 400, 400), parent->clip_rect()); 2109 EXPECT_EQ(gfx::Rect(2, 2, 400, 400), parent->clip_rect());
2110 EXPECT_EQ(gfx::Rect(800, 800), child1->clip_rect()); 2110 EXPECT_EQ(gfx::Rect(800, 800), child1->clip_rect());
2111 EXPECT_EQ(gfx::Rect(5, 5, 800, 800), child2->clip_rect()); 2111 EXPECT_EQ(gfx::Rect(5, 5, 800, 800), child2->clip_rect());
2112 EXPECT_EQ(gfx::Rect(1500, 1500), grand_child->clip_rect()); 2112 EXPECT_EQ(gfx::Rect(1500, 1500), grand_child->clip_rect());
2113 EXPECT_EQ(gfx::Rect(16, 16, 2000, 2000), leaf_node1->clip_rect()); 2113 EXPECT_EQ(gfx::Rect(16, 16, 2000, 2000), leaf_node1->clip_rect());
2114 EXPECT_EQ(gfx::Rect(14, 14, 2000, 2000), leaf_node2->clip_rect()); 2114 EXPECT_EQ(gfx::Rect(14, 14, 2000, 2000), leaf_node2->clip_rect());
2115 2115
2116 ExecuteCalculateDrawPropertiesWithoutSeparateSurfaces(root); 2116 ExecuteCalculateDrawPropertiesWithoutSeparateSurfaces(root);
2117 EXPECT_EQ(gfx::Rect(100, 100), root->clip_rect()); 2117 EXPECT_EQ(gfx::Rect(100, 100), root->clip_rect());
2118 EXPECT_EQ(gfx::Rect(2, 2, 400, 400), parent->clip_rect()); 2118 EXPECT_EQ(gfx::Rect(2, 2, 400, 400), parent->clip_rect());
2119 EXPECT_EQ(gfx::Rect(6, 6, 800, 800), child1->clip_rect()); 2119 EXPECT_EQ(gfx::Rect(6, 6, 800, 800), child1->clip_rect());
2120 EXPECT_EQ(gfx::Rect(5, 5, 800, 800), child2->clip_rect()); 2120 EXPECT_EQ(gfx::Rect(5, 5, 800, 800), child2->clip_rect());
2121 EXPECT_EQ(gfx::Rect(14, 14, 1500, 1500), grand_child->clip_rect()); 2121 EXPECT_EQ(gfx::Rect(14, 14, 1500, 1500), grand_child->clip_rect());
2122 EXPECT_EQ(gfx::Rect(30, 30, 2000, 2000), leaf_node1->clip_rect()); 2122 EXPECT_EQ(gfx::Rect(30, 30, 2000, 2000), leaf_node1->clip_rect());
2123 EXPECT_EQ(gfx::Rect(14, 14, 2000, 2000), leaf_node2->clip_rect()); 2123 EXPECT_EQ(gfx::Rect(14, 14, 2000, 2000), leaf_node2->clip_rect());
2124 2124
2125 // Case 2: The root is clipped. In this case, layers that draw into the root 2125 // Case 2: The root is clipped. In this case, layers that draw into the root
2126 // render surface are clipped by the root's bounds. 2126 // render surface are clipped by the root's bounds.
2127 root->SetMasksToBounds(true); 2127 root->SetMasksToBounds(true);
2128 host_impl()->active_tree()->property_trees()->needs_rebuild = true; 2128 host_impl()->active_tree()->property_trees()->needs_rebuild = true;
2129 root->SetForceRenderSurface(true);
2130 child1->SetForceRenderSurface(true);
2131 grand_child->SetForceRenderSurface(true);
2129 ExecuteCalculateDrawProperties(root); 2132 ExecuteCalculateDrawProperties(root);
2133 EXPECT_TRUE(root->has_render_surface());
2134 EXPECT_FALSE(parent->has_render_surface());
2135 EXPECT_TRUE(child1->has_render_surface());
2136 EXPECT_FALSE(child2->has_render_surface());
2137 EXPECT_TRUE(grand_child->has_render_surface());
2138 EXPECT_FALSE(leaf_node1->has_render_surface());
2139 EXPECT_FALSE(leaf_node2->has_render_surface());
2130 EXPECT_EQ(gfx::Rect(100, 100), root->clip_rect()); 2140 EXPECT_EQ(gfx::Rect(100, 100), root->clip_rect());
2131 EXPECT_EQ(gfx::Rect(100, 100), parent->clip_rect()); 2141 EXPECT_EQ(gfx::Rect(100, 100), parent->clip_rect());
2132 EXPECT_EQ(gfx::Rect(800, 800), child1->clip_rect()); 2142 EXPECT_EQ(gfx::Rect(800, 800), child1->clip_rect());
2133 EXPECT_EQ(gfx::Rect(100, 100), child2->clip_rect()); 2143 EXPECT_EQ(gfx::Rect(100, 100), child2->clip_rect());
2134 EXPECT_EQ(gfx::Rect(1500, 1500), grand_child->clip_rect()); 2144 EXPECT_EQ(gfx::Rect(1500, 1500), grand_child->clip_rect());
2135 EXPECT_EQ(gfx::Rect(16, 16, 2000, 2000), leaf_node1->clip_rect()); 2145 EXPECT_EQ(gfx::Rect(16, 16, 2000, 2000), leaf_node1->clip_rect());
2136 EXPECT_EQ(gfx::Rect(100, 100), leaf_node2->clip_rect()); 2146 EXPECT_EQ(gfx::Rect(100, 100), leaf_node2->clip_rect());
2137 2147
2138 ExecuteCalculateDrawPropertiesWithoutSeparateSurfaces(root); 2148 ExecuteCalculateDrawPropertiesWithoutSeparateSurfaces(root);
2139 EXPECT_EQ(gfx::Rect(100, 100), root->clip_rect()); 2149 EXPECT_EQ(gfx::Rect(100, 100), root->clip_rect());
2140 EXPECT_EQ(gfx::Rect(100, 100), parent->clip_rect()); 2150 EXPECT_EQ(gfx::Rect(100, 100), parent->clip_rect());
2141 EXPECT_EQ(gfx::Rect(100, 100), child1->clip_rect()); 2151 EXPECT_EQ(gfx::Rect(100, 100), child1->clip_rect());
2142 EXPECT_EQ(gfx::Rect(100, 100), child2->clip_rect()); 2152 EXPECT_EQ(gfx::Rect(100, 100), child2->clip_rect());
2143 EXPECT_EQ(gfx::Rect(100, 100), grand_child->clip_rect()); 2153 EXPECT_EQ(gfx::Rect(100, 100), grand_child->clip_rect());
2144 EXPECT_EQ(gfx::Rect(100, 100), leaf_node1->clip_rect()); 2154 EXPECT_EQ(gfx::Rect(100, 100), leaf_node1->clip_rect());
2145 EXPECT_EQ(gfx::Rect(100, 100), leaf_node2->clip_rect()); 2155 EXPECT_EQ(gfx::Rect(100, 100), leaf_node2->clip_rect());
2146 2156
2147 root->SetMasksToBounds(false); 2157 root->SetMasksToBounds(false);
2148 2158
2149 // Case 3: The parent and child1 are clipped. When surfaces are enabled, the 2159 // Case 3: The parent and child1 are clipped. When surfaces are enabled, the
2150 // parent clip rect only contributes to the subtree rooted at child2, since 2160 // parent clip rect only contributes to the subtree rooted at child2, since
2151 // the subtree rooted at child1 renders into a separate surface. Similarly, 2161 // the subtree rooted at child1 renders into a separate surface. Similarly,
2152 // child1's clip rect doesn't contribute to its descendants, since its only 2162 // child1's clip rect doesn't contribute to its descendants, since its only
2153 // child is a render surface. However, without surfaces, these clip rects 2163 // child is a render surface. However, without surfaces, these clip rects
2154 // contribute to all descendants. 2164 // contribute to all descendants.
2155 parent->SetMasksToBounds(true); 2165 parent->SetMasksToBounds(true);
2156 child1->SetMasksToBounds(true); 2166 child1->SetMasksToBounds(true);
2157 host_impl()->active_tree()->property_trees()->needs_rebuild = true; 2167 host_impl()->active_tree()->property_trees()->needs_rebuild = true;
2168 root->SetForceRenderSurface(true);
2169 child1->SetForceRenderSurface(true);
2170 grand_child->SetForceRenderSurface(true);
2158 ExecuteCalculateDrawProperties(root); 2171 ExecuteCalculateDrawProperties(root);
2172 EXPECT_TRUE(root->has_render_surface());
2173 EXPECT_FALSE(parent->has_render_surface());
2174 EXPECT_TRUE(child1->has_render_surface());
2175 EXPECT_FALSE(child2->has_render_surface());
2176 EXPECT_TRUE(grand_child->has_render_surface());
2177 EXPECT_FALSE(leaf_node1->has_render_surface());
2178 EXPECT_FALSE(leaf_node2->has_render_surface());
2159 EXPECT_EQ(gfx::Rect(100, 100), root->clip_rect()); 2179 EXPECT_EQ(gfx::Rect(100, 100), root->clip_rect());
2160 EXPECT_EQ(gfx::Rect(2, 2, 400, 400), parent->clip_rect()); 2180 EXPECT_EQ(gfx::Rect(2, 2, 400, 400), parent->clip_rect());
2161 EXPECT_EQ(gfx::Rect(800, 800), child1->clip_rect()); 2181 EXPECT_EQ(gfx::Rect(800, 800), child1->clip_rect());
2162 EXPECT_EQ(gfx::Rect(2, 2, 400, 400), child2->clip_rect()); 2182 EXPECT_EQ(gfx::Rect(2, 2, 400, 400), child2->clip_rect());
2163 EXPECT_EQ(gfx::Rect(1500, 1500), grand_child->clip_rect()); 2183 EXPECT_EQ(gfx::Rect(1500, 1500), grand_child->clip_rect());
2164 EXPECT_EQ(gfx::Rect(16, 16, 2000, 2000), leaf_node1->clip_rect()); 2184 EXPECT_EQ(gfx::Rect(16, 16, 2000, 2000), leaf_node1->clip_rect());
2165 EXPECT_EQ(gfx::Rect(2, 2, 400, 400), leaf_node2->clip_rect()); 2185 EXPECT_EQ(gfx::Rect(2, 2, 400, 400), leaf_node2->clip_rect());
2166 2186
2167 ExecuteCalculateDrawPropertiesWithoutSeparateSurfaces(root); 2187 ExecuteCalculateDrawPropertiesWithoutSeparateSurfaces(root);
2168 EXPECT_EQ(gfx::Rect(100, 100), root->clip_rect()); 2188 EXPECT_EQ(gfx::Rect(100, 100), root->clip_rect());
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
2204 SetLayerPropertiesForTesting(grand_child, identity_matrix, gfx::Point3F(), 2224 SetLayerPropertiesForTesting(grand_child, identity_matrix, gfx::Point3F(),
2205 gfx::PointF(8.f, 8.f), gfx::Size(1500, 1500), 2225 gfx::PointF(8.f, 8.f), gfx::Size(1500, 1500),
2206 true, false, true); 2226 true, false, true);
2207 SetLayerPropertiesForTesting(leaf_node, identity_matrix, gfx::Point3F(), 2227 SetLayerPropertiesForTesting(leaf_node, identity_matrix, gfx::Point3F(),
2208 gfx::PointF(16.f, 16.f), gfx::Size(2000, 2000), 2228 gfx::PointF(16.f, 16.f), gfx::Size(2000, 2000),
2209 true, false, false); 2229 true, false, false);
2210 2230
2211 parent->SetMasksToBounds(true); 2231 parent->SetMasksToBounds(true);
2212 child->SetMasksToBounds(true); 2232 child->SetMasksToBounds(true);
2213 2233
2234 root->SetHasRenderSurface(true);
2235 child->SetHasRenderSurface(true);
2236 grand_child->SetHasRenderSurface(true);
2237
2214 gfx::Transform expected_leaf_draw_transform_with_surfaces; 2238 gfx::Transform expected_leaf_draw_transform_with_surfaces;
2215 expected_leaf_draw_transform_with_surfaces.Translate(16.0, 16.0); 2239 expected_leaf_draw_transform_with_surfaces.Translate(16.0, 16.0);
2216 2240
2217 gfx::Transform expected_leaf_draw_transform_without_surfaces; 2241 gfx::Transform expected_leaf_draw_transform_without_surfaces;
2218 expected_leaf_draw_transform_without_surfaces.Translate(30.0, 30.0); 2242 expected_leaf_draw_transform_without_surfaces.Translate(30.0, 30.0);
2219 2243
2220 ExecuteCalculateDrawProperties(root); 2244 ExecuteCalculateDrawProperties(root);
2221 EXPECT_EQ(gfx::Rect(16, 16, 2000, 2000), leaf_node->clip_rect()); 2245 EXPECT_EQ(gfx::Rect(16, 16, 2000, 2000), leaf_node->clip_rect());
2222 EXPECT_EQ(gfx::Rect(16, 16, 2000, 2000), leaf_node->drawable_content_rect()); 2246 EXPECT_EQ(gfx::Rect(16, 16, 2000, 2000), leaf_node->drawable_content_rect());
2223 EXPECT_EQ(expected_leaf_draw_transform_with_surfaces, 2247 EXPECT_EQ(expected_leaf_draw_transform_with_surfaces,
2224 leaf_node->DrawTransform()); 2248 leaf_node->DrawTransform());
2225 2249
2250 root->SetHasRenderSurface(true);
2251 child->SetHasRenderSurface(true);
2252 grand_child->SetHasRenderSurface(true);
2253
2226 ExecuteCalculateDrawPropertiesWithoutSeparateSurfaces(root); 2254 ExecuteCalculateDrawPropertiesWithoutSeparateSurfaces(root);
2227 EXPECT_EQ(gfx::Rect(6, 6, 396, 396), leaf_node->clip_rect()); 2255 EXPECT_EQ(gfx::Rect(6, 6, 396, 396), leaf_node->clip_rect());
2228 EXPECT_EQ(gfx::Rect(30, 30, 372, 372), leaf_node->drawable_content_rect()); 2256 EXPECT_EQ(gfx::Rect(30, 30, 372, 372), leaf_node->drawable_content_rect());
2229 EXPECT_EQ(expected_leaf_draw_transform_without_surfaces, 2257 EXPECT_EQ(expected_leaf_draw_transform_without_surfaces,
2230 leaf_node->DrawTransform()); 2258 leaf_node->DrawTransform());
2231 2259
2260 root->SetHasRenderSurface(true);
2261 child->SetHasRenderSurface(true);
2262 grand_child->SetHasRenderSurface(true);
2263
2232 ExecuteCalculateDrawProperties(root); 2264 ExecuteCalculateDrawProperties(root);
2233 EXPECT_EQ(gfx::Rect(16, 16, 2000, 2000), leaf_node->clip_rect()); 2265 EXPECT_EQ(gfx::Rect(16, 16, 2000, 2000), leaf_node->clip_rect());
2234 EXPECT_EQ(gfx::Rect(16, 16, 2000, 2000), leaf_node->drawable_content_rect()); 2266 EXPECT_EQ(gfx::Rect(16, 16, 2000, 2000), leaf_node->drawable_content_rect());
2235 EXPECT_EQ(expected_leaf_draw_transform_with_surfaces, 2267 EXPECT_EQ(expected_leaf_draw_transform_with_surfaces,
2236 leaf_node->DrawTransform()); 2268 leaf_node->DrawTransform());
2237 } 2269 }
2238 2270
2239 TEST_F(LayerTreeHostCommonTest, AnimationsForRenderSurfaceHierarchy) { 2271 TEST_F(LayerTreeHostCommonTest, AnimationsForRenderSurfaceHierarchy) {
2240 LayerImpl* parent = root_layer(); 2272 LayerImpl* parent = root_layer();
2241 LayerImpl* render_surface1 = AddChildToRoot<LayerImpl>(); 2273 LayerImpl* render_surface1 = AddChildToRoot<LayerImpl>();
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after
2970 true, false, false); 3002 true, false, false);
2971 SetLayerPropertiesForTesting(leaf_node2, identity_matrix, gfx::Point3F(), 3003 SetLayerPropertiesForTesting(leaf_node2, identity_matrix, gfx::Point3F(),
2972 gfx::PointF(9.f, 9.f), gfx::Size(2000, 2000), 3004 gfx::PointF(9.f, 9.f), gfx::Size(2000, 2000),
2973 true, false, false); 3005 true, false, false);
2974 3006
2975 // Case 1: No layers clip. Visible rects are clipped by the viewport, but the 3007 // Case 1: No layers clip. Visible rects are clipped by the viewport, but the
2976 // viewport clip doesn't apply to layers that draw into unclipped surfaces. 3008 // viewport clip doesn't apply to layers that draw into unclipped surfaces.
2977 // Each layer's drawable content rect is its bounds in target space; the only 3009 // Each layer's drawable content rect is its bounds in target space; the only
2978 // thing that changes with surfaces disabled is that target space is always 3010 // thing that changes with surfaces disabled is that target space is always
2979 // screen space. 3011 // screen space.
3012 root->SetHasRenderSurface(true);
3013 child1->SetHasRenderSurface(true);
3014 child2->SetHasRenderSurface(true);
2980 ExecuteCalculateDrawProperties(root); 3015 ExecuteCalculateDrawProperties(root);
2981 EXPECT_EQ(gfx::Rect(100, 100), root->visible_layer_rect()); 3016 EXPECT_EQ(gfx::Rect(100, 100), root->visible_layer_rect());
2982 EXPECT_EQ(gfx::Rect(0, 0, 98, 98), parent->visible_layer_rect()); 3017 EXPECT_EQ(gfx::Rect(0, 0, 98, 98), parent->visible_layer_rect());
2983 EXPECT_EQ(gfx::Rect(800, 800), child1->visible_layer_rect()); 3018 EXPECT_EQ(gfx::Rect(800, 800), child1->visible_layer_rect());
2984 EXPECT_EQ(gfx::Rect(800, 800), child2->visible_layer_rect()); 3019 EXPECT_EQ(gfx::Rect(800, 800), child2->visible_layer_rect());
2985 EXPECT_EQ(gfx::Rect(1500, 1500), grand_child1->visible_layer_rect()); 3020 EXPECT_EQ(gfx::Rect(1500, 1500), grand_child1->visible_layer_rect());
2986 EXPECT_EQ(gfx::Rect(1500, 1500), grand_child2->visible_layer_rect()); 3021 EXPECT_EQ(gfx::Rect(1500, 1500), grand_child2->visible_layer_rect());
2987 EXPECT_EQ(gfx::Rect(2000, 2000), leaf_node1->visible_layer_rect()); 3022 EXPECT_EQ(gfx::Rect(2000, 2000), leaf_node1->visible_layer_rect());
2988 EXPECT_EQ(gfx::Rect(2000, 2000), leaf_node2->visible_layer_rect()); 3023 EXPECT_EQ(gfx::Rect(2000, 2000), leaf_node2->visible_layer_rect());
2989 3024
(...skipping 28 matching lines...) Expand all
3018 EXPECT_EQ(gfx::Rect(21, 21, 2000, 2000), leaf_node2->drawable_content_rect()); 3053 EXPECT_EQ(gfx::Rect(21, 21, 2000, 2000), leaf_node2->drawable_content_rect());
3019 3054
3020 // Case 2: The parent clips. In this case, neither surface is unclipped, so 3055 // Case 2: The parent clips. In this case, neither surface is unclipped, so
3021 // all visible layer rects are clipped by the intersection of all ancestor 3056 // all visible layer rects are clipped by the intersection of all ancestor
3022 // clips, whether or not surfaces are disabled. However, drawable content 3057 // clips, whether or not surfaces are disabled. However, drawable content
3023 // rects are clipped only until the next render surface is reached, so 3058 // rects are clipped only until the next render surface is reached, so
3024 // descendants of parent have their drawable content rects clipped only when 3059 // descendants of parent have their drawable content rects clipped only when
3025 // surfaces are disabled. 3060 // surfaces are disabled.
3026 parent->SetMasksToBounds(true); 3061 parent->SetMasksToBounds(true);
3027 host_impl()->active_tree()->property_trees()->needs_rebuild = true; 3062 host_impl()->active_tree()->property_trees()->needs_rebuild = true;
3063 root->SetHasRenderSurface(true);
3064 child1->SetHasRenderSurface(true);
3065 child2->SetHasRenderSurface(true);
3028 ExecuteCalculateDrawProperties(root); 3066 ExecuteCalculateDrawProperties(root);
3029 EXPECT_EQ(gfx::Rect(100, 100), root->visible_layer_rect()); 3067 EXPECT_EQ(gfx::Rect(100, 100), root->visible_layer_rect());
3030 EXPECT_EQ(gfx::Rect(98, 98), parent->visible_layer_rect()); 3068 EXPECT_EQ(gfx::Rect(98, 98), parent->visible_layer_rect());
3031 EXPECT_EQ(gfx::Rect(94, 94), child1->visible_layer_rect()); 3069 EXPECT_EQ(gfx::Rect(94, 94), child1->visible_layer_rect());
3032 EXPECT_EQ(gfx::Rect(95, 95), child2->visible_layer_rect()); 3070 EXPECT_EQ(gfx::Rect(95, 95), child2->visible_layer_rect());
3033 EXPECT_EQ(gfx::Rect(86, 86), grand_child1->visible_layer_rect()); 3071 EXPECT_EQ(gfx::Rect(86, 86), grand_child1->visible_layer_rect());
3034 EXPECT_EQ(gfx::Rect(88, 88), grand_child2->visible_layer_rect()); 3072 EXPECT_EQ(gfx::Rect(88, 88), grand_child2->visible_layer_rect());
3035 EXPECT_EQ(gfx::Rect(70, 70), leaf_node1->visible_layer_rect()); 3073 EXPECT_EQ(gfx::Rect(70, 70), leaf_node1->visible_layer_rect());
3036 EXPECT_EQ(gfx::Rect(79, 79), leaf_node2->visible_layer_rect()); 3074 EXPECT_EQ(gfx::Rect(79, 79), leaf_node2->visible_layer_rect());
3037 3075
(...skipping 27 matching lines...) Expand all
3065 3103
3066 parent->SetMasksToBounds(false); 3104 parent->SetMasksToBounds(false);
3067 3105
3068 // Case 3: child1 and grand_child2 clip. In this case, descendants of these 3106 // Case 3: child1 and grand_child2 clip. In this case, descendants of these
3069 // layers have their visible rects clipped by them; without surfaces, these 3107 // layers have their visible rects clipped by them; without surfaces, these
3070 // rects are also clipped by the viewport. Similarly, descendants of these 3108 // rects are also clipped by the viewport. Similarly, descendants of these
3071 // layers have their drawable content rects clipped by them. 3109 // layers have their drawable content rects clipped by them.
3072 child1->SetMasksToBounds(true); 3110 child1->SetMasksToBounds(true);
3073 grand_child2->SetMasksToBounds(true); 3111 grand_child2->SetMasksToBounds(true);
3074 host_impl()->active_tree()->property_trees()->needs_rebuild = true; 3112 host_impl()->active_tree()->property_trees()->needs_rebuild = true;
3113 root->SetHasRenderSurface(true);
3114 child1->SetHasRenderSurface(true);
3115 child2->SetHasRenderSurface(true);
3075 ExecuteCalculateDrawProperties(root); 3116 ExecuteCalculateDrawProperties(root);
3076 EXPECT_EQ(gfx::Rect(100, 100), root->visible_layer_rect()); 3117 EXPECT_EQ(gfx::Rect(100, 100), root->visible_layer_rect());
3077 EXPECT_EQ(gfx::Rect(98, 98), parent->visible_layer_rect()); 3118 EXPECT_EQ(gfx::Rect(98, 98), parent->visible_layer_rect());
3078 EXPECT_EQ(gfx::Rect(800, 800), child1->visible_layer_rect()); 3119 EXPECT_EQ(gfx::Rect(800, 800), child1->visible_layer_rect());
3079 EXPECT_EQ(gfx::Rect(800, 800), child2->visible_layer_rect()); 3120 EXPECT_EQ(gfx::Rect(800, 800), child2->visible_layer_rect());
3080 EXPECT_EQ(gfx::Rect(792, 792), grand_child1->visible_layer_rect()); 3121 EXPECT_EQ(gfx::Rect(792, 792), grand_child1->visible_layer_rect());
3081 EXPECT_EQ(gfx::Rect(1500, 1500), grand_child2->visible_layer_rect()); 3122 EXPECT_EQ(gfx::Rect(1500, 1500), grand_child2->visible_layer_rect());
3082 EXPECT_EQ(gfx::Rect(776, 776), leaf_node1->visible_layer_rect()); 3123 EXPECT_EQ(gfx::Rect(776, 776), leaf_node1->visible_layer_rect());
3083 EXPECT_EQ(gfx::Rect(1491, 1491), leaf_node2->visible_layer_rect()); 3124 EXPECT_EQ(gfx::Rect(1491, 1491), leaf_node2->visible_layer_rect());
3084 3125
(...skipping 996 matching lines...) Expand 10 before | Expand all | Expand 10 after
4081 front_facing_child_of_front_facing_surface->id())); 4122 front_facing_child_of_front_facing_surface->id()));
4082 EXPECT_TRUE( 4123 EXPECT_TRUE(
4083 UpdateLayerListContains(front_facing_child_of_back_facing_surface->id())); 4124 UpdateLayerListContains(front_facing_child_of_back_facing_surface->id()));
4084 } 4125 }
4085 4126
4086 TEST_F(LayerTreeHostCommonTest, BackFaceCullingWithPreserves3d) { 4127 TEST_F(LayerTreeHostCommonTest, BackFaceCullingWithPreserves3d) {
4087 // Verify the behavior of back-face culling when preserves-3d transform style 4128 // Verify the behavior of back-face culling when preserves-3d transform style
4088 // is used. 4129 // is used.
4089 4130
4090 const gfx::Transform identity_matrix; 4131 const gfx::Transform identity_matrix;
4091 scoped_refptr<Layer> parent = Layer::Create(layer_settings()); 4132 LayerImpl* parent = root_layer();
4092 scoped_refptr<LayerWithForcedDrawsContent> front_facing_child = 4133 LayerImpl* front_facing_child = AddChildToRoot<LayerImpl>();
4093 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings())); 4134 LayerImpl* back_facing_child = AddChildToRoot<LayerImpl>();
4094 scoped_refptr<LayerWithForcedDrawsContent> back_facing_child = 4135 LayerImpl* front_facing_surface = AddChildToRoot<LayerImpl>();
4095 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings())); 4136 LayerImpl* back_facing_surface = AddChildToRoot<LayerImpl>();
4096 scoped_refptr<LayerWithForcedDrawsContent> front_facing_surface = 4137 LayerImpl* front_facing_child_of_front_facing_surface =
4097 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings())); 4138 AddChild<LayerImpl>(front_facing_surface);
4098 scoped_refptr<LayerWithForcedDrawsContent> back_facing_surface = 4139 LayerImpl* back_facing_child_of_front_facing_surface =
4099 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings())); 4140 AddChild<LayerImpl>(front_facing_surface);
4100 scoped_refptr<LayerWithForcedDrawsContent> 4141 LayerImpl* front_facing_child_of_back_facing_surface =
4101 front_facing_child_of_front_facing_surface = 4142 AddChild<LayerImpl>(back_facing_surface);
4102 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings())); 4143 LayerImpl* back_facing_child_of_back_facing_surface =
4103 scoped_refptr<LayerWithForcedDrawsContent> 4144 AddChild<LayerImpl>(back_facing_surface);
4104 back_facing_child_of_front_facing_surface = 4145 // Opacity will not force creation of render surfaces in this case because of
4105 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings())); 4146 // the preserve-3d transform style. Instead, an example of when a surface
4106 scoped_refptr<LayerWithForcedDrawsContent> 4147 // would be created with preserve-3d is when there is a replica layer.
4107 front_facing_child_of_back_facing_surface = 4148 LayerImpl* dummy_replica_layer1 =
4108 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings())); 4149 AddReplicaLayer<LayerImpl>(front_facing_surface);
4109 scoped_refptr<LayerWithForcedDrawsContent> 4150 LayerImpl* dummy_replica_layer2 =
4110 back_facing_child_of_back_facing_surface = 4151 AddReplicaLayer<LayerImpl>(back_facing_surface);
4111 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
4112 scoped_refptr<LayerWithForcedDrawsContent> dummy_replica_layer1 =
4113 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
4114 scoped_refptr<LayerWithForcedDrawsContent> dummy_replica_layer2 =
4115 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
4116
4117 parent->AddChild(front_facing_child);
4118 parent->AddChild(back_facing_child);
4119 parent->AddChild(front_facing_surface);
4120 parent->AddChild(back_facing_surface);
4121 front_facing_surface->AddChild(front_facing_child_of_front_facing_surface);
4122 front_facing_surface->AddChild(back_facing_child_of_front_facing_surface);
4123 back_facing_surface->AddChild(front_facing_child_of_back_facing_surface);
4124 back_facing_surface->AddChild(back_facing_child_of_back_facing_surface);
4125
4126 host()->SetRootLayer(parent);
4127 4152
4128 // Nothing is double-sided 4153 // Nothing is double-sided
4129 front_facing_child->SetDoubleSided(false); 4154 front_facing_child->SetDoubleSided(false);
4130 back_facing_child->SetDoubleSided(false); 4155 back_facing_child->SetDoubleSided(false);
4131 front_facing_surface->SetDoubleSided(false); 4156 front_facing_surface->SetDoubleSided(false);
4132 back_facing_surface->SetDoubleSided(false); 4157 back_facing_surface->SetDoubleSided(false);
4133 front_facing_child_of_front_facing_surface->SetDoubleSided(false); 4158 front_facing_child_of_front_facing_surface->SetDoubleSided(false);
4134 back_facing_child_of_front_facing_surface->SetDoubleSided(false); 4159 back_facing_child_of_front_facing_surface->SetDoubleSided(false);
4135 front_facing_child_of_back_facing_surface->SetDoubleSided(false); 4160 front_facing_child_of_back_facing_surface->SetDoubleSided(false);
4136 back_facing_child_of_back_facing_surface->SetDoubleSided(false); 4161 back_facing_child_of_back_facing_surface->SetDoubleSided(false);
4137 4162
4163 // Everything draws content.
4164 front_facing_child->SetDrawsContent(true);
4165 back_facing_child->SetDrawsContent(true);
4166 front_facing_surface->SetDrawsContent(true);
4167 back_facing_surface->SetDrawsContent(true);
4168 front_facing_child_of_front_facing_surface->SetDrawsContent(true);
4169 back_facing_child_of_front_facing_surface->SetDrawsContent(true);
4170 front_facing_child_of_back_facing_surface->SetDrawsContent(true);
4171 back_facing_child_of_back_facing_surface->SetDrawsContent(true);
4172 dummy_replica_layer1->SetDrawsContent(true);
4173 dummy_replica_layer2->SetDrawsContent(true);
4174
4138 gfx::Transform backface_matrix; 4175 gfx::Transform backface_matrix;
4139 backface_matrix.Translate(50.0, 50.0); 4176 backface_matrix.Translate(50.0, 50.0);
4140 backface_matrix.RotateAboutYAxis(180.0); 4177 backface_matrix.RotateAboutYAxis(180.0);
4141 backface_matrix.Translate(-50.0, -50.0); 4178 backface_matrix.Translate(-50.0, -50.0);
4142 4179
4143 // Opacity will not force creation of render surfaces in this case because of
4144 // the preserve-3d transform style. Instead, an example of when a surface
4145 // would be created with preserve-3d is when there is a replica layer.
4146 front_facing_surface->SetReplicaLayer(dummy_replica_layer1.get());
4147 back_facing_surface->SetReplicaLayer(dummy_replica_layer2.get());
4148
4149 // Each surface creates its own new 3d rendering context (as defined by W3C 4180 // Each surface creates its own new 3d rendering context (as defined by W3C
4150 // spec). According to current W3C CSS gfx::Transforms spec, layers in a 3d 4181 // spec). According to current W3C CSS gfx::Transforms spec, layers in a 3d
4151 // rendering context should use the transform with respect to that context. 4182 // rendering context should use the transform with respect to that context.
4152 // This 3d rendering context occurs when (a) parent's transform style is flat 4183 // This 3d rendering context occurs when (a) parent's transform style is flat
4153 // and (b) the layer's transform style is preserve-3d. 4184 // and (b) the layer's transform style is preserve-3d.
4154 SetLayerPropertiesForTesting(parent.get(), 4185 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(),
4155 identity_matrix, 4186 gfx::PointF(), gfx::Size(100, 100), true,
4156 gfx::Point3F(),
4157 gfx::PointF(),
4158 gfx::Size(100, 100),
4159 true,
4160 false); // parent transform style is flat. 4187 false); // parent transform style is flat.
4161 SetLayerPropertiesForTesting(front_facing_child.get(), 4188 SetLayerPropertiesForTesting(front_facing_child, identity_matrix,
4162 identity_matrix, 4189 gfx::Point3F(), gfx::PointF(),
4163 gfx::Point3F(), 4190 gfx::Size(100, 100), true, false);
4164 gfx::PointF(), 4191 SetLayerPropertiesForTesting(back_facing_child, backface_matrix,
4165 gfx::Size(100, 100), 4192 gfx::Point3F(), gfx::PointF(),
4166 true, 4193 gfx::Size(100, 100), true, false);
4167 false);
4168 SetLayerPropertiesForTesting(back_facing_child.get(),
4169 backface_matrix,
4170 gfx::Point3F(),
4171 gfx::PointF(),
4172 gfx::Size(100, 100),
4173 true,
4174 false);
4175 // surface transform style is preserve-3d. 4194 // surface transform style is preserve-3d.
4176 SetLayerPropertiesForTesting(front_facing_surface.get(), 4195 SetLayerPropertiesForTesting(front_facing_surface, identity_matrix,
4177 identity_matrix, 4196 gfx::Point3F(), gfx::PointF(),
4178 gfx::Point3F(), 4197 gfx::Size(100, 100), false, true);
4179 gfx::PointF(),
4180 gfx::Size(100, 100),
4181 false,
4182 true);
4183 // surface transform style is preserve-3d. 4198 // surface transform style is preserve-3d.
4184 SetLayerPropertiesForTesting(back_facing_surface.get(), 4199 SetLayerPropertiesForTesting(back_facing_surface, backface_matrix,
4185 backface_matrix, 4200 gfx::Point3F(), gfx::PointF(),
4186 gfx::Point3F(), 4201 gfx::Size(100, 100), false, true);
4187 gfx::PointF(), 4202 SetLayerPropertiesForTesting(front_facing_child_of_front_facing_surface,
4188 gfx::Size(100, 100), 4203 identity_matrix, gfx::Point3F(), gfx::PointF(),
4189 false, 4204 gfx::Size(100, 100), true, true);
4190 true); 4205 SetLayerPropertiesForTesting(back_facing_child_of_front_facing_surface,
4191 SetLayerPropertiesForTesting(front_facing_child_of_front_facing_surface.get(), 4206 backface_matrix, gfx::Point3F(), gfx::PointF(),
4192 identity_matrix, 4207 gfx::Size(100, 100), true, true);
4193 gfx::Point3F(), 4208 SetLayerPropertiesForTesting(front_facing_child_of_back_facing_surface,
4194 gfx::PointF(), 4209 identity_matrix, gfx::Point3F(), gfx::PointF(),
4195 gfx::Size(100, 100), 4210 gfx::Size(100, 100), true, true);
4196 true, 4211 SetLayerPropertiesForTesting(back_facing_child_of_back_facing_surface,
4197 true); 4212 backface_matrix, gfx::Point3F(), gfx::PointF(),
4198 SetLayerPropertiesForTesting(back_facing_child_of_front_facing_surface.get(), 4213 gfx::Size(100, 100), true, true);
4199 backface_matrix,
4200 gfx::Point3F(),
4201 gfx::PointF(),
4202 gfx::Size(100, 100),
4203 true,
4204 true);
4205 SetLayerPropertiesForTesting(front_facing_child_of_back_facing_surface.get(),
4206 identity_matrix,
4207 gfx::Point3F(),
4208 gfx::PointF(),
4209 gfx::Size(100, 100),
4210 true,
4211 true);
4212 SetLayerPropertiesForTesting(back_facing_child_of_back_facing_surface.get(),
4213 backface_matrix,
4214 gfx::Point3F(),
4215 gfx::PointF(),
4216 gfx::Size(100, 100),
4217 true,
4218 true);
4219 4214
4220 ExecuteCalculateDrawPropertiesWithPropertyTrees(parent.get()); 4215 ExecuteCalculateDrawPropertiesWithPropertyTrees(parent);
4221 4216
4222 // Verify which render surfaces were created and used. 4217 // Verify which render surfaces were created and used.
4223 EXPECT_FALSE(front_facing_child->has_render_surface()); 4218 EXPECT_FALSE(front_facing_child->has_render_surface());
4224 EXPECT_FALSE(back_facing_child->has_render_surface()); 4219 EXPECT_FALSE(back_facing_child->has_render_surface());
4225 EXPECT_TRUE(front_facing_surface->has_render_surface()); 4220 EXPECT_TRUE(front_facing_surface->has_render_surface());
4226 // We expect that a has_render_surface was created but not used. 4221 // We expect that a has_render_surface was created but not used.
4227 EXPECT_TRUE(back_facing_surface->has_render_surface()); 4222 EXPECT_TRUE(back_facing_surface->has_render_surface());
4228 EXPECT_FALSE( 4223 EXPECT_FALSE(
4229 front_facing_child_of_front_facing_surface->has_render_surface()); 4224 front_facing_child_of_front_facing_surface->has_render_surface());
4230 EXPECT_FALSE(back_facing_child_of_front_facing_surface->has_render_surface()); 4225 EXPECT_FALSE(back_facing_child_of_front_facing_surface->has_render_surface());
4231 EXPECT_FALSE(front_facing_child_of_back_facing_surface->has_render_surface()); 4226 EXPECT_FALSE(front_facing_child_of_back_facing_surface->has_render_surface());
4232 EXPECT_FALSE(back_facing_child_of_back_facing_surface->has_render_surface()); 4227 EXPECT_FALSE(back_facing_child_of_back_facing_surface->has_render_surface());
4233 4228
4234 EXPECT_EQ(3u, update_layer_list().size()); 4229 EXPECT_EQ(3u, update_layer_list_impl()->size());
4235 4230
4236 EXPECT_TRUE(UpdateLayerListContains(front_facing_child->id())); 4231 EXPECT_TRUE(UpdateLayerListImplContains(front_facing_child->id()));
4237 EXPECT_TRUE(UpdateLayerListContains(front_facing_surface->id())); 4232 EXPECT_TRUE(UpdateLayerListImplContains(front_facing_surface->id()));
4238 EXPECT_TRUE(UpdateLayerListContains( 4233 EXPECT_TRUE(UpdateLayerListImplContains(
4239 front_facing_child_of_front_facing_surface->id())); 4234 front_facing_child_of_front_facing_surface->id()));
4240 } 4235 }
4241 4236
4242 TEST_F(LayerTreeHostCommonTest, BackFaceCullingWithAnimatingTransforms) { 4237 TEST_F(LayerTreeHostCommonTest, BackFaceCullingWithAnimatingTransforms) {
4243 // Verify that layers are appropriately culled when their back face is showing 4238 // Verify that layers are appropriately culled when their back face is showing
4244 // and they are not double sided, while animations are going on. 4239 // and they are not double sided, while animations are going on.
4245 // 4240 //
4246 // Layers that are animating do not get culled on the main thread, as their 4241 // Layers that are animating do not get culled on the main thread, as their
4247 // transforms should be treated as "unknown" so we can not be sure that their 4242 // transforms should be treated as "unknown" so we can not be sure that their
4248 // back face is really showing. 4243 // back face is really showing.
(...skipping 1727 matching lines...) Expand 10 before | Expand all | Expand 10 after
5976 5971
5977 // Sanity check our num_unclipped_descendants values. 5972 // Sanity check our num_unclipped_descendants values.
5978 EXPECT_EQ(1u, render_surface1->num_unclipped_descendants()); 5973 EXPECT_EQ(1u, render_surface1->num_unclipped_descendants());
5979 EXPECT_EQ(0u, render_surface2->num_unclipped_descendants()); 5974 EXPECT_EQ(0u, render_surface2->num_unclipped_descendants());
5980 } 5975 }
5981 5976
5982 TEST_F(LayerTreeHostCommonTest, 5977 TEST_F(LayerTreeHostCommonTest,
5983 CreateRenderSurfaceWhenFlattenInsideRenderingContext) { 5978 CreateRenderSurfaceWhenFlattenInsideRenderingContext) {
5984 // Verifies that Render Surfaces are created at the edge of rendering context. 5979 // Verifies that Render Surfaces are created at the edge of rendering context.
5985 5980
5986 scoped_refptr<LayerWithForcedDrawsContent> parent = 5981 LayerImpl* root = root_layer();
5987 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings())); 5982 LayerImpl* child1 = AddChildToRoot<LayerImpl>();
5988 Layer* root = parent.get(); 5983 LayerImpl* child2 = AddChild<LayerImpl>(child1);
5989 scoped_refptr<LayerWithForcedDrawsContent> child_1 = 5984 LayerImpl* child3 = AddChild<LayerImpl>(child2);
5990 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings())); 5985 root->SetDrawsContent(true);
5991 Layer* child1 = child_1.get();
5992 scoped_refptr<LayerWithForcedDrawsContent> child_2 =
5993 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
5994 Layer* child2 = child_2.get();
5995 scoped_refptr<LayerWithForcedDrawsContent> child_3 =
5996 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
5997 Layer* child3 = child_3.get();
5998
5999 parent->AddChild(std::move(child_1));
6000 child1->AddChild(std::move(child_2));
6001 child2->AddChild(std::move(child_3));
6002
6003 host()->SetRootLayer(root);
6004 5986
6005 const gfx::Transform identity_matrix; 5987 const gfx::Transform identity_matrix;
6006 gfx::Point3F transform_origin; 5988 gfx::Point3F transform_origin;
6007 gfx::PointF position; 5989 gfx::PointF position;
6008 gfx::Size bounds(100, 100); 5990 gfx::Size bounds(100, 100);
6009 5991
6010 SetLayerPropertiesForTesting(root, identity_matrix, transform_origin, 5992 SetLayerPropertiesForTesting(root, identity_matrix, transform_origin,
6011 position, bounds, true, false); 5993 position, bounds, true, false);
6012 SetLayerPropertiesForTesting(child1, identity_matrix, transform_origin, 5994 SetLayerPropertiesForTesting(child1, identity_matrix, transform_origin,
6013 position, bounds, false, true); 5995 position, bounds, false, true);
5996 child1->SetDrawsContent(true);
6014 SetLayerPropertiesForTesting(child2, identity_matrix, transform_origin, 5997 SetLayerPropertiesForTesting(child2, identity_matrix, transform_origin,
6015 position, bounds, true, false); 5998 position, bounds, true, false);
5999 child2->SetDrawsContent(true);
6016 SetLayerPropertiesForTesting(child3, identity_matrix, transform_origin, 6000 SetLayerPropertiesForTesting(child3, identity_matrix, transform_origin,
6017 position, bounds, true, false); 6001 position, bounds, true, false);
6002 child3->SetDrawsContent(true);
6018 6003
6019 child2->Set3dSortingContextId(1); 6004 child2->Set3dSortingContextId(1);
6020 child3->Set3dSortingContextId(1); 6005 child3->Set3dSortingContextId(1);
6021 6006
6022 ExecuteCalculateDrawPropertiesWithPropertyTrees(parent.get()); 6007 ExecuteCalculateDrawPropertiesWithPropertyTrees(root);
6023 6008
6024 // Verify which render surfaces were created. 6009 // Verify which render surfaces were created.
6025 EXPECT_TRUE(root->has_render_surface()); 6010 EXPECT_TRUE(root->has_render_surface());
6026 EXPECT_FALSE(child1->has_render_surface()); 6011 EXPECT_FALSE(child1->has_render_surface());
6027 EXPECT_TRUE(child2->has_render_surface()); 6012 EXPECT_TRUE(child2->has_render_surface());
6028 EXPECT_FALSE(child3->has_render_surface()); 6013 EXPECT_FALSE(child3->has_render_surface());
6029 } 6014 }
6030 6015
6031 TEST_F(LayerTreeHostCommonTest, CanRenderToSeparateSurface) { 6016 TEST_F(LayerTreeHostCommonTest, CanRenderToSeparateSurface) {
6032 FakeImplTaskRunnerProvider task_runner_provider; 6017 FakeImplTaskRunnerProvider task_runner_provider;
6033 TestSharedBitmapManager shared_bitmap_manager; 6018 TestSharedBitmapManager shared_bitmap_manager;
6034 TestTaskGraphRunner task_graph_runner; 6019 TestTaskGraphRunner task_graph_runner;
6035 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, 6020 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager,
6036 &task_graph_runner); 6021 &task_graph_runner);
6022
6037 scoped_ptr<LayerImpl> root = 6023 scoped_ptr<LayerImpl> root =
6038 LayerImpl::Create(host_impl.active_tree(), 12345); 6024 LayerImpl::Create(host_impl.active_tree(), 12345);
6039 scoped_ptr<LayerImpl> child1 = 6025 scoped_ptr<LayerImpl> child1 =
6040 LayerImpl::Create(host_impl.active_tree(), 123456); 6026 LayerImpl::Create(host_impl.active_tree(), 123456);
6041 scoped_ptr<LayerImpl> child2 = 6027 scoped_ptr<LayerImpl> child2 =
6042 LayerImpl::Create(host_impl.active_tree(), 1234567); 6028 LayerImpl::Create(host_impl.active_tree(), 1234567);
6043 scoped_ptr<LayerImpl> child3 = 6029 scoped_ptr<LayerImpl> child3 =
6044 LayerImpl::Create(host_impl.active_tree(), 12345678); 6030 LayerImpl::Create(host_impl.active_tree(), 12345678);
6045 6031
6046 gfx::Transform identity_matrix; 6032 gfx::Transform identity_matrix;
(...skipping 1474 matching lines...) Expand 10 before | Expand all | Expand 10 after
7521 7507
7522 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl.active_tree(), 1); 7508 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl.active_tree(), 1);
7523 LayerImpl* root_layer = root.get(); 7509 LayerImpl* root_layer = root.get();
7524 scoped_ptr<LayerImpl> child1 = LayerImpl::Create(host_impl.active_tree(), 2); 7510 scoped_ptr<LayerImpl> child1 = LayerImpl::Create(host_impl.active_tree(), 2);
7525 LayerImpl* child1_layer = child1.get(); 7511 LayerImpl* child1_layer = child1.get();
7526 scoped_ptr<LayerImpl> child2 = LayerImpl::Create(host_impl.active_tree(), 3); 7512 scoped_ptr<LayerImpl> child2 = LayerImpl::Create(host_impl.active_tree(), 3);
7527 LayerImpl* child2_layer = child2.get(); 7513 LayerImpl* child2_layer = child2.get();
7528 7514
7529 root->AddChild(std::move(child1)); 7515 root->AddChild(std::move(child1));
7530 root->AddChild(std::move(child2)); 7516 root->AddChild(std::move(child2));
7531 root->SetHasRenderSurface(true); 7517 root->SetForceRenderSurface(true);
7532 root->SetDrawsContent(true); 7518 root->SetDrawsContent(true);
7533 7519
7534 gfx::Transform identity_matrix, scale_transform_child1, 7520 gfx::Transform identity_matrix, scale_transform_child1,
7535 scale_transform_child2; 7521 scale_transform_child2;
7536 scale_transform_child1.Scale(2, 3); 7522 scale_transform_child1.Scale(2, 3);
7537 scale_transform_child2.Scale(4, 5); 7523 scale_transform_child2.Scale(4, 5);
7538 7524
7539 SetLayerPropertiesForTesting(root_layer, identity_matrix, gfx::Point3F(), 7525 SetLayerPropertiesForTesting(root_layer, identity_matrix, gfx::Point3F(),
7540 gfx::PointF(), gfx::Size(1, 1), true, false, 7526 gfx::PointF(), gfx::Size(1, 1), true, false,
7541 true); 7527 true);
7542 SetLayerPropertiesForTesting(child1_layer, scale_transform_child1, 7528 SetLayerPropertiesForTesting(child1_layer, scale_transform_child1,
7543 gfx::Point3F(), gfx::PointF(), gfx::Size(1, 1), 7529 gfx::Point3F(), gfx::PointF(), gfx::Size(1, 1),
7544 true, false, false); 7530 true, false, false);
7545 7531
7546 child1_layer->SetMaskLayer(LayerImpl::Create(host_impl.active_tree(), 4)); 7532 child1_layer->SetMaskLayer(LayerImpl::Create(host_impl.active_tree(), 4));
7547 child1_layer->SetDrawsContent(true); 7533 child1_layer->SetDrawsContent(true);
7548 7534
7549 scoped_ptr<LayerImpl> replica_layer = 7535 scoped_ptr<LayerImpl> replica_layer =
7550 LayerImpl::Create(host_impl.active_tree(), 5); 7536 LayerImpl::Create(host_impl.active_tree(), 5);
7551 replica_layer->SetHasRenderSurface(true);
7552 replica_layer->SetMaskLayer(LayerImpl::Create(host_impl.active_tree(), 6)); 7537 replica_layer->SetMaskLayer(LayerImpl::Create(host_impl.active_tree(), 6));
7553 child1_layer->SetReplicaLayer(std::move(replica_layer)); 7538 child1_layer->SetReplicaLayer(std::move(replica_layer));
7554 child1_layer->SetHasRenderSurface(true); 7539 child1_layer->SetHasRenderSurface(true);
7555 7540
7556 ExecuteCalculateDrawProperties(root_layer); 7541 ExecuteCalculateDrawProperties(root_layer);
7557 7542
7558 TransformOperations scale; 7543 TransformOperations scale;
7559 scale.AppendScale(5.f, 8.f, 3.f); 7544 scale.AppendScale(5.f, 8.f, 3.f);
7560 7545
7561 AddAnimatedTransformToLayer(child2_layer, 1.0, TransformOperations(), scale); 7546 AddAnimatedTransformToLayer(child2_layer, 1.0, TransformOperations(), scale);
(...skipping 1194 matching lines...) Expand 10 before | Expand all | Expand 10 after
8756 transform1.RotateAboutXAxis(30); 8741 transform1.RotateAboutXAxis(30);
8757 // This transform should be a 3d transform as we want the render surface 8742 // This transform should be a 3d transform as we want the render surface
8758 // to flatten the transform 8743 // to flatten the transform
8759 gfx::Transform transform2; 8744 gfx::Transform transform2;
8760 transform2.Translate3d(10, 10, 10); 8745 transform2.Translate3d(10, 10, 10);
8761 8746
8762 layer_clips_subtree->SetMasksToBounds(true); 8747 layer_clips_subtree->SetMasksToBounds(true);
8763 test_layer->SetDrawsContent(true); 8748 test_layer->SetDrawsContent(true);
8764 8749
8765 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), 8750 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(),
8766 gfx::PointF(), gfx::Size(30, 30), true, false, 8751 gfx::PointF(), gfx::Size(30, 30), true, false);
8767 true);
8768 SetLayerPropertiesForTesting(significant_transform, transform1, 8752 SetLayerPropertiesForTesting(significant_transform, transform1,
8769 gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30), 8753 gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30),
8770 true, false, false); 8754 true, false);
8771 SetLayerPropertiesForTesting(layer_clips_subtree, identity_matrix, 8755 SetLayerPropertiesForTesting(layer_clips_subtree, identity_matrix,
8772 gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30), 8756 gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30),
8773 true, false, false); 8757 true, false);
8774 SetLayerPropertiesForTesting(render_surface, transform2, gfx::Point3F(), 8758 SetLayerPropertiesForTesting(render_surface, transform2, gfx::Point3F(),
8775 gfx::PointF(), gfx::Size(30, 30), true, false, 8759 gfx::PointF(), gfx::Size(30, 30), true, false);
8776 true);
8777 SetLayerPropertiesForTesting(test_layer, identity_matrix, gfx::Point3F(), 8760 SetLayerPropertiesForTesting(test_layer, identity_matrix, gfx::Point3F(),
8778 gfx::PointF(), gfx::Size(30, 30), true, false, 8761 gfx::PointF(), gfx::Size(30, 30), true, false);
8779 false);
8780 8762
8763 root->SetForceRenderSurface(true);
8764 significant_transform->SetForceRenderSurface(false);
8765 layer_clips_subtree->SetForceRenderSurface(true);
8766 render_surface->SetForceRenderSurface(true);
8767 test_layer->SetForceRenderSurface(false);
8781 ExecuteCalculateDrawProperties(root); 8768 ExecuteCalculateDrawProperties(root);
8782 8769
8783 TransformTree transform_tree = 8770 TransformTree transform_tree =
8784 root->layer_tree_impl()->property_trees()->transform_tree; 8771 root->layer_tree_impl()->property_trees()->transform_tree;
8785 TransformNode* transform_node = 8772 TransformNode* transform_node =
8786 transform_tree.Node(significant_transform->transform_tree_index()); 8773 transform_tree.Node(significant_transform->transform_tree_index());
8787 EXPECT_EQ(transform_node->owner_id, significant_transform->id()); 8774 EXPECT_EQ(transform_node->owner_id, significant_transform->id());
8788 8775
8776 EXPECT_TRUE(root->has_render_surface());
8777 EXPECT_FALSE(significant_transform->has_render_surface());
8778 EXPECT_TRUE(layer_clips_subtree->has_render_surface());
8779 EXPECT_TRUE(render_surface->has_render_surface());
8780 EXPECT_FALSE(test_layer->has_render_surface());
8781
8789 ClipTree clip_tree = root->layer_tree_impl()->property_trees()->clip_tree; 8782 ClipTree clip_tree = root->layer_tree_impl()->property_trees()->clip_tree;
8790 ClipNode* clip_node = clip_tree.Node(render_surface->clip_tree_index()); 8783 ClipNode* clip_node = clip_tree.Node(render_surface->clip_tree_index());
8791 EXPECT_FALSE(clip_node->data.applies_local_clip); 8784 EXPECT_FALSE(clip_node->data.applies_local_clip);
8792 EXPECT_EQ(gfx::Rect(30, 21), test_layer->visible_rect_from_property_trees()); 8785 EXPECT_EQ(gfx::Rect(22, 21), test_layer->visible_rect_from_property_trees());
ajuma 2015/12/02 14:54:21 Is this change because layer_clips_subtree has a s
weiliangc 2015/12/02 18:16:38 Mostly before ptree is built using LayerImpl's has
ajuma 2015/12/02 18:25:08 Ah, that makes sense, thanks.
8793 } 8786 }
8794 8787
8795 TEST_F(LayerTreeHostCommonTest, TransformOfParentClipNodeAncestorOfTarget) { 8788 TEST_F(LayerTreeHostCommonTest, TransformOfParentClipNodeAncestorOfTarget) {
8796 // Ensure that when parent clip node's transform is an ancestor of current 8789 // Ensure that when parent clip node's transform is an ancestor of current
8797 // clip node's target, clip is 'projected' from parent space to current 8790 // clip node's target, clip is 'projected' from parent space to current
8798 // target space and visible rects are calculated correctly. 8791 // target space and visible rects are calculated correctly.
8799 LayerImpl* root = root_layer(); 8792 LayerImpl* root = root_layer();
8800 LayerImpl* clip_layer = AddChild<LayerImpl>(root); 8793 LayerImpl* clip_layer = AddChild<LayerImpl>(root);
8801 LayerImpl* target_layer = AddChild<LayerImpl>(clip_layer); 8794 LayerImpl* target_layer = AddChild<LayerImpl>(clip_layer);
8802 LayerImpl* test_layer = AddChild<LayerImpl>(target_layer); 8795 LayerImpl* test_layer = AddChild<LayerImpl>(target_layer);
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
9311 bool root_in_rsll = 9304 bool root_in_rsll =
9312 std::find(rsll->begin(), rsll->end(), root) != rsll->end(); 9305 std::find(rsll->begin(), rsll->end(), root) != rsll->end();
9313 EXPECT_TRUE(root_in_rsll); 9306 EXPECT_TRUE(root_in_rsll);
9314 bool render_surface2_in_rsll = 9307 bool render_surface2_in_rsll =
9315 std::find(rsll->begin(), rsll->end(), render_surface2) != rsll->end(); 9308 std::find(rsll->begin(), rsll->end(), render_surface2) != rsll->end();
9316 EXPECT_FALSE(render_surface2_in_rsll); 9309 EXPECT_FALSE(render_surface2_in_rsll);
9317 } 9310 }
9318 9311
9319 } // namespace 9312 } // namespace
9320 } // namespace cc 9313 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698