| 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.h" | 5 #include "cc/trees/layer_tree_host.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 3755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3766 inner_viewport_scroll_layer->SetScrollClipLayerId( | 3766 inner_viewport_scroll_layer->SetScrollClipLayerId( |
| 3767 inner_viewport_container_layer->id()); | 3767 inner_viewport_container_layer->id()); |
| 3768 inner_viewport_scroll_layer->SetIsContainerForFixedPositionLayers(true); | 3768 inner_viewport_scroll_layer->SetIsContainerForFixedPositionLayers(true); |
| 3769 | 3769 |
| 3770 root_layer_->AddChild(inner_viewport_container_layer); | 3770 root_layer_->AddChild(inner_viewport_container_layer); |
| 3771 inner_viewport_container_layer->AddChild(overscroll_elasticity_layer); | 3771 inner_viewport_container_layer->AddChild(overscroll_elasticity_layer); |
| 3772 overscroll_elasticity_layer->AddChild(page_scale_layer); | 3772 overscroll_elasticity_layer->AddChild(page_scale_layer); |
| 3773 page_scale_layer->AddChild(inner_viewport_scroll_layer); | 3773 page_scale_layer->AddChild(inner_viewport_scroll_layer); |
| 3774 | 3774 |
| 3775 scoped_refptr<Layer> content_layer = FakePictureLayer::Create(&client_); | 3775 scoped_refptr<Layer> content_layer = FakePictureLayer::Create(&client_); |
| 3776 content_layer_id_ = content_layer->id(); |
| 3776 content_layer->SetBounds(gfx::Size(10, 10)); | 3777 content_layer->SetBounds(gfx::Size(10, 10)); |
| 3777 inner_viewport_scroll_layer->AddChild(content_layer); | 3778 inner_viewport_scroll_layer->AddChild(content_layer); |
| 3778 | 3779 |
| 3779 layer_tree_host()->SetRootLayer(root_layer_); | 3780 layer_tree_host()->SetRootLayer(root_layer_); |
| 3780 layer_tree_host()->RegisterViewportLayers( | 3781 layer_tree_host()->RegisterViewportLayers( |
| 3781 overscroll_elasticity_layer, page_scale_layer, | 3782 overscroll_elasticity_layer, page_scale_layer, |
| 3782 inner_viewport_scroll_layer, nullptr); | 3783 inner_viewport_scroll_layer, nullptr); |
| 3783 LayerTreeHostTest::SetupTree(); | 3784 LayerTreeHostTest::SetupTree(); |
| 3784 client_.set_bounds(content_layer->bounds()); | 3785 client_.set_bounds(content_layer->bounds()); |
| 3785 } | 3786 } |
| 3786 | 3787 |
| 3787 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 3788 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 3788 | 3789 |
| 3789 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { | 3790 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { |
| 3790 if (host_impl->sync_tree()->source_frame_number() == 0) { | 3791 if (host_impl->sync_tree()->source_frame_number() == 0) { |
| 3791 scroll_elasticity_helper_ = host_impl->CreateScrollElasticityHelper(); | 3792 scroll_elasticity_helper_ = host_impl->CreateScrollElasticityHelper(); |
| 3792 } | 3793 } |
| 3793 } | 3794 } |
| 3794 | 3795 |
| 3795 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { | 3796 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { |
| 3796 num_draws_++; | 3797 num_draws_++; |
| 3797 LayerImpl* content_layer_impl = | 3798 LayerImpl* content_layer_impl = |
| 3798 host_impl->active_tree()->InnerViewportScrollLayer()->children()[0]; | 3799 host_impl->active_tree()->LayerById(content_layer_id_); |
| 3799 gfx::Transform expected_draw_transform; | 3800 gfx::Transform expected_draw_transform; |
| 3800 switch (num_draws_) { | 3801 switch (num_draws_) { |
| 3801 case 1: | 3802 case 1: |
| 3802 // Initially, there's no overscroll. | 3803 // Initially, there's no overscroll. |
| 3803 EXPECT_EQ(expected_draw_transform, content_layer_impl->DrawTransform()); | 3804 EXPECT_EQ(expected_draw_transform, content_layer_impl->DrawTransform()); |
| 3804 | 3805 |
| 3805 // Begin overscrolling. This should be reflected in the draw transform | 3806 // Begin overscrolling. This should be reflected in the draw transform |
| 3806 // the next time we draw. | 3807 // the next time we draw. |
| 3807 scroll_elasticity_helper_->SetStretchAmount(gfx::Vector2dF(5.f, 6.f)); | 3808 scroll_elasticity_helper_->SetStretchAmount(gfx::Vector2dF(5.f, 6.f)); |
| 3808 break; | 3809 break; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 3826 NOTREACHED(); | 3827 NOTREACHED(); |
| 3827 } | 3828 } |
| 3828 } | 3829 } |
| 3829 | 3830 |
| 3830 void AfterTest() override {} | 3831 void AfterTest() override {} |
| 3831 | 3832 |
| 3832 private: | 3833 private: |
| 3833 FakeContentLayerClient client_; | 3834 FakeContentLayerClient client_; |
| 3834 scoped_refptr<Layer> root_layer_; | 3835 scoped_refptr<Layer> root_layer_; |
| 3835 ScrollElasticityHelper* scroll_elasticity_helper_; | 3836 ScrollElasticityHelper* scroll_elasticity_helper_; |
| 3837 int content_layer_id_; |
| 3836 int num_draws_; | 3838 int num_draws_; |
| 3837 }; | 3839 }; |
| 3838 | 3840 |
| 3839 MULTI_THREAD_TEST_F(LayerTreeHostTestElasticOverscroll); | 3841 MULTI_THREAD_TEST_F(LayerTreeHostTestElasticOverscroll); |
| 3840 | 3842 |
| 3841 class LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface | 3843 class LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface |
| 3842 : public LayerTreeHostTest { | 3844 : public LayerTreeHostTest { |
| 3843 protected: | 3845 protected: |
| 3844 LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface() | 3846 LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface() |
| 3845 : first_output_surface_memory_limit_(4321234), | 3847 : first_output_surface_memory_limit_(4321234), |
| (...skipping 2452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6298 EndTest(); | 6300 EndTest(); |
| 6299 } | 6301 } |
| 6300 | 6302 |
| 6301 void AfterTest() override {} | 6303 void AfterTest() override {} |
| 6302 }; | 6304 }; |
| 6303 | 6305 |
| 6304 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestPaintedDeviceScaleFactor); | 6306 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestPaintedDeviceScaleFactor); |
| 6305 | 6307 |
| 6306 } // namespace | 6308 } // namespace |
| 6307 } // namespace cc | 6309 } // namespace cc |
| OLD | NEW |