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

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

Issue 1432463002: cc: Track BeginMainFrame more precisely in CompositorTimingHistory. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed unit tests. New tests to be added. Created 5 years, 1 month 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/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 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 251
252 void Scheduler::DidCreateAndInitializeOutputSurface() { 252 void Scheduler::DidCreateAndInitializeOutputSurface() {
253 TRACE_EVENT0("cc", "Scheduler::DidCreateAndInitializeOutputSurface"); 253 TRACE_EVENT0("cc", "Scheduler::DidCreateAndInitializeOutputSurface");
254 DCHECK(!frame_source_->NeedsBeginFrames()); 254 DCHECK(!frame_source_->NeedsBeginFrames());
255 DCHECK(begin_impl_frame_deadline_task_.IsCancelled()); 255 DCHECK(begin_impl_frame_deadline_task_.IsCancelled());
256 state_machine_.DidCreateAndInitializeOutputSurface(); 256 state_machine_.DidCreateAndInitializeOutputSurface();
257 UpdateCompositorTimingHistoryRecordingEnabled(); 257 UpdateCompositorTimingHistoryRecordingEnabled();
258 ProcessScheduledActions(); 258 ProcessScheduledActions();
259 } 259 }
260 260
261 void Scheduler::NotifyBeginMainFrameStarted() { 261 void Scheduler::NotifyBeginMainFrameStarted(
262 base::TimeTicks main_thread_start_time) {
262 TRACE_EVENT0("cc", "Scheduler::NotifyBeginMainFrameStarted"); 263 TRACE_EVENT0("cc", "Scheduler::NotifyBeginMainFrameStarted");
263 state_machine_.NotifyBeginMainFrameStarted(); 264 state_machine_.NotifyBeginMainFrameStarted();
265 compositor_timing_history_->BeginMainFrameStarted(main_thread_start_time);
264 } 266 }
265 267
266 base::TimeTicks Scheduler::LastBeginImplFrameTime() { 268 base::TimeTicks Scheduler::LastBeginImplFrameTime() {
267 return begin_impl_frame_tracker_.Current().frame_time; 269 return begin_impl_frame_tracker_.Current().frame_time;
268 } 270 }
269 271
270 void Scheduler::SetupNextBeginFrameIfNeeded() { 272 void Scheduler::SetupNextBeginFrameIfNeeded() {
271 // Never call SetNeedsBeginFrames if the frame source already has the right 273 // Never call SetNeedsBeginFrames if the frame source already has the right
272 // value. 274 // value.
273 if (frame_source_->NeedsBeginFrames() != state_machine_.BeginFrameNeeded()) { 275 if (frame_source_->NeedsBeginFrames() != state_machine_.BeginFrameNeeded()) {
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 // BeginImplFrame starts a compositor frame that will wait up until a deadline 500 // BeginImplFrame starts a compositor frame that will wait up until a deadline
499 // for a BeginMainFrame+activation to complete before it times out and draws 501 // for a BeginMainFrame+activation to complete before it times out and draws
500 // any asynchronous animation and scroll/pinch updates. 502 // any asynchronous animation and scroll/pinch updates.
501 void Scheduler::BeginImplFrame(const BeginFrameArgs& args) { 503 void Scheduler::BeginImplFrame(const BeginFrameArgs& args) {
502 DCHECK_EQ(state_machine_.begin_impl_frame_state(), 504 DCHECK_EQ(state_machine_.begin_impl_frame_state(),
503 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE); 505 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE);
504 DCHECK(!BeginImplFrameDeadlinePending()); 506 DCHECK(!BeginImplFrameDeadlinePending());
505 DCHECK(state_machine_.HasInitializedOutputSurface()); 507 DCHECK(state_machine_.HasInitializedOutputSurface());
506 508
507 begin_impl_frame_tracker_.Start(args); 509 begin_impl_frame_tracker_.Start(args);
510 begin_main_frame_args_ = args;
508 state_machine_.OnBeginImplFrame(); 511 state_machine_.OnBeginImplFrame();
509 devtools_instrumentation::DidBeginFrame(layer_tree_host_id_); 512 devtools_instrumentation::DidBeginFrame(layer_tree_host_id_);
510 client_->WillBeginImplFrame(begin_impl_frame_tracker_.Current()); 513 client_->WillBeginImplFrame(begin_impl_frame_tracker_.Current());
511 514
512 ProcessScheduledActions(); 515 ProcessScheduledActions();
513 } 516 }
514 517
515 void Scheduler::ScheduleBeginImplFrameDeadline() { 518 void Scheduler::ScheduleBeginImplFrameDeadline() {
516 // The synchronous compositor does not post a deadline task. 519 // The synchronous compositor does not post a deadline task.
517 DCHECK(!settings_.using_synchronous_renderer_compositor); 520 DCHECK(!settings_.using_synchronous_renderer_compositor);
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 base::AutoReset<SchedulerStateMachine::Action> 639 base::AutoReset<SchedulerStateMachine::Action>
637 mark_inside_action(&inside_action_, action); 640 mark_inside_action(&inside_action_, action);
638 switch (action) { 641 switch (action) {
639 case SchedulerStateMachine::ACTION_NONE: 642 case SchedulerStateMachine::ACTION_NONE:
640 break; 643 break;
641 case SchedulerStateMachine::ACTION_ANIMATE: 644 case SchedulerStateMachine::ACTION_ANIMATE:
642 state_machine_.WillAnimate(); 645 state_machine_.WillAnimate();
643 client_->ScheduledActionAnimate(); 646 client_->ScheduledActionAnimate();
644 break; 647 break;
645 case SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME: 648 case SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME:
646 compositor_timing_history_->WillBeginMainFrame(); 649 compositor_timing_history_->WillBeginMainFrame(
650 begin_main_frame_args_.on_critical_path);
647 state_machine_.WillSendBeginMainFrame(); 651 state_machine_.WillSendBeginMainFrame();
652 // TODO(brianderson): Pass begin_main_frame_args_ directly to client.
648 client_->ScheduledActionSendBeginMainFrame(); 653 client_->ScheduledActionSendBeginMainFrame();
649 break; 654 break;
650 case SchedulerStateMachine::ACTION_COMMIT: { 655 case SchedulerStateMachine::ACTION_COMMIT: {
651 // TODO(robliao): Remove ScopedTracker below once crbug.com/461509 is 656 // TODO(robliao): Remove ScopedTracker below once crbug.com/461509 is
652 // fixed. 657 // fixed.
653 tracked_objects::ScopedTracker tracking_profile4( 658 tracked_objects::ScopedTracker tracking_profile4(
654 FROM_HERE_WITH_EXPLICIT_FUNCTION( 659 FROM_HERE_WITH_EXPLICIT_FUNCTION(
655 "461509 Scheduler::ProcessScheduledActions4")); 660 "461509 Scheduler::ProcessScheduledActions4"));
656 bool commit_has_no_updates = false; 661 bool commit_has_no_updates = false;
657 state_machine_.WillCommit(commit_has_no_updates); 662 state_machine_.WillCommit(commit_has_no_updates);
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
837 } 842 }
838 843
839 bool Scheduler::IsBeginMainFrameSentOrStarted() const { 844 bool Scheduler::IsBeginMainFrameSentOrStarted() const {
840 return (state_machine_.begin_main_frame_state() == 845 return (state_machine_.begin_main_frame_state() ==
841 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_SENT || 846 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_SENT ||
842 state_machine_.begin_main_frame_state() == 847 state_machine_.begin_main_frame_state() ==
843 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_STARTED); 848 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_STARTED);
844 } 849 }
845 850
846 } // namespace cc 851 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698