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