| Index: cc/trees/layer_tree_host.cc
|
| diff --git a/cc/trees/layer_tree_host.cc b/cc/trees/layer_tree_host.cc
|
| index 6eb60f64390c425fec8fd98fad4578c69f8b21cf..af778dcf62d88ae739ee7dd04959c93ba5d2b521 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) {
|
| @@ -168,6 +213,7 @@ void LayerTreeHost::InitializeForTesting(
|
|
|
| void LayerTreeHost::InitializeProxy(scoped_ptr<Proxy> proxy) {
|
| TRACE_EVENT0("cc", "LayerTreeHost::InitializeForReal");
|
| + DCHECK(task_runner_provider_);
|
|
|
| proxy_ = std::move(proxy);
|
| proxy_->Start();
|
| @@ -245,6 +291,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;
|
| @@ -430,6 +477,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(),
|
| @@ -737,8 +785,8 @@ static Layer* FindFirstScrollableLayer(Layer* layer) {
|
|
|
| void LayerTreeHost::RecordGpuRasterizationHistogram() {
|
| // Gpu rasterization is only supported for Renderer compositors.
|
| - // Checking for IsThreaded() to exclude Browser compositors.
|
| - if (gpu_rasterization_histogram_recorded_ || IsThreaded())
|
| + // Checking for IsSingleThreaded() to exclude Browser compositors.
|
| + if (gpu_rasterization_histogram_recorded_ || IsSingleThreaded())
|
| return;
|
|
|
| // Record how widely gpu rasterization is enabled.
|
| @@ -899,8 +947,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);
|
| }
|
|
|
| @@ -1263,4 +1311,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
|
|
|