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

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

Issue 13613003: cc: Make animations tick regardless of drawing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Drop extra statemachine function Created 7 years, 8 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/single_thread_proxy.cc ('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 "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "cc/base/thread.h" 10 #include "cc/base/thread.h"
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 "cc", "ThreadProxy::RequestVSyncNotification", "enable", !!client); 341 "cc", "ThreadProxy::RequestVSyncNotification", "enable", !!client);
342 vsync_client_ = client; 342 vsync_client_ = client;
343 layer_tree_host_impl_->EnableVSyncNotification(!!client); 343 layer_tree_host_impl_->EnableVSyncNotification(!!client);
344 } 344 }
345 345
346 void ThreadProxy::OnCanDrawStateChanged(bool can_draw) { 346 void ThreadProxy::OnCanDrawStateChanged(bool can_draw) {
347 DCHECK(IsImplThread()); 347 DCHECK(IsImplThread());
348 TRACE_EVENT1( 348 TRACE_EVENT1(
349 "cc", "ThreadProxy::OnCanDrawStateChanged", "can_draw", can_draw); 349 "cc", "ThreadProxy::OnCanDrawStateChanged", "can_draw", can_draw);
350 scheduler_on_impl_thread_->SetCanDraw(can_draw); 350 scheduler_on_impl_thread_->SetCanDraw(can_draw);
351 layer_tree_host_impl_->UpdateBackgroundAnimateTicking(
352 !scheduler_on_impl_thread_->WillDrawIfNeeded());
351 } 353 }
352 354
353 void ThreadProxy::OnHasPendingTreeStateChanged(bool has_pending_tree) { 355 void ThreadProxy::OnHasPendingTreeStateChanged(bool has_pending_tree) {
354 DCHECK(IsImplThread()); 356 DCHECK(IsImplThread());
355 TRACE_EVENT1("cc", 357 TRACE_EVENT1("cc",
356 "ThreadProxy::OnHasPendingTreeStateChanged", 358 "ThreadProxy::OnHasPendingTreeStateChanged",
357 "has_pending_tree", 359 "has_pending_tree",
358 has_pending_tree); 360 has_pending_tree);
359 scheduler_on_impl_thread_->SetHasPendingTree(has_pending_tree); 361 scheduler_on_impl_thread_->SetHasPendingTree(has_pending_tree);
360 } 362 }
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
804 806
805 // Complete all remaining texture updates. 807 // Complete all remaining texture updates.
806 current_resource_update_controller_on_impl_thread_->Finalize(); 808 current_resource_update_controller_on_impl_thread_->Finalize();
807 current_resource_update_controller_on_impl_thread_.reset(); 809 current_resource_update_controller_on_impl_thread_.reset();
808 810
809 layer_tree_host_impl_->BeginCommit(); 811 layer_tree_host_impl_->BeginCommit();
810 layer_tree_host_->BeginCommitOnImplThread(layer_tree_host_impl_.get()); 812 layer_tree_host_->BeginCommitOnImplThread(layer_tree_host_impl_.get());
811 layer_tree_host_->FinishCommitOnImplThread(layer_tree_host_impl_.get()); 813 layer_tree_host_->FinishCommitOnImplThread(layer_tree_host_impl_.get());
812 layer_tree_host_impl_->CommitComplete(); 814 layer_tree_host_impl_->CommitComplete();
813 815
816 layer_tree_host_impl_->UpdateBackgroundAnimateTicking(
817 !scheduler_on_impl_thread_->WillDrawIfNeeded());
818
814 next_frame_is_newly_committed_frame_on_impl_thread_ = true; 819 next_frame_is_newly_committed_frame_on_impl_thread_ = true;
815 820
816 if (layer_tree_host_->settings().impl_side_painting && 821 if (layer_tree_host_->settings().impl_side_painting &&
817 layer_tree_host_->BlocksPendingCommit()) { 822 layer_tree_host_->BlocksPendingCommit()) {
818 // For some layer types in impl-side painting, the commit is held until 823 // For some layer types in impl-side painting, the commit is held until
819 // the pending tree is activated. 824 // the pending tree is activated.
820 TRACE_EVENT_INSTANT0("cc", "HoldCommit", TRACE_EVENT_SCOPE_THREAD); 825 TRACE_EVENT_INSTANT0("cc", "HoldCommit", TRACE_EVENT_SCOPE_THREAD);
821 completion_event_for_commit_held_on_tree_activation_ = 826 completion_event_for_commit_held_on_tree_activation_ =
822 commit_completion_event_on_impl_thread_; 827 commit_completion_event_on_impl_thread_;
823 commit_completion_event_on_impl_thread_ = NULL; 828 commit_completion_event_on_impl_thread_ = NULL;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
869 874
870 // FIXME: compute the frame display time more intelligently 875 // FIXME: compute the frame display time more intelligently
871 base::TimeTicks monotonic_time = base::TimeTicks::Now(); 876 base::TimeTicks monotonic_time = base::TimeTicks::Now();
872 base::Time wall_clock_time = base::Time::Now(); 877 base::Time wall_clock_time = base::Time::Now();
873 878
874 if (input_handler_on_impl_thread_) 879 if (input_handler_on_impl_thread_)
875 input_handler_on_impl_thread_->Animate(monotonic_time); 880 input_handler_on_impl_thread_->Animate(monotonic_time);
876 881
877 layer_tree_host_impl_->ActivatePendingTreeIfNeeded(); 882 layer_tree_host_impl_->ActivatePendingTreeIfNeeded();
878 layer_tree_host_impl_->Animate(monotonic_time, wall_clock_time); 883 layer_tree_host_impl_->Animate(monotonic_time, wall_clock_time);
884 layer_tree_host_impl_->UpdateBackgroundAnimateTicking(false);
879 885
880 // This method is called on a forced draw, regardless of whether we are able 886 // This method is called on a forced draw, regardless of whether we are able
881 // to produce a frame, as the calling site on main thread is blocked until its 887 // to produce a frame, as the calling site on main thread is blocked until its
882 // request completes, and we signal completion here. If canDraw() is false, we 888 // request completes, and we signal completion here. If CanDraw() is false, we
883 // will indicate success=false to the caller, but we must still signal 889 // will indicate success=false to the caller, but we must still signal
884 // completion to avoid deadlock. 890 // completion to avoid deadlock.
885 891
886 // We guard prepareToDraw() with canDraw() because it always returns a valid 892 // We guard PrepareToDraw() with CanDraw() because it always returns a valid
887 // frame, so can only be used when such a frame is possible. Since 893 // frame, so can only be used when such a frame is possible. Since
888 // drawLayers() depends on the result of prepareToDraw(), it is guarded on 894 // DrawLayers() depends on the result of PrepareToDraw(), it is guarded on
889 // canDraw() as well. 895 // CanDraw() as well.
890 896
891 LayerTreeHostImpl::FrameData frame; 897 LayerTreeHostImpl::FrameData frame;
892 bool draw_frame = 898 bool draw_frame = false;
893 layer_tree_host_impl_->CanDraw() && 899 bool start_ready_animations = true;
894 (layer_tree_host_impl_->PrepareToDraw(&frame) || forced_draw); 900
901 if (layer_tree_host_impl_->CanDraw()) {
902 // Do not start animations if we skip drawing the frame to avoid
903 // checkerboarding.
904 if (layer_tree_host_impl_->PrepareToDraw(&frame) || forced_draw)
905 draw_frame = true;
906 else
907 start_ready_animations = false;
908 }
909
895 if (draw_frame) { 910 if (draw_frame) {
896 layer_tree_host_impl_->DrawLayers( 911 layer_tree_host_impl_->DrawLayers(
897 &frame, 912 &frame,
898 scheduler_on_impl_thread_->LastVSyncTime()); 913 scheduler_on_impl_thread_->LastVSyncTime());
899 result.did_draw= true; 914 result.did_draw = true;
900 } 915 }
901 layer_tree_host_impl_->DidDrawAllLayers(frame); 916 layer_tree_host_impl_->DidDrawAllLayers(frame);
902 917
918 layer_tree_host_impl_->UpdateAnimationState(start_ready_animations);
919
903 // Check for tree activation. 920 // Check for tree activation.
904 if (completion_event_for_commit_held_on_tree_activation_ && 921 if (completion_event_for_commit_held_on_tree_activation_ &&
905 !layer_tree_host_impl_->pending_tree()) { 922 !layer_tree_host_impl_->pending_tree()) {
906 TRACE_EVENT_INSTANT0("cc", "ReleaseCommitbyActivation", 923 TRACE_EVENT_INSTANT0("cc", "ReleaseCommitbyActivation",
907 TRACE_EVENT_SCOPE_THREAD); 924 TRACE_EVENT_SCOPE_THREAD);
908 DCHECK(layer_tree_host_impl_->settings().impl_side_painting); 925 DCHECK(layer_tree_host_impl_->settings().impl_side_painting);
909 completion_event_for_commit_held_on_tree_activation_->Signal(); 926 completion_event_for_commit_held_on_tree_activation_->Signal();
910 completion_event_for_commit_held_on_tree_activation_ = NULL; 927 completion_event_for_commit_held_on_tree_activation_ = NULL;
911 } 928 }
912 929
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
1313 base::Bind(&ThreadProxy::StartScrollbarAnimationOnImplThread, 1330 base::Bind(&ThreadProxy::StartScrollbarAnimationOnImplThread,
1314 impl_thread_weak_ptr_), 1331 impl_thread_weak_ptr_),
1315 delay); 1332 delay);
1316 } 1333 }
1317 1334
1318 void ThreadProxy::StartScrollbarAnimationOnImplThread() { 1335 void ThreadProxy::StartScrollbarAnimationOnImplThread() {
1319 layer_tree_host_impl_->StartScrollbarAnimation(base::TimeTicks::Now()); 1336 layer_tree_host_impl_->StartScrollbarAnimation(base::TimeTicks::Now());
1320 } 1337 }
1321 1338
1322 } // namespace cc 1339 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/single_thread_proxy.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698