| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 // This class exists to allow tests to override the frame source construction. | 58 // This class exists to allow tests to override the frame source construction. |
| 59 // A virtual method can't be used as this needs to happen in the constructor | 59 // A virtual method can't be used as this needs to happen in the constructor |
| 60 // (see C++ FAQ / Section 23 - http://goo.gl/fnrwom for why). | 60 // (see C++ FAQ / Section 23 - http://goo.gl/fnrwom for why). |
| 61 // This class exists solely long enough to construct the frame sources. | 61 // This class exists solely long enough to construct the frame sources. |
| 62 class CC_EXPORT SchedulerFrameSourcesConstructor { | 62 class CC_EXPORT SchedulerFrameSourcesConstructor { |
| 63 public: | 63 public: |
| 64 virtual ~SchedulerFrameSourcesConstructor() {} | 64 virtual ~SchedulerFrameSourcesConstructor() {} |
| 65 virtual BeginFrameSource* ConstructPrimaryFrameSource(Scheduler* scheduler); | 65 virtual BeginFrameSource* ConstructPrimaryFrameSource(Scheduler* scheduler); |
| 66 virtual BeginFrameSource* ConstructBackgroundFrameSource( | 66 virtual BeginFrameSource* ConstructBackgroundFrameSource( |
| 67 Scheduler* scheduler); | 67 Scheduler* scheduler); |
| 68 virtual BeginFrameSource* ConstructUnthrottledFrameSource( |
| 69 Scheduler* scheduler); |
| 68 | 70 |
| 69 protected: | 71 protected: |
| 70 SchedulerFrameSourcesConstructor() {} | 72 SchedulerFrameSourcesConstructor() {} |
| 71 | 73 |
| 72 friend class Scheduler; | 74 friend class Scheduler; |
| 73 }; | 75 }; |
| 74 | 76 |
| 75 class CC_EXPORT Scheduler : public BeginFrameObserverMixIn, | 77 class CC_EXPORT Scheduler : public BeginFrameObserverMixIn, |
| 76 public base::PowerObserver { | 78 public base::PowerObserver { |
| 77 public: | 79 public: |
| (...skipping 27 matching lines...) Expand all Loading... |
| 105 void CommitVSyncParameters(base::TimeTicks timebase, | 107 void CommitVSyncParameters(base::TimeTicks timebase, |
| 106 base::TimeDelta interval); | 108 base::TimeDelta interval); |
| 107 void SetEstimatedParentDrawTime(base::TimeDelta draw_time); | 109 void SetEstimatedParentDrawTime(base::TimeDelta draw_time); |
| 108 | 110 |
| 109 void SetCanStart(); | 111 void SetCanStart(); |
| 110 | 112 |
| 111 void SetVisible(bool visible); | 113 void SetVisible(bool visible); |
| 112 void SetCanDraw(bool can_draw); | 114 void SetCanDraw(bool can_draw); |
| 113 void NotifyReadyToActivate(); | 115 void NotifyReadyToActivate(); |
| 114 void NotifyReadyToDraw(); | 116 void NotifyReadyToDraw(); |
| 117 void SetThrottleFrameProduction(bool throttle); |
| 115 | 118 |
| 116 void SetNeedsCommit(); | 119 void SetNeedsCommit(); |
| 117 | 120 |
| 118 void SetNeedsRedraw(); | 121 void SetNeedsRedraw(); |
| 119 | 122 |
| 120 void SetNeedsAnimate(); | 123 void SetNeedsAnimate(); |
| 121 | 124 |
| 122 void SetNeedsPrepareTiles(); | 125 void SetNeedsPrepareTiles(); |
| 123 | 126 |
| 124 void SetMaxSwapsPending(int max); | 127 void SetMaxSwapsPending(int max); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 scoped_ptr<BeginFrameSource> external_begin_frame_source, | 180 scoped_ptr<BeginFrameSource> external_begin_frame_source, |
| 178 SchedulerFrameSourcesConstructor* frame_sources_constructor); | 181 SchedulerFrameSourcesConstructor* frame_sources_constructor); |
| 179 | 182 |
| 180 // virtual for testing - Don't call these in the constructor or | 183 // virtual for testing - Don't call these in the constructor or |
| 181 // destructor! | 184 // destructor! |
| 182 virtual base::TimeTicks Now() const; | 185 virtual base::TimeTicks Now() const; |
| 183 | 186 |
| 184 scoped_ptr<BeginFrameSourceMultiplexer> frame_source_; | 187 scoped_ptr<BeginFrameSourceMultiplexer> frame_source_; |
| 185 BeginFrameSource* primary_frame_source_; | 188 BeginFrameSource* primary_frame_source_; |
| 186 BeginFrameSource* background_frame_source_; | 189 BeginFrameSource* background_frame_source_; |
| 190 BeginFrameSource* unthrottled_frame_source_; |
| 187 | 191 |
| 188 // Storage when frame sources are internal | 192 // Storage when frame sources are internal |
| 189 scoped_ptr<BeginFrameSource> primary_frame_source_internal_; | 193 scoped_ptr<BeginFrameSource> primary_frame_source_internal_; |
| 190 scoped_ptr<SyntheticBeginFrameSource> background_frame_source_internal_; | 194 scoped_ptr<SyntheticBeginFrameSource> background_frame_source_internal_; |
| 195 scoped_ptr<BeginFrameSource> unthrottled_frame_source_internal_; |
| 191 | 196 |
| 192 VSyncParameterObserver* vsync_observer_; | 197 VSyncParameterObserver* vsync_observer_; |
| 198 bool throttle_frame_production_; |
| 193 | 199 |
| 194 const SchedulerSettings settings_; | 200 const SchedulerSettings settings_; |
| 195 SchedulerClient* client_; | 201 SchedulerClient* client_; |
| 196 int layer_tree_host_id_; | 202 int layer_tree_host_id_; |
| 197 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 203 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| 198 | 204 |
| 199 base::PowerMonitor* power_monitor_; | 205 base::PowerMonitor* power_monitor_; |
| 200 | 206 |
| 201 base::TimeDelta estimated_parent_draw_time_; | 207 base::TimeDelta estimated_parent_draw_time_; |
| 202 | 208 |
| 203 bool begin_retro_frame_posted_; | |
| 204 std::deque<BeginFrameArgs> begin_retro_frame_args_; | 209 std::deque<BeginFrameArgs> begin_retro_frame_args_; |
| 205 BeginFrameArgs begin_impl_frame_args_; | 210 BeginFrameArgs begin_impl_frame_args_; |
| 206 SchedulerStateMachine::BeginImplFrameDeadlineMode | 211 SchedulerStateMachine::BeginImplFrameDeadlineMode |
| 207 begin_impl_frame_deadline_mode_; | 212 begin_impl_frame_deadline_mode_; |
| 208 | 213 |
| 209 base::Closure begin_retro_frame_closure_; | 214 base::Closure begin_retro_frame_closure_; |
| 210 base::Closure begin_unthrottled_frame_closure_; | |
| 211 | |
| 212 base::Closure begin_impl_frame_deadline_closure_; | 215 base::Closure begin_impl_frame_deadline_closure_; |
| 213 base::Closure poll_for_draw_triggers_closure_; | 216 base::Closure poll_for_draw_triggers_closure_; |
| 214 base::Closure advance_commit_state_closure_; | 217 base::Closure advance_commit_state_closure_; |
| 218 base::CancelableClosure begin_retro_frame_task_; |
| 215 base::CancelableClosure begin_impl_frame_deadline_task_; | 219 base::CancelableClosure begin_impl_frame_deadline_task_; |
| 216 base::CancelableClosure poll_for_draw_triggers_task_; | 220 base::CancelableClosure poll_for_draw_triggers_task_; |
| 217 base::CancelableClosure advance_commit_state_task_; | 221 base::CancelableClosure advance_commit_state_task_; |
| 218 | 222 |
| 219 SchedulerStateMachine state_machine_; | 223 SchedulerStateMachine state_machine_; |
| 220 bool inside_process_scheduled_actions_; | 224 bool inside_process_scheduled_actions_; |
| 221 SchedulerStateMachine::Action inside_action_; | 225 SchedulerStateMachine::Action inside_action_; |
| 222 | 226 |
| 223 private: | 227 private: |
| 224 void ScheduleBeginImplFrameDeadline(); | 228 void ScheduleBeginImplFrameDeadline(); |
| 225 void RescheduleBeginImplFrameDeadlineIfNeeded(); | 229 void RescheduleBeginImplFrameDeadlineIfNeeded(); |
| 226 void SetupNextBeginFrameIfNeeded(); | 230 void SetupNextBeginFrameIfNeeded(); |
| 227 void PostBeginRetroFrameIfNeeded(); | 231 void PostBeginRetroFrameIfNeeded(); |
| 228 void SetupPollingMechanisms(bool needs_begin_frame); | 232 void SetupPollingMechanisms(); |
| 229 void DrawAndSwapIfPossible(); | 233 void DrawAndSwapIfPossible(); |
| 230 void ProcessScheduledActions(); | 234 void ProcessScheduledActions(); |
| 231 bool CanCommitAndActivateBeforeDeadline() const; | 235 bool CanCommitAndActivateBeforeDeadline() const; |
| 232 void AdvanceCommitStateIfPossible(); | 236 void AdvanceCommitStateIfPossible(); |
| 233 bool IsBeginMainFrameSentOrStarted() const; | 237 bool IsBeginMainFrameSentOrStarted() const; |
| 234 void BeginRetroFrame(); | 238 void BeginRetroFrame(); |
| 235 void BeginImplFrame(const BeginFrameArgs& args); | 239 void BeginImplFrame(const BeginFrameArgs& args); |
| 236 void OnBeginImplFrameDeadline(); | 240 void OnBeginImplFrameDeadline(); |
| 237 void PollForAnticipatedDrawTriggers(); | 241 void PollForAnticipatedDrawTriggers(); |
| 238 void PollToAdvanceCommitState(); | 242 void PollToAdvanceCommitState(); |
| 239 void SetupPowerMonitoring(); | 243 void SetupPowerMonitoring(); |
| 240 void TeardownPowerMonitoring(); | 244 void TeardownPowerMonitoring(); |
| 245 void UpdateActiveFrameSource(); |
| 241 | 246 |
| 242 base::TimeDelta EstimatedParentDrawTime() { | 247 base::TimeDelta EstimatedParentDrawTime() { |
| 243 return estimated_parent_draw_time_; | 248 return estimated_parent_draw_time_; |
| 244 } | 249 } |
| 245 | 250 |
| 246 bool IsInsideAction(SchedulerStateMachine::Action action) { | 251 bool IsInsideAction(SchedulerStateMachine::Action action) { |
| 247 return inside_action_ == action; | 252 return inside_action_ == action; |
| 248 } | 253 } |
| 249 | 254 |
| 250 base::WeakPtrFactory<Scheduler> weak_factory_; | 255 base::WeakPtrFactory<Scheduler> weak_factory_; |
| 251 | 256 |
| 252 friend class SchedulerFrameSourcesConstructor; | 257 friend class SchedulerFrameSourcesConstructor; |
| 253 friend class TestSchedulerFrameSourcesConstructor; | 258 friend class TestSchedulerFrameSourcesConstructor; |
| 254 | 259 |
| 255 DISALLOW_COPY_AND_ASSIGN(Scheduler); | 260 DISALLOW_COPY_AND_ASSIGN(Scheduler); |
| 256 }; | 261 }; |
| 257 | 262 |
| 258 } // namespace cc | 263 } // namespace cc |
| 259 | 264 |
| 260 #endif // CC_SCHEDULER_SCHEDULER_H_ | 265 #endif // CC_SCHEDULER_SCHEDULER_H_ |
| OLD | NEW |