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_main.h" | 5 #include "cc/trees/remote_channel_main.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "cc/proto/base_conversions.h" | 10 #include "cc/proto/base_conversions.h" |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 CompletionEvent* completion, | 170 CompletionEvent* completion, |
171 LayerTreeHost* layer_tree_host, | 171 LayerTreeHost* layer_tree_host, |
172 base::TimeTicks main_thread_start_time, | 172 base::TimeTicks main_thread_start_time, |
173 bool hold_commit_for_activation) { | 173 bool hold_commit_for_activation) { |
174 TRACE_EVENT0("cc.remote", "RemoteChannelMain::StartCommitOnImpl"); | 174 TRACE_EVENT0("cc.remote", "RemoteChannelMain::StartCommitOnImpl"); |
175 proto::CompositorMessage proto; | 175 proto::CompositorMessage proto; |
176 proto::CompositorMessageToImpl* to_impl_proto = proto.mutable_to_impl(); | 176 proto::CompositorMessageToImpl* to_impl_proto = proto.mutable_to_impl(); |
177 to_impl_proto->set_message_type(proto::CompositorMessageToImpl::START_COMMIT); | 177 to_impl_proto->set_message_type(proto::CompositorMessageToImpl::START_COMMIT); |
178 proto::StartCommit* start_commit_message = | 178 proto::StartCommit* start_commit_message = |
179 to_impl_proto->mutable_start_commit_message(); | 179 to_impl_proto->mutable_start_commit_message(); |
| 180 std::vector<std::unique_ptr<SwapPromise>> swap_promises; |
180 layer_tree_host->ToProtobufForCommit( | 181 layer_tree_host->ToProtobufForCommit( |
181 start_commit_message->mutable_layer_tree_host()); | 182 start_commit_message->mutable_layer_tree_host(), &swap_promises); |
182 | 183 |
183 VLOG(1) << "Sending commit message to client. Commit bytes size: " | 184 VLOG(1) << "Sending commit message to client. Commit bytes size: " |
184 << proto.ByteSize(); | 185 << proto.ByteSize(); |
185 SendMessageProto(proto); | 186 SendMessageProto(proto); |
186 | 187 |
| 188 // Activate the swap promises after the commit is queued. |
| 189 // In the threaded compositor, activation implies that the pending tree on the |
| 190 // impl thread has been activated. While the impl thread for the remote |
| 191 // compositor is on the client, the embedder still expects to receive these |
| 192 // events in order to drive decisions that depend on impl frame production. |
| 193 // So we dispatch these events after a commit message is sent to the client. |
| 194 // Sending the commit message implies that a visual update has been queued for |
| 195 // the client, which is the closest we can come to offering an indicator akin |
| 196 // to an impl frame queued for display. |
| 197 for (const auto& swap_promise : swap_promises) |
| 198 swap_promise->DidActivate(); |
| 199 |
187 // In order to avoid incurring the overhead for the client to send us a | 200 // In order to avoid incurring the overhead for the client to send us a |
188 // message for when a frame to be committed is drawn we inform the embedder | 201 // message for when a frame to be committed is drawn we inform the embedder |
189 // that the draw was successful immediately after sending the commit message. | 202 // that the draw was successful immediately after sending the commit message. |
190 // Since the compositing state may be used by the embedder to throttle | 203 // Since the compositing state may be used by the embedder to throttle |
191 // commit/draw requests, it is better to allow them to propagate rather than | 204 // commit/draw requests, it is better to allow them to propagate rather than |
192 // incurring a round-trip to get Acks for draw from the client for each frame. | 205 // incurring a round-trip to get Acks for draw from the client for each frame. |
193 | 206 |
194 // This is done as a separate PostTask to ensure that these calls run after | 207 // This is done as a separate PostTask to ensure that these calls run after |
195 // LayerTreeHostClient::DidCommit and stay consistent with the | 208 // LayerTreeHostClient::DidCommit and stay consistent with the |
196 // behaviour in the threaded compositor. | 209 // behaviour in the threaded compositor. |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 | 283 |
271 void RemoteChannelMain::DidCompleteSwapBuffers() { | 284 void RemoteChannelMain::DidCompleteSwapBuffers() { |
272 proxy_main_->DidCompleteSwapBuffers(); | 285 proxy_main_->DidCompleteSwapBuffers(); |
273 } | 286 } |
274 | 287 |
275 base::SingleThreadTaskRunner* RemoteChannelMain::MainThreadTaskRunner() const { | 288 base::SingleThreadTaskRunner* RemoteChannelMain::MainThreadTaskRunner() const { |
276 return task_runner_provider_->MainThreadTaskRunner(); | 289 return task_runner_provider_->MainThreadTaskRunner(); |
277 } | 290 } |
278 | 291 |
279 } // namespace cc | 292 } // namespace cc |
OLD | NEW |