| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 9633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9644 is_inf_or_nan = std::isinf(child->DrawTransform().matrix().get(1, 1)) || | 9644 is_inf_or_nan = std::isinf(child->DrawTransform().matrix().get(1, 1)) || |
| 9645 std::isnan(child->DrawTransform().matrix().get(1, 1)); | 9645 std::isnan(child->DrawTransform().matrix().get(1, 1)); |
| 9646 EXPECT_TRUE(is_inf_or_nan); | 9646 EXPECT_TRUE(is_inf_or_nan); |
| 9647 | 9647 |
| 9648 std::vector<LayerImpl*>* rsll = render_surface_layer_list_impl(); | 9648 std::vector<LayerImpl*>* rsll = render_surface_layer_list_impl(); |
| 9649 bool root_in_rsll = | 9649 bool root_in_rsll = |
| 9650 std::find(rsll->begin(), rsll->end(), root) != rsll->end(); | 9650 std::find(rsll->begin(), rsll->end(), root) != rsll->end(); |
| 9651 EXPECT_TRUE(root_in_rsll); | 9651 EXPECT_TRUE(root_in_rsll); |
| 9652 } | 9652 } |
| 9653 | 9653 |
| 9654 TEST_F(LayerTreeHostCommonTest, PropertyTreesRebuildWithOpacityChanges) { |
| 9655 const gfx::Transform identity_matrix; |
| 9656 scoped_refptr<Layer> root = Layer::Create(); |
| 9657 scoped_refptr<LayerWithForcedDrawsContent> child = |
| 9658 make_scoped_refptr(new LayerWithForcedDrawsContent()); |
| 9659 root->AddChild(child); |
| 9660 |
| 9661 host()->SetRootLayer(root); |
| 9662 |
| 9663 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), |
| 9664 gfx::PointF(), gfx::Size(100, 100), true, false); |
| 9665 SetLayerPropertiesForTesting(child.get(), identity_matrix, gfx::Point3F(), |
| 9666 gfx::PointF(), gfx::Size(20, 20), true, false); |
| 9667 |
| 9668 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
| 9669 |
| 9670 // Changing the opacity from 1 to non-1 value should trigger rebuild of |
| 9671 // property trees as a new effect node will be created. |
| 9672 child->SetOpacity(0.5f); |
| 9673 PropertyTrees* property_trees = host()->property_trees(); |
| 9674 EXPECT_TRUE(property_trees->needs_rebuild); |
| 9675 |
| 9676 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
| 9677 EXPECT_NE(property_trees->effect_id_to_index_map.find(child->id()), |
| 9678 property_trees->effect_id_to_index_map.end()); |
| 9679 |
| 9680 // child already has an effect node. Changing its opacity shouldn't trigger |
| 9681 // a property trees rebuild. |
| 9682 child->SetOpacity(0.8f); |
| 9683 property_trees = host()->property_trees(); |
| 9684 EXPECT_FALSE(property_trees->needs_rebuild); |
| 9685 |
| 9686 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
| 9687 EXPECT_NE(property_trees->effect_id_to_index_map.find(child->id()), |
| 9688 property_trees->effect_id_to_index_map.end()); |
| 9689 |
| 9690 // Changing the opacity from non-1 value to 1 should trigger a rebuild of |
| 9691 // property trees as the effect node may no longer be needed. |
| 9692 child->SetOpacity(1.f); |
| 9693 property_trees = host()->property_trees(); |
| 9694 EXPECT_TRUE(property_trees->needs_rebuild); |
| 9695 |
| 9696 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
| 9697 EXPECT_EQ(property_trees->effect_id_to_index_map.find(child->id()), |
| 9698 property_trees->effect_id_to_index_map.end()); |
| 9699 } |
| 9700 |
| 9654 TEST_F(LayerTreeHostCommonTest, OpacityAnimationsTrackingTest) { | 9701 TEST_F(LayerTreeHostCommonTest, OpacityAnimationsTrackingTest) { |
| 9655 const gfx::Transform identity_matrix; | 9702 const gfx::Transform identity_matrix; |
| 9656 scoped_refptr<Layer> root = Layer::Create(); | 9703 scoped_refptr<Layer> root = Layer::Create(); |
| 9657 scoped_refptr<LayerWithForcedDrawsContent> animated = | 9704 scoped_refptr<LayerWithForcedDrawsContent> animated = |
| 9658 make_scoped_refptr(new LayerWithForcedDrawsContent()); | 9705 make_scoped_refptr(new LayerWithForcedDrawsContent()); |
| 9659 root->AddChild(animated); | 9706 root->AddChild(animated); |
| 9660 | 9707 |
| 9661 host()->SetRootLayer(root); | 9708 host()->SetRootLayer(root); |
| 9662 | 9709 |
| 9663 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), | 9710 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9928 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); | 9975 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); |
| 9929 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); | 9976 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); |
| 9930 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); | 9977 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); |
| 9931 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); | 9978 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); |
| 9932 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); | 9979 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); |
| 9933 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); | 9980 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); |
| 9934 } | 9981 } |
| 9935 | 9982 |
| 9936 } // namespace | 9983 } // namespace |
| 9937 } // namespace cc | 9984 } // namespace cc |
| OLD | NEW |