| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/trees/proxy_main.h" | 5 #include "cc/trees/proxy_main.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/trace_event/trace_event.h" | 10 #include "base/trace_event/trace_event.h" |
| 11 #include "base/trace_event/trace_event_argument.h" | 11 #include "base/trace_event/trace_event_argument.h" |
| 12 #include "base/trace_event/trace_event_synthetic_delay.h" | 12 #include "base/trace_event/trace_event_synthetic_delay.h" |
| 13 #include "cc/debug/benchmark_instrumentation.h" | 13 #include "cc/debug/benchmark_instrumentation.h" |
| 14 #include "cc/debug/devtools_instrumentation.h" | 14 #include "cc/debug/devtools_instrumentation.h" |
| 15 #include "cc/output/compositor_frame_sink.h" | 15 #include "cc/output/compositor_frame_sink.h" |
| 16 #include "cc/output/swap_promise.h" | 16 #include "cc/output/swap_promise.h" |
| 17 #include "cc/resources/ui_resource_manager.h" | 17 #include "cc/resources/ui_resource_manager.h" |
| 18 #include "cc/trees/blocking_task_runner.h" | 18 #include "cc/trees/blocking_task_runner.h" |
| 19 #include "cc/trees/layer_tree_host_in_process.h" | 19 #include "cc/trees/layer_tree_host_in_process.h" |
| 20 #include "cc/trees/mutator_host.h" | 20 #include "cc/trees/mutator_host.h" |
| 21 #include "cc/trees/remote_channel_main.h" | |
| 22 #include "cc/trees/scoped_abort_remaining_swap_promises.h" | 21 #include "cc/trees/scoped_abort_remaining_swap_promises.h" |
| 23 #include "cc/trees/threaded_channel.h" | 22 #include "cc/trees/threaded_channel.h" |
| 24 | 23 |
| 25 namespace cc { | 24 namespace cc { |
| 26 | 25 |
| 27 std::unique_ptr<ProxyMain> ProxyMain::CreateThreaded( | 26 std::unique_ptr<ProxyMain> ProxyMain::CreateThreaded( |
| 28 LayerTreeHostInProcess* layer_tree_host, | 27 LayerTreeHostInProcess* layer_tree_host, |
| 29 TaskRunnerProvider* task_runner_provider) { | 28 TaskRunnerProvider* task_runner_provider) { |
| 30 std::unique_ptr<ProxyMain> proxy_main( | 29 std::unique_ptr<ProxyMain> proxy_main( |
| 31 new ProxyMain(layer_tree_host, task_runner_provider)); | 30 new ProxyMain(layer_tree_host, task_runner_provider)); |
| 32 proxy_main->SetChannel( | 31 proxy_main->SetChannel( |
| 33 ThreadedChannel::Create(proxy_main.get(), task_runner_provider)); | 32 ThreadedChannel::Create(proxy_main.get(), task_runner_provider)); |
| 34 return proxy_main; | 33 return proxy_main; |
| 35 } | 34 } |
| 36 | 35 |
| 37 std::unique_ptr<ProxyMain> ProxyMain::CreateRemote( | |
| 38 RemoteProtoChannel* remote_proto_channel, | |
| 39 LayerTreeHostInProcess* layer_tree_host, | |
| 40 TaskRunnerProvider* task_runner_provider) { | |
| 41 std::unique_ptr<ProxyMain> proxy_main( | |
| 42 new ProxyMain(layer_tree_host, task_runner_provider)); | |
| 43 proxy_main->SetChannel(RemoteChannelMain::Create( | |
| 44 remote_proto_channel, proxy_main.get(), task_runner_provider)); | |
| 45 return proxy_main; | |
| 46 } | |
| 47 | |
| 48 ProxyMain::ProxyMain(LayerTreeHostInProcess* layer_tree_host, | 36 ProxyMain::ProxyMain(LayerTreeHostInProcess* layer_tree_host, |
| 49 TaskRunnerProvider* task_runner_provider) | 37 TaskRunnerProvider* task_runner_provider) |
| 50 : layer_tree_host_(layer_tree_host), | 38 : layer_tree_host_(layer_tree_host), |
| 51 task_runner_provider_(task_runner_provider), | 39 task_runner_provider_(task_runner_provider), |
| 52 layer_tree_host_id_(layer_tree_host->GetId()), | 40 layer_tree_host_id_(layer_tree_host->GetId()), |
| 53 max_requested_pipeline_stage_(NO_PIPELINE_STAGE), | 41 max_requested_pipeline_stage_(NO_PIPELINE_STAGE), |
| 54 current_pipeline_stage_(NO_PIPELINE_STAGE), | 42 current_pipeline_stage_(NO_PIPELINE_STAGE), |
| 55 final_pipeline_stage_(NO_PIPELINE_STAGE), | 43 final_pipeline_stage_(NO_PIPELINE_STAGE), |
| 56 commit_waits_for_activation_(false), | 44 commit_waits_for_activation_(false), |
| 57 started_(false), | 45 started_(false), |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 return max_requested_pipeline_stage_ != NO_PIPELINE_STAGE; | 332 return max_requested_pipeline_stage_ != NO_PIPELINE_STAGE; |
| 345 } | 333 } |
| 346 | 334 |
| 347 void ProxyMain::MainThreadHasStoppedFlinging() { | 335 void ProxyMain::MainThreadHasStoppedFlinging() { |
| 348 DCHECK(IsMainThread()); | 336 DCHECK(IsMainThread()); |
| 349 channel_main_->MainThreadHasStoppedFlingingOnImpl(); | 337 channel_main_->MainThreadHasStoppedFlingingOnImpl(); |
| 350 } | 338 } |
| 351 | 339 |
| 352 void ProxyMain::Start() { | 340 void ProxyMain::Start() { |
| 353 DCHECK(IsMainThread()); | 341 DCHECK(IsMainThread()); |
| 354 DCHECK(layer_tree_host_->IsThreaded() || layer_tree_host_->IsRemoteServer()); | 342 DCHECK(layer_tree_host_->IsThreaded()); |
| 355 DCHECK(channel_main_); | 343 DCHECK(channel_main_); |
| 356 | 344 |
| 357 // Create LayerTreeHostImpl. | 345 // Create LayerTreeHostImpl. |
| 358 channel_main_->SynchronouslyInitializeImpl(layer_tree_host_); | 346 channel_main_->SynchronouslyInitializeImpl(layer_tree_host_); |
| 359 | 347 |
| 360 started_ = true; | 348 started_ = true; |
| 361 } | 349 } |
| 362 | 350 |
| 363 void ProxyMain::Stop() { | 351 void ProxyMain::Stop() { |
| 364 TRACE_EVENT0("cc", "ProxyMain::Stop"); | 352 TRACE_EVENT0("cc", "ProxyMain::Stop"); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 return false; | 408 return false; |
| 421 channel_main_->SetNeedsCommitOnImpl(); | 409 channel_main_->SetNeedsCommitOnImpl(); |
| 422 return true; | 410 return true; |
| 423 } | 411 } |
| 424 | 412 |
| 425 bool ProxyMain::IsMainThread() const { | 413 bool ProxyMain::IsMainThread() const { |
| 426 return task_runner_provider_->IsMainThread(); | 414 return task_runner_provider_->IsMainThread(); |
| 427 } | 415 } |
| 428 | 416 |
| 429 } // namespace cc | 417 } // namespace cc |
| OLD | NEW |