| 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 12 matching lines...) Expand all Loading... |
| 23 | 23 |
| 24 namespace base { | 24 namespace base { |
| 25 namespace trace_event { | 25 namespace trace_event { |
| 26 class ConvertableToTraceFormat; | 26 class ConvertableToTraceFormat; |
| 27 } | 27 } |
| 28 class SingleThreadTaskRunner; | 28 class SingleThreadTaskRunner; |
| 29 } | 29 } |
| 30 | 30 |
| 31 namespace cc { | 31 namespace cc { |
| 32 | 32 |
| 33 class CompositorTimingHistory; |
| 34 |
| 33 class SchedulerClient { | 35 class SchedulerClient { |
| 34 public: | 36 public: |
| 35 virtual void WillBeginImplFrame(const BeginFrameArgs& args) = 0; | 37 virtual void WillBeginImplFrame(const BeginFrameArgs& args) = 0; |
| 36 virtual void ScheduledActionSendBeginMainFrame() = 0; | 38 virtual void ScheduledActionSendBeginMainFrame() = 0; |
| 37 virtual DrawResult ScheduledActionDrawAndSwapIfPossible() = 0; | 39 virtual DrawResult ScheduledActionDrawAndSwapIfPossible() = 0; |
| 38 virtual DrawResult ScheduledActionDrawAndSwapForced() = 0; | 40 virtual DrawResult ScheduledActionDrawAndSwapForced() = 0; |
| 39 virtual void ScheduledActionAnimate() = 0; | 41 virtual void ScheduledActionAnimate() = 0; |
| 40 virtual void ScheduledActionCommit() = 0; | 42 virtual void ScheduledActionCommit() = 0; |
| 41 virtual void ScheduledActionActivateSyncTree() = 0; | 43 virtual void ScheduledActionActivateSyncTree() = 0; |
| 42 virtual void ScheduledActionBeginOutputSurfaceCreation() = 0; | 44 virtual void ScheduledActionBeginOutputSurfaceCreation() = 0; |
| 43 virtual void ScheduledActionPrepareTiles() = 0; | 45 virtual void ScheduledActionPrepareTiles() = 0; |
| 44 virtual void ScheduledActionInvalidateOutputSurface() = 0; | 46 virtual void ScheduledActionInvalidateOutputSurface() = 0; |
| 45 virtual base::TimeDelta DrawDurationEstimate() = 0; | |
| 46 virtual base::TimeDelta BeginMainFrameToCommitDurationEstimate() = 0; | |
| 47 virtual base::TimeDelta CommitToActivateDurationEstimate() = 0; | |
| 48 virtual void DidFinishImplFrame() = 0; | 47 virtual void DidFinishImplFrame() = 0; |
| 49 virtual void SendBeginFramesToChildren(const BeginFrameArgs& args) = 0; | 48 virtual void SendBeginFramesToChildren(const BeginFrameArgs& args) = 0; |
| 50 virtual void SendBeginMainFrameNotExpectedSoon() = 0; | 49 virtual void SendBeginMainFrameNotExpectedSoon() = 0; |
| 51 | 50 |
| 52 protected: | 51 protected: |
| 53 virtual ~SchedulerClient() {} | 52 virtual ~SchedulerClient() {} |
| 54 }; | 53 }; |
| 55 | 54 |
| 56 class CC_EXPORT Scheduler : public BeginFrameObserverBase { | 55 class CC_EXPORT Scheduler : public BeginFrameObserverBase { |
| 57 public: | 56 public: |
| 58 static scoped_ptr<Scheduler> Create( | 57 static scoped_ptr<Scheduler> Create( |
| 59 SchedulerClient* client, | 58 SchedulerClient* client, |
| 60 const SchedulerSettings& scheduler_settings, | 59 const SchedulerSettings& scheduler_settings, |
| 61 int layer_tree_host_id, | 60 int layer_tree_host_id, |
| 62 base::SingleThreadTaskRunner* task_runner, | 61 base::SingleThreadTaskRunner* task_runner, |
| 63 BeginFrameSource* external_frame_source); | 62 BeginFrameSource* external_frame_source, |
| 63 scoped_ptr<CompositorTimingHistory> compositor_timing_history); |
| 64 | 64 |
| 65 ~Scheduler() override; | 65 ~Scheduler() override; |
| 66 | 66 |
| 67 // BeginFrameObserverBase | 67 // BeginFrameObserverBase |
| 68 bool OnBeginFrameDerivedImpl(const BeginFrameArgs& args) override; | 68 bool OnBeginFrameDerivedImpl(const BeginFrameArgs& args) override; |
| 69 | 69 |
| 70 void OnDrawForOutputSurface(); | 70 void OnDrawForOutputSurface(); |
| 71 | 71 |
| 72 const SchedulerSettings& settings() const { return settings_; } | 72 const SchedulerSettings& settings() const { return settings_; } |
| 73 | 73 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 | 146 |
| 147 void SetAuthoritativeVSyncInterval(const base::TimeDelta& interval); | 147 void SetAuthoritativeVSyncInterval(const base::TimeDelta& interval); |
| 148 | 148 |
| 149 protected: | 149 protected: |
| 150 Scheduler(SchedulerClient* client, | 150 Scheduler(SchedulerClient* client, |
| 151 const SchedulerSettings& scheduler_settings, | 151 const SchedulerSettings& scheduler_settings, |
| 152 int layer_tree_host_id, | 152 int layer_tree_host_id, |
| 153 base::SingleThreadTaskRunner* task_runner, | 153 base::SingleThreadTaskRunner* task_runner, |
| 154 BeginFrameSource* external_frame_source, | 154 BeginFrameSource* external_frame_source, |
| 155 scoped_ptr<SyntheticBeginFrameSource> synthetic_frame_source, | 155 scoped_ptr<SyntheticBeginFrameSource> synthetic_frame_source, |
| 156 scoped_ptr<BackToBackBeginFrameSource> unthrottled_frame_source); | 156 scoped_ptr<BackToBackBeginFrameSource> unthrottled_frame_source, |
| 157 scoped_ptr<CompositorTimingHistory> compositor_timing_history); |
| 157 | 158 |
| 158 // virtual for testing - Don't call these in the constructor or | 159 // Virtual for testing. |
| 159 // destructor! | |
| 160 virtual base::TimeTicks Now() const; | 160 virtual base::TimeTicks Now() const; |
| 161 | 161 |
| 162 const SchedulerSettings settings_; | 162 const SchedulerSettings settings_; |
| 163 SchedulerClient* client_; | 163 SchedulerClient* client_; |
| 164 int layer_tree_host_id_; | 164 int layer_tree_host_id_; |
| 165 base::SingleThreadTaskRunner* task_runner_; | 165 base::SingleThreadTaskRunner* task_runner_; |
| 166 BeginFrameSource* external_frame_source_; | 166 BeginFrameSource* external_frame_source_; |
| 167 scoped_ptr<SyntheticBeginFrameSource> synthetic_frame_source_; | 167 scoped_ptr<SyntheticBeginFrameSource> synthetic_frame_source_; |
| 168 scoped_ptr<BackToBackBeginFrameSource> unthrottled_frame_source_; | 168 scoped_ptr<BackToBackBeginFrameSource> unthrottled_frame_source_; |
| 169 | 169 |
| 170 scoped_ptr<BeginFrameSourceMultiplexer> frame_source_; | 170 scoped_ptr<BeginFrameSourceMultiplexer> frame_source_; |
| 171 bool throttle_frame_production_; | 171 bool throttle_frame_production_; |
| 172 | 172 |
| 173 base::TimeDelta authoritative_vsync_interval_; | 173 base::TimeDelta authoritative_vsync_interval_; |
| 174 base::TimeTicks last_vsync_timebase_; | 174 base::TimeTicks last_vsync_timebase_; |
| 175 | 175 |
| 176 scoped_ptr<CompositorTimingHistory> compositor_timing_history_; |
| 176 base::TimeDelta estimated_parent_draw_time_; | 177 base::TimeDelta estimated_parent_draw_time_; |
| 177 | 178 |
| 178 std::deque<BeginFrameArgs> begin_retro_frame_args_; | 179 std::deque<BeginFrameArgs> begin_retro_frame_args_; |
| 179 SchedulerStateMachine::BeginImplFrameDeadlineMode | 180 SchedulerStateMachine::BeginImplFrameDeadlineMode |
| 180 begin_impl_frame_deadline_mode_; | 181 begin_impl_frame_deadline_mode_; |
| 181 BeginFrameTracker begin_impl_frame_tracker_; | 182 BeginFrameTracker begin_impl_frame_tracker_; |
| 182 | 183 |
| 183 base::Closure begin_retro_frame_closure_; | 184 base::Closure begin_retro_frame_closure_; |
| 184 base::Closure begin_impl_frame_deadline_closure_; | 185 base::Closure begin_impl_frame_deadline_closure_; |
| 185 base::CancelableClosure begin_retro_frame_task_; | 186 base::CancelableClosure begin_retro_frame_task_; |
| 186 base::CancelableClosure begin_impl_frame_deadline_task_; | 187 base::CancelableClosure begin_impl_frame_deadline_task_; |
| 187 | 188 |
| 188 SchedulerStateMachine state_machine_; | 189 SchedulerStateMachine state_machine_; |
| 189 bool inside_process_scheduled_actions_; | 190 bool inside_process_scheduled_actions_; |
| 190 SchedulerStateMachine::Action inside_action_; | 191 SchedulerStateMachine::Action inside_action_; |
| 191 | 192 |
| 192 private: | 193 private: |
| 193 void ScheduleBeginImplFrameDeadline(); | 194 void ScheduleBeginImplFrameDeadline(); |
| 194 void ScheduleBeginImplFrameDeadlineIfNeeded(); | 195 void ScheduleBeginImplFrameDeadlineIfNeeded(); |
| 195 void SetupNextBeginFrameIfNeeded(); | 196 void SetupNextBeginFrameIfNeeded(); |
| 196 void PostBeginRetroFrameIfNeeded(); | 197 void PostBeginRetroFrameIfNeeded(); |
| 197 void DrawAndSwapIfPossible(); | 198 void DrawAndSwapIfPossible(); |
| 199 void DrawAndSwapForced(); |
| 198 void ProcessScheduledActions(); | 200 void ProcessScheduledActions(); |
| 199 bool CanCommitAndActivateBeforeDeadline() const; | 201 bool CanCommitAndActivateBeforeDeadline() const; |
| 200 void AdvanceCommitStateIfPossible(); | 202 void AdvanceCommitStateIfPossible(); |
| 201 bool IsBeginMainFrameSentOrStarted() const; | 203 bool IsBeginMainFrameSentOrStarted() const; |
| 202 void BeginRetroFrame(); | 204 void BeginRetroFrame(); |
| 203 void BeginImplFrameWithDeadline(const BeginFrameArgs& args); | 205 void BeginImplFrameWithDeadline(const BeginFrameArgs& args); |
| 204 void BeginImplFrameSynchronous(const BeginFrameArgs& args); | 206 void BeginImplFrameSynchronous(const BeginFrameArgs& args); |
| 205 void BeginImplFrame(const BeginFrameArgs& args); | 207 void BeginImplFrame(const BeginFrameArgs& args); |
| 206 void FinishImplFrame(); | 208 void FinishImplFrame(); |
| 207 void OnBeginImplFrameDeadline(); | 209 void OnBeginImplFrameDeadline(); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 224 } | 226 } |
| 225 | 227 |
| 226 base::WeakPtrFactory<Scheduler> weak_factory_; | 228 base::WeakPtrFactory<Scheduler> weak_factory_; |
| 227 | 229 |
| 228 DISALLOW_COPY_AND_ASSIGN(Scheduler); | 230 DISALLOW_COPY_AND_ASSIGN(Scheduler); |
| 229 }; | 231 }; |
| 230 | 232 |
| 231 } // namespace cc | 233 } // namespace cc |
| 232 | 234 |
| 233 #endif // CC_SCHEDULER_SCHEDULER_H_ | 235 #endif // CC_SCHEDULER_SCHEDULER_H_ |
| OLD | NEW |