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 <set> | 7 #include <set> |
8 | 8 |
9 #include "cc/animation/layer_animation_controller.h" | 9 #include "cc/animation/layer_animation_controller.h" |
10 #include "cc/animation/transform_operations.h" | 10 #include "cc/animation/transform_operations.h" |
(...skipping 2924 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2935 gfx::PointF(5.f, 5.f), | 2935 gfx::PointF(5.f, 5.f), |
2936 gfx::Size(50, 50), | 2936 gfx::Size(50, 50), |
2937 true, | 2937 true, |
2938 false); | 2938 false); |
2939 | 2939 |
2940 ExecuteCalculateDrawProperties(root.get()); | 2940 ExecuteCalculateDrawProperties(root.get()); |
2941 | 2941 |
2942 EXPECT_TRUE(child->visible_content_rect().IsEmpty()); | 2942 EXPECT_TRUE(child->visible_content_rect().IsEmpty()); |
2943 EXPECT_TRUE(child->drawable_content_rect().IsEmpty()); | 2943 EXPECT_TRUE(child->drawable_content_rect().IsEmpty()); |
2944 | 2944 |
2945 // TODO(avallee): Cases 2, 3 comments no longer accurate. CSS spec days to | |
ajuma
2014/04/16 19:24:49
Please fix the comments rather than having this TO
avallee
2014/04/16 19:33:25
Done.
| |
2946 // never draw objects with uninvertible transforms. | |
2947 | |
2945 // Case 2: a matrix with flattened z, technically uninvertible but still | 2948 // Case 2: a matrix with flattened z, technically uninvertible but still |
2946 // drawable and visible. In this case, we must assume that the entire layer | 2949 // drawable and visible. In this case, we must assume that the entire layer |
2947 // bounds are visible since there is no way to inverse-project the surface | 2950 // bounds are visible since there is no way to inverse-project the surface |
2948 // bounds to intersect. | 2951 // bounds to intersect. |
2949 uninvertible_matrix.MakeIdentity(); | 2952 uninvertible_matrix.MakeIdentity(); |
2950 uninvertible_matrix.matrix().set(2, 2, 0.0); | 2953 uninvertible_matrix.matrix().set(2, 2, 0.0); |
2951 ASSERT_FALSE(uninvertible_matrix.IsInvertible()); | 2954 ASSERT_FALSE(uninvertible_matrix.IsInvertible()); |
2952 | 2955 |
2953 SetLayerPropertiesForTesting(child.get(), | 2956 SetLayerPropertiesForTesting(child.get(), |
2954 uninvertible_matrix, | 2957 uninvertible_matrix, |
2955 gfx::PointF(), | 2958 gfx::PointF(), |
2956 gfx::PointF(5.f, 5.f), | 2959 gfx::PointF(5.f, 5.f), |
2957 gfx::Size(50, 50), | 2960 gfx::Size(50, 50), |
2958 true, | 2961 true, |
2959 false); | 2962 false); |
2960 | 2963 |
2961 ExecuteCalculateDrawProperties(root.get()); | 2964 ExecuteCalculateDrawProperties(root.get()); |
2962 | 2965 |
2963 EXPECT_RECT_EQ(gfx::Rect(0, 0, 50, 50), child->visible_content_rect()); | 2966 EXPECT_TRUE(child->visible_content_rect().IsEmpty()); |
2964 EXPECT_RECT_EQ(gfx::Rect(5, 5, 50, 50), child->drawable_content_rect()); | 2967 EXPECT_TRUE(child->drawable_content_rect().IsEmpty()); |
2965 | 2968 |
2966 // Case 3: a matrix with flattened z, technically uninvertible but still | 2969 // Case 3: a matrix with flattened z, technically uninvertible but still |
2967 // drawable, but not visible. In this case, we don't need to conservatively | 2970 // drawable, but not visible. In this case, we don't need to conservatively |
2968 // assume that the whole layer is visible. | 2971 // assume that the whole layer is visible. |
2969 uninvertible_matrix.MakeIdentity(); | 2972 uninvertible_matrix.MakeIdentity(); |
2970 uninvertible_matrix.Translate(500.0, 0.0); | 2973 uninvertible_matrix.Translate(500.0, 0.0); |
2971 uninvertible_matrix.matrix().set(2, 2, 0.0); | 2974 uninvertible_matrix.matrix().set(2, 2, 0.0); |
2972 ASSERT_FALSE(uninvertible_matrix.IsInvertible()); | 2975 ASSERT_FALSE(uninvertible_matrix.IsInvertible()); |
2973 | 2976 |
2974 SetLayerPropertiesForTesting(child.get(), | 2977 SetLayerPropertiesForTesting(child.get(), |
2975 uninvertible_matrix, | 2978 uninvertible_matrix, |
2976 gfx::PointF(), | 2979 gfx::PointF(), |
2977 gfx::PointF(5.f, 5.f), | 2980 gfx::PointF(5.f, 5.f), |
2978 gfx::Size(50, 50), | 2981 gfx::Size(50, 50), |
2979 true, | 2982 true, |
2980 false); | 2983 false); |
2981 | 2984 |
2982 ExecuteCalculateDrawProperties(root.get()); | 2985 ExecuteCalculateDrawProperties(root.get()); |
2983 | 2986 |
2984 EXPECT_TRUE(child->visible_content_rect().IsEmpty()); | 2987 EXPECT_TRUE(child->visible_content_rect().IsEmpty()); |
2985 EXPECT_RECT_EQ(gfx::Rect(505, 5, 50, 50), child->drawable_content_rect()); | 2988 EXPECT_TRUE(child->drawable_content_rect().IsEmpty()); |
2986 } | 2989 } |
2987 | 2990 |
2988 TEST_F(LayerTreeHostCommonTest, | 2991 TEST_F(LayerTreeHostCommonTest, |
2989 DrawableAndVisibleContentRectsForLayersInClippedRenderSurface) { | 2992 DrawableAndVisibleContentRectsForLayersInClippedRenderSurface) { |
2990 scoped_refptr<Layer> root = Layer::Create(); | 2993 scoped_refptr<Layer> root = Layer::Create(); |
2991 scoped_refptr<Layer> render_surface1 = Layer::Create(); | 2994 scoped_refptr<Layer> render_surface1 = Layer::Create(); |
2992 scoped_refptr<LayerWithForcedDrawsContent> child1 = | 2995 scoped_refptr<LayerWithForcedDrawsContent> child1 = |
2993 make_scoped_refptr(new LayerWithForcedDrawsContent()); | 2996 make_scoped_refptr(new LayerWithForcedDrawsContent()); |
2994 scoped_refptr<LayerWithForcedDrawsContent> child2 = | 2997 scoped_refptr<LayerWithForcedDrawsContent> child2 = |
2995 make_scoped_refptr(new LayerWithForcedDrawsContent()); | 2998 make_scoped_refptr(new LayerWithForcedDrawsContent()); |
(...skipping 6135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9131 | 9134 |
9132 ExecuteCalculateDrawProperties(root.get()); | 9135 ExecuteCalculateDrawProperties(root.get()); |
9133 | 9136 |
9134 EXPECT_TRUE(root->render_surface()); | 9137 EXPECT_TRUE(root->render_surface()); |
9135 | 9138 |
9136 EXPECT_EQ(gfx::Rect(0, 0, 30, 30).ToString(), | 9139 EXPECT_EQ(gfx::Rect(0, 0, 30, 30).ToString(), |
9137 scroll_child->clip_rect().ToString()); | 9140 scroll_child->clip_rect().ToString()); |
9138 EXPECT_TRUE(scroll_child->is_clipped()); | 9141 EXPECT_TRUE(scroll_child->is_clipped()); |
9139 } | 9142 } |
9140 | 9143 |
9144 TEST_F(LayerTreeHostCommonTest, SingularTransformSubtreesDoNotDraw) { | |
9145 scoped_refptr<LayerWithForcedDrawsContent> root = | |
9146 make_scoped_refptr(new LayerWithForcedDrawsContent); | |
9147 scoped_refptr<LayerWithForcedDrawsContent> parent = | |
9148 make_scoped_refptr(new LayerWithForcedDrawsContent); | |
9149 scoped_refptr<LayerWithForcedDrawsContent> child = | |
9150 make_scoped_refptr(new LayerWithForcedDrawsContent); | |
9151 | |
9152 root->AddChild(parent); | |
9153 parent->AddChild(child); | |
9154 | |
9155 gfx::Transform identity_transform; | |
9156 SetLayerPropertiesForTesting(root.get(), | |
9157 identity_transform, | |
9158 gfx::PointF(), | |
9159 gfx::PointF(), | |
9160 gfx::Size(50, 50), | |
9161 true, | |
9162 true); | |
9163 root->SetForceRenderSurface(true); | |
9164 SetLayerPropertiesForTesting(parent.get(), | |
9165 identity_transform, | |
9166 gfx::PointF(), | |
9167 gfx::PointF(), | |
9168 gfx::Size(30, 30), | |
9169 true, | |
9170 true); | |
9171 parent->SetForceRenderSurface(true); | |
9172 SetLayerPropertiesForTesting(child.get(), | |
9173 identity_transform, | |
9174 gfx::PointF(), | |
9175 gfx::PointF(), | |
9176 gfx::Size(20, 20), | |
9177 true, | |
9178 true); | |
9179 child->SetForceRenderSurface(true); | |
9180 | |
9181 scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create(); | |
9182 host->SetRootLayer(root); | |
9183 | |
9184 ExecuteCalculateDrawProperties(root.get()); | |
9185 | |
9186 EXPECT_EQ(3u, render_surface_layer_list()->size()); | |
9187 | |
9188 gfx::Transform singular_transform; | |
9189 singular_transform.Scale3d( | |
9190 SkDoubleToMScalar(1.0), SkDoubleToMScalar(1.0), SkDoubleToMScalar(0.0)); | |
9191 | |
9192 child->SetTransform(singular_transform); | |
9193 | |
9194 ExecuteCalculateDrawProperties(root.get()); | |
9195 | |
9196 EXPECT_EQ(2u, render_surface_layer_list()->size()); | |
9197 | |
9198 // Ensure that the entire subtree under a layer with singular transform does | |
9199 // not get rendered. | |
9200 parent->SetTransform(singular_transform); | |
9201 child->SetTransform(identity_transform); | |
9202 | |
9203 ExecuteCalculateDrawProperties(root.get()); | |
9204 | |
9205 EXPECT_EQ(1u, render_surface_layer_list()->size()); | |
9206 } | |
9207 | |
9141 TEST_F(LayerTreeHostCommonTest, ClippedByOutOfOrderScrollParent) { | 9208 TEST_F(LayerTreeHostCommonTest, ClippedByOutOfOrderScrollParent) { |
9142 // Checks that clipping by a scroll parent that follows you in paint order | 9209 // Checks that clipping by a scroll parent that follows you in paint order |
9143 // still results in correct clipping. | 9210 // still results in correct clipping. |
9144 // | 9211 // |
9145 // + root | 9212 // + root |
9146 // + scroll_child | 9213 // + scroll_child |
9147 // + scroll_parent_border | 9214 // + scroll_parent_border |
9148 // + scroll_parent_clip | 9215 // + scroll_parent_clip |
9149 // + scroll_parent | 9216 // + scroll_parent |
9150 // | 9217 // |
(...skipping 849 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10000 | 10067 |
10001 // |grand_parent| has a transform that's neither a translation nor a scale. | 10068 // |grand_parent| has a transform that's neither a translation nor a scale. |
10002 EXPECT_EQ(0.f, grand_parent->last_maximum_animation_contents_scale()); | 10069 EXPECT_EQ(0.f, grand_parent->last_maximum_animation_contents_scale()); |
10003 EXPECT_EQ(0.f, parent_raw->last_maximum_animation_contents_scale()); | 10070 EXPECT_EQ(0.f, parent_raw->last_maximum_animation_contents_scale()); |
10004 EXPECT_EQ(0.f, child_raw->last_maximum_animation_contents_scale()); | 10071 EXPECT_EQ(0.f, child_raw->last_maximum_animation_contents_scale()); |
10005 EXPECT_EQ(0.f, grand_child_raw->last_maximum_animation_contents_scale()); | 10072 EXPECT_EQ(0.f, grand_child_raw->last_maximum_animation_contents_scale()); |
10006 } | 10073 } |
10007 | 10074 |
10008 } // namespace | 10075 } // namespace |
10009 } // namespace cc | 10076 } // namespace cc |
OLD | NEW |