Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(638)

Side by Side Diff: cc/trees/thread_proxy.cc

Issue 23530003: cc: Block commit on activate by setting a flag on LayerTreeHost. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: blockcommit: fix flake Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/trees/thread_proxy.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 void ThreadProxy::SetNeedsRedraw(gfx::Rect damage_rect) { 501 void ThreadProxy::SetNeedsRedraw(gfx::Rect damage_rect) {
500 DCHECK(IsMainThread()); 502 DCHECK(IsMainThread());
501 TRACE_EVENT0("cc", "ThreadProxy::SetNeedsRedraw"); 503 TRACE_EVENT0("cc", "ThreadProxy::SetNeedsRedraw");
502 Proxy::ImplThreadTaskRunner()->PostTask( 504 Proxy::ImplThreadTaskRunner()->PostTask(
503 FROM_HERE, 505 FROM_HERE,
504 base::Bind(&ThreadProxy::SetNeedsRedrawRectOnImplThread, 506 base::Bind(&ThreadProxy::SetNeedsRedrawRectOnImplThread,
505 impl_thread_weak_ptr_, 507 impl_thread_weak_ptr_,
506 damage_rect)); 508 damage_rect));
507 } 509 }
508 510
511 void ThreadProxy::SetNextCommitWaitsForActivation() {
512 DCHECK(IsMainThread());
513 DCHECK(!inside_commit_);
514 commit_waits_for_activation_ = true;
515 }
516
509 void ThreadProxy::SetDeferCommits(bool defer_commits) { 517 void ThreadProxy::SetDeferCommits(bool defer_commits) {
510 DCHECK(IsMainThread()); 518 DCHECK(IsMainThread());
511 DCHECK_NE(defer_commits_, defer_commits); 519 DCHECK_NE(defer_commits_, defer_commits);
512 defer_commits_ = defer_commits; 520 defer_commits_ = defer_commits;
513 521
514 if (defer_commits_) 522 if (defer_commits_)
515 TRACE_EVENT_ASYNC_BEGIN0("cc", "ThreadProxy::SetDeferCommits", this); 523 TRACE_EVENT_ASYNC_BEGIN0("cc", "ThreadProxy::SetDeferCommits", this);
516 else 524 else
517 TRACE_EVENT_ASYNC_END0("cc", "ThreadProxy::SetDeferCommits", this); 525 TRACE_EVENT_ASYNC_END0("cc", "ThreadProxy::SetDeferCommits", this);
518 526
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
926 void ThreadProxy::ScheduledActionCommit() { 934 void ThreadProxy::ScheduledActionCommit() {
927 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionCommit"); 935 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionCommit");
928 DCHECK(IsImplThread()); 936 DCHECK(IsImplThread());
929 DCHECK(commit_completion_event_on_impl_thread_); 937 DCHECK(commit_completion_event_on_impl_thread_);
930 DCHECK(current_resource_update_controller_on_impl_thread_); 938 DCHECK(current_resource_update_controller_on_impl_thread_);
931 939
932 // Complete all remaining texture updates. 940 // Complete all remaining texture updates.
933 current_resource_update_controller_on_impl_thread_->Finalize(); 941 current_resource_update_controller_on_impl_thread_->Finalize();
934 current_resource_update_controller_on_impl_thread_.reset(); 942 current_resource_update_controller_on_impl_thread_.reset();
935 943
944 inside_commit_ = true;
936 layer_tree_host_impl_->BeginCommit(); 945 layer_tree_host_impl_->BeginCommit();
937 layer_tree_host_->BeginCommitOnImplThread(layer_tree_host_impl_.get()); 946 layer_tree_host_->BeginCommitOnImplThread(layer_tree_host_impl_.get());
938 layer_tree_host_->FinishCommitOnImplThread(layer_tree_host_impl_.get()); 947 layer_tree_host_->FinishCommitOnImplThread(layer_tree_host_impl_.get());
939 layer_tree_host_impl_->CommitComplete(); 948 layer_tree_host_impl_->CommitComplete();
949 inside_commit_ = false;
940 950
941 SetInputThrottledUntilCommitOnImplThread(false); 951 SetInputThrottledUntilCommitOnImplThread(false);
942 952
943 UpdateBackgroundAnimateTicking(); 953 UpdateBackgroundAnimateTicking();
944 954
945 next_frame_is_newly_committed_frame_on_impl_thread_ = true; 955 next_frame_is_newly_committed_frame_on_impl_thread_ = true;
946 956
947 if (layer_tree_host_->settings().impl_side_painting && 957 if (layer_tree_host_->settings().impl_side_painting &&
948 layer_tree_host_->BlocksPendingCommit() && 958 commit_waits_for_activation_) {
949 layer_tree_host_impl_->pending_tree()) {
950 // For some layer types in impl-side painting, the commit is held until 959 // For some layer types in impl-side painting, the commit is held until
951 // the pending tree is activated. It's also possible that the 960 // the pending tree is activated. It's also possible that the
952 // pending tree has already activated if there was no work to be done. 961 // pending tree has already activated if there was no work to be done.
953 TRACE_EVENT_INSTANT0("cc", "HoldCommit", TRACE_EVENT_SCOPE_THREAD); 962 TRACE_EVENT_INSTANT0("cc", "HoldCommit", TRACE_EVENT_SCOPE_THREAD);
954 completion_event_for_commit_held_on_tree_activation_ = 963 completion_event_for_commit_held_on_tree_activation_ =
955 commit_completion_event_on_impl_thread_; 964 commit_completion_event_on_impl_thread_;
956 commit_completion_event_on_impl_thread_ = NULL; 965 commit_completion_event_on_impl_thread_ = NULL;
957 } else { 966 } else {
958 commit_completion_event_on_impl_thread_->Signal(); 967 commit_completion_event_on_impl_thread_->Signal();
959 commit_completion_event_on_impl_thread_ = NULL; 968 commit_completion_event_on_impl_thread_ = NULL;
960 } 969 }
961 970
971 commit_waits_for_activation_ = false;
972
962 commit_complete_time_ = base::TimeTicks::HighResNow(); 973 commit_complete_time_ = base::TimeTicks::HighResNow();
963 begin_frame_to_commit_duration_history_.InsertSample( 974 begin_frame_to_commit_duration_history_.InsertSample(
964 commit_complete_time_ - begin_frame_sent_to_main_thread_time_); 975 commit_complete_time_ - begin_frame_sent_to_main_thread_time_);
965 976
966 // SetVisible kicks off the next scheduler action, so this must be last. 977 // SetVisible kicks off the next scheduler action, so this must be last.
967 scheduler_on_impl_thread_->SetVisible(layer_tree_host_impl_->visible()); 978 scheduler_on_impl_thread_->SetVisible(layer_tree_host_impl_->visible());
968 } 979 }
969 980
970 void ThreadProxy::ScheduledActionUpdateVisibleTiles() { 981 void ThreadProxy::ScheduledActionUpdateVisibleTiles() {
971 DCHECK(IsImplThread()); 982 DCHECK(IsImplThread());
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after
1510 completion_event_for_commit_held_on_tree_activation_ = NULL; 1521 completion_event_for_commit_held_on_tree_activation_ = NULL;
1511 } 1522 }
1512 1523
1513 UpdateBackgroundAnimateTicking(); 1524 UpdateBackgroundAnimateTicking();
1514 1525
1515 commit_to_activate_duration_history_.InsertSample( 1526 commit_to_activate_duration_history_.InsertSample(
1516 base::TimeTicks::HighResNow() - commit_complete_time_); 1527 base::TimeTicks::HighResNow() - commit_complete_time_);
1517 } 1528 }
1518 1529
1519 } // namespace cc 1530 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/thread_proxy.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698