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

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

Issue 723713003: cc: Add SetChildrenNeedBeginFrames() & SendBeginFramesToChildren() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More tests are added Created 6 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/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 } 391 }
392 } 392 }
393 393
394 // BeginFrame is the mechanism that tells us that now is a good time to start 394 // BeginFrame is the mechanism that tells us that now is a good time to start
395 // making a frame. Usually this means that user input for the frame is complete. 395 // making a frame. Usually this means that user input for the frame is complete.
396 // If the scheduler is busy, we queue the BeginFrame to be handled later as 396 // If the scheduler is busy, we queue the BeginFrame to be handled later as
397 // a BeginRetroFrame. 397 // a BeginRetroFrame.
398 bool Scheduler::OnBeginFrameMixInDelegate(const BeginFrameArgs& args) { 398 bool Scheduler::OnBeginFrameMixInDelegate(const BeginFrameArgs& args) {
399 TRACE_EVENT1("cc", "Scheduler::BeginFrame", "args", args.AsValue()); 399 TRACE_EVENT1("cc", "Scheduler::BeginFrame", "args", args.AsValue());
400 400
401 // Deliver BeginFrames to children.
402 if (settings_.forward_begin_frames_to_children &&
403 state_machine_.children_need_begin_frames()) {
404 BeginFrameArgs adjusted_args_for_children(args);
405 // Adjust a deadline for child schedulers.
406 // TODO(simonhong): Once we have commitless update, we can get rid of
407 // BeginMainFrameToCommitDurationEstimate() +
408 // CommitToActivateDurationEstimate().
409 adjusted_args_for_children.deadline -=
410 (client_->BeginMainFrameToCommitDurationEstimate() +
411 client_->CommitToActivateDurationEstimate() +
412 client_->DrawDurationEstimate() + EstimatedParentDrawTime());
413 client_->SendBeginFramesToChildren(adjusted_args_for_children);
414 }
415
401 // We have just called SetNeedsBeginFrame(true) and the BeginFrameSource has 416 // We have just called SetNeedsBeginFrame(true) and the BeginFrameSource has
402 // sent us the last BeginFrame we have missed. As we might not be able to 417 // sent us the last BeginFrame we have missed. As we might not be able to
403 // actually make rendering for this call, handle it like a "retro frame". 418 // actually make rendering for this call, handle it like a "retro frame".
404 // TODO(brainderson): Add a test for this functionality ASAP! 419 // TODO(brainderson): Add a test for this functionality ASAP!
405 if (args.type == BeginFrameArgs::MISSED) { 420 if (args.type == BeginFrameArgs::MISSED) {
406 begin_retro_frame_args_.push_back(args); 421 begin_retro_frame_args_.push_back(args);
407 PostBeginRetroFrameIfNeeded(); 422 PostBeginRetroFrameIfNeeded();
408 return true; 423 return true;
409 } 424 }
410 425
(...skipping 15 matching lines...) Expand all
426 begin_retro_frame_args_.push_back(adjusted_args); 441 begin_retro_frame_args_.push_back(adjusted_args);
427 TRACE_EVENT_INSTANT0( 442 TRACE_EVENT_INSTANT0(
428 "cc", "Scheduler::BeginFrame deferred", TRACE_EVENT_SCOPE_THREAD); 443 "cc", "Scheduler::BeginFrame deferred", TRACE_EVENT_SCOPE_THREAD);
429 // Queuing the frame counts as "using it", so we need to return true. 444 // Queuing the frame counts as "using it", so we need to return true.
430 } else { 445 } else {
431 BeginImplFrame(adjusted_args); 446 BeginImplFrame(adjusted_args);
432 } 447 }
433 return true; 448 return true;
434 } 449 }
435 450
451 void Scheduler::SetChildrenNeedBeginFrames(bool children_need_begin_frames) {
452 DCHECK(settings_.forward_begin_frames_to_children);
453
454 state_machine_.SetChildrenNeedBeginFrames(children_need_begin_frames);
455 ProcessScheduledActions();
brianderson 2014/11/19 19:03:34 This should not trigger any new actions in the Bro
simonhong 2014/11/20 16:24:09 Done.
456 }
457
436 // BeginRetroFrame is called for BeginFrames that we've deferred because 458 // BeginRetroFrame is called for BeginFrames that we've deferred because
437 // the scheduler was in the middle of processing a previous BeginFrame. 459 // the scheduler was in the middle of processing a previous BeginFrame.
438 void Scheduler::BeginRetroFrame() { 460 void Scheduler::BeginRetroFrame() {
439 TRACE_EVENT0("cc", "Scheduler::BeginRetroFrame"); 461 TRACE_EVENT0("cc", "Scheduler::BeginRetroFrame");
440 DCHECK(!settings_.using_synchronous_renderer_compositor); 462 DCHECK(!settings_.using_synchronous_renderer_compositor);
441 DCHECK(begin_retro_frame_posted_); 463 DCHECK(begin_retro_frame_posted_);
442 begin_retro_frame_posted_ = false; 464 begin_retro_frame_posted_ = false;
443 465
444 // If there aren't any retroactive BeginFrames, then we've lost the 466 // If there aren't any retroactive BeginFrames, then we've lost the
445 // OutputSurface and should abort. 467 // OutputSurface and should abort.
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
784 } 806 }
785 807
786 bool Scheduler::IsBeginMainFrameSentOrStarted() const { 808 bool Scheduler::IsBeginMainFrameSentOrStarted() const {
787 return (state_machine_.commit_state() == 809 return (state_machine_.commit_state() ==
788 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT || 810 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT ||
789 state_machine_.commit_state() == 811 state_machine_.commit_state() ==
790 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED); 812 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED);
791 } 813 }
792 814
793 } // namespace cc 815 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698