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 "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 Loading... |
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(); |
351 } | 352 } |
352 | 353 |
353 void ThreadProxy::OnHasPendingTreeStateChanged(bool has_pending_tree) { | 354 void ThreadProxy::OnHasPendingTreeStateChanged(bool has_pending_tree) { |
354 DCHECK(IsImplThread()); | 355 DCHECK(IsImplThread()); |
355 TRACE_EVENT1("cc", | 356 TRACE_EVENT1("cc", |
356 "ThreadProxy::OnHasPendingTreeStateChanged", | 357 "ThreadProxy::OnHasPendingTreeStateChanged", |
357 "has_pending_tree", | 358 "has_pending_tree", |
358 has_pending_tree); | 359 has_pending_tree); |
359 scheduler_on_impl_thread_->SetHasPendingTree(has_pending_tree); | 360 scheduler_on_impl_thread_->SetHasPendingTree(has_pending_tree); |
360 } | 361 } |
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
804 | 805 |
805 // Complete all remaining texture updates. | 806 // Complete all remaining texture updates. |
806 current_resource_update_controller_on_impl_thread_->Finalize(); | 807 current_resource_update_controller_on_impl_thread_->Finalize(); |
807 current_resource_update_controller_on_impl_thread_.reset(); | 808 current_resource_update_controller_on_impl_thread_.reset(); |
808 | 809 |
809 layer_tree_host_impl_->BeginCommit(); | 810 layer_tree_host_impl_->BeginCommit(); |
810 layer_tree_host_->BeginCommitOnImplThread(layer_tree_host_impl_.get()); | 811 layer_tree_host_->BeginCommitOnImplThread(layer_tree_host_impl_.get()); |
811 layer_tree_host_->FinishCommitOnImplThread(layer_tree_host_impl_.get()); | 812 layer_tree_host_->FinishCommitOnImplThread(layer_tree_host_impl_.get()); |
812 layer_tree_host_impl_->CommitComplete(); | 813 layer_tree_host_impl_->CommitComplete(); |
813 | 814 |
| 815 layer_tree_host_impl_->UpdateBackgroundAnimateTicking(); |
| 816 |
814 next_frame_is_newly_committed_frame_on_impl_thread_ = true; | 817 next_frame_is_newly_committed_frame_on_impl_thread_ = true; |
815 | 818 |
816 if (layer_tree_host_->settings().impl_side_painting && | 819 if (layer_tree_host_->settings().impl_side_painting && |
817 layer_tree_host_->BlocksPendingCommit()) { | 820 layer_tree_host_->BlocksPendingCommit()) { |
818 // For some layer types in impl-side painting, the commit is held until | 821 // For some layer types in impl-side painting, the commit is held until |
819 // the pending tree is activated. | 822 // the pending tree is activated. |
820 TRACE_EVENT_INSTANT0("cc", "HoldCommit", TRACE_EVENT_SCOPE_THREAD); | 823 TRACE_EVENT_INSTANT0("cc", "HoldCommit", TRACE_EVENT_SCOPE_THREAD); |
821 completion_event_for_commit_held_on_tree_activation_ = | 824 completion_event_for_commit_held_on_tree_activation_ = |
822 commit_completion_event_on_impl_thread_; | 825 commit_completion_event_on_impl_thread_; |
823 commit_completion_event_on_impl_thread_ = NULL; | 826 commit_completion_event_on_impl_thread_ = NULL; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
869 | 872 |
870 // FIXME: compute the frame display time more intelligently | 873 // FIXME: compute the frame display time more intelligently |
871 base::TimeTicks monotonic_time = base::TimeTicks::Now(); | 874 base::TimeTicks monotonic_time = base::TimeTicks::Now(); |
872 base::Time wall_clock_time = base::Time::Now(); | 875 base::Time wall_clock_time = base::Time::Now(); |
873 | 876 |
874 if (input_handler_on_impl_thread_) | 877 if (input_handler_on_impl_thread_) |
875 input_handler_on_impl_thread_->Animate(monotonic_time); | 878 input_handler_on_impl_thread_->Animate(monotonic_time); |
876 | 879 |
877 layer_tree_host_impl_->ActivatePendingTreeIfNeeded(); | 880 layer_tree_host_impl_->ActivatePendingTreeIfNeeded(); |
878 layer_tree_host_impl_->Animate(monotonic_time, wall_clock_time); | 881 layer_tree_host_impl_->Animate(monotonic_time, wall_clock_time); |
| 882 layer_tree_host_impl_->UpdateBackgroundAnimateTicking(); |
879 | 883 |
880 // This method is called on a forced draw, regardless of whether we are able | 884 // 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 | 885 // 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 | 886 // 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 | 887 // will indicate success=false to the caller, but we must still signal |
884 // completion to avoid deadlock. | 888 // completion to avoid deadlock. |
885 | 889 |
886 // We guard prepareToDraw() with canDraw() because it always returns a valid | 890 // 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 | 891 // 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 | 892 // DrawLayers() depends on the result of PrepareToDraw(), it is guarded on |
889 // canDraw() as well. | 893 // CanDraw() as well. |
890 | 894 |
891 LayerTreeHostImpl::FrameData frame; | 895 LayerTreeHostImpl::FrameData frame; |
892 bool draw_frame = | 896 bool draw_frame = false; |
893 layer_tree_host_impl_->CanDraw() && | 897 bool start_ready_animations = true; |
894 (layer_tree_host_impl_->PrepareToDraw(&frame) || forced_draw); | 898 |
| 899 if (layer_tree_host_impl_->CanDraw()) { |
| 900 // Do not start animations if we skip drawing the frame to avoid |
| 901 // checkerboarding. |
| 902 if (layer_tree_host_impl_->PrepareToDraw(&frame) || forced_draw) |
| 903 draw_frame = true; |
| 904 else |
| 905 start_ready_animations = false; |
| 906 } |
| 907 |
895 if (draw_frame) { | 908 if (draw_frame) { |
896 layer_tree_host_impl_->DrawLayers( | 909 layer_tree_host_impl_->DrawLayers( |
897 &frame, | 910 &frame, |
898 scheduler_on_impl_thread_->LastVSyncTime()); | 911 scheduler_on_impl_thread_->LastVSyncTime()); |
899 result.did_draw= true; | 912 result.did_draw = true; |
900 } | 913 } |
901 layer_tree_host_impl_->DidDrawAllLayers(frame); | 914 layer_tree_host_impl_->DidDrawAllLayers(frame); |
902 | 915 |
| 916 layer_tree_host_impl_->UpdateAnimationState(start_ready_animations); |
| 917 |
903 // Check for tree activation. | 918 // Check for tree activation. |
904 if (completion_event_for_commit_held_on_tree_activation_ && | 919 if (completion_event_for_commit_held_on_tree_activation_ && |
905 !layer_tree_host_impl_->pending_tree()) { | 920 !layer_tree_host_impl_->pending_tree()) { |
906 TRACE_EVENT_INSTANT0("cc", "ReleaseCommitbyActivation", | 921 TRACE_EVENT_INSTANT0("cc", "ReleaseCommitbyActivation", |
907 TRACE_EVENT_SCOPE_THREAD); | 922 TRACE_EVENT_SCOPE_THREAD); |
908 DCHECK(layer_tree_host_impl_->settings().impl_side_painting); | 923 DCHECK(layer_tree_host_impl_->settings().impl_side_painting); |
909 completion_event_for_commit_held_on_tree_activation_->Signal(); | 924 completion_event_for_commit_held_on_tree_activation_->Signal(); |
910 completion_event_for_commit_held_on_tree_activation_ = NULL; | 925 completion_event_for_commit_held_on_tree_activation_ = NULL; |
911 } | 926 } |
912 | 927 |
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1313 base::Bind(&ThreadProxy::StartScrollbarAnimationOnImplThread, | 1328 base::Bind(&ThreadProxy::StartScrollbarAnimationOnImplThread, |
1314 impl_thread_weak_ptr_), | 1329 impl_thread_weak_ptr_), |
1315 delay); | 1330 delay); |
1316 } | 1331 } |
1317 | 1332 |
1318 void ThreadProxy::StartScrollbarAnimationOnImplThread() { | 1333 void ThreadProxy::StartScrollbarAnimationOnImplThread() { |
1319 layer_tree_host_impl_->StartScrollbarAnimation(base::TimeTicks::Now()); | 1334 layer_tree_host_impl_->StartScrollbarAnimation(base::TimeTicks::Now()); |
1320 } | 1335 } |
1321 | 1336 |
1322 } // namespace cc | 1337 } // namespace cc |
OLD | NEW |