Index: cc/trees/layer_tree_host_common_unittest.cc |
diff --git a/cc/trees/layer_tree_host_common_unittest.cc b/cc/trees/layer_tree_host_common_unittest.cc |
index 30cc15abbaf83a6965e4f9c7ee1fe25bb0321c28..6f05035428a285c7fc1f13411b77b6a52f067b07 100644 |
--- a/cc/trees/layer_tree_host_common_unittest.cc |
+++ b/cc/trees/layer_tree_host_common_unittest.cc |
@@ -2975,6 +2975,78 @@ TEST_F(LayerTreeHostCommonTest, |
EXPECT_FALSE(child->draw_properties().sorted_for_recursion); |
} |
+TEST_F(LayerTreeHostCommonTest, WillSortAtContextBoundary) { |
+ // Creates a layer tree that looks as follows: |
+ // * root (sorting-context-id1) |
+ // * parent (sorting-context-id2) |
+ // * child1 (sorting-context-id2) |
+ // * child2 (sorting-context-id2) |
+ // |
+ // This test ensures that we sort at |parent| even though both it and root are |
+ // set to be 3d sorted. |
+ FakeImplProxy proxy; |
+ TestSharedBitmapManager shared_bitmap_manager; |
+ FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); |
+ |
+ scoped_ptr<LayerImpl> root_ptr(LayerImpl::Create(host_impl.active_tree(), 1)); |
+ LayerImpl* root = root_ptr.get(); |
+ scoped_ptr<LayerImpl> parent_ptr( |
+ LayerImpl::Create(host_impl.active_tree(), 2)); |
+ LayerImpl* parent = parent_ptr.get(); |
+ scoped_ptr<LayerImpl> child1_ptr( |
+ LayerImpl::Create(host_impl.active_tree(), 3)); |
+ LayerImpl* child1 = child1_ptr.get(); |
+ scoped_ptr<LayerImpl> child2_ptr( |
+ LayerImpl::Create(host_impl.active_tree(), 4)); |
+ LayerImpl* child2 = child2_ptr.get(); |
+ |
+ gfx::Transform identity_matrix; |
+ gfx::Transform below_matrix; |
+ below_matrix.Translate3d(0.f, 0.f, -10.f); |
+ gfx::Transform above_matrix; |
+ above_matrix.Translate3d(0.f, 0.f, 10.f); |
+ |
+ SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), |
+ gfx::PointF(), gfx::Size(100, 100), true, true, |
+ true); |
+ SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(), |
+ gfx::PointF(), gfx::Size(50, 50), true, true, |
+ true); |
+ SetLayerPropertiesForTesting(child1, above_matrix, gfx::Point3F(), |
+ gfx::PointF(), gfx::Size(50, 50), true, true, |
+ false); |
+ SetLayerPropertiesForTesting(child2, below_matrix, gfx::Point3F(), |
+ gfx::PointF(), gfx::Size(50, 50), true, true, |
+ false); |
+ |
+ root->Set3dSortingContextId(3); |
+ root->SetDrawsContent(true); |
+ parent->Set3dSortingContextId(7); |
+ parent->SetDrawsContent(true); |
+ child1->Set3dSortingContextId(7); |
+ child1->SetDrawsContent(true); |
+ child2->Set3dSortingContextId(7); |
+ child2->SetDrawsContent(true); |
+ |
+ parent->AddChild(child1_ptr.Pass()); |
+ parent->AddChild(child2_ptr.Pass()); |
+ root->AddChild(parent_ptr.Pass()); |
+ |
+ LayerImplList render_surface_layer_list; |
+ LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
+ root_ptr.get(), root->bounds(), &render_surface_layer_list); |
+ inputs.can_adjust_raster_scales = true; |
+ LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
+ |
+ EXPECT_TRUE(root->render_surface()); |
+ EXPECT_EQ(2u, render_surface_layer_list.size()); |
+ |
+ EXPECT_EQ(3u, parent->render_surface()->layer_list().size()); |
+ EXPECT_EQ(child2->id(), parent->render_surface()->layer_list().at(0)->id()); |
+ EXPECT_EQ(parent->id(), parent->render_surface()->layer_list().at(1)->id()); |
+ EXPECT_EQ(child1->id(), parent->render_surface()->layer_list().at(2)->id()); |
+} |
+ |
TEST_F(LayerTreeHostCommonTest, |
SingularNonAnimatingTransformDoesNotPreventClearingDrawProperties) { |
scoped_refptr<Layer> root = Layer::Create(); |
@@ -8675,5 +8747,70 @@ TEST_F(LayerTreeHostCommonTest, BoundsDeltaAffectVisibleContentRect) { |
EXPECT_EQ(affected_by_delta, sublayer->visible_content_rect()); |
} |
+TEST_F(LayerTreeHostCommonTest, VisibleContentRectForAnimatedLayer) { |
+ const gfx::Transform identity_matrix; |
+ scoped_refptr<Layer> root = Layer::Create(); |
+ scoped_refptr<LayerWithForcedDrawsContent> animated = |
+ make_scoped_refptr(new LayerWithForcedDrawsContent()); |
+ |
+ root->AddChild(animated); |
+ |
+ scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); |
+ host->SetRootLayer(root); |
+ |
+ SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), |
+ gfx::PointF(), gfx::Size(100, 100), true, false); |
+ SetLayerPropertiesForTesting(animated.get(), identity_matrix, gfx::Point3F(), |
+ gfx::PointF(), gfx::Size(20, 20), true, false); |
+ |
+ root->SetMasksToBounds(true); |
+ root->SetForceRenderSurface(true); |
+ animated->SetOpacity(0.f); |
+ |
+ AddOpacityTransitionToController(animated->layer_animation_controller(), 10.0, |
+ 0.f, 1.f, false); |
+ |
+ ExecuteCalculateDrawProperties(root.get()); |
+ |
+ EXPECT_FALSE(animated->visible_rect_from_property_trees().IsEmpty()); |
+} |
+ |
+// Verify that having an animated filter (but no current filter, as these |
+// are mutually exclusive) correctly creates a render surface. |
+TEST_F(LayerTreeHostCommonTest, AnimatedFilterCreatesRenderSurface) { |
+ scoped_refptr<Layer> root = Layer::Create(); |
+ scoped_refptr<Layer> child = Layer::Create(); |
+ scoped_refptr<Layer> grandchild = Layer::Create(); |
+ root->AddChild(child); |
+ child->AddChild(grandchild); |
+ |
+ gfx::Transform identity_transform; |
+ SetLayerPropertiesForTesting(root.get(), identity_transform, gfx::Point3F(), |
+ gfx::PointF(), gfx::Size(50, 50), true, false); |
+ SetLayerPropertiesForTesting(child.get(), identity_transform, gfx::Point3F(), |
+ gfx::PointF(), gfx::Size(50, 50), true, false); |
+ SetLayerPropertiesForTesting(grandchild.get(), identity_transform, |
+ gfx::Point3F(), gfx::PointF(), gfx::Size(50, 50), |
+ true, false); |
+ scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); |
+ host->SetRootLayer(root); |
+ |
+ AddAnimatedFilterToLayer(child.get(), 10.0, 0.1f, 0.2f); |
+ |
+ ExecuteCalculateDrawProperties(root.get()); |
+ |
+ EXPECT_TRUE(root->render_surface()); |
+ EXPECT_TRUE(child->render_surface()); |
+ EXPECT_FALSE(grandchild->render_surface()); |
+ |
+ EXPECT_TRUE(root->filters().IsEmpty()); |
+ EXPECT_TRUE(child->filters().IsEmpty()); |
+ EXPECT_TRUE(grandchild->filters().IsEmpty()); |
+ |
+ EXPECT_FALSE(root->FilterIsAnimating()); |
+ EXPECT_TRUE(child->FilterIsAnimating()); |
+ EXPECT_FALSE(grandchild->FilterIsAnimating()); |
+} |
+ |
} // namespace |
} // namespace cc |