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/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" |
| 30 #include "cc/test/threaded_channel_for_test.h" | |
| 29 #include "cc/trees/layer_tree_host_client.h" | 31 #include "cc/trees/layer_tree_host_client.h" |
| 30 #include "cc/trees/layer_tree_host_impl.h" | 32 #include "cc/trees/layer_tree_host_impl.h" |
| 31 #include "cc/trees/layer_tree_host_single_thread_client.h" | 33 #include "cc/trees/layer_tree_host_single_thread_client.h" |
| 32 #include "cc/trees/layer_tree_impl.h" | 34 #include "cc/trees/layer_tree_impl.h" |
| 33 #include "cc/trees/proxy_impl.h" | 35 #include "cc/trees/proxy_impl.h" |
| 34 #include "cc/trees/proxy_main.h" | 36 #include "cc/trees/proxy_main.h" |
| 37 #include "cc/trees/remote_channel_host.h" | |
| 38 #include "cc/trees/remote_channel_host_client.h" | |
| 35 #include "cc/trees/single_thread_proxy.h" | 39 #include "cc/trees/single_thread_proxy.h" |
| 36 #include "cc/trees/threaded_channel.h" | 40 #include "cc/trees/threaded_channel.h" |
| 37 #include "testing/gmock/include/gmock/gmock.h" | 41 #include "testing/gmock/include/gmock/gmock.h" |
| 38 #include "ui/gfx/geometry/size_conversions.h" | 42 #include "ui/gfx/geometry/size_conversions.h" |
| 39 | 43 |
| 40 namespace cc { | 44 namespace cc { |
| 41 | 45 |
| 42 void CreateVirtualViewportLayers(Layer* root_layer, | 46 void CreateVirtualViewportLayers(Layer* root_layer, |
| 43 scoped_refptr<Layer> outer_scroll_layer, | 47 scoped_refptr<Layer> outer_scroll_layer, |
| 44 const gfx::Size& inner_bounds, | 48 const gfx::Size& inner_bounds, |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 335 LayerTreeHostImpl::NotifyTileStateChanged(tile); | 339 LayerTreeHostImpl::NotifyTileStateChanged(tile); |
| 336 test_hooks_->NotifyTileStateChangedOnThread(this, tile); | 340 test_hooks_->NotifyTileStateChangedOnThread(this, tile); |
| 337 } | 341 } |
| 338 | 342 |
| 339 private: | 343 private: |
| 340 TestHooks* test_hooks_; | 344 TestHooks* test_hooks_; |
| 341 bool block_notify_ready_to_activate_for_testing_; | 345 bool block_notify_ready_to_activate_for_testing_; |
| 342 bool notify_ready_to_activate_was_blocked_; | 346 bool notify_ready_to_activate_was_blocked_; |
| 343 }; | 347 }; |
| 344 | 348 |
| 349 // Implementation of RemoteChannelHostClient for tests. | |
| 350 class RemoteChannelHostClientForTesting : public RemoteChannelHostClient { | |
| 351 public: | |
| 352 static scoped_ptr<RemoteChannelHostClientForTesting> Create( | |
| 353 TestHooks* test_hooks) { | |
| 354 return make_scoped_ptr(new RemoteChannelHostClientForTesting(test_hooks)); | |
| 355 } | |
| 356 | |
| 357 void OverrideLayerTreeSettings(LayerTreeSettings* settings) override { | |
| 358 test_hooks_->OverrideLayerTreeSettings(settings); | |
| 359 } | |
| 360 | |
| 361 void DidShutdown() override { test_hooks_->DidShutdown(); } | |
| 362 | |
| 363 private: | |
| 364 explicit RemoteChannelHostClientForTesting(TestHooks* test_hooks) | |
| 365 : test_hooks_(test_hooks) {} | |
| 366 | |
| 367 TestHooks* test_hooks_; | |
| 368 }; | |
| 369 | |
| 345 // Implementation of LayerTreeHost callback interface. | 370 // Implementation of LayerTreeHost callback interface. |
| 346 class LayerTreeHostClientForTesting : public LayerTreeHostClient, | 371 class LayerTreeHostClientForTesting : public LayerTreeHostClient, |
| 347 public LayerTreeHostSingleThreadClient { | 372 public LayerTreeHostSingleThreadClient { |
| 348 public: | 373 public: |
| 349 static scoped_ptr<LayerTreeHostClientForTesting> Create( | 374 static scoped_ptr<LayerTreeHostClientForTesting> Create( |
| 350 TestHooks* test_hooks) { | 375 TestHooks* test_hooks) { |
| 351 return make_scoped_ptr(new LayerTreeHostClientForTesting(test_hooks)); | 376 return make_scoped_ptr(new LayerTreeHostClientForTesting(test_hooks)); |
| 352 } | 377 } |
| 353 ~LayerTreeHostClientForTesting() override {} | 378 ~LayerTreeHostClientForTesting() override {} |
| 354 | 379 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 414 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) | 439 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) |
| 415 override {} | 440 override {} |
| 416 | 441 |
| 417 private: | 442 private: |
| 418 explicit LayerTreeHostClientForTesting(TestHooks* test_hooks) | 443 explicit LayerTreeHostClientForTesting(TestHooks* test_hooks) |
| 419 : test_hooks_(test_hooks) {} | 444 : test_hooks_(test_hooks) {} |
| 420 | 445 |
| 421 TestHooks* test_hooks_; | 446 TestHooks* test_hooks_; |
| 422 }; | 447 }; |
| 423 | 448 |
| 449 // Injects RemoteChannelImplForTesting. | |
| 450 class RemoteChannelHostForTesting : public RemoteChannelHost { | |
| 451 public: | |
| 452 static scoped_ptr<RemoteChannelHostForTesting> Create( | |
| 453 TestHooks* test_hooks, | |
| 454 RemoteProtoChannel* remote_proto_channel, | |
| 455 RemoteChannelHostClient* client, | |
| 456 TaskGraphRunner* task_graph_runner, | |
| 457 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | |
| 458 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) { | |
| 459 return make_scoped_ptr(new RemoteChannelHostForTesting( | |
| 460 test_hooks, remote_proto_channel, client, task_graph_runner, | |
| 461 main_task_runner, impl_task_runner)); | |
| 462 } | |
| 463 | |
| 464 RemoteChannelImplForTest* remote_channel_impl_for_test() const { | |
| 465 return remote_channel_impl_for_test_; | |
| 466 } | |
| 467 | |
| 468 private: | |
| 469 RemoteChannelHostForTesting( | |
| 470 TestHooks* test_hooks, | |
| 471 RemoteProtoChannel* remote_proto_channel, | |
| 472 RemoteChannelHostClient* client, | |
| 473 TaskGraphRunner* task_graph_runner, | |
| 474 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | |
| 475 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) | |
| 476 : RemoteChannelHost(remote_proto_channel, | |
| 477 client, | |
| 478 task_graph_runner, | |
| 479 main_task_runner, | |
| 480 impl_task_runner), | |
| 481 test_hooks_(test_hooks) {} | |
| 482 | |
| 483 scoped_ptr<RemoteChannelImpl> CreateRemoteChannelImpl( | |
| 484 RemoteChannelHost* remote_channel_host, | |
| 485 TaskGraphRunner* task_graph_runner, | |
| 486 const LayerTreeSettings& settings, | |
| 487 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | |
| 488 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) override { | |
| 489 scoped_ptr<RemoteChannelImplForTest> channel_impl = | |
| 490 RemoteChannelImplForTest::Create(test_hooks_, remote_channel_host, | |
| 491 task_graph_runner, settings, | |
| 492 main_task_runner, impl_task_runner); | |
| 493 remote_channel_impl_for_test_ = channel_impl.get(); | |
| 494 return std::move(channel_impl); | |
| 495 } | |
| 496 | |
| 497 TestHooks* test_hooks_; | |
| 498 RemoteChannelImplForTest* remote_channel_impl_for_test_; | |
| 499 }; | |
| 500 | |
| 424 // Adapts LayerTreeHost for test. Injects LayerTreeHostImplForTesting. | 501 // Adapts LayerTreeHost for test. Injects LayerTreeHostImplForTesting. |
| 425 class LayerTreeHostForTesting : public LayerTreeHost { | 502 class LayerTreeHostForTesting : public LayerTreeHost { |
| 426 public: | 503 public: |
| 427 static scoped_ptr<LayerTreeHostForTesting> Create( | 504 static scoped_ptr<LayerTreeHostForTesting> Create( |
| 428 TestHooks* test_hooks, | 505 TestHooks* test_hooks, |
| 429 CompositorMode mode, | 506 CompositorMode mode, |
| 430 LayerTreeHostClientForTesting* client, | 507 LayerTreeHostClientForTesting* client, |
| 508 RemoteProtoChannel* remote_proto_channel, | |
| 431 SharedBitmapManager* shared_bitmap_manager, | 509 SharedBitmapManager* shared_bitmap_manager, |
| 432 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | 510 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
| 433 TaskGraphRunner* task_graph_runner, | 511 TaskGraphRunner* task_graph_runner, |
| 434 const LayerTreeSettings& settings, | 512 const LayerTreeSettings& settings, |
| 435 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 513 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
| 436 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, | 514 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, |
| 437 scoped_ptr<BeginFrameSource> external_begin_frame_source) { | 515 scoped_ptr<BeginFrameSource> external_begin_frame_source) { |
| 438 LayerTreeHost::InitParams params; | 516 LayerTreeHost::InitParams params; |
| 439 params.client = client; | 517 params.client = client; |
| 440 params.shared_bitmap_manager = shared_bitmap_manager; | 518 params.shared_bitmap_manager = shared_bitmap_manager; |
| 441 params.gpu_memory_buffer_manager = gpu_memory_buffer_manager; | 519 params.gpu_memory_buffer_manager = gpu_memory_buffer_manager; |
| 442 params.task_graph_runner = task_graph_runner; | 520 params.task_graph_runner = task_graph_runner; |
| 443 params.settings = &settings; | 521 params.settings = &settings; |
| 444 scoped_ptr<LayerTreeHostForTesting> layer_tree_host( | 522 scoped_ptr<LayerTreeHostForTesting> layer_tree_host( |
| 445 new LayerTreeHostForTesting(test_hooks, ¶ms, mode)); | 523 new LayerTreeHostForTesting(test_hooks, ¶ms, mode)); |
| 446 scoped_ptr<TaskRunnerProvider> task_runner_provider = | 524 scoped_ptr<TaskRunnerProvider> task_runner_provider = |
| 447 TaskRunnerProvider::Create(main_task_runner, impl_task_runner); | 525 TaskRunnerProvider::Create(main_task_runner, impl_task_runner); |
| 448 scoped_ptr<Proxy> proxy; | 526 scoped_ptr<Proxy> proxy; |
| 449 if (mode == CompositorMode::Threaded) { | 527 switch (mode) { |
| 450 DCHECK(impl_task_runner.get()); | 528 case CompositorMode::SingleThreaded: |
| 451 scoped_ptr<ProxyMain> proxy_main = ProxyMainForTest::CreateThreaded( | 529 proxy = SingleThreadProxyForTest::Create(test_hooks, |
| 452 test_hooks, layer_tree_host.get(), task_runner_provider.get()); | 530 layer_tree_host.get(), client, |
| 453 proxy = std::move(proxy_main); | 531 task_runner_provider.get()); |
| 454 } else { | 532 break; |
| 455 proxy = | 533 case CompositorMode::Threaded: |
| 456 SingleThreadProxyForTest::Create(test_hooks, layer_tree_host.get(), | 534 DCHECK(impl_task_runner.get()); |
| 457 client, task_runner_provider.get()); | 535 { |
| 536 scoped_ptr<ProxyMain> proxy_main = ProxyMainForTest::CreateThreaded( | |
| 537 test_hooks, layer_tree_host.get(), task_runner_provider.get()); | |
| 538 proxy = std::move(proxy_main); | |
|
vmpstr
2016/01/07 19:08:12
why not just proxy = ProxyMainForTest::CreateThrea
Khushal
2016/01/08 21:17:19
I think I was using a temp variable there earlier
| |
| 539 } | |
| 540 break; | |
| 541 case CompositorMode::Remote: | |
| 542 DCHECK(!impl_task_runner.get()); | |
| 543 DCHECK(!external_begin_frame_source); | |
| 544 { | |
| 545 scoped_ptr<ProxyMain> proxy_main = ProxyMainForTest::CreateRemote( | |
| 546 test_hooks, remote_proto_channel, layer_tree_host.get(), | |
| 547 task_runner_provider.get()); | |
| 548 proxy = std::move(proxy_main); | |
|
vmpstr
2016/01/07 19:08:11
Same here
Khushal
2016/01/08 21:17:19
Done.
| |
| 549 } | |
| 550 break; | |
| 551 default: | |
| 552 NOTREACHED(); | |
| 458 } | 553 } |
| 459 layer_tree_host->InitializeForTesting( | 554 layer_tree_host->InitializeForTesting( |
| 460 std::move(task_runner_provider), std::move(proxy), | 555 std::move(task_runner_provider), std::move(proxy), |
| 461 std::move(external_begin_frame_source)); | 556 std::move(external_begin_frame_source)); |
| 462 return layer_tree_host; | 557 return layer_tree_host; |
| 463 } | 558 } |
| 464 | 559 |
| 465 scoped_ptr<LayerTreeHostImpl> CreateLayerTreeHostImpl( | 560 scoped_ptr<LayerTreeHostImpl> CreateLayerTreeHostImpl( |
| 466 LayerTreeHostImplClient* host_impl_client) override { | 561 LayerTreeHostImplClient* host_impl_client) override { |
| 467 return LayerTreeHostImplForTesting::Create( | 562 return LayerTreeHostImplForTesting::Create( |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 513 | 608 |
| 514 // Tests should timeout quickly unless --cc-layer-tree-test-no-timeout was | 609 // Tests should timeout quickly unless --cc-layer-tree-test-no-timeout was |
| 515 // specified (for running in a debugger). | 610 // specified (for running in a debugger). |
| 516 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 611 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 517 if (!command_line->HasSwitch(switches::kCCLayerTreeTestNoTimeout)) | 612 if (!command_line->HasSwitch(switches::kCCLayerTreeTestNoTimeout)) |
| 518 timeout_seconds_ = 5; | 613 timeout_seconds_ = 5; |
| 519 } | 614 } |
| 520 | 615 |
| 521 LayerTreeTest::~LayerTreeTest() {} | 616 LayerTreeTest::~LayerTreeTest() {} |
| 522 | 617 |
| 618 bool LayerTreeTest::IsRemoteTest() const { | |
| 619 return mode_ == CompositorMode::Remote; | |
| 620 } | |
| 621 | |
| 523 void LayerTreeTest::EndTest() { | 622 void LayerTreeTest::EndTest() { |
| 524 if (ended_) | 623 if (ended_) |
| 525 return; | 624 return; |
| 526 ended_ = true; | 625 ended_ = true; |
| 527 | 626 |
| 528 // For the case where we EndTest during BeginTest(), set a flag to indicate | 627 // For the case where we EndTest during BeginTest(), set a flag to indicate |
| 529 // that the test should end the second BeginTest regains control. | 628 // that the test should end the second BeginTest regains control. |
| 530 if (beginning_) { | 629 if (beginning_) { |
| 531 end_when_begin_returns_ = true; | 630 end_when_begin_returns_ = true; |
| 532 } else { | 631 } else { |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 662 client_ = LayerTreeHostClientForTesting::Create(this); | 761 client_ = LayerTreeHostClientForTesting::Create(this); |
| 663 | 762 |
| 664 scoped_ptr<FakeExternalBeginFrameSource> external_begin_frame_source; | 763 scoped_ptr<FakeExternalBeginFrameSource> external_begin_frame_source; |
| 665 if (settings_.use_external_begin_frame_source) { | 764 if (settings_.use_external_begin_frame_source) { |
| 666 external_begin_frame_source.reset(new FakeExternalBeginFrameSource( | 765 external_begin_frame_source.reset(new FakeExternalBeginFrameSource( |
| 667 settings_.renderer_settings.refresh_rate)); | 766 settings_.renderer_settings.refresh_rate)); |
| 668 external_begin_frame_source_ = external_begin_frame_source.get(); | 767 external_begin_frame_source_ = external_begin_frame_source.get(); |
| 669 } | 768 } |
| 670 | 769 |
| 671 DCHECK(!impl_thread_ || impl_thread_->task_runner().get()); | 770 DCHECK(!impl_thread_ || impl_thread_->task_runner().get()); |
| 672 layer_tree_host_ = LayerTreeHostForTesting::Create( | 771 |
| 673 this, mode_, client_.get(), shared_bitmap_manager_.get(), | 772 if (IsRemoteTest()) { |
| 674 gpu_memory_buffer_manager_.get(), task_graph_runner_.get(), settings_, | 773 // It is important to create the RemoteChannelHost before the LayerTreeHost |
|
vmpstr
2016/01/07 19:08:12
What would be creating remote channel host in non-
Khushal
2016/01/08 21:17:19
As we discussed. I've removed the RemoteChannelHos
| |
| 675 base::ThreadTaskRunnerHandle::Get(), | 774 // since the main compositor immediately sends an initialization message to |
| 676 impl_thread_ ? impl_thread_->task_runner() : NULL, | 775 // the impl compositor. |
| 677 std::move(external_begin_frame_source)); | 776 DCHECK(impl_thread_); |
| 777 remote_channel_host_client_ = | |
| 778 RemoteChannelHostClientForTesting::Create(this); | |
| 779 remote_channel_host_for_testing_ = RemoteChannelHostForTesting::Create( | |
| 780 this, &remote_proto_channel_bridge_.channel_impl, | |
| 781 remote_channel_host_client_.get(), task_graph_runner_.get(), | |
| 782 base::ThreadTaskRunnerHandle::Get(), impl_thread_->task_runner()); | |
| 783 DCHECK(remote_proto_channel_bridge_.channel_impl.HasReceiver()); | |
| 784 | |
| 785 layer_tree_host_ = LayerTreeHostForTesting::Create( | |
| 786 this, mode_, client_.get(), &remote_proto_channel_bridge_.channel_main, | |
| 787 nullptr, nullptr, task_graph_runner_.get(), settings_, | |
| 788 base::ThreadTaskRunnerHandle::Get(), nullptr, | |
| 789 std::move(external_begin_frame_source)); | |
| 790 DCHECK(remote_proto_channel_bridge_.channel_main.HasReceiver()); | |
| 791 } else { | |
| 792 layer_tree_host_ = LayerTreeHostForTesting::Create( | |
| 793 this, mode_, client_.get(), nullptr, shared_bitmap_manager_.get(), | |
| 794 gpu_memory_buffer_manager_.get(), task_graph_runner_.get(), settings_, | |
| 795 base::ThreadTaskRunnerHandle::Get(), | |
| 796 impl_thread_ ? impl_thread_->task_runner() : NULL, | |
| 797 std::move(external_begin_frame_source)); | |
| 798 } | |
| 799 | |
| 678 ASSERT_TRUE(layer_tree_host_); | 800 ASSERT_TRUE(layer_tree_host_); |
| 679 | 801 |
| 680 started_ = true; | 802 started_ = true; |
| 681 beginning_ = true; | 803 beginning_ = true; |
| 682 SetupTree(); | 804 SetupTree(); |
| 683 WillBeginTest(); | 805 WillBeginTest(); |
| 684 BeginTest(); | 806 BeginTest(); |
| 685 beginning_ = false; | 807 beginning_ = false; |
| 686 if (end_when_begin_returns_) | 808 if (end_when_begin_returns_) |
| 687 RealEndTest(); | 809 RealEndTest(); |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 708 layer_tree_host_->root_layer()->SetIsDrawable(true); | 830 layer_tree_host_->root_layer()->SetIsDrawable(true); |
| 709 } | 831 } |
| 710 | 832 |
| 711 void LayerTreeTest::Timeout() { | 833 void LayerTreeTest::Timeout() { |
| 712 timed_out_ = true; | 834 timed_out_ = true; |
| 713 EndTest(); | 835 EndTest(); |
| 714 } | 836 } |
| 715 | 837 |
| 716 void LayerTreeTest::RealEndTest() { | 838 void LayerTreeTest::RealEndTest() { |
| 717 // TODO(mithro): Make this method only end when not inside an impl frame. | 839 // TODO(mithro): Make this method only end when not inside an impl frame. |
| 718 if (layer_tree_host_ && !timed_out_ && | 840 bool main_frame_will_happen; |
| 719 proxy()->MainFrameWillHappenForTesting()) { | 841 if (IsRemoteTest()) { |
| 842 main_frame_will_happen = | |
| 843 remote_channel_host_for_testing_ | |
| 844 ? GetRemoteChannelImplForTest()->MainFrameWillHappenForTesting() | |
| 845 : false; | |
| 846 } else { | |
| 847 main_frame_will_happen = | |
| 848 layer_tree_host_ ? proxy()->MainFrameWillHappenForTesting() : false; | |
| 849 } | |
| 850 | |
| 851 if (main_frame_will_happen && !timed_out_) { | |
| 720 main_task_runner_->PostTask( | 852 main_task_runner_->PostTask( |
| 721 FROM_HERE, | 853 FROM_HERE, |
| 722 base::Bind(&LayerTreeTest::RealEndTest, main_thread_weak_ptr_)); | 854 base::Bind(&LayerTreeTest::RealEndTest, main_thread_weak_ptr_)); |
| 723 return; | 855 return; |
| 724 } | 856 } |
| 725 | 857 |
| 726 base::MessageLoop::current()->QuitWhenIdle(); | 858 base::MessageLoop::current()->QuitWhenIdle(); |
| 727 } | 859 } |
| 728 | 860 |
| 729 void LayerTreeTest::DispatchAddAnimation(Layer* layer_to_receive_animation, | 861 void LayerTreeTest::DispatchAddAnimation(Layer* layer_to_receive_animation, |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 795 layer_tree_host_->SetNextCommitForcesRedraw(); | 927 layer_tree_host_->SetNextCommitForcesRedraw(); |
| 796 } | 928 } |
| 797 | 929 |
| 798 void LayerTreeTest::DispatchCompositeImmediately() { | 930 void LayerTreeTest::DispatchCompositeImmediately() { |
| 799 DCHECK(!task_runner_provider() || task_runner_provider()->IsMainThread()); | 931 DCHECK(!task_runner_provider() || task_runner_provider()->IsMainThread()); |
| 800 if (layer_tree_host_) | 932 if (layer_tree_host_) |
| 801 layer_tree_host_->Composite(base::TimeTicks::Now()); | 933 layer_tree_host_->Composite(base::TimeTicks::Now()); |
| 802 } | 934 } |
| 803 | 935 |
| 804 void LayerTreeTest::RunTest(CompositorMode mode, bool delegating_renderer) { | 936 void LayerTreeTest::RunTest(CompositorMode mode, bool delegating_renderer) { |
| 937 DCHECK(mode != CompositorMode::Deserializable); | |
| 805 mode_ = mode; | 938 mode_ = mode; |
| 806 if (mode_ == CompositorMode::Threaded) { | 939 if (mode_ != CompositorMode::SingleThreaded) { |
|
vmpstr
2016/01/07 19:08:12
I think this should be explicitly mode_ == Threade
Khushal
2016/01/08 21:17:19
Done.
| |
| 807 impl_thread_.reset(new base::Thread("Compositor")); | 940 impl_thread_.reset(new base::Thread("Compositor")); |
| 808 ASSERT_TRUE(impl_thread_->Start()); | 941 ASSERT_TRUE(impl_thread_->Start()); |
| 809 } | 942 } |
| 810 | 943 |
| 811 main_task_runner_ = base::ThreadTaskRunnerHandle::Get(); | 944 main_task_runner_ = base::ThreadTaskRunnerHandle::Get(); |
| 812 | 945 |
| 813 shared_bitmap_manager_.reset(new TestSharedBitmapManager); | 946 shared_bitmap_manager_.reset(new TestSharedBitmapManager); |
| 814 gpu_memory_buffer_manager_.reset(new TestGpuMemoryBufferManager); | 947 gpu_memory_buffer_manager_.reset(new TestGpuMemoryBufferManager); |
| 815 task_graph_runner_.reset(new TestTaskGraphRunner); | 948 task_graph_runner_.reset(new TestTaskGraphRunner); |
| 816 | 949 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 872 return FakeOutputSurface::CreateDelegating3d(); | 1005 return FakeOutputSurface::CreateDelegating3d(); |
| 873 else | 1006 else |
| 874 return FakeOutputSurface::Create3d(); | 1007 return FakeOutputSurface::Create3d(); |
| 875 } | 1008 } |
| 876 | 1009 |
| 877 TestWebGraphicsContext3D* LayerTreeTest::TestContext() { | 1010 TestWebGraphicsContext3D* LayerTreeTest::TestContext() { |
| 878 return static_cast<TestContextProvider*>(output_surface_->context_provider()) | 1011 return static_cast<TestContextProvider*>(output_surface_->context_provider()) |
| 879 ->TestContext3d(); | 1012 ->TestContext3d(); |
| 880 } | 1013 } |
| 881 | 1014 |
| 1015 void LayerTreeTest::DidShutdown() { | |
| 1016 ReceivedDidShutdown(); | |
| 1017 DestroyRemoteChannelHost(); | |
| 1018 } | |
| 1019 | |
| 882 int LayerTreeTest::LastCommittedSourceFrameNumber(LayerTreeHostImpl* impl) | 1020 int LayerTreeTest::LastCommittedSourceFrameNumber(LayerTreeHostImpl* impl) |
| 883 const { | 1021 const { |
| 884 if (impl->pending_tree()) | 1022 if (impl->pending_tree()) |
| 885 return impl->pending_tree()->source_frame_number(); | 1023 return impl->pending_tree()->source_frame_number(); |
| 886 if (impl->active_tree()) | 1024 if (impl->active_tree()) |
| 887 return impl->active_tree()->source_frame_number(); | 1025 return impl->active_tree()->source_frame_number(); |
| 888 // Source frames start at 0, so this is invalid. | 1026 // Source frames start at 0, so this is invalid. |
| 889 return -1; | 1027 return -1; |
| 890 } | 1028 } |
| 891 | 1029 |
| 892 void LayerTreeTest::DestroyLayerTreeHost() { | 1030 void LayerTreeTest::DestroyLayerTreeHost() { |
| 893 if (layer_tree_host_ && layer_tree_host_->root_layer()) | 1031 if (layer_tree_host_ && layer_tree_host_->root_layer()) |
| 894 layer_tree_host_->root_layer()->SetLayerTreeHost(NULL); | 1032 layer_tree_host_->root_layer()->SetLayerTreeHost(NULL); |
| 895 layer_tree_host_ = nullptr; | 1033 layer_tree_host_ = nullptr; |
| 1034 | |
| 1035 DCHECK(!remote_proto_channel_bridge_.channel_main.HasReceiver()); | |
| 1036 | |
| 1037 // Destroying the LayerTreeHost should destroy the RemoteChannelHost. | |
| 1038 DCHECK(!remote_channel_host_for_testing_); | |
| 1039 } | |
| 1040 | |
| 1041 void LayerTreeTest::DestroyRemoteChannelHost() { | |
| 1042 DCHECK(IsRemoteTest()); | |
| 1043 DCHECK(remote_channel_host_for_testing_); | |
| 1044 | |
| 1045 remote_channel_host_for_testing_ = nullptr; | |
| 1046 DCHECK(!remote_proto_channel_bridge_.channel_impl.HasReceiver()); | |
| 896 } | 1047 } |
| 897 | 1048 |
| 898 TaskGraphRunner* LayerTreeTest::task_graph_runner() const { | 1049 TaskGraphRunner* LayerTreeTest::task_graph_runner() const { |
| 899 return task_graph_runner_.get(); | 1050 return task_graph_runner_.get(); |
| 900 } | 1051 } |
| 901 | 1052 |
| 902 LayerTreeHost* LayerTreeTest::layer_tree_host() { | 1053 LayerTreeHost* LayerTreeTest::layer_tree_host() { |
| 903 // We check for a null task_runner_provider here as we sometimes ask for the | 1054 // We check for a null task_runner_provider here as we sometimes ask for the |
| 904 // layer tree host when the task_runner_provider does not exist, often for | 1055 // layer tree host when the task_runner_provider does not exist, often for |
| 905 // checking settings after a test has completed. For example, | 1056 // checking settings after a test has completed. For example, |
| 906 // LTHPixelResourceTest::RunPixelResourceTest. See elsewhere in this file for | 1057 // LTHPixelResourceTest::RunPixelResourceTest. See elsewhere in this file for |
| 907 // other examples. | 1058 // other examples. |
| 908 DCHECK(!task_runner_provider() || task_runner_provider()->IsMainThread() || | 1059 DCHECK(!task_runner_provider() || task_runner_provider()->IsMainThread() || |
| 909 task_runner_provider()->IsMainThreadBlocked()); | 1060 task_runner_provider()->IsMainThreadBlocked()); |
| 910 return layer_tree_host_.get(); | 1061 return layer_tree_host_.get(); |
| 911 } | 1062 } |
| 912 | 1063 |
| 913 ProxyMainForTest* LayerTreeTest::GetProxyMainForTest() const { | 1064 ProxyMainForTest* LayerTreeTest::GetProxyMainForTest() const { |
| 914 DCHECK(HasImplThread()); | 1065 DCHECK(HasImplThread()); |
| 915 return static_cast<ProxyMainForTest*>(proxy()); | 1066 return static_cast<ProxyMainForTest*>(proxy()); |
| 916 } | 1067 } |
| 917 | 1068 |
| 918 ProxyImplForTest* LayerTreeTest::GetProxyImplForTest() const { | 1069 ProxyImplForTest* LayerTreeTest::GetProxyImplForTest() const { |
| 919 DCHECK(HasImplThread()); | 1070 DCHECK(HasImplThread()); |
| 920 ThreadedChannel* threaded_channel = | 1071 |
| 921 static_cast<ThreadedChannel*>(GetProxyMainForTest()->channel_main()); | 1072 if (IsRemoteTest()) { |
| 922 ProxyImpl* proxy_impl = threaded_channel->GetProxyImplForTesting(); | 1073 return GetRemoteChannelImplForTest()->proxy_impl_for_test(); |
| 1074 } | |
| 1075 | |
| 1076 ProxyImplForTest* proxy_impl_for_test = | |
| 1077 GetThreadedChannelForTest()->proxy_impl_for_test(); | |
| 923 | 1078 |
| 924 // We check for null ProxyImpl since ProxyImpl exists in the ThreadedChannel | 1079 // We check for null ProxyImpl since ProxyImpl exists in the ThreadedChannel |
| 925 // only after it is initialized. | 1080 // only after it is initialized. |
| 926 DCHECK(proxy_impl); | 1081 DCHECK(proxy_impl_for_test); |
| 927 return static_cast<ProxyImplForTest*>(proxy_impl); | 1082 return proxy_impl_for_test; |
| 1083 } | |
| 1084 | |
| 1085 ThreadedChannelForTest* LayerTreeTest::GetThreadedChannelForTest() const { | |
| 1086 DCHECK(mode_ == CompositorMode::Threaded); | |
| 1087 | |
| 1088 return GetProxyMainForTest()->threaded_channel_for_test(); | |
| 1089 } | |
| 1090 | |
| 1091 RemoteChannelImplForTest* LayerTreeTest::GetRemoteChannelImplForTest() const { | |
| 1092 DCHECK(IsRemoteTest()); | |
| 1093 | |
| 1094 RemoteChannelImplForTest* remote_channel_impl_for_test = | |
| 1095 remote_channel_host_for_testing_->remote_channel_impl_for_test(); | |
| 1096 | |
| 1097 // We check for null RemoteChannelImpl since it is created only after the | |
| 1098 // RemoteChannelHost receives the initialization message. | |
| 1099 DCHECK(remote_channel_impl_for_test); | |
| 1100 return remote_channel_impl_for_test; | |
| 928 } | 1101 } |
| 929 | 1102 |
| 930 } // namespace cc | 1103 } // namespace cc |
| OLD | NEW |