| 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/thread_proxy.h" | 5 #include "cc/trees/thread_proxy.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 commit_requested_(false), | 85 commit_requested_(false), |
| 86 commit_request_sent_to_impl_thread_(false), | 86 commit_request_sent_to_impl_thread_(false), |
| 87 created_offscreen_context_provider_(false), | 87 created_offscreen_context_provider_(false), |
| 88 layer_tree_host_unsafe_(layer_tree_host), | 88 layer_tree_host_unsafe_(layer_tree_host), |
| 89 contents_texture_manager_unsafe_(NULL), | 89 contents_texture_manager_unsafe_(NULL), |
| 90 started_(false), | 90 started_(false), |
| 91 textures_acquired_(true), | 91 textures_acquired_(true), |
| 92 in_composite_and_readback_(false), | 92 in_composite_and_readback_(false), |
| 93 manage_tiles_pending_(false), | 93 manage_tiles_pending_(false), |
| 94 commit_waits_for_activation_(false), | 94 commit_waits_for_activation_(false), |
| 95 inside_commit_(false), | 95 main_thread_inside_commit_(false), |
| 96 begin_main_frame_sent_completion_event_on_impl_thread_(NULL), | 96 begin_main_frame_sent_completion_event_on_impl_thread_(NULL), |
| 97 readback_request_on_impl_thread_(NULL), | 97 readback_request_on_impl_thread_(NULL), |
| 98 commit_completion_event_on_impl_thread_(NULL), | 98 commit_completion_event_on_impl_thread_(NULL), |
| 99 completion_event_for_commit_held_on_tree_activation_(NULL), | 99 completion_event_for_commit_held_on_tree_activation_(NULL), |
| 100 texture_acquisition_completion_event_on_impl_thread_(NULL), | 100 texture_acquisition_completion_event_on_impl_thread_(NULL), |
| 101 next_frame_is_newly_committed_frame_on_impl_thread_(false), | 101 next_frame_is_newly_committed_frame_on_impl_thread_(false), |
| 102 throttle_frame_production_( | 102 throttle_frame_production_( |
| 103 layer_tree_host->settings().throttle_frame_production), | 103 layer_tree_host->settings().throttle_frame_production), |
| 104 begin_impl_frame_scheduling_enabled_( | 104 begin_impl_frame_scheduling_enabled_( |
| 105 layer_tree_host->settings().begin_impl_frame_scheduling_enabled), | 105 layer_tree_host->settings().begin_impl_frame_scheduling_enabled), |
| (...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 513 TRACE_EVENT0("cc", "ThreadProxy::SetNeedsRedraw"); | 513 TRACE_EVENT0("cc", "ThreadProxy::SetNeedsRedraw"); |
| 514 Proxy::ImplThreadTaskRunner()->PostTask( | 514 Proxy::ImplThreadTaskRunner()->PostTask( |
| 515 FROM_HERE, | 515 FROM_HERE, |
| 516 base::Bind(&ThreadProxy::SetNeedsRedrawRectOnImplThread, | 516 base::Bind(&ThreadProxy::SetNeedsRedrawRectOnImplThread, |
| 517 impl_thread_weak_ptr_, | 517 impl_thread_weak_ptr_, |
| 518 damage_rect)); | 518 damage_rect)); |
| 519 } | 519 } |
| 520 | 520 |
| 521 void ThreadProxy::SetNextCommitWaitsForActivation() { | 521 void ThreadProxy::SetNextCommitWaitsForActivation() { |
| 522 DCHECK(IsMainThread()); | 522 DCHECK(IsMainThread()); |
| 523 DCHECK(!inside_commit_); | 523 DCHECK(!main_thread_inside_commit_); |
| 524 commit_waits_for_activation_ = true; | 524 commit_waits_for_activation_ = true; |
| 525 } | 525 } |
| 526 | 526 |
| 527 void ThreadProxy::SetDeferCommits(bool defer_commits) { | 527 void ThreadProxy::SetDeferCommits(bool defer_commits) { |
| 528 DCHECK(IsMainThread()); | 528 DCHECK(IsMainThread()); |
| 529 DCHECK_NE(defer_commits_, defer_commits); | 529 DCHECK_NE(defer_commits_, defer_commits); |
| 530 defer_commits_ = defer_commits; | 530 defer_commits_ = defer_commits; |
| 531 | 531 |
| 532 if (defer_commits_) | 532 if (defer_commits_) |
| 533 TRACE_EVENT_ASYNC_BEGIN0("cc", "ThreadProxy::SetDeferCommits", this); | 533 TRACE_EVENT_ASYNC_BEGIN0("cc", "ThreadProxy::SetDeferCommits", this); |
| (...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1012 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionCommit"); | 1012 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionCommit"); |
| 1013 DCHECK(IsImplThread()); | 1013 DCHECK(IsImplThread()); |
| 1014 DCHECK(IsMainThreadBlocked()); | 1014 DCHECK(IsMainThreadBlocked()); |
| 1015 DCHECK(commit_completion_event_on_impl_thread_); | 1015 DCHECK(commit_completion_event_on_impl_thread_); |
| 1016 DCHECK(current_resource_update_controller_on_impl_thread_); | 1016 DCHECK(current_resource_update_controller_on_impl_thread_); |
| 1017 | 1017 |
| 1018 // Complete all remaining texture updates. | 1018 // Complete all remaining texture updates. |
| 1019 current_resource_update_controller_on_impl_thread_->Finalize(); | 1019 current_resource_update_controller_on_impl_thread_->Finalize(); |
| 1020 current_resource_update_controller_on_impl_thread_.reset(); | 1020 current_resource_update_controller_on_impl_thread_.reset(); |
| 1021 | 1021 |
| 1022 inside_commit_ = true; | 1022 main_thread_inside_commit_ = true; |
| 1023 layer_tree_host_impl_->BeginCommit(); | 1023 layer_tree_host_impl_->BeginCommit(); |
| 1024 layer_tree_host()->BeginCommitOnImplThread(layer_tree_host_impl_.get()); | 1024 layer_tree_host()->BeginCommitOnImplThread(layer_tree_host_impl_.get()); |
| 1025 layer_tree_host()->FinishCommitOnImplThread(layer_tree_host_impl_.get()); | 1025 layer_tree_host()->FinishCommitOnImplThread(layer_tree_host_impl_.get()); |
| 1026 layer_tree_host_impl_->CommitComplete(); | 1026 main_thread_inside_commit_ = false; |
| 1027 inside_commit_ = false; | |
| 1028 | |
| 1029 SetInputThrottledUntilCommitOnImplThread(false); | |
| 1030 | |
| 1031 UpdateBackgroundAnimateTicking(); | |
| 1032 | |
| 1033 next_frame_is_newly_committed_frame_on_impl_thread_ = true; | |
| 1034 | 1027 |
| 1035 bool hold_commit = layer_tree_host()->settings().impl_side_painting && | 1028 bool hold_commit = layer_tree_host()->settings().impl_side_painting && |
| 1036 commit_waits_for_activation_; | 1029 commit_waits_for_activation_; |
| 1037 commit_waits_for_activation_ = false; | 1030 commit_waits_for_activation_ = false; |
| 1038 | 1031 |
| 1039 if (hold_commit) { | 1032 if (hold_commit) { |
| 1040 // For some layer types in impl-side painting, the commit is held until | 1033 // For some layer types in impl-side painting, the commit is held until |
| 1041 // the pending tree is activated. It's also possible that the | 1034 // the pending tree is activated. It's also possible that the |
| 1042 // pending tree has already activated if there was no work to be done. | 1035 // pending tree has already activated if there was no work to be done. |
| 1043 TRACE_EVENT_INSTANT0("cc", "HoldCommit", TRACE_EVENT_SCOPE_THREAD); | 1036 TRACE_EVENT_INSTANT0("cc", "HoldCommit", TRACE_EVENT_SCOPE_THREAD); |
| 1044 completion_event_for_commit_held_on_tree_activation_ = | 1037 completion_event_for_commit_held_on_tree_activation_ = |
| 1045 commit_completion_event_on_impl_thread_; | 1038 commit_completion_event_on_impl_thread_; |
| 1046 commit_completion_event_on_impl_thread_ = NULL; | 1039 commit_completion_event_on_impl_thread_ = NULL; |
| 1047 } else { | 1040 } else { |
| 1048 commit_completion_event_on_impl_thread_->Signal(); | 1041 commit_completion_event_on_impl_thread_->Signal(); |
| 1049 commit_completion_event_on_impl_thread_ = NULL; | 1042 commit_completion_event_on_impl_thread_ = NULL; |
| 1050 } | 1043 } |
| 1051 | 1044 |
| 1045 // Delay this step until afer the main thread has been released as it's |
| 1046 // often a good bit of work to update the tree and prepare the new frame. |
| 1047 layer_tree_host_impl_->CommitComplete(); |
| 1048 |
| 1049 SetInputThrottledUntilCommitOnImplThread(false); |
| 1050 |
| 1051 UpdateBackgroundAnimateTicking(); |
| 1052 |
| 1053 next_frame_is_newly_committed_frame_on_impl_thread_ = true; |
| 1054 commit_waits_for_activation_ = false; |
| 1055 |
| 1052 commit_complete_time_ = base::TimeTicks::HighResNow(); | 1056 commit_complete_time_ = base::TimeTicks::HighResNow(); |
| 1053 begin_main_frame_to_commit_duration_history_.InsertSample( | 1057 begin_main_frame_to_commit_duration_history_.InsertSample( |
| 1054 commit_complete_time_ - begin_main_frame_sent_time_); | 1058 commit_complete_time_ - begin_main_frame_sent_time_); |
| 1055 | 1059 |
| 1056 // SetVisible kicks off the next scheduler action, so this must be last. | 1060 // SetVisible kicks off the next scheduler action, so this must be last. |
| 1057 scheduler_on_impl_thread_->SetVisible(layer_tree_host_impl_->visible()); | 1061 scheduler_on_impl_thread_->SetVisible(layer_tree_host_impl_->visible()); |
| 1058 } | 1062 } |
| 1059 | 1063 |
| 1060 void ThreadProxy::ScheduledActionUpdateVisibleTiles() { | 1064 void ThreadProxy::ScheduledActionUpdateVisibleTiles() { |
| 1061 DCHECK(IsImplThread()); | 1065 DCHECK(IsImplThread()); |
| (...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1649 commit_to_activate_duration_history_.InsertSample( | 1653 commit_to_activate_duration_history_.InsertSample( |
| 1650 base::TimeTicks::HighResNow() - commit_complete_time_); | 1654 base::TimeTicks::HighResNow() - commit_complete_time_); |
| 1651 } | 1655 } |
| 1652 | 1656 |
| 1653 void ThreadProxy::DidManageTiles() { | 1657 void ThreadProxy::DidManageTiles() { |
| 1654 DCHECK(IsImplThread()); | 1658 DCHECK(IsImplThread()); |
| 1655 scheduler_on_impl_thread_->DidManageTiles(); | 1659 scheduler_on_impl_thread_->DidManageTiles(); |
| 1656 } | 1660 } |
| 1657 | 1661 |
| 1658 } // namespace cc | 1662 } // namespace cc |
| OLD | NEW |