| 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 10246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10257 child->SetBounds(gfx::Size(20, 20)); | 10257 child->SetBounds(gfx::Size(20, 20)); |
| 10258 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get()); | 10258 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get()); |
| 10259 | 10259 |
| 10260 // Changing the opacity from 1 to non-1 value should trigger rebuild of | 10260 // Changing the opacity from 1 to non-1 value should trigger rebuild of |
| 10261 // property trees as a new effect node will be created. | 10261 // property trees as a new effect node will be created. |
| 10262 child->SetOpacity(0.5f); | 10262 child->SetOpacity(0.5f); |
| 10263 PropertyTrees* property_trees = host()->property_trees(); | 10263 PropertyTrees* property_trees = host()->property_trees(); |
| 10264 EXPECT_TRUE(property_trees->needs_rebuild); | 10264 EXPECT_TRUE(property_trees->needs_rebuild); |
| 10265 | 10265 |
| 10266 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get()); | 10266 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get()); |
| 10267 EXPECT_NE(property_trees->effect_id_to_index_map.find(child->id()), | 10267 EXPECT_NE(property_trees->layer_id_to_effect_node_index.find(child->id()), |
| 10268 property_trees->effect_id_to_index_map.end()); | 10268 property_trees->layer_id_to_effect_node_index.end()); |
| 10269 | 10269 |
| 10270 // child already has an effect node. Changing its opacity shouldn't trigger | 10270 // child already has an effect node. Changing its opacity shouldn't trigger |
| 10271 // a property trees rebuild. | 10271 // a property trees rebuild. |
| 10272 child->SetOpacity(0.8f); | 10272 child->SetOpacity(0.8f); |
| 10273 property_trees = host()->property_trees(); | 10273 property_trees = host()->property_trees(); |
| 10274 EXPECT_FALSE(property_trees->needs_rebuild); | 10274 EXPECT_FALSE(property_trees->needs_rebuild); |
| 10275 | 10275 |
| 10276 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get()); | 10276 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get()); |
| 10277 EXPECT_NE(property_trees->effect_id_to_index_map.find(child->id()), | 10277 EXPECT_NE(property_trees->layer_id_to_effect_node_index.find(child->id()), |
| 10278 property_trees->effect_id_to_index_map.end()); | 10278 property_trees->layer_id_to_effect_node_index.end()); |
| 10279 | 10279 |
| 10280 // Changing the opacity from non-1 value to 1 should trigger a rebuild of | 10280 // Changing the opacity from non-1 value to 1 should trigger a rebuild of |
| 10281 // property trees as the effect node may no longer be needed. | 10281 // property trees as the effect node may no longer be needed. |
| 10282 child->SetOpacity(1.f); | 10282 child->SetOpacity(1.f); |
| 10283 property_trees = host()->property_trees(); | 10283 property_trees = host()->property_trees(); |
| 10284 EXPECT_TRUE(property_trees->needs_rebuild); | 10284 EXPECT_TRUE(property_trees->needs_rebuild); |
| 10285 | 10285 |
| 10286 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get()); | 10286 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get()); |
| 10287 EXPECT_EQ(property_trees->effect_id_to_index_map.find(child->id()), | 10287 EXPECT_EQ(property_trees->layer_id_to_effect_node_index.find(child->id()), |
| 10288 property_trees->effect_id_to_index_map.end()); | 10288 property_trees->layer_id_to_effect_node_index.end()); |
| 10289 } | 10289 } |
| 10290 | 10290 |
| 10291 TEST_F(LayerTreeHostCommonTest, OpacityAnimationsTrackingTest) { | 10291 TEST_F(LayerTreeHostCommonTest, OpacityAnimationsTrackingTest) { |
| 10292 scoped_refptr<Layer> root = Layer::Create(); | 10292 scoped_refptr<Layer> root = Layer::Create(); |
| 10293 scoped_refptr<LayerWithForcedDrawsContent> animated = | 10293 scoped_refptr<LayerWithForcedDrawsContent> animated = |
| 10294 make_scoped_refptr(new LayerWithForcedDrawsContent()); | 10294 make_scoped_refptr(new LayerWithForcedDrawsContent()); |
| 10295 root->AddChild(animated); | 10295 root->AddChild(animated); |
| 10296 host()->SetRootLayer(root); | 10296 host()->SetRootLayer(root); |
| 10297 host()->GetLayerTree()->SetElementIdsForTesting(); | 10297 host()->GetLayerTree()->SetElementIdsForTesting(); |
| 10298 | 10298 |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10583 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); | 10583 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); |
| 10584 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); | 10584 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); |
| 10585 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); | 10585 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); |
| 10586 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); | 10586 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); |
| 10587 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); | 10587 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); |
| 10588 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); | 10588 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); |
| 10589 } | 10589 } |
| 10590 | 10590 |
| 10591 } // namespace | 10591 } // namespace |
| 10592 } // namespace cc | 10592 } // namespace cc |
| OLD | NEW |