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

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

Issue 23593003: cc: Avoid updating animations in the background without an active tree (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: alternate method 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
« 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 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 &completion, 231 &completion,
232 visible)); 232 visible));
233 completion.Wait(); 233 completion.Wait();
234 } 234 }
235 235
236 void ThreadProxy::SetVisibleOnImplThread(CompletionEvent* completion, 236 void ThreadProxy::SetVisibleOnImplThread(CompletionEvent* completion,
237 bool visible) { 237 bool visible) {
238 TRACE_EVENT0("cc", "ThreadProxy::SetVisibleOnImplThread"); 238 TRACE_EVENT0("cc", "ThreadProxy::SetVisibleOnImplThread");
239 layer_tree_host_impl_->SetVisible(visible); 239 layer_tree_host_impl_->SetVisible(visible);
240 scheduler_on_impl_thread_->SetVisible(visible); 240 scheduler_on_impl_thread_->SetVisible(visible);
241 UpdateBackgroundAnimateTicking();
242 completion->Signal();
243 }
244
245 void ThreadProxy::UpdateBackgroundAnimateTicking() {
241 layer_tree_host_impl_->UpdateBackgroundAnimateTicking( 246 layer_tree_host_impl_->UpdateBackgroundAnimateTicking(
242 !scheduler_on_impl_thread_->WillDrawIfNeeded()); 247 !scheduler_on_impl_thread_->WillDrawIfNeeded() &&
243 completion->Signal(); 248 layer_tree_host_impl_->active_tree()->root_layer());
244 } 249 }
245 250
246 void ThreadProxy::DoCreateAndInitializeOutputSurface() { 251 void ThreadProxy::DoCreateAndInitializeOutputSurface() {
247 TRACE_EVENT0("cc", "ThreadProxy::DoCreateAndInitializeOutputSurface"); 252 TRACE_EVENT0("cc", "ThreadProxy::DoCreateAndInitializeOutputSurface");
248 DCHECK(IsMainThread()); 253 DCHECK(IsMainThread());
249 254
250 scoped_ptr<OutputSurface> output_surface = first_output_surface_.Pass(); 255 scoped_ptr<OutputSurface> output_surface = first_output_surface_.Pass();
251 if (!output_surface) 256 if (!output_surface)
252 output_surface = layer_tree_host_->CreateOutputSurface(); 257 output_surface = layer_tree_host_->CreateOutputSurface();
253 258
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 DCHECK(IsImplThread()); 404 DCHECK(IsImplThread());
400 TRACE_EVENT0("cc", "ThreadProxy::BeginFrameOnImplThread"); 405 TRACE_EVENT0("cc", "ThreadProxy::BeginFrameOnImplThread");
401 scheduler_on_impl_thread_->BeginFrame(args); 406 scheduler_on_impl_thread_->BeginFrame(args);
402 } 407 }
403 408
404 void ThreadProxy::OnCanDrawStateChanged(bool can_draw) { 409 void ThreadProxy::OnCanDrawStateChanged(bool can_draw) {
405 DCHECK(IsImplThread()); 410 DCHECK(IsImplThread());
406 TRACE_EVENT1( 411 TRACE_EVENT1(
407 "cc", "ThreadProxy::OnCanDrawStateChanged", "can_draw", can_draw); 412 "cc", "ThreadProxy::OnCanDrawStateChanged", "can_draw", can_draw);
408 scheduler_on_impl_thread_->SetCanDraw(can_draw); 413 scheduler_on_impl_thread_->SetCanDraw(can_draw);
409 layer_tree_host_impl_->UpdateBackgroundAnimateTicking( 414 UpdateBackgroundAnimateTicking();
410 !scheduler_on_impl_thread_->WillDrawIfNeeded());
411 } 415 }
412 416
413 void ThreadProxy::NotifyReadyToActivate() { 417 void ThreadProxy::NotifyReadyToActivate() {
414 TRACE_EVENT0("cc", "ThreadProxy::NotifyReadyToActivate"); 418 TRACE_EVENT0("cc", "ThreadProxy::NotifyReadyToActivate");
415 scheduler_on_impl_thread_->NotifyReadyToActivate(); 419 scheduler_on_impl_thread_->NotifyReadyToActivate();
416 } 420 }
417 421
418 void ThreadProxy::SetNeedsCommitOnImplThread() { 422 void ThreadProxy::SetNeedsCommitOnImplThread() {
419 DCHECK(IsImplThread()); 423 DCHECK(IsImplThread());
420 TRACE_EVENT0("cc", "ThreadProxy::SetNeedsCommitOnImplThread"); 424 TRACE_EVENT0("cc", "ThreadProxy::SetNeedsCommitOnImplThread");
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after
921 current_resource_update_controller_on_impl_thread_->Finalize(); 925 current_resource_update_controller_on_impl_thread_->Finalize();
922 current_resource_update_controller_on_impl_thread_.reset(); 926 current_resource_update_controller_on_impl_thread_.reset();
923 927
924 layer_tree_host_impl_->BeginCommit(); 928 layer_tree_host_impl_->BeginCommit();
925 layer_tree_host_->BeginCommitOnImplThread(layer_tree_host_impl_.get()); 929 layer_tree_host_->BeginCommitOnImplThread(layer_tree_host_impl_.get());
926 layer_tree_host_->FinishCommitOnImplThread(layer_tree_host_impl_.get()); 930 layer_tree_host_->FinishCommitOnImplThread(layer_tree_host_impl_.get());
927 layer_tree_host_impl_->CommitComplete(); 931 layer_tree_host_impl_->CommitComplete();
928 932
929 SetInputThrottledUntilCommitOnImplThread(false); 933 SetInputThrottledUntilCommitOnImplThread(false);
930 934
931 layer_tree_host_impl_->UpdateBackgroundAnimateTicking( 935 UpdateBackgroundAnimateTicking();
932 !scheduler_on_impl_thread_->WillDrawIfNeeded());
933 936
934 next_frame_is_newly_committed_frame_on_impl_thread_ = true; 937 next_frame_is_newly_committed_frame_on_impl_thread_ = true;
935 938
936 if (layer_tree_host_->settings().impl_side_painting && 939 if (layer_tree_host_->settings().impl_side_painting &&
937 layer_tree_host_->BlocksPendingCommit() && 940 layer_tree_host_->BlocksPendingCommit() &&
938 layer_tree_host_impl_->pending_tree()) { 941 layer_tree_host_impl_->pending_tree()) {
939 // For some layer types in impl-side painting, the commit is held until 942 // For some layer types in impl-side painting, the commit is held until
940 // the pending tree is activated. It's also possible that the 943 // the pending tree is activated. It's also possible that the
941 // pending tree has already activated if there was no work to be done. 944 // pending tree has already activated if there was no work to be done.
942 TRACE_EVENT_INSTANT0("cc", "HoldCommit", TRACE_EVENT_SCOPE_THREAD); 945 TRACE_EVENT_INSTANT0("cc", "HoldCommit", TRACE_EVENT_SCOPE_THREAD);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
995 return result; 998 return result;
996 999
997 base::TimeTicks monotonic_time = 1000 base::TimeTicks monotonic_time =
998 layer_tree_host_impl_->CurrentFrameTimeTicks(); 1001 layer_tree_host_impl_->CurrentFrameTimeTicks();
999 base::Time wall_clock_time = layer_tree_host_impl_->CurrentFrameTime(); 1002 base::Time wall_clock_time = layer_tree_host_impl_->CurrentFrameTime();
1000 1003
1001 // TODO(enne): This should probably happen post-animate. 1004 // TODO(enne): This should probably happen post-animate.
1002 if (layer_tree_host_impl_->pending_tree()) 1005 if (layer_tree_host_impl_->pending_tree())
1003 layer_tree_host_impl_->pending_tree()->UpdateDrawProperties(); 1006 layer_tree_host_impl_->pending_tree()->UpdateDrawProperties();
1004 layer_tree_host_impl_->Animate(monotonic_time, wall_clock_time); 1007 layer_tree_host_impl_->Animate(monotonic_time, wall_clock_time);
1005 layer_tree_host_impl_->UpdateBackgroundAnimateTicking(false); 1008 UpdateBackgroundAnimateTicking();
danakj 2013/08/28 23:36:14 Why is this change correct, when it used to always
brianderson 2013/08/28 23:42:18 At first I did it because it was easier, but then
1006 1009
1007 base::TimeTicks start_time = base::TimeTicks::HighResNow(); 1010 base::TimeTicks start_time = base::TimeTicks::HighResNow();
1008 base::TimeDelta draw_duration_estimate = DrawDurationEstimate(); 1011 base::TimeDelta draw_duration_estimate = DrawDurationEstimate();
1009 base::AutoReset<bool> mark_inside(&inside_draw_, true); 1012 base::AutoReset<bool> mark_inside(&inside_draw_, true);
1010 1013
1011 // This method is called on a forced draw, regardless of whether we are able 1014 // This method is called on a forced draw, regardless of whether we are able
1012 // to produce a frame, as the calling site on main thread is blocked until its 1015 // to produce a frame, as the calling site on main thread is blocked until its
1013 // request completes, and we signal completion here. If CanDraw() is false, we 1016 // request completes, and we signal completion here. If CanDraw() is false, we
1014 // will indicate success=false to the caller, but we must still signal 1017 // will indicate success=false to the caller, but we must still signal
1015 // completion to avoid deadlock. 1018 // completion to avoid deadlock.
(...skipping 26 matching lines...) Expand all
1042 start_ready_animations = false; 1045 start_ready_animations = false;
1043 } 1046 }
1044 1047
1045 if (draw_frame) { 1048 if (draw_frame) {
1046 layer_tree_host_impl_->DrawLayers( 1049 layer_tree_host_impl_->DrawLayers(
1047 &frame, 1050 &frame,
1048 scheduler_on_impl_thread_->LastBeginFrameOnImplThreadTime()); 1051 scheduler_on_impl_thread_->LastBeginFrameOnImplThreadTime());
1049 result.did_draw = true; 1052 result.did_draw = true;
1050 } 1053 }
1051 layer_tree_host_impl_->DidDrawAllLayers(frame); 1054 layer_tree_host_impl_->DidDrawAllLayers(frame);
1052
1053 layer_tree_host_impl_->UpdateAnimationState(start_ready_animations); 1055 layer_tree_host_impl_->UpdateAnimationState(start_ready_animations);
1054 1056
1055 // Check for a pending CompositeAndReadback. 1057 // Check for a pending CompositeAndReadback.
1056 if (readback_request_on_impl_thread_) { 1058 if (readback_request_on_impl_thread_) {
1057 readback_request_on_impl_thread_->success = false; 1059 readback_request_on_impl_thread_->success = false;
1058 if (draw_frame) { 1060 if (draw_frame) {
1059 layer_tree_host_impl_->Readback(readback_request_on_impl_thread_->pixels, 1061 layer_tree_host_impl_->Readback(readback_request_on_impl_thread_->pixels,
1060 readback_request_on_impl_thread_->rect); 1062 readback_request_on_impl_thread_->rect);
1061 readback_request_on_impl_thread_->success = 1063 readback_request_on_impl_thread_->success =
1062 !layer_tree_host_impl_->IsContextLost(); 1064 !layer_tree_host_impl_->IsContextLost();
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
1493 1495
1494 if (completion_event_for_commit_held_on_tree_activation_ && 1496 if (completion_event_for_commit_held_on_tree_activation_ &&
1495 !layer_tree_host_impl_->pending_tree()) { 1497 !layer_tree_host_impl_->pending_tree()) {
1496 TRACE_EVENT_INSTANT0("cc", "ReleaseCommitbyActivation", 1498 TRACE_EVENT_INSTANT0("cc", "ReleaseCommitbyActivation",
1497 TRACE_EVENT_SCOPE_THREAD); 1499 TRACE_EVENT_SCOPE_THREAD);
1498 DCHECK(layer_tree_host_impl_->settings().impl_side_painting); 1500 DCHECK(layer_tree_host_impl_->settings().impl_side_painting);
1499 completion_event_for_commit_held_on_tree_activation_->Signal(); 1501 completion_event_for_commit_held_on_tree_activation_->Signal();
1500 completion_event_for_commit_held_on_tree_activation_ = NULL; 1502 completion_event_for_commit_held_on_tree_activation_ = NULL;
1501 } 1503 }
1502 1504
1505 UpdateBackgroundAnimateTicking();
1506
1503 commit_to_activate_duration_history_.InsertSample( 1507 commit_to_activate_duration_history_.InsertSample(
1504 base::TimeTicks::HighResNow() - commit_complete_time_); 1508 base::TimeTicks::HighResNow() - commit_complete_time_);
1505 } 1509 }
1506 1510
1507 } // namespace cc 1511 } // 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