| 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" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 inner_bounds, | 92 inner_bounds, |
| 93 outer_bounds, | 93 outer_bounds, |
| 94 host, | 94 host, |
| 95 layer_settings); | 95 layer_settings); |
| 96 } | 96 } |
| 97 | 97 |
| 98 // Creates a SingleThreadProxy that notifies the supplied |test_hooks| of | 98 // Creates a SingleThreadProxy that notifies the supplied |test_hooks| of |
| 99 // various actions. | 99 // various actions. |
| 100 class SingleThreadProxyForTest : public SingleThreadProxy { | 100 class SingleThreadProxyForTest : public SingleThreadProxy { |
| 101 public: | 101 public: |
| 102 static scoped_ptr<Proxy> Create( | 102 static scoped_ptr<Proxy> Create(TestHooks* test_hooks, |
| 103 TestHooks* test_hooks, | 103 LayerTreeHost* host, |
| 104 LayerTreeHost* host, | 104 LayerTreeHostSingleThreadClient* client, |
| 105 LayerTreeHostSingleThreadClient* client, | 105 TaskRunnerProvider* task_runner_provider) { |
| 106 TaskRunnerProvider* task_runner_provider, | |
| 107 scoped_ptr<BeginFrameSource> external_begin_frame_source) { | |
| 108 return make_scoped_ptr(new SingleThreadProxyForTest( | 106 return make_scoped_ptr(new SingleThreadProxyForTest( |
| 109 test_hooks, host, client, task_runner_provider, | 107 test_hooks, host, client, task_runner_provider)); |
| 110 std::move(external_begin_frame_source))); | |
| 111 } | 108 } |
| 112 | 109 |
| 113 ~SingleThreadProxyForTest() override {} | 110 ~SingleThreadProxyForTest() override {} |
| 114 | 111 |
| 115 private: | 112 private: |
| 116 SingleThreadProxyForTest( | 113 SingleThreadProxyForTest(TestHooks* test_hooks, |
| 117 TestHooks* test_hooks, | 114 LayerTreeHost* host, |
| 118 LayerTreeHost* host, | 115 LayerTreeHostSingleThreadClient* client, |
| 119 LayerTreeHostSingleThreadClient* client, | 116 TaskRunnerProvider* task_runner_provider) |
| 120 TaskRunnerProvider* task_runner_provider, | 117 : SingleThreadProxy(host, client, task_runner_provider), |
| 121 scoped_ptr<BeginFrameSource> external_begin_frame_source) | |
| 122 : SingleThreadProxy(host, | |
| 123 client, | |
| 124 task_runner_provider, | |
| 125 std::move(external_begin_frame_source)), | |
| 126 test_hooks_(test_hooks) {} | 118 test_hooks_(test_hooks) {} |
| 127 | 119 |
| 128 void ScheduledActionSendBeginMainFrame(const BeginFrameArgs& args) override { | 120 void ScheduledActionSendBeginMainFrame(const BeginFrameArgs& args) override { |
| 129 test_hooks_->ScheduledActionWillSendBeginMainFrame(); | 121 test_hooks_->ScheduledActionWillSendBeginMainFrame(); |
| 130 SingleThreadProxy::ScheduledActionSendBeginMainFrame(args); | 122 SingleThreadProxy::ScheduledActionSendBeginMainFrame(args); |
| 131 test_hooks_->ScheduledActionSendBeginMainFrame(); | 123 test_hooks_->ScheduledActionSendBeginMainFrame(); |
| 132 } | 124 } |
| 133 | 125 |
| 134 DrawResult ScheduledActionDrawAndSwapIfPossible() override { | 126 DrawResult ScheduledActionDrawAndSwapIfPossible() override { |
| 135 DrawResult result = | 127 DrawResult result = |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 params.task_graph_runner = task_graph_runner; | 442 params.task_graph_runner = task_graph_runner; |
| 451 params.settings = &settings; | 443 params.settings = &settings; |
| 452 scoped_ptr<LayerTreeHostForTesting> layer_tree_host( | 444 scoped_ptr<LayerTreeHostForTesting> layer_tree_host( |
| 453 new LayerTreeHostForTesting(test_hooks, ¶ms, mode)); | 445 new LayerTreeHostForTesting(test_hooks, ¶ms, mode)); |
| 454 scoped_ptr<TaskRunnerProvider> task_runner_provider = | 446 scoped_ptr<TaskRunnerProvider> task_runner_provider = |
| 455 TaskRunnerProvider::Create(main_task_runner, impl_task_runner); | 447 TaskRunnerProvider::Create(main_task_runner, impl_task_runner); |
| 456 scoped_ptr<Proxy> proxy; | 448 scoped_ptr<Proxy> proxy; |
| 457 if (mode == CompositorMode::Threaded) { | 449 if (mode == CompositorMode::Threaded) { |
| 458 DCHECK(impl_task_runner.get()); | 450 DCHECK(impl_task_runner.get()); |
| 459 scoped_ptr<ProxyMain> proxy_main = ProxyMainForTest::CreateThreaded( | 451 scoped_ptr<ProxyMain> proxy_main = ProxyMainForTest::CreateThreaded( |
| 460 test_hooks, layer_tree_host.get(), task_runner_provider.get(), | 452 test_hooks, layer_tree_host.get(), task_runner_provider.get()); |
| 461 std::move(external_begin_frame_source)); | |
| 462 proxy = std::move(proxy_main); | 453 proxy = std::move(proxy_main); |
| 463 } else { | 454 } else { |
| 464 proxy = SingleThreadProxyForTest::Create( | 455 proxy = |
| 465 test_hooks, layer_tree_host.get(), client, task_runner_provider.get(), | 456 SingleThreadProxyForTest::Create(test_hooks, layer_tree_host.get(), |
| 466 std::move(external_begin_frame_source)); | 457 client, task_runner_provider.get()); |
| 467 } | 458 } |
| 468 layer_tree_host->InitializeForTesting(std::move(task_runner_provider), | 459 layer_tree_host->InitializeForTesting( |
| 469 std::move(proxy)); | 460 std::move(task_runner_provider), std::move(proxy), |
| 461 std::move(external_begin_frame_source)); |
| 470 return layer_tree_host; | 462 return layer_tree_host; |
| 471 } | 463 } |
| 472 | 464 |
| 473 scoped_ptr<LayerTreeHostImpl> CreateLayerTreeHostImpl( | 465 scoped_ptr<LayerTreeHostImpl> CreateLayerTreeHostImpl( |
| 474 LayerTreeHostImplClient* host_impl_client) override { | 466 LayerTreeHostImplClient* host_impl_client) override { |
| 475 return LayerTreeHostImplForTesting::Create( | 467 return LayerTreeHostImplForTesting::Create( |
| 476 test_hooks_, settings(), host_impl_client, task_runner_provider(), | 468 test_hooks_, settings(), host_impl_client, task_runner_provider(), |
| 477 shared_bitmap_manager(), gpu_memory_buffer_manager(), | 469 shared_bitmap_manager(), gpu_memory_buffer_manager(), |
| 478 task_graph_runner(), rendering_stats_instrumentation()); | 470 task_graph_runner(), rendering_stats_instrumentation()); |
| 479 } | 471 } |
| (...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 929 static_cast<ThreadedChannel*>(GetProxyMainForTest()->channel_main()); | 921 static_cast<ThreadedChannel*>(GetProxyMainForTest()->channel_main()); |
| 930 ProxyImpl* proxy_impl = threaded_channel->GetProxyImplForTesting(); | 922 ProxyImpl* proxy_impl = threaded_channel->GetProxyImplForTesting(); |
| 931 | 923 |
| 932 // We check for null ProxyImpl since ProxyImpl exists in the ThreadedChannel | 924 // We check for null ProxyImpl since ProxyImpl exists in the ThreadedChannel |
| 933 // only after it is initialized. | 925 // only after it is initialized. |
| 934 DCHECK(proxy_impl); | 926 DCHECK(proxy_impl); |
| 935 return static_cast<ProxyImplForTest*>(proxy_impl); | 927 return static_cast<ProxyImplForTest*>(proxy_impl); |
| 936 } | 928 } |
| 937 | 929 |
| 938 } // namespace cc | 930 } // namespace cc |
| OLD | NEW |