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 2957 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2968 AddAnimatedTransformToLayer( | 2968 AddAnimatedTransformToLayer( |
2969 root.get(), 10.0, start_transform_operations, end_transform_operations); | 2969 root.get(), 10.0, start_transform_operations, end_transform_operations); |
2970 | 2970 |
2971 EXPECT_TRUE(root->TransformIsAnimating()); | 2971 EXPECT_TRUE(root->TransformIsAnimating()); |
2972 | 2972 |
2973 ExecuteCalculateDrawProperties(root.get()); | 2973 ExecuteCalculateDrawProperties(root.get()); |
2974 | 2974 |
2975 EXPECT_FALSE(child->draw_properties().sorted_for_recursion); | 2975 EXPECT_FALSE(child->draw_properties().sorted_for_recursion); |
2976 } | 2976 } |
2977 | 2977 |
| 2978 TEST_F(LayerTreeHostCommonTest, WillSortAtContextBoundary) { |
| 2979 // Creates a layer tree that looks as follows: |
| 2980 // * root (sorting-context-id1) |
| 2981 // * parent (sorting-context-id2) |
| 2982 // * child1 (sorting-context-id2) |
| 2983 // * child2 (sorting-context-id2) |
| 2984 // |
| 2985 // This test ensures that we sort at |parent| even though both it and root are |
| 2986 // set to be 3d sorted. |
| 2987 FakeImplProxy proxy; |
| 2988 TestSharedBitmapManager shared_bitmap_manager; |
| 2989 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); |
| 2990 |
| 2991 scoped_ptr<LayerImpl> root_ptr(LayerImpl::Create(host_impl.active_tree(), 1)); |
| 2992 LayerImpl* root = root_ptr.get(); |
| 2993 scoped_ptr<LayerImpl> parent_ptr( |
| 2994 LayerImpl::Create(host_impl.active_tree(), 2)); |
| 2995 LayerImpl* parent = parent_ptr.get(); |
| 2996 scoped_ptr<LayerImpl> child1_ptr( |
| 2997 LayerImpl::Create(host_impl.active_tree(), 3)); |
| 2998 LayerImpl* child1 = child1_ptr.get(); |
| 2999 scoped_ptr<LayerImpl> child2_ptr( |
| 3000 LayerImpl::Create(host_impl.active_tree(), 4)); |
| 3001 LayerImpl* child2 = child2_ptr.get(); |
| 3002 |
| 3003 gfx::Transform identity_matrix; |
| 3004 gfx::Transform below_matrix; |
| 3005 below_matrix.Translate3d(0.f, 0.f, -10.f); |
| 3006 gfx::Transform above_matrix; |
| 3007 above_matrix.Translate3d(0.f, 0.f, 10.f); |
| 3008 |
| 3009 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), |
| 3010 gfx::PointF(), gfx::Size(100, 100), true, true, |
| 3011 true); |
| 3012 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(), |
| 3013 gfx::PointF(), gfx::Size(50, 50), true, true, |
| 3014 true); |
| 3015 SetLayerPropertiesForTesting(child1, above_matrix, gfx::Point3F(), |
| 3016 gfx::PointF(), gfx::Size(50, 50), true, true, |
| 3017 false); |
| 3018 SetLayerPropertiesForTesting(child2, below_matrix, gfx::Point3F(), |
| 3019 gfx::PointF(), gfx::Size(50, 50), true, true, |
| 3020 false); |
| 3021 |
| 3022 root->Set3dSortingContextId(3); |
| 3023 root->SetDrawsContent(true); |
| 3024 parent->Set3dSortingContextId(7); |
| 3025 parent->SetDrawsContent(true); |
| 3026 child1->Set3dSortingContextId(7); |
| 3027 child1->SetDrawsContent(true); |
| 3028 child2->Set3dSortingContextId(7); |
| 3029 child2->SetDrawsContent(true); |
| 3030 |
| 3031 parent->AddChild(child1_ptr.Pass()); |
| 3032 parent->AddChild(child2_ptr.Pass()); |
| 3033 root->AddChild(parent_ptr.Pass()); |
| 3034 |
| 3035 LayerImplList render_surface_layer_list; |
| 3036 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
| 3037 root_ptr.get(), root->bounds(), &render_surface_layer_list); |
| 3038 inputs.can_adjust_raster_scales = true; |
| 3039 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
| 3040 |
| 3041 EXPECT_TRUE(root->render_surface()); |
| 3042 EXPECT_EQ(2u, render_surface_layer_list.size()); |
| 3043 |
| 3044 EXPECT_EQ(3u, parent->render_surface()->layer_list().size()); |
| 3045 EXPECT_EQ(child2->id(), parent->render_surface()->layer_list().at(0)->id()); |
| 3046 EXPECT_EQ(parent->id(), parent->render_surface()->layer_list().at(1)->id()); |
| 3047 EXPECT_EQ(child1->id(), parent->render_surface()->layer_list().at(2)->id()); |
| 3048 } |
| 3049 |
2978 TEST_F(LayerTreeHostCommonTest, | 3050 TEST_F(LayerTreeHostCommonTest, |
2979 SingularNonAnimatingTransformDoesNotPreventClearingDrawProperties) { | 3051 SingularNonAnimatingTransformDoesNotPreventClearingDrawProperties) { |
2980 scoped_refptr<Layer> root = Layer::Create(); | 3052 scoped_refptr<Layer> root = Layer::Create(); |
2981 | 3053 |
2982 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); | 3054 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); |
2983 host->SetRootLayer(root); | 3055 host->SetRootLayer(root); |
2984 | 3056 |
2985 gfx::Transform identity_matrix; | 3057 gfx::Transform identity_matrix; |
2986 gfx::Transform uninvertible_matrix(0.0, 0.0, 0.0, 0.0, 0.0, 0.0); | 3058 gfx::Transform uninvertible_matrix(0.0, 0.0, 0.0, 0.0, 0.0, 0.0); |
2987 ASSERT_FALSE(uninvertible_matrix.IsInvertible()); | 3059 ASSERT_FALSE(uninvertible_matrix.IsInvertible()); |
(...skipping 5680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8668 | 8740 |
8669 root->SetBoundsDelta(gfx::Vector2dF(0.0, 50.0)); | 8741 root->SetBoundsDelta(gfx::Vector2dF(0.0, 50.0)); |
8670 | 8742 |
8671 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 8743 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
8672 | 8744 |
8673 gfx::Rect affected_by_delta(0, 0, root_size.width(), | 8745 gfx::Rect affected_by_delta(0, 0, root_size.width(), |
8674 root_size.height() + 50); | 8746 root_size.height() + 50); |
8675 EXPECT_EQ(affected_by_delta, sublayer->visible_content_rect()); | 8747 EXPECT_EQ(affected_by_delta, sublayer->visible_content_rect()); |
8676 } | 8748 } |
8677 | 8749 |
| 8750 TEST_F(LayerTreeHostCommonTest, VisibleContentRectForAnimatedLayer) { |
| 8751 const gfx::Transform identity_matrix; |
| 8752 scoped_refptr<Layer> root = Layer::Create(); |
| 8753 scoped_refptr<LayerWithForcedDrawsContent> animated = |
| 8754 make_scoped_refptr(new LayerWithForcedDrawsContent()); |
| 8755 |
| 8756 root->AddChild(animated); |
| 8757 |
| 8758 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); |
| 8759 host->SetRootLayer(root); |
| 8760 |
| 8761 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), |
| 8762 gfx::PointF(), gfx::Size(100, 100), true, false); |
| 8763 SetLayerPropertiesForTesting(animated.get(), identity_matrix, gfx::Point3F(), |
| 8764 gfx::PointF(), gfx::Size(20, 20), true, false); |
| 8765 |
| 8766 root->SetMasksToBounds(true); |
| 8767 root->SetForceRenderSurface(true); |
| 8768 animated->SetOpacity(0.f); |
| 8769 |
| 8770 AddOpacityTransitionToController(animated->layer_animation_controller(), 10.0, |
| 8771 0.f, 1.f, false); |
| 8772 |
| 8773 ExecuteCalculateDrawProperties(root.get()); |
| 8774 |
| 8775 EXPECT_FALSE(animated->visible_rect_from_property_trees().IsEmpty()); |
| 8776 } |
| 8777 |
| 8778 // Verify that having an animated filter (but no current filter, as these |
| 8779 // are mutually exclusive) correctly creates a render surface. |
| 8780 TEST_F(LayerTreeHostCommonTest, AnimatedFilterCreatesRenderSurface) { |
| 8781 scoped_refptr<Layer> root = Layer::Create(); |
| 8782 scoped_refptr<Layer> child = Layer::Create(); |
| 8783 scoped_refptr<Layer> grandchild = Layer::Create(); |
| 8784 root->AddChild(child); |
| 8785 child->AddChild(grandchild); |
| 8786 |
| 8787 gfx::Transform identity_transform; |
| 8788 SetLayerPropertiesForTesting(root.get(), identity_transform, gfx::Point3F(), |
| 8789 gfx::PointF(), gfx::Size(50, 50), true, false); |
| 8790 SetLayerPropertiesForTesting(child.get(), identity_transform, gfx::Point3F(), |
| 8791 gfx::PointF(), gfx::Size(50, 50), true, false); |
| 8792 SetLayerPropertiesForTesting(grandchild.get(), identity_transform, |
| 8793 gfx::Point3F(), gfx::PointF(), gfx::Size(50, 50), |
| 8794 true, false); |
| 8795 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); |
| 8796 host->SetRootLayer(root); |
| 8797 |
| 8798 AddAnimatedFilterToLayer(child.get(), 10.0, 0.1f, 0.2f); |
| 8799 |
| 8800 ExecuteCalculateDrawProperties(root.get()); |
| 8801 |
| 8802 EXPECT_TRUE(root->render_surface()); |
| 8803 EXPECT_TRUE(child->render_surface()); |
| 8804 EXPECT_FALSE(grandchild->render_surface()); |
| 8805 |
| 8806 EXPECT_TRUE(root->filters().IsEmpty()); |
| 8807 EXPECT_TRUE(child->filters().IsEmpty()); |
| 8808 EXPECT_TRUE(grandchild->filters().IsEmpty()); |
| 8809 |
| 8810 EXPECT_FALSE(root->FilterIsAnimating()); |
| 8811 EXPECT_TRUE(child->FilterIsAnimating()); |
| 8812 EXPECT_FALSE(grandchild->FilterIsAnimating()); |
| 8813 } |
| 8814 |
8678 } // namespace | 8815 } // namespace |
8679 } // namespace cc | 8816 } // namespace cc |
OLD | NEW |