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

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

Issue 16871016: cc: Use BeginFrameArgs (Closed) Base URL: http://git.chromium.org/chromium/src.git@bfargs2
Patch Set: fix some tests; needs rebase; Created 7 years, 5 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
« cc/scheduler/scheduler.cc ('K') | « 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 previous_frame_had_checkerboard_(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
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);
375 if (!enable)
376 previous_frame_had_checkerboard_ = false;
373 } 377 }
374 378
375 void ThreadProxy::BeginFrameOnImplThread(const BeginFrameArgs& args) { 379 void ThreadProxy::BeginFrameOnImplThread(const BeginFrameArgs& args) {
376 DCHECK(IsImplThread()); 380 DCHECK(IsImplThread());
377 TRACE_EVENT0("cc", "ThreadProxy::BeginFrameOnImplThread"); 381 TRACE_EVENT0("cc", "ThreadProxy::BeginFrameOnImplThread");
382
383 base::TimeTicks monotonic_time =
384 layer_tree_host_impl_->CurrentFrameTimeTicks();
385 base::Time wall_clock_time = layer_tree_host_impl_->CurrentFrameTime();
386 if (!previous_frame_had_checkerboard_)
387 layer_tree_host_impl_->Animate(monotonic_time, wall_clock_time);
388
378 scheduler_on_impl_thread_->BeginFrame(args); 389 scheduler_on_impl_thread_->BeginFrame(args);
379 } 390 }
380 391
392 void ThreadProxy::DidFinishBeginFrameOnImplThread() {
393 layer_tree_host_impl_->ResetCurrentFrameTimeForNextFrame();
394 layer_tree_host_impl_->UpdateAnimationState(
395 !previous_frame_had_checkerboard_);
396 }
397
381 void ThreadProxy::OnCanDrawStateChanged(bool can_draw) { 398 void ThreadProxy::OnCanDrawStateChanged(bool can_draw) {
382 DCHECK(IsImplThread()); 399 DCHECK(IsImplThread());
383 TRACE_EVENT1( 400 TRACE_EVENT1(
384 "cc", "ThreadProxy::OnCanDrawStateChanged", "can_draw", can_draw); 401 "cc", "ThreadProxy::OnCanDrawStateChanged", "can_draw", can_draw);
385 scheduler_on_impl_thread_->SetCanDraw(can_draw); 402 scheduler_on_impl_thread_->SetCanDraw(can_draw);
386 layer_tree_host_impl_->UpdateBackgroundAnimateTicking( 403 // layer_tree_host_impl_->UpdateBackgroundAnimateTicking(
387 !scheduler_on_impl_thread_->WillDrawIfNeeded()); 404 // !scheduler_on_impl_thread_->WillDrawIfNeeded());
388 } 405 }
389 406
390 void ThreadProxy::OnHasPendingTreeStateChanged(bool has_pending_tree) { 407 void ThreadProxy::OnHasPendingTreeStateChanged(bool has_pending_tree) {
391 DCHECK(IsImplThread()); 408 DCHECK(IsImplThread());
392 TRACE_EVENT1("cc", "ThreadProxy::OnHasPendingTreeStateChanged", 409 TRACE_EVENT1("cc", "ThreadProxy::OnHasPendingTreeStateChanged",
393 "has_pending_tree", has_pending_tree); 410 "has_pending_tree", has_pending_tree);
394 scheduler_on_impl_thread_->SetHasPendingTree(has_pending_tree); 411 scheduler_on_impl_thread_->SetHasTrees(
412 has_pending_tree,
413 layer_tree_host_impl_->active_tree() ?
414 !layer_tree_host_impl_->active_tree()->root_layer() : true);
415
416 if (!has_pending_tree && !deffered_start_commit_on_impl_thread_.is_null()) {
417 Proxy::ImplThreadTaskRunner()->PostTask(
418 FROM_HERE,
419 deffered_start_commit_on_impl_thread_);
420 deffered_start_commit_on_impl_thread_.Reset();
421 }
395 } 422 }
396 423
397 void ThreadProxy::SetNeedsCommitOnImplThread() { 424 void ThreadProxy::SetNeedsCommitOnImplThread() {
398 DCHECK(IsImplThread()); 425 DCHECK(IsImplThread());
399 TRACE_EVENT0("cc", "ThreadProxy::SetNeedsCommitOnImplThread"); 426 TRACE_EVENT0("cc", "ThreadProxy::SetNeedsCommitOnImplThread");
400 scheduler_on_impl_thread_->SetNeedsCommit(); 427 scheduler_on_impl_thread_->SetNeedsCommit();
401 } 428 }
402 429
403 void ThreadProxy::PostAnimationEventsToMainThreadOnImplThread( 430 void ThreadProxy::PostAnimationEventsToMainThreadOnImplThread(
404 scoped_ptr<AnimationEventsVector> events, 431 scoped_ptr<AnimationEventsVector> events,
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 TRACE_EVENT0("cc", "ThreadProxy::FinishAllRenderingOnImplThread"); 647 TRACE_EVENT0("cc", "ThreadProxy::FinishAllRenderingOnImplThread");
621 DCHECK(IsImplThread()); 648 DCHECK(IsImplThread());
622 layer_tree_host_impl_->FinishAllRendering(); 649 layer_tree_host_impl_->FinishAllRendering();
623 completion->Signal(); 650 completion->Signal();
624 } 651 }
625 652
626 void ThreadProxy::ScheduledActionSendBeginFrameToMainThread() { 653 void ThreadProxy::ScheduledActionSendBeginFrameToMainThread() {
627 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionSendBeginFrameToMainThread"); 654 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionSendBeginFrameToMainThread");
628 scoped_ptr<BeginFrameAndCommitState> begin_frame_state( 655 scoped_ptr<BeginFrameAndCommitState> begin_frame_state(
629 new BeginFrameAndCommitState); 656 new BeginFrameAndCommitState);
657
630 begin_frame_state->monotonic_frame_begin_time = 658 begin_frame_state->monotonic_frame_begin_time =
631 layer_tree_host_impl_->CurrentPhysicalTimeTicks(); 659 layer_tree_host_impl_->CurrentPhysicalTimeTicks();
632 begin_frame_state->scroll_info = 660 begin_frame_state->scroll_info =
633 layer_tree_host_impl_->ProcessScrollDeltas(); 661 layer_tree_host_impl_->ProcessScrollDeltas();
634 662
635 if (!layer_tree_host_impl_->settings().impl_side_painting) { 663 if (!layer_tree_host_impl_->settings().impl_side_painting) {
636 DCHECK_GT(layer_tree_host_impl_->memory_allocation_limit_bytes(), 0u); 664 DCHECK_GT(layer_tree_host_impl_->memory_allocation_limit_bytes(), 0u);
637 } 665 }
666
667
638 begin_frame_state->memory_allocation_limit_bytes = 668 begin_frame_state->memory_allocation_limit_bytes =
639 layer_tree_host_impl_->memory_allocation_limit_bytes(); 669 layer_tree_host_impl_->memory_allocation_limit_bytes();
640 Proxy::MainThreadTaskRunner()->PostTask( 670 Proxy::MainThreadTaskRunner()->PostTask(
641 FROM_HERE, 671 FROM_HERE,
642 base::Bind(&ThreadProxy::BeginFrameOnMainThread, 672 base::Bind(&ThreadProxy::BeginFrameOnMainThread,
643 main_thread_weak_ptr_, 673 main_thread_weak_ptr_,
644 base::Passed(&begin_frame_state))); 674 base::Passed(&begin_frame_state)));
645 675
646 if (begin_frame_sent_to_main_thread_completion_event_on_impl_thread_) { 676 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(); 677 begin_frame_sent_to_main_thread_completion_event_on_impl_thread_->Signal();
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
775 } 805 }
776 806
777 layer_tree_host_->CommitComplete(); 807 layer_tree_host_->CommitComplete();
778 layer_tree_host_->DidBeginFrame(); 808 layer_tree_host_->DidBeginFrame();
779 } 809 }
780 810
781 void ThreadProxy::StartCommitOnImplThread( 811 void ThreadProxy::StartCommitOnImplThread(
782 CompletionEvent* completion, 812 CompletionEvent* completion,
783 ResourceUpdateQueue* raw_queue, 813 ResourceUpdateQueue* raw_queue,
784 scoped_refptr<cc::ContextProvider> offscreen_context_provider) { 814 scoped_refptr<cc::ContextProvider> offscreen_context_provider) {
785 scoped_ptr<ResourceUpdateQueue> queue(raw_queue);
786
787 TRACE_EVENT0("cc", "ThreadProxy::StartCommitOnImplThread"); 815 TRACE_EVENT0("cc", "ThreadProxy::StartCommitOnImplThread");
788 DCHECK(!commit_completion_event_on_impl_thread_); 816 DCHECK(!commit_completion_event_on_impl_thread_);
789 DCHECK(IsImplThread() && IsMainThreadBlocked()); 817 DCHECK(IsImplThread() && IsMainThreadBlocked());
790 DCHECK(scheduler_on_impl_thread_); 818 DCHECK(scheduler_on_impl_thread_);
791 DCHECK(scheduler_on_impl_thread_->CommitPending()); 819 DCHECK(scheduler_on_impl_thread_->CommitPending());
792 820
793 if (!layer_tree_host_impl_) { 821 if (!layer_tree_host_impl_) {
794 TRACE_EVENT0("cc", "EarlyOut_NoLayerTree"); 822 TRACE_EVENT0("cc", "EarlyOut_NoLayerTree");
795 completion->Signal(); 823 completion->Signal();
824
796 return; 825 return;
797 } 826 }
798 827
828 // TODO(brianderson): We really shouldn't need this hack.
829 // It's here to fix LayerTreeHostAnimationTestCompositeAndReadbackAnimateCount
830 // It would be an easy way to initiate commits on the main thread before
831 // the pending tree is free though =)
832 if (layer_tree_host_impl_->pending_tree()) {
833 DCHECK(deffered_start_commit_on_impl_thread_.is_null());
834 deffered_start_commit_on_impl_thread_ =
835 base::Bind(&ThreadProxy::StartCommitOnImplThread,
836 impl_thread_weak_ptr_,
837 completion,
838 raw_queue,
839 offscreen_context_provider);
840 return;
841 }
842
843 scoped_ptr<ResourceUpdateQueue> queue(raw_queue);
844
799 if (offscreen_context_provider.get()) 845 if (offscreen_context_provider.get())
800 offscreen_context_provider->BindToCurrentThread(); 846 offscreen_context_provider->BindToCurrentThread();
801 layer_tree_host_impl_->resource_provider()-> 847 layer_tree_host_impl_->resource_provider()->
802 set_offscreen_context_provider(offscreen_context_provider); 848 set_offscreen_context_provider(offscreen_context_provider);
803 849
804 if (layer_tree_host_->contents_texture_manager()) { 850 if (layer_tree_host_->contents_texture_manager()) {
805 if (layer_tree_host_->contents_texture_manager()-> 851 if (layer_tree_host_->contents_texture_manager()->
806 LinkedEvictedBackingsExist()) { 852 LinkedEvictedBackingsExist()) {
807 // Clear any uploads we were making to textures linked to evicted 853 // Clear any uploads we were making to textures linked to evicted
808 // resources 854 // resources
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
844 890
845 // Complete all remaining texture updates. 891 // Complete all remaining texture updates.
846 current_resource_update_controller_on_impl_thread_->Finalize(); 892 current_resource_update_controller_on_impl_thread_->Finalize();
847 current_resource_update_controller_on_impl_thread_.reset(); 893 current_resource_update_controller_on_impl_thread_.reset();
848 894
849 layer_tree_host_impl_->BeginCommit(); 895 layer_tree_host_impl_->BeginCommit();
850 layer_tree_host_->BeginCommitOnImplThread(layer_tree_host_impl_.get()); 896 layer_tree_host_->BeginCommitOnImplThread(layer_tree_host_impl_.get());
851 layer_tree_host_->FinishCommitOnImplThread(layer_tree_host_impl_.get()); 897 layer_tree_host_->FinishCommitOnImplThread(layer_tree_host_impl_.get());
852 layer_tree_host_impl_->CommitComplete(); 898 layer_tree_host_impl_->CommitComplete();
853 899
854 layer_tree_host_impl_->UpdateBackgroundAnimateTicking(
855 !scheduler_on_impl_thread_->WillDrawIfNeeded());
856
857 next_frame_is_newly_committed_frame_on_impl_thread_ = true; 900 next_frame_is_newly_committed_frame_on_impl_thread_ = true;
858 901
859 if (layer_tree_host_->settings().impl_side_painting && 902 if (layer_tree_host_->settings().impl_side_painting &&
860 layer_tree_host_->BlocksPendingCommit() && 903 layer_tree_host_->BlocksPendingCommit() &&
861 layer_tree_host_impl_->pending_tree()) { 904 layer_tree_host_impl_->pending_tree()) {
862 // For some layer types in impl-side painting, the commit is held until 905 // 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 906 // 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. 907 // pending tree has already activated if there was no work to be done.
865 TRACE_EVENT_INSTANT0("cc", "HoldCommit", TRACE_EVENT_SCOPE_THREAD); 908 TRACE_EVENT_INSTANT0("cc", "HoldCommit", TRACE_EVENT_SCOPE_THREAD);
866 completion_event_for_commit_held_on_tree_activation_ = 909 completion_event_for_commit_held_on_tree_activation_ =
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
958 /*
915 base::TimeTicks monotonic_time = 959 base::TimeTicks monotonic_time =
916 layer_tree_host_impl_->CurrentFrameTimeTicks(); 960 layer_tree_host_impl_->CurrentFrameTimeTicks();
917 base::Time wall_clock_time = layer_tree_host_impl_->CurrentFrameTime(); 961 base::Time wall_clock_time = layer_tree_host_impl_->CurrentFrameTime();
918 962
919 // TODO(enne): This should probably happen post-animate.
920 if (layer_tree_host_impl_->pending_tree()) { 963 if (layer_tree_host_impl_->pending_tree()) {
921 layer_tree_host_impl_->ActivatePendingTreeIfNeeded(); 964 layer_tree_host_impl_->ActivatePendingTreeIfNeeded();
922 if (layer_tree_host_impl_->pending_tree()) 965 if (layer_tree_host_impl_->pending_tree())
923 layer_tree_host_impl_->pending_tree()->UpdateDrawProperties(); 966 layer_tree_host_impl_->pending_tree()->UpdateDrawProperties();
924 } 967 }
968
925 layer_tree_host_impl_->Animate(monotonic_time, wall_clock_time); 969 layer_tree_host_impl_->Animate(monotonic_time, wall_clock_time);
926 layer_tree_host_impl_->UpdateBackgroundAnimateTicking(false); 970 layer_tree_host_impl_->UpdateBackgroundAnimateTicking(false);
971 */
927 972
928 base::TimeTicks start_time = base::TimeTicks::HighResNow(); 973 base::TimeTicks start_time = base::TimeTicks::HighResNow();
929 base::TimeDelta draw_duration_estimate = DrawDurationEstimate(); 974 base::TimeDelta draw_duration_estimate = DrawDurationEstimate();
930 base::AutoReset<bool> mark_inside(&inside_draw_, true); 975 base::AutoReset<bool> mark_inside(&inside_draw_, true);
931 976
932 // This method is called on a forced draw, regardless of whether we are able 977 // 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 978 // 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 979 // 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 980 // will indicate success=false to the caller, but we must still signal
936 // completion to avoid deadlock. 981 // completion to avoid deadlock.
937 982
938 // We guard PrepareToDraw() with CanDraw() because it always returns a valid 983 // 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 984 // 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 985 // DrawLayers() depends on the result of PrepareToDraw(), it is guarded on
941 // CanDraw() as well. 986 // CanDraw() as well.
942 987
943 bool drawing_for_readback = !!readback_request_on_impl_thread_; 988 bool drawing_for_readback = !!readback_request_on_impl_thread_;
944 bool can_do_readback = layer_tree_host_impl_->renderer()->CanReadPixels(); 989 bool can_do_readback = layer_tree_host_impl_->renderer()->CanReadPixels();
945 990
946 LayerTreeHostImpl::FrameData frame; 991 LayerTreeHostImpl::FrameData frame;
947 bool draw_frame = false; 992 bool draw_frame = false;
948 bool start_ready_animations = true; 993 // bool start_ready_animations = true;
949 994
950 if (layer_tree_host_impl_->CanDraw() && 995 if (layer_tree_host_impl_->CanDraw() &&
951 (!drawing_for_readback || can_do_readback)) { 996 (!drawing_for_readback || can_do_readback)) {
952 // If it is for a readback, make sure we draw the portion being read back. 997 // If it is for a readback, make sure we draw the portion being read back.
953 gfx::Rect readback_rect; 998 gfx::Rect readback_rect;
954 if (drawing_for_readback) 999 if (drawing_for_readback)
955 readback_rect = readback_request_on_impl_thread_->rect; 1000 readback_rect = readback_request_on_impl_thread_->rect;
956 1001
957 // Do not start animations if we skip drawing the frame to avoid 1002 // Do not start animations if we skip drawing the frame to avoid
958 // checkerboarding. 1003 // checkerboarding.
959 if (layer_tree_host_impl_->PrepareToDraw(&frame, readback_rect) || 1004 if (layer_tree_host_impl_->PrepareToDraw(&frame, readback_rect) ||
960 forced_draw) 1005 forced_draw)
961 draw_frame = true; 1006 draw_frame = true;
962 else 1007 // else
963 start_ready_animations = false; 1008 // start_ready_animations = false;
964 } 1009 }
965 1010
1011 previous_frame_had_checkerboard_ = !draw_frame;
1012
966 if (draw_frame) { 1013 if (draw_frame) {
967 layer_tree_host_impl_->DrawLayers( 1014 layer_tree_host_impl_->DrawLayers(
968 &frame, 1015 &frame,
969 scheduler_on_impl_thread_->LastBeginFrameOnImplThreadTime()); 1016 scheduler_on_impl_thread_->LastBeginFrameOnImplThreadTime());
970 result.did_draw = true; 1017 result.did_draw = true;
971 } 1018 }
972 layer_tree_host_impl_->DidDrawAllLayers(frame); 1019 layer_tree_host_impl_->DidDrawAllLayers(frame);
973 1020
974 layer_tree_host_impl_->UpdateAnimationState(start_ready_animations);
975
976 // Check for a pending CompositeAndReadback. 1021 // Check for a pending CompositeAndReadback.
977 if (readback_request_on_impl_thread_) { 1022 if (readback_request_on_impl_thread_) {
978 readback_request_on_impl_thread_->success = false; 1023 readback_request_on_impl_thread_->success = false;
979 if (draw_frame) { 1024 if (draw_frame) {
980 layer_tree_host_impl_->Readback(readback_request_on_impl_thread_->pixels, 1025 layer_tree_host_impl_->Readback(readback_request_on_impl_thread_->pixels,
981 readback_request_on_impl_thread_->rect); 1026 readback_request_on_impl_thread_->rect);
982 readback_request_on_impl_thread_->success = 1027 readback_request_on_impl_thread_->success =
983 !layer_tree_host_impl_->IsContextLost(); 1028 !layer_tree_host_impl_->IsContextLost();
984 } 1029 }
985 readback_request_on_impl_thread_->completion.Signal(); 1030 readback_request_on_impl_thread_->completion.Signal();
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
1083 1128
1084 ScheduledActionDrawAndSwapResult 1129 ScheduledActionDrawAndSwapResult
1085 ThreadProxy::ScheduledActionDrawAndSwapForced() { 1130 ThreadProxy::ScheduledActionDrawAndSwapForced() {
1086 return ScheduledActionDrawAndSwapInternal(true); 1131 return ScheduledActionDrawAndSwapInternal(true);
1087 } 1132 }
1088 1133
1089 void ThreadProxy::DidAnticipatedDrawTimeChange(base::TimeTicks time) { 1134 void ThreadProxy::DidAnticipatedDrawTimeChange(base::TimeTicks time) {
1090 if (current_resource_update_controller_on_impl_thread_) 1135 if (current_resource_update_controller_on_impl_thread_)
1091 current_resource_update_controller_on_impl_thread_ 1136 current_resource_update_controller_on_impl_thread_
1092 ->PerformMoreUpdates(time); 1137 ->PerformMoreUpdates(time);
1093 layer_tree_host_impl_->ResetCurrentFrameTimeForNextFrame();
1094 } 1138 }
1095 1139
1096 base::TimeDelta ThreadProxy::DrawDurationEstimate() { 1140 base::TimeDelta ThreadProxy::DrawDurationEstimate() {
1097 base::TimeDelta historical_estimate = 1141 base::TimeDelta historical_estimate =
1098 draw_duration_history_.Percentile(kDrawDurationEstimationPercentile); 1142 draw_duration_history_.Percentile(kDrawDurationEstimationPercentile);
1099 base::TimeDelta padding = base::TimeDelta::FromMicroseconds( 1143 base::TimeDelta padding = base::TimeDelta::FromMicroseconds(
1100 kDrawDurationEstimatePaddingInMicroseconds); 1144 kDrawDurationEstimatePaddingInMicroseconds);
1101 return historical_estimate + padding; 1145 return historical_estimate + padding;
1102 } 1146 }
1103 1147
1148 void ThreadProxy::PostBeginFrameDeadline(const base::Closure &closure,
1149 base::TimeTicks deadline) {
1150 base::TimeDelta delta = deadline - base::TimeTicks::Now();
1151 if (delta <= base::TimeDelta())
1152 delta = base::TimeDelta();
1153 Proxy::ImplThreadTaskRunner()->PostDelayedTask(FROM_HERE, closure, delta);
1154 }
1155
1104 void ThreadProxy::ReadyToFinalizeTextureUpdates() { 1156 void ThreadProxy::ReadyToFinalizeTextureUpdates() {
1105 DCHECK(IsImplThread()); 1157 DCHECK(IsImplThread());
1106 scheduler_on_impl_thread_->FinishCommit(); 1158 scheduler_on_impl_thread_->FinishCommit();
1107 } 1159 }
1108 1160
1109 void ThreadProxy::DidCommitAndDrawFrame() { 1161 void ThreadProxy::DidCommitAndDrawFrame() {
1110 DCHECK(IsMainThread()); 1162 DCHECK(IsMainThread());
1111 if (!layer_tree_host_) 1163 if (!layer_tree_host_)
1112 return; 1164 return;
1113 layer_tree_host_->DidCommitAndDrawFrame(); 1165 layer_tree_host_->DidCommitAndDrawFrame();
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
1437 !layer_tree_host_impl_->pending_tree()) { 1489 !layer_tree_host_impl_->pending_tree()) {
1438 TRACE_EVENT_INSTANT0("cc", "ReleaseCommitbyActivation", 1490 TRACE_EVENT_INSTANT0("cc", "ReleaseCommitbyActivation",
1439 TRACE_EVENT_SCOPE_THREAD); 1491 TRACE_EVENT_SCOPE_THREAD);
1440 DCHECK(layer_tree_host_impl_->settings().impl_side_painting); 1492 DCHECK(layer_tree_host_impl_->settings().impl_side_painting);
1441 completion_event_for_commit_held_on_tree_activation_->Signal(); 1493 completion_event_for_commit_held_on_tree_activation_->Signal();
1442 completion_event_for_commit_held_on_tree_activation_ = NULL; 1494 completion_event_for_commit_held_on_tree_activation_ = NULL;
1443 } 1495 }
1444 } 1496 }
1445 1497
1446 } // namespace cc 1498 } // namespace cc
OLDNEW
« cc/scheduler/scheduler.cc ('K') | « cc/trees/thread_proxy.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698