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" |
11 #include "base/single_thread_task_runner.h" | 11 #include "base/single_thread_task_runner.h" |
12 #include "base/threading/thread_task_runner_handle.h" | 12 #include "base/threading/thread_task_runner_handle.h" |
13 #include "cc/animation/animation.h" | 13 #include "cc/animation/animation.h" |
14 #include "cc/animation/animation_host.h" | 14 #include "cc/animation/animation_host.h" |
15 #include "cc/animation/element_animations.h" | 15 #include "cc/animation/element_animations.h" |
16 #include "cc/animation/timing_function.h" | 16 #include "cc/animation/timing_function.h" |
17 #include "cc/base/switches.h" | 17 #include "cc/base/switches.h" |
18 #include "cc/blimp/image_serialization_processor.h" | 18 #include "cc/blimp/image_serialization_processor.h" |
19 #include "cc/input/input_handler.h" | 19 #include "cc/input/input_handler.h" |
20 #include "cc/layers/layer.h" | 20 #include "cc/layers/layer.h" |
21 #include "cc/layers/layer_impl.h" | 21 #include "cc/layers/layer_impl.h" |
22 #include "cc/output/buffer_to_texture_target_map.h" | 22 #include "cc/output/buffer_to_texture_target_map.h" |
23 #include "cc/proto/compositor_message_to_impl.pb.h" | 23 #include "cc/proto/compositor_message_to_impl.pb.h" |
24 #include "cc/test/animation_test_common.h" | 24 #include "cc/test/animation_test_common.h" |
25 #include "cc/test/begin_frame_args_test.h" | 25 #include "cc/test/begin_frame_args_test.h" |
26 #include "cc/test/fake_external_begin_frame_source.h" | |
danakj
2016/09/20 18:19:21
Can you move the impl of this to the one test that
enne (OOO)
2016/09/20 18:34:26
Will punt. This is used in scheduler_unittest and
| |
27 #include "cc/test/fake_image_serialization_processor.h" | 26 #include "cc/test/fake_image_serialization_processor.h" |
28 #include "cc/test/fake_layer_tree_host_client.h" | 27 #include "cc/test/fake_layer_tree_host_client.h" |
29 #include "cc/test/fake_output_surface.h" | 28 #include "cc/test/fake_output_surface.h" |
30 #include "cc/test/test_compositor_frame_sink.h" | 29 #include "cc/test/test_compositor_frame_sink.h" |
31 #include "cc/test/test_context_provider.h" | 30 #include "cc/test/test_context_provider.h" |
32 #include "cc/test/test_shared_bitmap_manager.h" | 31 #include "cc/test/test_shared_bitmap_manager.h" |
33 #include "cc/trees/layer_tree_host_client.h" | 32 #include "cc/trees/layer_tree_host_client.h" |
34 #include "cc/trees/layer_tree_host_impl.h" | 33 #include "cc/trees/layer_tree_host_impl.h" |
35 #include "cc/trees/layer_tree_host_single_thread_client.h" | 34 #include "cc/trees/layer_tree_host_single_thread_client.h" |
36 #include "cc/trees/layer_tree_impl.h" | 35 #include "cc/trees/layer_tree_impl.h" |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
347 TestHooks* test_hooks, | 346 TestHooks* test_hooks, |
348 CompositorMode mode, | 347 CompositorMode mode, |
349 LayerTreeHostClientForTesting* client, | 348 LayerTreeHostClientForTesting* client, |
350 RemoteProtoChannel* remote_proto_channel, | 349 RemoteProtoChannel* remote_proto_channel, |
351 SharedBitmapManager* shared_bitmap_manager, | 350 SharedBitmapManager* shared_bitmap_manager, |
352 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | 351 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
353 TaskGraphRunner* task_graph_runner, | 352 TaskGraphRunner* task_graph_runner, |
354 const LayerTreeSettings& settings, | 353 const LayerTreeSettings& settings, |
355 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 354 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
356 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, | 355 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, |
357 std::unique_ptr<BeginFrameSource> external_begin_frame_source, | |
358 ImageSerializationProcessor* image_serialization_processor) { | 356 ImageSerializationProcessor* image_serialization_processor) { |
359 LayerTreeHostInProcess::InitParams params; | 357 LayerTreeHostInProcess::InitParams params; |
360 params.client = client; | 358 params.client = client; |
361 params.shared_bitmap_manager = shared_bitmap_manager; | 359 params.shared_bitmap_manager = shared_bitmap_manager; |
362 params.gpu_memory_buffer_manager = gpu_memory_buffer_manager; | 360 params.gpu_memory_buffer_manager = gpu_memory_buffer_manager; |
363 params.task_graph_runner = task_graph_runner; | 361 params.task_graph_runner = task_graph_runner; |
364 params.settings = &settings; | 362 params.settings = &settings; |
365 params.image_serialization_processor = image_serialization_processor; | 363 params.image_serialization_processor = image_serialization_processor; |
366 | 364 |
367 params.animation_host = | 365 params.animation_host = |
368 AnimationHost::CreateForTesting(ThreadInstance::MAIN); | 366 AnimationHost::CreateForTesting(ThreadInstance::MAIN); |
369 std::unique_ptr<LayerTreeHostForTesting> layer_tree_host( | 367 std::unique_ptr<LayerTreeHostForTesting> layer_tree_host( |
370 new LayerTreeHostForTesting(test_hooks, ¶ms, mode)); | 368 new LayerTreeHostForTesting(test_hooks, ¶ms, mode)); |
371 std::unique_ptr<TaskRunnerProvider> task_runner_provider = | 369 std::unique_ptr<TaskRunnerProvider> task_runner_provider = |
372 TaskRunnerProvider::Create(main_task_runner, impl_task_runner); | 370 TaskRunnerProvider::Create(main_task_runner, impl_task_runner); |
373 std::unique_ptr<Proxy> proxy; | 371 std::unique_ptr<Proxy> proxy; |
374 switch (mode) { | 372 switch (mode) { |
375 case CompositorMode::SINGLE_THREADED: | 373 case CompositorMode::SINGLE_THREADED: |
376 proxy = SingleThreadProxy::Create(layer_tree_host.get(), client, | 374 proxy = SingleThreadProxy::Create(layer_tree_host.get(), client, |
377 task_runner_provider.get()); | 375 task_runner_provider.get()); |
378 break; | 376 break; |
379 case CompositorMode::THREADED: | 377 case CompositorMode::THREADED: |
380 DCHECK(impl_task_runner.get()); | 378 DCHECK(impl_task_runner.get()); |
381 proxy = ProxyMain::CreateThreaded(layer_tree_host.get(), | 379 proxy = ProxyMain::CreateThreaded(layer_tree_host.get(), |
382 task_runner_provider.get()); | 380 task_runner_provider.get()); |
383 break; | 381 break; |
384 case CompositorMode::REMOTE: | 382 case CompositorMode::REMOTE: |
385 DCHECK(!external_begin_frame_source); | |
386 // The Remote LayerTreeHost on the client has the impl task runner. | 383 // The Remote LayerTreeHost on the client has the impl task runner. |
387 if (task_runner_provider->HasImplThread()) { | 384 if (task_runner_provider->HasImplThread()) { |
388 proxy = base::MakeUnique<RemoteChannelImpl>( | 385 proxy = base::MakeUnique<RemoteChannelImpl>( |
389 layer_tree_host.get(), remote_proto_channel, | 386 layer_tree_host.get(), remote_proto_channel, |
390 task_runner_provider.get()); | 387 task_runner_provider.get()); |
391 } else { | 388 } else { |
392 proxy = ProxyMain::CreateRemote(remote_proto_channel, | 389 proxy = ProxyMain::CreateRemote(remote_proto_channel, |
393 layer_tree_host.get(), | 390 layer_tree_host.get(), |
394 task_runner_provider.get()); | 391 task_runner_provider.get()); |
395 } | 392 } |
396 break; | 393 break; |
397 } | 394 } |
398 layer_tree_host->InitializeForTesting( | 395 layer_tree_host->InitializeForTesting(std::move(task_runner_provider), |
399 std::move(task_runner_provider), std::move(proxy), | 396 std::move(proxy)); |
400 std::move(external_begin_frame_source)); | |
401 return layer_tree_host; | 397 return layer_tree_host; |
402 } | 398 } |
403 | 399 |
404 std::unique_ptr<LayerTreeHostImpl> CreateLayerTreeHostImpl( | 400 std::unique_ptr<LayerTreeHostImpl> CreateLayerTreeHostImpl( |
405 LayerTreeHostImplClient* host_impl_client) override { | 401 LayerTreeHostImplClient* host_impl_client) override { |
406 std::unique_ptr<LayerTreeHostImpl> host_impl = | 402 std::unique_ptr<LayerTreeHostImpl> host_impl = |
407 LayerTreeHostImplForTesting::Create( | 403 LayerTreeHostImplForTesting::Create( |
408 test_hooks_, GetSettings(), host_impl_client, | 404 test_hooks_, GetSettings(), host_impl_client, |
409 GetTaskRunnerProvider(), shared_bitmap_manager(), | 405 GetTaskRunnerProvider(), shared_bitmap_manager(), |
410 gpu_memory_buffer_manager(), task_graph_runner(), | 406 gpu_memory_buffer_manager(), task_graph_runner(), |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
629 void LayerTreeTest::DoBeginTest() { | 625 void LayerTreeTest::DoBeginTest() { |
630 client_ = LayerTreeHostClientForTesting::Create(this); | 626 client_ = LayerTreeHostClientForTesting::Create(this); |
631 | 627 |
632 DCHECK(!impl_thread_ || impl_thread_->task_runner().get()); | 628 DCHECK(!impl_thread_ || impl_thread_->task_runner().get()); |
633 | 629 |
634 if (IsRemoteTest()) { | 630 if (IsRemoteTest()) { |
635 DCHECK(impl_thread_); | 631 DCHECK(impl_thread_); |
636 layer_tree_host_ = LayerTreeHostForTesting::Create( | 632 layer_tree_host_ = LayerTreeHostForTesting::Create( |
637 this, mode_, client_.get(), &remote_proto_channel_bridge_.channel_main, | 633 this, mode_, client_.get(), &remote_proto_channel_bridge_.channel_main, |
638 nullptr, nullptr, task_graph_runner_.get(), settings_, | 634 nullptr, nullptr, task_graph_runner_.get(), settings_, |
639 base::ThreadTaskRunnerHandle::Get(), nullptr, nullptr, | 635 base::ThreadTaskRunnerHandle::Get(), nullptr, |
640 image_serialization_processor_.get()); | 636 image_serialization_processor_.get()); |
641 DCHECK(remote_proto_channel_bridge_.channel_main.HasReceiver()); | 637 DCHECK(remote_proto_channel_bridge_.channel_main.HasReceiver()); |
642 | 638 |
643 LayerTreeSettings settings = settings_; | 639 LayerTreeSettings settings = settings_; |
644 settings.abort_commit_before_compositor_frame_sink_creation = false; | 640 settings.abort_commit_before_compositor_frame_sink_creation = false; |
645 remote_client_layer_tree_host_ = LayerTreeHostForTesting::Create( | 641 remote_client_layer_tree_host_ = LayerTreeHostForTesting::Create( |
646 this, mode_, client_.get(), &remote_proto_channel_bridge_.channel_impl, | 642 this, mode_, client_.get(), &remote_proto_channel_bridge_.channel_impl, |
647 nullptr, nullptr, task_graph_runner_.get(), settings, | 643 nullptr, nullptr, task_graph_runner_.get(), settings, |
648 base::ThreadTaskRunnerHandle::Get(), impl_thread_->task_runner(), | 644 base::ThreadTaskRunnerHandle::Get(), impl_thread_->task_runner(), |
649 nullptr, image_serialization_processor_.get()); | 645 image_serialization_processor_.get()); |
650 DCHECK(remote_proto_channel_bridge_.channel_impl.HasReceiver()); | 646 DCHECK(remote_proto_channel_bridge_.channel_impl.HasReceiver()); |
651 } else { | 647 } else { |
652 layer_tree_host_ = LayerTreeHostForTesting::Create( | 648 layer_tree_host_ = LayerTreeHostForTesting::Create( |
653 this, mode_, client_.get(), nullptr, shared_bitmap_manager_.get(), | 649 this, mode_, client_.get(), nullptr, shared_bitmap_manager_.get(), |
654 gpu_memory_buffer_manager_.get(), task_graph_runner_.get(), settings_, | 650 gpu_memory_buffer_manager_.get(), task_graph_runner_.get(), settings_, |
655 base::ThreadTaskRunnerHandle::Get(), | 651 base::ThreadTaskRunnerHandle::Get(), |
656 impl_thread_ ? impl_thread_->task_runner() : nullptr, nullptr, | 652 impl_thread_ ? impl_thread_->task_runner() : nullptr, |
657 image_serialization_processor_.get()); | 653 image_serialization_processor_.get()); |
658 } | 654 } |
659 | 655 |
660 ASSERT_TRUE(layer_tree_host_); | 656 ASSERT_TRUE(layer_tree_host_); |
661 | 657 |
662 main_task_runner_ = | 658 main_task_runner_ = |
663 layer_tree_host_->GetTaskRunnerProvider()->MainThreadTaskRunner(); | 659 layer_tree_host_->GetTaskRunnerProvider()->MainThreadTaskRunner(); |
664 impl_task_runner_ = | 660 impl_task_runner_ = |
665 layer_tree_host_->GetTaskRunnerProvider()->ImplThreadTaskRunner(); | 661 layer_tree_host_->GetTaskRunnerProvider()->ImplThreadTaskRunner(); |
666 if (!impl_task_runner_) { | 662 if (!impl_task_runner_) { |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
815 // mocked out. | 811 // mocked out. |
816 settings_.renderer_settings.refresh_rate = 200.0; | 812 settings_.renderer_settings.refresh_rate = 200.0; |
817 settings_.background_animation_rate = 200.0; | 813 settings_.background_animation_rate = 200.0; |
818 // Disable latency recovery to make the scheduler more predictable in its | 814 // Disable latency recovery to make the scheduler more predictable in its |
819 // actions and less dependent on timings to make decisions. | 815 // actions and less dependent on timings to make decisions. |
820 settings_.enable_latency_recovery = false; | 816 settings_.enable_latency_recovery = false; |
821 settings_.verify_clip_tree_calculations = true; | 817 settings_.verify_clip_tree_calculations = true; |
822 settings_.verify_transform_tree_calculations = true; | 818 settings_.verify_transform_tree_calculations = true; |
823 settings_.renderer_settings.buffer_to_texture_target_map = | 819 settings_.renderer_settings.buffer_to_texture_target_map = |
824 DefaultBufferToTextureTargetMapForTesting(); | 820 DefaultBufferToTextureTargetMapForTesting(); |
825 // The TestCompositorFrameSink will provide a BeginFrameSource. | |
826 settings_.use_compositor_frame_sink_begin_frame_source = true; | |
827 InitializeSettings(&settings_); | 821 InitializeSettings(&settings_); |
828 DCHECK(settings_.use_compositor_frame_sink_begin_frame_source); | |
829 DCHECK(!settings_.use_external_begin_frame_source); | |
830 | 822 |
831 base::ThreadTaskRunnerHandle::Get()->PostTask( | 823 base::ThreadTaskRunnerHandle::Get()->PostTask( |
832 FROM_HERE, | 824 FROM_HERE, |
833 base::Bind(&LayerTreeTest::DoBeginTest, base::Unretained(this))); | 825 base::Bind(&LayerTreeTest::DoBeginTest, base::Unretained(this))); |
834 | 826 |
835 base::RunLoop().Run(); | 827 base::RunLoop().Run(); |
836 DestroyLayerTreeHost(); | 828 DestroyLayerTreeHost(); |
837 | 829 |
838 timeout_.Cancel(); | 830 timeout_.Cancel(); |
839 | 831 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
923 } | 915 } |
924 | 916 |
925 LayerTreeHost* LayerTreeTest::remote_client_layer_tree_host() { | 917 LayerTreeHost* LayerTreeTest::remote_client_layer_tree_host() { |
926 DCHECK(IsRemoteTest()); | 918 DCHECK(IsRemoteTest()); |
927 DCHECK(task_runner_provider()->IsMainThread() || | 919 DCHECK(task_runner_provider()->IsMainThread() || |
928 task_runner_provider()->IsMainThreadBlocked()); | 920 task_runner_provider()->IsMainThreadBlocked()); |
929 return remote_client_layer_tree_host_.get(); | 921 return remote_client_layer_tree_host_.get(); |
930 } | 922 } |
931 | 923 |
932 } // namespace cc | 924 } // namespace cc |
OLD | NEW |