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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 : Proxy(impl_task_runner), | 69 : Proxy(impl_task_runner), |
70 animate_requested_(false), | 70 animate_requested_(false), |
71 commit_requested_(false), | 71 commit_requested_(false), |
72 commit_request_sent_to_impl_thread_(false), | 72 commit_request_sent_to_impl_thread_(false), |
73 created_offscreen_context_provider_(false), | 73 created_offscreen_context_provider_(false), |
74 layer_tree_host_(layer_tree_host), | 74 layer_tree_host_(layer_tree_host), |
75 started_(false), | 75 started_(false), |
76 textures_acquired_(true), | 76 textures_acquired_(true), |
77 in_composite_and_readback_(false), | 77 in_composite_and_readback_(false), |
78 manage_tiles_pending_(false), | 78 manage_tiles_pending_(false), |
| 79 commit_waits_for_activation_(false), |
| 80 inside_commit_(false), |
79 weak_factory_on_impl_thread_(this), | 81 weak_factory_on_impl_thread_(this), |
80 weak_factory_(this), | 82 weak_factory_(this), |
81 begin_frame_sent_to_main_thread_completion_event_on_impl_thread_(NULL), | 83 begin_frame_sent_to_main_thread_completion_event_on_impl_thread_(NULL), |
82 readback_request_on_impl_thread_(NULL), | 84 readback_request_on_impl_thread_(NULL), |
83 commit_completion_event_on_impl_thread_(NULL), | 85 commit_completion_event_on_impl_thread_(NULL), |
84 completion_event_for_commit_held_on_tree_activation_(NULL), | 86 completion_event_for_commit_held_on_tree_activation_(NULL), |
85 texture_acquisition_completion_event_on_impl_thread_(NULL), | 87 texture_acquisition_completion_event_on_impl_thread_(NULL), |
86 next_frame_is_newly_committed_frame_on_impl_thread_(false), | 88 next_frame_is_newly_committed_frame_on_impl_thread_(false), |
87 throttle_frame_production_( | 89 throttle_frame_production_( |
88 layer_tree_host->settings().throttle_frame_production), | 90 layer_tree_host->settings().throttle_frame_production), |
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 void ThreadProxy::SetNeedsRedraw(gfx::Rect damage_rect) { | 497 void ThreadProxy::SetNeedsRedraw(gfx::Rect damage_rect) { |
496 DCHECK(IsMainThread()); | 498 DCHECK(IsMainThread()); |
497 TRACE_EVENT0("cc", "ThreadProxy::SetNeedsRedraw"); | 499 TRACE_EVENT0("cc", "ThreadProxy::SetNeedsRedraw"); |
498 Proxy::ImplThreadTaskRunner()->PostTask( | 500 Proxy::ImplThreadTaskRunner()->PostTask( |
499 FROM_HERE, | 501 FROM_HERE, |
500 base::Bind(&ThreadProxy::SetNeedsRedrawRectOnImplThread, | 502 base::Bind(&ThreadProxy::SetNeedsRedrawRectOnImplThread, |
501 impl_thread_weak_ptr_, | 503 impl_thread_weak_ptr_, |
502 damage_rect)); | 504 damage_rect)); |
503 } | 505 } |
504 | 506 |
| 507 void ThreadProxy::SetNextCommitWaitsForActivation() { |
| 508 DCHECK(IsMainThread()); |
| 509 DCHECK(!inside_commit_); |
| 510 commit_waits_for_activation_ = true; |
| 511 } |
| 512 |
505 void ThreadProxy::SetDeferCommits(bool defer_commits) { | 513 void ThreadProxy::SetDeferCommits(bool defer_commits) { |
506 DCHECK(IsMainThread()); | 514 DCHECK(IsMainThread()); |
507 DCHECK_NE(defer_commits_, defer_commits); | 515 DCHECK_NE(defer_commits_, defer_commits); |
508 defer_commits_ = defer_commits; | 516 defer_commits_ = defer_commits; |
509 | 517 |
510 if (defer_commits_) | 518 if (defer_commits_) |
511 TRACE_EVENT_ASYNC_BEGIN0("cc", "ThreadProxy::SetDeferCommits", this); | 519 TRACE_EVENT_ASYNC_BEGIN0("cc", "ThreadProxy::SetDeferCommits", this); |
512 else | 520 else |
513 TRACE_EVENT_ASYNC_END0("cc", "ThreadProxy::SetDeferCommits", this); | 521 TRACE_EVENT_ASYNC_END0("cc", "ThreadProxy::SetDeferCommits", this); |
514 | 522 |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
922 void ThreadProxy::ScheduledActionCommit() { | 930 void ThreadProxy::ScheduledActionCommit() { |
923 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionCommit"); | 931 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionCommit"); |
924 DCHECK(IsImplThread()); | 932 DCHECK(IsImplThread()); |
925 DCHECK(commit_completion_event_on_impl_thread_); | 933 DCHECK(commit_completion_event_on_impl_thread_); |
926 DCHECK(current_resource_update_controller_on_impl_thread_); | 934 DCHECK(current_resource_update_controller_on_impl_thread_); |
927 | 935 |
928 // Complete all remaining texture updates. | 936 // Complete all remaining texture updates. |
929 current_resource_update_controller_on_impl_thread_->Finalize(); | 937 current_resource_update_controller_on_impl_thread_->Finalize(); |
930 current_resource_update_controller_on_impl_thread_.reset(); | 938 current_resource_update_controller_on_impl_thread_.reset(); |
931 | 939 |
| 940 inside_commit_ = true; |
932 layer_tree_host_impl_->BeginCommit(); | 941 layer_tree_host_impl_->BeginCommit(); |
933 layer_tree_host_->BeginCommitOnImplThread(layer_tree_host_impl_.get()); | 942 layer_tree_host_->BeginCommitOnImplThread(layer_tree_host_impl_.get()); |
934 layer_tree_host_->FinishCommitOnImplThread(layer_tree_host_impl_.get()); | 943 layer_tree_host_->FinishCommitOnImplThread(layer_tree_host_impl_.get()); |
935 layer_tree_host_impl_->CommitComplete(); | 944 layer_tree_host_impl_->CommitComplete(); |
| 945 inside_commit_ = false; |
936 | 946 |
937 SetInputThrottledUntilCommitOnImplThread(false); | 947 SetInputThrottledUntilCommitOnImplThread(false); |
938 | 948 |
939 layer_tree_host_impl_->UpdateBackgroundAnimateTicking( | 949 layer_tree_host_impl_->UpdateBackgroundAnimateTicking( |
940 !scheduler_on_impl_thread_->WillDrawIfNeeded()); | 950 !scheduler_on_impl_thread_->WillDrawIfNeeded()); |
941 | 951 |
942 next_frame_is_newly_committed_frame_on_impl_thread_ = true; | 952 next_frame_is_newly_committed_frame_on_impl_thread_ = true; |
943 | 953 |
944 if (layer_tree_host_->settings().impl_side_painting && | 954 if (layer_tree_host_->settings().impl_side_painting && |
945 layer_tree_host_->BlocksPendingCommit() && | 955 commit_waits_for_activation_) { |
946 layer_tree_host_impl_->pending_tree()) { | |
947 // For some layer types in impl-side painting, the commit is held until | 956 // For some layer types in impl-side painting, the commit is held until |
948 // the pending tree is activated. It's also possible that the | 957 // the pending tree is activated. It's also possible that the |
949 // pending tree has already activated if there was no work to be done. | 958 // pending tree has already activated if there was no work to be done. |
950 TRACE_EVENT_INSTANT0("cc", "HoldCommit", TRACE_EVENT_SCOPE_THREAD); | 959 TRACE_EVENT_INSTANT0("cc", "HoldCommit", TRACE_EVENT_SCOPE_THREAD); |
951 completion_event_for_commit_held_on_tree_activation_ = | 960 completion_event_for_commit_held_on_tree_activation_ = |
952 commit_completion_event_on_impl_thread_; | 961 commit_completion_event_on_impl_thread_; |
953 commit_completion_event_on_impl_thread_ = NULL; | 962 commit_completion_event_on_impl_thread_ = NULL; |
954 } else { | 963 } else { |
955 commit_completion_event_on_impl_thread_->Signal(); | 964 commit_completion_event_on_impl_thread_->Signal(); |
956 commit_completion_event_on_impl_thread_ = NULL; | 965 commit_completion_event_on_impl_thread_ = NULL; |
957 } | 966 } |
958 | 967 |
| 968 commit_waits_for_activation_ = false; |
| 969 |
959 commit_complete_time_ = base::TimeTicks::HighResNow(); | 970 commit_complete_time_ = base::TimeTicks::HighResNow(); |
960 begin_frame_to_commit_duration_history_.InsertSample( | 971 begin_frame_to_commit_duration_history_.InsertSample( |
961 commit_complete_time_ - begin_frame_sent_to_main_thread_time_); | 972 commit_complete_time_ - begin_frame_sent_to_main_thread_time_); |
962 | 973 |
963 // SetVisible kicks off the next scheduler action, so this must be last. | 974 // SetVisible kicks off the next scheduler action, so this must be last. |
964 scheduler_on_impl_thread_->SetVisible(layer_tree_host_impl_->visible()); | 975 scheduler_on_impl_thread_->SetVisible(layer_tree_host_impl_->visible()); |
965 } | 976 } |
966 | 977 |
967 void ThreadProxy::ScheduledActionUpdateVisibleTiles() { | 978 void ThreadProxy::ScheduledActionUpdateVisibleTiles() { |
968 DCHECK(IsImplThread()); | 979 DCHECK(IsImplThread()); |
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1506 DCHECK(layer_tree_host_impl_->settings().impl_side_painting); | 1517 DCHECK(layer_tree_host_impl_->settings().impl_side_painting); |
1507 completion_event_for_commit_held_on_tree_activation_->Signal(); | 1518 completion_event_for_commit_held_on_tree_activation_->Signal(); |
1508 completion_event_for_commit_held_on_tree_activation_ = NULL; | 1519 completion_event_for_commit_held_on_tree_activation_ = NULL; |
1509 } | 1520 } |
1510 | 1521 |
1511 commit_to_activate_duration_history_.InsertSample( | 1522 commit_to_activate_duration_history_.InsertSample( |
1512 base::TimeTicks::HighResNow() - commit_complete_time_); | 1523 base::TimeTicks::HighResNow() - commit_complete_time_); |
1513 } | 1524 } |
1514 | 1525 |
1515 } // namespace cc | 1526 } // namespace cc |
OLD | NEW |