| 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/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 layer_tree_host->InitializeForTesting( | 397 layer_tree_host->InitializeForTesting( |
| 398 std::move(task_runner_provider), std::move(proxy), | 398 std::move(task_runner_provider), std::move(proxy), |
| 399 std::move(external_begin_frame_source)); | 399 std::move(external_begin_frame_source)); |
| 400 return layer_tree_host; | 400 return layer_tree_host; |
| 401 } | 401 } |
| 402 | 402 |
| 403 std::unique_ptr<LayerTreeHostImpl> CreateLayerTreeHostImpl( | 403 std::unique_ptr<LayerTreeHostImpl> CreateLayerTreeHostImpl( |
| 404 LayerTreeHostImplClient* host_impl_client) override { | 404 LayerTreeHostImplClient* host_impl_client) override { |
| 405 std::unique_ptr<LayerTreeHostImpl> host_impl = | 405 std::unique_ptr<LayerTreeHostImpl> host_impl = |
| 406 LayerTreeHostImplForTesting::Create( | 406 LayerTreeHostImplForTesting::Create( |
| 407 test_hooks_, settings(), host_impl_client, task_runner_provider(), | 407 test_hooks_, GetSettings(), host_impl_client, |
| 408 shared_bitmap_manager(), gpu_memory_buffer_manager(), | 408 GetTaskRunnerProvider(), shared_bitmap_manager(), |
| 409 task_graph_runner(), rendering_stats_instrumentation()); | 409 gpu_memory_buffer_manager(), task_graph_runner(), |
| 410 rendering_stats_instrumentation()); |
| 410 input_handler_weak_ptr_ = host_impl->AsWeakPtr(); | 411 input_handler_weak_ptr_ = host_impl->AsWeakPtr(); |
| 411 return host_impl; | 412 return host_impl; |
| 412 } | 413 } |
| 413 | 414 |
| 414 void SetNeedsCommit() override { | 415 void SetNeedsCommit() override { |
| 415 if (!test_started_) | 416 if (!test_started_) |
| 416 return; | 417 return; |
| 417 LayerTreeHost::SetNeedsCommit(); | 418 LayerTreeHost::SetNeedsCommit(); |
| 418 } | 419 } |
| 419 | 420 |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 643 this, mode_, client_.get(), nullptr, shared_bitmap_manager_.get(), | 644 this, mode_, client_.get(), nullptr, shared_bitmap_manager_.get(), |
| 644 gpu_memory_buffer_manager_.get(), task_graph_runner_.get(), settings_, | 645 gpu_memory_buffer_manager_.get(), task_graph_runner_.get(), settings_, |
| 645 base::ThreadTaskRunnerHandle::Get(), | 646 base::ThreadTaskRunnerHandle::Get(), |
| 646 impl_thread_ ? impl_thread_->task_runner() : nullptr, nullptr, | 647 impl_thread_ ? impl_thread_->task_runner() : nullptr, nullptr, |
| 647 image_serialization_processor_.get()); | 648 image_serialization_processor_.get()); |
| 648 } | 649 } |
| 649 | 650 |
| 650 ASSERT_TRUE(layer_tree_host_); | 651 ASSERT_TRUE(layer_tree_host_); |
| 651 | 652 |
| 652 main_task_runner_ = | 653 main_task_runner_ = |
| 653 layer_tree_host_->task_runner_provider()->MainThreadTaskRunner(); | 654 layer_tree_host_->GetTaskRunnerProvider()->MainThreadTaskRunner(); |
| 654 impl_task_runner_ = | 655 impl_task_runner_ = |
| 655 layer_tree_host_->task_runner_provider()->ImplThreadTaskRunner(); | 656 layer_tree_host_->GetTaskRunnerProvider()->ImplThreadTaskRunner(); |
| 656 if (!impl_task_runner_) { | 657 if (!impl_task_runner_) { |
| 657 // For tests, if there's no impl thread, make things easier by just giving | 658 // For tests, if there's no impl thread, make things easier by just giving |
| 658 // the main thread task runner. | 659 // the main thread task runner. |
| 659 impl_task_runner_ = main_task_runner_; | 660 impl_task_runner_ = main_task_runner_; |
| 660 } | 661 } |
| 661 | 662 |
| 662 if (timeout_seconds_) { | 663 if (timeout_seconds_) { |
| 663 timeout_.Reset(base::Bind(&LayerTreeTest::Timeout, base::Unretained(this))); | 664 timeout_.Reset(base::Bind(&LayerTreeTest::Timeout, base::Unretained(this))); |
| 664 main_task_runner_->PostDelayedTask( | 665 main_task_runner_->PostDelayedTask( |
| 665 FROM_HERE, timeout_.callback(), | 666 FROM_HERE, timeout_.callback(), |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 851 layer_tree_host_->SetOutputSurface(std::move(delegating_output_surface)); | 852 layer_tree_host_->SetOutputSurface(std::move(delegating_output_surface)); |
| 852 } | 853 } |
| 853 } | 854 } |
| 854 | 855 |
| 855 std::unique_ptr<TestDelegatingOutputSurface> | 856 std::unique_ptr<TestDelegatingOutputSurface> |
| 856 LayerTreeTest::CreateDelegatingOutputSurface( | 857 LayerTreeTest::CreateDelegatingOutputSurface( |
| 857 scoped_refptr<ContextProvider> compositor_context_provider, | 858 scoped_refptr<ContextProvider> compositor_context_provider, |
| 858 scoped_refptr<ContextProvider> worker_context_provider) { | 859 scoped_refptr<ContextProvider> worker_context_provider) { |
| 859 bool synchronous_composite = | 860 bool synchronous_composite = |
| 860 !HasImplThread() && | 861 !HasImplThread() && |
| 861 !layer_tree_host()->settings().single_thread_proxy_scheduler; | 862 !layer_tree_host()->GetSettings().single_thread_proxy_scheduler; |
| 862 // Disable reclaim resources by default to act like the Display lives | 863 // Disable reclaim resources by default to act like the Display lives |
| 863 // out-of-process. | 864 // out-of-process. |
| 864 bool force_disable_reclaim_resources = true; | 865 bool force_disable_reclaim_resources = true; |
| 865 return base::MakeUnique<TestDelegatingOutputSurface>( | 866 return base::MakeUnique<TestDelegatingOutputSurface>( |
| 866 compositor_context_provider, std::move(worker_context_provider), | 867 compositor_context_provider, std::move(worker_context_provider), |
| 867 CreateDisplayOutputSurface(compositor_context_provider), | 868 CreateDisplayOutputSurface(compositor_context_provider), |
| 868 shared_bitmap_manager(), gpu_memory_buffer_manager(), | 869 shared_bitmap_manager(), gpu_memory_buffer_manager(), |
| 869 layer_tree_host()->settings().renderer_settings, ImplThreadTaskRunner(), | 870 layer_tree_host()->GetSettings().renderer_settings, |
| 870 synchronous_composite, force_disable_reclaim_resources); | 871 ImplThreadTaskRunner(), synchronous_composite, |
| 872 force_disable_reclaim_resources); |
| 871 } | 873 } |
| 872 | 874 |
| 873 std::unique_ptr<OutputSurface> LayerTreeTest::CreateDisplayOutputSurface( | 875 std::unique_ptr<OutputSurface> LayerTreeTest::CreateDisplayOutputSurface( |
| 874 scoped_refptr<ContextProvider> compositor_context_provider) { | 876 scoped_refptr<ContextProvider> compositor_context_provider) { |
| 875 // By default the Display shares a context with the LayerTreeHostImpl. | 877 // By default the Display shares a context with the LayerTreeHostImpl. |
| 876 return FakeOutputSurface::Create3d(std::move(compositor_context_provider)); | 878 return FakeOutputSurface::Create3d(std::move(compositor_context_provider)); |
| 877 } | 879 } |
| 878 | 880 |
| 879 void LayerTreeTest::DestroyLayerTreeHost() { | 881 void LayerTreeTest::DestroyLayerTreeHost() { |
| 880 if (layer_tree_host_ && layer_tree_host_->GetLayerTree()->root_layer()) | 882 if (layer_tree_host_ && layer_tree_host_->GetLayerTree()->root_layer()) |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 923 // thread. In the remote mode, the impl thread of the compositor lives on | 925 // thread. In the remote mode, the impl thread of the compositor lives on |
| 924 // the client, so return the task runner provider owned by the remote client | 926 // the client, so return the task runner provider owned by the remote client |
| 925 // LayerTreeHost. | 927 // LayerTreeHost. |
| 926 LayerTreeHost* host = IsRemoteTest() ? remote_client_layer_tree_host_.get() | 928 LayerTreeHost* host = IsRemoteTest() ? remote_client_layer_tree_host_.get() |
| 927 : layer_tree_host_.get(); | 929 : layer_tree_host_.get(); |
| 928 | 930 |
| 929 // If this fails, the test has ended and there is no task runners to find | 931 // If this fails, the test has ended and there is no task runners to find |
| 930 // anymore. | 932 // anymore. |
| 931 DCHECK(host); | 933 DCHECK(host); |
| 932 | 934 |
| 933 return host->task_runner_provider(); | 935 return host->GetTaskRunnerProvider(); |
| 934 } | 936 } |
| 935 | 937 |
| 936 LayerTreeHost* LayerTreeTest::layer_tree_host() { | 938 LayerTreeHost* LayerTreeTest::layer_tree_host() { |
| 937 DCHECK(task_runner_provider()->IsMainThread() || | 939 DCHECK(task_runner_provider()->IsMainThread() || |
| 938 task_runner_provider()->IsMainThreadBlocked()); | 940 task_runner_provider()->IsMainThreadBlocked()); |
| 939 return layer_tree_host_.get(); | 941 return layer_tree_host_.get(); |
| 940 } | 942 } |
| 941 | 943 |
| 942 LayerTreeHost* LayerTreeTest::remote_client_layer_tree_host() { | 944 LayerTreeHost* LayerTreeTest::remote_client_layer_tree_host() { |
| 943 DCHECK(IsRemoteTest()); | 945 DCHECK(IsRemoteTest()); |
| 944 DCHECK(task_runner_provider()->IsMainThread() || | 946 DCHECK(task_runner_provider()->IsMainThread() || |
| 945 task_runner_provider()->IsMainThreadBlocked()); | 947 task_runner_provider()->IsMainThreadBlocked()); |
| 946 return remote_client_layer_tree_host_.get(); | 948 return remote_client_layer_tree_host_.get(); |
| 947 } | 949 } |
| 948 | 950 |
| 949 } // namespace cc | 951 } // namespace cc |
| OLD | NEW |