| 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/logging.h" | 10 #include "base/logging.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 return scheduler->unthrottled_frame_source_internal_.get(); | 59 return scheduler->unthrottled_frame_source_internal_.get(); |
| 60 } | 60 } |
| 61 | 61 |
| 62 Scheduler::Scheduler( | 62 Scheduler::Scheduler( |
| 63 SchedulerClient* client, | 63 SchedulerClient* client, |
| 64 const SchedulerSettings& scheduler_settings, | 64 const SchedulerSettings& scheduler_settings, |
| 65 int layer_tree_host_id, | 65 int layer_tree_host_id, |
| 66 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, | 66 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, |
| 67 scoped_ptr<BeginFrameSource> external_begin_frame_source, | 67 scoped_ptr<BeginFrameSource> external_begin_frame_source, |
| 68 SchedulerFrameSourcesConstructor* frame_sources_constructor) | 68 SchedulerFrameSourcesConstructor* frame_sources_constructor) |
| 69 : frame_source_(), | 69 : begin_frame_count_(0), |
| 70 frame_source_(), |
| 70 primary_frame_source_(NULL), | 71 primary_frame_source_(NULL), |
| 71 primary_frame_source_internal_(external_begin_frame_source.Pass()), | 72 primary_frame_source_internal_(external_begin_frame_source.Pass()), |
| 72 vsync_observer_(NULL), | 73 vsync_observer_(NULL), |
| 73 authoritative_vsync_interval_(base::TimeDelta()), | 74 authoritative_vsync_interval_(base::TimeDelta()), |
| 74 last_vsync_timebase_(base::TimeTicks()), | 75 last_vsync_timebase_(base::TimeTicks()), |
| 75 throttle_frame_production_(false), | 76 throttle_frame_production_(false), |
| 76 settings_(scheduler_settings), | 77 settings_(scheduler_settings), |
| 77 client_(client), | 78 client_(client), |
| 78 layer_tree_host_id_(layer_tree_host_id), | 79 layer_tree_host_id_(layer_tree_host_id), |
| 79 task_runner_(task_runner), | 80 task_runner_(task_runner), |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 } | 334 } |
| 334 } | 335 } |
| 335 | 336 |
| 336 // BeginFrame is the mechanism that tells us that now is a good time to start | 337 // BeginFrame is the mechanism that tells us that now is a good time to start |
| 337 // making a frame. Usually this means that user input for the frame is complete. | 338 // making a frame. Usually this means that user input for the frame is complete. |
| 338 // If the scheduler is busy, we queue the BeginFrame to be handled later as | 339 // If the scheduler is busy, we queue the BeginFrame to be handled later as |
| 339 // a BeginRetroFrame. | 340 // a BeginRetroFrame. |
| 340 bool Scheduler::OnBeginFrameMixInDelegate(const BeginFrameArgs& args) { | 341 bool Scheduler::OnBeginFrameMixInDelegate(const BeginFrameArgs& args) { |
| 341 TRACE_EVENT1("cc,benchmark", "Scheduler::BeginFrame", "args", args.AsValue()); | 342 TRACE_EVENT1("cc,benchmark", "Scheduler::BeginFrame", "args", args.AsValue()); |
| 342 | 343 |
| 344 bool in_renderer = !settings_.main_thread_should_always_be_low_latency; |
| 345 if (in_renderer) { |
| 346 const int kFramesToSkip = 1; |
| 347 begin_frame_count_++; |
| 348 if (begin_frame_count_ <= kFramesToSkip) |
| 349 return false; |
| 350 begin_frame_count_ = 0; |
| 351 } |
| 352 |
| 343 // Deliver BeginFrames to children. | 353 // Deliver BeginFrames to children. |
| 344 if (state_machine_.children_need_begin_frames()) { | 354 if (state_machine_.children_need_begin_frames()) { |
| 345 BeginFrameArgs adjusted_args_for_children(args); | 355 BeginFrameArgs adjusted_args_for_children(args); |
| 346 // Adjust a deadline for child schedulers. | 356 // Adjust a deadline for child schedulers. |
| 347 // TODO(simonhong): Once we have commitless update, we can get rid of | 357 // TODO(simonhong): Once we have commitless update, we can get rid of |
| 348 // BeginMainFrameToCommitDurationEstimate() + | 358 // BeginMainFrameToCommitDurationEstimate() + |
| 349 // CommitToActivateDurationEstimate(). | 359 // CommitToActivateDurationEstimate(). |
| 350 adjusted_args_for_children.deadline -= | 360 adjusted_args_for_children.deadline -= |
| 351 (client_->BeginMainFrameToCommitDurationEstimate() + | 361 (client_->BeginMainFrameToCommitDurationEstimate() + |
| 352 client_->CommitToActivateDurationEstimate() + | 362 client_->CommitToActivateDurationEstimate() + |
| (...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 830 } | 840 } |
| 831 | 841 |
| 832 bool Scheduler::IsBeginMainFrameSentOrStarted() const { | 842 bool Scheduler::IsBeginMainFrameSentOrStarted() const { |
| 833 return (state_machine_.commit_state() == | 843 return (state_machine_.commit_state() == |
| 834 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT || | 844 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT || |
| 835 state_machine_.commit_state() == | 845 state_machine_.commit_state() == |
| 836 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED); | 846 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED); |
| 837 } | 847 } |
| 838 | 848 |
| 839 } // namespace cc | 849 } // namespace cc |
| OLD | NEW |