| 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 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 } | 386 } |
| 387 } | 387 } |
| 388 | 388 |
| 389 // BeginFrame is the mechanism that tells us that now is a good time to start | 389 // BeginFrame is the mechanism that tells us that now is a good time to start |
| 390 // making a frame. Usually this means that user input for the frame is complete. | 390 // making a frame. Usually this means that user input for the frame is complete. |
| 391 // If the scheduler is busy, we queue the BeginFrame to be handled later as | 391 // If the scheduler is busy, we queue the BeginFrame to be handled later as |
| 392 // a BeginRetroFrame. | 392 // a BeginRetroFrame. |
| 393 bool Scheduler::OnBeginFrameMixInDelegate(const BeginFrameArgs& args) { | 393 bool Scheduler::OnBeginFrameMixInDelegate(const BeginFrameArgs& args) { |
| 394 TRACE_EVENT1("cc", "Scheduler::BeginFrame", "args", args.AsValue()); | 394 TRACE_EVENT1("cc", "Scheduler::BeginFrame", "args", args.AsValue()); |
| 395 | 395 |
| 396 // Deliver BeginFrames to children. |
| 397 if (settings_.forward_begin_frames_to_children && |
| 398 state_machine_.children_need_begin_frames()) { |
| 399 BeginFrameArgs adjusted_args_for_children(args); |
| 400 // Adjust a deadline for child schedulers. |
| 401 // TODO(simonhong): Once we have commitless update, we can get rid of |
| 402 // BeginMainFrameToCommitDurationEstimate() + |
| 403 // CommitToActivateDurationEstimate(). |
| 404 adjusted_args_for_children.deadline -= |
| 405 (client_->BeginMainFrameToCommitDurationEstimate() + |
| 406 client_->CommitToActivateDurationEstimate() + |
| 407 client_->DrawDurationEstimate() + EstimatedParentDrawTime()); |
| 408 client_->SendBeginFramesToChildren(adjusted_args_for_children); |
| 409 } |
| 410 |
| 396 // We have just called SetNeedsBeginFrame(true) and the BeginFrameSource has | 411 // We have just called SetNeedsBeginFrame(true) and the BeginFrameSource has |
| 397 // sent us the last BeginFrame we have missed. As we might not be able to | 412 // sent us the last BeginFrame we have missed. As we might not be able to |
| 398 // actually make rendering for this call, handle it like a "retro frame". | 413 // actually make rendering for this call, handle it like a "retro frame". |
| 399 // TODO(brainderson): Add a test for this functionality ASAP! | 414 // TODO(brainderson): Add a test for this functionality ASAP! |
| 400 if (args.type == BeginFrameArgs::MISSED) { | 415 if (args.type == BeginFrameArgs::MISSED) { |
| 401 begin_retro_frame_args_.push_back(args); | 416 begin_retro_frame_args_.push_back(args); |
| 402 PostBeginRetroFrameIfNeeded(); | 417 PostBeginRetroFrameIfNeeded(); |
| 403 return true; | 418 return true; |
| 404 } | 419 } |
| 405 | 420 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 421 begin_retro_frame_args_.push_back(adjusted_args); | 436 begin_retro_frame_args_.push_back(adjusted_args); |
| 422 TRACE_EVENT_INSTANT0( | 437 TRACE_EVENT_INSTANT0( |
| 423 "cc", "Scheduler::BeginFrame deferred", TRACE_EVENT_SCOPE_THREAD); | 438 "cc", "Scheduler::BeginFrame deferred", TRACE_EVENT_SCOPE_THREAD); |
| 424 // Queuing the frame counts as "using it", so we need to return true. | 439 // Queuing the frame counts as "using it", so we need to return true. |
| 425 } else { | 440 } else { |
| 426 BeginImplFrame(adjusted_args); | 441 BeginImplFrame(adjusted_args); |
| 427 } | 442 } |
| 428 return true; | 443 return true; |
| 429 } | 444 } |
| 430 | 445 |
| 446 void Scheduler::SetChildrenNeedBeginFrames(bool children_need_begin_frames) { |
| 447 DCHECK(settings_.forward_begin_frames_to_children); |
| 448 state_machine_.SetChildrenNeedBeginFrames(children_need_begin_frames); |
| 449 DCHECK_EQ(state_machine_.NextAction(), SchedulerStateMachine::ACTION_NONE); |
| 450 } |
| 451 |
| 431 // BeginRetroFrame is called for BeginFrames that we've deferred because | 452 // BeginRetroFrame is called for BeginFrames that we've deferred because |
| 432 // the scheduler was in the middle of processing a previous BeginFrame. | 453 // the scheduler was in the middle of processing a previous BeginFrame. |
| 433 void Scheduler::BeginRetroFrame() { | 454 void Scheduler::BeginRetroFrame() { |
| 434 TRACE_EVENT0("cc", "Scheduler::BeginRetroFrame"); | 455 TRACE_EVENT0("cc", "Scheduler::BeginRetroFrame"); |
| 435 DCHECK(!settings_.using_synchronous_renderer_compositor); | 456 DCHECK(!settings_.using_synchronous_renderer_compositor); |
| 436 DCHECK(begin_retro_frame_posted_); | 457 DCHECK(begin_retro_frame_posted_); |
| 437 begin_retro_frame_posted_ = false; | 458 begin_retro_frame_posted_ = false; |
| 438 | 459 |
| 439 // If there aren't any retroactive BeginFrames, then we've lost the | 460 // If there aren't any retroactive BeginFrames, then we've lost the |
| 440 // OutputSurface and should abort. | 461 // OutputSurface and should abort. |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 777 } | 798 } |
| 778 | 799 |
| 779 bool Scheduler::IsBeginMainFrameSentOrStarted() const { | 800 bool Scheduler::IsBeginMainFrameSentOrStarted() const { |
| 780 return (state_machine_.commit_state() == | 801 return (state_machine_.commit_state() == |
| 781 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT || | 802 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT || |
| 782 state_machine_.commit_state() == | 803 state_machine_.commit_state() == |
| 783 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED); | 804 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED); |
| 784 } | 805 } |
| 785 | 806 |
| 786 } // namespace cc | 807 } // namespace cc |
| OLD | NEW |