| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/remote_channel_impl.h" | 5 #include "cc/trees/remote_channel_impl.h" |
| 6 | 6 |
| 7 #include "base/bind_helpers.h" | 7 #include "base/bind_helpers.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
| 10 #include "cc/animation/animation_events.h" | 10 #include "cc/animation/animation_events.h" |
| 11 #include "cc/proto/compositor_message.pb.h" | 11 #include "cc/proto/compositor_message.pb.h" |
| 12 #include "cc/proto/compositor_message_to_impl.pb.h" | 12 #include "cc/proto/compositor_message_to_impl.pb.h" |
| 13 #include "cc/proto/compositor_message_to_main.pb.h" | 13 #include "cc/proto/compositor_message_to_main.pb.h" |
| 14 #include "cc/proto/gfx_conversions.h" | 14 #include "cc/proto/gfx_conversions.h" |
| 15 #include "cc/trees/layer_tree_host.h" | 15 #include "cc/trees/layer_tree_host_in_process.h" |
| 16 #include "cc/trees/layer_tree_settings.h" | 16 #include "cc/trees/layer_tree_settings.h" |
| 17 | 17 |
| 18 namespace cc { | 18 namespace cc { |
| 19 | 19 |
| 20 RemoteChannelImpl::RemoteChannelImpl(LayerTreeHost* layer_tree_host, | 20 RemoteChannelImpl::RemoteChannelImpl(LayerTreeHostInProcess* layer_tree_host, |
| 21 RemoteProtoChannel* remote_proto_channel, | 21 RemoteProtoChannel* remote_proto_channel, |
| 22 TaskRunnerProvider* task_runner_provider) | 22 TaskRunnerProvider* task_runner_provider) |
| 23 : task_runner_provider_(task_runner_provider), | 23 : task_runner_provider_(task_runner_provider), |
| 24 main_thread_vars_unsafe_(this, layer_tree_host, remote_proto_channel), | 24 main_thread_vars_unsafe_(this, layer_tree_host, remote_proto_channel), |
| 25 compositor_thread_vars_unsafe_( | 25 compositor_thread_vars_unsafe_( |
| 26 main().remote_channel_weak_factory.GetWeakPtr()) { | 26 main().remote_channel_weak_factory.GetWeakPtr()) { |
| 27 DCHECK(task_runner_provider_->IsMainThread()); | 27 DCHECK(task_runner_provider_->IsMainThread()); |
| 28 | 28 |
| 29 main().remote_proto_channel->SetProtoReceiver(this); | 29 main().remote_proto_channel->SetProtoReceiver(this); |
| 30 } | 30 } |
| 31 | 31 |
| 32 RemoteChannelImpl::~RemoteChannelImpl() { | 32 RemoteChannelImpl::~RemoteChannelImpl() { |
| 33 DCHECK(task_runner_provider_->IsMainThread()); | 33 DCHECK(task_runner_provider_->IsMainThread()); |
| 34 DCHECK(!main().started); | 34 DCHECK(!main().started); |
| 35 | 35 |
| 36 main().remote_proto_channel->SetProtoReceiver(nullptr); | 36 main().remote_proto_channel->SetProtoReceiver(nullptr); |
| 37 } | 37 } |
| 38 | 38 |
| 39 std::unique_ptr<ProxyImpl> RemoteChannelImpl::CreateProxyImpl( | 39 std::unique_ptr<ProxyImpl> RemoteChannelImpl::CreateProxyImpl( |
| 40 ChannelImpl* channel_impl, | 40 ChannelImpl* channel_impl, |
| 41 LayerTreeHost* layer_tree_host, | 41 LayerTreeHostInProcess* layer_tree_host, |
| 42 TaskRunnerProvider* task_runner_provider, | 42 TaskRunnerProvider* task_runner_provider, |
| 43 std::unique_ptr<BeginFrameSource> external_begin_frame_source) { | 43 std::unique_ptr<BeginFrameSource> external_begin_frame_source) { |
| 44 DCHECK(task_runner_provider_->IsImplThread()); | 44 DCHECK(task_runner_provider_->IsImplThread()); |
| 45 DCHECK(!external_begin_frame_source); | 45 DCHECK(!external_begin_frame_source); |
| 46 return base::MakeUnique<ProxyImpl>(channel_impl, layer_tree_host, | 46 return base::MakeUnique<ProxyImpl>(channel_impl, layer_tree_host, |
| 47 task_runner_provider, | 47 task_runner_provider, |
| 48 std::move(external_begin_frame_source)); | 48 std::move(external_begin_frame_source)); |
| 49 } | 49 } |
| 50 | 50 |
| 51 void RemoteChannelImpl::OnProtoReceived( | 51 void RemoteChannelImpl::OnProtoReceived( |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 void RemoteChannelImpl::SetNeedsAnimate() { | 185 void RemoteChannelImpl::SetNeedsAnimate() { |
| 186 NOTREACHED() << "Should not be called on the remote client LayerTreeHost"; | 186 NOTREACHED() << "Should not be called on the remote client LayerTreeHost"; |
| 187 } | 187 } |
| 188 | 188 |
| 189 void RemoteChannelImpl::SetNeedsUpdateLayers() { | 189 void RemoteChannelImpl::SetNeedsUpdateLayers() { |
| 190 NOTREACHED() << "Should not be called on the remote client LayerTreeHost"; | 190 NOTREACHED() << "Should not be called on the remote client LayerTreeHost"; |
| 191 } | 191 } |
| 192 | 192 |
| 193 void RemoteChannelImpl::SetNeedsCommit() { | 193 void RemoteChannelImpl::SetNeedsCommit() { |
| 194 // Ideally commits should be requested only on the server. But we have to | 194 // Ideally commits should be requested only on the server. But we have to |
| 195 // allow this call since the LayerTreeHost will currently ask for a commit in | 195 // allow this call since the LayerTreeHostInProcesswill currently ask for a |
| 196 // 2 cases: | 196 // commit in 2 cases: |
| 197 // 1) When it is being initialized from a protobuf for a commit. | 197 // 1) When it is being initialized from a protobuf for a commit. |
| 198 // 2) When it loses the CompositorFrameSink. | 198 // 2) When it loses the CompositorFrameSink. |
| 199 NOTIMPLEMENTED() << "Commits should not be requested on the client"; | 199 NOTIMPLEMENTED() << "Commits should not be requested on the client"; |
| 200 } | 200 } |
| 201 | 201 |
| 202 void RemoteChannelImpl::SetNeedsRedraw(const gfx::Rect& damage_rect) { | 202 void RemoteChannelImpl::SetNeedsRedraw(const gfx::Rect& damage_rect) { |
| 203 NOTREACHED() << "Should not be called on the remote client LayerTreeHost"; | 203 NOTREACHED() << "Should not be called on the remote client LayerTreeHost"; |
| 204 } | 204 } |
| 205 | 205 |
| 206 void RemoteChannelImpl::SetNextCommitWaitsForActivation() { | 206 void RemoteChannelImpl::SetNextCommitWaitsForActivation() { |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 | 434 |
| 435 void RemoteChannelImpl::PostSetNeedsRedrawToImpl( | 435 void RemoteChannelImpl::PostSetNeedsRedrawToImpl( |
| 436 const gfx::Rect& damaged_rect) { | 436 const gfx::Rect& damaged_rect) { |
| 437 DCHECK(task_runner_provider_->IsMainThread()); | 437 DCHECK(task_runner_provider_->IsMainThread()); |
| 438 | 438 |
| 439 ImplThreadTaskRunner()->PostTask( | 439 ImplThreadTaskRunner()->PostTask( |
| 440 FROM_HERE, base::Bind(&ProxyImpl::SetNeedsRedrawOnImpl, | 440 FROM_HERE, base::Bind(&ProxyImpl::SetNeedsRedrawOnImpl, |
| 441 proxy_impl_weak_ptr_, damaged_rect)); | 441 proxy_impl_weak_ptr_, damaged_rect)); |
| 442 } | 442 } |
| 443 | 443 |
| 444 void RemoteChannelImpl::InitializeImplOnImpl(CompletionEvent* completion, | 444 void RemoteChannelImpl::InitializeImplOnImpl( |
| 445 LayerTreeHost* layer_tree_host) { | 445 CompletionEvent* completion, |
| 446 LayerTreeHostInProcess* layer_tree_host) { |
| 446 DCHECK(task_runner_provider_->IsMainThreadBlocked()); | 447 DCHECK(task_runner_provider_->IsMainThreadBlocked()); |
| 447 DCHECK(task_runner_provider_->IsImplThread()); | 448 DCHECK(task_runner_provider_->IsImplThread()); |
| 448 | 449 |
| 449 impl().proxy_impl = | 450 impl().proxy_impl = |
| 450 CreateProxyImpl(this, layer_tree_host, task_runner_provider_, nullptr); | 451 CreateProxyImpl(this, layer_tree_host, task_runner_provider_, nullptr); |
| 451 impl().proxy_impl_weak_factory = | 452 impl().proxy_impl_weak_factory = |
| 452 base::MakeUnique<base::WeakPtrFactory<ProxyImpl>>( | 453 base::MakeUnique<base::WeakPtrFactory<ProxyImpl>>( |
| 453 impl().proxy_impl.get()); | 454 impl().proxy_impl.get()); |
| 454 proxy_impl_weak_ptr_ = impl().proxy_impl_weak_factory->GetWeakPtr(); | 455 proxy_impl_weak_ptr_ = impl().proxy_impl_weak_factory->GetWeakPtr(); |
| 455 completion->Signal(); | 456 completion->Signal(); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 base::SingleThreadTaskRunner* RemoteChannelImpl::MainThreadTaskRunner() const { | 492 base::SingleThreadTaskRunner* RemoteChannelImpl::MainThreadTaskRunner() const { |
| 492 return task_runner_provider_->MainThreadTaskRunner(); | 493 return task_runner_provider_->MainThreadTaskRunner(); |
| 493 } | 494 } |
| 494 | 495 |
| 495 base::SingleThreadTaskRunner* RemoteChannelImpl::ImplThreadTaskRunner() const { | 496 base::SingleThreadTaskRunner* RemoteChannelImpl::ImplThreadTaskRunner() const { |
| 496 return task_runner_provider_->ImplThreadTaskRunner(); | 497 return task_runner_provider_->ImplThreadTaskRunner(); |
| 497 } | 498 } |
| 498 | 499 |
| 499 RemoteChannelImpl::MainThreadOnly::MainThreadOnly( | 500 RemoteChannelImpl::MainThreadOnly::MainThreadOnly( |
| 500 RemoteChannelImpl* remote_channel_impl, | 501 RemoteChannelImpl* remote_channel_impl, |
| 501 LayerTreeHost* layer_tree_host, | 502 LayerTreeHostInProcess* layer_tree_host, |
| 502 RemoteProtoChannel* remote_proto_channel) | 503 RemoteProtoChannel* remote_proto_channel) |
| 503 : layer_tree_host(layer_tree_host), | 504 : layer_tree_host(layer_tree_host), |
| 504 remote_proto_channel(remote_proto_channel), | 505 remote_proto_channel(remote_proto_channel), |
| 505 started(false), | 506 started(false), |
| 506 waiting_for_compositor_frame_sink_initialization(false), | 507 waiting_for_compositor_frame_sink_initialization(false), |
| 507 remote_channel_weak_factory(remote_channel_impl) { | 508 remote_channel_weak_factory(remote_channel_impl) { |
| 508 DCHECK(layer_tree_host); | 509 DCHECK(layer_tree_host); |
| 509 DCHECK(remote_proto_channel); | 510 DCHECK(remote_proto_channel); |
| 510 } | 511 } |
| 511 | 512 |
| 512 RemoteChannelImpl::MainThreadOnly::~MainThreadOnly() {} | 513 RemoteChannelImpl::MainThreadOnly::~MainThreadOnly() {} |
| 513 | 514 |
| 514 RemoteChannelImpl::CompositorThreadOnly::CompositorThreadOnly( | 515 RemoteChannelImpl::CompositorThreadOnly::CompositorThreadOnly( |
| 515 base::WeakPtr<RemoteChannelImpl> remote_channel_weak_ptr) | 516 base::WeakPtr<RemoteChannelImpl> remote_channel_weak_ptr) |
| 516 : proxy_impl(nullptr), | 517 : proxy_impl(nullptr), |
| 517 proxy_impl_weak_factory(nullptr), | 518 proxy_impl_weak_factory(nullptr), |
| 518 remote_channel_weak_ptr(remote_channel_weak_ptr) {} | 519 remote_channel_weak_ptr(remote_channel_weak_ptr) {} |
| 519 | 520 |
| 520 RemoteChannelImpl::CompositorThreadOnly::~CompositorThreadOnly() {} | 521 RemoteChannelImpl::CompositorThreadOnly::~CompositorThreadOnly() {} |
| 521 | 522 |
| 522 } // namespace cc | 523 } // namespace cc |
| OLD | NEW |