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 6ac4cd38e7be7a32e57d72011cd862c3cf0375aa..03cc19d5cc11135526a963d67c8888008fd9ff0a 100644 |
| --- a/cc/trees/layer_tree_host.cc |
| +++ b/cc/trees/layer_tree_host.cc |
| @@ -86,6 +86,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), |
| @@ -122,7 +152,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) { |
| @@ -143,10 +174,9 @@ void LayerTreeHost::InitializeThreaded( |
| scoped_ptr<BeginFrameSource> external_begin_frame_source) { |
| task_runner_provider_ = |
| TaskRunnerProvider::Create(main_task_runner, impl_task_runner); |
| - scoped_ptr<ProxyMain> proxy_main = |
| + InitializeProxy( |
| ProxyMain::CreateThreaded(this, task_runner_provider_.get(), |
| - std::move(external_begin_frame_source)); |
| - InitializeProxy(std::move(proxy_main)); |
| + std::move(external_begin_frame_source))); |
| } |
| void LayerTreeHost::InitializeSingleThreaded( |
| @@ -159,6 +189,21 @@ 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())); |
| +} |
| + |
| +void LayerTreeHost::InitializeDeserializable( |
| + 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) { |
| @@ -174,6 +219,7 @@ void LayerTreeHost::SetTaskRunnerProviderForTesting( |
| void LayerTreeHost::InitializeProxy(scoped_ptr<Proxy> proxy) { |
| TRACE_EVENT0("cc", "LayerTreeHost::InitializeForReal"); |
| + DCHECK(task_runner_provider_); |
| proxy_ = std::move(proxy); |
| proxy_->Start(); |
| @@ -219,6 +265,16 @@ LayerTreeHost::~LayerTreeHost() { |
| } |
| } |
| +void LayerTreeHost::ToProtobuf() { |
|
David Trainor- moved to gerrit
2015/12/15 00:52:14
Add todo to implement?
Khushal
2015/12/15 05:05:30
Done.
|
| + DCHECK(task_runner_provider_->IsMainThread()); |
| + DCHECK(IsRemote()); |
| +} |
| + |
| +void LayerTreeHost::FromProtobuf() { |
| + DCHECK(task_runner_provider_->IsMainThread()); |
| + DCHECK(IsDeserializable()); |
| +} |
| + |
| void LayerTreeHost::WillBeginMainFrame() { |
| devtools_instrumentation::WillBeginMainThreadFrame(id(), |
| source_frame_number()); |
| @@ -251,6 +307,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; |
| @@ -436,6 +493,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(), |
| @@ -905,8 +963,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); |
| } |
| @@ -1269,4 +1327,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 |