OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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/layer_tree_host.h" | 5 #include "cc/trees/layer_tree_host.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 LayerTreeHost::LayerTreeHost(InitParams* params, | 206 LayerTreeHost::LayerTreeHost(InitParams* params, |
207 CompositorMode mode, | 207 CompositorMode mode, |
208 std::unique_ptr<LayerTree> layer_tree) | 208 std::unique_ptr<LayerTree> layer_tree) |
209 : micro_benchmark_controller_(this), | 209 : micro_benchmark_controller_(this), |
210 layer_tree_(std::move(layer_tree)), | 210 layer_tree_(std::move(layer_tree)), |
211 next_ui_resource_id_(1), | 211 next_ui_resource_id_(1), |
212 compositor_mode_(mode), | 212 compositor_mode_(mode), |
213 client_(params->client), | 213 client_(params->client), |
214 source_frame_number_(0), | 214 source_frame_number_(0), |
215 rendering_stats_instrumentation_(RenderingStatsInstrumentation::Create()), | 215 rendering_stats_instrumentation_(RenderingStatsInstrumentation::Create()), |
216 output_surface_lost_(true), | |
217 settings_(*params->settings), | 216 settings_(*params->settings), |
218 debug_state_(settings_.initial_debug_state), | 217 debug_state_(settings_.initial_debug_state), |
219 visible_(false), | 218 visible_(false), |
220 has_gpu_rasterization_trigger_(false), | 219 has_gpu_rasterization_trigger_(false), |
221 content_is_suitable_for_gpu_rasterization_(true), | 220 content_is_suitable_for_gpu_rasterization_(true), |
222 gpu_rasterization_histogram_recorded_(false), | 221 gpu_rasterization_histogram_recorded_(false), |
223 did_complete_scale_animation_(false), | 222 did_complete_scale_animation_(false), |
224 id_(s_layer_tree_host_sequence_number.GetNext() + 1), | 223 id_(s_layer_tree_host_sequence_number.GetNext() + 1), |
225 next_commit_forces_redraw_(false), | 224 next_commit_forces_redraw_(false), |
226 shared_bitmap_manager_(params->shared_bitmap_manager), | 225 shared_bitmap_manager_(params->shared_bitmap_manager), |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 | 259 |
261 void LayerTreeHost::InitializeRemoteServer( | 260 void LayerTreeHost::InitializeRemoteServer( |
262 RemoteProtoChannel* remote_proto_channel, | 261 RemoteProtoChannel* remote_proto_channel, |
263 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner) { | 262 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner) { |
264 task_runner_provider_ = TaskRunnerProvider::Create(main_task_runner, nullptr); | 263 task_runner_provider_ = TaskRunnerProvider::Create(main_task_runner, nullptr); |
265 | 264 |
266 if (image_serialization_processor_) { | 265 if (image_serialization_processor_) { |
267 engine_picture_cache_ = | 266 engine_picture_cache_ = |
268 image_serialization_processor_->CreateEnginePictureCache(); | 267 image_serialization_processor_->CreateEnginePictureCache(); |
269 } | 268 } |
270 | |
271 // The LayerTreeHost on the server never requests the output surface since | |
272 // it is only needed on the client. Since ProxyMain aborts commits if | |
273 // output_surface_lost() is true, always assume we have the output surface | |
274 // on the server. | |
275 output_surface_lost_ = false; | |
276 | |
277 InitializeProxy(ProxyMain::CreateRemote(remote_proto_channel, this, | 269 InitializeProxy(ProxyMain::CreateRemote(remote_proto_channel, this, |
278 task_runner_provider_.get()), | 270 task_runner_provider_.get()), |
279 nullptr); | 271 nullptr); |
280 } | 272 } |
281 | 273 |
282 void LayerTreeHost::InitializeRemoteClient( | 274 void LayerTreeHost::InitializeRemoteClient( |
283 RemoteProtoChannel* remote_proto_channel, | 275 RemoteProtoChannel* remote_proto_channel, |
284 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 276 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
285 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) { | 277 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) { |
286 task_runner_provider_ = | 278 task_runner_provider_ = |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
481 source_frame_number_++; | 473 source_frame_number_++; |
482 client_->DidCommit(); | 474 client_->DidCommit(); |
483 if (did_complete_scale_animation_) { | 475 if (did_complete_scale_animation_) { |
484 client_->DidCompletePageScaleAnimation(); | 476 client_->DidCompletePageScaleAnimation(); |
485 did_complete_scale_animation_ = false; | 477 did_complete_scale_animation_ = false; |
486 } | 478 } |
487 } | 479 } |
488 | 480 |
489 void LayerTreeHost::SetOutputSurface(std::unique_ptr<OutputSurface> surface) { | 481 void LayerTreeHost::SetOutputSurface(std::unique_ptr<OutputSurface> surface) { |
490 TRACE_EVENT0("cc", "LayerTreeHost::SetOutputSurface"); | 482 TRACE_EVENT0("cc", "LayerTreeHost::SetOutputSurface"); |
491 DCHECK(output_surface_lost_); | |
492 DCHECK(surface); | 483 DCHECK(surface); |
493 | 484 |
494 DCHECK(!new_output_surface_); | 485 DCHECK(!new_output_surface_); |
495 new_output_surface_ = std::move(surface); | 486 new_output_surface_ = std::move(surface); |
496 proxy_->SetOutputSurface(new_output_surface_.get()); | 487 proxy_->SetOutputSurface(new_output_surface_.get()); |
497 } | 488 } |
498 | 489 |
499 std::unique_ptr<OutputSurface> LayerTreeHost::ReleaseOutputSurface() { | 490 std::unique_ptr<OutputSurface> LayerTreeHost::ReleaseOutputSurface() { |
500 DCHECK(!visible_); | 491 DCHECK(!visible_); |
501 DCHECK(!output_surface_lost_); | |
502 | 492 |
503 DidLoseOutputSurface(); | 493 DidLoseOutputSurface(); |
504 proxy_->ReleaseOutputSurface(); | 494 proxy_->ReleaseOutputSurface(); |
505 return std::move(current_output_surface_); | 495 return std::move(current_output_surface_); |
506 } | 496 } |
507 | 497 |
508 void LayerTreeHost::RequestNewOutputSurface() { | 498 void LayerTreeHost::RequestNewOutputSurface() { |
509 client_->RequestNewOutputSurface(); | 499 client_->RequestNewOutputSurface(); |
510 } | 500 } |
511 | 501 |
512 void LayerTreeHost::DidInitializeOutputSurface() { | 502 void LayerTreeHost::DidInitializeOutputSurface() { |
513 DCHECK(new_output_surface_); | 503 DCHECK(new_output_surface_); |
514 output_surface_lost_ = false; | |
515 current_output_surface_ = std::move(new_output_surface_); | 504 current_output_surface_ = std::move(new_output_surface_); |
516 client_->DidInitializeOutputSurface(); | 505 client_->DidInitializeOutputSurface(); |
517 } | 506 } |
518 | 507 |
519 void LayerTreeHost::DidFailToInitializeOutputSurface() { | 508 void LayerTreeHost::DidFailToInitializeOutputSurface() { |
520 DCHECK(output_surface_lost_); | |
521 DCHECK(new_output_surface_); | 509 DCHECK(new_output_surface_); |
522 // Note: It is safe to drop all output surface references here as | 510 // Note: It is safe to drop all output surface references here as |
523 // LayerTreeHostImpl will not keep a pointer to either the old or | 511 // LayerTreeHostImpl will not keep a pointer to either the old or |
524 // new output surface after failing to initialize the new one. | 512 // new output surface after failing to initialize the new one. |
525 current_output_surface_ = nullptr; | 513 current_output_surface_ = nullptr; |
526 new_output_surface_ = nullptr; | 514 new_output_surface_ = nullptr; |
527 client_->DidFailToInitializeOutputSurface(); | 515 client_->DidFailToInitializeOutputSurface(); |
528 } | 516 } |
529 | 517 |
530 std::unique_ptr<LayerTreeHostImpl> LayerTreeHost::CreateLayerTreeHostImpl( | 518 std::unique_ptr<LayerTreeHostImpl> LayerTreeHost::CreateLayerTreeHostImpl( |
(...skipping 17 matching lines...) Expand all Loading... |
548 shared_bitmap_manager_ = NULL; | 536 shared_bitmap_manager_ = NULL; |
549 gpu_memory_buffer_manager_ = NULL; | 537 gpu_memory_buffer_manager_ = NULL; |
550 task_graph_runner_ = NULL; | 538 task_graph_runner_ = NULL; |
551 input_handler_weak_ptr_ = host_impl->AsWeakPtr(); | 539 input_handler_weak_ptr_ = host_impl->AsWeakPtr(); |
552 return host_impl; | 540 return host_impl; |
553 } | 541 } |
554 | 542 |
555 void LayerTreeHost::DidLoseOutputSurface() { | 543 void LayerTreeHost::DidLoseOutputSurface() { |
556 TRACE_EVENT0("cc", "LayerTreeHost::DidLoseOutputSurface"); | 544 TRACE_EVENT0("cc", "LayerTreeHost::DidLoseOutputSurface"); |
557 DCHECK(task_runner_provider_->IsMainThread()); | 545 DCHECK(task_runner_provider_->IsMainThread()); |
558 | |
559 if (output_surface_lost_) | |
560 return; | |
561 | |
562 output_surface_lost_ = true; | |
563 SetNeedsCommit(); | 546 SetNeedsCommit(); |
564 } | 547 } |
565 | 548 |
566 void LayerTreeHost::SetDeferCommits(bool defer_commits) { | 549 void LayerTreeHost::SetDeferCommits(bool defer_commits) { |
567 proxy_->SetDeferCommits(defer_commits); | 550 proxy_->SetDeferCommits(defer_commits); |
568 } | 551 } |
569 | 552 |
570 void LayerTreeHost::SetNeedsAnimate() { | 553 void LayerTreeHost::SetNeedsAnimate() { |
571 proxy_->SetNeedsAnimate(); | 554 proxy_->SetNeedsAnimate(); |
572 NotifySwapPromiseMonitorsOfSetNeedsCommit(); | 555 NotifySwapPromiseMonitorsOfSetNeedsCommit(); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
661 } | 644 } |
662 | 645 |
663 void LayerTreeHost::NotifyInputThrottledUntilCommit() { | 646 void LayerTreeHost::NotifyInputThrottledUntilCommit() { |
664 proxy_->NotifyInputThrottledUntilCommit(); | 647 proxy_->NotifyInputThrottledUntilCommit(); |
665 } | 648 } |
666 | 649 |
667 void LayerTreeHost::LayoutAndUpdateLayers() { | 650 void LayerTreeHost::LayoutAndUpdateLayers() { |
668 DCHECK(IsSingleThreaded()); | 651 DCHECK(IsSingleThreaded()); |
669 // This function is only valid when not using the scheduler. | 652 // This function is only valid when not using the scheduler. |
670 DCHECK(!settings_.single_thread_proxy_scheduler); | 653 DCHECK(!settings_.single_thread_proxy_scheduler); |
671 SingleThreadProxy* proxy = static_cast<SingleThreadProxy*>(proxy_.get()); | |
672 | |
673 if (output_surface_lost()) { | |
674 proxy->RequestNewOutputSurface(); | |
675 // RequestNewOutputSurface could have synchronously created an output | |
676 // surface, so check again before returning. | |
677 if (output_surface_lost()) | |
678 return; | |
679 } | |
680 | |
681 RequestMainFrameUpdate(); | 654 RequestMainFrameUpdate(); |
682 UpdateLayers(); | 655 UpdateLayers(); |
683 } | 656 } |
684 | 657 |
685 void LayerTreeHost::Composite(base::TimeTicks frame_begin_time) { | 658 void LayerTreeHost::Composite(base::TimeTicks frame_begin_time) { |
686 DCHECK(IsSingleThreaded()); | 659 DCHECK(IsSingleThreaded()); |
687 // This function is only valid when not using the scheduler. | 660 // This function is only valid when not using the scheduler. |
688 DCHECK(!settings_.single_thread_proxy_scheduler); | 661 DCHECK(!settings_.single_thread_proxy_scheduler); |
689 SingleThreadProxy* proxy = static_cast<SingleThreadProxy*>(proxy_.get()); | 662 SingleThreadProxy* proxy = static_cast<SingleThreadProxy*>(proxy_.get()); |
690 | 663 |
691 proxy->CompositeImmediately(frame_begin_time); | 664 proxy->CompositeImmediately(frame_begin_time); |
692 } | 665 } |
693 | 666 |
694 bool LayerTreeHost::UpdateLayers() { | 667 bool LayerTreeHost::UpdateLayers() { |
695 DCHECK(!output_surface_lost_); | |
696 if (!layer_tree_->root_layer()) | 668 if (!layer_tree_->root_layer()) |
697 return false; | 669 return false; |
698 DCHECK(!layer_tree_->root_layer()->parent()); | 670 DCHECK(!layer_tree_->root_layer()->parent()); |
699 bool result = DoUpdateLayers(layer_tree_->root_layer()); | 671 bool result = DoUpdateLayers(layer_tree_->root_layer()); |
700 micro_benchmark_controller_.DidUpdateLayers(); | 672 micro_benchmark_controller_.DidUpdateLayers(); |
701 return result || next_commit_forces_redraw_; | 673 return result || next_commit_forces_redraw_; |
702 } | 674 } |
703 | 675 |
704 void LayerTreeHost::DidCompletePageScaleAnimation() { | 676 void LayerTreeHost::DidCompletePageScaleAnimation() { |
705 did_complete_scale_animation_ = true; | 677 did_complete_scale_animation_ = true; |
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1127 | 1099 |
1128 surface_client_id_ = proto.surface_client_id(); | 1100 surface_client_id_ = proto.surface_client_id(); |
1129 next_surface_sequence_ = proto.next_surface_sequence(); | 1101 next_surface_sequence_ = proto.next_surface_sequence(); |
1130 } | 1102 } |
1131 | 1103 |
1132 AnimationHost* LayerTreeHost::animation_host() const { | 1104 AnimationHost* LayerTreeHost::animation_host() const { |
1133 return layer_tree_->animation_host(); | 1105 return layer_tree_->animation_host(); |
1134 } | 1106 } |
1135 | 1107 |
1136 } // namespace cc | 1108 } // namespace cc |
OLD | NEW |