| 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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 TEST(LayerImplTest, VerifyLayerChangesAreTrackedProperly) { | 115 TEST(LayerImplTest, VerifyLayerChangesAreTrackedProperly) { |
| 116 // | 116 // |
| 117 // This test checks that layerPropertyChanged() has the correct behavior. | 117 // This test checks that layerPropertyChanged() has the correct behavior. |
| 118 // | 118 // |
| 119 | 119 |
| 120 // The constructor on this will fake that we are on the correct thread. | 120 // The constructor on this will fake that we are on the correct thread. |
| 121 // Create a simple LayerImpl tree: | 121 // Create a simple LayerImpl tree: |
| 122 FakeImplTaskRunnerProvider task_runner_provider; | 122 FakeImplTaskRunnerProvider task_runner_provider; |
| 123 TestSharedBitmapManager shared_bitmap_manager; | 123 TestSharedBitmapManager shared_bitmap_manager; |
| 124 TestTaskGraphRunner task_graph_runner; | 124 TestTaskGraphRunner task_graph_runner; |
| 125 scoped_ptr<OutputSurface> output_surface = FakeOutputSurface::Create3d(); | 125 std::unique_ptr<OutputSurface> output_surface = FakeOutputSurface::Create3d(); |
| 126 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, | 126 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, |
| 127 &task_graph_runner); | 127 &task_graph_runner); |
| 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 scoped_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 scoped_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 scoped_ptr<LayerImpl> scroll_parent = | 138 std::unique_ptr<LayerImpl> scroll_parent = |
| 139 LayerImpl::Create(host_impl.active_tree(), 3); | 139 LayerImpl::Create(host_impl.active_tree(), 3); |
| 140 LayerImpl* scroll_child = LayerImpl::Create(host_impl.active_tree(), 4).get(); | 140 LayerImpl* scroll_child = LayerImpl::Create(host_impl.active_tree(), 4).get(); |
| 141 std::set<LayerImpl*>* scroll_children = new std::set<LayerImpl*>(); | 141 std::set<LayerImpl*>* scroll_children = new std::set<LayerImpl*>(); |
| 142 scroll_children->insert(scroll_child); | 142 scroll_children->insert(scroll_child); |
| 143 scroll_children->insert(root); | 143 scroll_children->insert(root); |
| 144 root->SetForceRenderSurface(true); | 144 root->SetForceRenderSurface(true); |
| 145 | 145 |
| 146 scoped_ptr<LayerImpl> clip_parent = | 146 std::unique_ptr<LayerImpl> clip_parent = |
| 147 LayerImpl::Create(host_impl.active_tree(), 5); | 147 LayerImpl::Create(host_impl.active_tree(), 5); |
| 148 LayerImpl* clip_child = LayerImpl::Create(host_impl.active_tree(), 6).get(); | 148 LayerImpl* clip_child = LayerImpl::Create(host_impl.active_tree(), 6).get(); |
| 149 std::set<LayerImpl*>* clip_children = new std::set<LayerImpl*>(); | 149 std::set<LayerImpl*>* clip_children = new std::set<LayerImpl*>(); |
| 150 clip_children->insert(clip_child); | 150 clip_children->insert(clip_child); |
| 151 clip_children->insert(root); | 151 clip_children->insert(root); |
| 152 root->layer_tree_impl()->ResetAllChangeTracking( | 152 root->layer_tree_impl()->ResetAllChangeTracking( |
| 153 PropertyTrees::ResetFlags::ALL_TREES); | 153 PropertyTrees::ResetFlags::ALL_TREES); |
| 154 | 154 |
| 155 root->AddChild(LayerImpl::Create(host_impl.active_tree(), 7)); | 155 root->AddChild(LayerImpl::Create(host_impl.active_tree(), 7)); |
| 156 LayerImpl* child = root->children()[0]; | 156 LayerImpl* child = root->children()[0]; |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE( | 271 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE( |
| 272 root->SetClipParent(clip_parent.get())); | 272 root->SetClipParent(clip_parent.get())); |
| 273 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE( | 273 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE( |
| 274 root->SetClipChildren(clip_children)); | 274 root->SetClipChildren(clip_children)); |
| 275 } | 275 } |
| 276 | 276 |
| 277 TEST(LayerImplTest, VerifyNeedsUpdateDrawProperties) { | 277 TEST(LayerImplTest, VerifyNeedsUpdateDrawProperties) { |
| 278 FakeImplTaskRunnerProvider task_runner_provider; | 278 FakeImplTaskRunnerProvider task_runner_provider; |
| 279 TestSharedBitmapManager shared_bitmap_manager; | 279 TestSharedBitmapManager shared_bitmap_manager; |
| 280 TestTaskGraphRunner task_graph_runner; | 280 TestTaskGraphRunner task_graph_runner; |
| 281 scoped_ptr<OutputSurface> output_surface = FakeOutputSurface::Create3d(); | 281 std::unique_ptr<OutputSurface> output_surface = FakeOutputSurface::Create3d(); |
| 282 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, | 282 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, |
| 283 &task_graph_runner); | 283 &task_graph_runner); |
| 284 host_impl.SetVisible(true); | 284 host_impl.SetVisible(true); |
| 285 EXPECT_TRUE(host_impl.InitializeRenderer(output_surface.get())); | 285 EXPECT_TRUE(host_impl.InitializeRenderer(output_surface.get())); |
| 286 host_impl.active_tree()->SetRootLayer( | 286 host_impl.active_tree()->SetRootLayer( |
| 287 LayerImpl::Create(host_impl.active_tree(), 1)); | 287 LayerImpl::Create(host_impl.active_tree(), 1)); |
| 288 LayerImpl* root = host_impl.active_tree()->root_layer(); | 288 LayerImpl* root = host_impl.active_tree()->root_layer(); |
| 289 root->SetHasRenderSurface(true); | 289 root->SetHasRenderSurface(true); |
| 290 scoped_ptr<LayerImpl> layer_ptr = | 290 std::unique_ptr<LayerImpl> layer_ptr = |
| 291 LayerImpl::Create(host_impl.active_tree(), 2); | 291 LayerImpl::Create(host_impl.active_tree(), 2); |
| 292 LayerImpl* layer = layer_ptr.get(); | 292 LayerImpl* layer = layer_ptr.get(); |
| 293 root->AddChild(std::move(layer_ptr)); | 293 root->AddChild(std::move(layer_ptr)); |
| 294 layer->SetScrollClipLayer(root->id()); | 294 layer->SetScrollClipLayer(root->id()); |
| 295 scoped_ptr<LayerImpl> layer2_ptr = | 295 std::unique_ptr<LayerImpl> layer2_ptr = |
| 296 LayerImpl::Create(host_impl.active_tree(), 3); | 296 LayerImpl::Create(host_impl.active_tree(), 3); |
| 297 LayerImpl* layer2 = layer2_ptr.get(); | 297 LayerImpl* layer2 = layer2_ptr.get(); |
| 298 root->AddChild(std::move(layer2_ptr)); | 298 root->AddChild(std::move(layer2_ptr)); |
| 299 host_impl.active_tree()->BuildPropertyTreesForTesting(); | 299 host_impl.active_tree()->BuildPropertyTreesForTesting(); |
| 300 DCHECK(host_impl.CanDraw()); | 300 DCHECK(host_impl.CanDraw()); |
| 301 | 301 |
| 302 gfx::PointF arbitrary_point_f = gfx::PointF(0.125f, 0.25f); | 302 gfx::PointF arbitrary_point_f = gfx::PointF(0.125f, 0.25f); |
| 303 float arbitrary_number = 0.352f; | 303 float arbitrary_number = 0.352f; |
| 304 gfx::Size arbitrary_size = gfx::Size(111, 222); | 304 gfx::Size arbitrary_size = gfx::Size(111, 222); |
| 305 gfx::Point arbitrary_point = gfx::Point(333, 444); | 305 gfx::Point arbitrary_point = gfx::Point(333, 444); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetBounds(arbitrary_size)); | 419 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetBounds(arbitrary_size)); |
| 420 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetElementId(2)); | 420 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetElementId(2)); |
| 421 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES( | 421 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES( |
| 422 layer->SetMutableProperties(MutableProperty::kTransform)); | 422 layer->SetMutableProperties(MutableProperty::kTransform)); |
| 423 } | 423 } |
| 424 | 424 |
| 425 TEST(LayerImplTest, SafeOpaqueBackgroundColor) { | 425 TEST(LayerImplTest, SafeOpaqueBackgroundColor) { |
| 426 FakeImplTaskRunnerProvider task_runner_provider; | 426 FakeImplTaskRunnerProvider task_runner_provider; |
| 427 TestSharedBitmapManager shared_bitmap_manager; | 427 TestSharedBitmapManager shared_bitmap_manager; |
| 428 TestTaskGraphRunner task_graph_runner; | 428 TestTaskGraphRunner task_graph_runner; |
| 429 scoped_ptr<OutputSurface> output_surface = FakeOutputSurface::Create3d(); | 429 std::unique_ptr<OutputSurface> output_surface = FakeOutputSurface::Create3d(); |
| 430 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, | 430 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, |
| 431 &task_graph_runner); | 431 &task_graph_runner); |
| 432 host_impl.SetVisible(true); | 432 host_impl.SetVisible(true); |
| 433 EXPECT_TRUE(host_impl.InitializeRenderer(output_surface.get())); | 433 EXPECT_TRUE(host_impl.InitializeRenderer(output_surface.get())); |
| 434 host_impl.active_tree()->SetRootLayer( | 434 host_impl.active_tree()->SetRootLayer( |
| 435 LayerImpl::Create(host_impl.active_tree(), 1)); | 435 LayerImpl::Create(host_impl.active_tree(), 1)); |
| 436 LayerImpl* layer = host_impl.active_tree()->root_layer(); | 436 LayerImpl* layer = host_impl.active_tree()->root_layer(); |
| 437 | 437 |
| 438 for (int contents_opaque = 0; contents_opaque < 2; ++contents_opaque) { | 438 for (int contents_opaque = 0; contents_opaque < 2; ++contents_opaque) { |
| 439 for (int layer_opaque = 0; layer_opaque < 2; ++layer_opaque) { | 439 for (int layer_opaque = 0; layer_opaque < 2; ++layer_opaque) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 461 } | 461 } |
| 462 } | 462 } |
| 463 | 463 |
| 464 TEST(LayerImplTest, TransformInvertibility) { | 464 TEST(LayerImplTest, TransformInvertibility) { |
| 465 FakeImplTaskRunnerProvider task_runner_provider; | 465 FakeImplTaskRunnerProvider task_runner_provider; |
| 466 TestSharedBitmapManager shared_bitmap_manager; | 466 TestSharedBitmapManager shared_bitmap_manager; |
| 467 TestTaskGraphRunner task_graph_runner; | 467 TestTaskGraphRunner task_graph_runner; |
| 468 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, | 468 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, |
| 469 &task_graph_runner); | 469 &task_graph_runner); |
| 470 | 470 |
| 471 scoped_ptr<LayerImpl> layer = LayerImpl::Create(host_impl.active_tree(), 1); | 471 std::unique_ptr<LayerImpl> layer = |
| 472 LayerImpl::Create(host_impl.active_tree(), 1); |
| 472 EXPECT_TRUE(layer->transform().IsInvertible()); | 473 EXPECT_TRUE(layer->transform().IsInvertible()); |
| 473 EXPECT_TRUE(layer->transform_is_invertible()); | 474 EXPECT_TRUE(layer->transform_is_invertible()); |
| 474 | 475 |
| 475 gfx::Transform transform; | 476 gfx::Transform transform; |
| 476 transform.Scale3d( | 477 transform.Scale3d( |
| 477 SkDoubleToMScalar(1.0), SkDoubleToMScalar(1.0), SkDoubleToMScalar(0.0)); | 478 SkDoubleToMScalar(1.0), SkDoubleToMScalar(1.0), SkDoubleToMScalar(0.0)); |
| 478 layer->SetTransform(transform); | 479 layer->SetTransform(transform); |
| 479 EXPECT_FALSE(layer->transform().IsInvertible()); | 480 EXPECT_FALSE(layer->transform().IsInvertible()); |
| 480 EXPECT_FALSE(layer->transform_is_invertible()); | 481 EXPECT_FALSE(layer->transform_is_invertible()); |
| 481 | 482 |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 651 | 652 |
| 652 scroll_tree(layer())->UpdateScrollOffsetBaseForTesting(layer()->id(), | 653 scroll_tree(layer())->UpdateScrollOffsetBaseForTesting(layer()->id(), |
| 653 scroll_offset); | 654 scroll_offset); |
| 654 gfx::Vector2dF unscrolled = layer()->ScrollBy(scroll_delta); | 655 gfx::Vector2dF unscrolled = layer()->ScrollBy(scroll_delta); |
| 655 | 656 |
| 656 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 0), unscrolled); | 657 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 0), unscrolled); |
| 657 EXPECT_VECTOR_EQ(gfx::Vector2dF(22, 23), layer()->CurrentScrollOffset()); | 658 EXPECT_VECTOR_EQ(gfx::Vector2dF(22, 23), layer()->CurrentScrollOffset()); |
| 658 | 659 |
| 659 scroll_tree(layer())->CollectScrollDeltasForTesting(); | 660 scroll_tree(layer())->CollectScrollDeltasForTesting(); |
| 660 | 661 |
| 661 scoped_ptr<LayerImpl> pending_layer = | 662 std::unique_ptr<LayerImpl> pending_layer = |
| 662 LayerImpl::Create(host_impl().sync_tree(), layer()->id()); | 663 LayerImpl::Create(host_impl().sync_tree(), layer()->id()); |
| 663 scroll_tree(pending_layer.get()) | 664 scroll_tree(pending_layer.get()) |
| 664 ->UpdateScrollOffsetBaseForTesting(pending_layer->id(), | 665 ->UpdateScrollOffsetBaseForTesting(pending_layer->id(), |
| 665 layer()->CurrentScrollOffset()); | 666 layer()->CurrentScrollOffset()); |
| 666 | 667 |
| 667 pending_layer->PushPropertiesTo(layer()); | 668 pending_layer->PushPropertiesTo(layer()); |
| 668 | 669 |
| 669 EXPECT_VECTOR_EQ(gfx::Vector2dF(22, 23), layer()->CurrentScrollOffset()); | 670 EXPECT_VECTOR_EQ(gfx::Vector2dF(22, 23), layer()->CurrentScrollOffset()); |
| 670 EXPECT_VECTOR_EQ(layer()->CurrentScrollOffset(), | 671 EXPECT_VECTOR_EQ(layer()->CurrentScrollOffset(), |
| 671 pending_layer->CurrentScrollOffset()); | 672 pending_layer->CurrentScrollOffset()); |
| 672 } | 673 } |
| 673 | 674 |
| 674 } // namespace | 675 } // namespace |
| 675 } // namespace cc | 676 } // namespace cc |
| OLD | NEW |