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

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

Issue 1460923002: cc: CompositorTimingHistory throughput UMAs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@didDraw
Patch Set: Remove debug TRACE_EVENTS Created 5 years 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') | tools/metrics/histograms/histograms.xml » ('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 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 base::TimeTicks main_thread_start_time) { 269 base::TimeTicks main_thread_start_time) {
270 TRACE_EVENT0("cc", "Scheduler::NotifyBeginMainFrameStarted"); 270 TRACE_EVENT0("cc", "Scheduler::NotifyBeginMainFrameStarted");
271 state_machine_.NotifyBeginMainFrameStarted(); 271 state_machine_.NotifyBeginMainFrameStarted();
272 compositor_timing_history_->BeginMainFrameStarted(main_thread_start_time); 272 compositor_timing_history_->BeginMainFrameStarted(main_thread_start_time);
273 } 273 }
274 274
275 base::TimeTicks Scheduler::LastBeginImplFrameTime() { 275 base::TimeTicks Scheduler::LastBeginImplFrameTime() {
276 return begin_impl_frame_tracker_.Current().frame_time; 276 return begin_impl_frame_tracker_.Current().frame_time;
277 } 277 }
278 278
279 void Scheduler::BeginImplFrameNotExpectedSoon() {
280 compositor_timing_history_->BeginImplFrameNotExpectedSoon();
281
282 // Tying this to SendBeginMainFrameNotExpectedSoon will have some
283 // false negatives, but we want to avoid running long idle tasks when
284 // we are actually active.
285 client_->SendBeginMainFrameNotExpectedSoon();
286 }
287
279 void Scheduler::SetupNextBeginFrameIfNeeded() { 288 void Scheduler::SetupNextBeginFrameIfNeeded() {
280 // Never call SetNeedsBeginFrames if the frame source already has the right 289 // Never call SetNeedsBeginFrames if the frame source already has the right
281 // value. 290 // value.
282 if (frame_source_->NeedsBeginFrames() != state_machine_.BeginFrameNeeded()) { 291 if (frame_source_->NeedsBeginFrames() != state_machine_.BeginFrameNeeded()) {
283 if (state_machine_.BeginFrameNeeded()) { 292 if (state_machine_.BeginFrameNeeded()) {
284 // Call SetNeedsBeginFrames(true) as soon as possible. 293 // Call SetNeedsBeginFrames(true) as soon as possible.
285 frame_source_->SetNeedsBeginFrames(true); 294 frame_source_->SetNeedsBeginFrames(true);
286 devtools_instrumentation::NeedsBeginFrameChanged(layer_tree_host_id_, 295 devtools_instrumentation::NeedsBeginFrameChanged(layer_tree_host_id_,
287 true); 296 true);
288 } else if (state_machine_.begin_impl_frame_state() == 297 } else if (state_machine_.begin_impl_frame_state() ==
289 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE) { 298 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE) {
290 // Call SetNeedsBeginFrames(false) in between frames only. 299 // Call SetNeedsBeginFrames(false) in between frames only.
291 frame_source_->SetNeedsBeginFrames(false); 300 frame_source_->SetNeedsBeginFrames(false);
292 client_->SendBeginMainFrameNotExpectedSoon(); 301 BeginImplFrameNotExpectedSoon();
293 devtools_instrumentation::NeedsBeginFrameChanged(layer_tree_host_id_, 302 devtools_instrumentation::NeedsBeginFrameChanged(layer_tree_host_id_,
294 false); 303 false);
295 } 304 }
296 } 305 }
297 306
298 PostBeginRetroFrameIfNeeded(); 307 PostBeginRetroFrameIfNeeded();
299 } 308 }
300 309
301 // BeginFrame is the mechanism that tells us that now is a good time to start 310 // BeginFrame is the mechanism that tells us that now is a good time to start
302 // making a frame. Usually this means that user input for the frame is complete. 311 // making a frame. Usually this means that user input for the frame is complete.
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 TRACE_EVENT1("cc,benchmark", "Scheduler::BeginImplFrame", "args", 533 TRACE_EVENT1("cc,benchmark", "Scheduler::BeginImplFrame", "args",
525 args.AsValue()); 534 args.AsValue());
526 535
527 // The main thread currently can't commit before we draw with the 536 // The main thread currently can't commit before we draw with the
528 // synchronous compositor, so never consider the BeginMainFrame fast. 537 // synchronous compositor, so never consider the BeginMainFrame fast.
529 state_machine_.SetCriticalBeginMainFrameToActivateIsFast(false); 538 state_machine_.SetCriticalBeginMainFrameToActivateIsFast(false);
530 begin_main_frame_args_ = args; 539 begin_main_frame_args_ = args;
531 begin_main_frame_args_.on_critical_path = !ImplLatencyTakesPriority(); 540 begin_main_frame_args_.on_critical_path = !ImplLatencyTakesPriority();
532 541
533 BeginImplFrame(args); 542 BeginImplFrame(args);
543 compositor_timing_history_->WillFinishImplFrame(
544 state_machine_.needs_redraw());
534 FinishImplFrame(); 545 FinishImplFrame();
535 } 546 }
536 547
537 void Scheduler::FinishImplFrame() { 548 void Scheduler::FinishImplFrame() {
538 state_machine_.OnBeginImplFrameIdle(); 549 state_machine_.OnBeginImplFrameIdle();
539 ProcessScheduledActions(); 550 ProcessScheduledActions();
540 551
541 client_->DidFinishImplFrame(); 552 client_->DidFinishImplFrame();
542 frame_source_->DidFinishFrame(begin_retro_frame_args_.size()); 553 frame_source_->DidFinishFrame(begin_retro_frame_args_.size());
543 begin_impl_frame_tracker_.Finish(); 554 begin_impl_frame_tracker_.Finish();
544 } 555 }
545 556
546 // BeginImplFrame starts a compositor frame that will wait up until a deadline 557 // BeginImplFrame starts a compositor frame that will wait up until a deadline
547 // for a BeginMainFrame+activation to complete before it times out and draws 558 // for a BeginMainFrame+activation to complete before it times out and draws
548 // any asynchronous animation and scroll/pinch updates. 559 // any asynchronous animation and scroll/pinch updates.
549 void Scheduler::BeginImplFrame(const BeginFrameArgs& args) { 560 void Scheduler::BeginImplFrame(const BeginFrameArgs& args) {
550 DCHECK_EQ(state_machine_.begin_impl_frame_state(), 561 DCHECK_EQ(state_machine_.begin_impl_frame_state(),
551 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE); 562 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE);
552 DCHECK(!BeginImplFrameDeadlinePending()); 563 DCHECK(!BeginImplFrameDeadlinePending());
553 DCHECK(state_machine_.HasInitializedOutputSurface()); 564 DCHECK(state_machine_.HasInitializedOutputSurface());
554 565
555 begin_impl_frame_tracker_.Start(args); 566 begin_impl_frame_tracker_.Start(args);
556 state_machine_.OnBeginImplFrame(); 567 state_machine_.OnBeginImplFrame();
557 devtools_instrumentation::DidBeginFrame(layer_tree_host_id_); 568 devtools_instrumentation::DidBeginFrame(layer_tree_host_id_);
569 compositor_timing_history_->WillBeginImplFrame(
570 state_machine_.NewActiveTreeLikely());
558 client_->WillBeginImplFrame(begin_impl_frame_tracker_.Current()); 571 client_->WillBeginImplFrame(begin_impl_frame_tracker_.Current());
559 572
560 ProcessScheduledActions(); 573 ProcessScheduledActions();
561 } 574 }
562 575
563 void Scheduler::ScheduleBeginImplFrameDeadline() { 576 void Scheduler::ScheduleBeginImplFrameDeadline() {
564 // The synchronous compositor does not post a deadline task. 577 // The synchronous compositor does not post a deadline task.
565 DCHECK(!settings_.using_synchronous_renderer_compositor); 578 DCHECK(!settings_.using_synchronous_renderer_compositor);
566 579
567 begin_impl_frame_deadline_task_.Cancel(); 580 begin_impl_frame_deadline_task_.Cancel();
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 // the deadline separately. For example: 646 // the deadline separately. For example:
634 // * Sending the BeginMainFrame will not occur after the deadline in 647 // * Sending the BeginMainFrame will not occur after the deadline in
635 // order to wait for more user-input before starting the next commit. 648 // order to wait for more user-input before starting the next commit.
636 // * Creating a new OuputSurface will not occur during the deadline in 649 // * Creating a new OuputSurface will not occur during the deadline in
637 // order to allow the state machine to "settle" first. 650 // order to allow the state machine to "settle" first.
638 651
639 // TODO(robliao): Remove ScopedTracker below once crbug.com/461509 is fixed. 652 // TODO(robliao): Remove ScopedTracker below once crbug.com/461509 is fixed.
640 tracked_objects::ScopedTracker tracking_profile1( 653 tracked_objects::ScopedTracker tracking_profile1(
641 FROM_HERE_WITH_EXPLICIT_FUNCTION( 654 FROM_HERE_WITH_EXPLICIT_FUNCTION(
642 "461509 Scheduler::OnBeginImplFrameDeadline1")); 655 "461509 Scheduler::OnBeginImplFrameDeadline1"));
656 compositor_timing_history_->WillFinishImplFrame(
657 state_machine_.needs_redraw());
643 state_machine_.OnBeginImplFrameDeadline(); 658 state_machine_.OnBeginImplFrameDeadline();
644 ProcessScheduledActions(); 659 ProcessScheduledActions();
645 FinishImplFrame(); 660 FinishImplFrame();
646 } 661 }
647 662
648 void Scheduler::DrawAndSwapIfPossible() { 663 void Scheduler::DrawAndSwapIfPossible() {
664 bool drawing_with_new_active_tree =
665 state_machine_.active_tree_needs_first_draw();
666 compositor_timing_history_->WillDraw();
649 state_machine_.WillDraw(); 667 state_machine_.WillDraw();
650 compositor_timing_history_->WillDraw();
651 DrawResult result = client_->ScheduledActionDrawAndSwapIfPossible(); 668 DrawResult result = client_->ScheduledActionDrawAndSwapIfPossible();
652 compositor_timing_history_->DidDraw();
653 state_machine_.DidDraw(result); 669 state_machine_.DidDraw(result);
670 compositor_timing_history_->DidDraw(drawing_with_new_active_tree);
654 } 671 }
655 672
656 void Scheduler::DrawAndSwapForced() { 673 void Scheduler::DrawAndSwapForced() {
674 bool drawing_with_new_active_tree =
675 state_machine_.active_tree_needs_first_draw();
676 compositor_timing_history_->WillDraw();
657 state_machine_.WillDraw(); 677 state_machine_.WillDraw();
658 compositor_timing_history_->WillDraw();
659 DrawResult result = client_->ScheduledActionDrawAndSwapForced(); 678 DrawResult result = client_->ScheduledActionDrawAndSwapForced();
660 compositor_timing_history_->DidDraw();
661 state_machine_.DidDraw(result); 679 state_machine_.DidDraw(result);
680 compositor_timing_history_->DidDraw(drawing_with_new_active_tree);
662 } 681 }
663 682
664 void Scheduler::SetDeferCommits(bool defer_commits) { 683 void Scheduler::SetDeferCommits(bool defer_commits) {
665 TRACE_EVENT1("cc", "Scheduler::SetDeferCommits", 684 TRACE_EVENT1("cc", "Scheduler::SetDeferCommits",
666 "defer_commits", 685 "defer_commits",
667 defer_commits); 686 defer_commits);
668 state_machine_.SetDeferCommits(defer_commits); 687 state_machine_.SetDeferCommits(defer_commits);
669 ProcessScheduledActions(); 688 ProcessScheduledActions();
670 } 689 }
671 690
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
886 } 905 }
887 906
888 bool Scheduler::IsBeginMainFrameSentOrStarted() const { 907 bool Scheduler::IsBeginMainFrameSentOrStarted() const {
889 return (state_machine_.begin_main_frame_state() == 908 return (state_machine_.begin_main_frame_state() ==
890 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_SENT || 909 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_SENT ||
891 state_machine_.begin_main_frame_state() == 910 state_machine_.begin_main_frame_state() ==
892 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_STARTED); 911 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_STARTED);
893 } 912 }
894 913
895 } // namespace cc 914 } // namespace cc
OLDNEW
« no previous file with comments | « cc/scheduler/scheduler.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698