OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/trees/layer_tree_host_common.h" | 5 #include "cc/trees/layer_tree_host_common.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "cc/animation/layer_animation_controller.h" | 10 #include "cc/animation/layer_animation_controller.h" |
(...skipping 1807 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1818 { | 1818 { |
1819 RenderSurfaceLayerList render_surface_layer_list; | 1819 RenderSurfaceLayerList render_surface_layer_list; |
1820 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( | 1820 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( |
1821 root.get(), parent->bounds(), &render_surface_layer_list); | 1821 root.get(), parent->bounds(), &render_surface_layer_list); |
1822 inputs.can_adjust_raster_scales = true; | 1822 inputs.can_adjust_raster_scales = true; |
1823 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 1823 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
1824 | 1824 |
1825 ASSERT_TRUE(root->render_surface()); | 1825 ASSERT_TRUE(root->render_surface()); |
1826 ASSERT_TRUE(child2->render_surface()); | 1826 ASSERT_TRUE(child2->render_surface()); |
1827 | 1827 |
1828 EXPECT_FALSE(root->is_clipped()); | 1828 EXPECT_FALSE(root->is_clipped_from_property_tree()); |
1829 EXPECT_TRUE(root->render_surface()->is_clipped()); | 1829 EXPECT_TRUE(root->render_surface()->is_clipped()); |
1830 EXPECT_FALSE(parent->is_clipped()); | 1830 EXPECT_FALSE(parent->is_clipped_from_property_tree()); |
1831 EXPECT_FALSE(child1->is_clipped()); | 1831 EXPECT_FALSE(child1->is_clipped_from_property_tree()); |
1832 EXPECT_FALSE(child2->is_clipped()); | 1832 EXPECT_FALSE(child2->is_clipped_from_property_tree()); |
1833 EXPECT_FALSE(child2->render_surface()->is_clipped()); | 1833 EXPECT_FALSE(child2->render_surface()->is_clipped()); |
1834 EXPECT_FALSE(grand_child->is_clipped()); | 1834 EXPECT_FALSE(grand_child->is_clipped_from_property_tree()); |
1835 EXPECT_FALSE(leaf_node1->is_clipped()); | 1835 EXPECT_FALSE(leaf_node1->is_clipped_from_property_tree()); |
1836 EXPECT_FALSE(leaf_node2->is_clipped()); | 1836 EXPECT_FALSE(leaf_node2->is_clipped_from_property_tree()); |
1837 } | 1837 } |
1838 | 1838 |
1839 // Case 2: parent masksToBounds, so the parent, child1, and child2's | 1839 // Case 2: parent masksToBounds, so the parent, child1, and child2's |
1840 // surface are clipped. But layers that contribute to child2's surface are | 1840 // surface are clipped. But layers that contribute to child2's surface are |
1841 // not clipped explicitly because child2's surface already accounts for | 1841 // not clipped explicitly because child2's surface already accounts for |
1842 // that clip. | 1842 // that clip. |
1843 { | 1843 { |
1844 RenderSurfaceLayerList render_surface_layer_list; | 1844 RenderSurfaceLayerList render_surface_layer_list; |
1845 parent->SetMasksToBounds(true); | 1845 parent->SetMasksToBounds(true); |
1846 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( | 1846 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( |
1847 root.get(), parent->bounds(), &render_surface_layer_list); | 1847 root.get(), parent->bounds(), &render_surface_layer_list); |
1848 inputs.can_adjust_raster_scales = true; | 1848 inputs.can_adjust_raster_scales = true; |
1849 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 1849 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
1850 | 1850 |
1851 ASSERT_TRUE(root->render_surface()); | 1851 ASSERT_TRUE(root->render_surface()); |
1852 ASSERT_TRUE(child2->render_surface()); | 1852 ASSERT_TRUE(child2->render_surface()); |
1853 | 1853 |
1854 EXPECT_FALSE(root->is_clipped()); | 1854 EXPECT_FALSE(root->is_clipped_from_property_tree()); |
1855 EXPECT_TRUE(root->render_surface()->is_clipped()); | 1855 EXPECT_TRUE(root->render_surface()->is_clipped()); |
1856 EXPECT_TRUE(parent->is_clipped()); | 1856 EXPECT_TRUE(parent->is_clipped_from_property_tree()); |
1857 EXPECT_TRUE(child1->is_clipped()); | 1857 EXPECT_TRUE(child1->is_clipped_from_property_tree()); |
1858 EXPECT_FALSE(child2->is_clipped()); | 1858 EXPECT_FALSE(child2->is_clipped_from_property_tree()); |
1859 EXPECT_TRUE(child2->render_surface()->is_clipped()); | 1859 EXPECT_TRUE(child2->render_surface()->is_clipped()); |
1860 EXPECT_TRUE(grand_child->is_clipped()); | 1860 EXPECT_TRUE(grand_child->is_clipped_from_property_tree()); |
1861 EXPECT_TRUE(leaf_node1->is_clipped()); | 1861 EXPECT_TRUE(leaf_node1->is_clipped_from_property_tree()); |
1862 EXPECT_FALSE(leaf_node2->is_clipped()); | 1862 EXPECT_FALSE(leaf_node2->is_clipped_from_property_tree()); |
1863 } | 1863 } |
1864 | 1864 |
1865 // Case 3: child2 masksToBounds. The layer and subtree are clipped, and | 1865 // Case 3: child2 masksToBounds. The layer and subtree are clipped, and |
1866 // child2's render surface is not clipped. | 1866 // child2's render surface is not clipped. |
1867 { | 1867 { |
1868 RenderSurfaceLayerList render_surface_layer_list; | 1868 RenderSurfaceLayerList render_surface_layer_list; |
1869 parent->SetMasksToBounds(false); | 1869 parent->SetMasksToBounds(false); |
1870 child2->SetMasksToBounds(true); | 1870 child2->SetMasksToBounds(true); |
1871 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( | 1871 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( |
1872 root.get(), parent->bounds(), &render_surface_layer_list); | 1872 root.get(), parent->bounds(), &render_surface_layer_list); |
1873 inputs.can_adjust_raster_scales = true; | 1873 inputs.can_adjust_raster_scales = true; |
1874 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 1874 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
1875 | 1875 |
1876 ASSERT_TRUE(root->render_surface()); | 1876 ASSERT_TRUE(root->render_surface()); |
1877 ASSERT_TRUE(child2->render_surface()); | 1877 ASSERT_TRUE(child2->render_surface()); |
1878 | 1878 |
1879 EXPECT_FALSE(root->is_clipped()); | 1879 EXPECT_FALSE(root->is_clipped_from_property_tree()); |
1880 EXPECT_TRUE(root->render_surface()->is_clipped()); | 1880 EXPECT_TRUE(root->render_surface()->is_clipped()); |
1881 EXPECT_FALSE(parent->is_clipped()); | 1881 EXPECT_FALSE(parent->is_clipped_from_property_tree()); |
1882 EXPECT_FALSE(child1->is_clipped()); | 1882 EXPECT_FALSE(child1->is_clipped_from_property_tree()); |
1883 EXPECT_TRUE(child2->is_clipped()); | 1883 EXPECT_TRUE(child2->is_clipped_from_property_tree()); |
1884 EXPECT_FALSE(child2->render_surface()->is_clipped()); | 1884 EXPECT_FALSE(child2->render_surface()->is_clipped()); |
1885 EXPECT_FALSE(grand_child->is_clipped()); | 1885 EXPECT_FALSE(grand_child->is_clipped_from_property_tree()); |
1886 EXPECT_FALSE(leaf_node1->is_clipped()); | 1886 EXPECT_FALSE(leaf_node1->is_clipped_from_property_tree()); |
1887 EXPECT_TRUE(leaf_node2->is_clipped()); | 1887 EXPECT_TRUE(leaf_node2->is_clipped_from_property_tree()); |
1888 } | 1888 } |
1889 } | 1889 } |
1890 | 1890 |
1891 TEST_F(LayerTreeHostCommonTest, DrawableContentRectForLayers) { | 1891 TEST_F(LayerTreeHostCommonTest, DrawableContentRectForLayers) { |
1892 // Verify that layers get the appropriate DrawableContentRect when their | 1892 // Verify that layers get the appropriate DrawableContentRect when their |
1893 // parent masksToBounds is true. | 1893 // parent masksToBounds is true. |
1894 // | 1894 // |
1895 // grand_child1 - completely inside the region; DrawableContentRect should | 1895 // grand_child1 - completely inside the region; DrawableContentRect should |
1896 // be the layer rect expressed in target space. | 1896 // be the layer rect expressed in target space. |
1897 // grand_child2 - partially clipped but NOT masksToBounds; the clip rect | 1897 // grand_child2 - partially clipped but NOT masksToBounds; the clip rect |
(...skipping 1034 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2932 gfx::PointF(125.f, 125.f), gfx::Size(50, 50), | 2932 gfx::PointF(125.f, 125.f), gfx::Size(50, 50), |
2933 true, false); | 2933 true, false); |
2934 | 2934 |
2935 RenderSurfaceLayerList render_surface_layer_list; | 2935 RenderSurfaceLayerList render_surface_layer_list; |
2936 // Now set the root render surface an empty clip. | 2936 // Now set the root render surface an empty clip. |
2937 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( | 2937 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( |
2938 root.get(), gfx::Size(), &render_surface_layer_list); | 2938 root.get(), gfx::Size(), &render_surface_layer_list); |
2939 | 2939 |
2940 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 2940 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
2941 ASSERT_TRUE(root->render_surface()); | 2941 ASSERT_TRUE(root->render_surface()); |
2942 EXPECT_FALSE(root->is_clipped()); | 2942 EXPECT_FALSE(root->is_clipped_from_property_tree()); |
2943 | 2943 |
2944 gfx::Rect empty; | 2944 gfx::Rect empty; |
2945 EXPECT_EQ(empty, root->render_surface()->clip_rect()); | 2945 EXPECT_EQ(empty, root->render_surface()->clip_rect()); |
2946 EXPECT_TRUE(root->render_surface()->is_clipped()); | 2946 EXPECT_TRUE(root->render_surface()->is_clipped()); |
2947 | 2947 |
2948 // Visible content rect calculation will check if the target surface is | 2948 // Visible content rect calculation will check if the target surface is |
2949 // clipped or not. An empty clip rect does not indicate the render surface | 2949 // clipped or not. An empty clip rect does not indicate the render surface |
2950 // is unclipped. | 2950 // is unclipped. |
2951 EXPECT_EQ(empty, child1->visible_layer_rect()); | 2951 EXPECT_EQ(empty, child1->visible_layer_rect()); |
2952 EXPECT_EQ(empty, child2->visible_layer_rect()); | 2952 EXPECT_EQ(empty, child2->visible_layer_rect()); |
(...skipping 2820 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5773 EXPECT_EQ(gfx::Rect(0, 0, 0, 0).ToString(), | 5773 EXPECT_EQ(gfx::Rect(0, 0, 0, 0).ToString(), |
5774 render_surface1->render_surface()->clip_rect().ToString()); | 5774 render_surface1->render_surface()->clip_rect().ToString()); |
5775 EXPECT_FALSE(render_surface1->render_surface()->is_clipped()); | 5775 EXPECT_FALSE(render_surface1->render_surface()->is_clipped()); |
5776 EXPECT_EQ(gfx::Rect(0, 0, 0, 0).ToString(), | 5776 EXPECT_EQ(gfx::Rect(0, 0, 0, 0).ToString(), |
5777 render_surface2->render_surface()->clip_rect().ToString()); | 5777 render_surface2->render_surface()->clip_rect().ToString()); |
5778 EXPECT_FALSE(render_surface2->render_surface()->is_clipped()); | 5778 EXPECT_FALSE(render_surface2->render_surface()->is_clipped()); |
5779 | 5779 |
5780 // NB: clip rects are in target space. | 5780 // NB: clip rects are in target space. |
5781 EXPECT_EQ(gfx::Rect(0, 0, 40, 40).ToString(), | 5781 EXPECT_EQ(gfx::Rect(0, 0, 40, 40).ToString(), |
5782 render_surface1->clip_rect().ToString()); | 5782 render_surface1->clip_rect().ToString()); |
5783 EXPECT_TRUE(render_surface1->is_clipped()); | 5783 EXPECT_TRUE(render_surface1->is_clipped_from_property_tree()); |
5784 | 5784 |
5785 // This value is inherited from the clipping ancestor layer, 'intervening'. | 5785 // This value is inherited from the clipping ancestor layer, 'intervening'. |
5786 EXPECT_EQ(gfx::Rect(0, 0, 5, 5).ToString(), | 5786 EXPECT_EQ(gfx::Rect(0, 0, 5, 5).ToString(), |
5787 render_surface2->clip_rect().ToString()); | 5787 render_surface2->clip_rect().ToString()); |
5788 EXPECT_TRUE(render_surface2->is_clipped()); | 5788 EXPECT_TRUE(render_surface2->is_clipped_from_property_tree()); |
5789 | 5789 |
5790 // The content rects of both render surfaces should both have expanded to | 5790 // The content rects of both render surfaces should both have expanded to |
5791 // contain the clip child. | 5791 // contain the clip child. |
5792 EXPECT_EQ(gfx::Rect(0, 0, 40, 40).ToString(), | 5792 EXPECT_EQ(gfx::Rect(0, 0, 40, 40).ToString(), |
5793 render_surface1->render_surface()->content_rect().ToString()); | 5793 render_surface1->render_surface()->content_rect().ToString()); |
5794 EXPECT_EQ(gfx::Rect(-1, -1, 40, 40).ToString(), | 5794 EXPECT_EQ(gfx::Rect(-1, -1, 40, 40).ToString(), |
5795 render_surface2->render_surface()->content_rect().ToString()); | 5795 render_surface2->render_surface()->content_rect().ToString()); |
5796 | 5796 |
5797 // The clip child should have inherited the clip parent's clip (projected to | 5797 // The clip child should have inherited the clip parent's clip (projected to |
5798 // the right space, of course), and should have the correctly sized visible | 5798 // the right space, of course), and should have the correctly sized visible |
5799 // content rect. | 5799 // content rect. |
5800 EXPECT_EQ(gfx::Rect(-1, -1, 40, 40).ToString(), | 5800 EXPECT_EQ(gfx::Rect(-1, -1, 40, 40).ToString(), |
5801 clip_child->clip_rect().ToString()); | 5801 clip_child->clip_rect().ToString()); |
5802 EXPECT_EQ(gfx::Rect(9, 9, 40, 40).ToString(), | 5802 EXPECT_EQ(gfx::Rect(9, 9, 40, 40).ToString(), |
5803 clip_child->visible_layer_rect().ToString()); | 5803 clip_child->visible_layer_rect().ToString()); |
5804 EXPECT_TRUE(clip_child->is_clipped()); | 5804 EXPECT_TRUE(clip_child->is_clipped_from_property_tree()); |
5805 } | 5805 } |
5806 | 5806 |
5807 TEST_F(LayerTreeHostCommonTest, ClipParentScrolledInterveningLayer) { | 5807 TEST_F(LayerTreeHostCommonTest, ClipParentScrolledInterveningLayer) { |
5808 // Ensure that intervening render surfaces are not a problem, even if there | 5808 // Ensure that intervening render surfaces are not a problem, even if there |
5809 // is a scroll involved. Note, we do _not_ have to consider any other sort | 5809 // is a scroll involved. Note, we do _not_ have to consider any other sort |
5810 // of transform. | 5810 // of transform. |
5811 // | 5811 // |
5812 // root (a render surface) | 5812 // root (a render surface) |
5813 // + clip_parent (masks to bounds) | 5813 // + clip_parent (masks to bounds) |
5814 // + render_surface1 (sets opacity) | 5814 // + render_surface1 (sets opacity) |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5901 EXPECT_EQ(gfx::Rect(0, 0, 0, 0).ToString(), | 5901 EXPECT_EQ(gfx::Rect(0, 0, 0, 0).ToString(), |
5902 render_surface1->render_surface()->clip_rect().ToString()); | 5902 render_surface1->render_surface()->clip_rect().ToString()); |
5903 EXPECT_FALSE(render_surface1->render_surface()->is_clipped()); | 5903 EXPECT_FALSE(render_surface1->render_surface()->is_clipped()); |
5904 EXPECT_EQ(gfx::Rect(0, 0, 0, 0).ToString(), | 5904 EXPECT_EQ(gfx::Rect(0, 0, 0, 0).ToString(), |
5905 render_surface2->render_surface()->clip_rect().ToString()); | 5905 render_surface2->render_surface()->clip_rect().ToString()); |
5906 EXPECT_FALSE(render_surface2->render_surface()->is_clipped()); | 5906 EXPECT_FALSE(render_surface2->render_surface()->is_clipped()); |
5907 | 5907 |
5908 // NB: clip rects are in target space. | 5908 // NB: clip rects are in target space. |
5909 EXPECT_EQ(gfx::Rect(0, 0, 40, 40).ToString(), | 5909 EXPECT_EQ(gfx::Rect(0, 0, 40, 40).ToString(), |
5910 render_surface1->clip_rect().ToString()); | 5910 render_surface1->clip_rect().ToString()); |
5911 EXPECT_TRUE(render_surface1->is_clipped()); | 5911 EXPECT_TRUE(render_surface1->is_clipped_from_property_tree()); |
5912 | 5912 |
5913 // This value is inherited from the clipping ancestor layer, 'intervening'. | 5913 // This value is inherited from the clipping ancestor layer, 'intervening'. |
5914 EXPECT_EQ(gfx::Rect(2, 2, 3, 3).ToString(), | 5914 EXPECT_EQ(gfx::Rect(2, 2, 3, 3).ToString(), |
5915 render_surface2->clip_rect().ToString()); | 5915 render_surface2->clip_rect().ToString()); |
5916 EXPECT_TRUE(render_surface2->is_clipped()); | 5916 EXPECT_TRUE(render_surface2->is_clipped_from_property_tree()); |
5917 | 5917 |
5918 // The content rects of both render surfaces should both have expanded to | 5918 // The content rects of both render surfaces should both have expanded to |
5919 // contain the clip child. | 5919 // contain the clip child. |
5920 EXPECT_EQ(gfx::Rect(0, 0, 40, 40).ToString(), | 5920 EXPECT_EQ(gfx::Rect(0, 0, 40, 40).ToString(), |
5921 render_surface1->render_surface()->content_rect().ToString()); | 5921 render_surface1->render_surface()->content_rect().ToString()); |
5922 EXPECT_EQ(gfx::Rect(2, 2, 40, 40).ToString(), | 5922 EXPECT_EQ(gfx::Rect(2, 2, 40, 40).ToString(), |
5923 render_surface2->render_surface()->content_rect().ToString()); | 5923 render_surface2->render_surface()->content_rect().ToString()); |
5924 | 5924 |
5925 // The clip child should have inherited the clip parent's clip (projected to | 5925 // The clip child should have inherited the clip parent's clip (projected to |
5926 // the right space, of course), and should have the correctly sized visible | 5926 // the right space, of course), and should have the correctly sized visible |
5927 // content rect. | 5927 // content rect. |
5928 EXPECT_EQ(gfx::Rect(2, 2, 40, 40).ToString(), | 5928 EXPECT_EQ(gfx::Rect(2, 2, 40, 40).ToString(), |
5929 clip_child->clip_rect().ToString()); | 5929 clip_child->clip_rect().ToString()); |
5930 EXPECT_EQ(gfx::Rect(12, 12, 40, 40).ToString(), | 5930 EXPECT_EQ(gfx::Rect(12, 12, 40, 40).ToString(), |
5931 clip_child->visible_layer_rect().ToString()); | 5931 clip_child->visible_layer_rect().ToString()); |
5932 EXPECT_TRUE(clip_child->is_clipped()); | 5932 EXPECT_TRUE(clip_child->is_clipped_from_property_tree()); |
5933 } | 5933 } |
5934 | 5934 |
5935 TEST_F(LayerTreeHostCommonTest, DescendantsOfClipChildren) { | 5935 TEST_F(LayerTreeHostCommonTest, DescendantsOfClipChildren) { |
5936 // Ensures that descendants of the clip child inherit the correct clip. | 5936 // Ensures that descendants of the clip child inherit the correct clip. |
5937 // | 5937 // |
5938 // root (a render surface) | 5938 // root (a render surface) |
5939 // + clip_parent (masks to bounds) | 5939 // + clip_parent (masks to bounds) |
5940 // + intervening (masks to bounds) | 5940 // + intervening (masks to bounds) |
5941 // + clip_child | 5941 // + clip_child |
5942 // + child | 5942 // + child |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5998 host()->SetRootLayer(root); | 5998 host()->SetRootLayer(root); |
5999 | 5999 |
6000 ExecuteCalculateDrawProperties(root.get()); | 6000 ExecuteCalculateDrawProperties(root.get()); |
6001 | 6001 |
6002 EXPECT_TRUE(root->render_surface()); | 6002 EXPECT_TRUE(root->render_surface()); |
6003 | 6003 |
6004 // Neither the clip child nor its descendant should have inherited the clip | 6004 // Neither the clip child nor its descendant should have inherited the clip |
6005 // from |intervening|. | 6005 // from |intervening|. |
6006 EXPECT_EQ(gfx::Rect(0, 0, 40, 40).ToString(), | 6006 EXPECT_EQ(gfx::Rect(0, 0, 40, 40).ToString(), |
6007 clip_child->clip_rect().ToString()); | 6007 clip_child->clip_rect().ToString()); |
6008 EXPECT_TRUE(clip_child->is_clipped()); | 6008 EXPECT_TRUE(clip_child->is_clipped_from_property_tree()); |
6009 EXPECT_EQ(gfx::Rect(0, 0, 40, 40).ToString(), | 6009 EXPECT_EQ(gfx::Rect(0, 0, 40, 40).ToString(), |
6010 child->visible_layer_rect().ToString()); | 6010 child->visible_layer_rect().ToString()); |
6011 EXPECT_TRUE(child->is_clipped()); | 6011 EXPECT_TRUE(child->is_clipped_from_property_tree()); |
6012 } | 6012 } |
6013 | 6013 |
6014 TEST_F(LayerTreeHostCommonTest, | 6014 TEST_F(LayerTreeHostCommonTest, |
6015 SurfacesShouldBeUnaffectedByNonDescendantClipChildren) { | 6015 SurfacesShouldBeUnaffectedByNonDescendantClipChildren) { |
6016 // Ensures that non-descendant clip children in the tree do not affect | 6016 // Ensures that non-descendant clip children in the tree do not affect |
6017 // render surfaces. | 6017 // render surfaces. |
6018 // | 6018 // |
6019 // root (a render surface) | 6019 // root (a render surface) |
6020 // + clip_parent (masks to bounds) | 6020 // + clip_parent (masks to bounds) |
6021 // + render_surface1 | 6021 // + render_surface1 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6094 host()->SetRootLayer(root); | 6094 host()->SetRootLayer(root); |
6095 | 6095 |
6096 ExecuteCalculateDrawProperties(root.get()); | 6096 ExecuteCalculateDrawProperties(root.get()); |
6097 | 6097 |
6098 EXPECT_TRUE(root->render_surface()); | 6098 EXPECT_TRUE(root->render_surface()); |
6099 EXPECT_TRUE(render_surface1->render_surface()); | 6099 EXPECT_TRUE(render_surface1->render_surface()); |
6100 EXPECT_TRUE(render_surface2->render_surface()); | 6100 EXPECT_TRUE(render_surface2->render_surface()); |
6101 | 6101 |
6102 EXPECT_EQ(gfx::Rect(0, 0, 5, 5).ToString(), | 6102 EXPECT_EQ(gfx::Rect(0, 0, 5, 5).ToString(), |
6103 render_surface1->clip_rect().ToString()); | 6103 render_surface1->clip_rect().ToString()); |
6104 EXPECT_TRUE(render_surface1->is_clipped()); | 6104 EXPECT_TRUE(render_surface1->is_clipped_from_property_tree()); |
6105 | 6105 |
6106 // The render surface should not clip (it has unclipped descendants), instead | 6106 // The render surface should not clip (it has unclipped descendants), instead |
6107 // it should rely on layer clipping. | 6107 // it should rely on layer clipping. |
6108 EXPECT_EQ(gfx::Rect(0, 0, 0, 0).ToString(), | 6108 EXPECT_EQ(gfx::Rect(0, 0, 0, 0).ToString(), |
6109 render_surface1->render_surface()->clip_rect().ToString()); | 6109 render_surface1->render_surface()->clip_rect().ToString()); |
6110 EXPECT_FALSE(render_surface1->render_surface()->is_clipped()); | 6110 EXPECT_FALSE(render_surface1->render_surface()->is_clipped()); |
6111 | 6111 |
6112 // That said, it should have grown to accomodate the unclipped descendant. | 6112 // That said, it should have grown to accomodate the unclipped descendant. |
6113 EXPECT_EQ(gfx::Rect(-1, 1, 6, 4).ToString(), | 6113 EXPECT_EQ(gfx::Rect(-1, 1, 6, 4).ToString(), |
6114 render_surface1->render_surface()->content_rect().ToString()); | 6114 render_surface1->render_surface()->content_rect().ToString()); |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6349 false); | 6349 false); |
6350 | 6350 |
6351 host()->SetRootLayer(root); | 6351 host()->SetRootLayer(root); |
6352 | 6352 |
6353 ExecuteCalculateDrawProperties(root.get()); | 6353 ExecuteCalculateDrawProperties(root.get()); |
6354 | 6354 |
6355 EXPECT_TRUE(root->render_surface()); | 6355 EXPECT_TRUE(root->render_surface()); |
6356 | 6356 |
6357 EXPECT_EQ(gfx::Rect(0, 0, 30, 30).ToString(), | 6357 EXPECT_EQ(gfx::Rect(0, 0, 30, 30).ToString(), |
6358 scroll_child->clip_rect().ToString()); | 6358 scroll_child->clip_rect().ToString()); |
6359 EXPECT_TRUE(scroll_child->is_clipped()); | 6359 EXPECT_TRUE(scroll_child->is_clipped_from_property_tree()); |
6360 } | 6360 } |
6361 | 6361 |
6362 TEST_F(LayerTreeHostCommonTest, SingularTransformSubtreesDoNotDraw) { | 6362 TEST_F(LayerTreeHostCommonTest, SingularTransformSubtreesDoNotDraw) { |
6363 scoped_refptr<LayerWithForcedDrawsContent> root = | 6363 scoped_refptr<LayerWithForcedDrawsContent> root = |
6364 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings())); | 6364 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings())); |
6365 scoped_refptr<LayerWithForcedDrawsContent> parent = | 6365 scoped_refptr<LayerWithForcedDrawsContent> parent = |
6366 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings())); | 6366 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings())); |
6367 scoped_refptr<LayerWithForcedDrawsContent> child = | 6367 scoped_refptr<LayerWithForcedDrawsContent> child = |
6368 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings())); | 6368 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings())); |
6369 | 6369 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6464 SetLayerPropertiesForTesting(scroll_child, identity_transform, gfx::Point3F(), | 6464 SetLayerPropertiesForTesting(scroll_child, identity_transform, gfx::Point3F(), |
6465 gfx::PointF(), gfx::Size(50, 50), true, false, | 6465 gfx::PointF(), gfx::Size(50, 50), true, false, |
6466 false); | 6466 false); |
6467 | 6467 |
6468 ExecuteCalculateDrawProperties(root); | 6468 ExecuteCalculateDrawProperties(root); |
6469 | 6469 |
6470 EXPECT_TRUE(root->render_surface()); | 6470 EXPECT_TRUE(root->render_surface()); |
6471 | 6471 |
6472 EXPECT_EQ(gfx::Rect(0, 0, 30, 30).ToString(), | 6472 EXPECT_EQ(gfx::Rect(0, 0, 30, 30).ToString(), |
6473 scroll_child->clip_rect().ToString()); | 6473 scroll_child->clip_rect().ToString()); |
6474 EXPECT_TRUE(scroll_child->is_clipped()); | 6474 EXPECT_TRUE(scroll_child->is_clipped_from_property_tree()); |
6475 } | 6475 } |
6476 | 6476 |
6477 TEST_F(LayerTreeHostCommonTest, ClippedByOutOfOrderScrollGrandparent) { | 6477 TEST_F(LayerTreeHostCommonTest, ClippedByOutOfOrderScrollGrandparent) { |
6478 // Checks that clipping by a scroll parent and scroll grandparent that follow | 6478 // Checks that clipping by a scroll parent and scroll grandparent that follow |
6479 // you in paint order still results in correct clipping. | 6479 // you in paint order still results in correct clipping. |
6480 // | 6480 // |
6481 // + root | 6481 // + root |
6482 // + scroll_child | 6482 // + scroll_child |
6483 // + scroll_parent_border | 6483 // + scroll_parent_border |
6484 // | + scroll_parent_clip | 6484 // | + scroll_parent_clip |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6539 SetLayerPropertiesForTesting(scroll_child, identity_transform, gfx::Point3F(), | 6539 SetLayerPropertiesForTesting(scroll_child, identity_transform, gfx::Point3F(), |
6540 gfx::PointF(), gfx::Size(50, 50), true, false, | 6540 gfx::PointF(), gfx::Size(50, 50), true, false, |
6541 false); | 6541 false); |
6542 | 6542 |
6543 ExecuteCalculateDrawProperties(root); | 6543 ExecuteCalculateDrawProperties(root); |
6544 | 6544 |
6545 EXPECT_TRUE(root->render_surface()); | 6545 EXPECT_TRUE(root->render_surface()); |
6546 | 6546 |
6547 EXPECT_EQ(gfx::Rect(0, 0, 20, 20).ToString(), | 6547 EXPECT_EQ(gfx::Rect(0, 0, 20, 20).ToString(), |
6548 scroll_child->clip_rect().ToString()); | 6548 scroll_child->clip_rect().ToString()); |
6549 EXPECT_TRUE(scroll_child->is_clipped()); | 6549 EXPECT_TRUE(scroll_child->is_clipped_from_property_tree()); |
6550 | 6550 |
6551 // Despite the fact that we visited the above layers out of order to get the | 6551 // Despite the fact that we visited the above layers out of order to get the |
6552 // correct clip, the layer lists should be unaffected. | 6552 // correct clip, the layer lists should be unaffected. |
6553 EXPECT_EQ(3u, root->render_surface()->layer_list().size()); | 6553 EXPECT_EQ(3u, root->render_surface()->layer_list().size()); |
6554 EXPECT_EQ(scroll_child, root->render_surface()->layer_list().at(0)); | 6554 EXPECT_EQ(scroll_child, root->render_surface()->layer_list().at(0)); |
6555 EXPECT_EQ(scroll_parent, root->render_surface()->layer_list().at(1)); | 6555 EXPECT_EQ(scroll_parent, root->render_surface()->layer_list().at(1)); |
6556 EXPECT_EQ(scroll_grandparent, root->render_surface()->layer_list().at(2)); | 6556 EXPECT_EQ(scroll_grandparent, root->render_surface()->layer_list().at(2)); |
6557 } | 6557 } |
6558 | 6558 |
6559 TEST_F(LayerTreeHostCommonTest, OutOfOrderClippingRequiresRSLLSorting) { | 6559 TEST_F(LayerTreeHostCommonTest, OutOfOrderClippingRequiresRSLLSorting) { |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6635 SetLayerPropertiesForTesting(scroll_child, identity_transform, gfx::Point3F(), | 6635 SetLayerPropertiesForTesting(scroll_child, identity_transform, gfx::Point3F(), |
6636 gfx::PointF(), gfx::Size(50, 50), true, false, | 6636 gfx::PointF(), gfx::Size(50, 50), true, false, |
6637 false); | 6637 false); |
6638 | 6638 |
6639 ExecuteCalculateDrawProperties(root); | 6639 ExecuteCalculateDrawProperties(root); |
6640 | 6640 |
6641 EXPECT_TRUE(root->render_surface()); | 6641 EXPECT_TRUE(root->render_surface()); |
6642 | 6642 |
6643 EXPECT_EQ(gfx::Rect(0, 0, 20, 20).ToString(), | 6643 EXPECT_EQ(gfx::Rect(0, 0, 20, 20).ToString(), |
6644 scroll_child->clip_rect().ToString()); | 6644 scroll_child->clip_rect().ToString()); |
6645 EXPECT_TRUE(scroll_child->is_clipped()); | 6645 EXPECT_TRUE(scroll_child->is_clipped_from_property_tree()); |
6646 | 6646 |
6647 // Despite the fact that we had to process the layers out of order to get the | 6647 // Despite the fact that we had to process the layers out of order to get the |
6648 // right clip, our render_surface_layer_list's order should be unaffected. | 6648 // right clip, our render_surface_layer_list's order should be unaffected. |
6649 EXPECT_EQ(3u, render_surface_layer_list_impl()->size()); | 6649 EXPECT_EQ(3u, render_surface_layer_list_impl()->size()); |
6650 EXPECT_EQ(root, render_surface_layer_list_impl()->at(0)); | 6650 EXPECT_EQ(root, render_surface_layer_list_impl()->at(0)); |
6651 EXPECT_EQ(render_surface2, render_surface_layer_list_impl()->at(1)); | 6651 EXPECT_EQ(render_surface2, render_surface_layer_list_impl()->at(1)); |
6652 EXPECT_EQ(render_surface1, render_surface_layer_list_impl()->at(2)); | 6652 EXPECT_EQ(render_surface1, render_surface_layer_list_impl()->at(2)); |
6653 EXPECT_TRUE(render_surface_layer_list_impl()->at(0)->render_surface()); | 6653 EXPECT_TRUE(render_surface_layer_list_impl()->at(0)->render_surface()); |
6654 EXPECT_TRUE(render_surface_layer_list_impl()->at(1)->render_surface()); | 6654 EXPECT_TRUE(render_surface_layer_list_impl()->at(1)->render_surface()); |
6655 EXPECT_TRUE(render_surface_layer_list_impl()->at(2)->render_surface()); | 6655 EXPECT_TRUE(render_surface_layer_list_impl()->at(2)->render_surface()); |
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7310 | 7310 |
7311 expected.clear(); | 7311 expected.clear(); |
7312 expected.insert(grand_child2_raw); | 7312 expected.insert(grand_child2_raw); |
7313 | 7313 |
7314 actual.clear(); | 7314 actual.clear(); |
7315 GatherDrawnLayers(render_surface_layer_list_impl(), &actual); | 7315 GatherDrawnLayers(render_surface_layer_list_impl(), &actual); |
7316 EXPECT_EQ(expected, actual); | 7316 EXPECT_EQ(expected, actual); |
7317 | 7317 |
7318 // Add a mask layer to child. | 7318 // Add a mask layer to child. |
7319 child_raw->SetMaskLayer(LayerImpl::Create(host_impl.active_tree(), 6).Pass()); | 7319 child_raw->SetMaskLayer(LayerImpl::Create(host_impl.active_tree(), 6).Pass()); |
| 7320 child_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; |
7320 | 7321 |
7321 ExecuteCalculateDrawProperties(grand_parent_raw); | 7322 ExecuteCalculateDrawProperties(grand_parent_raw); |
7322 member_id = render_surface_layer_list_count(); | 7323 member_id = render_surface_layer_list_count(); |
7323 | 7324 |
7324 EXPECT_NE(member_id, membership_id(grand_parent_raw)); | 7325 EXPECT_NE(member_id, membership_id(grand_parent_raw)); |
7325 EXPECT_NE(member_id, membership_id(parent_raw)); | 7326 EXPECT_NE(member_id, membership_id(parent_raw)); |
7326 EXPECT_NE(member_id, membership_id(child_raw)); | 7327 EXPECT_NE(member_id, membership_id(child_raw)); |
7327 EXPECT_EQ(member_id, membership_id(child_raw->mask_layer())); | 7328 EXPECT_EQ(member_id, membership_id(child_raw->mask_layer())); |
7328 EXPECT_NE(member_id, membership_id(grand_child1_raw)); | 7329 EXPECT_NE(member_id, membership_id(grand_child1_raw)); |
7329 EXPECT_EQ(member_id, membership_id(grand_child2_raw)); | 7330 EXPECT_EQ(member_id, membership_id(grand_child2_raw)); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7401 EXPECT_NE(member_id, membership_id(grand_child2_raw)); | 7402 EXPECT_NE(member_id, membership_id(grand_child2_raw)); |
7402 | 7403 |
7403 expected.clear(); | 7404 expected.clear(); |
7404 expected.insert(child_raw); | 7405 expected.insert(child_raw); |
7405 expected.insert(child_raw->mask_layer()); | 7406 expected.insert(child_raw->mask_layer()); |
7406 actual.clear(); | 7407 actual.clear(); |
7407 GatherDrawnLayers(render_surface_layer_list_impl(), &actual); | 7408 GatherDrawnLayers(render_surface_layer_list_impl(), &actual); |
7408 EXPECT_EQ(expected, actual); | 7409 EXPECT_EQ(expected, actual); |
7409 | 7410 |
7410 child_raw->TakeMaskLayer(); | 7411 child_raw->TakeMaskLayer(); |
| 7412 child_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; |
7411 | 7413 |
7412 // Now everyone's a member! | 7414 // Now everyone's a member! |
7413 grand_parent_raw->SetDrawsContent(true); | 7415 grand_parent_raw->SetDrawsContent(true); |
7414 parent_raw->SetDrawsContent(true); | 7416 parent_raw->SetDrawsContent(true); |
7415 child_raw->SetDrawsContent(true); | 7417 child_raw->SetDrawsContent(true); |
7416 grand_child1_raw->SetDrawsContent(true); | 7418 grand_child1_raw->SetDrawsContent(true); |
7417 grand_child2_raw->SetDrawsContent(true); | 7419 grand_child2_raw->SetDrawsContent(true); |
7418 | 7420 |
7419 ExecuteCalculateDrawProperties(grand_parent_raw); | 7421 ExecuteCalculateDrawProperties(grand_parent_raw); |
7420 member_id = render_surface_layer_list_count(); | 7422 member_id = render_surface_layer_list_count(); |
(...skipping 1191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8612 EXPECT_FALSE(root->layer_or_descendant_is_drawn()); | 8614 EXPECT_FALSE(root->layer_or_descendant_is_drawn()); |
8613 EXPECT_FALSE(root->visited()); | 8615 EXPECT_FALSE(root->visited()); |
8614 EXPECT_FALSE(root->sorted_for_recursion()); | 8616 EXPECT_FALSE(root->sorted_for_recursion()); |
8615 EXPECT_FALSE(child->layer_or_descendant_is_drawn()); | 8617 EXPECT_FALSE(child->layer_or_descendant_is_drawn()); |
8616 EXPECT_FALSE(child->visited()); | 8618 EXPECT_FALSE(child->visited()); |
8617 EXPECT_FALSE(child->sorted_for_recursion()); | 8619 EXPECT_FALSE(child->sorted_for_recursion()); |
8618 } | 8620 } |
8619 | 8621 |
8620 } // namespace | 8622 } // namespace |
8621 } // namespace cc | 8623 } // namespace cc |
OLD | NEW |