| 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 #ifndef CC_SCHEDULER_SCHEDULER_H_ | 5 #ifndef CC_SCHEDULER_SCHEDULER_H_ |
| 6 #define CC_SCHEDULER_SCHEDULER_H_ | 6 #define CC_SCHEDULER_SCHEDULER_H_ |
| 7 | 7 |
| 8 #include <deque> | 8 #include <deque> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 scoped_refptr<base::debug::ConvertableToTraceFormat> AsValue() const; | 130 scoped_refptr<base::debug::ConvertableToTraceFormat> AsValue() const; |
| 131 | 131 |
| 132 void SetContinuousPainting(bool continuous_painting) { | 132 void SetContinuousPainting(bool continuous_painting) { |
| 133 state_machine_.SetContinuousPainting(continuous_painting); | 133 state_machine_.SetContinuousPainting(continuous_painting); |
| 134 } | 134 } |
| 135 | 135 |
| 136 protected: | 136 protected: |
| 137 class CC_EXPORT SyntheticBeginFrameSource : public TimeSourceClient { | 137 class CC_EXPORT SyntheticBeginFrameSource : public TimeSourceClient { |
| 138 public: | 138 public: |
| 139 SyntheticBeginFrameSource(Scheduler* scheduler, | 139 SyntheticBeginFrameSource(Scheduler* scheduler, |
| 140 base::SingleThreadTaskRunner* task_runner); | 140 scoped_refptr<DelayBasedTimeSource> time_source); |
| 141 virtual ~SyntheticBeginFrameSource(); | 141 virtual ~SyntheticBeginFrameSource(); |
| 142 | 142 |
| 143 // Updates the phase and frequency of the timer. | 143 // Updates the phase and frequency of the timer. |
| 144 void CommitVSyncParameters(base::TimeTicks timebase, | 144 void CommitVSyncParameters(base::TimeTicks timebase, |
| 145 base::TimeDelta interval); | 145 base::TimeDelta interval); |
| 146 | 146 |
| 147 // Activates future BeginFrames and, if activating, pushes the most | 147 // Activates future BeginFrames and, if activating, pushes the most |
| 148 // recently missed BeginFrame to the back of a retroactive queue. | 148 // recently missed BeginFrame to the back of a retroactive queue. |
| 149 void SetNeedsBeginFrame(bool needs_begin_frame, | 149 void SetNeedsBeginFrame(bool needs_begin_frame, |
| 150 std::deque<BeginFrameArgs>* begin_retro_frame_args); | 150 std::deque<BeginFrameArgs>* begin_retro_frame_args); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 161 | 161 |
| 162 Scheduler* scheduler_; | 162 Scheduler* scheduler_; |
| 163 scoped_refptr<DelayBasedTimeSource> time_source_; | 163 scoped_refptr<DelayBasedTimeSource> time_source_; |
| 164 }; | 164 }; |
| 165 | 165 |
| 166 Scheduler(SchedulerClient* client, | 166 Scheduler(SchedulerClient* client, |
| 167 const SchedulerSettings& scheduler_settings, | 167 const SchedulerSettings& scheduler_settings, |
| 168 int layer_tree_host_id, | 168 int layer_tree_host_id, |
| 169 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner); | 169 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner); |
| 170 | 170 |
| 171 virtual base::TimeTicks Now() const; |
| 172 |
| 171 const SchedulerSettings settings_; | 173 const SchedulerSettings settings_; |
| 172 SchedulerClient* client_; | 174 SchedulerClient* client_; |
| 173 int layer_tree_host_id_; | 175 int layer_tree_host_id_; |
| 174 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 176 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| 175 | 177 |
| 176 base::TimeDelta vsync_interval_; | 178 base::TimeDelta vsync_interval_; |
| 177 base::TimeDelta estimated_parent_draw_time_; | 179 base::TimeDelta estimated_parent_draw_time_; |
| 178 | 180 |
| 179 bool last_set_needs_begin_frame_; | 181 bool last_set_needs_begin_frame_; |
| 180 bool begin_unthrottled_frame_posted_; | 182 bool begin_unthrottled_frame_posted_; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 191 base::Closure poll_for_draw_triggers_closure_; | 193 base::Closure poll_for_draw_triggers_closure_; |
| 192 base::Closure advance_commit_state_closure_; | 194 base::Closure advance_commit_state_closure_; |
| 193 base::CancelableClosure begin_impl_frame_deadline_task_; | 195 base::CancelableClosure begin_impl_frame_deadline_task_; |
| 194 base::CancelableClosure poll_for_draw_triggers_task_; | 196 base::CancelableClosure poll_for_draw_triggers_task_; |
| 195 base::CancelableClosure advance_commit_state_task_; | 197 base::CancelableClosure advance_commit_state_task_; |
| 196 | 198 |
| 197 SchedulerStateMachine state_machine_; | 199 SchedulerStateMachine state_machine_; |
| 198 bool inside_process_scheduled_actions_; | 200 bool inside_process_scheduled_actions_; |
| 199 SchedulerStateMachine::Action inside_action_; | 201 SchedulerStateMachine::Action inside_action_; |
| 200 | 202 |
| 203 base::TimeDelta VSyncInterval() { return vsync_interval_; } |
| 204 |
| 201 private: | 205 private: |
| 202 base::TimeTicks AdjustedBeginImplFrameDeadline( | 206 base::TimeTicks AdjustedBeginImplFrameDeadline( |
| 203 const BeginFrameArgs& args, | 207 const BeginFrameArgs& args, |
| 204 base::TimeDelta draw_duration_estimate) const; | 208 base::TimeDelta draw_duration_estimate) const; |
| 205 void ScheduleBeginImplFrameDeadline(base::TimeTicks deadline); | 209 void ScheduleBeginImplFrameDeadline(base::TimeTicks deadline); |
| 206 void SetupNextBeginFrameIfNeeded(); | 210 void SetupNextBeginFrameIfNeeded(); |
| 207 void PostBeginRetroFrameIfNeeded(); | 211 void PostBeginRetroFrameIfNeeded(); |
| 208 void SetupNextBeginFrameWhenVSyncThrottlingEnabled(bool needs_begin_frame); | 212 void SetupNextBeginFrameWhenVSyncThrottlingEnabled(bool needs_begin_frame); |
| 209 void SetupNextBeginFrameWhenVSyncThrottlingDisabled(bool needs_begin_frame); | 213 void SetupNextBeginFrameWhenVSyncThrottlingDisabled(bool needs_begin_frame); |
| 210 void SetupPollingMechanisms(bool needs_begin_frame); | 214 void SetupPollingMechanisms(bool needs_begin_frame); |
| 211 void DrawAndSwapIfPossible(); | 215 void DrawAndSwapIfPossible(); |
| 212 void ProcessScheduledActions(); | 216 void ProcessScheduledActions(); |
| 213 bool CanCommitAndActivateBeforeDeadline() const; | 217 bool CanCommitAndActivateBeforeDeadline() const; |
| 214 void AdvanceCommitStateIfPossible(); | 218 void AdvanceCommitStateIfPossible(); |
| 215 bool IsBeginMainFrameSentOrStarted() const; | 219 bool IsBeginMainFrameSentOrStarted() const; |
| 216 void SetupSyntheticBeginFrames(); | 220 void SetupSyntheticBeginFrames(); |
| 217 void BeginRetroFrame(); | 221 void BeginRetroFrame(); |
| 218 void BeginUnthrottledFrame(); | 222 void BeginUnthrottledFrame(); |
| 219 void BeginImplFrame(const BeginFrameArgs& args); | 223 void BeginImplFrame(const BeginFrameArgs& args); |
| 220 void OnBeginImplFrameDeadline(); | 224 void OnBeginImplFrameDeadline(); |
| 221 void PollForAnticipatedDrawTriggers(); | 225 void PollForAnticipatedDrawTriggers(); |
| 222 void PollToAdvanceCommitState(); | 226 void PollToAdvanceCommitState(); |
| 223 | 227 |
| 224 base::TimeDelta VSyncInterval() { return vsync_interval_; } | |
| 225 | |
| 226 base::TimeDelta EstimatedParentDrawTime() { | 228 base::TimeDelta EstimatedParentDrawTime() { |
| 227 return estimated_parent_draw_time_; | 229 return estimated_parent_draw_time_; |
| 228 } | 230 } |
| 229 | 231 |
| 230 bool IsInsideAction(SchedulerStateMachine::Action action) { | 232 bool IsInsideAction(SchedulerStateMachine::Action action) { |
| 231 return inside_action_ == action; | 233 return inside_action_ == action; |
| 232 } | 234 } |
| 233 | 235 |
| 234 base::WeakPtrFactory<Scheduler> weak_factory_; | 236 base::WeakPtrFactory<Scheduler> weak_factory_; |
| 235 | 237 |
| 236 DISALLOW_COPY_AND_ASSIGN(Scheduler); | 238 DISALLOW_COPY_AND_ASSIGN(Scheduler); |
| 237 }; | 239 }; |
| 238 | 240 |
| 239 } // namespace cc | 241 } // namespace cc |
| 240 | 242 |
| 241 #endif // CC_SCHEDULER_SCHEDULER_H_ | 243 #endif // CC_SCHEDULER_SCHEDULER_H_ |
| OLD | NEW |