| 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/layers/layer.h" | 5 #include "cc/layers/layer.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/thread_task_runner_handle.h" | 9 #include "base/thread_task_runner_handle.h" |
| 10 #include "cc/animation/animation_host.h" | 10 #include "cc/animation/animation_host.h" |
| (...skipping 1046 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1057 // changed. | 1057 // changed. |
| 1058 gfx::Size arbitrary_size = gfx::Size(111, 222); | 1058 gfx::Size arbitrary_size = gfx::Size(111, 222); |
| 1059 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); | 1059 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); |
| 1060 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetBounds(arbitrary_size)); | 1060 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetBounds(arbitrary_size)); |
| 1061 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( | 1061 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( |
| 1062 root->PushPropertiesTo(root_impl.get()); | 1062 root->PushPropertiesTo(root_impl.get()); |
| 1063 child->PushPropertiesTo(child_impl.get()); | 1063 child->PushPropertiesTo(child_impl.get()); |
| 1064 child2->PushPropertiesTo(child2_impl.get()); | 1064 child2->PushPropertiesTo(child2_impl.get()); |
| 1065 grand_child->PushPropertiesTo(grand_child_impl.get())); | 1065 grand_child->PushPropertiesTo(grand_child_impl.get())); |
| 1066 | 1066 |
| 1067 FilterOperations arbitrary_filters; |
| 1068 arbitrary_filters.Append(FilterOperation::CreateOpacityFilter(0.5f)); |
| 1069 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); |
| 1070 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetFilters(arbitrary_filters)); |
| 1071 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( |
| 1072 root->PushPropertiesTo(root_impl.get()); |
| 1073 child->PushPropertiesTo(child_impl.get()); |
| 1074 child2->PushPropertiesTo(child2_impl.get()); |
| 1075 grand_child->PushPropertiesTo(grand_child_impl.get())); |
| 1076 |
| 1067 gfx::PointF arbitrary_point_f = gfx::PointF(0.125f, 0.25f); | 1077 gfx::PointF arbitrary_point_f = gfx::PointF(0.125f, 0.25f); |
| 1068 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); | 1078 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); |
| 1069 root->SetPosition(arbitrary_point_f); | 1079 root->SetPosition(arbitrary_point_f); |
| 1070 TransformNode* node = layer_tree_host_->property_trees()->transform_tree.Node( | 1080 TransformNode* node = layer_tree_host_->property_trees()->transform_tree.Node( |
| 1071 root->transform_tree_index()); | 1081 root->transform_tree_index()); |
| 1072 EXPECT_TRUE(node->data.transform_changed); | 1082 EXPECT_TRUE(node->data.transform_changed); |
| 1073 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( | 1083 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( |
| 1074 root->PushPropertiesTo(root_impl.get()); | 1084 root->PushPropertiesTo(root_impl.get()); |
| 1075 child->PushPropertiesTo(child_impl.get()); | 1085 child->PushPropertiesTo(child_impl.get()); |
| 1076 child2->PushPropertiesTo(child2_impl.get()); | 1086 child2->PushPropertiesTo(child2_impl.get()); |
| 1077 grand_child->PushPropertiesTo(grand_child_impl.get()); | 1087 grand_child->PushPropertiesTo(grand_child_impl.get()); |
| 1078 layer_tree_host_->property_trees()->transform_tree.ResetChangeTracking()); | 1088 layer_tree_host_->property_trees()->ResetAllChangeTracking( |
| 1089 PropertyTrees::ResetFlags::ALL_TREES)); |
| 1079 EXPECT_FALSE(node->data.transform_changed); | 1090 EXPECT_FALSE(node->data.transform_changed); |
| 1080 | 1091 |
| 1081 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); | 1092 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); |
| 1082 child->SetPosition(arbitrary_point_f); | 1093 child->SetPosition(arbitrary_point_f); |
| 1083 node = layer_tree_host_->property_trees()->transform_tree.Node( | 1094 node = layer_tree_host_->property_trees()->transform_tree.Node( |
| 1084 child->transform_tree_index()); | 1095 child->transform_tree_index()); |
| 1085 EXPECT_TRUE(node->data.transform_changed); | 1096 EXPECT_TRUE(node->data.transform_changed); |
| 1086 // child2 is not in the subtree of child, but its scroll parent is. So, its | 1097 // child2 is not in the subtree of child, but its scroll parent is. So, its |
| 1087 // to_screen will be effected by change in position of child2. | 1098 // to_screen will be effected by change in position of child2. |
| 1088 layer_tree_host_->property_trees()->transform_tree.UpdateTransforms( | 1099 layer_tree_host_->property_trees()->transform_tree.UpdateTransforms( |
| 1089 child2->transform_tree_index()); | 1100 child2->transform_tree_index()); |
| 1090 node = layer_tree_host_->property_trees()->transform_tree.Node( | 1101 node = layer_tree_host_->property_trees()->transform_tree.Node( |
| 1091 child2->transform_tree_index()); | 1102 child2->transform_tree_index()); |
| 1092 EXPECT_TRUE(node->data.transform_changed); | 1103 EXPECT_TRUE(node->data.transform_changed); |
| 1093 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( | 1104 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( |
| 1094 child->PushPropertiesTo(child_impl.get()); | 1105 child->PushPropertiesTo(child_impl.get()); |
| 1095 grand_child->PushPropertiesTo(grand_child_impl.get()); | 1106 grand_child->PushPropertiesTo(grand_child_impl.get()); |
| 1096 layer_tree_host_->property_trees()->transform_tree.ResetChangeTracking()); | 1107 layer_tree_host_->property_trees()->ResetAllChangeTracking( |
| 1108 PropertyTrees::ResetFlags::ALL_TREES)); |
| 1097 node = layer_tree_host_->property_trees()->transform_tree.Node( | 1109 node = layer_tree_host_->property_trees()->transform_tree.Node( |
| 1098 child->transform_tree_index()); | 1110 child->transform_tree_index()); |
| 1099 EXPECT_FALSE(node->data.transform_changed); | 1111 EXPECT_FALSE(node->data.transform_changed); |
| 1100 | 1112 |
| 1101 gfx::Point3F arbitrary_point_3f = gfx::Point3F(0.125f, 0.25f, 0.f); | 1113 gfx::Point3F arbitrary_point_3f = gfx::Point3F(0.125f, 0.25f, 0.f); |
| 1102 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); | 1114 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); |
| 1103 root->SetTransformOrigin(arbitrary_point_3f); | 1115 root->SetTransformOrigin(arbitrary_point_3f); |
| 1104 node = layer_tree_host_->property_trees()->transform_tree.Node( | 1116 node = layer_tree_host_->property_trees()->transform_tree.Node( |
| 1105 root->transform_tree_index()); | 1117 root->transform_tree_index()); |
| 1106 EXPECT_TRUE(node->data.transform_changed); | 1118 EXPECT_TRUE(node->data.transform_changed); |
| 1107 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( | 1119 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( |
| 1108 root->PushPropertiesTo(root_impl.get()); | 1120 root->PushPropertiesTo(root_impl.get()); |
| 1109 child->PushPropertiesTo(child_impl.get()); | 1121 child->PushPropertiesTo(child_impl.get()); |
| 1110 child2->PushPropertiesTo(child2_impl.get()); | 1122 child2->PushPropertiesTo(child2_impl.get()); |
| 1111 grand_child->PushPropertiesTo(grand_child_impl.get()); | 1123 grand_child->PushPropertiesTo(grand_child_impl.get()); |
| 1112 layer_tree_host_->property_trees()->transform_tree.ResetChangeTracking()); | 1124 layer_tree_host_->property_trees()->ResetAllChangeTracking( |
| 1125 PropertyTrees::ResetFlags::ALL_TREES)); |
| 1113 | 1126 |
| 1114 gfx::Transform arbitrary_transform; | 1127 gfx::Transform arbitrary_transform; |
| 1115 arbitrary_transform.Scale3d(0.1f, 0.2f, 0.3f); | 1128 arbitrary_transform.Scale3d(0.1f, 0.2f, 0.3f); |
| 1116 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); | 1129 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); |
| 1117 root->SetTransform(arbitrary_transform); | 1130 root->SetTransform(arbitrary_transform); |
| 1118 node = layer_tree_host_->property_trees()->transform_tree.Node( | 1131 node = layer_tree_host_->property_trees()->transform_tree.Node( |
| 1119 root->transform_tree_index()); | 1132 root->transform_tree_index()); |
| 1120 EXPECT_TRUE(node->data.transform_changed); | 1133 EXPECT_TRUE(node->data.transform_changed); |
| 1121 } | 1134 } |
| 1122 | 1135 |
| (...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1713 | 1726 |
| 1714 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetOpacity(0.5f)); | 1727 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetOpacity(0.5f)); |
| 1715 | 1728 |
| 1716 EXPECT_FALSE(impl_layer->LayerPropertyChanged()); | 1729 EXPECT_FALSE(impl_layer->LayerPropertyChanged()); |
| 1717 | 1730 |
| 1718 test_layer->PushPropertiesTo(impl_layer.get()); | 1731 test_layer->PushPropertiesTo(impl_layer.get()); |
| 1719 | 1732 |
| 1720 EXPECT_TRUE(impl_layer->LayerPropertyChanged()); | 1733 EXPECT_TRUE(impl_layer->LayerPropertyChanged()); |
| 1721 } | 1734 } |
| 1722 | 1735 |
| 1723 TEST_F(LayerTest, | |
| 1724 PushPropsDoesntCauseLayerPropertyChangedDuringImplOnlyFilterAnim) { | |
| 1725 scoped_refptr<Layer> test_layer = Layer::Create(layer_settings_); | |
| 1726 scoped_ptr<LayerImpl> impl_layer = | |
| 1727 LayerImpl::Create(host_impl_.active_tree(), 1); | |
| 1728 | |
| 1729 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, | |
| 1730 layer_tree_host_->SetRootLayer(test_layer)); | |
| 1731 | |
| 1732 scoped_ptr<AnimationRegistrar> registrar; | |
| 1733 if (settings().use_compositor_animation_timelines) { | |
| 1734 AddAnimatedFilterToLayerWithPlayer(impl_layer->id(), timeline_impl(), 1.0, | |
| 1735 1.f, 2.f); | |
| 1736 } else { | |
| 1737 registrar = AnimationRegistrar::Create(); | |
| 1738 impl_layer->layer_animation_controller()->SetAnimationRegistrar( | |
| 1739 registrar.get()); | |
| 1740 | |
| 1741 AddAnimatedFilterToController(impl_layer->layer_animation_controller(), 1.0, | |
| 1742 1.f, 2.f); | |
| 1743 } | |
| 1744 | |
| 1745 FilterOperations filters; | |
| 1746 filters.Append(FilterOperation::CreateBlurFilter(2.f)); | |
| 1747 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetFilters(filters)); | |
| 1748 | |
| 1749 EXPECT_FALSE(impl_layer->LayerPropertyChanged()); | |
| 1750 test_layer->PushPropertiesTo(impl_layer.get()); | |
| 1751 EXPECT_TRUE(impl_layer->LayerPropertyChanged()); | |
| 1752 | |
| 1753 impl_layer->ResetAllChangeTrackingForSubtree(); | |
| 1754 if (settings().use_compositor_animation_timelines) { | |
| 1755 int animation_id = AddAnimatedFilterToLayerWithPlayer( | |
| 1756 impl_layer->id(), timeline_impl(), 1.0, 1.f, 2.f); | |
| 1757 GetAnimationFromLayerWithExistingPlayer(impl_layer->id(), timeline_impl(), | |
| 1758 animation_id) | |
| 1759 ->set_is_impl_only(true); | |
| 1760 } else { | |
| 1761 AddAnimatedFilterToController(impl_layer->layer_animation_controller(), 1.0, | |
| 1762 1.f, 2.f); | |
| 1763 impl_layer->layer_animation_controller() | |
| 1764 ->GetAnimation(TargetProperty::FILTER) | |
| 1765 ->set_is_impl_only(true); | |
| 1766 } | |
| 1767 filters.Append(FilterOperation::CreateSepiaFilter(0.5f)); | |
| 1768 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetFilters(filters)); | |
| 1769 | |
| 1770 EXPECT_FALSE(impl_layer->LayerPropertyChanged()); | |
| 1771 test_layer->PushPropertiesTo(impl_layer.get()); | |
| 1772 EXPECT_FALSE(impl_layer->LayerPropertyChanged()); | |
| 1773 } | |
| 1774 | |
| 1775 TEST_F(LayerTest, MaskAndReplicaHasParent) { | 1736 TEST_F(LayerTest, MaskAndReplicaHasParent) { |
| 1776 scoped_refptr<Layer> parent = Layer::Create(layer_settings_); | 1737 scoped_refptr<Layer> parent = Layer::Create(layer_settings_); |
| 1777 scoped_refptr<Layer> child = Layer::Create(layer_settings_); | 1738 scoped_refptr<Layer> child = Layer::Create(layer_settings_); |
| 1778 scoped_refptr<Layer> mask = Layer::Create(layer_settings_); | 1739 scoped_refptr<Layer> mask = Layer::Create(layer_settings_); |
| 1779 scoped_refptr<Layer> replica = Layer::Create(layer_settings_); | 1740 scoped_refptr<Layer> replica = Layer::Create(layer_settings_); |
| 1780 scoped_refptr<Layer> replica_mask = Layer::Create(layer_settings_); | 1741 scoped_refptr<Layer> replica_mask = Layer::Create(layer_settings_); |
| 1781 scoped_refptr<Layer> mask_replacement = Layer::Create(layer_settings_); | 1742 scoped_refptr<Layer> mask_replacement = Layer::Create(layer_settings_); |
| 1782 scoped_refptr<Layer> replica_replacement = Layer::Create(layer_settings_); | 1743 scoped_refptr<Layer> replica_replacement = Layer::Create(layer_settings_); |
| 1783 scoped_refptr<Layer> replica_mask_replacement = | 1744 scoped_refptr<Layer> replica_mask_replacement = |
| 1784 Layer::Create(layer_settings_); | 1745 Layer::Create(layer_settings_); |
| (...skipping 946 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2731 EXPECT_EQ(MutableProperty::kNone, impl_layer->mutable_properties()); | 2692 EXPECT_EQ(MutableProperty::kNone, impl_layer->mutable_properties()); |
| 2732 | 2693 |
| 2733 test_layer->PushPropertiesTo(impl_layer.get()); | 2694 test_layer->PushPropertiesTo(impl_layer.get()); |
| 2734 | 2695 |
| 2735 EXPECT_EQ(2lu, impl_layer->element_id()); | 2696 EXPECT_EQ(2lu, impl_layer->element_id()); |
| 2736 EXPECT_EQ(MutableProperty::kTransform, impl_layer->mutable_properties()); | 2697 EXPECT_EQ(MutableProperty::kTransform, impl_layer->mutable_properties()); |
| 2737 } | 2698 } |
| 2738 | 2699 |
| 2739 } // namespace | 2700 } // namespace |
| 2740 } // namespace cc | 2701 } // namespace cc |
| OLD | NEW |