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

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

Issue 1184863004: cc: Move timing history to the Scheduler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase, add include 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
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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 commit_completion_event(NULL), 106 commit_completion_event(NULL),
107 completion_event_for_commit_held_on_tree_activation(NULL), 107 completion_event_for_commit_held_on_tree_activation(NULL),
108 next_frame_is_newly_committed_frame(false), 108 next_frame_is_newly_committed_frame(false),
109 inside_draw(false), 109 inside_draw(false),
110 input_throttled_until_commit(false), 110 input_throttled_until_commit(false),
111 smoothness_priority_expiration_notifier( 111 smoothness_priority_expiration_notifier(
112 proxy->ImplThreadTaskRunner(), 112 proxy->ImplThreadTaskRunner(),
113 base::Bind(&ThreadProxy::RenewTreePriority, base::Unretained(proxy)), 113 base::Bind(&ThreadProxy::RenewTreePriority, base::Unretained(proxy)),
114 base::TimeDelta::FromMilliseconds( 114 base::TimeDelta::FromMilliseconds(
115 kSmoothnessTakesPriorityExpirationDelay * 1000)), 115 kSmoothnessTakesPriorityExpirationDelay * 1000)),
116 timing_history(rendering_stats_instrumentation),
117 external_begin_frame_source(external_begin_frame_source.Pass()), 116 external_begin_frame_source(external_begin_frame_source.Pass()),
117 rendering_stats_instrumentation(rendering_stats_instrumentation),
118 weak_factory(proxy) { 118 weak_factory(proxy) {
119 } 119 }
120 120
121 ThreadProxy::CompositorThreadOnly::~CompositorThreadOnly() {} 121 ThreadProxy::CompositorThreadOnly::~CompositorThreadOnly() {}
122 122
123 ThreadProxy::~ThreadProxy() { 123 ThreadProxy::~ThreadProxy() {
124 TRACE_EVENT0("cc", "ThreadProxy::~ThreadProxy"); 124 TRACE_EVENT0("cc", "ThreadProxy::~ThreadProxy");
125 DCHECK(IsMainThread()); 125 DCHECK(IsMainThread());
126 DCHECK(!main().started); 126 DCHECK(!main().started);
127 } 127 }
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 // main_frame_before_activation_enabled is set, since we might run this code 661 // main_frame_before_activation_enabled is set, since we might run this code
662 // twice before recording a duration. crbug.com/469824 662 // twice before recording a duration. crbug.com/469824
663 impl().last_begin_main_frame_args = begin_main_frame_state->begin_frame_args; 663 impl().last_begin_main_frame_args = begin_main_frame_state->begin_frame_args;
664 Proxy::MainThreadTaskRunner()->PostTask( 664 Proxy::MainThreadTaskRunner()->PostTask(
665 FROM_HERE, 665 FROM_HERE,
666 base::Bind(&ThreadProxy::BeginMainFrame, 666 base::Bind(&ThreadProxy::BeginMainFrame,
667 main_thread_weak_ptr_, 667 main_thread_weak_ptr_,
668 base::Passed(&begin_main_frame_state))); 668 base::Passed(&begin_main_frame_state)));
669 devtools_instrumentation::DidRequestMainThreadFrame( 669 devtools_instrumentation::DidRequestMainThreadFrame(
670 impl().layer_tree_host_id); 670 impl().layer_tree_host_id);
671 impl().timing_history.DidBeginMainFrame();
672 } 671 }
673 672
674 void ThreadProxy::SendBeginMainFrameNotExpectedSoon() { 673 void ThreadProxy::SendBeginMainFrameNotExpectedSoon() {
675 Proxy::MainThreadTaskRunner()->PostTask( 674 Proxy::MainThreadTaskRunner()->PostTask(
676 FROM_HERE, base::Bind(&ThreadProxy::BeginMainFrameNotExpectedSoon, 675 FROM_HERE, base::Bind(&ThreadProxy::BeginMainFrameNotExpectedSoon,
677 main_thread_weak_ptr_)); 676 main_thread_weak_ptr_));
678 } 677 }
679 678
680 void ThreadProxy::BeginMainFrame( 679 void ThreadProxy::BeginMainFrame(
681 scoped_ptr<BeginMainFrameAndCommitState> begin_main_frame_state) { 680 scoped_ptr<BeginMainFrameAndCommitState> begin_main_frame_state) {
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
916 impl().commit_completion_event = NULL; 915 impl().commit_completion_event = NULL;
917 } 916 }
918 917
919 // Delay this step until afer the main thread has been released as it's 918 // Delay this step until afer the main thread has been released as it's
920 // often a good bit of work to update the tree and prepare the new frame. 919 // often a good bit of work to update the tree and prepare the new frame.
921 impl().layer_tree_host_impl->CommitComplete(); 920 impl().layer_tree_host_impl->CommitComplete();
922 921
923 SetInputThrottledUntilCommitOnImplThread(false); 922 SetInputThrottledUntilCommitOnImplThread(false);
924 923
925 impl().next_frame_is_newly_committed_frame = true; 924 impl().next_frame_is_newly_committed_frame = true;
926
927 impl().timing_history.DidCommit();
928 } 925 }
929 926
930 void ThreadProxy::ScheduledActionActivateSyncTree() { 927 void ThreadProxy::ScheduledActionActivateSyncTree() {
931 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionActivateSyncTree"); 928 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionActivateSyncTree");
932 DCHECK(IsImplThread()); 929 DCHECK(IsImplThread());
933 impl().layer_tree_host_impl->ActivateSyncTree(); 930 impl().layer_tree_host_impl->ActivateSyncTree();
934 } 931 }
935 932
936 void ThreadProxy::ScheduledActionBeginOutputSurfaceCreation() { 933 void ThreadProxy::ScheduledActionBeginOutputSurfaceCreation() {
937 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionBeginOutputSurfaceCreation"); 934 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionBeginOutputSurfaceCreation");
938 DCHECK(IsImplThread()); 935 DCHECK(IsImplThread());
939 Proxy::MainThreadTaskRunner()->PostTask( 936 Proxy::MainThreadTaskRunner()->PostTask(
940 FROM_HERE, 937 FROM_HERE,
941 base::Bind(&ThreadProxy::RequestNewOutputSurface, main_thread_weak_ptr_)); 938 base::Bind(&ThreadProxy::RequestNewOutputSurface, main_thread_weak_ptr_));
942 } 939 }
943 940
944 DrawResult ThreadProxy::DrawSwapInternal(bool forced_draw) { 941 DrawResult ThreadProxy::DrawSwapInternal(bool forced_draw) {
945 TRACE_EVENT_SYNTHETIC_DELAY("cc.DrawAndSwap"); 942 TRACE_EVENT_SYNTHETIC_DELAY("cc.DrawAndSwap");
946 DrawResult result; 943 DrawResult result;
947 944
948 DCHECK(IsImplThread()); 945 DCHECK(IsImplThread());
949 DCHECK(impl().layer_tree_host_impl.get()); 946 DCHECK(impl().layer_tree_host_impl.get());
950 947
951 impl().timing_history.DidStartDrawing();
952 base::AutoReset<bool> mark_inside(&impl().inside_draw, true); 948 base::AutoReset<bool> mark_inside(&impl().inside_draw, true);
953 949
954 if (impl().layer_tree_host_impl->pending_tree()) { 950 if (impl().layer_tree_host_impl->pending_tree()) {
955 bool update_lcd_text = false; 951 bool update_lcd_text = false;
956 impl().layer_tree_host_impl->pending_tree()->UpdateDrawProperties( 952 impl().layer_tree_host_impl->pending_tree()->UpdateDrawProperties(
957 update_lcd_text); 953 update_lcd_text);
958 } 954 }
959 955
960 // This method is called on a forced draw, regardless of whether we are able 956 // This method is called on a forced draw, regardless of whether we are able
961 // to produce a frame, as the calling site on main thread is blocked until its 957 // to produce a frame, as the calling site on main thread is blocked until its
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
993 impl().layer_tree_host_impl->SwapBuffers(frame); 989 impl().layer_tree_host_impl->SwapBuffers(frame);
994 990
995 // Tell the main thread that the the newly-commited frame was drawn. 991 // Tell the main thread that the the newly-commited frame was drawn.
996 if (impl().next_frame_is_newly_committed_frame) { 992 if (impl().next_frame_is_newly_committed_frame) {
997 impl().next_frame_is_newly_committed_frame = false; 993 impl().next_frame_is_newly_committed_frame = false;
998 Proxy::MainThreadTaskRunner()->PostTask( 994 Proxy::MainThreadTaskRunner()->PostTask(
999 FROM_HERE, 995 FROM_HERE,
1000 base::Bind(&ThreadProxy::DidCommitAndDrawFrame, main_thread_weak_ptr_)); 996 base::Bind(&ThreadProxy::DidCommitAndDrawFrame, main_thread_weak_ptr_));
1001 } 997 }
1002 998
1003 if (result == DRAW_SUCCESS)
1004 impl().timing_history.DidFinishDrawing();
1005
1006 DCHECK_NE(INVALID_RESULT, result); 999 DCHECK_NE(INVALID_RESULT, result);
1007 return result; 1000 return result;
1008 } 1001 }
1009 1002
1010 void ThreadProxy::ScheduledActionPrepareTiles() { 1003 void ThreadProxy::ScheduledActionPrepareTiles() {
1011 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionPrepareTiles"); 1004 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionPrepareTiles");
1012 impl().layer_tree_host_impl->PrepareTiles(); 1005 impl().layer_tree_host_impl->PrepareTiles();
1013 } 1006 }
1014 1007
1015 DrawResult ThreadProxy::ScheduledActionDrawAndSwapIfPossible() { 1008 DrawResult ThreadProxy::ScheduledActionDrawAndSwapIfPossible() {
(...skipping 13 matching lines...) Expand all
1029 bool forced_draw = true; 1022 bool forced_draw = true;
1030 return DrawSwapInternal(forced_draw); 1023 return DrawSwapInternal(forced_draw);
1031 } 1024 }
1032 1025
1033 void ThreadProxy::ScheduledActionInvalidateOutputSurface() { 1026 void ThreadProxy::ScheduledActionInvalidateOutputSurface() {
1034 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionInvalidateOutputSurface"); 1027 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionInvalidateOutputSurface");
1035 DCHECK(impl().layer_tree_host_impl->output_surface()); 1028 DCHECK(impl().layer_tree_host_impl->output_surface());
1036 impl().layer_tree_host_impl->output_surface()->Invalidate(); 1029 impl().layer_tree_host_impl->output_surface()->Invalidate();
1037 } 1030 }
1038 1031
1039 base::TimeDelta ThreadProxy::DrawDurationEstimate() {
1040 return impl().timing_history.DrawDurationEstimate();
1041 }
1042
1043 base::TimeDelta ThreadProxy::BeginMainFrameToCommitDurationEstimate() {
1044 return impl().timing_history.BeginMainFrameToCommitDurationEstimate();
1045 }
1046
1047 base::TimeDelta ThreadProxy::CommitToActivateDurationEstimate() {
1048 return impl().timing_history.CommitToActivateDurationEstimate();
1049 }
1050
1051 void ThreadProxy::DidFinishImplFrame() { 1032 void ThreadProxy::DidFinishImplFrame() {
1052 impl().layer_tree_host_impl->DidFinishImplFrame(); 1033 impl().layer_tree_host_impl->DidFinishImplFrame();
1053 } 1034 }
1054 1035
1055 void ThreadProxy::SendBeginFramesToChildren(const BeginFrameArgs& args) { 1036 void ThreadProxy::SendBeginFramesToChildren(const BeginFrameArgs& args) {
1056 NOTREACHED() << "Only used by SingleThreadProxy"; 1037 NOTREACHED() << "Only used by SingleThreadProxy";
1057 } 1038 }
1058 1039
1059 void ThreadProxy::SetAuthoritativeVSyncInterval( 1040 void ThreadProxy::SetAuthoritativeVSyncInterval(
1060 const base::TimeDelta& interval) { 1041 const base::TimeDelta& interval) {
(...skipping 17 matching lines...) Expand all
1078 } 1059 }
1079 1060
1080 void ThreadProxy::InitializeImplOnImplThread(CompletionEvent* completion) { 1061 void ThreadProxy::InitializeImplOnImplThread(CompletionEvent* completion) {
1081 TRACE_EVENT0("cc", "ThreadProxy::InitializeImplOnImplThread"); 1062 TRACE_EVENT0("cc", "ThreadProxy::InitializeImplOnImplThread");
1082 DCHECK(IsImplThread()); 1063 DCHECK(IsImplThread());
1083 impl().layer_tree_host_impl = 1064 impl().layer_tree_host_impl =
1084 layer_tree_host()->CreateLayerTreeHostImpl(this); 1065 layer_tree_host()->CreateLayerTreeHostImpl(this);
1085 SchedulerSettings scheduler_settings( 1066 SchedulerSettings scheduler_settings(
1086 layer_tree_host()->settings().ToSchedulerSettings()); 1067 layer_tree_host()->settings().ToSchedulerSettings());
1087 impl().scheduler = Scheduler::Create( 1068 impl().scheduler = Scheduler::Create(
1088 this, 1069 this, scheduler_settings, impl().layer_tree_host_id,
1089 scheduler_settings, 1070 ImplThreadTaskRunner(), impl().external_begin_frame_source.Pass(),
1090 impl().layer_tree_host_id, 1071 impl().rendering_stats_instrumentation);
1091 ImplThreadTaskRunner(),
1092 impl().external_begin_frame_source.Pass());
1093 impl().scheduler->SetVisible(impl().layer_tree_host_impl->visible()); 1072 impl().scheduler->SetVisible(impl().layer_tree_host_impl->visible());
1094 impl_thread_weak_ptr_ = impl().weak_factory.GetWeakPtr(); 1073 impl_thread_weak_ptr_ = impl().weak_factory.GetWeakPtr();
1095 completion->Signal(); 1074 completion->Signal();
1096 } 1075 }
1097 1076
1098 void ThreadProxy::InitializeOutputSurfaceOnImplThread( 1077 void ThreadProxy::InitializeOutputSurfaceOnImplThread(
1099 scoped_ptr<OutputSurface> output_surface) { 1078 scoped_ptr<OutputSurface> output_surface) {
1100 TRACE_EVENT0("cc", "ThreadProxy::InitializeOutputSurfaceOnImplThread"); 1079 TRACE_EVENT0("cc", "ThreadProxy::InitializeOutputSurfaceOnImplThread");
1101 DCHECK(IsImplThread()); 1080 DCHECK(IsImplThread());
1102 1081
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
1245 TRACE_EVENT0("cc", "ThreadProxy::DidActivateSyncTreeOnImplThread"); 1224 TRACE_EVENT0("cc", "ThreadProxy::DidActivateSyncTreeOnImplThread");
1246 DCHECK(IsImplThread()); 1225 DCHECK(IsImplThread());
1247 1226
1248 if (impl().completion_event_for_commit_held_on_tree_activation) { 1227 if (impl().completion_event_for_commit_held_on_tree_activation) {
1249 TRACE_EVENT_INSTANT0( 1228 TRACE_EVENT_INSTANT0(
1250 "cc", "ReleaseCommitbyActivation", TRACE_EVENT_SCOPE_THREAD); 1229 "cc", "ReleaseCommitbyActivation", TRACE_EVENT_SCOPE_THREAD);
1251 impl().completion_event_for_commit_held_on_tree_activation->Signal(); 1230 impl().completion_event_for_commit_held_on_tree_activation->Signal();
1252 impl().completion_event_for_commit_held_on_tree_activation = NULL; 1231 impl().completion_event_for_commit_held_on_tree_activation = NULL;
1253 } 1232 }
1254 1233
1255 impl().timing_history.DidActivateSyncTree();
1256 impl().last_processed_begin_main_frame_args = 1234 impl().last_processed_begin_main_frame_args =
1257 impl().last_begin_main_frame_args; 1235 impl().last_begin_main_frame_args;
1258 } 1236 }
1259 1237
1260 void ThreadProxy::DidPrepareTiles() { 1238 void ThreadProxy::DidPrepareTiles() {
1261 DCHECK(IsImplThread()); 1239 DCHECK(IsImplThread());
1262 impl().scheduler->DidPrepareTiles(); 1240 impl().scheduler->DidPrepareTiles();
1263 } 1241 }
1264 1242
1265 void ThreadProxy::DidCompletePageScaleAnimationOnImplThread() { 1243 void ThreadProxy::DidCompletePageScaleAnimationOnImplThread() {
(...skipping 21 matching lines...) Expand all
1287 1265
1288 void ThreadProxy::PostFrameTimingEvents( 1266 void ThreadProxy::PostFrameTimingEvents(
1289 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, 1267 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events,
1290 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) { 1268 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) {
1291 DCHECK(IsMainThread()); 1269 DCHECK(IsMainThread());
1292 layer_tree_host()->RecordFrameTimingEvents(composite_events.Pass(), 1270 layer_tree_host()->RecordFrameTimingEvents(composite_events.Pass(),
1293 main_frame_events.Pass()); 1271 main_frame_events.Pass());
1294 } 1272 }
1295 1273
1296 } // namespace cc 1274 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698