| 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 17 matching lines...) Expand all Loading... |
| 28 #include "cc/test/fake_output_surface.h" | 28 #include "cc/test/fake_output_surface.h" |
| 29 #include "cc/test/test_compositor_frame_sink.h" | 29 #include "cc/test/test_compositor_frame_sink.h" |
| 30 #include "cc/test/test_context_provider.h" | 30 #include "cc/test/test_context_provider.h" |
| 31 #include "cc/test/test_shared_bitmap_manager.h" | 31 #include "cc/test/test_shared_bitmap_manager.h" |
| 32 #include "cc/trees/layer_tree_host_client.h" | 32 #include "cc/trees/layer_tree_host_client.h" |
| 33 #include "cc/trees/layer_tree_host_impl.h" | 33 #include "cc/trees/layer_tree_host_impl.h" |
| 34 #include "cc/trees/layer_tree_host_single_thread_client.h" | 34 #include "cc/trees/layer_tree_host_single_thread_client.h" |
| 35 #include "cc/trees/layer_tree_impl.h" | 35 #include "cc/trees/layer_tree_impl.h" |
| 36 #include "cc/trees/proxy_impl.h" | 36 #include "cc/trees/proxy_impl.h" |
| 37 #include "cc/trees/proxy_main.h" | 37 #include "cc/trees/proxy_main.h" |
| 38 #include "cc/trees/remote_channel_impl.h" | |
| 39 #include "cc/trees/single_thread_proxy.h" | 38 #include "cc/trees/single_thread_proxy.h" |
| 40 #include "cc/trees/threaded_channel.h" | 39 #include "cc/trees/threaded_channel.h" |
| 41 #include "testing/gmock/include/gmock/gmock.h" | 40 #include "testing/gmock/include/gmock/gmock.h" |
| 42 #include "ui/gfx/geometry/size_conversions.h" | 41 #include "ui/gfx/geometry/size_conversions.h" |
| 43 | 42 |
| 44 namespace cc { | 43 namespace cc { |
| 45 | 44 |
| 46 void CreateVirtualViewportLayers(Layer* root_layer, | 45 void CreateVirtualViewportLayers(Layer* root_layer, |
| 47 scoped_refptr<Layer> outer_scroll_layer, | 46 scoped_refptr<Layer> outer_scroll_layer, |
| 48 const gfx::Size& inner_bounds, | 47 const gfx::Size& inner_bounds, |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 TestHooks* test_hooks_; | 338 TestHooks* test_hooks_; |
| 340 }; | 339 }; |
| 341 | 340 |
| 342 // Adapts LayerTreeHost for test. Injects LayerTreeHostImplForTesting. | 341 // Adapts LayerTreeHost for test. Injects LayerTreeHostImplForTesting. |
| 343 class LayerTreeHostForTesting : public LayerTreeHostInProcess { | 342 class LayerTreeHostForTesting : public LayerTreeHostInProcess { |
| 344 public: | 343 public: |
| 345 static std::unique_ptr<LayerTreeHostForTesting> Create( | 344 static std::unique_ptr<LayerTreeHostForTesting> Create( |
| 346 TestHooks* test_hooks, | 345 TestHooks* test_hooks, |
| 347 CompositorMode mode, | 346 CompositorMode mode, |
| 348 LayerTreeHostClientForTesting* client, | 347 LayerTreeHostClientForTesting* client, |
| 349 RemoteProtoChannel* remote_proto_channel, | |
| 350 SharedBitmapManager* shared_bitmap_manager, | 348 SharedBitmapManager* shared_bitmap_manager, |
| 351 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | 349 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
| 352 TaskGraphRunner* task_graph_runner, | 350 TaskGraphRunner* task_graph_runner, |
| 353 const LayerTreeSettings& settings, | 351 const LayerTreeSettings& settings, |
| 354 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 352 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
| 355 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, | 353 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) { |
| 356 ImageSerializationProcessor* image_serialization_processor) { | |
| 357 LayerTreeHostInProcess::InitParams params; | 354 LayerTreeHostInProcess::InitParams params; |
| 358 params.client = client; | 355 params.client = client; |
| 359 params.shared_bitmap_manager = shared_bitmap_manager; | 356 params.shared_bitmap_manager = shared_bitmap_manager; |
| 360 params.gpu_memory_buffer_manager = gpu_memory_buffer_manager; | 357 params.gpu_memory_buffer_manager = gpu_memory_buffer_manager; |
| 361 params.task_graph_runner = task_graph_runner; | 358 params.task_graph_runner = task_graph_runner; |
| 362 params.settings = &settings; | 359 params.settings = &settings; |
| 363 params.image_serialization_processor = image_serialization_processor; | |
| 364 | 360 |
| 365 params.animation_host = | 361 params.animation_host = |
| 366 AnimationHost::CreateForTesting(ThreadInstance::MAIN); | 362 AnimationHost::CreateForTesting(ThreadInstance::MAIN); |
| 367 std::unique_ptr<LayerTreeHostForTesting> layer_tree_host( | 363 std::unique_ptr<LayerTreeHostForTesting> layer_tree_host( |
| 368 new LayerTreeHostForTesting(test_hooks, ¶ms, mode)); | 364 new LayerTreeHostForTesting(test_hooks, ¶ms, mode)); |
| 369 std::unique_ptr<TaskRunnerProvider> task_runner_provider = | 365 std::unique_ptr<TaskRunnerProvider> task_runner_provider = |
| 370 TaskRunnerProvider::Create(main_task_runner, impl_task_runner); | 366 TaskRunnerProvider::Create(main_task_runner, impl_task_runner); |
| 371 std::unique_ptr<Proxy> proxy; | 367 std::unique_ptr<Proxy> proxy; |
| 372 switch (mode) { | 368 switch (mode) { |
| 373 case CompositorMode::SINGLE_THREADED: | 369 case CompositorMode::SINGLE_THREADED: |
| 374 proxy = SingleThreadProxy::Create(layer_tree_host.get(), client, | 370 proxy = SingleThreadProxy::Create(layer_tree_host.get(), client, |
| 375 task_runner_provider.get()); | 371 task_runner_provider.get()); |
| 376 break; | 372 break; |
| 377 case CompositorMode::THREADED: | 373 case CompositorMode::THREADED: |
| 378 DCHECK(impl_task_runner.get()); | 374 DCHECK(impl_task_runner.get()); |
| 379 proxy = ProxyMain::CreateThreaded(layer_tree_host.get(), | 375 proxy = ProxyMain::CreateThreaded(layer_tree_host.get(), |
| 380 task_runner_provider.get()); | 376 task_runner_provider.get()); |
| 381 break; | 377 break; |
| 382 case CompositorMode::REMOTE: | 378 case CompositorMode::REMOTE: |
| 383 // The Remote LayerTreeHost on the client has the impl task runner. | 379 NOTREACHED(); |
| 384 if (task_runner_provider->HasImplThread()) { | |
| 385 proxy = base::MakeUnique<RemoteChannelImpl>( | |
| 386 layer_tree_host.get(), remote_proto_channel, | |
| 387 task_runner_provider.get()); | |
| 388 } else { | |
| 389 proxy = ProxyMain::CreateRemote(remote_proto_channel, | |
| 390 layer_tree_host.get(), | |
| 391 task_runner_provider.get()); | |
| 392 } | |
| 393 break; | |
| 394 } | 380 } |
| 395 layer_tree_host->InitializeForTesting(std::move(task_runner_provider), | 381 layer_tree_host->InitializeForTesting(std::move(task_runner_provider), |
| 396 std::move(proxy)); | 382 std::move(proxy)); |
| 397 return layer_tree_host; | 383 return layer_tree_host; |
| 398 } | 384 } |
| 399 | 385 |
| 400 std::unique_ptr<LayerTreeHostImpl> CreateLayerTreeHostImpl( | 386 std::unique_ptr<LayerTreeHostImpl> CreateLayerTreeHostImpl( |
| 401 LayerTreeHostImplClient* host_impl_client) override { | 387 LayerTreeHostImplClient* host_impl_client) override { |
| 402 std::unique_ptr<LayerTreeHostImpl> host_impl = | 388 std::unique_ptr<LayerTreeHostImpl> host_impl = |
| 403 LayerTreeHostImplForTesting::Create( | 389 LayerTreeHostImplForTesting::Create( |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 451 } | 437 } |
| 452 void DisplayDidDrawAndSwap() override { | 438 void DisplayDidDrawAndSwap() override { |
| 453 hooks_->DisplayDidDrawAndSwapOnThread(); | 439 hooks_->DisplayDidDrawAndSwapOnThread(); |
| 454 } | 440 } |
| 455 | 441 |
| 456 private: | 442 private: |
| 457 TestHooks* hooks_; | 443 TestHooks* hooks_; |
| 458 }; | 444 }; |
| 459 | 445 |
| 460 LayerTreeTest::LayerTreeTest() | 446 LayerTreeTest::LayerTreeTest() |
| 461 : image_serialization_processor_( | 447 : compositor_frame_sink_client_( |
| 462 base::WrapUnique(new FakeImageSerializationProcessor)), | |
| 463 compositor_frame_sink_client_( | |
| 464 new LayerTreeTestCompositorFrameSinkClient(this)), | 448 new LayerTreeTestCompositorFrameSinkClient(this)), |
| 465 weak_factory_(this) { | 449 weak_factory_(this) { |
| 466 main_thread_weak_ptr_ = weak_factory_.GetWeakPtr(); | 450 main_thread_weak_ptr_ = weak_factory_.GetWeakPtr(); |
| 467 | 451 |
| 468 // Tests should timeout quickly unless --cc-layer-tree-test-no-timeout was | 452 // Tests should timeout quickly unless --cc-layer-tree-test-no-timeout was |
| 469 // specified (for running in a debugger). | 453 // specified (for running in a debugger). |
| 470 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 454 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 471 if (!command_line->HasSwitch(switches::kCCLayerTreeTestNoTimeout)) | 455 if (!command_line->HasSwitch(switches::kCCLayerTreeTestNoTimeout)) |
| 472 timeout_seconds_ = 5; | 456 timeout_seconds_ = 5; |
| 473 if (command_line->HasSwitch(switches::kCCLayerTreeTestLongTimeout)) | 457 if (command_line->HasSwitch(switches::kCCLayerTreeTestLongTimeout)) |
| 474 timeout_seconds_ = 5 * 60; | 458 timeout_seconds_ = 5 * 60; |
| 475 } | 459 } |
| 476 | 460 |
| 477 LayerTreeTest::~LayerTreeTest() {} | 461 LayerTreeTest::~LayerTreeTest() {} |
| 478 | 462 |
| 479 Proxy* LayerTreeTest::remote_client_proxy() const { | |
| 480 DCHECK(IsRemoteTest()); | |
| 481 return remote_client_layer_tree_host_ | |
| 482 ? remote_client_layer_tree_host_->proxy() | |
| 483 : nullptr; | |
| 484 } | |
| 485 | |
| 486 bool LayerTreeTest::IsRemoteTest() const { | 463 bool LayerTreeTest::IsRemoteTest() const { |
| 487 return mode_ == CompositorMode::REMOTE; | 464 return mode_ == CompositorMode::REMOTE; |
| 488 } | 465 } |
| 489 | 466 |
| 490 gfx::Vector2dF LayerTreeTest::ScrollDelta(LayerImpl* layer_impl) { | 467 gfx::Vector2dF LayerTreeTest::ScrollDelta(LayerImpl* layer_impl) { |
| 491 gfx::ScrollOffset delta = | 468 gfx::ScrollOffset delta = |
| 492 layer_impl->layer_tree_impl() | 469 layer_impl->layer_tree_impl() |
| 493 ->property_trees() | 470 ->property_trees() |
| 494 ->scroll_tree.GetScrollOffsetDeltaForTesting(layer_impl->id()); | 471 ->scroll_tree.GetScrollOffsetDeltaForTesting(layer_impl->id()); |
| 495 return gfx::Vector2dF(delta.x(), delta.y()); | 472 return gfx::Vector2dF(delta.x(), delta.y()); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 595 | 572 |
| 596 void LayerTreeTest::PostNextCommitWaitsForActivationToMainThread() { | 573 void LayerTreeTest::PostNextCommitWaitsForActivationToMainThread() { |
| 597 main_task_runner_->PostTask( | 574 main_task_runner_->PostTask( |
| 598 FROM_HERE, | 575 FROM_HERE, |
| 599 base::Bind(&LayerTreeTest::DispatchNextCommitWaitsForActivation, | 576 base::Bind(&LayerTreeTest::DispatchNextCommitWaitsForActivation, |
| 600 main_thread_weak_ptr_)); | 577 main_thread_weak_ptr_)); |
| 601 } | 578 } |
| 602 | 579 |
| 603 std::unique_ptr<CompositorFrameSink> | 580 std::unique_ptr<CompositorFrameSink> |
| 604 LayerTreeTest::ReleaseCompositorFrameSinkOnLayerTreeHost() { | 581 LayerTreeTest::ReleaseCompositorFrameSinkOnLayerTreeHost() { |
| 605 if (IsRemoteTest()) { | |
| 606 DCHECK(remote_client_layer_tree_host_); | |
| 607 return remote_client_layer_tree_host_->ReleaseCompositorFrameSink(); | |
| 608 } | |
| 609 return layer_tree_host_->ReleaseCompositorFrameSink(); | 582 return layer_tree_host_->ReleaseCompositorFrameSink(); |
| 610 } | 583 } |
| 611 | 584 |
| 612 void LayerTreeTest::SetVisibleOnLayerTreeHost(bool visible) { | 585 void LayerTreeTest::SetVisibleOnLayerTreeHost(bool visible) { |
| 613 layer_tree_host_->SetVisible(visible); | 586 layer_tree_host_->SetVisible(visible); |
| 614 | |
| 615 if (IsRemoteTest()) { | |
| 616 DCHECK(remote_client_layer_tree_host_); | |
| 617 remote_client_layer_tree_host_->SetVisible(visible); | |
| 618 } | |
| 619 } | 587 } |
| 620 | 588 |
| 621 void LayerTreeTest::WillBeginTest() { | 589 void LayerTreeTest::WillBeginTest() { |
| 622 SetVisibleOnLayerTreeHost(true); | 590 SetVisibleOnLayerTreeHost(true); |
| 623 } | 591 } |
| 624 | 592 |
| 625 void LayerTreeTest::DoBeginTest() { | 593 void LayerTreeTest::DoBeginTest() { |
| 626 client_ = LayerTreeHostClientForTesting::Create(this); | 594 client_ = LayerTreeHostClientForTesting::Create(this); |
| 627 | 595 |
| 628 DCHECK(!impl_thread_ || impl_thread_->task_runner().get()); | 596 DCHECK(!impl_thread_ || impl_thread_->task_runner().get()); |
| 629 | 597 layer_tree_host_ = LayerTreeHostForTesting::Create( |
| 630 if (IsRemoteTest()) { | 598 this, mode_, client_.get(), shared_bitmap_manager_.get(), |
| 631 DCHECK(impl_thread_); | 599 gpu_memory_buffer_manager_.get(), task_graph_runner_.get(), settings_, |
| 632 layer_tree_host_ = LayerTreeHostForTesting::Create( | 600 base::ThreadTaskRunnerHandle::Get(), |
| 633 this, mode_, client_.get(), &remote_proto_channel_bridge_.channel_main, | 601 impl_thread_ ? impl_thread_->task_runner() : nullptr); |
| 634 nullptr, nullptr, task_graph_runner_.get(), settings_, | |
| 635 base::ThreadTaskRunnerHandle::Get(), nullptr, | |
| 636 image_serialization_processor_.get()); | |
| 637 DCHECK(remote_proto_channel_bridge_.channel_main.HasReceiver()); | |
| 638 | |
| 639 LayerTreeSettings settings = settings_; | |
| 640 settings.abort_commit_before_compositor_frame_sink_creation = false; | |
| 641 remote_client_layer_tree_host_ = LayerTreeHostForTesting::Create( | |
| 642 this, mode_, client_.get(), &remote_proto_channel_bridge_.channel_impl, | |
| 643 nullptr, nullptr, task_graph_runner_.get(), settings, | |
| 644 base::ThreadTaskRunnerHandle::Get(), impl_thread_->task_runner(), | |
| 645 image_serialization_processor_.get()); | |
| 646 DCHECK(remote_proto_channel_bridge_.channel_impl.HasReceiver()); | |
| 647 } else { | |
| 648 layer_tree_host_ = LayerTreeHostForTesting::Create( | |
| 649 this, mode_, client_.get(), nullptr, shared_bitmap_manager_.get(), | |
| 650 gpu_memory_buffer_manager_.get(), task_graph_runner_.get(), settings_, | |
| 651 base::ThreadTaskRunnerHandle::Get(), | |
| 652 impl_thread_ ? impl_thread_->task_runner() : nullptr, | |
| 653 image_serialization_processor_.get()); | |
| 654 } | |
| 655 | 602 |
| 656 ASSERT_TRUE(layer_tree_host_); | 603 ASSERT_TRUE(layer_tree_host_); |
| 657 | 604 |
| 658 main_task_runner_ = | 605 main_task_runner_ = |
| 659 layer_tree_host_->GetTaskRunnerProvider()->MainThreadTaskRunner(); | 606 layer_tree_host_->GetTaskRunnerProvider()->MainThreadTaskRunner(); |
| 660 impl_task_runner_ = | 607 impl_task_runner_ = |
| 661 layer_tree_host_->GetTaskRunnerProvider()->ImplThreadTaskRunner(); | 608 layer_tree_host_->GetTaskRunnerProvider()->ImplThreadTaskRunner(); |
| 662 if (!impl_task_runner_) { | 609 if (!impl_task_runner_) { |
| 663 // For tests, if there's no impl thread, make things easier by just giving | 610 // For tests, if there's no impl thread, make things easier by just giving |
| 664 // the main thread task runner. | 611 // the main thread task runner. |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 704 } | 651 } |
| 705 | 652 |
| 706 void LayerTreeTest::Timeout() { | 653 void LayerTreeTest::Timeout() { |
| 707 timed_out_ = true; | 654 timed_out_ = true; |
| 708 EndTest(); | 655 EndTest(); |
| 709 } | 656 } |
| 710 | 657 |
| 711 void LayerTreeTest::RealEndTest() { | 658 void LayerTreeTest::RealEndTest() { |
| 712 // TODO(mithro): Make this method only end when not inside an impl frame. | 659 // TODO(mithro): Make this method only end when not inside an impl frame. |
| 713 bool main_frame_will_happen; | 660 bool main_frame_will_happen; |
| 714 if (IsRemoteTest()) { | |
| 715 main_frame_will_happen = | |
| 716 remote_client_layer_tree_host_ | |
| 717 ? remote_client_proxy()->MainFrameWillHappenForTesting() | |
| 718 : false; | |
| 719 } else { | |
| 720 main_frame_will_happen = | 661 main_frame_will_happen = |
| 721 layer_tree_host_ ? proxy()->MainFrameWillHappenForTesting() : false; | 662 layer_tree_host_ ? proxy()->MainFrameWillHappenForTesting() : false; |
| 722 } | |
| 723 | 663 |
| 724 if (main_frame_will_happen && !timed_out_) { | 664 if (main_frame_will_happen && !timed_out_) { |
| 725 main_task_runner_->PostTask( | 665 main_task_runner_->PostTask( |
| 726 FROM_HERE, | 666 FROM_HERE, |
| 727 base::Bind(&LayerTreeTest::RealEndTest, main_thread_weak_ptr_)); | 667 base::Bind(&LayerTreeTest::RealEndTest, main_thread_weak_ptr_)); |
| 728 return; | 668 return; |
| 729 } | 669 } |
| 730 | 670 |
| 731 base::MessageLoop::current()->QuitWhenIdle(); | 671 base::MessageLoop::current()->QuitWhenIdle(); |
| 732 } | 672 } |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 841 void LayerTreeTest::RequestNewCompositorFrameSink() { | 781 void LayerTreeTest::RequestNewCompositorFrameSink() { |
| 842 scoped_refptr<TestContextProvider> shared_context_provider = | 782 scoped_refptr<TestContextProvider> shared_context_provider = |
| 843 TestContextProvider::Create(); | 783 TestContextProvider::Create(); |
| 844 scoped_refptr<TestContextProvider> worker_context_provider = | 784 scoped_refptr<TestContextProvider> worker_context_provider = |
| 845 TestContextProvider::CreateWorker(); | 785 TestContextProvider::CreateWorker(); |
| 846 | 786 |
| 847 auto compositor_frame_sink = CreateCompositorFrameSink( | 787 auto compositor_frame_sink = CreateCompositorFrameSink( |
| 848 std::move(shared_context_provider), std::move(worker_context_provider)); | 788 std::move(shared_context_provider), std::move(worker_context_provider)); |
| 849 compositor_frame_sink->SetClient(compositor_frame_sink_client_.get()); | 789 compositor_frame_sink->SetClient(compositor_frame_sink_client_.get()); |
| 850 | 790 |
| 851 if (IsRemoteTest()) { | |
| 852 DCHECK(remote_client_layer_tree_host_); | |
| 853 remote_client_layer_tree_host_->SetCompositorFrameSink( | |
| 854 std::move(compositor_frame_sink)); | |
| 855 } else { | |
| 856 layer_tree_host_->SetCompositorFrameSink(std::move(compositor_frame_sink)); | 791 layer_tree_host_->SetCompositorFrameSink(std::move(compositor_frame_sink)); |
| 857 } | |
| 858 } | 792 } |
| 859 | 793 |
| 860 std::unique_ptr<TestCompositorFrameSink> | 794 std::unique_ptr<TestCompositorFrameSink> |
| 861 LayerTreeTest::CreateCompositorFrameSink( | 795 LayerTreeTest::CreateCompositorFrameSink( |
| 862 scoped_refptr<ContextProvider> compositor_context_provider, | 796 scoped_refptr<ContextProvider> compositor_context_provider, |
| 863 scoped_refptr<ContextProvider> worker_context_provider) { | 797 scoped_refptr<ContextProvider> worker_context_provider) { |
| 864 bool synchronous_composite = | 798 bool synchronous_composite = |
| 865 !HasImplThread() && | 799 !HasImplThread() && |
| 866 !layer_tree_host()->GetSettings().single_thread_proxy_scheduler; | 800 !layer_tree_host()->GetSettings().single_thread_proxy_scheduler; |
| 867 // Disable reclaim resources by default to act like the Display lives | 801 // Disable reclaim resources by default to act like the Display lives |
| (...skipping 11 matching lines...) Expand all Loading... |
| 879 std::unique_ptr<OutputSurface> LayerTreeTest::CreateDisplayOutputSurface( | 813 std::unique_ptr<OutputSurface> LayerTreeTest::CreateDisplayOutputSurface( |
| 880 scoped_refptr<ContextProvider> compositor_context_provider) { | 814 scoped_refptr<ContextProvider> compositor_context_provider) { |
| 881 // By default the Display shares a context with the LayerTreeHostImpl. | 815 // By default the Display shares a context with the LayerTreeHostImpl. |
| 882 return FakeOutputSurface::Create3d(std::move(compositor_context_provider)); | 816 return FakeOutputSurface::Create3d(std::move(compositor_context_provider)); |
| 883 } | 817 } |
| 884 | 818 |
| 885 void LayerTreeTest::DestroyLayerTreeHost() { | 819 void LayerTreeTest::DestroyLayerTreeHost() { |
| 886 if (layer_tree_host_ && layer_tree_host_->GetLayerTree()->root_layer()) | 820 if (layer_tree_host_ && layer_tree_host_->GetLayerTree()->root_layer()) |
| 887 layer_tree_host_->GetLayerTree()->root_layer()->SetLayerTreeHost(NULL); | 821 layer_tree_host_->GetLayerTree()->root_layer()->SetLayerTreeHost(NULL); |
| 888 layer_tree_host_ = nullptr; | 822 layer_tree_host_ = nullptr; |
| 889 | |
| 890 DCHECK(!remote_proto_channel_bridge_.channel_main.HasReceiver()); | |
| 891 | |
| 892 remote_client_layer_tree_host_ = nullptr; | |
| 893 DCHECK(!remote_proto_channel_bridge_.channel_impl.HasReceiver()); | |
| 894 } | 823 } |
| 895 | 824 |
| 896 TaskRunnerProvider* LayerTreeTest::task_runner_provider() const { | 825 TaskRunnerProvider* LayerTreeTest::task_runner_provider() const { |
| 897 // All LayerTreeTests can use the task runner provider to access the impl | 826 LayerTreeHost* host = layer_tree_host_.get(); |
| 898 // thread. In the remote mode, the impl thread of the compositor lives on | |
| 899 // the client, so return the task runner provider owned by the remote client | |
| 900 // LayerTreeHost. | |
| 901 LayerTreeHost* host = IsRemoteTest() ? remote_client_layer_tree_host_.get() | |
| 902 : layer_tree_host_.get(); | |
| 903 | 827 |
| 904 // If this fails, the test has ended and there is no task runners to find | 828 // If this fails, the test has ended and there is no task runners to find |
| 905 // anymore. | 829 // anymore. |
| 906 DCHECK(host); | 830 DCHECK(host); |
| 907 | 831 |
| 908 return host->GetTaskRunnerProvider(); | 832 return host->GetTaskRunnerProvider(); |
| 909 } | 833 } |
| 910 | 834 |
| 911 LayerTreeHostInProcess* LayerTreeTest::layer_tree_host() { | 835 LayerTreeHostInProcess* LayerTreeTest::layer_tree_host() { |
| 912 DCHECK(task_runner_provider()->IsMainThread() || | 836 DCHECK(task_runner_provider()->IsMainThread() || |
| 913 task_runner_provider()->IsMainThreadBlocked()); | 837 task_runner_provider()->IsMainThreadBlocked()); |
| 914 return layer_tree_host_.get(); | 838 return layer_tree_host_.get(); |
| 915 } | 839 } |
| 916 | 840 |
| 917 LayerTreeHost* LayerTreeTest::remote_client_layer_tree_host() { | |
| 918 DCHECK(IsRemoteTest()); | |
| 919 DCHECK(task_runner_provider()->IsMainThread() || | |
| 920 task_runner_provider()->IsMainThreadBlocked()); | |
| 921 return remote_client_layer_tree_host_.get(); | |
| 922 } | |
| 923 | |
| 924 } // namespace cc | 841 } // namespace cc |
| OLD | NEW |