| 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_impl.h" | 5 #include "cc/layers/layer_impl.h" |
| 6 | 6 |
| 7 #include "cc/animation/mutable_properties.h" | 7 #include "cc/animation/mutable_properties.h" |
| 8 #include "cc/layers/painted_scrollbar_layer_impl.h" | 8 #include "cc/layers/painted_scrollbar_layer_impl.h" |
| 9 #include "cc/layers/solid_color_scrollbar_layer_impl.h" | 9 #include "cc/layers/solid_color_scrollbar_layer_impl.h" |
| 10 #include "cc/output/filter_operation.h" | 10 #include "cc/output/filter_operation.h" |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 host_impl.SetVisible(true); | 128 host_impl.SetVisible(true); |
| 129 EXPECT_TRUE(host_impl.InitializeRenderer(output_surface.get())); | 129 EXPECT_TRUE(host_impl.InitializeRenderer(output_surface.get())); |
| 130 std::unique_ptr<LayerImpl> root_clip_ptr = | 130 std::unique_ptr<LayerImpl> root_clip_ptr = |
| 131 LayerImpl::Create(host_impl.active_tree(), 1); | 131 LayerImpl::Create(host_impl.active_tree(), 1); |
| 132 LayerImpl* root_clip = root_clip_ptr.get(); | 132 LayerImpl* root_clip = root_clip_ptr.get(); |
| 133 std::unique_ptr<LayerImpl> root_ptr = | 133 std::unique_ptr<LayerImpl> root_ptr = |
| 134 LayerImpl::Create(host_impl.active_tree(), 2); | 134 LayerImpl::Create(host_impl.active_tree(), 2); |
| 135 LayerImpl* root = root_ptr.get(); | 135 LayerImpl* root = root_ptr.get(); |
| 136 root_clip_ptr->AddChild(std::move(root_ptr)); | 136 root_clip_ptr->AddChild(std::move(root_ptr)); |
| 137 host_impl.active_tree()->SetRootLayer(std::move(root_clip_ptr)); | 137 host_impl.active_tree()->SetRootLayer(std::move(root_clip_ptr)); |
| 138 std::unique_ptr<LayerImpl> scroll_parent = | 138 |
| 139 LayerImpl::Create(host_impl.active_tree(), 3); | |
| 140 LayerImpl* scroll_child = LayerImpl::Create(host_impl.active_tree(), 4).get(); | |
| 141 std::set<LayerImpl*>* scroll_children = new std::set<LayerImpl*>(); | |
| 142 scroll_children->insert(scroll_child); | |
| 143 scroll_children->insert(root); | |
| 144 root->test_properties()->force_render_surface = true; | 139 root->test_properties()->force_render_surface = true; |
| 145 | |
| 146 std::unique_ptr<LayerImpl> clip_parent = | |
| 147 LayerImpl::Create(host_impl.active_tree(), 5); | |
| 148 LayerImpl* clip_child = LayerImpl::Create(host_impl.active_tree(), 6).get(); | |
| 149 std::set<LayerImpl*>* clip_children = new std::set<LayerImpl*>(); | |
| 150 clip_children->insert(clip_child); | |
| 151 clip_children->insert(root); | |
| 152 root->layer_tree_impl()->ResetAllChangeTracking( | 140 root->layer_tree_impl()->ResetAllChangeTracking( |
| 153 PropertyTrees::ResetFlags::ALL_TREES); | 141 PropertyTrees::ResetFlags::ALL_TREES); |
| 154 | 142 |
| 155 root->AddChild(LayerImpl::Create(host_impl.active_tree(), 7)); | 143 root->AddChild(LayerImpl::Create(host_impl.active_tree(), 7)); |
| 156 LayerImpl* child = root->children()[0]; | 144 LayerImpl* child = root->children()[0]; |
| 157 child->AddChild(LayerImpl::Create(host_impl.active_tree(), 8)); | 145 child->AddChild(LayerImpl::Create(host_impl.active_tree(), 8)); |
| 158 LayerImpl* grand_child = child->children()[0]; | 146 LayerImpl* grand_child = child->children()[0]; |
| 159 root->SetScrollClipLayer(root_clip->id()); | 147 root->SetScrollClipLayer(root_clip->id()); |
| 160 host_impl.active_tree()->BuildPropertyTreesForTesting(); | 148 host_impl.active_tree()->BuildPropertyTreesForTesting(); |
| 161 | 149 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 root->SetMasksToBounds(true); | 210 root->SetMasksToBounds(true); |
| 223 host_impl.active_tree()->property_trees()->needs_rebuild = true; | 211 host_impl.active_tree()->property_trees()->needs_rebuild = true; |
| 224 host_impl.active_tree()->BuildPropertyTreesForTesting(); | 212 host_impl.active_tree()->BuildPropertyTreesForTesting(); |
| 225 | 213 |
| 226 // Changing these properties does not cause the layer to be marked as changed | 214 // Changing these properties does not cause the layer to be marked as changed |
| 227 // but does cause the layer to need to push properties. | 215 // but does cause the layer to need to push properties. |
| 228 EXECUTE_AND_VERIFY_NEEDS_PUSH_PROPERTIES_AND_SUBTREE_DID_NOT_CHANGE( | 216 EXECUTE_AND_VERIFY_NEEDS_PUSH_PROPERTIES_AND_SUBTREE_DID_NOT_CHANGE( |
| 229 root->SetElementId(2)); | 217 root->SetElementId(2)); |
| 230 EXECUTE_AND_VERIFY_NEEDS_PUSH_PROPERTIES_AND_SUBTREE_DID_NOT_CHANGE( | 218 EXECUTE_AND_VERIFY_NEEDS_PUSH_PROPERTIES_AND_SUBTREE_DID_NOT_CHANGE( |
| 231 root->SetMutableProperties(MutableProperty::kOpacity)); | 219 root->SetMutableProperties(MutableProperty::kOpacity)); |
| 232 EXECUTE_AND_VERIFY_NEEDS_PUSH_PROPERTIES_AND_SUBTREE_DID_NOT_CHANGE( | |
| 233 root->SetScrollParent(scroll_parent.get())); | |
| 234 EXECUTE_AND_VERIFY_NEEDS_PUSH_PROPERTIES_AND_SUBTREE_DID_NOT_CHANGE( | |
| 235 root->SetScrollChildren(scroll_children)); | |
| 236 EXECUTE_AND_VERIFY_NEEDS_PUSH_PROPERTIES_AND_SUBTREE_DID_NOT_CHANGE( | |
| 237 root->SetClipParent(clip_parent.get())); | |
| 238 EXECUTE_AND_VERIFY_NEEDS_PUSH_PROPERTIES_AND_SUBTREE_DID_NOT_CHANGE( | |
| 239 root->SetClipChildren(clip_children)); | |
| 240 | 220 |
| 241 // After setting all these properties already, setting to the exact same | 221 // After setting all these properties already, setting to the exact same |
| 242 // values again should not cause any change. | 222 // values again should not cause any change. |
| 243 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->SetMasksToBounds(true)); | 223 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->SetMasksToBounds(true)); |
| 244 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE( | 224 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE( |
| 245 root->SetPosition(arbitrary_point_f)); | 225 root->SetPosition(arbitrary_point_f)); |
| 246 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->Set3dSortingContextId(1)); | 226 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->Set3dSortingContextId(1)); |
| 247 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE( | 227 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE( |
| 248 root->SetTransform(arbitrary_transform)); | 228 root->SetTransform(arbitrary_transform)); |
| 249 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->SetContentsOpaque(true)); | 229 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->SetContentsOpaque(true)); |
| 250 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->SetOpacity(arbitrary_number)); | 230 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->SetOpacity(arbitrary_number)); |
| 251 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE( | 231 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE( |
| 252 root->SetBlendMode(arbitrary_blend_mode)); | 232 root->SetBlendMode(arbitrary_blend_mode)); |
| 253 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->SetDrawsContent(true)); | 233 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->SetDrawsContent(true)); |
| 254 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->SetBounds(bounds_size)); | 234 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->SetBounds(bounds_size)); |
| 255 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE( | |
| 256 root->SetScrollParent(scroll_parent.get())); | |
| 257 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE( | |
| 258 root->SetScrollChildren(scroll_children)); | |
| 259 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE( | |
| 260 root->SetClipParent(clip_parent.get())); | |
| 261 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE( | |
| 262 root->SetClipChildren(clip_children)); | |
| 263 } | 235 } |
| 264 | 236 |
| 265 TEST(LayerImplTest, VerifyNeedsUpdateDrawProperties) { | 237 TEST(LayerImplTest, VerifyNeedsUpdateDrawProperties) { |
| 266 FakeImplTaskRunnerProvider task_runner_provider; | 238 FakeImplTaskRunnerProvider task_runner_provider; |
| 267 TestSharedBitmapManager shared_bitmap_manager; | 239 TestSharedBitmapManager shared_bitmap_manager; |
| 268 TestTaskGraphRunner task_graph_runner; | 240 TestTaskGraphRunner task_graph_runner; |
| 269 std::unique_ptr<OutputSurface> output_surface = FakeOutputSurface::Create3d(); | 241 std::unique_ptr<OutputSurface> output_surface = FakeOutputSurface::Create3d(); |
| 270 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, | 242 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, |
| 271 &task_graph_runner); | 243 &task_graph_runner); |
| 272 host_impl.SetVisible(true); | 244 host_impl.SetVisible(true); |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 606 | 578 |
| 607 pending_layer->PushPropertiesTo(layer()); | 579 pending_layer->PushPropertiesTo(layer()); |
| 608 | 580 |
| 609 EXPECT_VECTOR_EQ(gfx::Vector2dF(22, 23), layer()->CurrentScrollOffset()); | 581 EXPECT_VECTOR_EQ(gfx::Vector2dF(22, 23), layer()->CurrentScrollOffset()); |
| 610 EXPECT_VECTOR_EQ(layer()->CurrentScrollOffset(), | 582 EXPECT_VECTOR_EQ(layer()->CurrentScrollOffset(), |
| 611 pending_layer->CurrentScrollOffset()); | 583 pending_layer->CurrentScrollOffset()); |
| 612 } | 584 } |
| 613 | 585 |
| 614 } // namespace | 586 } // namespace |
| 615 } // namespace cc | 587 } // namespace cc |
| OLD | NEW |