Chromium Code Reviews| 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/output_surface.h" | 15 #include "cc/output/output_surface.h" |
| 16 #include "cc/output/swap_promise.h" | 16 #include "cc/output/swap_promise.h" |
| 17 #include "cc/trees/blocking_task_runner.h" | 17 #include "cc/trees/blocking_task_runner.h" |
| 18 #include "cc/trees/layer_tree_host.h" | 18 #include "cc/trees/layer_tree_host.h" |
| 19 #include "cc/trees/scoped_abort_remaining_swap_promises.h" | 19 #include "cc/trees/scoped_abort_remaining_swap_promises.h" |
| 20 #include "cc/trees/threaded_channel.h" | 20 #include "cc/trees/threaded_channel.h" |
| 21 | 21 |
| 22 namespace cc { | 22 namespace cc { |
| 23 | 23 |
| 24 scoped_ptr<ProxyMain> ProxyMain::CreateThreaded( | 24 scoped_ptr<ProxyMain> ProxyMain::CreateThreaded( |
| 25 LayerTreeHost* layer_tree_host, | 25 LayerTreeHost* layer_tree_host, |
| 26 TaskRunnerProvider* task_runner_provider, | 26 TaskRunnerProvider* task_runner_provider) { |
| 27 scoped_ptr<BeginFrameSource> external_begin_frame_source) { | |
| 28 scoped_ptr<ProxyMain> proxy_main( | 27 scoped_ptr<ProxyMain> proxy_main( |
| 29 new ProxyMain(layer_tree_host, task_runner_provider, | 28 new ProxyMain(layer_tree_host, task_runner_provider)); |
| 30 std::move(external_begin_frame_source))); | |
| 31 proxy_main->SetChannel( | 29 proxy_main->SetChannel( |
| 32 ThreadedChannel::Create(proxy_main.get(), task_runner_provider)); | 30 ThreadedChannel::Create(proxy_main.get(), task_runner_provider)); |
| 33 return proxy_main; | 31 return proxy_main; |
| 34 } | 32 } |
| 35 | 33 |
| 36 ProxyMain::ProxyMain(LayerTreeHost* layer_tree_host, | 34 ProxyMain::ProxyMain(LayerTreeHost* layer_tree_host, |
| 37 TaskRunnerProvider* task_runner_provider, | 35 TaskRunnerProvider* task_runner_provider) |
| 38 scoped_ptr<BeginFrameSource> external_begin_frame_source) | |
| 39 : layer_tree_host_(layer_tree_host), | 36 : layer_tree_host_(layer_tree_host), |
| 40 task_runner_provider_(task_runner_provider), | 37 task_runner_provider_(task_runner_provider), |
| 41 layer_tree_host_id_(layer_tree_host->id()), | 38 layer_tree_host_id_(layer_tree_host->id()), |
| 42 max_requested_pipeline_stage_(NO_PIPELINE_STAGE), | 39 max_requested_pipeline_stage_(NO_PIPELINE_STAGE), |
| 43 current_pipeline_stage_(NO_PIPELINE_STAGE), | 40 current_pipeline_stage_(NO_PIPELINE_STAGE), |
| 44 final_pipeline_stage_(NO_PIPELINE_STAGE), | 41 final_pipeline_stage_(NO_PIPELINE_STAGE), |
| 45 commit_waits_for_activation_(false), | 42 commit_waits_for_activation_(false), |
| 46 started_(false), | 43 started_(false), |
| 47 defer_commits_(false), | 44 defer_commits_(false) { |
| 48 external_begin_frame_source_(std::move(external_begin_frame_source)) { | |
| 49 TRACE_EVENT0("cc", "ProxyMain::ProxyMain"); | 45 TRACE_EVENT0("cc", "ProxyMain::ProxyMain"); |
| 50 DCHECK(task_runner_provider_); | 46 DCHECK(task_runner_provider_); |
| 51 DCHECK(IsMainThread()); | 47 DCHECK(IsMainThread()); |
| 52 DCHECK(!layer_tree_host_->settings().use_external_begin_frame_source || | |
|
brianderson
2015/12/10 23:06:02
Can you keep this DCHECK in ProxyMain::Start?
Khushal
2015/12/11 02:37:40
Done.
| |
| 53 external_begin_frame_source_); | |
| 54 } | 48 } |
| 55 | 49 |
| 56 ProxyMain::~ProxyMain() { | 50 ProxyMain::~ProxyMain() { |
| 57 TRACE_EVENT0("cc", "ProxyMain::~ProxyMain"); | 51 TRACE_EVENT0("cc", "ProxyMain::~ProxyMain"); |
| 58 DCHECK(IsMainThread()); | 52 DCHECK(IsMainThread()); |
| 59 DCHECK(!started_); | 53 DCHECK(!started_); |
| 60 } | 54 } |
| 61 | 55 |
| 62 void ProxyMain::SetChannel(scoped_ptr<ChannelMain> channel_main) { | 56 void ProxyMain::SetChannel(scoped_ptr<ChannelMain> channel_main) { |
| 63 DCHECK(!channel_main_); | 57 DCHECK(!channel_main_); |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 373 bool ProxyMain::BeginMainFrameRequested() const { | 367 bool ProxyMain::BeginMainFrameRequested() const { |
| 374 DCHECK(IsMainThread()); | 368 DCHECK(IsMainThread()); |
| 375 return max_requested_pipeline_stage_ != NO_PIPELINE_STAGE; | 369 return max_requested_pipeline_stage_ != NO_PIPELINE_STAGE; |
| 376 } | 370 } |
| 377 | 371 |
| 378 void ProxyMain::MainThreadHasStoppedFlinging() { | 372 void ProxyMain::MainThreadHasStoppedFlinging() { |
| 379 DCHECK(IsMainThread()); | 373 DCHECK(IsMainThread()); |
| 380 channel_main_->MainThreadHasStoppedFlingingOnImpl(); | 374 channel_main_->MainThreadHasStoppedFlingingOnImpl(); |
| 381 } | 375 } |
| 382 | 376 |
| 383 void ProxyMain::Start() { | 377 void ProxyMain::Start( |
| 378 scoped_ptr<BeginFrameSource> external_begin_frame_source) { | |
| 384 DCHECK(IsMainThread()); | 379 DCHECK(IsMainThread()); |
| 385 DCHECK(task_runner_provider_->HasImplThread()); | 380 DCHECK(task_runner_provider_->HasImplThread()); |
| 386 DCHECK(channel_main_); | 381 DCHECK(channel_main_); |
| 387 | 382 |
| 388 // Create LayerTreeHostImpl. | 383 // Create LayerTreeHostImpl. |
| 389 channel_main_->SynchronouslyInitializeImpl( | 384 channel_main_->SynchronouslyInitializeImpl( |
| 390 layer_tree_host_, std::move(external_begin_frame_source_)); | 385 layer_tree_host_, std::move(external_begin_frame_source)); |
| 391 | 386 |
| 392 started_ = true; | 387 started_ = true; |
| 393 } | 388 } |
| 394 | 389 |
| 395 void ProxyMain::Stop() { | 390 void ProxyMain::Stop() { |
| 396 TRACE_EVENT0("cc", "ProxyMain::Stop"); | 391 TRACE_EVENT0("cc", "ProxyMain::Stop"); |
| 397 DCHECK(IsMainThread()); | 392 DCHECK(IsMainThread()); |
| 398 DCHECK(started_); | 393 DCHECK(started_); |
| 399 | 394 |
| 400 channel_main_->SynchronouslyCloseImpl(); | 395 channel_main_->SynchronouslyCloseImpl(); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 456 return false; | 451 return false; |
| 457 channel_main_->SetNeedsCommitOnImpl(); | 452 channel_main_->SetNeedsCommitOnImpl(); |
| 458 return true; | 453 return true; |
| 459 } | 454 } |
| 460 | 455 |
| 461 bool ProxyMain::IsMainThread() const { | 456 bool ProxyMain::IsMainThread() const { |
| 462 return task_runner_provider_->IsMainThread(); | 457 return task_runner_provider_->IsMainThread(); |
| 463 } | 458 } |
| 464 | 459 |
| 465 } // namespace cc | 460 } // namespace cc |
| OLD | NEW |