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 12 matching lines...) Expand all Loading... |
23 #include "cc/test/fake_layer_tree_host.h" | 23 #include "cc/test/fake_layer_tree_host.h" |
24 #include "cc/test/fake_layer_tree_host_client.h" | 24 #include "cc/test/fake_layer_tree_host_client.h" |
25 #include "cc/test/fake_layer_tree_host_impl.h" | 25 #include "cc/test/fake_layer_tree_host_impl.h" |
26 #include "cc/test/geometry_test_utils.h" | 26 #include "cc/test/geometry_test_utils.h" |
27 #include "cc/test/layer_test_common.h" | 27 #include "cc/test/layer_test_common.h" |
28 #include "cc/test/test_gpu_memory_buffer_manager.h" | 28 #include "cc/test/test_gpu_memory_buffer_manager.h" |
29 #include "cc/test/test_shared_bitmap_manager.h" | 29 #include "cc/test/test_shared_bitmap_manager.h" |
30 #include "cc/test/test_task_graph_runner.h" | 30 #include "cc/test/test_task_graph_runner.h" |
31 #include "cc/trees/layer_tree_host.h" | 31 #include "cc/trees/layer_tree_host.h" |
32 #include "cc/trees/single_thread_proxy.h" | 32 #include "cc/trees/single_thread_proxy.h" |
| 33 #include "cc/trees/transform_node.h" |
33 #include "testing/gmock/include/gmock/gmock.h" | 34 #include "testing/gmock/include/gmock/gmock.h" |
34 #include "testing/gtest/include/gtest/gtest.h" | 35 #include "testing/gtest/include/gtest/gtest.h" |
35 #include "third_party/skia/include/core/SkColor.h" | 36 #include "third_party/skia/include/core/SkColor.h" |
36 #include "ui/gfx/geometry/point3_f.h" | 37 #include "ui/gfx/geometry/point3_f.h" |
37 #include "ui/gfx/geometry/point_f.h" | 38 #include "ui/gfx/geometry/point_f.h" |
38 #include "ui/gfx/geometry/scroll_offset.h" | 39 #include "ui/gfx/geometry/scroll_offset.h" |
39 #include "ui/gfx/geometry/size.h" | 40 #include "ui/gfx/geometry/size.h" |
40 #include "ui/gfx/geometry/vector2d_f.h" | 41 #include "ui/gfx/geometry/vector2d_f.h" |
41 #include "ui/gfx/transform.h" | 42 #include "ui/gfx/transform.h" |
42 | 43 |
(...skipping 1088 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1131 EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED( | 1132 EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED( |
1132 root->SetBackgroundFilters(arbitrary_filters)); | 1133 root->SetBackgroundFilters(arbitrary_filters)); |
1133 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( | 1134 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( |
1134 root->PushPropertiesTo(root_impl.get())); | 1135 root->PushPropertiesTo(root_impl.get())); |
1135 | 1136 |
1136 gfx::PointF arbitrary_point_f = gfx::PointF(0.125f, 0.25f); | 1137 gfx::PointF arbitrary_point_f = gfx::PointF(0.125f, 0.25f); |
1137 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); | 1138 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); |
1138 root->SetPosition(arbitrary_point_f); | 1139 root->SetPosition(arbitrary_point_f); |
1139 TransformNode* node = layer_tree_host_->property_trees()->transform_tree.Node( | 1140 TransformNode* node = layer_tree_host_->property_trees()->transform_tree.Node( |
1140 root->transform_tree_index()); | 1141 root->transform_tree_index()); |
1141 EXPECT_TRUE(node->data.transform_changed); | 1142 EXPECT_TRUE(node->transform_changed); |
1142 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( | 1143 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( |
1143 root->PushPropertiesTo(root_impl.get()); | 1144 root->PushPropertiesTo(root_impl.get()); |
1144 child->PushPropertiesTo(child_impl.get()); | 1145 child->PushPropertiesTo(child_impl.get()); |
1145 child2->PushPropertiesTo(child2_impl.get()); | 1146 child2->PushPropertiesTo(child2_impl.get()); |
1146 grand_child->PushPropertiesTo(grand_child_impl.get()); | 1147 grand_child->PushPropertiesTo(grand_child_impl.get()); |
1147 layer_tree_host_->property_trees()->ResetAllChangeTracking()); | 1148 layer_tree_host_->property_trees()->ResetAllChangeTracking()); |
1148 EXPECT_FALSE(node->data.transform_changed); | 1149 EXPECT_FALSE(node->transform_changed); |
1149 | 1150 |
1150 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); | 1151 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); |
1151 child->SetPosition(arbitrary_point_f); | 1152 child->SetPosition(arbitrary_point_f); |
1152 node = layer_tree_host_->property_trees()->transform_tree.Node( | 1153 node = layer_tree_host_->property_trees()->transform_tree.Node( |
1153 child->transform_tree_index()); | 1154 child->transform_tree_index()); |
1154 EXPECT_TRUE(node->data.transform_changed); | 1155 EXPECT_TRUE(node->transform_changed); |
1155 // child2 is not in the subtree of child, but its scroll parent is. So, its | 1156 // child2 is not in the subtree of child, but its scroll parent is. So, its |
1156 // to_screen will be effected by change in position of child2. | 1157 // to_screen will be effected by change in position of child2. |
1157 layer_tree_host_->property_trees()->transform_tree.UpdateTransforms( | 1158 layer_tree_host_->property_trees()->transform_tree.UpdateTransforms( |
1158 child2->transform_tree_index()); | 1159 child2->transform_tree_index()); |
1159 node = layer_tree_host_->property_trees()->transform_tree.Node( | 1160 node = layer_tree_host_->property_trees()->transform_tree.Node( |
1160 child2->transform_tree_index()); | 1161 child2->transform_tree_index()); |
1161 EXPECT_TRUE(node->data.transform_changed); | 1162 EXPECT_TRUE(node->transform_changed); |
1162 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( | 1163 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( |
1163 child->PushPropertiesTo(child_impl.get()); | 1164 child->PushPropertiesTo(child_impl.get()); |
1164 grand_child->PushPropertiesTo(grand_child_impl.get()); | 1165 grand_child->PushPropertiesTo(grand_child_impl.get()); |
1165 layer_tree_host_->property_trees()->ResetAllChangeTracking()); | 1166 layer_tree_host_->property_trees()->ResetAllChangeTracking()); |
1166 node = layer_tree_host_->property_trees()->transform_tree.Node( | 1167 node = layer_tree_host_->property_trees()->transform_tree.Node( |
1167 child->transform_tree_index()); | 1168 child->transform_tree_index()); |
1168 EXPECT_FALSE(node->data.transform_changed); | 1169 EXPECT_FALSE(node->transform_changed); |
1169 | 1170 |
1170 gfx::Point3F arbitrary_point_3f = gfx::Point3F(0.125f, 0.25f, 0.f); | 1171 gfx::Point3F arbitrary_point_3f = gfx::Point3F(0.125f, 0.25f, 0.f); |
1171 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); | 1172 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); |
1172 root->SetTransformOrigin(arbitrary_point_3f); | 1173 root->SetTransformOrigin(arbitrary_point_3f); |
1173 node = layer_tree_host_->property_trees()->transform_tree.Node( | 1174 node = layer_tree_host_->property_trees()->transform_tree.Node( |
1174 root->transform_tree_index()); | 1175 root->transform_tree_index()); |
1175 EXPECT_TRUE(node->data.transform_changed); | 1176 EXPECT_TRUE(node->transform_changed); |
1176 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( | 1177 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( |
1177 root->PushPropertiesTo(root_impl.get()); | 1178 root->PushPropertiesTo(root_impl.get()); |
1178 child->PushPropertiesTo(child_impl.get()); | 1179 child->PushPropertiesTo(child_impl.get()); |
1179 child2->PushPropertiesTo(child2_impl.get()); | 1180 child2->PushPropertiesTo(child2_impl.get()); |
1180 grand_child->PushPropertiesTo(grand_child_impl.get()); | 1181 grand_child->PushPropertiesTo(grand_child_impl.get()); |
1181 layer_tree_host_->property_trees()->ResetAllChangeTracking()); | 1182 layer_tree_host_->property_trees()->ResetAllChangeTracking()); |
1182 | 1183 |
1183 gfx::Transform arbitrary_transform; | 1184 gfx::Transform arbitrary_transform; |
1184 arbitrary_transform.Scale3d(0.1f, 0.2f, 0.3f); | 1185 arbitrary_transform.Scale3d(0.1f, 0.2f, 0.3f); |
1185 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); | 1186 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); |
1186 root->SetTransform(arbitrary_transform); | 1187 root->SetTransform(arbitrary_transform); |
1187 node = layer_tree_host_->property_trees()->transform_tree.Node( | 1188 node = layer_tree_host_->property_trees()->transform_tree.Node( |
1188 root->transform_tree_index()); | 1189 root->transform_tree_index()); |
1189 EXPECT_TRUE(node->data.transform_changed); | 1190 EXPECT_TRUE(node->transform_changed); |
1190 } | 1191 } |
1191 | 1192 |
1192 TEST_F(LayerTest, AddAndRemoveChild) { | 1193 TEST_F(LayerTest, AddAndRemoveChild) { |
1193 scoped_refptr<Layer> parent = Layer::Create(); | 1194 scoped_refptr<Layer> parent = Layer::Create(); |
1194 scoped_refptr<Layer> child = Layer::Create(); | 1195 scoped_refptr<Layer> child = Layer::Create(); |
1195 | 1196 |
1196 // Upon creation, layers should not have children or parent. | 1197 // Upon creation, layers should not have children or parent. |
1197 ASSERT_EQ(0U, parent->children().size()); | 1198 ASSERT_EQ(0U, parent->children().size()); |
1198 EXPECT_FALSE(child->parent()); | 1199 EXPECT_FALSE(child->parent()); |
1199 | 1200 |
(...skipping 1316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2516 EXPECT_EQ(MutableProperty::kNone, impl_layer->mutable_properties()); | 2517 EXPECT_EQ(MutableProperty::kNone, impl_layer->mutable_properties()); |
2517 | 2518 |
2518 test_layer->PushPropertiesTo(impl_layer.get()); | 2519 test_layer->PushPropertiesTo(impl_layer.get()); |
2519 | 2520 |
2520 EXPECT_EQ(ElementId(2, 0), impl_layer->element_id()); | 2521 EXPECT_EQ(ElementId(2, 0), impl_layer->element_id()); |
2521 EXPECT_EQ(MutableProperty::kTransform, impl_layer->mutable_properties()); | 2522 EXPECT_EQ(MutableProperty::kTransform, impl_layer->mutable_properties()); |
2522 } | 2523 } |
2523 | 2524 |
2524 } // namespace | 2525 } // namespace |
2525 } // namespace cc | 2526 } // namespace cc |
OLD | NEW |