OLD | NEW |
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 Loading... |
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 Loading... |
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 state_machine_.SetChildrenNeedBeginFrames(children_need_begin_frames); |
| 454 DCHECK_EQ(state_machine_.NextAction(), SchedulerStateMachine::ACTION_NONE); |
| 455 } |
| 456 |
436 // BeginRetroFrame is called for BeginFrames that we've deferred because | 457 // BeginRetroFrame is called for BeginFrames that we've deferred because |
437 // the scheduler was in the middle of processing a previous BeginFrame. | 458 // the scheduler was in the middle of processing a previous BeginFrame. |
438 void Scheduler::BeginRetroFrame() { | 459 void Scheduler::BeginRetroFrame() { |
439 TRACE_EVENT0("cc", "Scheduler::BeginRetroFrame"); | 460 TRACE_EVENT0("cc", "Scheduler::BeginRetroFrame"); |
440 DCHECK(!settings_.using_synchronous_renderer_compositor); | 461 DCHECK(!settings_.using_synchronous_renderer_compositor); |
441 DCHECK(begin_retro_frame_posted_); | 462 DCHECK(begin_retro_frame_posted_); |
442 begin_retro_frame_posted_ = false; | 463 begin_retro_frame_posted_ = false; |
443 | 464 |
444 // If there aren't any retroactive BeginFrames, then we've lost the | 465 // If there aren't any retroactive BeginFrames, then we've lost the |
445 // OutputSurface and should abort. | 466 // OutputSurface and should abort. |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
784 } | 805 } |
785 | 806 |
786 bool Scheduler::IsBeginMainFrameSentOrStarted() const { | 807 bool Scheduler::IsBeginMainFrameSentOrStarted() const { |
787 return (state_machine_.commit_state() == | 808 return (state_machine_.commit_state() == |
788 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT || | 809 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT || |
789 state_machine_.commit_state() == | 810 state_machine_.commit_state() == |
790 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED); | 811 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED); |
791 } | 812 } |
792 | 813 |
793 } // namespace cc | 814 } // namespace cc |
OLD | NEW |