Chromium Code Reviews| 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 0932bffb9fcdc517ae7e3a6caf5eb0eae8075321..b0b6e40fc326912a7704c604fe3f04d294bf09ae 100644 |
| --- a/cc/trees/layer_tree_host_common_unittest.cc |
| +++ b/cc/trees/layer_tree_host_common_unittest.cc |
| @@ -9651,6 +9651,54 @@ TEST_F(LayerTreeHostCommonTest, LargeTransformTest) { |
| EXPECT_TRUE(root_in_rsll); |
| } |
| +TEST_F(LayerTreeHostCommonTest, PropertyTreesRebuildWithOpacityChanges) { |
| + const gfx::Transform identity_matrix; |
| + scoped_refptr<Layer> root = Layer::Create(); |
| + scoped_refptr<LayerWithForcedDrawsContent> child = |
| + make_scoped_refptr(new LayerWithForcedDrawsContent()); |
| + root->AddChild(child); |
| + |
| + host()->SetRootLayer(root); |
| + |
| + SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), |
| + gfx::PointF(), gfx::Size(100, 100), true, false); |
| + SetLayerPropertiesForTesting(child.get(), identity_matrix, gfx::Point3F(), |
| + gfx::PointF(), gfx::Size(20, 20), true, false); |
| + |
| + 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.
|
| + ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
| + |
| + // Changing the opacity from 1 to non-1 value should trigger rebuild of |
| + // property trees as a new effect node will be created. |
| + child->SetOpacity(0.5f); |
| + 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.
|
| + EXPECT_TRUE(property_trees->needs_rebuild); |
| + |
| + ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
| + EXPECT_NE(property_trees->effect_id_to_index_map.find(child->id()), |
| + property_trees->effect_id_to_index_map.end()); |
| + |
| + // child already has an effect node. Changing its opacity shouldn't trigger |
| + // a property trees rebuild. |
| + child->SetOpacity(0.8f); |
| + property_trees = root->layer_tree_host()->property_trees(); |
| + EXPECT_FALSE(property_trees->needs_rebuild); |
| + |
| + ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
| + EXPECT_NE(property_trees->effect_id_to_index_map.find(child->id()), |
| + property_trees->effect_id_to_index_map.end()); |
| + |
| + // Changing the opacity from non-1 value to 1 should trigger a rebuild of |
| + // property trees as the effect node may no longer be needed. |
| + child->SetOpacity(1.f); |
| + property_trees = root->layer_tree_host()->property_trees(); |
| + EXPECT_TRUE(property_trees->needs_rebuild); |
| + |
| + ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
| + EXPECT_EQ(property_trees->effect_id_to_index_map.find(child->id()), |
| + property_trees->effect_id_to_index_map.end()); |
| +} |
| + |
| TEST_F(LayerTreeHostCommonTest, OpacityAnimationsTrackingTest) { |
| const gfx::Transform identity_matrix; |
| scoped_refptr<Layer> root = Layer::Create(); |