Chromium Code Reviews| 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/test/layer_tree_test.h" | 5 #include "cc/test/layer_tree_test.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 712 layer_tree_host()->SetViewportSize(device_root_bounds); | 712 layer_tree_host()->SetViewportSize(device_root_bounds); |
| 713 layer_tree_host()->root_layer()->SetIsDrawable(true); | 713 layer_tree_host()->root_layer()->SetIsDrawable(true); |
| 714 layer_tree_host()->SetElementIdsForTesting(); | 714 layer_tree_host()->SetElementIdsForTesting(); |
| 715 } | 715 } |
| 716 | 716 |
| 717 void LayerTreeTest::Timeout() { | 717 void LayerTreeTest::Timeout() { |
| 718 timed_out_ = true; | 718 timed_out_ = true; |
| 719 EndTest(); | 719 EndTest(); |
| 720 } | 720 } |
| 721 | 721 |
| 722 void LayerTreeTest::InitializeRendererSettings( | |
| 723 RendererSettings* renderer_settings) { | |
| 724 // Spend less time waiting for BeginFrame because the output is | |
| 725 // mocked out. | |
| 726 renderer_settings->refresh_rate = 200.0; | |
| 727 renderer_settings->buffer_to_texture_target_map = | |
| 728 DefaultBufferToTextureTargetMapForTesting(); | |
| 729 } | |
| 730 | |
| 722 void LayerTreeTest::RealEndTest() { | 731 void LayerTreeTest::RealEndTest() { |
| 723 // TODO(mithro): Make this method only end when not inside an impl frame. | 732 // TODO(mithro): Make this method only end when not inside an impl frame. |
| 724 bool main_frame_will_happen = | 733 bool main_frame_will_happen = |
| 725 layer_tree_host_ | 734 layer_tree_host_ |
| 726 ? layer_tree_host_->proxy()->MainFrameWillHappenForTesting() | 735 ? layer_tree_host_->proxy()->MainFrameWillHappenForTesting() |
| 727 : false; | 736 : false; |
| 728 | 737 |
| 729 if (main_frame_will_happen && !timed_out_) { | 738 if (main_frame_will_happen && !timed_out_) { |
| 730 main_task_runner_->PostTask( | 739 main_task_runner_->PostTask( |
| 731 FROM_HERE, | 740 FROM_HERE, |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 818 | 827 |
| 819 image_worker_ = base::MakeUnique<base::Thread>("ImageWorker"); | 828 image_worker_ = base::MakeUnique<base::Thread>("ImageWorker"); |
| 820 ASSERT_TRUE(image_worker_->Start()); | 829 ASSERT_TRUE(image_worker_->Start()); |
| 821 | 830 |
| 822 shared_bitmap_manager_.reset(new TestSharedBitmapManager); | 831 shared_bitmap_manager_.reset(new TestSharedBitmapManager); |
| 823 gpu_memory_buffer_manager_.reset(new TestGpuMemoryBufferManager); | 832 gpu_memory_buffer_manager_.reset(new TestGpuMemoryBufferManager); |
| 824 task_graph_runner_.reset(new TestTaskGraphRunner); | 833 task_graph_runner_.reset(new TestTaskGraphRunner); |
| 825 | 834 |
| 826 // Spend less time waiting for BeginFrame because the output is | 835 // Spend less time waiting for BeginFrame because the output is |
| 827 // mocked out. | 836 // mocked out. |
| 828 settings_.renderer_settings.refresh_rate = 200.0; | |
| 829 settings_.background_animation_rate = 200.0; | 837 settings_.background_animation_rate = 200.0; |
| 830 // Disable latency recovery to make the scheduler more predictable in its | 838 // Disable latency recovery to make the scheduler more predictable in its |
| 831 // actions and less dependent on timings to make decisions. | 839 // actions and less dependent on timings to make decisions. |
| 832 settings_.enable_latency_recovery = false; | 840 settings_.enable_latency_recovery = false; |
| 833 settings_.renderer_settings.buffer_to_texture_target_map = | 841 settings_.buffer_to_texture_target_map = |
| 834 DefaultBufferToTextureTargetMapForTesting(); | 842 DefaultBufferToTextureTargetMapForTesting(); |
| 835 InitializeSettings(&settings_); | 843 InitializeSettings(&settings_); |
| 836 | 844 |
| 837 base::ThreadTaskRunnerHandle::Get()->PostTask( | 845 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 838 FROM_HERE, | 846 FROM_HERE, |
| 839 base::BindOnce(&LayerTreeTest::DoBeginTest, base::Unretained(this))); | 847 base::BindOnce(&LayerTreeTest::DoBeginTest, base::Unretained(this))); |
| 840 | 848 |
| 841 base::RunLoop().Run(); | 849 base::RunLoop().Run(); |
| 842 DestroyLayerTreeHost(); | 850 DestroyLayerTreeHost(); |
| 843 | 851 |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 862 std::move(shared_context_provider), std::move(worker_context_provider)); | 870 std::move(shared_context_provider), std::move(worker_context_provider)); |
| 863 compositor_frame_sink->SetClient(compositor_frame_sink_client_.get()); | 871 compositor_frame_sink->SetClient(compositor_frame_sink_client_.get()); |
| 864 layer_tree_host_->SetCompositorFrameSink(std::move(compositor_frame_sink)); | 872 layer_tree_host_->SetCompositorFrameSink(std::move(compositor_frame_sink)); |
| 865 } | 873 } |
| 866 | 874 |
| 867 std::unique_ptr<TestCompositorFrameSink> | 875 std::unique_ptr<TestCompositorFrameSink> |
| 868 LayerTreeTest::CreateCompositorFrameSink( | 876 LayerTreeTest::CreateCompositorFrameSink( |
| 869 scoped_refptr<ContextProvider> compositor_context_provider, | 877 scoped_refptr<ContextProvider> compositor_context_provider, |
| 870 scoped_refptr<ContextProvider> worker_context_provider) { | 878 scoped_refptr<ContextProvider> worker_context_provider) { |
| 871 constexpr bool disable_display_vsync = false; | 879 constexpr bool disable_display_vsync = false; |
| 880 RendererSettings renderer_settings; | |
| 881 InitializeRendererSettings(&renderer_settings); | |
|
danakj
2017/05/25 15:27:18
It feels a bit too easy for a patch author to forg
Alex Z.
2017/05/25 17:39:15
Done.
| |
| 872 bool synchronous_composite = | 882 bool synchronous_composite = |
| 873 !HasImplThread() && | 883 !HasImplThread() && |
| 874 !layer_tree_host()->GetSettings().single_thread_proxy_scheduler; | 884 !layer_tree_host()->GetSettings().single_thread_proxy_scheduler; |
| 875 return base::MakeUnique<TestCompositorFrameSink>( | 885 return base::MakeUnique<TestCompositorFrameSink>( |
| 876 compositor_context_provider, std::move(worker_context_provider), | 886 compositor_context_provider, std::move(worker_context_provider), |
| 877 shared_bitmap_manager(), gpu_memory_buffer_manager(), | 887 shared_bitmap_manager(), gpu_memory_buffer_manager(), renderer_settings, |
| 878 layer_tree_host()->GetSettings().renderer_settings, impl_task_runner_, | 888 impl_task_runner_, synchronous_composite, disable_display_vsync); |
| 879 synchronous_composite, disable_display_vsync); | |
| 880 } | 889 } |
| 881 | 890 |
| 882 std::unique_ptr<OutputSurface> | 891 std::unique_ptr<OutputSurface> |
| 883 LayerTreeTest::CreateDisplayOutputSurfaceOnThread( | 892 LayerTreeTest::CreateDisplayOutputSurfaceOnThread( |
| 884 scoped_refptr<ContextProvider> compositor_context_provider) { | 893 scoped_refptr<ContextProvider> compositor_context_provider) { |
| 885 // By default the Display shares a context with the LayerTreeHostImpl. | 894 // By default the Display shares a context with the LayerTreeHostImpl. |
| 886 return FakeOutputSurface::Create3d(std::move(compositor_context_provider)); | 895 return FakeOutputSurface::Create3d(std::move(compositor_context_provider)); |
| 887 } | 896 } |
| 888 | 897 |
| 889 void LayerTreeTest::DestroyLayerTreeHost() { | 898 void LayerTreeTest::DestroyLayerTreeHost() { |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 906 DCHECK(task_runner_provider()->IsMainThread() || | 915 DCHECK(task_runner_provider()->IsMainThread() || |
| 907 task_runner_provider()->IsMainThreadBlocked()); | 916 task_runner_provider()->IsMainThreadBlocked()); |
| 908 return layer_tree_host_.get(); | 917 return layer_tree_host_.get(); |
| 909 } | 918 } |
| 910 | 919 |
| 911 Proxy* LayerTreeTest::proxy() { | 920 Proxy* LayerTreeTest::proxy() { |
| 912 return layer_tree_host() ? layer_tree_host()->proxy() : NULL; | 921 return layer_tree_host() ? layer_tree_host()->proxy() : NULL; |
| 913 } | 922 } |
| 914 | 923 |
| 915 } // namespace cc | 924 } // namespace cc |
| OLD | NEW |