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 = |
893 layer_tree_host_impl_->CanDraw() && | 897 layer_tree_host_impl_->CanDraw() && |
894 (layer_tree_host_impl_->PrepareToDraw(&frame) || forced_draw); | 898 (layer_tree_host_impl_->PrepareToDraw(&frame) || forced_draw); |
895 if (draw_frame) { | 899 if (draw_frame) { |
896 layer_tree_host_impl_->DrawLayers( | 900 layer_tree_host_impl_->DrawLayers( |
897 &frame, | 901 &frame, |
898 scheduler_on_impl_thread_->LastVSyncTime()); | 902 scheduler_on_impl_thread_->LastVSyncTime()); |
899 result.did_draw= true; | 903 result.did_draw= true; |
900 } | 904 } |
901 layer_tree_host_impl_->DidDrawAllLayers(frame); | 905 layer_tree_host_impl_->DidDrawAllLayers(frame); |
902 | 906 |
907 layer_tree_host_impl_->UpdateAnimationState(); | |
ajuma
2013/04/04 15:28:47
If the call to PrepareToDraw (above) returned fals
danakj
2013/04/04 18:28:25
Ok, I've done this and added LayerTreeHostAnimatio
| |
908 | |
903 // Check for tree activation. | 909 // Check for tree activation. |
904 if (completion_event_for_commit_held_on_tree_activation_ && | 910 if (completion_event_for_commit_held_on_tree_activation_ && |
905 !layer_tree_host_impl_->pending_tree()) { | 911 !layer_tree_host_impl_->pending_tree()) { |
906 TRACE_EVENT_INSTANT0("cc", "ReleaseCommitbyActivation", | 912 TRACE_EVENT_INSTANT0("cc", "ReleaseCommitbyActivation", |
907 TRACE_EVENT_SCOPE_THREAD); | 913 TRACE_EVENT_SCOPE_THREAD); |
908 DCHECK(layer_tree_host_impl_->settings().impl_side_painting); | 914 DCHECK(layer_tree_host_impl_->settings().impl_side_painting); |
909 completion_event_for_commit_held_on_tree_activation_->Signal(); | 915 completion_event_for_commit_held_on_tree_activation_->Signal(); |
910 completion_event_for_commit_held_on_tree_activation_ = NULL; | 916 completion_event_for_commit_held_on_tree_activation_ = NULL; |
911 } | 917 } |
912 | 918 |
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1313 base::Bind(&ThreadProxy::StartScrollbarAnimationOnImplThread, | 1319 base::Bind(&ThreadProxy::StartScrollbarAnimationOnImplThread, |
1314 impl_thread_weak_ptr_), | 1320 impl_thread_weak_ptr_), |
1315 delay); | 1321 delay); |
1316 } | 1322 } |
1317 | 1323 |
1318 void ThreadProxy::StartScrollbarAnimationOnImplThread() { | 1324 void ThreadProxy::StartScrollbarAnimationOnImplThread() { |
1319 layer_tree_host_impl_->StartScrollbarAnimation(base::TimeTicks::Now()); | 1325 layer_tree_host_impl_->StartScrollbarAnimation(base::TimeTicks::Now()); |
1320 } | 1326 } |
1321 | 1327 |
1322 } // namespace cc | 1328 } // namespace cc |
OLD | NEW |