Chromium Code Reviews| Index: cc/trees/layer_tree_host.cc |
| diff --git a/cc/trees/layer_tree_host.cc b/cc/trees/layer_tree_host.cc |
| index 70740935217a4482d62abd598cb54e879017a7d4..2d4d8fd5f067b3f73a686c486b6fc6fd0cc1fcca 100644 |
| --- a/cc/trees/layer_tree_host.cc |
| +++ b/cc/trees/layer_tree_host.cc |
| @@ -89,6 +89,36 @@ scoped_ptr<LayerTreeHost> LayerTreeHost::CreateSingleThreaded( |
| return layer_tree_host; |
| } |
| +scoped_ptr<LayerTreeHost> LayerTreeHost::CreateRemote( |
| + RemoteProtoChannel* remote_proto_channel, |
| + InitParams* params) { |
| + DCHECK(params->main_task_runner.get()); |
| + DCHECK(params->settings); |
| + DCHECK(remote_proto_channel); |
| + |
| + // Using an external begin frame source is not supported in remote mode. |
| + DCHECK(!params->settings->use_external_begin_frame_source); |
| + DCHECK(!params->external_begin_frame_source); |
| + |
| + scoped_ptr<LayerTreeHost> layer_tree_host( |
| + new LayerTreeHost(params, CompositorMode::Remote)); |
| + layer_tree_host->InitializeRemote(remote_proto_channel, |
| + params->main_task_runner); |
| + return layer_tree_host; |
| +} |
| + |
| +scoped_ptr<LayerTreeHost> LayerTreeHost::CreateDeserializable( |
| + scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, |
| + InitParams* params) { |
| + DCHECK(params->settings); |
| + |
| + scoped_ptr<LayerTreeHost> layer_tree_host( |
| + new LayerTreeHost(params, CompositorMode::Deserializable)); |
| + layer_tree_host->InitializeDeserializable(params->main_task_runner, |
| + impl_task_runner); |
| + return layer_tree_host; |
| +} |
| + |
| LayerTreeHost::LayerTreeHost(InitParams* params, CompositorMode mode) |
| : micro_benchmark_controller_(this), |
| next_ui_resource_id_(1), |
| @@ -125,7 +155,8 @@ LayerTreeHost::LayerTreeHost(InitParams* params, CompositorMode mode) |
| task_graph_runner_(params->task_graph_runner), |
| surface_id_namespace_(0u), |
| next_surface_sequence_(1u) { |
| - DCHECK(task_graph_runner_); |
| + if (compositor_mode_ != CompositorMode::Remote) |
| + DCHECK(task_graph_runner_); |
| if (settings_.accelerated_animation_enabled) { |
| if (settings_.use_compositor_animation_timelines) { |
| @@ -162,6 +193,22 @@ void LayerTreeHost::InitializeSingleThreaded( |
| std::move(external_begin_frame_source)); |
| } |
| +void LayerTreeHost::InitializeRemote( |
| + RemoteProtoChannel* remote_proto_channel, |
| + scoped_refptr<base::SingleThreadTaskRunner> main_task_runner) { |
| + task_runner_provider_ = TaskRunnerProvider::Create(main_task_runner, nullptr); |
| + InitializeProxy(ProxyMain::CreateRemote(remote_proto_channel, this, |
| + task_runner_provider_.get()), |
| + nullptr); |
| +} |
| + |
| +void LayerTreeHost::InitializeDeserializable( |
|
vmpstr
2016/01/07 19:08:12
I think the rest of the review kind of depends on
Khushal
2016/01/08 21:17:19
Updated this to use the remote mode and the Remote
|
| + scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
| + scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) { |
| + task_runner_provider_ = |
| + TaskRunnerProvider::Create(main_task_runner, impl_task_runner); |
| +} |
| + |
| void LayerTreeHost::InitializeForTesting( |
| scoped_ptr<TaskRunnerProvider> task_runner_provider, |
| scoped_ptr<Proxy> proxy_for_testing, |
| @@ -181,6 +228,7 @@ void LayerTreeHost::InitializeProxy( |
| scoped_ptr<Proxy> proxy, |
| scoped_ptr<BeginFrameSource> external_begin_frame_source) { |
| TRACE_EVENT0("cc", "LayerTreeHost::InitializeForReal"); |
| + DCHECK(task_runner_provider_); |
| proxy_ = std::move(proxy); |
| proxy_->Start(std::move(external_begin_frame_source)); |
| @@ -226,6 +274,20 @@ LayerTreeHost::~LayerTreeHost() { |
| } |
| } |
| +void LayerTreeHost::ToProtobuf() { |
| + DCHECK(task_runner_provider_->IsMainThread()); |
| + DCHECK(IsRemote()); |
| + |
| + // TODO(khushalsagar, nyquist): Serialize LayerTreeHost state to proto. |
| +} |
| + |
| +void LayerTreeHost::FromProtobuf() { |
| + DCHECK(task_runner_provider_->IsMainThread()); |
| + DCHECK(IsDeserializable()); |
| + |
| + // TODO(khushalsagar, nyquist): Deserialize LayerTreeHost state from proto. |
| +} |
| + |
| void LayerTreeHost::WillBeginMainFrame() { |
| devtools_instrumentation::WillBeginMainThreadFrame(id(), |
| source_frame_number()); |
| @@ -258,6 +320,7 @@ void LayerTreeHost::RequestMainFrameUpdate() { |
| // should be delayed until the LayerTreeHost::CommitComplete, which will run |
| // after the commit, but on the main thread. |
| void LayerTreeHost::FinishCommitOnImplThread(LayerTreeHostImpl* host_impl) { |
| + DCHECK(!IsRemote()); |
| DCHECK(task_runner_provider_->IsImplThread()); |
| bool is_new_trace; |
| @@ -443,6 +506,7 @@ void LayerTreeHost::DidFailToInitializeOutputSurface() { |
| scoped_ptr<LayerTreeHostImpl> LayerTreeHost::CreateLayerTreeHostImpl( |
| LayerTreeHostImplClient* client) { |
| + DCHECK(!IsRemote()); |
| DCHECK(task_runner_provider_->IsImplThread()); |
| scoped_ptr<LayerTreeHostImpl> host_impl = LayerTreeHostImpl::Create( |
| settings_, client, task_runner_provider_.get(), |
| @@ -912,8 +976,8 @@ void LayerTreeHost::SetPaintedDeviceScaleFactor( |
| void LayerTreeHost::UpdateTopControlsState(TopControlsState constraints, |
| TopControlsState current, |
| bool animate) { |
| - // Top controls are only used in threaded mode. |
| - DCHECK(IsThreaded()); |
| + // Top controls are only used in threaded or remote mode. |
| + DCHECK(IsThreaded() || IsRemote()); |
| proxy_->UpdateTopControlsState(constraints, current, animate); |
| } |
| @@ -1276,4 +1340,16 @@ bool LayerTreeHost::IsThreaded() const { |
| return compositor_mode_ == CompositorMode::Threaded; |
| } |
| +bool LayerTreeHost::IsRemote() const { |
| + DCHECK(compositor_mode_ != CompositorMode::Remote || |
| + !task_runner_provider_->HasImplThread()); |
| + return compositor_mode_ == CompositorMode::Remote; |
| +} |
| + |
| +bool LayerTreeHost::IsDeserializable() const { |
| + DCHECK(compositor_mode_ != CompositorMode::Deserializable || |
| + task_runner_provider_->HasImplThread()); |
| + return compositor_mode_ == CompositorMode::Deserializable; |
| +} |
| + |
| } // namespace cc |