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

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

Powered by Google App Engine
This is Rietveld 408576698