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

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

Issue 1194743002: cc: Remove ResourceUpdateQueue and ResourceUpdateController. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: resourcequeue: header Created 5 years, 6 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
« no previous file with comments | « cc/trees/thread_proxy.h ('k') | components/view_manager/surfaces/surfaces_scheduler.h » ('j') | 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 <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 747 matching lines...) Expand 10 before | Expand all | Expand 10 after
758 758
759 // Clear the commit flag after updating animations and layout here --- objects 759 // Clear the commit flag after updating animations and layout here --- objects
760 // that only layout when painted will trigger another SetNeedsCommit inside 760 // that only layout when painted will trigger another SetNeedsCommit inside
761 // UpdateLayers. 761 // UpdateLayers.
762 main().commit_requested = false; 762 main().commit_requested = false;
763 main().commit_request_sent_to_impl_thread = false; 763 main().commit_request_sent_to_impl_thread = false;
764 bool can_cancel_this_commit = 764 bool can_cancel_this_commit =
765 main().can_cancel_commit && !begin_main_frame_state->evicted_ui_resources; 765 main().can_cancel_commit && !begin_main_frame_state->evicted_ui_resources;
766 main().can_cancel_commit = true; 766 main().can_cancel_commit = true;
767 767
768 scoped_ptr<ResourceUpdateQueue> queue =
769 make_scoped_ptr(new ResourceUpdateQueue);
770
771 bool updated = layer_tree_host()->UpdateLayers(); 768 bool updated = layer_tree_host()->UpdateLayers();
772 769
773 layer_tree_host()->WillCommit(); 770 layer_tree_host()->WillCommit();
774 devtools_instrumentation::ScopedCommitTrace commit_task( 771 devtools_instrumentation::ScopedCommitTrace commit_task(
775 layer_tree_host()->id()); 772 layer_tree_host()->id());
776 773
777 // Before calling animate, we set main().animate_requested to false. If it is 774 // Before calling animate, we set main().animate_requested to false. If it is
778 // true now, it means SetNeedAnimate was called again, but during a state when 775 // true now, it means SetNeedAnimate was called again, but during a state when
779 // main().commit_request_sent_to_impl_thread = true. We need to force that 776 // main().commit_request_sent_to_impl_thread = true. We need to force that
780 // call to happen again now so that the commit request is sent to the impl 777 // call to happen again now so that the commit request is sent to the impl
(...skipping 30 matching lines...) Expand all
811 DebugScopedSetMainThreadBlocked main_thread_blocked(this); 808 DebugScopedSetMainThreadBlocked main_thread_blocked(this);
812 809
813 // This CapturePostTasks should be destroyed before CommitComplete() is 810 // This CapturePostTasks should be destroyed before CommitComplete() is
814 // called since that goes out to the embedder, and we want the embedder 811 // called since that goes out to the embedder, and we want the embedder
815 // to receive its callbacks before that. 812 // to receive its callbacks before that.
816 BlockingTaskRunner::CapturePostTasks blocked( 813 BlockingTaskRunner::CapturePostTasks blocked(
817 blocking_main_thread_task_runner()); 814 blocking_main_thread_task_runner());
818 815
819 CompletionEvent completion; 816 CompletionEvent completion;
820 Proxy::ImplThreadTaskRunner()->PostTask( 817 Proxy::ImplThreadTaskRunner()->PostTask(
821 FROM_HERE, 818 FROM_HERE, base::Bind(&ThreadProxy::StartCommitOnImplThread,
822 base::Bind(&ThreadProxy::StartCommitOnImplThread, 819 impl_thread_weak_ptr_, &completion));
823 impl_thread_weak_ptr_,
824 &completion,
825 queue.release()));
826 completion.Wait(); 820 completion.Wait();
827 } 821 }
828 822
829 layer_tree_host()->CommitComplete(); 823 layer_tree_host()->CommitComplete();
830 layer_tree_host()->DidBeginMainFrame(); 824 layer_tree_host()->DidBeginMainFrame();
831 } 825 }
832 826
833 void ThreadProxy::BeginMainFrameNotExpectedSoon() { 827 void ThreadProxy::BeginMainFrameNotExpectedSoon() {
834 TRACE_EVENT0("cc", "ThreadProxy::BeginMainFrameNotExpectedSoon"); 828 TRACE_EVENT0("cc", "ThreadProxy::BeginMainFrameNotExpectedSoon");
835 DCHECK(IsMainThread()); 829 DCHECK(IsMainThread());
836 layer_tree_host()->BeginMainFrameNotExpectedSoon(); 830 layer_tree_host()->BeginMainFrameNotExpectedSoon();
837 } 831 }
838 832
839 void ThreadProxy::StartCommitOnImplThread(CompletionEvent* completion, 833 void ThreadProxy::StartCommitOnImplThread(CompletionEvent* completion) {
840 ResourceUpdateQueue* raw_queue) {
841 TRACE_EVENT0("cc", "ThreadProxy::StartCommitOnImplThread"); 834 TRACE_EVENT0("cc", "ThreadProxy::StartCommitOnImplThread");
842 DCHECK(!impl().commit_completion_event); 835 DCHECK(!impl().commit_completion_event);
843 DCHECK(IsImplThread() && IsMainThreadBlocked()); 836 DCHECK(IsImplThread() && IsMainThreadBlocked());
844 DCHECK(impl().scheduler); 837 DCHECK(impl().scheduler);
845 DCHECK(impl().scheduler->CommitPending()); 838 DCHECK(impl().scheduler->CommitPending());
846 839
847 if (!impl().layer_tree_host_impl) { 840 if (!impl().layer_tree_host_impl) {
848 TRACE_EVENT_INSTANT0( 841 TRACE_EVENT_INSTANT0(
849 "cc", "EarlyOut_NoLayerTree", TRACE_EVENT_SCOPE_THREAD); 842 "cc", "EarlyOut_NoLayerTree", TRACE_EVENT_SCOPE_THREAD);
850 completion->Signal(); 843 completion->Signal();
851 return; 844 return;
852 } 845 }
853 846
854 // Ideally, we should inform to impl thread when BeginMainFrame is started. 847 // Ideally, we should inform to impl thread when BeginMainFrame is started.
855 // But, we can avoid a PostTask in here. 848 // But, we can avoid a PostTask in here.
856 impl().scheduler->NotifyBeginMainFrameStarted(); 849 impl().scheduler->NotifyBeginMainFrameStarted();
857
858 scoped_ptr<ResourceUpdateQueue> queue(raw_queue);
859
860 impl().commit_completion_event = completion; 850 impl().commit_completion_event = completion;
861 impl().current_resource_update_controller = ResourceUpdateController::Create( 851 impl().scheduler->NotifyReadyToCommit();
862 this,
863 Proxy::ImplThreadTaskRunner(),
864 queue.Pass(),
865 impl().layer_tree_host_impl->resource_provider());
866 impl().current_resource_update_controller->PerformMoreUpdates(
867 impl().scheduler->AnticipatedDrawTime());
868 } 852 }
869 853
870 void ThreadProxy::BeginMainFrameAbortedOnImplThread( 854 void ThreadProxy::BeginMainFrameAbortedOnImplThread(
871 CommitEarlyOutReason reason) { 855 CommitEarlyOutReason reason) {
872 TRACE_EVENT1("cc", "ThreadProxy::BeginMainFrameAbortedOnImplThread", "reason", 856 TRACE_EVENT1("cc", "ThreadProxy::BeginMainFrameAbortedOnImplThread", "reason",
873 CommitEarlyOutReasonToString(reason)); 857 CommitEarlyOutReasonToString(reason));
874 DCHECK(IsImplThread()); 858 DCHECK(IsImplThread());
875 DCHECK(impl().scheduler); 859 DCHECK(impl().scheduler);
876 DCHECK(impl().scheduler->CommitPending()); 860 DCHECK(impl().scheduler->CommitPending());
877 DCHECK(!impl().layer_tree_host_impl->pending_tree()); 861 DCHECK(!impl().layer_tree_host_impl->pending_tree());
(...skipping 27 matching lines...) Expand all
905 if (!impl().layer_tree_host_impl->AnimationsAreVisible()) { 889 if (!impl().layer_tree_host_impl->AnimationsAreVisible()) {
906 impl().layer_tree_host_impl->UpdateAnimationState(true); 890 impl().layer_tree_host_impl->UpdateAnimationState(true);
907 } 891 }
908 } 892 }
909 893
910 void ThreadProxy::ScheduledActionCommit() { 894 void ThreadProxy::ScheduledActionCommit() {
911 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionCommit"); 895 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionCommit");
912 DCHECK(IsImplThread()); 896 DCHECK(IsImplThread());
913 DCHECK(IsMainThreadBlocked()); 897 DCHECK(IsMainThreadBlocked());
914 DCHECK(impl().commit_completion_event); 898 DCHECK(impl().commit_completion_event);
915 DCHECK(impl().current_resource_update_controller);
916
917 // Complete all remaining texture updates.
918 impl().current_resource_update_controller->Finalize();
919 impl().current_resource_update_controller = nullptr;
920 899
921 blocked_main().main_thread_inside_commit = true; 900 blocked_main().main_thread_inside_commit = true;
922 impl().layer_tree_host_impl->BeginCommit(); 901 impl().layer_tree_host_impl->BeginCommit();
923 layer_tree_host()->BeginCommitOnImplThread(impl().layer_tree_host_impl.get()); 902 layer_tree_host()->BeginCommitOnImplThread(impl().layer_tree_host_impl.get());
924 layer_tree_host()->FinishCommitOnImplThread( 903 layer_tree_host()->FinishCommitOnImplThread(
925 impl().layer_tree_host_impl.get()); 904 impl().layer_tree_host_impl.get());
926 blocked_main().main_thread_inside_commit = false; 905 blocked_main().main_thread_inside_commit = false;
927 906
928 bool hold_commit = layer_tree_host()->settings().impl_side_painting && 907 bool hold_commit = layer_tree_host()->settings().impl_side_painting &&
929 blocked_main().commit_waits_for_activation; 908 blocked_main().commit_waits_for_activation;
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
1056 bool forced_draw = true; 1035 bool forced_draw = true;
1057 return DrawSwapInternal(forced_draw); 1036 return DrawSwapInternal(forced_draw);
1058 } 1037 }
1059 1038
1060 void ThreadProxy::ScheduledActionInvalidateOutputSurface() { 1039 void ThreadProxy::ScheduledActionInvalidateOutputSurface() {
1061 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionInvalidateOutputSurface"); 1040 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionInvalidateOutputSurface");
1062 DCHECK(impl().layer_tree_host_impl->output_surface()); 1041 DCHECK(impl().layer_tree_host_impl->output_surface());
1063 impl().layer_tree_host_impl->output_surface()->Invalidate(); 1042 impl().layer_tree_host_impl->output_surface()->Invalidate();
1064 } 1043 }
1065 1044
1066 void ThreadProxy::DidAnticipatedDrawTimeChange(base::TimeTicks time) {
1067 if (impl().current_resource_update_controller)
1068 impl().current_resource_update_controller->PerformMoreUpdates(time);
1069 }
1070
1071 base::TimeDelta ThreadProxy::DrawDurationEstimate() { 1045 base::TimeDelta ThreadProxy::DrawDurationEstimate() {
1072 return impl().timing_history.DrawDurationEstimate(); 1046 return impl().timing_history.DrawDurationEstimate();
1073 } 1047 }
1074 1048
1075 base::TimeDelta ThreadProxy::BeginMainFrameToCommitDurationEstimate() { 1049 base::TimeDelta ThreadProxy::BeginMainFrameToCommitDurationEstimate() {
1076 return impl().timing_history.BeginMainFrameToCommitDurationEstimate(); 1050 return impl().timing_history.BeginMainFrameToCommitDurationEstimate();
1077 } 1051 }
1078 1052
1079 base::TimeDelta ThreadProxy::CommitToActivateDurationEstimate() { 1053 base::TimeDelta ThreadProxy::CommitToActivateDurationEstimate() {
1080 return impl().timing_history.CommitToActivateDurationEstimate(); 1054 return impl().timing_history.CommitToActivateDurationEstimate();
1081 } 1055 }
1082 1056
1083 void ThreadProxy::DidFinishImplFrame() { 1057 void ThreadProxy::DidFinishImplFrame() {
1084 impl().layer_tree_host_impl->DidFinishImplFrame(); 1058 impl().layer_tree_host_impl->DidFinishImplFrame();
1085 } 1059 }
1086 1060
1087 void ThreadProxy::SendBeginFramesToChildren(const BeginFrameArgs& args) { 1061 void ThreadProxy::SendBeginFramesToChildren(const BeginFrameArgs& args) {
1088 NOTREACHED() << "Only used by SingleThreadProxy"; 1062 NOTREACHED() << "Only used by SingleThreadProxy";
1089 } 1063 }
1090 1064
1091 void ThreadProxy::SetAuthoritativeVSyncInterval( 1065 void ThreadProxy::SetAuthoritativeVSyncInterval(
1092 const base::TimeDelta& interval) { 1066 const base::TimeDelta& interval) {
1093 NOTREACHED() << "Only used by SingleThreadProxy"; 1067 NOTREACHED() << "Only used by SingleThreadProxy";
1094 } 1068 }
1095 1069
1096 void ThreadProxy::ReadyToFinalizeTextureUpdates() {
1097 DCHECK(IsImplThread());
1098 impl().scheduler->NotifyReadyToCommit();
1099 }
1100
1101 void ThreadProxy::DidCommitAndDrawFrame() { 1070 void ThreadProxy::DidCommitAndDrawFrame() {
1102 DCHECK(IsMainThread()); 1071 DCHECK(IsMainThread());
1103 layer_tree_host()->DidCommitAndDrawFrame(); 1072 layer_tree_host()->DidCommitAndDrawFrame();
1104 } 1073 }
1105 1074
1106 void ThreadProxy::DidCompleteSwapBuffers() { 1075 void ThreadProxy::DidCompleteSwapBuffers() {
1107 DCHECK(IsMainThread()); 1076 DCHECK(IsMainThread());
1108 layer_tree_host()->DidCompleteSwapBuffers(); 1077 layer_tree_host()->DidCompleteSwapBuffers();
1109 } 1078 }
1110 1079
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1165 if (context_provider) 1134 if (context_provider)
1166 context_provider->ContextGL()->Finish(); 1135 context_provider->ContextGL()->Finish();
1167 } 1136 }
1168 completion->Signal(); 1137 completion->Signal();
1169 } 1138 }
1170 1139
1171 void ThreadProxy::LayerTreeHostClosedOnImplThread(CompletionEvent* completion) { 1140 void ThreadProxy::LayerTreeHostClosedOnImplThread(CompletionEvent* completion) {
1172 TRACE_EVENT0("cc", "ThreadProxy::LayerTreeHostClosedOnImplThread"); 1141 TRACE_EVENT0("cc", "ThreadProxy::LayerTreeHostClosedOnImplThread");
1173 DCHECK(IsImplThread()); 1142 DCHECK(IsImplThread());
1174 DCHECK(IsMainThreadBlocked()); 1143 DCHECK(IsMainThreadBlocked());
1175 impl().current_resource_update_controller = nullptr;
1176 impl().scheduler = nullptr; 1144 impl().scheduler = nullptr;
1177 impl().layer_tree_host_impl = nullptr; 1145 impl().layer_tree_host_impl = nullptr;
1178 impl().weak_factory.InvalidateWeakPtrs(); 1146 impl().weak_factory.InvalidateWeakPtrs();
1179 // We need to explicitly shutdown the notifier to destroy any weakptrs it is 1147 // We need to explicitly shutdown the notifier to destroy any weakptrs it is
1180 // holding while still on the compositor thread. This also ensures any 1148 // holding while still on the compositor thread. This also ensures any
1181 // callbacks holding a ThreadProxy pointer are cancelled. 1149 // callbacks holding a ThreadProxy pointer are cancelled.
1182 impl().smoothness_priority_expiration_notifier.Shutdown(); 1150 impl().smoothness_priority_expiration_notifier.Shutdown();
1183 completion->Signal(); 1151 completion->Signal();
1184 } 1152 }
1185 1153
1186 size_t ThreadProxy::MaxPartialTextureUpdates() const {
1187 return ResourceUpdateController::MaxPartialTextureUpdates();
1188 }
1189
1190 ThreadProxy::BeginMainFrameAndCommitState::BeginMainFrameAndCommitState() 1154 ThreadProxy::BeginMainFrameAndCommitState::BeginMainFrameAndCommitState()
1191 : memory_allocation_limit_bytes(0), 1155 : memory_allocation_limit_bytes(0),
1192 memory_allocation_priority_cutoff(0), 1156 memory_allocation_priority_cutoff(0),
1193 evicted_ui_resources(false) {} 1157 evicted_ui_resources(false) {}
1194 1158
1195 ThreadProxy::BeginMainFrameAndCommitState::~BeginMainFrameAndCommitState() {} 1159 ThreadProxy::BeginMainFrameAndCommitState::~BeginMainFrameAndCommitState() {}
1196 1160
1197 bool ThreadProxy::MainFrameWillHappenForTesting() { 1161 bool ThreadProxy::MainFrameWillHappenForTesting() {
1198 DCHECK(IsMainThread()); 1162 DCHECK(IsMainThread());
1199 CompletionEvent completion; 1163 CompletionEvent completion;
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
1330 1294
1331 void ThreadProxy::PostFrameTimingEvents( 1295 void ThreadProxy::PostFrameTimingEvents(
1332 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, 1296 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events,
1333 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) { 1297 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) {
1334 DCHECK(IsMainThread()); 1298 DCHECK(IsMainThread());
1335 layer_tree_host()->RecordFrameTimingEvents(composite_events.Pass(), 1299 layer_tree_host()->RecordFrameTimingEvents(composite_events.Pass(),
1336 main_frame_events.Pass()); 1300 main_frame_events.Pass());
1337 } 1301 }
1338 1302
1339 } // namespace cc 1303 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/thread_proxy.h ('k') | components/view_manager/surfaces/surfaces_scheduler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698