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