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 <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 Loading... | |
69 commit_requested_(false), | 69 commit_requested_(false), |
70 commit_request_sent_to_impl_thread_(false), | 70 commit_request_sent_to_impl_thread_(false), |
71 created_offscreen_context_provider_(false), | 71 created_offscreen_context_provider_(false), |
72 layer_tree_host_(layer_tree_host), | 72 layer_tree_host_(layer_tree_host), |
73 started_(false), | 73 started_(false), |
74 textures_acquired_(true), | 74 textures_acquired_(true), |
75 in_composite_and_readback_(false), | 75 in_composite_and_readback_(false), |
76 manage_tiles_pending_(false), | 76 manage_tiles_pending_(false), |
77 weak_factory_on_impl_thread_(this), | 77 weak_factory_on_impl_thread_(this), |
78 weak_factory_(this), | 78 weak_factory_(this), |
79 frame_did_draw_(false), | |
79 begin_frame_sent_to_main_thread_completion_event_on_impl_thread_(NULL), | 80 begin_frame_sent_to_main_thread_completion_event_on_impl_thread_(NULL), |
80 readback_request_on_impl_thread_(NULL), | 81 readback_request_on_impl_thread_(NULL), |
81 commit_completion_event_on_impl_thread_(NULL), | 82 commit_completion_event_on_impl_thread_(NULL), |
82 completion_event_for_commit_held_on_tree_activation_(NULL), | 83 completion_event_for_commit_held_on_tree_activation_(NULL), |
83 texture_acquisition_completion_event_on_impl_thread_(NULL), | 84 texture_acquisition_completion_event_on_impl_thread_(NULL), |
84 next_frame_is_newly_committed_frame_on_impl_thread_(false), | 85 next_frame_is_newly_committed_frame_on_impl_thread_(false), |
85 throttle_frame_production_( | 86 throttle_frame_production_( |
86 layer_tree_host->settings().throttle_frame_production), | 87 layer_tree_host->settings().throttle_frame_production), |
87 begin_frame_scheduling_enabled_( | 88 begin_frame_scheduling_enabled_( |
88 layer_tree_host->settings().begin_frame_scheduling_enabled), | 89 layer_tree_host->settings().begin_frame_scheduling_enabled), |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
363 Proxy::MainThreadTaskRunner()->PostTask( | 364 Proxy::MainThreadTaskRunner()->PostTask( |
364 FROM_HERE, | 365 FROM_HERE, |
365 base::Bind(&ThreadProxy::DidCompleteSwapBuffers, main_thread_weak_ptr_)); | 366 base::Bind(&ThreadProxy::DidCompleteSwapBuffers, main_thread_weak_ptr_)); |
366 } | 367 } |
367 | 368 |
368 void ThreadProxy::SetNeedsBeginFrameOnImplThread(bool enable) { | 369 void ThreadProxy::SetNeedsBeginFrameOnImplThread(bool enable) { |
369 DCHECK(IsImplThread()); | 370 DCHECK(IsImplThread()); |
370 TRACE_EVENT1("cc", "ThreadProxy::SetNeedsBeginFrameOnImplThread", | 371 TRACE_EVENT1("cc", "ThreadProxy::SetNeedsBeginFrameOnImplThread", |
371 "enable", enable); | 372 "enable", enable); |
372 layer_tree_host_impl_->SetNeedsBeginFrame(enable); | 373 layer_tree_host_impl_->SetNeedsBeginFrame(enable); |
374 layer_tree_host_impl_->UpdateBackgroundAnimateTicking(!enable); | |
373 } | 375 } |
374 | 376 |
375 void ThreadProxy::BeginFrameOnImplThread(const BeginFrameArgs& args) { | 377 void ThreadProxy::BeginFrameOnImplThread(const BeginFrameArgs& args) { |
376 DCHECK(IsImplThread()); | 378 DCHECK(IsImplThread()); |
377 TRACE_EVENT0("cc", "ThreadProxy::BeginFrameOnImplThread"); | 379 TRACE_EVENT0("cc", "ThreadProxy::BeginFrameOnImplThread"); |
380 | |
381 base::TimeTicks monotonic_time = | |
382 layer_tree_host_impl_->CurrentFrameTimeTicks(); | |
383 base::Time wall_clock_time = layer_tree_host_impl_->CurrentFrameTime(); | |
384 layer_tree_host_impl_->Animate(monotonic_time, wall_clock_time); | |
385 | |
386 // Reinitialize for the current frame. | |
387 frame_did_draw_ = false; | |
388 | |
378 scheduler_on_impl_thread_->BeginFrame(args); | 389 scheduler_on_impl_thread_->BeginFrame(args); |
379 } | 390 } |
380 | 391 |
392 void ThreadProxy::DidBeginFrameDeadlineOnImplThread() { | |
393 layer_tree_host_impl_->UpdateAnimationState(frame_did_draw_); | |
394 layer_tree_host_impl_->ResetCurrentFrameTimeForNextFrame(); | |
395 } | |
396 | |
381 void ThreadProxy::OnCanDrawStateChanged(bool can_draw) { | 397 void ThreadProxy::OnCanDrawStateChanged(bool can_draw) { |
382 DCHECK(IsImplThread()); | 398 DCHECK(IsImplThread()); |
383 TRACE_EVENT1( | 399 TRACE_EVENT1( |
384 "cc", "ThreadProxy::OnCanDrawStateChanged", "can_draw", can_draw); | 400 "cc", "ThreadProxy::OnCanDrawStateChanged", "can_draw", can_draw); |
385 scheduler_on_impl_thread_->SetCanDraw(can_draw); | 401 scheduler_on_impl_thread_->SetCanDraw(can_draw); |
386 layer_tree_host_impl_->UpdateBackgroundAnimateTicking( | 402 layer_tree_host_impl_->UpdateBackgroundAnimateTicking( |
387 !scheduler_on_impl_thread_->WillDrawIfNeeded()); | 403 !scheduler_on_impl_thread_->WillDrawIfNeeded()); |
388 } | 404 } |
389 | 405 |
390 void ThreadProxy::OnHasPendingTreeStateChanged(bool has_pending_tree) { | 406 void ThreadProxy::OnHasPendingTreeStateChanged(bool has_pending_tree) { |
391 DCHECK(IsImplThread()); | 407 DCHECK(IsImplThread()); |
392 TRACE_EVENT1("cc", "ThreadProxy::OnHasPendingTreeStateChanged", | 408 TRACE_EVENT1("cc", "ThreadProxy::OnHasPendingTreeStateChanged", |
393 "has_pending_tree", has_pending_tree); | 409 "has_pending_tree", has_pending_tree); |
394 scheduler_on_impl_thread_->SetHasPendingTree(has_pending_tree); | 410 scheduler_on_impl_thread_->SetHasTrees( |
brianderson
2013/07/09 01:50:48
The meaning of the two arguments to SetHasTrees (h
| |
411 has_pending_tree, | |
412 layer_tree_host_impl_->active_tree() ? | |
413 !layer_tree_host_impl_->active_tree()->root_layer() : true); | |
414 | |
415 if (!has_pending_tree && !deferred_start_commit_on_impl_thread_.is_null()) { | |
416 Proxy::ImplThreadTaskRunner()->PostTask( | |
417 FROM_HERE, | |
418 deferred_start_commit_on_impl_thread_); | |
419 deferred_start_commit_on_impl_thread_.Reset(); | |
420 } | |
395 } | 421 } |
396 | 422 |
397 void ThreadProxy::SetNeedsCommitOnImplThread() { | 423 void ThreadProxy::SetNeedsCommitOnImplThread() { |
398 DCHECK(IsImplThread()); | 424 DCHECK(IsImplThread()); |
399 TRACE_EVENT0("cc", "ThreadProxy::SetNeedsCommitOnImplThread"); | 425 TRACE_EVENT0("cc", "ThreadProxy::SetNeedsCommitOnImplThread"); |
400 scheduler_on_impl_thread_->SetNeedsCommit(); | 426 scheduler_on_impl_thread_->SetNeedsCommit(); |
401 } | 427 } |
402 | 428 |
403 void ThreadProxy::PostAnimationEventsToMainThreadOnImplThread( | 429 void ThreadProxy::PostAnimationEventsToMainThreadOnImplThread( |
404 scoped_ptr<AnimationEventsVector> events, | 430 scoped_ptr<AnimationEventsVector> events, |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
620 TRACE_EVENT0("cc", "ThreadProxy::FinishAllRenderingOnImplThread"); | 646 TRACE_EVENT0("cc", "ThreadProxy::FinishAllRenderingOnImplThread"); |
621 DCHECK(IsImplThread()); | 647 DCHECK(IsImplThread()); |
622 layer_tree_host_impl_->FinishAllRendering(); | 648 layer_tree_host_impl_->FinishAllRendering(); |
623 completion->Signal(); | 649 completion->Signal(); |
624 } | 650 } |
625 | 651 |
626 void ThreadProxy::ScheduledActionSendBeginFrameToMainThread() { | 652 void ThreadProxy::ScheduledActionSendBeginFrameToMainThread() { |
627 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionSendBeginFrameToMainThread"); | 653 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionSendBeginFrameToMainThread"); |
628 scoped_ptr<BeginFrameAndCommitState> begin_frame_state( | 654 scoped_ptr<BeginFrameAndCommitState> begin_frame_state( |
629 new BeginFrameAndCommitState); | 655 new BeginFrameAndCommitState); |
656 | |
630 begin_frame_state->monotonic_frame_begin_time = | 657 begin_frame_state->monotonic_frame_begin_time = |
631 layer_tree_host_impl_->CurrentPhysicalTimeTicks(); | 658 layer_tree_host_impl_->CurrentPhysicalTimeTicks(); |
632 begin_frame_state->scroll_info = | 659 begin_frame_state->scroll_info = |
633 layer_tree_host_impl_->ProcessScrollDeltas(); | 660 layer_tree_host_impl_->ProcessScrollDeltas(); |
634 | 661 |
635 if (!layer_tree_host_impl_->settings().impl_side_painting) { | 662 if (!layer_tree_host_impl_->settings().impl_side_painting) { |
636 DCHECK_GT(layer_tree_host_impl_->memory_allocation_limit_bytes(), 0u); | 663 DCHECK_GT(layer_tree_host_impl_->memory_allocation_limit_bytes(), 0u); |
637 } | 664 } |
665 | |
666 | |
638 begin_frame_state->memory_allocation_limit_bytes = | 667 begin_frame_state->memory_allocation_limit_bytes = |
639 layer_tree_host_impl_->memory_allocation_limit_bytes(); | 668 layer_tree_host_impl_->memory_allocation_limit_bytes(); |
640 Proxy::MainThreadTaskRunner()->PostTask( | 669 Proxy::MainThreadTaskRunner()->PostTask( |
641 FROM_HERE, | 670 FROM_HERE, |
642 base::Bind(&ThreadProxy::BeginFrameOnMainThread, | 671 base::Bind(&ThreadProxy::BeginFrameOnMainThread, |
643 main_thread_weak_ptr_, | 672 main_thread_weak_ptr_, |
644 base::Passed(&begin_frame_state))); | 673 base::Passed(&begin_frame_state))); |
645 | 674 |
646 if (begin_frame_sent_to_main_thread_completion_event_on_impl_thread_) { | 675 if (begin_frame_sent_to_main_thread_completion_event_on_impl_thread_) { |
647 begin_frame_sent_to_main_thread_completion_event_on_impl_thread_->Signal(); | 676 begin_frame_sent_to_main_thread_completion_event_on_impl_thread_->Signal(); |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
775 } | 804 } |
776 | 805 |
777 layer_tree_host_->CommitComplete(); | 806 layer_tree_host_->CommitComplete(); |
778 layer_tree_host_->DidBeginFrame(); | 807 layer_tree_host_->DidBeginFrame(); |
779 } | 808 } |
780 | 809 |
781 void ThreadProxy::StartCommitOnImplThread( | 810 void ThreadProxy::StartCommitOnImplThread( |
782 CompletionEvent* completion, | 811 CompletionEvent* completion, |
783 ResourceUpdateQueue* raw_queue, | 812 ResourceUpdateQueue* raw_queue, |
784 scoped_refptr<cc::ContextProvider> offscreen_context_provider) { | 813 scoped_refptr<cc::ContextProvider> offscreen_context_provider) { |
785 scoped_ptr<ResourceUpdateQueue> queue(raw_queue); | |
786 | |
787 TRACE_EVENT0("cc", "ThreadProxy::StartCommitOnImplThread"); | 814 TRACE_EVENT0("cc", "ThreadProxy::StartCommitOnImplThread"); |
788 DCHECK(!commit_completion_event_on_impl_thread_); | 815 DCHECK(!commit_completion_event_on_impl_thread_); |
789 DCHECK(IsImplThread() && IsMainThreadBlocked()); | 816 DCHECK(IsImplThread() && IsMainThreadBlocked()); |
790 DCHECK(scheduler_on_impl_thread_); | 817 DCHECK(scheduler_on_impl_thread_); |
791 DCHECK(scheduler_on_impl_thread_->CommitPending()); | 818 DCHECK(scheduler_on_impl_thread_->CommitPending()); |
792 | 819 |
793 if (!layer_tree_host_impl_) { | 820 if (!layer_tree_host_impl_) { |
794 TRACE_EVENT0("cc", "EarlyOut_NoLayerTree"); | 821 TRACE_EVENT0("cc", "EarlyOut_NoLayerTree"); |
795 completion->Signal(); | 822 completion->Signal(); |
823 | |
796 return; | 824 return; |
797 } | 825 } |
798 | 826 |
827 // We defer forced commits while there is a pending tree here. | |
brianderson
2013/07/09 01:50:48
I added deferred_start_commit_on_impl_thread_ in o
| |
828 if (layer_tree_host_impl_->pending_tree()) { | |
829 DCHECK(deferred_start_commit_on_impl_thread_.is_null()); | |
830 deferred_start_commit_on_impl_thread_ = | |
831 base::Bind(&ThreadProxy::StartCommitOnImplThread, | |
832 impl_thread_weak_ptr_, | |
833 completion, | |
834 raw_queue, | |
835 offscreen_context_provider); | |
836 return; | |
837 } | |
838 | |
839 scoped_ptr<ResourceUpdateQueue> queue(raw_queue); | |
840 | |
799 if (offscreen_context_provider.get()) | 841 if (offscreen_context_provider.get()) |
800 offscreen_context_provider->BindToCurrentThread(); | 842 offscreen_context_provider->BindToCurrentThread(); |
801 layer_tree_host_impl_->resource_provider()-> | 843 layer_tree_host_impl_->resource_provider()-> |
802 set_offscreen_context_provider(offscreen_context_provider); | 844 set_offscreen_context_provider(offscreen_context_provider); |
803 | 845 |
804 if (layer_tree_host_->contents_texture_manager()) { | 846 if (layer_tree_host_->contents_texture_manager()) { |
805 if (layer_tree_host_->contents_texture_manager()-> | 847 if (layer_tree_host_->contents_texture_manager()-> |
806 LinkedEvictedBackingsExist()) { | 848 LinkedEvictedBackingsExist()) { |
807 // Clear any uploads we were making to textures linked to evicted | 849 // Clear any uploads we were making to textures linked to evicted |
808 // resources | 850 // resources |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
844 | 886 |
845 // Complete all remaining texture updates. | 887 // Complete all remaining texture updates. |
846 current_resource_update_controller_on_impl_thread_->Finalize(); | 888 current_resource_update_controller_on_impl_thread_->Finalize(); |
847 current_resource_update_controller_on_impl_thread_.reset(); | 889 current_resource_update_controller_on_impl_thread_.reset(); |
848 | 890 |
849 layer_tree_host_impl_->BeginCommit(); | 891 layer_tree_host_impl_->BeginCommit(); |
850 layer_tree_host_->BeginCommitOnImplThread(layer_tree_host_impl_.get()); | 892 layer_tree_host_->BeginCommitOnImplThread(layer_tree_host_impl_.get()); |
851 layer_tree_host_->FinishCommitOnImplThread(layer_tree_host_impl_.get()); | 893 layer_tree_host_->FinishCommitOnImplThread(layer_tree_host_impl_.get()); |
852 layer_tree_host_impl_->CommitComplete(); | 894 layer_tree_host_impl_->CommitComplete(); |
853 | 895 |
854 layer_tree_host_impl_->UpdateBackgroundAnimateTicking( | |
855 !scheduler_on_impl_thread_->WillDrawIfNeeded()); | |
856 | |
857 next_frame_is_newly_committed_frame_on_impl_thread_ = true; | 896 next_frame_is_newly_committed_frame_on_impl_thread_ = true; |
858 | 897 |
859 if (layer_tree_host_->settings().impl_side_painting && | 898 if (layer_tree_host_->settings().impl_side_painting && |
860 layer_tree_host_->BlocksPendingCommit() && | 899 layer_tree_host_->BlocksPendingCommit() && |
861 layer_tree_host_impl_->pending_tree()) { | 900 layer_tree_host_impl_->pending_tree()) { |
862 // For some layer types in impl-side painting, the commit is held until | 901 // For some layer types in impl-side painting, the commit is held until |
863 // the pending tree is activated. It's also possible that the | 902 // the pending tree is activated. It's also possible that the |
864 // pending tree has already activated if there was no work to be done. | 903 // pending tree has already activated if there was no work to be done. |
865 TRACE_EVENT_INSTANT0("cc", "HoldCommit", TRACE_EVENT_SCOPE_THREAD); | 904 TRACE_EVENT_INSTANT0("cc", "HoldCommit", TRACE_EVENT_SCOPE_THREAD); |
866 completion_event_for_commit_held_on_tree_activation_ = | 905 completion_event_for_commit_held_on_tree_activation_ = |
867 commit_completion_event_on_impl_thread_; | 906 commit_completion_event_on_impl_thread_; |
868 commit_completion_event_on_impl_thread_ = NULL; | 907 commit_completion_event_on_impl_thread_ = NULL; |
869 } else { | 908 } else { |
870 commit_completion_event_on_impl_thread_->Signal(); | 909 commit_completion_event_on_impl_thread_->Signal(); |
871 commit_completion_event_on_impl_thread_ = NULL; | 910 commit_completion_event_on_impl_thread_ = NULL; |
872 } | 911 } |
873 | 912 |
913 // The commit may have added animations, requiring us to start | |
914 // background ticking. | |
915 layer_tree_host_impl_->UpdateBackgroundAnimateTicking( | |
916 !scheduler_on_impl_thread_->WillDrawIfNeeded()); | |
874 // SetVisible kicks off the next scheduler action, so this must be last. | 917 // SetVisible kicks off the next scheduler action, so this must be last. |
875 scheduler_on_impl_thread_->SetVisible(layer_tree_host_impl_->visible()); | 918 scheduler_on_impl_thread_->SetVisible(layer_tree_host_impl_->visible()); |
876 } | 919 } |
877 | 920 |
878 void ThreadProxy::ScheduledActionCheckForCompletedTileUploads() { | 921 void ThreadProxy::ScheduledActionCheckForCompletedTileUploads() { |
879 DCHECK(IsImplThread()); | 922 DCHECK(IsImplThread()); |
880 TRACE_EVENT0("cc", | 923 TRACE_EVENT0("cc", |
881 "ThreadProxy::ScheduledActionCheckForCompletedTileUploads"); | 924 "ThreadProxy::ScheduledActionCheckForCompletedTileUploads"); |
882 layer_tree_host_impl_->CheckForCompletedTileUploads(); | 925 layer_tree_host_impl_->CheckForCompletedTileUploads(); |
883 } | 926 } |
(...skipping 21 matching lines...) Expand all Loading... | |
905 result.did_swap = false; | 948 result.did_swap = false; |
906 DCHECK(IsImplThread()); | 949 DCHECK(IsImplThread()); |
907 DCHECK(layer_tree_host_impl_.get()); | 950 DCHECK(layer_tree_host_impl_.get()); |
908 if (!layer_tree_host_impl_) | 951 if (!layer_tree_host_impl_) |
909 return result; | 952 return result; |
910 | 953 |
911 DCHECK(layer_tree_host_impl_->renderer()); | 954 DCHECK(layer_tree_host_impl_->renderer()); |
912 if (!layer_tree_host_impl_->renderer()) | 955 if (!layer_tree_host_impl_->renderer()) |
913 return result; | 956 return result; |
914 | 957 |
915 base::TimeTicks monotonic_time = | |
916 layer_tree_host_impl_->CurrentFrameTimeTicks(); | |
917 base::Time wall_clock_time = layer_tree_host_impl_->CurrentFrameTime(); | |
918 | |
919 // TODO(enne): This should probably happen post-animate. | |
920 if (layer_tree_host_impl_->pending_tree()) { | |
921 layer_tree_host_impl_->ActivatePendingTreeIfNeeded(); | |
922 if (layer_tree_host_impl_->pending_tree()) | |
923 layer_tree_host_impl_->pending_tree()->UpdateDrawProperties(); | |
924 } | |
925 layer_tree_host_impl_->Animate(monotonic_time, wall_clock_time); | |
926 layer_tree_host_impl_->UpdateBackgroundAnimateTicking(false); | |
927 | |
928 base::TimeTicks start_time = base::TimeTicks::HighResNow(); | 958 base::TimeTicks start_time = base::TimeTicks::HighResNow(); |
929 base::TimeDelta draw_duration_estimate = DrawDurationEstimate(); | 959 base::TimeDelta draw_duration_estimate = DrawDurationEstimate(); |
930 base::AutoReset<bool> mark_inside(&inside_draw_, true); | 960 base::AutoReset<bool> mark_inside(&inside_draw_, true); |
931 | 961 |
932 // This method is called on a forced draw, regardless of whether we are able | 962 // This method is called on a forced draw, regardless of whether we are able |
933 // to produce a frame, as the calling site on main thread is blocked until its | 963 // to produce a frame, as the calling site on main thread is blocked until its |
934 // request completes, and we signal completion here. If CanDraw() is false, we | 964 // request completes, and we signal completion here. If CanDraw() is false, we |
935 // will indicate success=false to the caller, but we must still signal | 965 // will indicate success=false to the caller, but we must still signal |
936 // completion to avoid deadlock. | 966 // completion to avoid deadlock. |
937 | 967 |
938 // We guard PrepareToDraw() with CanDraw() because it always returns a valid | 968 // We guard PrepareToDraw() with CanDraw() because it always returns a valid |
939 // frame, so can only be used when such a frame is possible. Since | 969 // frame, so can only be used when such a frame is possible. Since |
940 // DrawLayers() depends on the result of PrepareToDraw(), it is guarded on | 970 // DrawLayers() depends on the result of PrepareToDraw(), it is guarded on |
941 // CanDraw() as well. | 971 // CanDraw() as well. |
942 | 972 |
943 bool drawing_for_readback = !!readback_request_on_impl_thread_; | 973 bool drawing_for_readback = !!readback_request_on_impl_thread_; |
944 bool can_do_readback = layer_tree_host_impl_->renderer()->CanReadPixels(); | 974 bool can_do_readback = layer_tree_host_impl_->renderer()->CanReadPixels(); |
945 | 975 |
946 LayerTreeHostImpl::FrameData frame; | 976 LayerTreeHostImpl::FrameData frame; |
947 bool draw_frame = false; | 977 bool draw_frame = false; |
948 bool start_ready_animations = true; | |
949 | 978 |
950 if (layer_tree_host_impl_->CanDraw() && | 979 if (layer_tree_host_impl_->CanDraw() && |
951 (!drawing_for_readback || can_do_readback)) { | 980 (!drawing_for_readback || can_do_readback)) { |
952 // If it is for a readback, make sure we draw the portion being read back. | 981 // If it is for a readback, make sure we draw the portion being read back. |
953 gfx::Rect readback_rect; | 982 gfx::Rect readback_rect; |
954 if (drawing_for_readback) | 983 if (drawing_for_readback) |
955 readback_rect = readback_request_on_impl_thread_->rect; | 984 readback_rect = readback_request_on_impl_thread_->rect; |
956 | 985 |
957 // Do not start animations if we skip drawing the frame to avoid | 986 // Do not start animations if we skip drawing the frame to avoid |
958 // checkerboarding. | 987 // checkerboarding. |
959 if (layer_tree_host_impl_->PrepareToDraw(&frame, readback_rect) || | 988 if (layer_tree_host_impl_->PrepareToDraw(&frame, readback_rect) || |
960 forced_draw) | 989 forced_draw) |
961 draw_frame = true; | 990 draw_frame = true; |
962 else | |
963 start_ready_animations = false; | |
964 } | 991 } |
965 | 992 |
993 frame_did_draw_ = draw_frame; | |
994 | |
966 if (draw_frame) { | 995 if (draw_frame) { |
967 layer_tree_host_impl_->DrawLayers( | 996 layer_tree_host_impl_->DrawLayers( |
968 &frame, | 997 &frame, |
969 scheduler_on_impl_thread_->LastBeginFrameOnImplThreadTime()); | 998 scheduler_on_impl_thread_->LastBeginFrameOnImplThreadTime()); |
970 result.did_draw = true; | 999 result.did_draw = true; |
971 } | 1000 } |
972 layer_tree_host_impl_->DidDrawAllLayers(frame); | 1001 layer_tree_host_impl_->DidDrawAllLayers(frame); |
973 | 1002 |
974 layer_tree_host_impl_->UpdateAnimationState(start_ready_animations); | |
975 | |
976 // Check for a pending CompositeAndReadback. | 1003 // Check for a pending CompositeAndReadback. |
977 if (readback_request_on_impl_thread_) { | 1004 if (readback_request_on_impl_thread_) { |
978 readback_request_on_impl_thread_->success = false; | 1005 readback_request_on_impl_thread_->success = false; |
979 if (draw_frame) { | 1006 if (draw_frame) { |
980 layer_tree_host_impl_->Readback(readback_request_on_impl_thread_->pixels, | 1007 layer_tree_host_impl_->Readback(readback_request_on_impl_thread_->pixels, |
981 readback_request_on_impl_thread_->rect); | 1008 readback_request_on_impl_thread_->rect); |
982 readback_request_on_impl_thread_->success = | 1009 readback_request_on_impl_thread_->success = |
983 !layer_tree_host_impl_->IsContextLost(); | 1010 !layer_tree_host_impl_->IsContextLost(); |
984 } | 1011 } |
985 readback_request_on_impl_thread_->completion.Signal(); | 1012 readback_request_on_impl_thread_->completion.Signal(); |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1083 | 1110 |
1084 ScheduledActionDrawAndSwapResult | 1111 ScheduledActionDrawAndSwapResult |
1085 ThreadProxy::ScheduledActionDrawAndSwapForced() { | 1112 ThreadProxy::ScheduledActionDrawAndSwapForced() { |
1086 return ScheduledActionDrawAndSwapInternal(true); | 1113 return ScheduledActionDrawAndSwapInternal(true); |
1087 } | 1114 } |
1088 | 1115 |
1089 void ThreadProxy::DidAnticipatedDrawTimeChange(base::TimeTicks time) { | 1116 void ThreadProxy::DidAnticipatedDrawTimeChange(base::TimeTicks time) { |
1090 if (current_resource_update_controller_on_impl_thread_) | 1117 if (current_resource_update_controller_on_impl_thread_) |
1091 current_resource_update_controller_on_impl_thread_ | 1118 current_resource_update_controller_on_impl_thread_ |
1092 ->PerformMoreUpdates(time); | 1119 ->PerformMoreUpdates(time); |
1093 layer_tree_host_impl_->ResetCurrentFrameTimeForNextFrame(); | |
1094 } | 1120 } |
1095 | 1121 |
1096 base::TimeDelta ThreadProxy::DrawDurationEstimate() { | 1122 base::TimeDelta ThreadProxy::DrawDurationEstimate() { |
1097 base::TimeDelta historical_estimate = | 1123 base::TimeDelta historical_estimate = |
1098 draw_duration_history_.Percentile(kDrawDurationEstimationPercentile); | 1124 draw_duration_history_.Percentile(kDrawDurationEstimationPercentile); |
1099 base::TimeDelta padding = base::TimeDelta::FromMicroseconds( | 1125 base::TimeDelta padding = base::TimeDelta::FromMicroseconds( |
1100 kDrawDurationEstimatePaddingInMicroseconds); | 1126 kDrawDurationEstimatePaddingInMicroseconds); |
1101 return historical_estimate + padding; | 1127 return historical_estimate + padding; |
1102 } | 1128 } |
1103 | 1129 |
1130 void ThreadProxy::PostBeginFrameDeadline(const base::Closure &closure, | |
1131 base::TimeTicks deadline) { | |
1132 base::TimeDelta delta = deadline - base::TimeTicks::Now(); | |
1133 if (delta <= base::TimeDelta()) | |
1134 delta = base::TimeDelta(); | |
1135 Proxy::ImplThreadTaskRunner()->PostDelayedTask(FROM_HERE, closure, delta); | |
1136 } | |
1137 | |
1104 void ThreadProxy::ReadyToFinalizeTextureUpdates() { | 1138 void ThreadProxy::ReadyToFinalizeTextureUpdates() { |
1105 DCHECK(IsImplThread()); | 1139 DCHECK(IsImplThread()); |
1106 scheduler_on_impl_thread_->FinishCommit(); | 1140 scheduler_on_impl_thread_->FinishCommit(); |
1107 } | 1141 } |
1108 | 1142 |
1109 void ThreadProxy::DidCommitAndDrawFrame() { | 1143 void ThreadProxy::DidCommitAndDrawFrame() { |
1110 DCHECK(IsMainThread()); | 1144 DCHECK(IsMainThread()); |
1111 if (!layer_tree_host_) | 1145 if (!layer_tree_host_) |
1112 return; | 1146 return; |
1113 layer_tree_host_->DidCommitAndDrawFrame(); | 1147 layer_tree_host_->DidCommitAndDrawFrame(); |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1439 !layer_tree_host_impl_->pending_tree()) { | 1473 !layer_tree_host_impl_->pending_tree()) { |
1440 TRACE_EVENT_INSTANT0("cc", "ReleaseCommitbyActivation", | 1474 TRACE_EVENT_INSTANT0("cc", "ReleaseCommitbyActivation", |
1441 TRACE_EVENT_SCOPE_THREAD); | 1475 TRACE_EVENT_SCOPE_THREAD); |
1442 DCHECK(layer_tree_host_impl_->settings().impl_side_painting); | 1476 DCHECK(layer_tree_host_impl_->settings().impl_side_painting); |
1443 completion_event_for_commit_held_on_tree_activation_->Signal(); | 1477 completion_event_for_commit_held_on_tree_activation_->Signal(); |
1444 completion_event_for_commit_held_on_tree_activation_ = NULL; | 1478 completion_event_for_commit_held_on_tree_activation_ = NULL; |
1445 } | 1479 } |
1446 } | 1480 } |
1447 | 1481 |
1448 } // namespace cc | 1482 } // namespace cc |
OLD | NEW |