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 <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 1756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1767 kCompletedMainFrame, | 1767 kCompletedMainFrame, |
1768 kCompletedImplFrame, | 1768 kCompletedImplFrame, |
1769 }; | 1769 }; |
1770 | 1770 |
1771 LayerTreeHostTestCompositeImmediatelyStateTransitions() | 1771 LayerTreeHostTestCompositeImmediatelyStateTransitions() |
1772 : current_state_(kInvalid), current_begin_frame_args_() {} | 1772 : current_state_(kInvalid), current_begin_frame_args_() {} |
1773 | 1773 |
1774 void InitializeSettings(LayerTreeSettings* settings) override { | 1774 void InitializeSettings(LayerTreeSettings* settings) override { |
1775 settings->single_thread_proxy_scheduler = false; | 1775 settings->single_thread_proxy_scheduler = false; |
1776 settings->use_zero_copy = true; | 1776 settings->use_zero_copy = true; |
1777 settings->use_one_copy = false; | |
1778 } | 1777 } |
1779 | 1778 |
1780 void BeginTest() override { | 1779 void BeginTest() override { |
1781 current_state_ = kStartedTest; | 1780 current_state_ = kStartedTest; |
1782 PostCompositeImmediatelyToMainThread(); | 1781 PostCompositeImmediatelyToMainThread(); |
1783 } | 1782 } |
1784 | 1783 |
1785 void WillBeginImplFrameOnThread(LayerTreeHostImpl* host_impl, | 1784 void WillBeginImplFrameOnThread(LayerTreeHostImpl* host_impl, |
1786 const BeginFrameArgs& args) override { | 1785 const BeginFrameArgs& args) override { |
1787 EXPECT_EQ(current_state_, kStartedTest); | 1786 EXPECT_EQ(current_state_, kStartedTest); |
(...skipping 1965 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3753 } | 3752 } |
3754 | 3753 |
3755 void AfterTest() override {} | 3754 void AfterTest() override {} |
3756 | 3755 |
3757 FakeContentLayerClient client_; | 3756 FakeContentLayerClient client_; |
3758 scoped_refptr<FakePictureLayer> root_layer_; | 3757 scoped_refptr<FakePictureLayer> root_layer_; |
3759 }; | 3758 }; |
3760 | 3759 |
3761 MULTI_THREAD_TEST_F(LayerTreeHostTestUpdateLayerInEmptyViewport); | 3760 MULTI_THREAD_TEST_F(LayerTreeHostTestUpdateLayerInEmptyViewport); |
3762 | 3761 |
3763 class LayerTreeHostTestMaxTransferBufferUsageBytes : public LayerTreeHostTest { | |
3764 protected: | |
3765 void InitializeSettings(LayerTreeSettings* settings) override { | |
3766 // Testing async uploads. | |
3767 settings->use_zero_copy = false; | |
3768 settings->use_one_copy = false; | |
3769 } | |
3770 | |
3771 scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface() override { | |
3772 scoped_refptr<TestContextProvider> context_provider = | |
3773 TestContextProvider::Create(); | |
3774 context_provider->SetMaxTransferBufferUsageBytes(512 * 512); | |
3775 if (delegating_renderer()) | |
3776 return FakeOutputSurface::CreateDelegating3d(context_provider); | |
3777 else | |
3778 return FakeOutputSurface::Create3d(context_provider); | |
3779 } | |
3780 | |
3781 void SetupTree() override { | |
3782 client_.set_fill_with_nonsolid_color(true); | |
3783 scoped_refptr<FakePictureLayer> root_layer = | |
3784 FakePictureLayer::Create(layer_settings(), &client_); | |
3785 root_layer->SetBounds(gfx::Size(1024, 1024)); | |
3786 root_layer->SetIsDrawable(true); | |
3787 | |
3788 layer_tree_host()->SetRootLayer(root_layer); | |
3789 LayerTreeHostTest::SetupTree(); | |
3790 } | |
3791 | |
3792 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | |
3793 | |
3794 void DidActivateTreeOnThread(LayerTreeHostImpl* impl) override { | |
3795 TestWebGraphicsContext3D* context = TestContext(); | |
3796 | |
3797 // Expect that the transfer buffer memory used is equal to the | |
3798 // MaxTransferBufferUsageBytes value set in CreateOutputSurface. | |
3799 EXPECT_EQ(512 * 512u, context->max_used_transfer_buffer_usage_bytes()); | |
3800 EndTest(); | |
3801 } | |
3802 | |
3803 void AfterTest() override {} | |
3804 | |
3805 private: | |
3806 FakeContentLayerClient client_; | |
3807 }; | |
3808 | |
3809 // Impl-side painting is a multi-threaded compositor feature. | |
3810 MULTI_THREAD_TEST_F(LayerTreeHostTestMaxTransferBufferUsageBytes); | |
3811 | |
3812 class LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface | 3762 class LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface |
3813 : public LayerTreeHostTest { | 3763 : public LayerTreeHostTest { |
3814 protected: | 3764 protected: |
3815 LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface() | 3765 LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface() |
3816 : first_output_surface_memory_limit_(4321234), | 3766 : first_output_surface_memory_limit_(4321234), |
3817 second_output_surface_memory_limit_(1234321) {} | 3767 second_output_surface_memory_limit_(1234321) {} |
3818 | 3768 |
3819 scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface() override { | 3769 scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface() override { |
3820 if (!first_context_provider_.get()) { | 3770 if (!first_context_provider_.get()) { |
3821 first_context_provider_ = TestContextProvider::Create(); | 3771 first_context_provider_ = TestContextProvider::Create(); |
(...skipping 970 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4792 | 4742 |
4793 // Do a synchronous composite and assert that the swap promise succeeds. | 4743 // Do a synchronous composite and assert that the swap promise succeeds. |
4794 class LayerTreeHostTestSynchronousCompositeSwapPromise | 4744 class LayerTreeHostTestSynchronousCompositeSwapPromise |
4795 : public LayerTreeHostTest { | 4745 : public LayerTreeHostTest { |
4796 public: | 4746 public: |
4797 LayerTreeHostTestSynchronousCompositeSwapPromise() : commit_count_(0) {} | 4747 LayerTreeHostTestSynchronousCompositeSwapPromise() : commit_count_(0) {} |
4798 | 4748 |
4799 void InitializeSettings(LayerTreeSettings* settings) override { | 4749 void InitializeSettings(LayerTreeSettings* settings) override { |
4800 settings->single_thread_proxy_scheduler = false; | 4750 settings->single_thread_proxy_scheduler = false; |
4801 settings->use_zero_copy = true; | 4751 settings->use_zero_copy = true; |
4802 settings->use_one_copy = false; | |
4803 } | 4752 } |
4804 | 4753 |
4805 void BeginTest() override { | 4754 void BeginTest() override { |
4806 // Successful composite. | 4755 // Successful composite. |
4807 scoped_ptr<SwapPromise> swap_promise0( | 4756 scoped_ptr<SwapPromise> swap_promise0( |
4808 new TestSwapPromise(&swap_promise_result_[0])); | 4757 new TestSwapPromise(&swap_promise_result_[0])); |
4809 layer_tree_host()->QueueSwapPromise(swap_promise0.Pass()); | 4758 layer_tree_host()->QueueSwapPromise(swap_promise0.Pass()); |
4810 layer_tree_host()->Composite(base::TimeTicks::Now()); | 4759 layer_tree_host()->Composite(base::TimeTicks::Now()); |
4811 | 4760 |
4812 // Fail to swap (no damage). | 4761 // Fail to swap (no damage). |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5096 base::WaitableEvent playback_allowed_event_; | 5045 base::WaitableEvent playback_allowed_event_; |
5097 }; | 5046 }; |
5098 | 5047 |
5099 // This test does pinching on the impl side which is not supported in single | 5048 // This test does pinching on the impl side which is not supported in single |
5100 // thread. | 5049 // thread. |
5101 MULTI_THREAD_TEST_F(LayerTreeHostTestCrispUpAfterPinchEnds); | 5050 MULTI_THREAD_TEST_F(LayerTreeHostTestCrispUpAfterPinchEnds); |
5102 | 5051 |
5103 class LayerTreeHostTestCrispUpAfterPinchEndsWithOneCopy | 5052 class LayerTreeHostTestCrispUpAfterPinchEndsWithOneCopy |
5104 : public LayerTreeHostTestCrispUpAfterPinchEnds { | 5053 : public LayerTreeHostTestCrispUpAfterPinchEnds { |
5105 protected: | 5054 protected: |
5106 void InitializeSettings(LayerTreeSettings* settings) override { | |
5107 settings->use_one_copy = true; | |
5108 } | |
5109 | |
5110 scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface() override { | 5055 scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface() override { |
5111 scoped_ptr<TestWebGraphicsContext3D> context3d = | 5056 scoped_ptr<TestWebGraphicsContext3D> context3d = |
5112 TestWebGraphicsContext3D::Create(); | 5057 TestWebGraphicsContext3D::Create(); |
5113 context3d->set_support_image(true); | 5058 context3d->set_support_image(true); |
5114 context3d->set_support_sync_query(true); | 5059 context3d->set_support_sync_query(true); |
5115 #if defined(OS_MACOSX) | 5060 #if defined(OS_MACOSX) |
5116 context3d->set_support_texture_rectangle(true); | 5061 context3d->set_support_texture_rectangle(true); |
5117 #endif | 5062 #endif |
5118 | 5063 |
5119 if (delegating_renderer()) | 5064 if (delegating_renderer()) |
(...skipping 1140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6260 ScrollAndScaleSet scale_info_; | 6205 ScrollAndScaleSet scale_info_; |
6261 ScrollAndScaleSet no_op_info_; | 6206 ScrollAndScaleSet no_op_info_; |
6262 bool requested_update_layers_; | 6207 bool requested_update_layers_; |
6263 int commit_count_; | 6208 int commit_count_; |
6264 }; | 6209 }; |
6265 | 6210 |
6266 MULTI_THREAD_TEST_F(LayerTreeHostScrollingAndScalingUpdatesLayers); | 6211 MULTI_THREAD_TEST_F(LayerTreeHostScrollingAndScalingUpdatesLayers); |
6267 | 6212 |
6268 } // namespace | 6213 } // namespace |
6269 } // namespace cc | 6214 } // namespace cc |
OLD | NEW |