| 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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, | 120 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, |
| 121 &task_graph_runner); | 121 &task_graph_runner); |
| 122 host_impl.SetVisible(true); | 122 host_impl.SetVisible(true); |
| 123 EXPECT_TRUE(host_impl.InitializeRenderer(output_surface.get())); | 123 EXPECT_TRUE(host_impl.InitializeRenderer(output_surface.get())); |
| 124 std::unique_ptr<LayerImpl> root_clip_ptr = | 124 std::unique_ptr<LayerImpl> root_clip_ptr = |
| 125 LayerImpl::Create(host_impl.active_tree(), 1); | 125 LayerImpl::Create(host_impl.active_tree(), 1); |
| 126 LayerImpl* root_clip = root_clip_ptr.get(); | 126 LayerImpl* root_clip = root_clip_ptr.get(); |
| 127 std::unique_ptr<LayerImpl> root_ptr = | 127 std::unique_ptr<LayerImpl> root_ptr = |
| 128 LayerImpl::Create(host_impl.active_tree(), 2); | 128 LayerImpl::Create(host_impl.active_tree(), 2); |
| 129 LayerImpl* root = root_ptr.get(); | 129 LayerImpl* root = root_ptr.get(); |
| 130 root_clip_ptr->AddChild(std::move(root_ptr)); | 130 root_clip_ptr->test_properties()->AddChild(std::move(root_ptr)); |
| 131 host_impl.active_tree()->SetRootLayer(std::move(root_clip_ptr)); | 131 host_impl.active_tree()->SetRootLayer(std::move(root_clip_ptr)); |
| 132 | 132 |
| 133 root->test_properties()->force_render_surface = true; | 133 root->test_properties()->force_render_surface = true; |
| 134 root->layer_tree_impl()->ResetAllChangeTracking(); | 134 root->layer_tree_impl()->ResetAllChangeTracking(); |
| 135 | 135 |
| 136 root->AddChild(LayerImpl::Create(host_impl.active_tree(), 7)); | 136 root->test_properties()->AddChild( |
| 137 LayerImpl::Create(host_impl.active_tree(), 7)); |
| 137 LayerImpl* child = root->test_properties()->children[0]; | 138 LayerImpl* child = root->test_properties()->children[0]; |
| 138 child->AddChild(LayerImpl::Create(host_impl.active_tree(), 8)); | 139 child->test_properties()->AddChild( |
| 140 LayerImpl::Create(host_impl.active_tree(), 8)); |
| 139 LayerImpl* grand_child = child->test_properties()->children[0]; | 141 LayerImpl* grand_child = child->test_properties()->children[0]; |
| 140 root->SetScrollClipLayer(root_clip->id()); | 142 root->SetScrollClipLayer(root_clip->id()); |
| 141 host_impl.active_tree()->BuildLayerListAndPropertyTreesForTesting(); | 143 host_impl.active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
| 142 | 144 |
| 143 // Adding children is an internal operation and should not mark layers as | 145 // Adding children is an internal operation and should not mark layers as |
| 144 // changed. | 146 // changed. |
| 145 EXPECT_FALSE(root->LayerPropertyChanged()); | 147 EXPECT_FALSE(root->LayerPropertyChanged()); |
| 146 EXPECT_FALSE(child->LayerPropertyChanged()); | 148 EXPECT_FALSE(child->LayerPropertyChanged()); |
| 147 EXPECT_FALSE(grand_child->LayerPropertyChanged()); | 149 EXPECT_FALSE(grand_child->LayerPropertyChanged()); |
| 148 | 150 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 &task_graph_runner); | 234 &task_graph_runner); |
| 233 host_impl.SetVisible(true); | 235 host_impl.SetVisible(true); |
| 234 EXPECT_TRUE(host_impl.InitializeRenderer(output_surface.get())); | 236 EXPECT_TRUE(host_impl.InitializeRenderer(output_surface.get())); |
| 235 host_impl.active_tree()->SetRootLayer( | 237 host_impl.active_tree()->SetRootLayer( |
| 236 LayerImpl::Create(host_impl.active_tree(), 1)); | 238 LayerImpl::Create(host_impl.active_tree(), 1)); |
| 237 LayerImpl* root = host_impl.active_tree()->root_layer(); | 239 LayerImpl* root = host_impl.active_tree()->root_layer(); |
| 238 root->SetHasRenderSurface(true); | 240 root->SetHasRenderSurface(true); |
| 239 std::unique_ptr<LayerImpl> layer_ptr = | 241 std::unique_ptr<LayerImpl> layer_ptr = |
| 240 LayerImpl::Create(host_impl.active_tree(), 2); | 242 LayerImpl::Create(host_impl.active_tree(), 2); |
| 241 LayerImpl* layer = layer_ptr.get(); | 243 LayerImpl* layer = layer_ptr.get(); |
| 242 root->AddChild(std::move(layer_ptr)); | 244 root->test_properties()->AddChild(std::move(layer_ptr)); |
| 243 layer->SetScrollClipLayer(root->id()); | 245 layer->SetScrollClipLayer(root->id()); |
| 244 std::unique_ptr<LayerImpl> layer2_ptr = | 246 std::unique_ptr<LayerImpl> layer2_ptr = |
| 245 LayerImpl::Create(host_impl.active_tree(), 3); | 247 LayerImpl::Create(host_impl.active_tree(), 3); |
| 246 LayerImpl* layer2 = layer2_ptr.get(); | 248 LayerImpl* layer2 = layer2_ptr.get(); |
| 247 root->AddChild(std::move(layer2_ptr)); | 249 root->test_properties()->AddChild(std::move(layer2_ptr)); |
| 248 host_impl.active_tree()->BuildLayerListAndPropertyTreesForTesting(); | 250 host_impl.active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
| 249 DCHECK(host_impl.CanDraw()); | 251 DCHECK(host_impl.CanDraw()); |
| 250 | 252 |
| 251 gfx::PointF arbitrary_point_f = gfx::PointF(0.125f, 0.25f); | 253 gfx::PointF arbitrary_point_f = gfx::PointF(0.125f, 0.25f); |
| 252 float arbitrary_number = 0.352f; | 254 float arbitrary_number = 0.352f; |
| 253 gfx::Size arbitrary_size = gfx::Size(111, 222); | 255 gfx::Size arbitrary_size = gfx::Size(111, 222); |
| 254 gfx::Vector2d arbitrary_vector2d = gfx::Vector2d(111, 222); | 256 gfx::Vector2d arbitrary_vector2d = gfx::Vector2d(111, 222); |
| 255 gfx::Size large_size = gfx::Size(1000, 1000); | 257 gfx::Size large_size = gfx::Size(1000, 1000); |
| 256 SkColor arbitrary_color = SkColorSetRGB(10, 20, 30); | 258 SkColor arbitrary_color = SkColorSetRGB(10, 20, 30); |
| 257 gfx::Transform arbitrary_transform; | 259 gfx::Transform arbitrary_transform; |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 class LayerImplScrollTest : public testing::Test { | 388 class LayerImplScrollTest : public testing::Test { |
| 387 public: | 389 public: |
| 388 LayerImplScrollTest() | 390 LayerImplScrollTest() |
| 389 : host_impl_(settings(), | 391 : host_impl_(settings(), |
| 390 &task_runner_provider_, | 392 &task_runner_provider_, |
| 391 &shared_bitmap_manager_, | 393 &shared_bitmap_manager_, |
| 392 &task_graph_runner_), | 394 &task_graph_runner_), |
| 393 root_id_(7) { | 395 root_id_(7) { |
| 394 host_impl_.active_tree()->SetRootLayer( | 396 host_impl_.active_tree()->SetRootLayer( |
| 395 LayerImpl::Create(host_impl_.active_tree(), root_id_)); | 397 LayerImpl::Create(host_impl_.active_tree(), root_id_)); |
| 396 host_impl_.active_tree()->root_layer()->AddChild( | 398 host_impl_.active_tree()->root_layer()->test_properties()->AddChild( |
| 397 LayerImpl::Create(host_impl_.active_tree(), root_id_ + 1)); | 399 LayerImpl::Create(host_impl_.active_tree(), root_id_ + 1)); |
| 398 layer()->SetScrollClipLayer(root_id_); | 400 layer()->SetScrollClipLayer(root_id_); |
| 399 // Set the max scroll offset by noting that the root layer has bounds (1,1), | 401 // Set the max scroll offset by noting that the root layer has bounds (1,1), |
| 400 // thus whatever bounds are set for the layer will be the max scroll | 402 // thus whatever bounds are set for the layer will be the max scroll |
| 401 // offset plus 1 in each direction. | 403 // offset plus 1 in each direction. |
| 402 host_impl_.active_tree()->root_layer()->SetBounds(gfx::Size(1, 1)); | 404 host_impl_.active_tree()->root_layer()->SetBounds(gfx::Size(1, 1)); |
| 403 gfx::Vector2d max_scroll_offset(51, 81); | 405 gfx::Vector2d max_scroll_offset(51, 81); |
| 404 layer()->SetBounds(gfx::Size(max_scroll_offset.x(), max_scroll_offset.y())); | 406 layer()->SetBounds(gfx::Size(max_scroll_offset.x(), max_scroll_offset.y())); |
| 405 host_impl_.active_tree()->BuildLayerListAndPropertyTreesForTesting(); | 407 host_impl_.active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
| 406 } | 408 } |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 560 | 562 |
| 561 pending_layer->PushPropertiesTo(layer()); | 563 pending_layer->PushPropertiesTo(layer()); |
| 562 | 564 |
| 563 EXPECT_VECTOR_EQ(gfx::Vector2dF(22, 23), layer()->CurrentScrollOffset()); | 565 EXPECT_VECTOR_EQ(gfx::Vector2dF(22, 23), layer()->CurrentScrollOffset()); |
| 564 EXPECT_VECTOR_EQ(layer()->CurrentScrollOffset(), | 566 EXPECT_VECTOR_EQ(layer()->CurrentScrollOffset(), |
| 565 pending_layer->CurrentScrollOffset()); | 567 pending_layer->CurrentScrollOffset()); |
| 566 } | 568 } |
| 567 | 569 |
| 568 } // namespace | 570 } // namespace |
| 569 } // namespace cc | 571 } // namespace cc |
| OLD | NEW |