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

Side by Side Diff: cc/scheduler/scheduler.cc

Issue 1213653005: Revert of cc: Measure compositor timing with finer granularity (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@modeTimingHistory3
Patch Set: Created 5 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
« no previous file with comments | « cc/scheduler/scheduler.h ('k') | cc/scheduler/scheduler_unittest.cc » ('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/scheduler/scheduler.h" 5 #include "cc/scheduler/scheduler.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 estimated_parent_draw_time_ = draw_time; 124 estimated_parent_draw_time_ = draw_time;
125 } 125 }
126 126
127 void Scheduler::SetCanStart() { 127 void Scheduler::SetCanStart() {
128 state_machine_.SetCanStart(); 128 state_machine_.SetCanStart();
129 ProcessScheduledActions(); 129 ProcessScheduledActions();
130 } 130 }
131 131
132 void Scheduler::SetVisible(bool visible) { 132 void Scheduler::SetVisible(bool visible) {
133 state_machine_.SetVisible(visible); 133 state_machine_.SetVisible(visible);
134 UpdateCompositorTimingHistoryRecordingEnabled();
135 ProcessScheduledActions(); 134 ProcessScheduledActions();
136 } 135 }
137 136
138 void Scheduler::SetCanDraw(bool can_draw) { 137 void Scheduler::SetCanDraw(bool can_draw) {
139 state_machine_.SetCanDraw(can_draw); 138 state_machine_.SetCanDraw(can_draw);
140 ProcessScheduledActions(); 139 ProcessScheduledActions();
141 } 140 }
142 141
143 void Scheduler::NotifyReadyToActivate() { 142 void Scheduler::NotifyReadyToActivate() {
144 compositor_timing_history_->ReadyToActivate();
145 state_machine_.NotifyReadyToActivate(); 143 state_machine_.NotifyReadyToActivate();
146 ProcessScheduledActions(); 144 ProcessScheduledActions();
147 } 145 }
148 146
149 void Scheduler::NotifyReadyToDraw() { 147 void Scheduler::NotifyReadyToDraw() {
150 // Future work might still needed for crbug.com/352894. 148 // Future work might still needed for crbug.com/352894.
151 state_machine_.NotifyReadyToDraw(); 149 state_machine_.NotifyReadyToDraw();
152 ProcessScheduledActions(); 150 ProcessScheduledActions();
153 } 151 }
154 152
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 state_machine_.SetImplLatencyTakesPriority(impl_latency_takes_priority); 210 state_machine_.SetImplLatencyTakesPriority(impl_latency_takes_priority);
213 ProcessScheduledActions(); 211 ProcessScheduledActions();
214 } 212 }
215 213
216 void Scheduler::NotifyReadyToCommit() { 214 void Scheduler::NotifyReadyToCommit() {
217 TRACE_EVENT0("cc", "Scheduler::NotifyReadyToCommit"); 215 TRACE_EVENT0("cc", "Scheduler::NotifyReadyToCommit");
218 state_machine_.NotifyReadyToCommit(); 216 state_machine_.NotifyReadyToCommit();
219 ProcessScheduledActions(); 217 ProcessScheduledActions();
220 } 218 }
221 219
222 void Scheduler::DidCommit() {
223 compositor_timing_history_->DidCommit();
224 }
225
226 void Scheduler::BeginMainFrameAborted(CommitEarlyOutReason reason) { 220 void Scheduler::BeginMainFrameAborted(CommitEarlyOutReason reason) {
227 TRACE_EVENT1("cc", "Scheduler::BeginMainFrameAborted", "reason", 221 TRACE_EVENT1("cc", "Scheduler::BeginMainFrameAborted", "reason",
228 CommitEarlyOutReasonToString(reason)); 222 CommitEarlyOutReasonToString(reason));
229 compositor_timing_history_->BeginMainFrameAborted();
230 state_machine_.BeginMainFrameAborted(reason); 223 state_machine_.BeginMainFrameAborted(reason);
231 ProcessScheduledActions(); 224 ProcessScheduledActions();
232 } 225 }
233 226
234 void Scheduler::WillPrepareTiles() {
235 compositor_timing_history_->WillPrepareTiles();
236 }
237
238 void Scheduler::DidPrepareTiles() { 227 void Scheduler::DidPrepareTiles() {
239 compositor_timing_history_->DidPrepareTiles();
240 state_machine_.DidPrepareTiles(); 228 state_machine_.DidPrepareTiles();
241 } 229 }
242 230
243 void Scheduler::DidLoseOutputSurface() { 231 void Scheduler::DidLoseOutputSurface() {
244 TRACE_EVENT0("cc", "Scheduler::DidLoseOutputSurface"); 232 TRACE_EVENT0("cc", "Scheduler::DidLoseOutputSurface");
245 begin_retro_frame_args_.clear(); 233 begin_retro_frame_args_.clear();
246 begin_retro_frame_task_.Cancel(); 234 begin_retro_frame_task_.Cancel();
247 state_machine_.DidLoseOutputSurface(); 235 state_machine_.DidLoseOutputSurface();
248 UpdateCompositorTimingHistoryRecordingEnabled();
249 ProcessScheduledActions(); 236 ProcessScheduledActions();
250 } 237 }
251 238
252 void Scheduler::DidCreateAndInitializeOutputSurface() { 239 void Scheduler::DidCreateAndInitializeOutputSurface() {
253 TRACE_EVENT0("cc", "Scheduler::DidCreateAndInitializeOutputSurface"); 240 TRACE_EVENT0("cc", "Scheduler::DidCreateAndInitializeOutputSurface");
254 DCHECK(!frame_source_->NeedsBeginFrames()); 241 DCHECK(!frame_source_->NeedsBeginFrames());
255 DCHECK(begin_impl_frame_deadline_task_.IsCancelled()); 242 DCHECK(begin_impl_frame_deadline_task_.IsCancelled());
256 state_machine_.DidCreateAndInitializeOutputSurface(); 243 state_machine_.DidCreateAndInitializeOutputSurface();
257 UpdateCompositorTimingHistoryRecordingEnabled();
258 ProcessScheduledActions(); 244 ProcessScheduledActions();
259 } 245 }
260 246
261 void Scheduler::NotifyBeginMainFrameStarted() { 247 void Scheduler::NotifyBeginMainFrameStarted() {
262 TRACE_EVENT0("cc", "Scheduler::NotifyBeginMainFrameStarted"); 248 TRACE_EVENT0("cc", "Scheduler::NotifyBeginMainFrameStarted");
263 state_machine_.NotifyBeginMainFrameStarted(); 249 state_machine_.NotifyBeginMainFrameStarted();
264 } 250 }
265 251
266 base::TimeTicks Scheduler::LastBeginImplFrameTime() { 252 base::TimeTicks Scheduler::LastBeginImplFrameTime() {
267 return begin_impl_frame_tracker_.Current().frame_time; 253 return begin_impl_frame_tracker_.Current().frame_time;
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 // TODO(robliao): Remove ScopedTracker below once crbug.com/461509 is fixed. 572 // TODO(robliao): Remove ScopedTracker below once crbug.com/461509 is fixed.
587 tracked_objects::ScopedTracker tracking_profile1( 573 tracked_objects::ScopedTracker tracking_profile1(
588 FROM_HERE_WITH_EXPLICIT_FUNCTION( 574 FROM_HERE_WITH_EXPLICIT_FUNCTION(
589 "461509 Scheduler::OnBeginImplFrameDeadline1")); 575 "461509 Scheduler::OnBeginImplFrameDeadline1"));
590 state_machine_.OnBeginImplFrameDeadline(); 576 state_machine_.OnBeginImplFrameDeadline();
591 ProcessScheduledActions(); 577 ProcessScheduledActions();
592 FinishImplFrame(); 578 FinishImplFrame();
593 } 579 }
594 580
595 void Scheduler::DrawAndSwapIfPossible() { 581 void Scheduler::DrawAndSwapIfPossible() {
596 compositor_timing_history_->WillDraw(); 582 compositor_timing_history_->DidStartDrawing();
597 DrawResult result = client_->ScheduledActionDrawAndSwapIfPossible(); 583 DrawResult result = client_->ScheduledActionDrawAndSwapIfPossible();
598 state_machine_.DidDrawIfPossibleCompleted(result); 584 state_machine_.DidDrawIfPossibleCompleted(result);
599 compositor_timing_history_->DidDraw(); 585 compositor_timing_history_->DidFinishDrawing();
600 } 586 }
601 587
602 void Scheduler::DrawAndSwapForced() { 588 void Scheduler::DrawAndSwapForced() {
603 compositor_timing_history_->WillDraw(); 589 compositor_timing_history_->DidStartDrawing();
604 client_->ScheduledActionDrawAndSwapForced(); 590 client_->ScheduledActionDrawAndSwapForced();
605 compositor_timing_history_->DidDraw(); 591 compositor_timing_history_->DidFinishDrawing();
606 } 592 }
607 593
608 void Scheduler::SetDeferCommits(bool defer_commits) { 594 void Scheduler::SetDeferCommits(bool defer_commits) {
609 TRACE_EVENT1("cc", "Scheduler::SetDeferCommits", 595 TRACE_EVENT1("cc", "Scheduler::SetDeferCommits",
610 "defer_commits", 596 "defer_commits",
611 defer_commits); 597 defer_commits);
612 state_machine_.SetDeferCommits(defer_commits); 598 state_machine_.SetDeferCommits(defer_commits);
613 ProcessScheduledActions(); 599 ProcessScheduledActions();
614 } 600 }
615 601
(...skipping 25 matching lines...) Expand all
641 compositor_timing_history_->WillBeginMainFrame(); 627 compositor_timing_history_->WillBeginMainFrame();
642 client_->ScheduledActionSendBeginMainFrame(); 628 client_->ScheduledActionSendBeginMainFrame();
643 break; 629 break;
644 case SchedulerStateMachine::ACTION_COMMIT: { 630 case SchedulerStateMachine::ACTION_COMMIT: {
645 // TODO(robliao): Remove ScopedTracker below once crbug.com/461509 is 631 // TODO(robliao): Remove ScopedTracker below once crbug.com/461509 is
646 // fixed. 632 // fixed.
647 tracked_objects::ScopedTracker tracking_profile4( 633 tracked_objects::ScopedTracker tracking_profile4(
648 FROM_HERE_WITH_EXPLICIT_FUNCTION( 634 FROM_HERE_WITH_EXPLICIT_FUNCTION(
649 "461509 Scheduler::ProcessScheduledActions4")); 635 "461509 Scheduler::ProcessScheduledActions4"));
650 client_->ScheduledActionCommit(); 636 client_->ScheduledActionCommit();
637 compositor_timing_history_->DidCommit();
651 break; 638 break;
652 } 639 }
653 case SchedulerStateMachine::ACTION_ACTIVATE_SYNC_TREE: 640 case SchedulerStateMachine::ACTION_ACTIVATE_SYNC_TREE:
654 compositor_timing_history_->WillActivate();
655 client_->ScheduledActionActivateSyncTree(); 641 client_->ScheduledActionActivateSyncTree();
656 compositor_timing_history_->DidActivate(); 642 compositor_timing_history_->DidActivateSyncTree();
657 break; 643 break;
658 case SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE: { 644 case SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE: {
659 // TODO(robliao): Remove ScopedTracker below once crbug.com/461509 is 645 // TODO(robliao): Remove ScopedTracker below once crbug.com/461509 is
660 // fixed. 646 // fixed.
661 tracked_objects::ScopedTracker tracking_profile6( 647 tracked_objects::ScopedTracker tracking_profile6(
662 FROM_HERE_WITH_EXPLICIT_FUNCTION( 648 FROM_HERE_WITH_EXPLICIT_FUNCTION(
663 "461509 Scheduler::ProcessScheduledActions6")); 649 "461509 Scheduler::ProcessScheduledActions6"));
664 DrawAndSwapIfPossible(); 650 DrawAndSwapIfPossible();
665 break; 651 break;
666 } 652 }
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
728 state->BeginDictionary("begin_impl_frame_args"); 714 state->BeginDictionary("begin_impl_frame_args");
729 begin_impl_frame_tracker_.AsValueInto(Now(), state); 715 begin_impl_frame_tracker_.AsValueInto(Now(), state);
730 state->EndDictionary(); 716 state->EndDictionary();
731 state->EndDictionary(); 717 state->EndDictionary();
732 718
733 state->BeginDictionary("compositor_timing_history"); 719 state->BeginDictionary("compositor_timing_history");
734 compositor_timing_history_->AsValueInto(state); 720 compositor_timing_history_->AsValueInto(state);
735 state->EndDictionary(); 721 state->EndDictionary();
736 } 722 }
737 723
738 void Scheduler::UpdateCompositorTimingHistoryRecordingEnabled() {
739 compositor_timing_history_->SetRecordingEnabled(
740 state_machine_.HasInitializedOutputSurface() && state_machine_.visible());
741 }
742
743 bool Scheduler::CanCommitAndActivateBeforeDeadline() const { 724 bool Scheduler::CanCommitAndActivateBeforeDeadline() const {
744 BeginFrameArgs args = 725 BeginFrameArgs args =
745 begin_impl_frame_tracker_.DangerousMethodCurrentOrLast(); 726 begin_impl_frame_tracker_.DangerousMethodCurrentOrLast();
746 727
747 // Check if the main thread computation and commit can be finished before the 728 // Check if the main thread computation and commit can be finished before the
748 // impl thread's deadline. 729 // impl thread's deadline.
749 base::TimeTicks estimated_draw_time = 730 base::TimeTicks estimated_draw_time =
750 args.frame_time + 731 args.frame_time +
751 compositor_timing_history_->BeginMainFrameToCommitDurationEstimate() + 732 compositor_timing_history_->BeginMainFrameToCommitDurationEstimate() +
752 compositor_timing_history_->CommitToReadyToActivateDurationEstimate() + 733 compositor_timing_history_->CommitToActivateDurationEstimate();
753 compositor_timing_history_->ActivateDurationEstimate();
754 734
755 TRACE_EVENT2(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler"), 735 TRACE_EVENT2(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler"),
756 "CanCommitAndActivateBeforeDeadline", 736 "CanCommitAndActivateBeforeDeadline",
757 "time_left_after_drawing_ms", 737 "time_left_after_drawing_ms",
758 (args.deadline - estimated_draw_time).InMillisecondsF(), "state", 738 (args.deadline - estimated_draw_time).InMillisecondsF(), "state",
759 AsValue()); 739 AsValue());
760 740
761 return estimated_draw_time < args.deadline; 741 return estimated_draw_time < args.deadline;
762 } 742 }
763 743
764 bool Scheduler::IsBeginMainFrameSentOrStarted() const { 744 bool Scheduler::IsBeginMainFrameSentOrStarted() const {
765 return (state_machine_.commit_state() == 745 return (state_machine_.commit_state() ==
766 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT || 746 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT ||
767 state_machine_.commit_state() == 747 state_machine_.commit_state() ==
768 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED); 748 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED);
769 } 749 }
770 750
771 } // namespace cc 751 } // namespace cc
OLDNEW
« no previous file with comments | « cc/scheduler/scheduler.h ('k') | cc/scheduler/scheduler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698