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.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 std::unique_ptr<RemoteChannelImpl> RemoteChannelImpl::Create( | |
21 LayerTreeHost* layer_tree_host, | |
22 RemoteProtoChannel* remote_proto_channel, | |
23 TaskRunnerProvider* task_runner_provider) { | |
24 return base::WrapUnique(new RemoteChannelImpl( | |
25 layer_tree_host, remote_proto_channel, task_runner_provider)); | |
26 } | |
27 | |
28 RemoteChannelImpl::RemoteChannelImpl(LayerTreeHost* layer_tree_host, | 20 RemoteChannelImpl::RemoteChannelImpl(LayerTreeHost* layer_tree_host, |
29 RemoteProtoChannel* remote_proto_channel, | 21 RemoteProtoChannel* remote_proto_channel, |
30 TaskRunnerProvider* task_runner_provider) | 22 TaskRunnerProvider* task_runner_provider) |
31 : task_runner_provider_(task_runner_provider), | 23 : task_runner_provider_(task_runner_provider), |
32 main_thread_vars_unsafe_(this, layer_tree_host, remote_proto_channel), | 24 main_thread_vars_unsafe_(this, layer_tree_host, remote_proto_channel), |
33 compositor_thread_vars_unsafe_( | 25 compositor_thread_vars_unsafe_( |
34 main().remote_channel_weak_factory.GetWeakPtr()) { | 26 main().remote_channel_weak_factory.GetWeakPtr()) { |
35 DCHECK(task_runner_provider_->IsMainThread()); | 27 DCHECK(task_runner_provider_->IsMainThread()); |
36 | 28 |
37 main().remote_proto_channel->SetProtoReceiver(this); | 29 main().remote_proto_channel->SetProtoReceiver(this); |
38 } | 30 } |
39 | 31 |
40 RemoteChannelImpl::~RemoteChannelImpl() { | 32 RemoteChannelImpl::~RemoteChannelImpl() { |
41 DCHECK(task_runner_provider_->IsMainThread()); | 33 DCHECK(task_runner_provider_->IsMainThread()); |
42 DCHECK(!main().started); | 34 DCHECK(!main().started); |
43 | 35 |
44 main().remote_proto_channel->SetProtoReceiver(nullptr); | 36 main().remote_proto_channel->SetProtoReceiver(nullptr); |
45 } | 37 } |
46 | 38 |
47 std::unique_ptr<ProxyImpl> RemoteChannelImpl::CreateProxyImpl( | 39 std::unique_ptr<ProxyImpl> RemoteChannelImpl::CreateProxyImpl( |
48 ChannelImpl* channel_impl, | 40 ChannelImpl* channel_impl, |
49 LayerTreeHost* layer_tree_host, | 41 LayerTreeHost* layer_tree_host, |
50 TaskRunnerProvider* task_runner_provider, | 42 TaskRunnerProvider* task_runner_provider, |
51 std::unique_ptr<BeginFrameSource> external_begin_frame_source) { | 43 std::unique_ptr<BeginFrameSource> external_begin_frame_source) { |
52 DCHECK(task_runner_provider_->IsImplThread()); | 44 DCHECK(task_runner_provider_->IsImplThread()); |
53 DCHECK(!external_begin_frame_source); | 45 DCHECK(!external_begin_frame_source); |
54 return ProxyImpl::Create(channel_impl, layer_tree_host, task_runner_provider, | 46 return base::MakeUnique<ProxyImpl>(channel_impl, layer_tree_host, |
55 std::move(external_begin_frame_source)); | 47 task_runner_provider, |
| 48 std::move(external_begin_frame_source)); |
56 } | 49 } |
57 | 50 |
58 void RemoteChannelImpl::OnProtoReceived( | 51 void RemoteChannelImpl::OnProtoReceived( |
59 std::unique_ptr<proto::CompositorMessage> proto) { | 52 std::unique_ptr<proto::CompositorMessage> proto) { |
60 DCHECK(task_runner_provider_->IsMainThread()); | 53 DCHECK(task_runner_provider_->IsMainThread()); |
61 DCHECK(main().started); | 54 DCHECK(main().started); |
62 DCHECK(proto->has_to_impl()); | 55 DCHECK(proto->has_to_impl()); |
63 | 56 |
64 // If we don't have an output surface, queue the message and defer processing | 57 // If we don't have an output surface, queue the message and defer processing |
65 // it till we initialize a new output surface. | 58 // it till we initialize a new output surface. |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 main().layer_tree_host->FromProtobufForCommit( | 111 main().layer_tree_host->FromProtobufForCommit( |
119 start_commit_message.layer_tree_host()); | 112 start_commit_message.layer_tree_host()); |
120 | 113 |
121 { | 114 { |
122 DebugScopedSetMainThreadBlocked main_thread_blocked( | 115 DebugScopedSetMainThreadBlocked main_thread_blocked( |
123 task_runner_provider_); | 116 task_runner_provider_); |
124 CompletionEvent completion; | 117 CompletionEvent completion; |
125 VLOG(1) << "Starting commit."; | 118 VLOG(1) << "Starting commit."; |
126 ImplThreadTaskRunner()->PostTask( | 119 ImplThreadTaskRunner()->PostTask( |
127 FROM_HERE, | 120 FROM_HERE, |
128 base::Bind(&ProxyImpl::StartCommitOnImpl, proxy_impl_weak_ptr_, | 121 base::Bind(&ProxyImpl::NotifyReadyToCommitOnImpl, |
129 &completion, main().layer_tree_host, | 122 proxy_impl_weak_ptr_, &completion, |
130 main_thread_start_time, false)); | 123 main().layer_tree_host, main_thread_start_time, false)); |
131 completion.Wait(); | 124 completion.Wait(); |
132 } | 125 } |
133 } break; | 126 } break; |
134 case proto::CompositorMessageToImpl::BEGIN_MAIN_FRAME_ABORTED: { | 127 case proto::CompositorMessageToImpl::BEGIN_MAIN_FRAME_ABORTED: { |
135 base::TimeTicks main_thread_start_time = base::TimeTicks::Now(); | 128 base::TimeTicks main_thread_start_time = base::TimeTicks::Now(); |
136 const proto::BeginMainFrameAborted& begin_main_frame_aborted_message = | 129 const proto::BeginMainFrameAborted& begin_main_frame_aborted_message = |
137 proto.begin_main_frame_aborted_message(); | 130 proto.begin_main_frame_aborted_message(); |
138 CommitEarlyOutReason reason = CommitEarlyOutReasonFromProtobuf( | 131 CommitEarlyOutReason reason = CommitEarlyOutReasonFromProtobuf( |
139 begin_main_frame_aborted_message.reason()); | 132 begin_main_frame_aborted_message.reason()); |
140 VLOG(1) << "Received BeginMainFrameAborted from the engine with reason: " | 133 VLOG(1) << "Received BeginMainFrameAborted from the engine with reason: " |
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
543 | 536 |
544 RemoteChannelImpl::CompositorThreadOnly::CompositorThreadOnly( | 537 RemoteChannelImpl::CompositorThreadOnly::CompositorThreadOnly( |
545 base::WeakPtr<RemoteChannelImpl> remote_channel_weak_ptr) | 538 base::WeakPtr<RemoteChannelImpl> remote_channel_weak_ptr) |
546 : proxy_impl(nullptr), | 539 : proxy_impl(nullptr), |
547 proxy_impl_weak_factory(nullptr), | 540 proxy_impl_weak_factory(nullptr), |
548 remote_channel_weak_ptr(remote_channel_weak_ptr) {} | 541 remote_channel_weak_ptr(remote_channel_weak_ptr) {} |
549 | 542 |
550 RemoteChannelImpl::CompositorThreadOnly::~CompositorThreadOnly() {} | 543 RemoteChannelImpl::CompositorThreadOnly::~CompositorThreadOnly() {} |
551 | 544 |
552 } // namespace cc | 545 } // namespace cc |
OLD | NEW |