Chromium Code Reviews| 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" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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( |
| 52 std::unique_ptr<proto::CompositorMessage> proto) { | 52 std::unique_ptr<proto::CompositorMessage> proto) { |
| 53 DCHECK(task_runner_provider_->IsMainThread()); | 53 DCHECK(task_runner_provider_->IsMainThread()); |
| 54 DCHECK(main().started); | 54 DCHECK(main().started); |
| 55 DCHECK(proto->has_to_impl()); | 55 DCHECK(proto->has_to_impl()); |
| 56 | 56 |
| 57 // If we don't have an output surface, queue the message and defer processing | 57 // If we don't have an CompositorFrameSink, queue the message and defer |
| 58 // it till we initialize a new output surface. | 58 // processing |
|
enne (OOO)
2016/09/14 00:35:45
@_@
| |
| 59 if (main().waiting_for_output_surface_initialization) { | 59 // it till we initialize a new CompositorFrameSink. |
| 60 VLOG(1) << "Queueing message proto since output surface was released."; | 60 if (main().waiting_for_compositor_frame_sink_initialization) { |
| 61 VLOG(1) << "Queueing message proto since CompositorFrameSink was released."; | |
| 61 main().pending_messages.push(proto->to_impl()); | 62 main().pending_messages.push(proto->to_impl()); |
| 62 } else { | 63 } else { |
| 63 HandleProto(proto->to_impl()); | 64 HandleProto(proto->to_impl()); |
| 64 } | 65 } |
| 65 } | 66 } |
| 66 | 67 |
| 67 void RemoteChannelImpl::HandleProto( | 68 void RemoteChannelImpl::HandleProto( |
| 68 const proto::CompositorMessageToImpl& proto) { | 69 const proto::CompositorMessageToImpl& proto) { |
| 69 DCHECK(task_runner_provider_->IsMainThread()); | 70 DCHECK(task_runner_provider_->IsMainThread()); |
| 70 DCHECK(proto.has_message_type()); | 71 DCHECK(proto.has_message_type()); |
| 71 DCHECK(!main().waiting_for_output_surface_initialization); | 72 DCHECK(!main().waiting_for_compositor_frame_sink_initialization); |
| 72 | 73 |
| 73 switch (proto.message_type()) { | 74 switch (proto.message_type()) { |
| 74 case proto::CompositorMessageToImpl::UNKNOWN: | 75 case proto::CompositorMessageToImpl::UNKNOWN: |
| 75 NOTIMPLEMENTED() << "Ignoring message of UNKNOWN type"; | 76 NOTIMPLEMENTED() << "Ignoring message of UNKNOWN type"; |
| 76 break; | 77 break; |
| 77 case proto::CompositorMessageToImpl::SET_NEEDS_COMMIT: | 78 case proto::CompositorMessageToImpl::SET_NEEDS_COMMIT: |
| 78 VLOG(1) << "Received commit request from the engine."; | 79 VLOG(1) << "Received commit request from the engine."; |
| 79 ImplThreadTaskRunner()->PostTask( | 80 ImplThreadTaskRunner()->PostTask( |
| 80 FROM_HERE, | 81 FROM_HERE, |
| 81 base::Bind(&ProxyImpl::SetNeedsCommitOnImpl, proxy_impl_weak_ptr_)); | 82 base::Bind(&ProxyImpl::SetNeedsCommitOnImpl, proxy_impl_weak_ptr_)); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 140 | 141 |
| 141 bool RemoteChannelImpl::IsStarted() const { | 142 bool RemoteChannelImpl::IsStarted() const { |
| 142 DCHECK(task_runner_provider_->IsMainThread()); | 143 DCHECK(task_runner_provider_->IsMainThread()); |
| 143 return main().started; | 144 return main().started; |
| 144 } | 145 } |
| 145 | 146 |
| 146 bool RemoteChannelImpl::CommitToActiveTree() const { | 147 bool RemoteChannelImpl::CommitToActiveTree() const { |
| 147 return false; | 148 return false; |
| 148 } | 149 } |
| 149 | 150 |
| 150 void RemoteChannelImpl::SetOutputSurface(OutputSurface* output_surface) { | 151 void RemoteChannelImpl::SetCompositorFrameSink( |
| 152 CompositorFrameSink* compositor_frame_sink) { | |
| 151 DCHECK(task_runner_provider_->IsMainThread()); | 153 DCHECK(task_runner_provider_->IsMainThread()); |
| 152 | 154 |
| 153 ImplThreadTaskRunner()->PostTask( | 155 ImplThreadTaskRunner()->PostTask( |
| 154 FROM_HERE, base::Bind(&ProxyImpl::InitializeOutputSurfaceOnImpl, | 156 FROM_HERE, base::Bind(&ProxyImpl::InitializeCompositorFrameSinkOnImpl, |
| 155 proxy_impl_weak_ptr_, output_surface)); | 157 proxy_impl_weak_ptr_, compositor_frame_sink)); |
| 156 } | 158 } |
| 157 | 159 |
| 158 void RemoteChannelImpl::ReleaseOutputSurface() { | 160 void RemoteChannelImpl::ReleaseCompositorFrameSink() { |
| 159 DCHECK(task_runner_provider_->IsMainThread()); | 161 DCHECK(task_runner_provider_->IsMainThread()); |
| 160 DCHECK(!main().waiting_for_output_surface_initialization); | 162 DCHECK(!main().waiting_for_compositor_frame_sink_initialization); |
| 161 VLOG(1) << "Releasing Output Surface"; | 163 VLOG(1) << "Releasing CompositorFrameSink"; |
| 162 | 164 |
| 163 { | 165 { |
| 164 CompletionEvent completion; | 166 CompletionEvent completion; |
| 165 DebugScopedSetMainThreadBlocked main_thread_blocked(task_runner_provider_); | 167 DebugScopedSetMainThreadBlocked main_thread_blocked(task_runner_provider_); |
| 166 ImplThreadTaskRunner()->PostTask( | 168 ImplThreadTaskRunner()->PostTask( |
| 167 FROM_HERE, base::Bind(&ProxyImpl::ReleaseOutputSurfaceOnImpl, | 169 FROM_HERE, base::Bind(&ProxyImpl::ReleaseCompositorFrameSinkOnImpl, |
| 168 proxy_impl_weak_ptr_, &completion)); | 170 proxy_impl_weak_ptr_, &completion)); |
| 169 completion.Wait(); | 171 completion.Wait(); |
| 170 } | 172 } |
| 171 | 173 |
| 172 main().waiting_for_output_surface_initialization = true; | 174 main().waiting_for_compositor_frame_sink_initialization = true; |
| 173 } | 175 } |
| 174 | 176 |
| 175 void RemoteChannelImpl::SetVisible(bool visible) { | 177 void RemoteChannelImpl::SetVisible(bool visible) { |
| 176 DCHECK(task_runner_provider_->IsMainThread()); | 178 DCHECK(task_runner_provider_->IsMainThread()); |
| 177 VLOG(1) << "Setting visibility to: " << visible; | 179 VLOG(1) << "Setting visibility to: " << visible; |
| 178 | 180 |
| 179 ImplThreadTaskRunner()->PostTask( | 181 ImplThreadTaskRunner()->PostTask( |
| 180 FROM_HERE, | 182 FROM_HERE, |
| 181 base::Bind(&ProxyImpl::SetVisibleOnImpl, proxy_impl_weak_ptr_, visible)); | 183 base::Bind(&ProxyImpl::SetVisibleOnImpl, proxy_impl_weak_ptr_, visible)); |
| 182 } | 184 } |
| 183 | 185 |
| 184 void RemoteChannelImpl::SetNeedsAnimate() { | 186 void RemoteChannelImpl::SetNeedsAnimate() { |
| 185 NOTREACHED() << "Should not be called on the remote client LayerTreeHost"; | 187 NOTREACHED() << "Should not be called on the remote client LayerTreeHost"; |
| 186 } | 188 } |
| 187 | 189 |
| 188 void RemoteChannelImpl::SetNeedsUpdateLayers() { | 190 void RemoteChannelImpl::SetNeedsUpdateLayers() { |
| 189 NOTREACHED() << "Should not be called on the remote client LayerTreeHost"; | 191 NOTREACHED() << "Should not be called on the remote client LayerTreeHost"; |
| 190 } | 192 } |
| 191 | 193 |
| 192 void RemoteChannelImpl::SetNeedsCommit() { | 194 void RemoteChannelImpl::SetNeedsCommit() { |
| 193 // Ideally commits should be requested only on the server. But we have to | 195 // Ideally commits should be requested only on the server. But we have to |
| 194 // allow this call since the LayerTreeHost will currently ask for a commit in | 196 // allow this call since the LayerTreeHost will currently ask for a commit in |
| 195 // 2 cases: | 197 // 2 cases: |
| 196 // 1) When it is being initialized from a protobuf for a commit. | 198 // 1) When it is being initialized from a protobuf for a commit. |
| 197 // 2) When it loses the output surface. | 199 // 2) When it loses the CompositorFrameSink. |
| 198 NOTIMPLEMENTED() << "Commits should not be requested on the client"; | 200 NOTIMPLEMENTED() << "Commits should not be requested on the client"; |
| 199 } | 201 } |
| 200 | 202 |
| 201 void RemoteChannelImpl::SetNeedsRedraw(const gfx::Rect& damage_rect) { | 203 void RemoteChannelImpl::SetNeedsRedraw(const gfx::Rect& damage_rect) { |
| 202 NOTREACHED() << "Should not be called on the remote client LayerTreeHost"; | 204 NOTREACHED() << "Should not be called on the remote client LayerTreeHost"; |
| 203 } | 205 } |
| 204 | 206 |
| 205 void RemoteChannelImpl::SetNextCommitWaitsForActivation() { | 207 void RemoteChannelImpl::SetNextCommitWaitsForActivation() { |
| 206 NOTREACHED() << "Should not be called on the remote client LayerTreeHost"; | 208 NOTREACHED() << "Should not be called on the remote client LayerTreeHost"; |
| 207 } | 209 } |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 312 void RemoteChannelImpl::DidCommitAndDrawFrame() { | 314 void RemoteChannelImpl::DidCommitAndDrawFrame() { |
| 313 DCHECK(task_runner_provider_->IsImplThread()); | 315 DCHECK(task_runner_provider_->IsImplThread()); |
| 314 MainThreadTaskRunner()->PostTask( | 316 MainThreadTaskRunner()->PostTask( |
| 315 FROM_HERE, base::Bind(&RemoteChannelImpl::DidCommitAndDrawFrameOnMain, | 317 FROM_HERE, base::Bind(&RemoteChannelImpl::DidCommitAndDrawFrameOnMain, |
| 316 impl().remote_channel_weak_ptr)); | 318 impl().remote_channel_weak_ptr)); |
| 317 } | 319 } |
| 318 | 320 |
| 319 void RemoteChannelImpl::SetAnimationEvents( | 321 void RemoteChannelImpl::SetAnimationEvents( |
| 320 std::unique_ptr<AnimationEvents> queue) {} | 322 std::unique_ptr<AnimationEvents> queue) {} |
| 321 | 323 |
| 322 void RemoteChannelImpl::DidLoseOutputSurface() { | 324 void RemoteChannelImpl::DidLoseCompositorFrameSink() { |
| 323 DCHECK(task_runner_provider_->IsImplThread()); | |
| 324 | |
| 325 MainThreadTaskRunner()->PostTask( | |
| 326 FROM_HERE, base::Bind(&RemoteChannelImpl::DidLoseOutputSurfaceOnMain, | |
| 327 impl().remote_channel_weak_ptr)); | |
| 328 } | |
| 329 | |
| 330 void RemoteChannelImpl::RequestNewOutputSurface() { | |
| 331 DCHECK(task_runner_provider_->IsImplThread()); | |
| 332 | |
| 333 MainThreadTaskRunner()->PostTask( | |
| 334 FROM_HERE, base::Bind(&RemoteChannelImpl::RequestNewOutputSurfaceOnMain, | |
| 335 impl().remote_channel_weak_ptr)); | |
| 336 } | |
| 337 | |
| 338 void RemoteChannelImpl::DidInitializeOutputSurface(bool success) { | |
| 339 DCHECK(task_runner_provider_->IsImplThread()); | 325 DCHECK(task_runner_provider_->IsImplThread()); |
| 340 | 326 |
| 341 MainThreadTaskRunner()->PostTask( | 327 MainThreadTaskRunner()->PostTask( |
| 342 FROM_HERE, | 328 FROM_HERE, |
| 343 base::Bind(&RemoteChannelImpl::DidInitializeOutputSurfaceOnMain, | 329 base::Bind(&RemoteChannelImpl::DidLoseCompositorFrameSinkOnMain, |
| 330 impl().remote_channel_weak_ptr)); | |
| 331 } | |
| 332 | |
| 333 void RemoteChannelImpl::RequestNewCompositorFrameSink() { | |
| 334 DCHECK(task_runner_provider_->IsImplThread()); | |
| 335 | |
| 336 MainThreadTaskRunner()->PostTask( | |
| 337 FROM_HERE, | |
| 338 base::Bind(&RemoteChannelImpl::RequestNewCompositorFrameSinkOnMain, | |
| 339 impl().remote_channel_weak_ptr)); | |
| 340 } | |
| 341 | |
| 342 void RemoteChannelImpl::DidInitializeCompositorFrameSink(bool success) { | |
| 343 DCHECK(task_runner_provider_->IsImplThread()); | |
| 344 | |
| 345 MainThreadTaskRunner()->PostTask( | |
| 346 FROM_HERE, | |
| 347 base::Bind(&RemoteChannelImpl::DidInitializeCompositorFrameSinkOnMain, | |
| 344 impl().remote_channel_weak_ptr, success)); | 348 impl().remote_channel_weak_ptr, success)); |
| 345 } | 349 } |
| 346 | 350 |
| 347 void RemoteChannelImpl::DidCompletePageScaleAnimation() {} | 351 void RemoteChannelImpl::DidCompletePageScaleAnimation() {} |
| 348 | 352 |
| 349 void RemoteChannelImpl::BeginMainFrame( | 353 void RemoteChannelImpl::BeginMainFrame( |
| 350 std::unique_ptr<BeginMainFrameAndCommitState> begin_main_frame_state) { | 354 std::unique_ptr<BeginMainFrameAndCommitState> begin_main_frame_state) { |
| 351 std::unique_ptr<proto::CompositorMessage> proto; | 355 std::unique_ptr<proto::CompositorMessage> proto; |
| 352 proto.reset(new proto::CompositorMessage); | 356 proto.reset(new proto::CompositorMessage); |
| 353 proto::CompositorMessageToMain* to_main_proto = proto->mutable_to_main(); | 357 proto::CompositorMessageToMain* to_main_proto = proto->mutable_to_main(); |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 375 void RemoteChannelImpl::DidCompleteSwapBuffersOnMain() { | 379 void RemoteChannelImpl::DidCompleteSwapBuffersOnMain() { |
| 376 DCHECK(task_runner_provider_->IsMainThread()); | 380 DCHECK(task_runner_provider_->IsMainThread()); |
| 377 main().layer_tree_host->DidCompleteSwapBuffers(); | 381 main().layer_tree_host->DidCompleteSwapBuffers(); |
| 378 } | 382 } |
| 379 | 383 |
| 380 void RemoteChannelImpl::DidCommitAndDrawFrameOnMain() { | 384 void RemoteChannelImpl::DidCommitAndDrawFrameOnMain() { |
| 381 DCHECK(task_runner_provider_->IsMainThread()); | 385 DCHECK(task_runner_provider_->IsMainThread()); |
| 382 main().layer_tree_host->DidCommitAndDrawFrame(); | 386 main().layer_tree_host->DidCommitAndDrawFrame(); |
| 383 } | 387 } |
| 384 | 388 |
| 385 void RemoteChannelImpl::DidLoseOutputSurfaceOnMain() { | 389 void RemoteChannelImpl::DidLoseCompositorFrameSinkOnMain() { |
| 386 DCHECK(task_runner_provider_->IsMainThread()); | 390 DCHECK(task_runner_provider_->IsMainThread()); |
| 387 | 391 |
| 388 main().layer_tree_host->DidLoseOutputSurface(); | 392 main().layer_tree_host->DidLoseCompositorFrameSink(); |
| 389 } | 393 } |
| 390 | 394 |
| 391 void RemoteChannelImpl::RequestNewOutputSurfaceOnMain() { | 395 void RemoteChannelImpl::RequestNewCompositorFrameSinkOnMain() { |
| 392 DCHECK(task_runner_provider_->IsMainThread()); | 396 DCHECK(task_runner_provider_->IsMainThread()); |
| 393 | 397 |
| 394 main().layer_tree_host->RequestNewOutputSurface(); | 398 main().layer_tree_host->RequestNewCompositorFrameSink(); |
| 395 } | 399 } |
| 396 | 400 |
| 397 void RemoteChannelImpl::DidInitializeOutputSurfaceOnMain(bool success) { | 401 void RemoteChannelImpl::DidInitializeCompositorFrameSinkOnMain(bool success) { |
| 398 DCHECK(task_runner_provider_->IsMainThread()); | 402 DCHECK(task_runner_provider_->IsMainThread()); |
| 399 | 403 |
| 400 if (!success) { | 404 if (!success) { |
| 401 main().layer_tree_host->DidFailToInitializeOutputSurface(); | 405 main().layer_tree_host->DidFailToInitializeCompositorFrameSink(); |
| 402 return; | 406 return; |
| 403 } | 407 } |
| 404 | 408 |
| 405 VLOG(1) << "OutputSurface initialized successfully"; | 409 VLOG(1) << "CompositorFrameSink initialized successfully"; |
| 406 main().layer_tree_host->DidInitializeOutputSurface(); | 410 main().layer_tree_host->DidInitializeCompositorFrameSink(); |
| 407 | 411 |
| 408 // If we were waiting for output surface initialization, we might have queued | 412 // If we were waiting for CompositorFrameSink initialization, we might have |
| 409 // some messages. Relay them now that a new output surface has been | 413 // queued |
|
enne (OOO)
2016/09/14 00:35:45
@_@
| |
| 414 // some messages. Relay them now that a new CompositorFrameSink has been | |
| 410 // initialized. | 415 // initialized. |
| 411 main().waiting_for_output_surface_initialization = false; | 416 main().waiting_for_compositor_frame_sink_initialization = false; |
| 412 while (!main().pending_messages.empty()) { | 417 while (!main().pending_messages.empty()) { |
| 413 VLOG(1) << "Handling queued message"; | 418 VLOG(1) << "Handling queued message"; |
| 414 HandleProto(main().pending_messages.front()); | 419 HandleProto(main().pending_messages.front()); |
| 415 main().pending_messages.pop(); | 420 main().pending_messages.pop(); |
| 416 } | 421 } |
| 417 | 422 |
| 418 // The commit after a new output surface can early out, in which case we will | 423 // The commit after a new CompositorFrameSink can early out, in which case we |
| 424 // will | |
|
enne (OOO)
2016/09/14 00:35:45
@_@
| |
| 419 // never redraw. Schedule one just to be safe. | 425 // never redraw. Schedule one just to be safe. |
| 420 PostSetNeedsRedrawToImpl(gfx::Rect( | 426 PostSetNeedsRedrawToImpl(gfx::Rect( |
| 421 main().layer_tree_host->GetLayerTree()->device_viewport_size())); | 427 main().layer_tree_host->GetLayerTree()->device_viewport_size())); |
| 422 } | 428 } |
| 423 | 429 |
| 424 void RemoteChannelImpl::SendMessageProtoOnMain( | 430 void RemoteChannelImpl::SendMessageProtoOnMain( |
| 425 std::unique_ptr<proto::CompositorMessage> proto) { | 431 std::unique_ptr<proto::CompositorMessage> proto) { |
| 426 DCHECK(task_runner_provider_->IsMainThread()); | 432 DCHECK(task_runner_provider_->IsMainThread()); |
| 427 VLOG(1) << "Sending BeginMainFrame request to the engine."; | 433 VLOG(1) << "Sending BeginMainFrame request to the engine."; |
| 428 | 434 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 493 return task_runner_provider_->ImplThreadTaskRunner(); | 499 return task_runner_provider_->ImplThreadTaskRunner(); |
| 494 } | 500 } |
| 495 | 501 |
| 496 RemoteChannelImpl::MainThreadOnly::MainThreadOnly( | 502 RemoteChannelImpl::MainThreadOnly::MainThreadOnly( |
| 497 RemoteChannelImpl* remote_channel_impl, | 503 RemoteChannelImpl* remote_channel_impl, |
| 498 LayerTreeHost* layer_tree_host, | 504 LayerTreeHost* layer_tree_host, |
| 499 RemoteProtoChannel* remote_proto_channel) | 505 RemoteProtoChannel* remote_proto_channel) |
| 500 : layer_tree_host(layer_tree_host), | 506 : layer_tree_host(layer_tree_host), |
| 501 remote_proto_channel(remote_proto_channel), | 507 remote_proto_channel(remote_proto_channel), |
| 502 started(false), | 508 started(false), |
| 503 waiting_for_output_surface_initialization(false), | 509 waiting_for_compositor_frame_sink_initialization(false), |
| 504 remote_channel_weak_factory(remote_channel_impl) { | 510 remote_channel_weak_factory(remote_channel_impl) { |
| 505 DCHECK(layer_tree_host); | 511 DCHECK(layer_tree_host); |
| 506 DCHECK(remote_proto_channel); | 512 DCHECK(remote_proto_channel); |
| 507 } | 513 } |
| 508 | 514 |
| 509 RemoteChannelImpl::MainThreadOnly::~MainThreadOnly() {} | 515 RemoteChannelImpl::MainThreadOnly::~MainThreadOnly() {} |
| 510 | 516 |
| 511 RemoteChannelImpl::CompositorThreadOnly::CompositorThreadOnly( | 517 RemoteChannelImpl::CompositorThreadOnly::CompositorThreadOnly( |
| 512 base::WeakPtr<RemoteChannelImpl> remote_channel_weak_ptr) | 518 base::WeakPtr<RemoteChannelImpl> remote_channel_weak_ptr) |
| 513 : proxy_impl(nullptr), | 519 : proxy_impl(nullptr), |
| 514 proxy_impl_weak_factory(nullptr), | 520 proxy_impl_weak_factory(nullptr), |
| 515 remote_channel_weak_ptr(remote_channel_weak_ptr) {} | 521 remote_channel_weak_ptr(remote_channel_weak_ptr) {} |
| 516 | 522 |
| 517 RemoteChannelImpl::CompositorThreadOnly::~CompositorThreadOnly() {} | 523 RemoteChannelImpl::CompositorThreadOnly::~CompositorThreadOnly() {} |
| 518 | 524 |
| 519 } // namespace cc | 525 } // namespace cc |
| OLD | NEW |