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/trees/layer_tree_host_impl.h" | 5 #include "cc/trees/layer_tree_host_impl.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <cmath> | 10 #include <cmath> |
(...skipping 4953 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4964 TEST_F(LayerTreeHostImplTest, ScrollMissesBackfacingChild) { | 4964 TEST_F(LayerTreeHostImplTest, ScrollMissesBackfacingChild) { |
4965 gfx::Size surface_size(10, 10); | 4965 gfx::Size surface_size(10, 10); |
4966 std::unique_ptr<LayerImpl> root = | 4966 std::unique_ptr<LayerImpl> root = |
4967 LayerImpl::Create(host_impl_->active_tree(), 1); | 4967 LayerImpl::Create(host_impl_->active_tree(), 1); |
4968 root->test_properties()->force_render_surface = true; | 4968 root->test_properties()->force_render_surface = true; |
4969 std::unique_ptr<LayerImpl> child = | 4969 std::unique_ptr<LayerImpl> child = |
4970 CreateScrollableLayer(2, surface_size, root.get()); | 4970 CreateScrollableLayer(2, surface_size, root.get()); |
4971 | 4971 |
4972 gfx::Transform matrix; | 4972 gfx::Transform matrix; |
4973 matrix.RotateAboutXAxis(180.0); | 4973 matrix.RotateAboutXAxis(180.0); |
4974 child->SetTransform(matrix); | 4974 child->test_properties()->transform = matrix; |
4975 child->test_properties()->double_sided = false; | 4975 child->test_properties()->double_sided = false; |
4976 | 4976 |
4977 root->test_properties()->AddChild(std::move(child)); | 4977 root->test_properties()->AddChild(std::move(child)); |
4978 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root)); | 4978 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root)); |
4979 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 4979 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
4980 | 4980 |
4981 host_impl_->SetViewportSize(surface_size); | 4981 host_impl_->SetViewportSize(surface_size); |
4982 DrawFrame(); | 4982 DrawFrame(); |
4983 | 4983 |
4984 // Scroll event is ignored because the scrollable layer is not facing the | 4984 // Scroll event is ignored because the scrollable layer is not facing the |
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5526 .thread); | 5526 .thread); |
5527 } | 5527 } |
5528 | 5528 |
5529 TEST_F(LayerTreeHostImplTest, ScrollAxisAlignedRotatedLayer) { | 5529 TEST_F(LayerTreeHostImplTest, ScrollAxisAlignedRotatedLayer) { |
5530 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 5530 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
5531 scroll_layer->SetDrawsContent(true); | 5531 scroll_layer->SetDrawsContent(true); |
5532 | 5532 |
5533 // Rotate the root layer 90 degrees counter-clockwise about its center. | 5533 // Rotate the root layer 90 degrees counter-clockwise about its center. |
5534 gfx::Transform rotate_transform; | 5534 gfx::Transform rotate_transform; |
5535 rotate_transform.Rotate(-90.0); | 5535 rotate_transform.Rotate(-90.0); |
5536 host_impl_->active_tree()->root_layer_for_testing()->SetTransform( | 5536 host_impl_->active_tree() |
5537 rotate_transform); | 5537 ->root_layer_for_testing() |
| 5538 ->test_properties() |
| 5539 ->transform = rotate_transform; |
5538 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 5540 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
5539 | 5541 |
5540 gfx::Size surface_size(50, 50); | 5542 gfx::Size surface_size(50, 50); |
5541 host_impl_->SetViewportSize(surface_size); | 5543 host_impl_->SetViewportSize(surface_size); |
5542 DrawFrame(); | 5544 DrawFrame(); |
5543 | 5545 |
5544 // Scroll to the right in screen coordinates with a gesture. | 5546 // Scroll to the right in screen coordinates with a gesture. |
5545 gfx::Vector2d gesture_scroll_delta(10, 0); | 5547 gfx::Vector2d gesture_scroll_delta(10, 0); |
5546 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 5548 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
5547 host_impl_ | 5549 host_impl_ |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5581 | 5583 |
5582 // Create a child layer that is rotated to a non-axis-aligned angle. | 5584 // Create a child layer that is rotated to a non-axis-aligned angle. |
5583 std::unique_ptr<LayerImpl> clip_layer = | 5585 std::unique_ptr<LayerImpl> clip_layer = |
5584 LayerImpl::Create(host_impl_->active_tree(), child_clip_layer_id); | 5586 LayerImpl::Create(host_impl_->active_tree(), child_clip_layer_id); |
5585 std::unique_ptr<LayerImpl> child = CreateScrollableLayer( | 5587 std::unique_ptr<LayerImpl> child = CreateScrollableLayer( |
5586 child_layer_id, scroll_layer->bounds(), clip_layer.get()); | 5588 child_layer_id, scroll_layer->bounds(), clip_layer.get()); |
5587 gfx::Transform rotate_transform; | 5589 gfx::Transform rotate_transform; |
5588 rotate_transform.Translate(-50.0, -50.0); | 5590 rotate_transform.Translate(-50.0, -50.0); |
5589 rotate_transform.Rotate(child_layer_angle); | 5591 rotate_transform.Rotate(child_layer_angle); |
5590 rotate_transform.Translate(50.0, 50.0); | 5592 rotate_transform.Translate(50.0, 50.0); |
5591 clip_layer->SetTransform(rotate_transform); | 5593 clip_layer->test_properties()->transform = rotate_transform; |
5592 | 5594 |
5593 // Only allow vertical scrolling. | 5595 // Only allow vertical scrolling. |
5594 clip_layer->SetBounds( | 5596 clip_layer->SetBounds( |
5595 gfx::Size(child->bounds().width(), child->bounds().height() / 2)); | 5597 gfx::Size(child->bounds().width(), child->bounds().height() / 2)); |
5596 // The rotation depends on the layer's transform origin, and the child layer | 5598 // The rotation depends on the layer's transform origin, and the child layer |
5597 // is a different size than the clip, so make sure the clip layer's origin | 5599 // is a different size than the clip, so make sure the clip layer's origin |
5598 // lines up over the child. | 5600 // lines up over the child. |
5599 clip_layer->test_properties()->transform_origin = gfx::Point3F( | 5601 clip_layer->test_properties()->transform_origin = gfx::Point3F( |
5600 clip_layer->bounds().width() * 0.5f, clip_layer->bounds().height(), 0.f); | 5602 clip_layer->bounds().width() * 0.5f, clip_layer->bounds().height(), 0.f); |
5601 LayerImpl* child_ptr = child.get(); | 5603 LayerImpl* child_ptr = child.get(); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5668 std::unique_ptr<LayerImpl> clip_layer = | 5670 std::unique_ptr<LayerImpl> clip_layer = |
5669 LayerImpl::Create(host_impl_->active_tree(), child_clip_layer_id); | 5671 LayerImpl::Create(host_impl_->active_tree(), child_clip_layer_id); |
5670 std::unique_ptr<LayerImpl> child = CreateScrollableLayer( | 5672 std::unique_ptr<LayerImpl> child = CreateScrollableLayer( |
5671 child_layer_id, scroll_layer->bounds(), clip_layer.get()); | 5673 child_layer_id, scroll_layer->bounds(), clip_layer.get()); |
5672 LayerImpl* child_ptr = child.get(); | 5674 LayerImpl* child_ptr = child.get(); |
5673 gfx::Transform perspective_transform; | 5675 gfx::Transform perspective_transform; |
5674 perspective_transform.Translate(-50.0, -50.0); | 5676 perspective_transform.Translate(-50.0, -50.0); |
5675 perspective_transform.ApplyPerspectiveDepth(20); | 5677 perspective_transform.ApplyPerspectiveDepth(20); |
5676 perspective_transform.RotateAboutXAxis(45); | 5678 perspective_transform.RotateAboutXAxis(45); |
5677 perspective_transform.Translate(50.0, 50.0); | 5679 perspective_transform.Translate(50.0, 50.0); |
5678 clip_layer->SetTransform(perspective_transform); | 5680 clip_layer->test_properties()->transform = perspective_transform; |
5679 | 5681 |
5680 clip_layer->SetBounds(gfx::Size(child_ptr->bounds().width() / 2, | 5682 clip_layer->SetBounds(gfx::Size(child_ptr->bounds().width() / 2, |
5681 child_ptr->bounds().height() / 2)); | 5683 child_ptr->bounds().height() / 2)); |
5682 // The transform depends on the layer's transform origin, and the child layer | 5684 // The transform depends on the layer's transform origin, and the child layer |
5683 // is a different size than the clip, so make sure the clip layer's origin | 5685 // is a different size than the clip, so make sure the clip layer's origin |
5684 // lines up over the child. | 5686 // lines up over the child. |
5685 clip_layer->test_properties()->transform_origin = gfx::Point3F( | 5687 clip_layer->test_properties()->transform_origin = gfx::Point3F( |
5686 clip_layer->bounds().width(), clip_layer->bounds().height(), 0.f); | 5688 clip_layer->bounds().width(), clip_layer->bounds().height(), 0.f); |
5687 clip_layer->test_properties()->AddChild(std::move(child)); | 5689 clip_layer->test_properties()->AddChild(std::move(child)); |
5688 scroll_layer->test_properties()->AddChild(std::move(clip_layer)); | 5690 scroll_layer->test_properties()->AddChild(std::move(clip_layer)); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5738 } | 5740 } |
5739 | 5741 |
5740 TEST_F(LayerTreeHostImplTest, ScrollScaledLayer) { | 5742 TEST_F(LayerTreeHostImplTest, ScrollScaledLayer) { |
5741 LayerImpl* scroll_layer = | 5743 LayerImpl* scroll_layer = |
5742 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 5744 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
5743 | 5745 |
5744 // Scale the layer to twice its normal size. | 5746 // Scale the layer to twice its normal size. |
5745 int scale = 2; | 5747 int scale = 2; |
5746 gfx::Transform scale_transform; | 5748 gfx::Transform scale_transform; |
5747 scale_transform.Scale(scale, scale); | 5749 scale_transform.Scale(scale, scale); |
5748 scroll_layer->test_properties()->parent->SetTransform(scale_transform); | 5750 scroll_layer->test_properties()->parent->test_properties()->transform = |
| 5751 scale_transform; |
5749 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 5752 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
5750 | 5753 |
5751 gfx::Size surface_size(50, 50); | 5754 gfx::Size surface_size(50, 50); |
5752 host_impl_->SetViewportSize(surface_size); | 5755 host_impl_->SetViewportSize(surface_size); |
5753 DrawFrame(); | 5756 DrawFrame(); |
5754 | 5757 |
5755 // Scroll down in screen coordinates with a gesture. | 5758 // Scroll down in screen coordinates with a gesture. |
5756 gfx::Vector2d scroll_delta(0, 10); | 5759 gfx::Vector2d scroll_delta(0, 10); |
5757 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 5760 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
5758 host_impl_ | 5761 host_impl_ |
(...skipping 3938 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9697 ->test_properties() | 9700 ->test_properties() |
9698 ->children[0]; | 9701 ->children[0]; |
9699 content_layer->test_properties()->AddChild( | 9702 content_layer->test_properties()->AddChild( |
9700 LayerImpl::Create(host_impl_->active_tree(), 100)); | 9703 LayerImpl::Create(host_impl_->active_tree(), 100)); |
9701 LayerImpl* test_layer = host_impl_->active_tree()->LayerById(100); | 9704 LayerImpl* test_layer = host_impl_->active_tree()->LayerById(100); |
9702 test_layer->test_properties()->force_render_surface = true; | 9705 test_layer->test_properties()->force_render_surface = true; |
9703 test_layer->SetDrawsContent(true); | 9706 test_layer->SetDrawsContent(true); |
9704 test_layer->SetBounds(layer_size); | 9707 test_layer->SetBounds(layer_size); |
9705 gfx::Transform perspective_transform; | 9708 gfx::Transform perspective_transform; |
9706 perspective_transform.ApplyPerspectiveDepth(2); | 9709 perspective_transform.ApplyPerspectiveDepth(2); |
9707 test_layer->SetTransform(perspective_transform); | 9710 test_layer->test_properties()->transform = perspective_transform; |
9708 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 9711 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
9709 | 9712 |
9710 bool update_lcd_text = false; | 9713 bool update_lcd_text = false; |
9711 | 9714 |
9712 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 9715 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
9713 host_impl_->active_tree()->UpdateDrawProperties(update_lcd_text); | 9716 host_impl_->active_tree()->UpdateDrawProperties(update_lcd_text); |
9714 TransformNode* node = | 9717 TransformNode* node = |
9715 host_impl_->active_tree()->property_trees()->transform_tree.Node( | 9718 host_impl_->active_tree()->property_trees()->transform_tree.Node( |
9716 test_layer->transform_tree_index()); | 9719 test_layer->transform_tree_index()); |
9717 EXPECT_EQ(node->surface_contents_scale, gfx::Vector2dF(1.f, 1.f)); | 9720 EXPECT_EQ(node->surface_contents_scale, gfx::Vector2dF(1.f, 1.f)); |
(...skipping 1109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10827 | 10830 |
10828 host_impl_->CreatePendingTree(); | 10831 host_impl_->CreatePendingTree(); |
10829 host_impl_->pending_tree()->set_source_frame_number(i + 1); | 10832 host_impl_->pending_tree()->set_source_frame_number(i + 1); |
10830 LayerImpl* content_layer = host_impl_->pending_tree() | 10833 LayerImpl* content_layer = host_impl_->pending_tree() |
10831 ->OuterViewportScrollLayer() | 10834 ->OuterViewportScrollLayer() |
10832 ->test_properties() | 10835 ->test_properties() |
10833 ->children[0]; | 10836 ->children[0]; |
10834 // The scroll done on the active tree is undone on the pending tree. | 10837 // The scroll done on the active tree is undone on the pending tree. |
10835 gfx::Transform translate; | 10838 gfx::Transform translate; |
10836 translate.Translate(0, accumulated_scroll); | 10839 translate.Translate(0, accumulated_scroll); |
10837 content_layer->SetTransform(translate); | 10840 content_layer->test_properties()->transform = translate; |
10838 | 10841 |
10839 LayerTreeImpl* pending_tree = host_impl_->pending_tree(); | 10842 LayerTreeImpl* pending_tree = host_impl_->pending_tree(); |
10840 pending_tree->PushPageScaleFromMainThread(1.f, 1.f, 1.f); | 10843 pending_tree->PushPageScaleFromMainThread(1.f, 1.f, 1.f); |
10841 LayerImpl* last_scrolled_layer = pending_tree->LayerById( | 10844 LayerImpl* last_scrolled_layer = pending_tree->LayerById( |
10842 host_impl_->active_tree()->LastScrolledLayerId()); | 10845 host_impl_->active_tree()->LastScrolledLayerId()); |
10843 | 10846 |
10844 // When building property trees from impl side, the builder uses the scroll | 10847 // When building property trees from impl side, the builder uses the scroll |
10845 // offset of layer_impl to initialize the scroll offset in scroll tree: | 10848 // offset of layer_impl to initialize the scroll offset in scroll tree: |
10846 // scroll_tree.synced_scroll_offset.PushFromMainThread( | 10849 // scroll_tree.synced_scroll_offset.PushFromMainThread( |
10847 // layer->CurrentScrollOffset()). | 10850 // layer->CurrentScrollOffset()). |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10894 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); | 10897 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); |
10895 | 10898 |
10896 // Re-initialize with a software output surface. | 10899 // Re-initialize with a software output surface. |
10897 output_surface_ = FakeOutputSurface::CreateDelegatingSoftware(); | 10900 output_surface_ = FakeOutputSurface::CreateDelegatingSoftware(); |
10898 host_impl_->InitializeRenderer(output_surface_.get()); | 10901 host_impl_->InitializeRenderer(output_surface_.get()); |
10899 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); | 10902 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); |
10900 } | 10903 } |
10901 | 10904 |
10902 } // namespace | 10905 } // namespace |
10903 } // namespace cc | 10906 } // namespace cc |
OLD | NEW |