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

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

Issue 1175113010: cc: Rename visible_content_rect and content stuff on quads. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rename-visible-content-rect: moreandroid Created 5 years, 6 months 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.cc » ('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 9
10 #include "cc/animation/layer_animation_controller.h" 10 #include "cc/animation/layer_animation_controller.h"
(...skipping 2674 matching lines...) Expand 10 before | Expand all | Expand 10 after
2685 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), 2685 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(),
2686 gfx::PointF(60, 70), gfx::Size(100, 100), true, 2686 gfx::PointF(60, 70), gfx::Size(100, 100), true,
2687 false); 2687 false);
2688 ExecuteCalculateDrawProperties(root.get()); 2688 ExecuteCalculateDrawProperties(root.get());
2689 2689
2690 EXPECT_EQ(gfx::Rect(0, 0, 100, 100), 2690 EXPECT_EQ(gfx::Rect(0, 0, 100, 100),
2691 root->render_surface()->DrawableContentRect()); 2691 root->render_surface()->DrawableContentRect());
2692 // In target space, not clipped. 2692 // In target space, not clipped.
2693 EXPECT_EQ(gfx::Rect(60, 70, 100, 100), root->drawable_content_rect()); 2693 EXPECT_EQ(gfx::Rect(60, 70, 100, 100), root->drawable_content_rect());
2694 // In layer space, clipped. 2694 // In layer space, clipped.
2695 EXPECT_EQ(gfx::Rect(0, 0, 40, 30), root->visible_content_rect()); 2695 EXPECT_EQ(gfx::Rect(0, 0, 40, 30), root->visible_layer_rect());
2696 } 2696 }
2697 2697
2698 TEST_F(LayerTreeHostCommonTest, DrawableAndVisibleContentRectsForSimpleLayers) { 2698 TEST_F(LayerTreeHostCommonTest, DrawableAndVisibleContentRectsForSimpleLayers) {
2699 scoped_refptr<Layer> root = Layer::Create(layer_settings()); 2699 scoped_refptr<Layer> root = Layer::Create(layer_settings());
2700 scoped_refptr<LayerWithForcedDrawsContent> child1 = 2700 scoped_refptr<LayerWithForcedDrawsContent> child1 =
2701 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings())); 2701 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
2702 scoped_refptr<LayerWithForcedDrawsContent> child2 = 2702 scoped_refptr<LayerWithForcedDrawsContent> child2 =
2703 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings())); 2703 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
2704 scoped_refptr<LayerWithForcedDrawsContent> child3 = 2704 scoped_refptr<LayerWithForcedDrawsContent> child3 =
2705 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings())); 2705 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
2739 gfx::Size(50, 50), 2739 gfx::Size(50, 50),
2740 true, 2740 true,
2741 false); 2741 false);
2742 2742
2743 ExecuteCalculateDrawProperties(root.get()); 2743 ExecuteCalculateDrawProperties(root.get());
2744 2744
2745 EXPECT_EQ(gfx::Rect(0, 0, 100, 100), 2745 EXPECT_EQ(gfx::Rect(0, 0, 100, 100),
2746 root->render_surface()->DrawableContentRect()); 2746 root->render_surface()->DrawableContentRect());
2747 EXPECT_EQ(gfx::Rect(0, 0, 100, 100), root->drawable_content_rect()); 2747 EXPECT_EQ(gfx::Rect(0, 0, 100, 100), root->drawable_content_rect());
2748 2748
2749 // Layers that do not draw content should have empty visible_content_rects. 2749 // Layers that do not draw content should have empty visible_layer_rects.
2750 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_content_rect()); 2750 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_layer_rect());
2751 2751
2752 // layer visible_content_rects are clipped by their target surface. 2752 // layer visible_layer_rects are clipped by their target surface.
2753 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child1->visible_content_rect()); 2753 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child1->visible_layer_rect());
2754 EXPECT_EQ(gfx::Rect(0, 0, 25, 25), child2->visible_content_rect()); 2754 EXPECT_EQ(gfx::Rect(0, 0, 25, 25), child2->visible_layer_rect());
2755 EXPECT_TRUE(child3->visible_content_rect().IsEmpty()); 2755 EXPECT_TRUE(child3->visible_layer_rect().IsEmpty());
2756 2756
2757 // layer drawable_content_rects are not clipped. 2757 // layer drawable_content_rects are not clipped.
2758 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child1->drawable_content_rect()); 2758 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child1->drawable_content_rect());
2759 EXPECT_EQ(gfx::Rect(75, 75, 50, 50), child2->drawable_content_rect()); 2759 EXPECT_EQ(gfx::Rect(75, 75, 50, 50), child2->drawable_content_rect());
2760 EXPECT_EQ(gfx::Rect(125, 125, 50, 50), child3->drawable_content_rect()); 2760 EXPECT_EQ(gfx::Rect(125, 125, 50, 50), child3->drawable_content_rect());
2761 } 2761 }
2762 2762
2763 TEST_F(LayerTreeHostCommonTest, 2763 TEST_F(LayerTreeHostCommonTest,
2764 DrawableAndVisibleContentRectsForLayersClippedByLayer) { 2764 DrawableAndVisibleContentRectsForLayersClippedByLayer) {
2765 scoped_refptr<Layer> root = Layer::Create(layer_settings()); 2765 scoped_refptr<Layer> root = Layer::Create(layer_settings());
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
2818 child->SetMasksToBounds(true); 2818 child->SetMasksToBounds(true);
2819 ExecuteCalculateDrawProperties(root.get()); 2819 ExecuteCalculateDrawProperties(root.get());
2820 2820
2821 ASSERT_FALSE(child->render_surface()); 2821 ASSERT_FALSE(child->render_surface());
2822 2822
2823 EXPECT_EQ(gfx::Rect(0, 0, 100, 100), 2823 EXPECT_EQ(gfx::Rect(0, 0, 100, 100),
2824 root->render_surface()->DrawableContentRect()); 2824 root->render_surface()->DrawableContentRect());
2825 EXPECT_EQ(gfx::Rect(0, 0, 100, 100), root->drawable_content_rect()); 2825 EXPECT_EQ(gfx::Rect(0, 0, 100, 100), root->drawable_content_rect());
2826 2826
2827 // Layers that do not draw content should have empty visible content rects. 2827 // Layers that do not draw content should have empty visible content rects.
2828 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_content_rect()); 2828 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_layer_rect());
2829 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), child->visible_content_rect()); 2829 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), child->visible_layer_rect());
2830 2830
2831 // All grandchild visible content rects should be clipped by child. 2831 // All grandchild visible content rects should be clipped by child.
2832 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), grand_child1->visible_content_rect()); 2832 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), grand_child1->visible_layer_rect());
2833 EXPECT_EQ(gfx::Rect(0, 0, 25, 25), grand_child2->visible_content_rect()); 2833 EXPECT_EQ(gfx::Rect(0, 0, 25, 25), grand_child2->visible_layer_rect());
2834 EXPECT_TRUE(grand_child3->visible_content_rect().IsEmpty()); 2834 EXPECT_TRUE(grand_child3->visible_layer_rect().IsEmpty());
2835 2835
2836 // All grandchild DrawableContentRects should also be clipped by child. 2836 // All grandchild DrawableContentRects should also be clipped by child.
2837 EXPECT_EQ(gfx::Rect(5, 5, 50, 50), grand_child1->drawable_content_rect()); 2837 EXPECT_EQ(gfx::Rect(5, 5, 50, 50), grand_child1->drawable_content_rect());
2838 EXPECT_EQ(gfx::Rect(75, 75, 25, 25), grand_child2->drawable_content_rect()); 2838 EXPECT_EQ(gfx::Rect(75, 75, 25, 25), grand_child2->drawable_content_rect());
2839 EXPECT_TRUE(grand_child3->drawable_content_rect().IsEmpty()); 2839 EXPECT_TRUE(grand_child3->drawable_content_rect().IsEmpty());
2840 } 2840 }
2841 2841
2842 TEST_F(LayerTreeHostCommonTest, VisibleContentRectWithClippingAndScaling) { 2842 TEST_F(LayerTreeHostCommonTest, VisibleContentRectWithClippingAndScaling) {
2843 scoped_refptr<Layer> root = Layer::Create(layer_settings()); 2843 scoped_refptr<Layer> root = Layer::Create(layer_settings());
2844 scoped_refptr<Layer> child = Layer::Create(layer_settings()); 2844 scoped_refptr<Layer> child = Layer::Create(layer_settings());
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
2930 render_surface1->SetForceRenderSurface(true); 2930 render_surface1->SetForceRenderSurface(true);
2931 ExecuteCalculateDrawProperties(root.get()); 2931 ExecuteCalculateDrawProperties(root.get());
2932 2932
2933 ASSERT_TRUE(render_surface1->render_surface()); 2933 ASSERT_TRUE(render_surface1->render_surface());
2934 2934
2935 EXPECT_EQ(gfx::Rect(0, 0, 100, 100), 2935 EXPECT_EQ(gfx::Rect(0, 0, 100, 100),
2936 root->render_surface()->DrawableContentRect()); 2936 root->render_surface()->DrawableContentRect());
2937 EXPECT_EQ(gfx::Rect(0, 0, 100, 100), root->drawable_content_rect()); 2937 EXPECT_EQ(gfx::Rect(0, 0, 100, 100), root->drawable_content_rect());
2938 2938
2939 // Layers that do not draw content should have empty visible content rects. 2939 // Layers that do not draw content should have empty visible content rects.
2940 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_content_rect()); 2940 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_layer_rect());
2941 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), render_surface1->visible_content_rect()); 2941 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), render_surface1->visible_layer_rect());
2942 2942
2943 // An unclipped surface grows its DrawableContentRect to include all drawable 2943 // An unclipped surface grows its DrawableContentRect to include all drawable
2944 // regions of the subtree. 2944 // regions of the subtree.
2945 EXPECT_EQ(gfx::Rect(5, 5, 170, 170), 2945 EXPECT_EQ(gfx::Rect(5, 5, 170, 170),
2946 render_surface1->render_surface()->DrawableContentRect()); 2946 render_surface1->render_surface()->DrawableContentRect());
2947 2947
2948 // All layers that draw content into the unclipped surface are also unclipped. 2948 // All layers that draw content into the unclipped surface are also unclipped.
2949 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child1->visible_content_rect()); 2949 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child1->visible_layer_rect());
2950 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child2->visible_content_rect()); 2950 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child2->visible_layer_rect());
2951 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child3->visible_content_rect()); 2951 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child3->visible_layer_rect());
2952 2952
2953 EXPECT_EQ(gfx::Rect(5, 5, 50, 50), child1->drawable_content_rect()); 2953 EXPECT_EQ(gfx::Rect(5, 5, 50, 50), child1->drawable_content_rect());
2954 EXPECT_EQ(gfx::Rect(75, 75, 50, 50), child2->drawable_content_rect()); 2954 EXPECT_EQ(gfx::Rect(75, 75, 50, 50), child2->drawable_content_rect());
2955 EXPECT_EQ(gfx::Rect(125, 125, 50, 50), child3->drawable_content_rect()); 2955 EXPECT_EQ(gfx::Rect(125, 125, 50, 50), child3->drawable_content_rect());
2956 } 2956 }
2957 2957
2958 TEST_F(LayerTreeHostCommonTest, 2958 TEST_F(LayerTreeHostCommonTest,
2959 VisibleContentRectsForClippedSurfaceWithEmptyClip) { 2959 VisibleContentRectsForClippedSurfaceWithEmptyClip) {
2960 scoped_refptr<Layer> root = Layer::Create(layer_settings()); 2960 scoped_refptr<Layer> root = Layer::Create(layer_settings());
2961 scoped_refptr<LayerWithForcedDrawsContent> child1 = 2961 scoped_refptr<LayerWithForcedDrawsContent> child1 =
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
2993 ASSERT_TRUE(root->render_surface()); 2993 ASSERT_TRUE(root->render_surface());
2994 EXPECT_FALSE(root->is_clipped()); 2994 EXPECT_FALSE(root->is_clipped());
2995 2995
2996 gfx::Rect empty; 2996 gfx::Rect empty;
2997 EXPECT_EQ(empty, root->render_surface()->clip_rect()); 2997 EXPECT_EQ(empty, root->render_surface()->clip_rect());
2998 EXPECT_TRUE(root->render_surface()->is_clipped()); 2998 EXPECT_TRUE(root->render_surface()->is_clipped());
2999 2999
3000 // Visible content rect calculation will check if the target surface is 3000 // Visible content rect calculation will check if the target surface is
3001 // clipped or not. An empty clip rect does not indicate the render surface 3001 // clipped or not. An empty clip rect does not indicate the render surface
3002 // is unclipped. 3002 // is unclipped.
3003 EXPECT_EQ(empty, child1->visible_content_rect()); 3003 EXPECT_EQ(empty, child1->visible_layer_rect());
3004 EXPECT_EQ(empty, child2->visible_content_rect()); 3004 EXPECT_EQ(empty, child2->visible_layer_rect());
3005 EXPECT_EQ(empty, child3->visible_content_rect()); 3005 EXPECT_EQ(empty, child3->visible_layer_rect());
3006 } 3006 }
3007 3007
3008 TEST_F(LayerTreeHostCommonTest, 3008 TEST_F(LayerTreeHostCommonTest,
3009 DrawableAndVisibleContentRectsForLayersWithUninvertibleTransform) { 3009 DrawableAndVisibleContentRectsForLayersWithUninvertibleTransform) {
3010 scoped_refptr<Layer> root = Layer::Create(layer_settings()); 3010 scoped_refptr<Layer> root = Layer::Create(layer_settings());
3011 scoped_refptr<LayerWithForcedDrawsContent> child = 3011 scoped_refptr<LayerWithForcedDrawsContent> child =
3012 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings())); 3012 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
3013 root->AddChild(child); 3013 root->AddChild(child);
3014 3014
3015 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); 3015 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
(...skipping 14 matching lines...) Expand all
3030 SetLayerPropertiesForTesting(child.get(), 3030 SetLayerPropertiesForTesting(child.get(),
3031 uninvertible_matrix, 3031 uninvertible_matrix,
3032 gfx::Point3F(), 3032 gfx::Point3F(),
3033 gfx::PointF(5.f, 5.f), 3033 gfx::PointF(5.f, 5.f),
3034 gfx::Size(50, 50), 3034 gfx::Size(50, 50),
3035 true, 3035 true,
3036 false); 3036 false);
3037 3037
3038 ExecuteCalculateDrawProperties(root.get()); 3038 ExecuteCalculateDrawProperties(root.get());
3039 3039
3040 EXPECT_TRUE(child->visible_content_rect().IsEmpty()); 3040 EXPECT_TRUE(child->visible_layer_rect().IsEmpty());
3041 EXPECT_TRUE(child->drawable_content_rect().IsEmpty()); 3041 EXPECT_TRUE(child->drawable_content_rect().IsEmpty());
3042 3042
3043 // Case 2: a matrix with flattened z, uninvertible and not visible according 3043 // Case 2: a matrix with flattened z, uninvertible and not visible according
3044 // to the CSS spec. 3044 // to the CSS spec.
3045 uninvertible_matrix.MakeIdentity(); 3045 uninvertible_matrix.MakeIdentity();
3046 uninvertible_matrix.matrix().set(2, 2, 0.0); 3046 uninvertible_matrix.matrix().set(2, 2, 0.0);
3047 ASSERT_FALSE(uninvertible_matrix.IsInvertible()); 3047 ASSERT_FALSE(uninvertible_matrix.IsInvertible());
3048 3048
3049 SetLayerPropertiesForTesting(child.get(), 3049 SetLayerPropertiesForTesting(child.get(),
3050 uninvertible_matrix, 3050 uninvertible_matrix,
3051 gfx::Point3F(), 3051 gfx::Point3F(),
3052 gfx::PointF(5.f, 5.f), 3052 gfx::PointF(5.f, 5.f),
3053 gfx::Size(50, 50), 3053 gfx::Size(50, 50),
3054 true, 3054 true,
3055 false); 3055 false);
3056 3056
3057 ExecuteCalculateDrawProperties(root.get()); 3057 ExecuteCalculateDrawProperties(root.get());
3058 3058
3059 EXPECT_TRUE(child->visible_content_rect().IsEmpty()); 3059 EXPECT_TRUE(child->visible_layer_rect().IsEmpty());
3060 EXPECT_TRUE(child->drawable_content_rect().IsEmpty()); 3060 EXPECT_TRUE(child->drawable_content_rect().IsEmpty());
3061 3061
3062 // Case 3: a matrix with flattened z, also uninvertible and not visible. 3062 // Case 3: a matrix with flattened z, also uninvertible and not visible.
3063 uninvertible_matrix.MakeIdentity(); 3063 uninvertible_matrix.MakeIdentity();
3064 uninvertible_matrix.Translate(500.0, 0.0); 3064 uninvertible_matrix.Translate(500.0, 0.0);
3065 uninvertible_matrix.matrix().set(2, 2, 0.0); 3065 uninvertible_matrix.matrix().set(2, 2, 0.0);
3066 ASSERT_FALSE(uninvertible_matrix.IsInvertible()); 3066 ASSERT_FALSE(uninvertible_matrix.IsInvertible());
3067 3067
3068 SetLayerPropertiesForTesting(child.get(), 3068 SetLayerPropertiesForTesting(child.get(),
3069 uninvertible_matrix, 3069 uninvertible_matrix,
3070 gfx::Point3F(), 3070 gfx::Point3F(),
3071 gfx::PointF(5.f, 5.f), 3071 gfx::PointF(5.f, 5.f),
3072 gfx::Size(50, 50), 3072 gfx::Size(50, 50),
3073 true, 3073 true,
3074 false); 3074 false);
3075 3075
3076 ExecuteCalculateDrawProperties(root.get()); 3076 ExecuteCalculateDrawProperties(root.get());
3077 3077
3078 EXPECT_TRUE(child->visible_content_rect().IsEmpty()); 3078 EXPECT_TRUE(child->visible_layer_rect().IsEmpty());
3079 EXPECT_TRUE(child->drawable_content_rect().IsEmpty()); 3079 EXPECT_TRUE(child->drawable_content_rect().IsEmpty());
3080 } 3080 }
3081 3081
3082 TEST_F(LayerTreeHostCommonTest, 3082 TEST_F(LayerTreeHostCommonTest,
3083 SingularTransformDoesNotPreventClearingDrawProperties) { 3083 SingularTransformDoesNotPreventClearingDrawProperties) {
3084 scoped_refptr<Layer> root = Layer::Create(layer_settings()); 3084 scoped_refptr<Layer> root = Layer::Create(layer_settings());
3085 scoped_refptr<LayerWithForcedDrawsContent> child = 3085 scoped_refptr<LayerWithForcedDrawsContent> child =
3086 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings())); 3086 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
3087 root->AddChild(child); 3087 root->AddChild(child);
3088 3088
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
3213 render_surface1->SetForceRenderSurface(true); 3213 render_surface1->SetForceRenderSurface(true);
3214 ExecuteCalculateDrawProperties(root.get()); 3214 ExecuteCalculateDrawProperties(root.get());
3215 3215
3216 ASSERT_TRUE(render_surface1->render_surface()); 3216 ASSERT_TRUE(render_surface1->render_surface());
3217 3217
3218 EXPECT_EQ(gfx::Rect(0, 0, 100, 100), 3218 EXPECT_EQ(gfx::Rect(0, 0, 100, 100),
3219 root->render_surface()->DrawableContentRect()); 3219 root->render_surface()->DrawableContentRect());
3220 EXPECT_EQ(gfx::Rect(0, 0, 100, 100), root->drawable_content_rect()); 3220 EXPECT_EQ(gfx::Rect(0, 0, 100, 100), root->drawable_content_rect());
3221 3221
3222 // Layers that do not draw content should have empty visible content rects. 3222 // Layers that do not draw content should have empty visible content rects.
3223 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_content_rect()); 3223 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_layer_rect());
3224 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), render_surface1->visible_content_rect()); 3224 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), render_surface1->visible_layer_rect());
3225 3225
3226 // A clipped surface grows its DrawableContentRect to include all drawable 3226 // A clipped surface grows its DrawableContentRect to include all drawable
3227 // regions of the subtree, but also gets clamped by the ancestor's clip. 3227 // regions of the subtree, but also gets clamped by the ancestor's clip.
3228 EXPECT_EQ(gfx::Rect(5, 5, 95, 95), 3228 EXPECT_EQ(gfx::Rect(5, 5, 95, 95),
3229 render_surface1->render_surface()->DrawableContentRect()); 3229 render_surface1->render_surface()->DrawableContentRect());
3230 3230
3231 // All layers that draw content into the surface have their visible content 3231 // All layers that draw content into the surface have their visible content
3232 // rect clipped by the surface clip rect. 3232 // rect clipped by the surface clip rect.
3233 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child1->visible_content_rect()); 3233 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child1->visible_layer_rect());
3234 EXPECT_EQ(gfx::Rect(0, 0, 25, 25), child2->visible_content_rect()); 3234 EXPECT_EQ(gfx::Rect(0, 0, 25, 25), child2->visible_layer_rect());
3235 EXPECT_TRUE(child3->visible_content_rect().IsEmpty()); 3235 EXPECT_TRUE(child3->visible_layer_rect().IsEmpty());
3236 3236
3237 // But the DrawableContentRects are unclipped. 3237 // But the DrawableContentRects are unclipped.
3238 EXPECT_EQ(gfx::Rect(5, 5, 50, 50), child1->drawable_content_rect()); 3238 EXPECT_EQ(gfx::Rect(5, 5, 50, 50), child1->drawable_content_rect());
3239 EXPECT_EQ(gfx::Rect(75, 75, 50, 50), child2->drawable_content_rect()); 3239 EXPECT_EQ(gfx::Rect(75, 75, 50, 50), child2->drawable_content_rect());
3240 EXPECT_EQ(gfx::Rect(125, 125, 50, 50), child3->drawable_content_rect()); 3240 EXPECT_EQ(gfx::Rect(125, 125, 50, 50), child3->drawable_content_rect());
3241 } 3241 }
3242 3242
3243 TEST_F(LayerTreeHostCommonTest, 3243 TEST_F(LayerTreeHostCommonTest,
3244 DrawableAndVisibleContentRectsForSurfaceHierarchy) { 3244 DrawableAndVisibleContentRectsForSurfaceHierarchy) {
3245 // Check that clipping does not propagate down surfaces. 3245 // Check that clipping does not propagate down surfaces.
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
3311 ExecuteCalculateDrawProperties(root.get()); 3311 ExecuteCalculateDrawProperties(root.get());
3312 3312
3313 ASSERT_TRUE(render_surface1->render_surface()); 3313 ASSERT_TRUE(render_surface1->render_surface());
3314 ASSERT_TRUE(render_surface2->render_surface()); 3314 ASSERT_TRUE(render_surface2->render_surface());
3315 3315
3316 EXPECT_EQ(gfx::Rect(0, 0, 100, 100), 3316 EXPECT_EQ(gfx::Rect(0, 0, 100, 100),
3317 root->render_surface()->DrawableContentRect()); 3317 root->render_surface()->DrawableContentRect());
3318 EXPECT_EQ(gfx::Rect(0, 0, 100, 100), root->drawable_content_rect()); 3318 EXPECT_EQ(gfx::Rect(0, 0, 100, 100), root->drawable_content_rect());
3319 3319
3320 // Layers that do not draw content should have empty visible content rects. 3320 // Layers that do not draw content should have empty visible content rects.
3321 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_content_rect()); 3321 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_layer_rect());
3322 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), render_surface1->visible_content_rect()); 3322 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), render_surface1->visible_layer_rect());
3323 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), render_surface2->visible_content_rect()); 3323 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), render_surface2->visible_layer_rect());
3324 3324
3325 // A clipped surface grows its DrawableContentRect to include all drawable 3325 // A clipped surface grows its DrawableContentRect to include all drawable
3326 // regions of the subtree, but also gets clamped by the ancestor's clip. 3326 // regions of the subtree, but also gets clamped by the ancestor's clip.
3327 EXPECT_EQ(gfx::Rect(5, 5, 95, 95), 3327 EXPECT_EQ(gfx::Rect(5, 5, 95, 95),
3328 render_surface1->render_surface()->DrawableContentRect()); 3328 render_surface1->render_surface()->DrawableContentRect());
3329 3329
3330 // render_surface1 lives in the "unclipped universe" of render_surface1, and 3330 // render_surface1 lives in the "unclipped universe" of render_surface1, and
3331 // is only implicitly clipped by render_surface1's content rect. So, 3331 // is only implicitly clipped by render_surface1's content rect. So,
3332 // render_surface2 grows to enclose all drawable content of its subtree. 3332 // render_surface2 grows to enclose all drawable content of its subtree.
3333 EXPECT_EQ(gfx::Rect(5, 5, 170, 170), 3333 EXPECT_EQ(gfx::Rect(5, 5, 170, 170),
3334 render_surface2->render_surface()->DrawableContentRect()); 3334 render_surface2->render_surface()->DrawableContentRect());
3335 3335
3336 // All layers that draw content into render_surface2 think they are unclipped. 3336 // All layers that draw content into render_surface2 think they are unclipped.
3337 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child1->visible_content_rect()); 3337 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child1->visible_layer_rect());
3338 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child2->visible_content_rect()); 3338 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child2->visible_layer_rect());
3339 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child3->visible_content_rect()); 3339 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child3->visible_layer_rect());
3340 3340
3341 // DrawableContentRects are also unclipped. 3341 // DrawableContentRects are also unclipped.
3342 EXPECT_EQ(gfx::Rect(5, 5, 50, 50), child1->drawable_content_rect()); 3342 EXPECT_EQ(gfx::Rect(5, 5, 50, 50), child1->drawable_content_rect());
3343 EXPECT_EQ(gfx::Rect(75, 75, 50, 50), child2->drawable_content_rect()); 3343 EXPECT_EQ(gfx::Rect(75, 75, 50, 50), child2->drawable_content_rect());
3344 EXPECT_EQ(gfx::Rect(125, 125, 50, 50), child3->drawable_content_rect()); 3344 EXPECT_EQ(gfx::Rect(125, 125, 50, 50), child3->drawable_content_rect());
3345 } 3345 }
3346 3346
3347 TEST_F(LayerTreeHostCommonTest, 3347 TEST_F(LayerTreeHostCommonTest,
3348 DrawableAndVisibleContentRectsWithTransformOnUnclippedSurface) { 3348 DrawableAndVisibleContentRectsWithTransformOnUnclippedSurface) {
3349 // Layers that have non-axis aligned bounds (due to transforms) have an 3349 // Layers that have non-axis aligned bounds (due to transforms) have an
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
3387 render_surface1->SetForceRenderSurface(true); 3387 render_surface1->SetForceRenderSurface(true);
3388 ExecuteCalculateDrawProperties(root.get()); 3388 ExecuteCalculateDrawProperties(root.get());
3389 3389
3390 ASSERT_TRUE(render_surface1->render_surface()); 3390 ASSERT_TRUE(render_surface1->render_surface());
3391 3391
3392 EXPECT_EQ(gfx::Rect(0, 0, 100, 100), 3392 EXPECT_EQ(gfx::Rect(0, 0, 100, 100),
3393 root->render_surface()->DrawableContentRect()); 3393 root->render_surface()->DrawableContentRect());
3394 EXPECT_EQ(gfx::Rect(0, 0, 100, 100), root->drawable_content_rect()); 3394 EXPECT_EQ(gfx::Rect(0, 0, 100, 100), root->drawable_content_rect());
3395 3395
3396 // Layers that do not draw content should have empty visible content rects. 3396 // Layers that do not draw content should have empty visible content rects.
3397 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_content_rect()); 3397 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_layer_rect());
3398 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), render_surface1->visible_content_rect()); 3398 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), render_surface1->visible_layer_rect());
3399 3399
3400 // The unclipped surface grows its DrawableContentRect to include all drawable 3400 // The unclipped surface grows its DrawableContentRect to include all drawable
3401 // regions of the subtree. 3401 // regions of the subtree.
3402 int diagonal_radius = ceil(sqrt(2.0) * 25.0); 3402 int diagonal_radius = ceil(sqrt(2.0) * 25.0);
3403 gfx::Rect expected_surface_drawable_content = 3403 gfx::Rect expected_surface_drawable_content =
3404 gfx::Rect(50 - diagonal_radius, 3404 gfx::Rect(50 - diagonal_radius,
3405 50 - diagonal_radius, 3405 50 - diagonal_radius,
3406 diagonal_radius * 2, 3406 diagonal_radius * 2,
3407 diagonal_radius * 2); 3407 diagonal_radius * 2);
3408 EXPECT_EQ(expected_surface_drawable_content, 3408 EXPECT_EQ(expected_surface_drawable_content,
3409 render_surface1->render_surface()->DrawableContentRect()); 3409 render_surface1->render_surface()->DrawableContentRect());
3410 3410
3411 // All layers that draw content into the unclipped surface are also unclipped. 3411 // All layers that draw content into the unclipped surface are also unclipped.
3412 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child1->visible_content_rect()); 3412 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child1->visible_layer_rect());
3413 EXPECT_EQ(expected_surface_drawable_content, child1->drawable_content_rect()); 3413 EXPECT_EQ(expected_surface_drawable_content, child1->drawable_content_rect());
3414 } 3414 }
3415 3415
3416 TEST_F(LayerTreeHostCommonTest, 3416 TEST_F(LayerTreeHostCommonTest,
3417 DrawableAndVisibleContentRectsWithTransformOnClippedSurface) { 3417 DrawableAndVisibleContentRectsWithTransformOnClippedSurface) {
3418 // Layers that have non-axis aligned bounds (due to transforms) have an 3418 // Layers that have non-axis aligned bounds (due to transforms) have an
3419 // expanded, axis-aligned DrawableContentRect and visible content rect. 3419 // expanded, axis-aligned DrawableContentRect and visible content rect.
3420 3420
3421 scoped_refptr<Layer> root = Layer::Create(layer_settings()); 3421 scoped_refptr<Layer> root = Layer::Create(layer_settings());
3422 scoped_refptr<Layer> render_surface1 = Layer::Create(layer_settings()); 3422 scoped_refptr<Layer> render_surface1 = Layer::Create(layer_settings());
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
3470 gfx::Rect expected_surface_drawable_content = 3470 gfx::Rect expected_surface_drawable_content =
3471 gfx::IntersectRects(unclipped_surface_content, gfx::Rect(0, 0, 50, 50)); 3471 gfx::IntersectRects(unclipped_surface_content, gfx::Rect(0, 0, 50, 50));
3472 EXPECT_EQ(expected_surface_drawable_content, 3472 EXPECT_EQ(expected_surface_drawable_content,
3473 render_surface1->render_surface()->DrawableContentRect()); 3473 render_surface1->render_surface()->DrawableContentRect());
3474 3474
3475 // On the clipped surface, only a quarter of the child1 is visible, but when 3475 // On the clipped surface, only a quarter of the child1 is visible, but when
3476 // rotating it back to child1's content space, the actual enclosing rect ends 3476 // rotating it back to child1's content space, the actual enclosing rect ends
3477 // up covering the full left half of child1. 3477 // up covering the full left half of child1.
3478 // 3478 //
3479 // Given the floating point math, this number is a little bit fuzzy. 3479 // Given the floating point math, this number is a little bit fuzzy.
3480 EXPECT_EQ(gfx::Rect(0, 0, 26, 50), child1->visible_content_rect()); 3480 EXPECT_EQ(gfx::Rect(0, 0, 26, 50), child1->visible_layer_rect());
3481 3481
3482 // The child's DrawableContentRect is unclipped. 3482 // The child's DrawableContentRect is unclipped.
3483 EXPECT_EQ(unclipped_surface_content, child1->drawable_content_rect()); 3483 EXPECT_EQ(unclipped_surface_content, child1->drawable_content_rect());
3484 } 3484 }
3485 3485
3486 TEST_F(LayerTreeHostCommonTest, DrawableAndVisibleContentRectsInHighDPI) { 3486 TEST_F(LayerTreeHostCommonTest, DrawableAndVisibleContentRectsInHighDPI) {
3487 MockContentLayerClient client; 3487 MockContentLayerClient client;
3488 3488
3489 scoped_refptr<Layer> root = Layer::Create(layer_settings()); 3489 scoped_refptr<Layer> root = Layer::Create(layer_settings());
3490 scoped_refptr<FakePictureLayer> render_surface1 = 3490 scoped_refptr<FakePictureLayer> render_surface1 =
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
3571 // render_surface2 lives in the "unclipped universe" of render_surface1, and 3571 // render_surface2 lives in the "unclipped universe" of render_surface1, and
3572 // is only implicitly clipped by render_surface1. 3572 // is only implicitly clipped by render_surface1.
3573 EXPECT_EQ(gfx::Rect(10, 10, 350, 350), 3573 EXPECT_EQ(gfx::Rect(10, 10, 350, 350),
3574 render_surface2->render_surface()->DrawableContentRect()); 3574 render_surface2->render_surface()->DrawableContentRect());
3575 3575
3576 EXPECT_EQ(gfx::Rect(10, 10, 100, 100), child1->drawable_content_rect()); 3576 EXPECT_EQ(gfx::Rect(10, 10, 100, 100), child1->drawable_content_rect());
3577 EXPECT_EQ(gfx::Rect(150, 150, 100, 100), child2->drawable_content_rect()); 3577 EXPECT_EQ(gfx::Rect(150, 150, 100, 100), child2->drawable_content_rect());
3578 EXPECT_EQ(gfx::Rect(250, 250, 100, 100), child3->drawable_content_rect()); 3578 EXPECT_EQ(gfx::Rect(250, 250, 100, 100), child3->drawable_content_rect());
3579 3579
3580 // The root layer does not actually draw content of its own. 3580 // The root layer does not actually draw content of its own.
3581 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_content_rect()); 3581 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_layer_rect());
3582 3582
3583 // All layer visible content rects are not expressed in content space of each 3583 // All layer visible content rects are not expressed in content space of each
3584 // layer, so they are not scaled by the device_scale_factor. 3584 // layer, so they are not scaled by the device_scale_factor.
3585 EXPECT_EQ(gfx::Rect(0, 0, 3, 4), render_surface1->visible_content_rect()); 3585 EXPECT_EQ(gfx::Rect(0, 0, 3, 4), render_surface1->visible_layer_rect());
3586 EXPECT_EQ(gfx::Rect(0, 0, 7, 13), render_surface2->visible_content_rect()); 3586 EXPECT_EQ(gfx::Rect(0, 0, 7, 13), render_surface2->visible_layer_rect());
3587 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child1->visible_content_rect()); 3587 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child1->visible_layer_rect());
3588 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child2->visible_content_rect()); 3588 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child2->visible_layer_rect());
3589 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child3->visible_content_rect()); 3589 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child3->visible_layer_rect());
3590 } 3590 }
3591 3591
3592 TEST_F(LayerTreeHostCommonTest, BackFaceCullingWithoutPreserves3d) { 3592 TEST_F(LayerTreeHostCommonTest, BackFaceCullingWithoutPreserves3d) {
3593 // Verify the behavior of back-face culling when there are no preserve-3d 3593 // Verify the behavior of back-face culling when there are no preserve-3d
3594 // layers. Note that 3d transforms still apply in this case, but they are 3594 // layers. Note that 3d transforms still apply in this case, but they are
3595 // "flattened" to each parent layer according to current W3C spec. 3595 // "flattened" to each parent layer according to current W3C spec.
3596 3596
3597 const gfx::Transform identity_matrix; 3597 const gfx::Transform identity_matrix;
3598 scoped_refptr<Layer> parent = Layer::Create(layer_settings()); 3598 scoped_refptr<Layer> parent = Layer::Create(layer_settings());
3599 scoped_refptr<LayerWithForcedDrawsContent> front_facing_child = 3599 scoped_refptr<LayerWithForcedDrawsContent> front_facing_child =
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
4104 ASSERT_EQ( 4104 ASSERT_EQ(
4105 2u, 4105 2u,
4106 render_surface_layer_list.at(1)->render_surface()->layer_list().size()); 4106 render_surface_layer_list.at(1)->render_surface()->layer_list().size());
4107 EXPECT_EQ(animating_surface->id(), 4107 EXPECT_EQ(animating_surface->id(),
4108 render_surface_layer_list.at(1) 4108 render_surface_layer_list.at(1)
4109 ->render_surface()->layer_list().at(0)->id()); 4109 ->render_surface()->layer_list().at(0)->id());
4110 EXPECT_EQ(child_of_animating_surface->id(), 4110 EXPECT_EQ(child_of_animating_surface->id(),
4111 render_surface_layer_list.at(1) 4111 render_surface_layer_list.at(1)
4112 ->render_surface()->layer_list().at(1)->id()); 4112 ->render_surface()->layer_list().at(1)->id());
4113 4113
4114 EXPECT_FALSE(child2->visible_content_rect().IsEmpty()); 4114 EXPECT_FALSE(child2->visible_layer_rect().IsEmpty());
4115 4115
4116 // The animating layers should have a visible content rect that represents the 4116 // The animating layers should have a visible content rect that represents the
4117 // area of the front face that is within the viewport. 4117 // area of the front face that is within the viewport.
4118 EXPECT_EQ(animating_child->visible_content_rect(), 4118 EXPECT_EQ(animating_child->visible_layer_rect(),
4119 gfx::Rect(animating_child->bounds())); 4119 gfx::Rect(animating_child->bounds()));
4120 EXPECT_EQ(animating_surface->visible_content_rect(), 4120 EXPECT_EQ(animating_surface->visible_layer_rect(),
4121 gfx::Rect(animating_surface->bounds())); 4121 gfx::Rect(animating_surface->bounds()));
4122 // And layers in the subtree of the animating layer should have valid visible 4122 // And layers in the subtree of the animating layer should have valid visible
4123 // content rects also. 4123 // content rects also.
4124 EXPECT_EQ(child_of_animating_surface->visible_content_rect(), 4124 EXPECT_EQ(child_of_animating_surface->visible_layer_rect(),
4125 gfx::Rect(child_of_animating_surface->bounds())); 4125 gfx::Rect(child_of_animating_surface->bounds()));
4126 } 4126 }
4127 4127
4128 TEST_F(LayerTreeHostCommonTest, 4128 TEST_F(LayerTreeHostCommonTest,
4129 BackFaceCullingWithPreserves3dForFlatteningSurface) { 4129 BackFaceCullingWithPreserves3dForFlatteningSurface) {
4130 // Verify the behavior of back-face culling for a render surface that is 4130 // Verify the behavior of back-face culling for a render surface that is
4131 // created when it flattens its subtree, and its parent has preserves-3d. 4131 // created when it flattens its subtree, and its parent has preserves-3d.
4132 4132
4133 const gfx::Transform identity_matrix; 4133 const gfx::Transform identity_matrix;
4134 scoped_refptr<Layer> parent = Layer::Create(layer_settings()); 4134 scoped_refptr<Layer> parent = Layer::Create(layer_settings());
(...skipping 1494 matching lines...) Expand 10 before | Expand all | Expand 10 after
5629 5629
5630 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); 5630 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
5631 host->SetRootLayer(root); 5631 host->SetRootLayer(root);
5632 5632
5633 RenderSurfaceLayerList render_surface_layer_list; 5633 RenderSurfaceLayerList render_surface_layer_list;
5634 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( 5634 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs(
5635 root.get(), root->bounds(), &render_surface_layer_list); 5635 root.get(), root->bounds(), &render_surface_layer_list);
5636 inputs.can_adjust_raster_scales = true; 5636 inputs.can_adjust_raster_scales = true;
5637 LayerTreeHostCommon::CalculateDrawProperties(&inputs); 5637 LayerTreeHostCommon::CalculateDrawProperties(&inputs);
5638 5638
5639 // The visible_content_rect for the |surface_child| should not be clipped by 5639 // The visible_layer_rect for the |surface_child| should not be clipped by
5640 // the viewport. 5640 // the viewport.
5641 EXPECT_EQ(gfx::Rect(50, 50).ToString(), 5641 EXPECT_EQ(gfx::Rect(50, 50).ToString(),
5642 surface_child->visible_content_rect().ToString()); 5642 surface_child->visible_layer_rect().ToString());
5643 } 5643 }
5644 5644
5645 TEST_F(LayerTreeHostCommonTest, TransformedClipParent) { 5645 TEST_F(LayerTreeHostCommonTest, TransformedClipParent) {
5646 // Ensure that a transform between the layer and its render surface is not a 5646 // Ensure that a transform between the layer and its render surface is not a
5647 // problem. Constructs the following layer tree. 5647 // problem. Constructs the following layer tree.
5648 // 5648 //
5649 // root (a render surface) 5649 // root (a render surface)
5650 // + render_surface 5650 // + render_surface
5651 // + clip_parent (scaled) 5651 // + clip_parent (scaled)
5652 // + intervening_clipping_layer 5652 // + intervening_clipping_layer
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
5860 render_surface1->render_surface()->content_rect().ToString()); 5860 render_surface1->render_surface()->content_rect().ToString());
5861 EXPECT_EQ(gfx::Rect(-1, -1, 40, 40).ToString(), 5861 EXPECT_EQ(gfx::Rect(-1, -1, 40, 40).ToString(),
5862 render_surface2->render_surface()->content_rect().ToString()); 5862 render_surface2->render_surface()->content_rect().ToString());
5863 5863
5864 // The clip child should have inherited the clip parent's clip (projected to 5864 // The clip child should have inherited the clip parent's clip (projected to
5865 // the right space, of course), and should have the correctly sized visible 5865 // the right space, of course), and should have the correctly sized visible
5866 // content rect. 5866 // content rect.
5867 EXPECT_EQ(gfx::Rect(-1, -1, 40, 40).ToString(), 5867 EXPECT_EQ(gfx::Rect(-1, -1, 40, 40).ToString(),
5868 clip_child->clip_rect().ToString()); 5868 clip_child->clip_rect().ToString());
5869 EXPECT_EQ(gfx::Rect(9, 9, 40, 40).ToString(), 5869 EXPECT_EQ(gfx::Rect(9, 9, 40, 40).ToString(),
5870 clip_child->visible_content_rect().ToString()); 5870 clip_child->visible_layer_rect().ToString());
5871 EXPECT_TRUE(clip_child->is_clipped()); 5871 EXPECT_TRUE(clip_child->is_clipped());
5872 } 5872 }
5873 5873
5874 TEST_F(LayerTreeHostCommonTest, ClipParentScrolledInterveningLayer) { 5874 TEST_F(LayerTreeHostCommonTest, ClipParentScrolledInterveningLayer) {
5875 // Ensure that intervening render surfaces are not a problem, even if there 5875 // Ensure that intervening render surfaces are not a problem, even if there
5876 // is a scroll involved. Note, we do _not_ have to consider any other sort 5876 // is a scroll involved. Note, we do _not_ have to consider any other sort
5877 // of transform. 5877 // of transform.
5878 // 5878 //
5879 // root (a render surface) 5879 // root (a render surface)
5880 // + clip_parent (masks to bounds) 5880 // + clip_parent (masks to bounds)
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
5989 render_surface1->render_surface()->content_rect().ToString()); 5989 render_surface1->render_surface()->content_rect().ToString());
5990 EXPECT_EQ(gfx::Rect(2, 2, 40, 40).ToString(), 5990 EXPECT_EQ(gfx::Rect(2, 2, 40, 40).ToString(),
5991 render_surface2->render_surface()->content_rect().ToString()); 5991 render_surface2->render_surface()->content_rect().ToString());
5992 5992
5993 // The clip child should have inherited the clip parent's clip (projected to 5993 // The clip child should have inherited the clip parent's clip (projected to
5994 // the right space, of course), and should have the correctly sized visible 5994 // the right space, of course), and should have the correctly sized visible
5995 // content rect. 5995 // content rect.
5996 EXPECT_EQ(gfx::Rect(2, 2, 40, 40).ToString(), 5996 EXPECT_EQ(gfx::Rect(2, 2, 40, 40).ToString(),
5997 clip_child->clip_rect().ToString()); 5997 clip_child->clip_rect().ToString());
5998 EXPECT_EQ(gfx::Rect(12, 12, 40, 40).ToString(), 5998 EXPECT_EQ(gfx::Rect(12, 12, 40, 40).ToString(),
5999 clip_child->visible_content_rect().ToString()); 5999 clip_child->visible_layer_rect().ToString());
6000 EXPECT_TRUE(clip_child->is_clipped()); 6000 EXPECT_TRUE(clip_child->is_clipped());
6001 } 6001 }
6002 6002
6003 TEST_F(LayerTreeHostCommonTest, DescendantsOfClipChildren) { 6003 TEST_F(LayerTreeHostCommonTest, DescendantsOfClipChildren) {
6004 // Ensures that descendants of the clip child inherit the correct clip. 6004 // Ensures that descendants of the clip child inherit the correct clip.
6005 // 6005 //
6006 // root (a render surface) 6006 // root (a render surface)
6007 // + clip_parent (masks to bounds) 6007 // + clip_parent (masks to bounds)
6008 // + intervening (masks to bounds) 6008 // + intervening (masks to bounds)
6009 // + clip_child 6009 // + clip_child
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
6069 ExecuteCalculateDrawProperties(root.get()); 6069 ExecuteCalculateDrawProperties(root.get());
6070 6070
6071 EXPECT_TRUE(root->render_surface()); 6071 EXPECT_TRUE(root->render_surface());
6072 6072
6073 // Neither the clip child nor its descendant should have inherited the clip 6073 // Neither the clip child nor its descendant should have inherited the clip
6074 // from |intervening|. 6074 // from |intervening|.
6075 EXPECT_EQ(gfx::Rect(0, 0, 40, 40).ToString(), 6075 EXPECT_EQ(gfx::Rect(0, 0, 40, 40).ToString(),
6076 clip_child->clip_rect().ToString()); 6076 clip_child->clip_rect().ToString());
6077 EXPECT_TRUE(clip_child->is_clipped()); 6077 EXPECT_TRUE(clip_child->is_clipped());
6078 EXPECT_EQ(gfx::Rect(0, 0, 40, 40).ToString(), 6078 EXPECT_EQ(gfx::Rect(0, 0, 40, 40).ToString(),
6079 child->visible_content_rect().ToString()); 6079 child->visible_layer_rect().ToString());
6080 EXPECT_TRUE(child->is_clipped()); 6080 EXPECT_TRUE(child->is_clipped());
6081 } 6081 }
6082 6082
6083 TEST_F(LayerTreeHostCommonTest, 6083 TEST_F(LayerTreeHostCommonTest,
6084 SurfacesShouldBeUnaffectedByNonDescendantClipChildren) { 6084 SurfacesShouldBeUnaffectedByNonDescendantClipChildren) {
6085 // Ensures that non-descendant clip children in the tree do not affect 6085 // Ensures that non-descendant clip children in the tree do not affect
6086 // render surfaces. 6086 // render surfaces.
6087 // 6087 //
6088 // root (a render surface) 6088 // root (a render surface)
6089 // + clip_parent (masks to bounds) 6089 // + clip_parent (masks to bounds)
(...skipping 1831 matching lines...) Expand 10 before | Expand all | Expand 10 after
7921 RenderSurfaceLayerList render_surface_layer_list; 7921 RenderSurfaceLayerList render_surface_layer_list;
7922 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( 7922 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs(
7923 host->root_layer(), device_viewport_size, &render_surface_layer_list); 7923 host->root_layer(), device_viewport_size, &render_surface_layer_list);
7924 inputs.device_scale_factor = 2.f; 7924 inputs.device_scale_factor = 2.f;
7925 inputs.page_scale_factor = 1.f; 7925 inputs.page_scale_factor = 1.f;
7926 inputs.page_scale_layer = NULL; 7926 inputs.page_scale_layer = NULL;
7927 LayerTreeHostCommon::CalculateDrawProperties(&inputs); 7927 LayerTreeHostCommon::CalculateDrawProperties(&inputs);
7928 7928
7929 // Layers in the root render surface have their visible content rect clipped 7929 // Layers in the root render surface have their visible content rect clipped
7930 // by the viewport. 7930 // by the viewport.
7931 EXPECT_EQ(gfx::Rect(768 / 2, 582 / 2), root->visible_content_rect()); 7931 EXPECT_EQ(gfx::Rect(768 / 2, 582 / 2), root->visible_layer_rect());
7932 7932
7933 // Layers drawing to a child render surface should still have their visible 7933 // Layers drawing to a child render surface should still have their visible
7934 // content rect clipped by the viewport. 7934 // content rect clipped by the viewport.
7935 EXPECT_EQ(gfx::Rect(768 / 2, 582 / 2), content->visible_content_rect()); 7935 EXPECT_EQ(gfx::Rect(768 / 2, 582 / 2), content->visible_layer_rect());
7936 } 7936 }
7937 7937
7938 TEST_F(LayerTreeHostCommonTest, BoundsDeltaAffectVisibleContentRect) { 7938 TEST_F(LayerTreeHostCommonTest, BoundsDeltaAffectVisibleContentRect) {
7939 FakeImplProxy proxy; 7939 FakeImplProxy proxy;
7940 TestSharedBitmapManager shared_bitmap_manager; 7940 TestSharedBitmapManager shared_bitmap_manager;
7941 TestTaskGraphRunner task_graph_runner; 7941 TestTaskGraphRunner task_graph_runner;
7942 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, 7942 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager,
7943 &task_graph_runner); 7943 &task_graph_runner);
7944 7944
7945 // Set two layers: the root layer clips it's child, 7945 // Set two layers: the root layer clips it's child,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
7981 false, 7981 false,
7982 false); 7982 false);
7983 sublayer->SetDrawsContent(true); 7983 sublayer->SetDrawsContent(true);
7984 7984
7985 LayerImplList layer_impl_list; 7985 LayerImplList layer_impl_list;
7986 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 7986 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
7987 root, device_viewport_size, &layer_impl_list); 7987 root, device_viewport_size, &layer_impl_list);
7988 7988
7989 LayerTreeHostCommon::CalculateDrawProperties(&inputs); 7989 LayerTreeHostCommon::CalculateDrawProperties(&inputs);
7990 7990
7991 EXPECT_EQ(gfx::Rect(root_size), sublayer->visible_content_rect()); 7991 EXPECT_EQ(gfx::Rect(root_size), sublayer->visible_layer_rect());
7992 7992
7993 root->SetBoundsDelta(gfx::Vector2dF(0.0, 50.0)); 7993 root->SetBoundsDelta(gfx::Vector2dF(0.0, 50.0));
7994 7994
7995 LayerTreeHostCommon::CalculateDrawProperties(&inputs); 7995 LayerTreeHostCommon::CalculateDrawProperties(&inputs);
7996 7996
7997 gfx::Rect affected_by_delta(0, 0, root_size.width(), 7997 gfx::Rect affected_by_delta(0, 0, root_size.width(),
7998 root_size.height() + 50); 7998 root_size.height() + 50);
7999 EXPECT_EQ(affected_by_delta, sublayer->visible_content_rect()); 7999 EXPECT_EQ(affected_by_delta, sublayer->visible_layer_rect());
8000 } 8000 }
8001 8001
8002 TEST_F(LayerTreeHostCommonTest, VisibleContentRectForAnimatedLayer) { 8002 TEST_F(LayerTreeHostCommonTest, VisibleContentRectForAnimatedLayer) {
8003 const gfx::Transform identity_matrix; 8003 const gfx::Transform identity_matrix;
8004 scoped_refptr<Layer> root = Layer::Create(layer_settings()); 8004 scoped_refptr<Layer> root = Layer::Create(layer_settings());
8005 scoped_refptr<LayerWithForcedDrawsContent> animated = 8005 scoped_refptr<LayerWithForcedDrawsContent> animated =
8006 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings())); 8006 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
8007 8007
8008 root->AddChild(animated); 8008 root->AddChild(animated);
8009 8009
(...skipping 801 matching lines...) Expand 10 before | Expand all | Expand 10 after
8811 EXPECT_FALSE(root->layer_or_descendant_is_drawn()); 8811 EXPECT_FALSE(root->layer_or_descendant_is_drawn());
8812 EXPECT_FALSE(root->visited()); 8812 EXPECT_FALSE(root->visited());
8813 EXPECT_FALSE(root->sorted_for_recursion()); 8813 EXPECT_FALSE(root->sorted_for_recursion());
8814 EXPECT_FALSE(child->layer_or_descendant_is_drawn()); 8814 EXPECT_FALSE(child->layer_or_descendant_is_drawn());
8815 EXPECT_FALSE(child->visited()); 8815 EXPECT_FALSE(child->visited());
8816 EXPECT_FALSE(child->sorted_for_recursion()); 8816 EXPECT_FALSE(child->sorted_for_recursion());
8817 } 8817 }
8818 8818
8819 } // namespace 8819 } // namespace
8820 } // namespace cc 8820 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_common.cc ('k') | cc/trees/layer_tree_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698