Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(308)

Side by Side Diff: cc/test/layer_tree_test.cc

Issue 1513643010: cc:: Add remote mode to the compositor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/single_thread_task_runner.h" 9 #include "base/single_thread_task_runner.h"
10 #include "base/thread_task_runner_handle.h" 10 #include "base/thread_task_runner_handle.h"
11 #include "cc/animation/animation.h" 11 #include "cc/animation/animation.h"
12 #include "cc/animation/animation_host.h" 12 #include "cc/animation/animation_host.h"
13 #include "cc/animation/animation_registrar.h" 13 #include "cc/animation/animation_registrar.h"
14 #include "cc/animation/layer_animation_controller.h" 14 #include "cc/animation/layer_animation_controller.h"
15 #include "cc/animation/timing_function.h" 15 #include "cc/animation/timing_function.h"
16 #include "cc/base/switches.h" 16 #include "cc/base/switches.h"
17 #include "cc/input/input_handler.h" 17 #include "cc/input/input_handler.h"
18 #include "cc/layers/layer.h" 18 #include "cc/layers/layer.h"
19 #include "cc/layers/layer_impl.h" 19 #include "cc/layers/layer_impl.h"
20 #include "cc/test/animation_test_common.h" 20 #include "cc/test/animation_test_common.h"
21 #include "cc/test/begin_frame_args_test.h" 21 #include "cc/test/begin_frame_args_test.h"
22 #include "cc/test/fake_external_begin_frame_source.h" 22 #include "cc/test/fake_external_begin_frame_source.h"
23 #include "cc/test/fake_layer_tree_host_client.h" 23 #include "cc/test/fake_layer_tree_host_client.h"
24 #include "cc/test/fake_output_surface.h" 24 #include "cc/test/fake_output_surface.h"
25 #include "cc/test/remote_channel_impl_for_test.h"
25 #include "cc/test/test_context_provider.h" 26 #include "cc/test/test_context_provider.h"
26 #include "cc/test/test_gpu_memory_buffer_manager.h" 27 #include "cc/test/test_gpu_memory_buffer_manager.h"
27 #include "cc/test/test_shared_bitmap_manager.h" 28 #include "cc/test/test_shared_bitmap_manager.h"
28 #include "cc/test/test_task_graph_runner.h" 29 #include "cc/test/test_task_graph_runner.h"
29 #include "cc/trees/layer_tree_host_client.h" 30 #include "cc/trees/layer_tree_host_client.h"
30 #include "cc/trees/layer_tree_host_impl.h" 31 #include "cc/trees/layer_tree_host_impl.h"
31 #include "cc/trees/layer_tree_host_single_thread_client.h" 32 #include "cc/trees/layer_tree_host_single_thread_client.h"
32 #include "cc/trees/layer_tree_impl.h" 33 #include "cc/trees/layer_tree_impl.h"
33 #include "cc/trees/proxy_impl.h" 34 #include "cc/trees/proxy_impl.h"
34 #include "cc/trees/proxy_main.h" 35 #include "cc/trees/proxy_main.h"
36 #include "cc/trees/remote_channel_host.h"
37 #include "cc/trees/remote_channel_host_client.h"
35 #include "cc/trees/single_thread_proxy.h" 38 #include "cc/trees/single_thread_proxy.h"
36 #include "cc/trees/threaded_channel.h" 39 #include "cc/trees/threaded_channel.h"
37 #include "testing/gmock/include/gmock/gmock.h" 40 #include "testing/gmock/include/gmock/gmock.h"
38 #include "ui/gfx/geometry/size_conversions.h" 41 #include "ui/gfx/geometry/size_conversions.h"
39 42
40 namespace cc { 43 namespace cc {
41 44
42 void CreateVirtualViewportLayers(Layer* root_layer, 45 void CreateVirtualViewportLayers(Layer* root_layer,
43 scoped_refptr<Layer> outer_scroll_layer, 46 scoped_refptr<Layer> outer_scroll_layer,
44 const gfx::Size& inner_bounds, 47 const gfx::Size& inner_bounds,
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 LayerTreeHostImpl::NotifyTileStateChanged(tile); 346 LayerTreeHostImpl::NotifyTileStateChanged(tile);
344 test_hooks_->NotifyTileStateChangedOnThread(this, tile); 347 test_hooks_->NotifyTileStateChangedOnThread(this, tile);
345 } 348 }
346 349
347 private: 350 private:
348 TestHooks* test_hooks_; 351 TestHooks* test_hooks_;
349 bool block_notify_ready_to_activate_for_testing_; 352 bool block_notify_ready_to_activate_for_testing_;
350 bool notify_ready_to_activate_was_blocked_; 353 bool notify_ready_to_activate_was_blocked_;
351 }; 354 };
352 355
356 // Implementation of RemoteChannelHostClient for tests.
357 class RemoteChannelHostClientForTesting : public RemoteChannelHostClient {
358 public:
359 static scoped_ptr<RemoteChannelHostClientForTesting> Create(
360 TestHooks* test_hooks) {
361 return make_scoped_ptr(new RemoteChannelHostClientForTesting(test_hooks));
362 }
363
364 void OverrideLayerTreeSettings(LayerTreeSettings* settings) override {
365 test_hooks_->OverrideLayerTreeSettings(settings);
366 }
367
368 void DidShutdown() override { test_hooks_->DidShutdown(); }
369
370 private:
371 explicit RemoteChannelHostClientForTesting(TestHooks* test_hooks)
372 : test_hooks_(test_hooks) {}
373
374 TestHooks* test_hooks_;
375 };
376
353 // Implementation of LayerTreeHost callback interface. 377 // Implementation of LayerTreeHost callback interface.
354 class LayerTreeHostClientForTesting : public LayerTreeHostClient, 378 class LayerTreeHostClientForTesting : public LayerTreeHostClient,
355 public LayerTreeHostSingleThreadClient { 379 public LayerTreeHostSingleThreadClient {
356 public: 380 public:
357 static scoped_ptr<LayerTreeHostClientForTesting> Create( 381 static scoped_ptr<LayerTreeHostClientForTesting> Create(
358 TestHooks* test_hooks) { 382 TestHooks* test_hooks) {
359 return make_scoped_ptr(new LayerTreeHostClientForTesting(test_hooks)); 383 return make_scoped_ptr(new LayerTreeHostClientForTesting(test_hooks));
360 } 384 }
361 ~LayerTreeHostClientForTesting() override {} 385 ~LayerTreeHostClientForTesting() override {}
362 386
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) 446 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events)
423 override {} 447 override {}
424 448
425 private: 449 private:
426 explicit LayerTreeHostClientForTesting(TestHooks* test_hooks) 450 explicit LayerTreeHostClientForTesting(TestHooks* test_hooks)
427 : test_hooks_(test_hooks) {} 451 : test_hooks_(test_hooks) {}
428 452
429 TestHooks* test_hooks_; 453 TestHooks* test_hooks_;
430 }; 454 };
431 455
456 // Injects RemoteChannelImplForTesting.
457 class RemoteChannelHostForTesting : public RemoteChannelHost {
458 public:
459 static scoped_ptr<RemoteChannelHostForTesting> Create(
460 TestHooks* test_hooks,
461 RemoteProtoChannel* remote_proto_channel,
462 RemoteChannelHostClient* client,
463 TaskGraphRunner* task_graph_runner,
464 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
465 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) {
466 return make_scoped_ptr(new RemoteChannelHostForTesting(
467 test_hooks, remote_proto_channel, client, task_graph_runner,
468 main_task_runner, impl_task_runner));
469 }
470
471 RemoteChannelImplForTest* remote_channel_impl_for_test() const {
472 return remote_channel_impl_for_test_;
473 }
474
475 private:
476 RemoteChannelHostForTesting(
477 TestHooks* test_hooks,
478 RemoteProtoChannel* remote_proto_channel,
479 RemoteChannelHostClient* client,
480 TaskGraphRunner* task_graph_runner,
481 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
482 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner)
483 : RemoteChannelHost(remote_proto_channel,
484 client,
485 task_graph_runner,
486 main_task_runner,
487 impl_task_runner),
488 test_hooks_(test_hooks) {}
489
490 scoped_ptr<RemoteChannelImpl> CreateRemoteChannelImpl(
491 RemoteChannelHost* remote_channel_host,
492 TaskGraphRunner* task_graph_runner,
493 const LayerTreeSettings& settings,
494 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
495 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) override {
496 scoped_ptr<RemoteChannelImplForTest> channel_impl =
497 RemoteChannelImplForTest::Create(test_hooks_, remote_channel_host,
498 task_graph_runner, settings,
499 main_task_runner, impl_task_runner);
500 remote_channel_impl_for_test_ = channel_impl.get();
501 return std::move(channel_impl);
502 }
503
504 TestHooks* test_hooks_;
505 RemoteChannelImplForTest* remote_channel_impl_for_test_;
506 };
507
432 // Adapts LayerTreeHost for test. Injects LayerTreeHostImplForTesting. 508 // Adapts LayerTreeHost for test. Injects LayerTreeHostImplForTesting.
433 class LayerTreeHostForTesting : public LayerTreeHost { 509 class LayerTreeHostForTesting : public LayerTreeHost {
434 public: 510 public:
435 static scoped_ptr<LayerTreeHostForTesting> Create( 511 static scoped_ptr<LayerTreeHostForTesting> Create(
436 TestHooks* test_hooks, 512 TestHooks* test_hooks,
437 CompositorMode mode, 513 CompositorMode mode,
438 LayerTreeHostClientForTesting* client, 514 LayerTreeHostClientForTesting* client,
515 RemoteProtoChannel* remote_proto_channel,
439 SharedBitmapManager* shared_bitmap_manager, 516 SharedBitmapManager* shared_bitmap_manager,
440 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, 517 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager,
441 TaskGraphRunner* task_graph_runner, 518 TaskGraphRunner* task_graph_runner,
442 const LayerTreeSettings& settings, 519 const LayerTreeSettings& settings,
443 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, 520 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
444 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, 521 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner,
445 scoped_ptr<BeginFrameSource> external_begin_frame_source) { 522 scoped_ptr<BeginFrameSource> external_begin_frame_source) {
446 LayerTreeHost::InitParams params; 523 LayerTreeHost::InitParams params;
447 params.client = client; 524 params.client = client;
448 params.shared_bitmap_manager = shared_bitmap_manager; 525 params.shared_bitmap_manager = shared_bitmap_manager;
449 params.gpu_memory_buffer_manager = gpu_memory_buffer_manager; 526 params.gpu_memory_buffer_manager = gpu_memory_buffer_manager;
450 params.task_graph_runner = task_graph_runner; 527 params.task_graph_runner = task_graph_runner;
451 params.settings = &settings; 528 params.settings = &settings;
452 scoped_ptr<LayerTreeHostForTesting> layer_tree_host( 529 scoped_ptr<LayerTreeHostForTesting> layer_tree_host(
453 new LayerTreeHostForTesting(test_hooks, &params, mode)); 530 new LayerTreeHostForTesting(test_hooks, &params, mode));
454 scoped_ptr<TaskRunnerProvider> task_runner_provider = 531 scoped_ptr<TaskRunnerProvider> task_runner_provider =
455 TaskRunnerProvider::Create(main_task_runner, impl_task_runner); 532 TaskRunnerProvider::Create(main_task_runner, impl_task_runner);
456 scoped_ptr<Proxy> proxy; 533 scoped_ptr<Proxy> proxy;
457 if (mode == CompositorMode::Threaded) { 534 switch (mode) {
458 DCHECK(impl_task_runner.get()); 535 case CompositorMode::SingleThreaded:
459 scoped_ptr<ProxyMain> proxy_main = ProxyMainForTest::CreateThreaded( 536 proxy = SingleThreadProxyForTest::Create(
460 test_hooks, layer_tree_host.get(), task_runner_provider.get(), 537 test_hooks, layer_tree_host.get(), client,
461 std::move(external_begin_frame_source)); 538 task_runner_provider.get(), std::move(external_begin_frame_source));
462 proxy = std::move(proxy_main); 539 break;
463 } else { 540 case CompositorMode::Threaded:
464 proxy = SingleThreadProxyForTest::Create( 541 DCHECK(impl_task_runner.get());
465 test_hooks, layer_tree_host.get(), client, task_runner_provider.get(), 542 {
466 std::move(external_begin_frame_source)); 543 scoped_ptr<ProxyMain> proxy_main = ProxyMainForTest::CreateThreaded(
544 test_hooks, layer_tree_host.get(), task_runner_provider.get(),
545 std::move(external_begin_frame_source));
546 proxy = std::move(proxy_main);
547 }
548 break;
549 case CompositorMode::Remote:
550 DCHECK(!impl_task_runner.get());
551 DCHECK(!external_begin_frame_source);
552 {
553 scoped_ptr<ProxyMain> proxy_main = ProxyMainForTest::CreateRemote(
554 test_hooks, remote_proto_channel, layer_tree_host.get(),
555 task_runner_provider.get());
556 proxy = std::move(proxy_main);
557 }
558 break;
559 default:
560 NOTREACHED();
467 } 561 }
468 layer_tree_host->InitializeForTesting(std::move(task_runner_provider), 562 layer_tree_host->InitializeForTesting(std::move(task_runner_provider),
469 std::move(proxy)); 563 std::move(proxy));
470 return layer_tree_host; 564 return layer_tree_host;
471 } 565 }
472 566
473 scoped_ptr<LayerTreeHostImpl> CreateLayerTreeHostImpl( 567 scoped_ptr<LayerTreeHostImpl> CreateLayerTreeHostImpl(
474 LayerTreeHostImplClient* host_impl_client) override { 568 LayerTreeHostImplClient* host_impl_client) override {
475 return LayerTreeHostImplForTesting::Create( 569 return LayerTreeHostImplForTesting::Create(
476 test_hooks_, settings(), host_impl_client, task_runner_provider(), 570 test_hooks_, settings(), host_impl_client, task_runner_provider(),
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 615
522 // Tests should timeout quickly unless --cc-layer-tree-test-no-timeout was 616 // Tests should timeout quickly unless --cc-layer-tree-test-no-timeout was
523 // specified (for running in a debugger). 617 // specified (for running in a debugger).
524 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 618 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
525 if (!command_line->HasSwitch(switches::kCCLayerTreeTestNoTimeout)) 619 if (!command_line->HasSwitch(switches::kCCLayerTreeTestNoTimeout))
526 timeout_seconds_ = 5; 620 timeout_seconds_ = 5;
527 } 621 }
528 622
529 LayerTreeTest::~LayerTreeTest() {} 623 LayerTreeTest::~LayerTreeTest() {}
530 624
625 bool LayerTreeTest::IsRemoteTest() const {
626 return mode_ == CompositorMode::Remote;
627 }
628
531 void LayerTreeTest::EndTest() { 629 void LayerTreeTest::EndTest() {
532 if (ended_) 630 if (ended_)
533 return; 631 return;
534 ended_ = true; 632 ended_ = true;
535 633
536 // For the case where we EndTest during BeginTest(), set a flag to indicate 634 // For the case where we EndTest during BeginTest(), set a flag to indicate
537 // that the test should end the second BeginTest regains control. 635 // that the test should end the second BeginTest regains control.
538 if (beginning_) { 636 if (beginning_) {
539 end_when_begin_returns_ = true; 637 end_when_begin_returns_ = true;
540 } else { 638 } else {
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 client_ = LayerTreeHostClientForTesting::Create(this); 768 client_ = LayerTreeHostClientForTesting::Create(this);
671 769
672 scoped_ptr<FakeExternalBeginFrameSource> external_begin_frame_source; 770 scoped_ptr<FakeExternalBeginFrameSource> external_begin_frame_source;
673 if (settings_.use_external_begin_frame_source) { 771 if (settings_.use_external_begin_frame_source) {
674 external_begin_frame_source.reset(new FakeExternalBeginFrameSource( 772 external_begin_frame_source.reset(new FakeExternalBeginFrameSource(
675 settings_.renderer_settings.refresh_rate)); 773 settings_.renderer_settings.refresh_rate));
676 external_begin_frame_source_ = external_begin_frame_source.get(); 774 external_begin_frame_source_ = external_begin_frame_source.get();
677 } 775 }
678 776
679 DCHECK(!impl_thread_ || impl_thread_->task_runner().get()); 777 DCHECK(!impl_thread_ || impl_thread_->task_runner().get());
680 layer_tree_host_ = LayerTreeHostForTesting::Create( 778
681 this, mode_, client_.get(), shared_bitmap_manager_.get(), 779 if (IsRemoteTest()) {
682 gpu_memory_buffer_manager_.get(), task_graph_runner_.get(), settings_, 780 // It is important to create the RemoteChannelHost before the LayerTreeHost
683 base::ThreadTaskRunnerHandle::Get(), 781 // since the main compositor immediately sends an initialization message to
684 impl_thread_ ? impl_thread_->task_runner() : NULL, 782 // the impl compositor.
685 std::move(external_begin_frame_source)); 783 DCHECK(impl_thread_);
784 remote_channel_host_client_ =
785 RemoteChannelHostClientForTesting::Create(this);
786 remote_channel_host_for_testing_ = RemoteChannelHostForTesting::Create(
787 this, &remote_proto_channel_bridge_.channel_impl,
788 remote_channel_host_client_.get(), task_graph_runner_.get(),
789 base::ThreadTaskRunnerHandle::Get(), impl_thread_->task_runner());
790
791 layer_tree_host_ = LayerTreeHostForTesting::Create(
792 this, mode_, client_.get(), &remote_proto_channel_bridge_.channel_main,
793 nullptr, nullptr, task_graph_runner_.get(), settings_,
794 base::ThreadTaskRunnerHandle::Get(), nullptr,
795 std::move(external_begin_frame_source));
796 } else {
797 layer_tree_host_ = LayerTreeHostForTesting::Create(
798 this, mode_, client_.get(), nullptr, shared_bitmap_manager_.get(),
799 gpu_memory_buffer_manager_.get(), task_graph_runner_.get(), settings_,
800 base::ThreadTaskRunnerHandle::Get(),
801 impl_thread_ ? impl_thread_->task_runner() : NULL,
802 std::move(external_begin_frame_source));
803 }
804
686 ASSERT_TRUE(layer_tree_host_); 805 ASSERT_TRUE(layer_tree_host_);
687 806
688 started_ = true; 807 started_ = true;
689 beginning_ = true; 808 beginning_ = true;
690 SetupTree(); 809 SetupTree();
691 WillBeginTest(); 810 WillBeginTest();
692 BeginTest(); 811 BeginTest();
693 beginning_ = false; 812 beginning_ = false;
694 if (end_when_begin_returns_) 813 if (end_when_begin_returns_)
695 RealEndTest(); 814 RealEndTest();
(...skipping 20 matching lines...) Expand all
716 layer_tree_host_->root_layer()->SetIsDrawable(true); 835 layer_tree_host_->root_layer()->SetIsDrawable(true);
717 } 836 }
718 837
719 void LayerTreeTest::Timeout() { 838 void LayerTreeTest::Timeout() {
720 timed_out_ = true; 839 timed_out_ = true;
721 EndTest(); 840 EndTest();
722 } 841 }
723 842
724 void LayerTreeTest::RealEndTest() { 843 void LayerTreeTest::RealEndTest() {
725 // TODO(mithro): Make this method only end when not inside an impl frame. 844 // TODO(mithro): Make this method only end when not inside an impl frame.
726 if (layer_tree_host_ && !timed_out_ && 845 bool main_frame_will_happen;
727 proxy()->MainFrameWillHappenForTesting()) { 846 if (IsRemoteTest()) {
847 main_frame_will_happen =
848 remote_channel_host_for_testing_
849 ? GetRemoteChannelImplForTest()->MainFrameWillHappenForTesting()
850 : false;
851 } else {
852 main_frame_will_happen =
853 layer_tree_host_ ? proxy()->MainFrameWillHappenForTesting() : false;
854 }
855
856 if (main_frame_will_happen && !timed_out_) {
728 main_task_runner_->PostTask( 857 main_task_runner_->PostTask(
729 FROM_HERE, 858 FROM_HERE,
730 base::Bind(&LayerTreeTest::RealEndTest, main_thread_weak_ptr_)); 859 base::Bind(&LayerTreeTest::RealEndTest, main_thread_weak_ptr_));
731 return; 860 return;
732 } 861 }
733 862
734 base::MessageLoop::current()->QuitWhenIdle(); 863 base::MessageLoop::current()->QuitWhenIdle();
735 } 864 }
736 865
737 void LayerTreeTest::DispatchAddAnimation(Layer* layer_to_receive_animation, 866 void LayerTreeTest::DispatchAddAnimation(Layer* layer_to_receive_animation,
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
803 layer_tree_host_->SetNextCommitForcesRedraw(); 932 layer_tree_host_->SetNextCommitForcesRedraw();
804 } 933 }
805 934
806 void LayerTreeTest::DispatchCompositeImmediately() { 935 void LayerTreeTest::DispatchCompositeImmediately() {
807 DCHECK(!task_runner_provider() || task_runner_provider()->IsMainThread()); 936 DCHECK(!task_runner_provider() || task_runner_provider()->IsMainThread());
808 if (layer_tree_host_) 937 if (layer_tree_host_)
809 layer_tree_host_->Composite(base::TimeTicks::Now()); 938 layer_tree_host_->Composite(base::TimeTicks::Now());
810 } 939 }
811 940
812 void LayerTreeTest::RunTest(CompositorMode mode, bool delegating_renderer) { 941 void LayerTreeTest::RunTest(CompositorMode mode, bool delegating_renderer) {
942 DCHECK(mode != CompositorMode::Deserializable);
813 mode_ = mode; 943 mode_ = mode;
814 if (mode_ == CompositorMode::Threaded) { 944 if (mode_ != CompositorMode::SingleThreaded) {
815 impl_thread_.reset(new base::Thread("Compositor")); 945 impl_thread_.reset(new base::Thread("Compositor"));
816 ASSERT_TRUE(impl_thread_->Start()); 946 ASSERT_TRUE(impl_thread_->Start());
817 } 947 }
818 948
819 main_task_runner_ = base::ThreadTaskRunnerHandle::Get(); 949 main_task_runner_ = base::ThreadTaskRunnerHandle::Get();
820 950
821 shared_bitmap_manager_.reset(new TestSharedBitmapManager); 951 shared_bitmap_manager_.reset(new TestSharedBitmapManager);
822 gpu_memory_buffer_manager_.reset(new TestGpuMemoryBufferManager); 952 gpu_memory_buffer_manager_.reset(new TestGpuMemoryBufferManager);
823 task_graph_runner_.reset(new TestTaskGraphRunner); 953 task_graph_runner_.reset(new TestTaskGraphRunner);
824 954
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
880 return FakeOutputSurface::CreateDelegating3d(); 1010 return FakeOutputSurface::CreateDelegating3d();
881 else 1011 else
882 return FakeOutputSurface::Create3d(); 1012 return FakeOutputSurface::Create3d();
883 } 1013 }
884 1014
885 TestWebGraphicsContext3D* LayerTreeTest::TestContext() { 1015 TestWebGraphicsContext3D* LayerTreeTest::TestContext() {
886 return static_cast<TestContextProvider*>(output_surface_->context_provider()) 1016 return static_cast<TestContextProvider*>(output_surface_->context_provider())
887 ->TestContext3d(); 1017 ->TestContext3d();
888 } 1018 }
889 1019
1020 void LayerTreeTest::DidShutdown() {
1021 DCHECK(remote_channel_host_for_testing_);
1022 remote_channel_host_for_testing_.reset();
1023 }
1024
890 int LayerTreeTest::LastCommittedSourceFrameNumber(LayerTreeHostImpl* impl) 1025 int LayerTreeTest::LastCommittedSourceFrameNumber(LayerTreeHostImpl* impl)
891 const { 1026 const {
892 if (impl->pending_tree()) 1027 if (impl->pending_tree())
893 return impl->pending_tree()->source_frame_number(); 1028 return impl->pending_tree()->source_frame_number();
894 if (impl->active_tree()) 1029 if (impl->active_tree())
895 return impl->active_tree()->source_frame_number(); 1030 return impl->active_tree()->source_frame_number();
896 // Source frames start at 0, so this is invalid. 1031 // Source frames start at 0, so this is invalid.
897 return -1; 1032 return -1;
898 } 1033 }
899 1034
900 void LayerTreeTest::DestroyLayerTreeHost() { 1035 void LayerTreeTest::DestroyLayerTreeHost() {
901 if (layer_tree_host_ && layer_tree_host_->root_layer()) 1036 if (layer_tree_host_ && layer_tree_host_->root_layer())
902 layer_tree_host_->root_layer()->SetLayerTreeHost(NULL); 1037 layer_tree_host_->root_layer()->SetLayerTreeHost(NULL);
903 layer_tree_host_ = nullptr; 1038 layer_tree_host_ = nullptr;
1039 DCHECK(!remote_channel_host_for_testing_);
904 } 1040 }
905 1041
906 TaskGraphRunner* LayerTreeTest::task_graph_runner() const { 1042 TaskGraphRunner* LayerTreeTest::task_graph_runner() const {
907 return task_graph_runner_.get(); 1043 return task_graph_runner_.get();
908 } 1044 }
909 1045
910 LayerTreeHost* LayerTreeTest::layer_tree_host() { 1046 LayerTreeHost* LayerTreeTest::layer_tree_host() {
911 // We check for a null task_runner_provider here as we sometimes ask for the 1047 // We check for a null task_runner_provider here as we sometimes ask for the
912 // layer tree host when the task_runner_provider does not exist, often for 1048 // layer tree host when the task_runner_provider does not exist, often for
913 // checking settings after a test has completed. For example, 1049 // checking settings after a test has completed. For example,
914 // LTHPixelResourceTest::RunPixelResourceTest. See elsewhere in this file for 1050 // LTHPixelResourceTest::RunPixelResourceTest. See elsewhere in this file for
915 // other examples. 1051 // other examples.
916 DCHECK(!task_runner_provider() || task_runner_provider()->IsMainThread() || 1052 DCHECK(!task_runner_provider() || task_runner_provider()->IsMainThread() ||
917 task_runner_provider()->IsMainThreadBlocked()); 1053 task_runner_provider()->IsMainThreadBlocked());
918 return layer_tree_host_.get(); 1054 return layer_tree_host_.get();
919 } 1055 }
920 1056
921 ProxyMainForTest* LayerTreeTest::GetProxyMainForTest() const { 1057 ProxyMainForTest* LayerTreeTest::GetProxyMainForTest() const {
922 DCHECK(HasImplThread()); 1058 DCHECK(HasImplThread());
923 return static_cast<ProxyMainForTest*>(proxy()); 1059 return static_cast<ProxyMainForTest*>(proxy());
924 } 1060 }
925 1061
926 ProxyImplForTest* LayerTreeTest::GetProxyImplForTest() const { 1062 ProxyImplForTest* LayerTreeTest::GetProxyImplForTest() const {
927 DCHECK(HasImplThread()); 1063 DCHECK(HasImplThread());
1064 ProxyImpl* proxy_impl;
David Trainor- moved to gerrit 2015/12/11 17:13:44 Can you leave this line below?
Khushal 2015/12/11 22:49:37 Done. I changed the structure so we can get ProxyI
1065 if (IsRemoteTest()) {
1066 return GetRemoteChannelImplForTest()->proxy_impl_for_test();
1067 }
928 ThreadedChannel* threaded_channel = 1068 ThreadedChannel* threaded_channel =
929 static_cast<ThreadedChannel*>(GetProxyMainForTest()->channel_main()); 1069 static_cast<ThreadedChannel*>(GetProxyMainForTest()->channel_main());
930 ProxyImpl* proxy_impl = threaded_channel->GetProxyImplForTesting(); 1070 proxy_impl = threaded_channel->GetProxyImplForTesting();
931 1071
932 // We check for null ProxyImpl since ProxyImpl exists in the ThreadedChannel 1072 // We check for null ProxyImpl since ProxyImpl exists in the ThreadedChannel
933 // only after it is initialized. 1073 // only after it is initialized.
934 DCHECK(proxy_impl); 1074 DCHECK(proxy_impl);
935 return static_cast<ProxyImplForTest*>(proxy_impl); 1075 return static_cast<ProxyImplForTest*>(proxy_impl);
936 } 1076 }
937 1077
1078 RemoteChannelImplForTest* LayerTreeTest::GetRemoteChannelImplForTest() const {
1079 DCHECK(IsRemoteTest());
1080 return remote_channel_host_for_testing_->remote_channel_impl_for_test();
1081 }
1082
938 } // namespace cc 1083 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698