Chromium Code Reviews| 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 root->SetForceRenderSurfaceForTesting(true); | |
|
ajuma
2016/05/16 22:05:20
Is this line needed? (Won't the root always get a
jaydasika
2016/05/17 01:40:01
Done.
| |
| 9669 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | |
| 9670 | |
| 9671 // Changing the opacity from 1 to non-1 value should trigger rebuild of | |
| 9672 // property trees as a new effect node will be created. | |
| 9673 child->SetOpacity(0.5f); | |
| 9674 PropertyTrees* property_trees = root->layer_tree_host()->property_trees(); | |
|
ajuma
2016/05/16 22:05:20
"host()->property_trees()" here and in a couple pl
jaydasika
2016/05/17 01:40:01
Done.
| |
| 9675 EXPECT_TRUE(property_trees->needs_rebuild); | |
| 9676 | |
| 9677 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | |
| 9678 EXPECT_NE(property_trees->effect_id_to_index_map.find(child->id()), | |
| 9679 property_trees->effect_id_to_index_map.end()); | |
| 9680 | |
| 9681 // child already has an effect node. Changing its opacity shouldn't trigger | |
| 9682 // a property trees rebuild. | |
| 9683 child->SetOpacity(0.8f); | |
| 9684 property_trees = root->layer_tree_host()->property_trees(); | |
| 9685 EXPECT_FALSE(property_trees->needs_rebuild); | |
| 9686 | |
| 9687 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | |
| 9688 EXPECT_NE(property_trees->effect_id_to_index_map.find(child->id()), | |
| 9689 property_trees->effect_id_to_index_map.end()); | |
| 9690 | |
| 9691 // Changing the opacity from non-1 value to 1 should trigger a rebuild of | |
| 9692 // property trees as the effect node may no longer be needed. | |
| 9693 child->SetOpacity(1.f); | |
| 9694 property_trees = root->layer_tree_host()->property_trees(); | |
| 9695 EXPECT_TRUE(property_trees->needs_rebuild); | |
| 9696 | |
| 9697 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | |
| 9698 EXPECT_EQ(property_trees->effect_id_to_index_map.find(child->id()), | |
| 9699 property_trees->effect_id_to_index_map.end()); | |
| 9700 } | |
| 9701 | |
| 9654 TEST_F(LayerTreeHostCommonTest, OpacityAnimationsTrackingTest) { | 9702 TEST_F(LayerTreeHostCommonTest, OpacityAnimationsTrackingTest) { |
| 9655 const gfx::Transform identity_matrix; | 9703 const gfx::Transform identity_matrix; |
| 9656 scoped_refptr<Layer> root = Layer::Create(); | 9704 scoped_refptr<Layer> root = Layer::Create(); |
| 9657 scoped_refptr<LayerWithForcedDrawsContent> animated = | 9705 scoped_refptr<LayerWithForcedDrawsContent> animated = |
| 9658 make_scoped_refptr(new LayerWithForcedDrawsContent()); | 9706 make_scoped_refptr(new LayerWithForcedDrawsContent()); |
| 9659 root->AddChild(animated); | 9707 root->AddChild(animated); |
| 9660 | 9708 |
| 9661 host()->SetRootLayer(root); | 9709 host()->SetRootLayer(root); |
| 9662 | 9710 |
| 9663 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), | 9711 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()); | 9976 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); |
| 9929 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); | 9977 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); |
| 9930 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); | 9978 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); |
| 9931 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); | 9979 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); |
| 9932 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); | 9980 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); |
| 9933 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); | 9981 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); |
| 9934 } | 9982 } |
| 9935 | 9983 |
| 9936 } // namespace | 9984 } // namespace |
| 9937 } // namespace cc | 9985 } // namespace cc |
| OLD | NEW |