| 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/threading/thread_task_runner_handle.h" | 9 #include "base/threading/thread_task_runner_handle.h" |
| 10 #include "cc/animation/animation_host.h" | 10 #include "cc/animation/animation_host.h" |
| (...skipping 1104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1115 root->SetPosition(arbitrary_point_f); | 1115 root->SetPosition(arbitrary_point_f); |
| 1116 TransformNode* node = layer_tree_host_->property_trees()->transform_tree.Node( | 1116 TransformNode* node = layer_tree_host_->property_trees()->transform_tree.Node( |
| 1117 root->transform_tree_index()); | 1117 root->transform_tree_index()); |
| 1118 EXPECT_TRUE(node->data.transform_changed); | 1118 EXPECT_TRUE(node->data.transform_changed); |
| 1119 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( | 1119 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( |
| 1120 root->PushPropertiesTo(root_impl.get()); | 1120 root->PushPropertiesTo(root_impl.get()); |
| 1121 child->PushPropertiesTo(child_impl.get()); | 1121 child->PushPropertiesTo(child_impl.get()); |
| 1122 child2->PushPropertiesTo(child2_impl.get()); | 1122 child2->PushPropertiesTo(child2_impl.get()); |
| 1123 grand_child->PushPropertiesTo(grand_child_impl.get()); | 1123 grand_child->PushPropertiesTo(grand_child_impl.get()); |
| 1124 layer_tree_host_->property_trees()->ResetAllChangeTracking( | 1124 layer_tree_host_->property_trees()->ResetAllChangeTracking( |
| 1125 PropertyTrees::ResetFlags::ALL_TREES)); | 1125 PropertyTrees::Types::EFFECT_AND_TRANSFORM_TREES)); |
| 1126 EXPECT_FALSE(node->data.transform_changed); | 1126 EXPECT_FALSE(node->data.transform_changed); |
| 1127 | 1127 |
| 1128 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); | 1128 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); |
| 1129 child->SetPosition(arbitrary_point_f); | 1129 child->SetPosition(arbitrary_point_f); |
| 1130 node = layer_tree_host_->property_trees()->transform_tree.Node( | 1130 node = layer_tree_host_->property_trees()->transform_tree.Node( |
| 1131 child->transform_tree_index()); | 1131 child->transform_tree_index()); |
| 1132 EXPECT_TRUE(node->data.transform_changed); | 1132 EXPECT_TRUE(node->data.transform_changed); |
| 1133 // child2 is not in the subtree of child, but its scroll parent is. So, its | 1133 // child2 is not in the subtree of child, but its scroll parent is. So, its |
| 1134 // to_screen will be effected by change in position of child2. | 1134 // to_screen will be effected by change in position of child2. |
| 1135 layer_tree_host_->property_trees()->transform_tree.UpdateTransforms( | 1135 layer_tree_host_->property_trees()->transform_tree.UpdateTransforms( |
| 1136 child2->transform_tree_index()); | 1136 child2->transform_tree_index()); |
| 1137 node = layer_tree_host_->property_trees()->transform_tree.Node( | 1137 node = layer_tree_host_->property_trees()->transform_tree.Node( |
| 1138 child2->transform_tree_index()); | 1138 child2->transform_tree_index()); |
| 1139 EXPECT_TRUE(node->data.transform_changed); | 1139 EXPECT_TRUE(node->data.transform_changed); |
| 1140 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( | 1140 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( |
| 1141 child->PushPropertiesTo(child_impl.get()); | 1141 child->PushPropertiesTo(child_impl.get()); |
| 1142 grand_child->PushPropertiesTo(grand_child_impl.get()); | 1142 grand_child->PushPropertiesTo(grand_child_impl.get()); |
| 1143 layer_tree_host_->property_trees()->ResetAllChangeTracking( | 1143 layer_tree_host_->property_trees()->ResetAllChangeTracking( |
| 1144 PropertyTrees::ResetFlags::ALL_TREES)); | 1144 PropertyTrees::Types::EFFECT_AND_TRANSFORM_TREES)); |
| 1145 node = layer_tree_host_->property_trees()->transform_tree.Node( | 1145 node = layer_tree_host_->property_trees()->transform_tree.Node( |
| 1146 child->transform_tree_index()); | 1146 child->transform_tree_index()); |
| 1147 EXPECT_FALSE(node->data.transform_changed); | 1147 EXPECT_FALSE(node->data.transform_changed); |
| 1148 | 1148 |
| 1149 gfx::Point3F arbitrary_point_3f = gfx::Point3F(0.125f, 0.25f, 0.f); | 1149 gfx::Point3F arbitrary_point_3f = gfx::Point3F(0.125f, 0.25f, 0.f); |
| 1150 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); | 1150 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); |
| 1151 root->SetTransformOrigin(arbitrary_point_3f); | 1151 root->SetTransformOrigin(arbitrary_point_3f); |
| 1152 node = layer_tree_host_->property_trees()->transform_tree.Node( | 1152 node = layer_tree_host_->property_trees()->transform_tree.Node( |
| 1153 root->transform_tree_index()); | 1153 root->transform_tree_index()); |
| 1154 EXPECT_TRUE(node->data.transform_changed); | 1154 EXPECT_TRUE(node->data.transform_changed); |
| 1155 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( | 1155 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( |
| 1156 root->PushPropertiesTo(root_impl.get()); | 1156 root->PushPropertiesTo(root_impl.get()); |
| 1157 child->PushPropertiesTo(child_impl.get()); | 1157 child->PushPropertiesTo(child_impl.get()); |
| 1158 child2->PushPropertiesTo(child2_impl.get()); | 1158 child2->PushPropertiesTo(child2_impl.get()); |
| 1159 grand_child->PushPropertiesTo(grand_child_impl.get()); | 1159 grand_child->PushPropertiesTo(grand_child_impl.get()); |
| 1160 layer_tree_host_->property_trees()->ResetAllChangeTracking( | 1160 layer_tree_host_->property_trees()->ResetAllChangeTracking( |
| 1161 PropertyTrees::ResetFlags::ALL_TREES)); | 1161 PropertyTrees::Types::EFFECT_AND_TRANSFORM_TREES)); |
| 1162 | 1162 |
| 1163 gfx::Transform arbitrary_transform; | 1163 gfx::Transform arbitrary_transform; |
| 1164 arbitrary_transform.Scale3d(0.1f, 0.2f, 0.3f); | 1164 arbitrary_transform.Scale3d(0.1f, 0.2f, 0.3f); |
| 1165 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); | 1165 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); |
| 1166 root->SetTransform(arbitrary_transform); | 1166 root->SetTransform(arbitrary_transform); |
| 1167 node = layer_tree_host_->property_trees()->transform_tree.Node( | 1167 node = layer_tree_host_->property_trees()->transform_tree.Node( |
| 1168 root->transform_tree_index()); | 1168 root->transform_tree_index()); |
| 1169 EXPECT_TRUE(node->data.transform_changed); | 1169 EXPECT_TRUE(node->data.transform_changed); |
| 1170 } | 1170 } |
| 1171 | 1171 |
| (...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1724 // The LayerImpl's update_rect() should be accumulated here, since we did not | 1724 // The LayerImpl's update_rect() should be accumulated here, since we did not |
| 1725 // do anything to clear it. | 1725 // do anything to clear it. |
| 1726 test_layer->SetNeedsDisplayRect(gfx::Rect(10, 10, 5, 5)); | 1726 test_layer->SetNeedsDisplayRect(gfx::Rect(10, 10, 5, 5)); |
| 1727 test_layer->PushPropertiesTo(impl_layer_ptr); | 1727 test_layer->PushPropertiesTo(impl_layer_ptr); |
| 1728 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0.f, 0.f, 15.f, 15.f), | 1728 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0.f, 0.f, 15.f, 15.f), |
| 1729 impl_layer_ptr->update_rect()); | 1729 impl_layer_ptr->update_rect()); |
| 1730 | 1730 |
| 1731 // If we do clear the LayerImpl side, then the next update_rect() should be | 1731 // If we do clear the LayerImpl side, then the next update_rect() should be |
| 1732 // fresh without accumulation. | 1732 // fresh without accumulation. |
| 1733 host_impl_.active_tree()->ResetAllChangeTracking( | 1733 host_impl_.active_tree()->ResetAllChangeTracking( |
| 1734 PropertyTrees::ResetFlags::ALL_TREES); | 1734 PropertyTrees::Types::EFFECT_AND_TRANSFORM_TREES); |
| 1735 test_layer->SetNeedsDisplayRect(gfx::Rect(10, 10, 5, 5)); | 1735 test_layer->SetNeedsDisplayRect(gfx::Rect(10, 10, 5, 5)); |
| 1736 test_layer->PushPropertiesTo(impl_layer_ptr); | 1736 test_layer->PushPropertiesTo(impl_layer_ptr); |
| 1737 EXPECT_FLOAT_RECT_EQ(gfx::RectF(10.f, 10.f, 5.f, 5.f), | 1737 EXPECT_FLOAT_RECT_EQ(gfx::RectF(10.f, 10.f, 5.f, 5.f), |
| 1738 impl_layer_ptr->update_rect()); | 1738 impl_layer_ptr->update_rect()); |
| 1739 } | 1739 } |
| 1740 | 1740 |
| 1741 TEST_F(LayerTest, PushPropertiesCausesLayerPropertyChangedForTransform) { | 1741 TEST_F(LayerTest, PushPropertiesCausesLayerPropertyChangedForTransform) { |
| 1742 scoped_refptr<Layer> test_layer = Layer::Create(); | 1742 scoped_refptr<Layer> test_layer = Layer::Create(); |
| 1743 std::unique_ptr<LayerImpl> impl_layer = | 1743 std::unique_ptr<LayerImpl> impl_layer = |
| 1744 LayerImpl::Create(host_impl_.active_tree(), 1); | 1744 LayerImpl::Create(host_impl_.active_tree(), 1); |
| (...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2495 EXPECT_EQ(MutableProperty::kNone, impl_layer->mutable_properties()); | 2495 EXPECT_EQ(MutableProperty::kNone, impl_layer->mutable_properties()); |
| 2496 | 2496 |
| 2497 test_layer->PushPropertiesTo(impl_layer.get()); | 2497 test_layer->PushPropertiesTo(impl_layer.get()); |
| 2498 | 2498 |
| 2499 EXPECT_EQ(2lu, impl_layer->element_id()); | 2499 EXPECT_EQ(2lu, impl_layer->element_id()); |
| 2500 EXPECT_EQ(MutableProperty::kTransform, impl_layer->mutable_properties()); | 2500 EXPECT_EQ(MutableProperty::kTransform, impl_layer->mutable_properties()); |
| 2501 } | 2501 } |
| 2502 | 2502 |
| 2503 } // namespace | 2503 } // namespace |
| 2504 } // namespace cc | 2504 } // namespace cc |
| OLD | NEW |