Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(928)

Side by Side Diff: cc/scheduler/scheduler.h

Issue 554973002: Disable scheduler deadline task on battery power in Windows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: After rebase Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | cc/scheduler/scheduler.cc » ('j') | cc/scheduler/scheduler.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/cancelable_callback.h" 12 #include "base/cancelable_callback.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/power_monitor/power_observer.h"
14 #include "base/time/time.h" 15 #include "base/time/time.h"
15 #include "cc/base/cc_export.h" 16 #include "cc/base/cc_export.h"
16 #include "cc/output/begin_frame_args.h" 17 #include "cc/output/begin_frame_args.h"
17 #include "cc/scheduler/delay_based_time_source.h" 18 #include "cc/scheduler/delay_based_time_source.h"
18 #include "cc/scheduler/draw_result.h" 19 #include "cc/scheduler/draw_result.h"
19 #include "cc/scheduler/scheduler_settings.h" 20 #include "cc/scheduler/scheduler_settings.h"
20 #include "cc/scheduler/scheduler_state_machine.h" 21 #include "cc/scheduler/scheduler_state_machine.h"
21 22
22 namespace base { 23 namespace base {
23 namespace debug { 24 namespace debug {
(...skipping 20 matching lines...) Expand all
44 virtual void DidAnticipatedDrawTimeChange(base::TimeTicks time) = 0; 45 virtual void DidAnticipatedDrawTimeChange(base::TimeTicks time) = 0;
45 virtual base::TimeDelta DrawDurationEstimate() = 0; 46 virtual base::TimeDelta DrawDurationEstimate() = 0;
46 virtual base::TimeDelta BeginMainFrameToCommitDurationEstimate() = 0; 47 virtual base::TimeDelta BeginMainFrameToCommitDurationEstimate() = 0;
47 virtual base::TimeDelta CommitToActivateDurationEstimate() = 0; 48 virtual base::TimeDelta CommitToActivateDurationEstimate() = 0;
48 virtual void DidBeginImplFrameDeadline() = 0; 49 virtual void DidBeginImplFrameDeadline() = 0;
49 50
50 protected: 51 protected:
51 virtual ~SchedulerClient() {} 52 virtual ~SchedulerClient() {}
52 }; 53 };
53 54
54 class CC_EXPORT Scheduler { 55 class CC_EXPORT Scheduler : public base::PowerObserver {
55 public: 56 public:
56 static scoped_ptr<Scheduler> Create( 57 static scoped_ptr<Scheduler> Create(
57 SchedulerClient* client, 58 SchedulerClient* client,
58 const SchedulerSettings& scheduler_settings, 59 const SchedulerSettings& scheduler_settings,
59 int layer_tree_host_id, 60 int layer_tree_host_id,
60 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) { 61 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) {
61 return make_scoped_ptr(new Scheduler( 62 return make_scoped_ptr(new Scheduler(
62 client, scheduler_settings, layer_tree_host_id, task_runner)); 63 client, scheduler_settings, layer_tree_host_id, task_runner));
63 } 64 }
64 65
65 virtual ~Scheduler(); 66 virtual ~Scheduler();
66 67
68 // base::PowerObserver method.
69 virtual void OnPowerStateChange(bool on_battery_power) OVERRIDE;
70
67 const SchedulerSettings& settings() const { return settings_; } 71 const SchedulerSettings& settings() const { return settings_; }
68 72
69 void CommitVSyncParameters(base::TimeTicks timebase, 73 void CommitVSyncParameters(base::TimeTicks timebase,
70 base::TimeDelta interval); 74 base::TimeDelta interval);
71 void SetEstimatedParentDrawTime(base::TimeDelta draw_time); 75 void SetEstimatedParentDrawTime(base::TimeDelta draw_time);
72 76
73 void SetCanStart(); 77 void SetCanStart();
74 78
75 void SetVisible(bool visible); 79 void SetVisible(bool visible);
76 void SetCanDraw(bool can_draw); 80 void SetCanDraw(bool can_draw);
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 base::Closure poll_for_draw_triggers_closure_; 195 base::Closure poll_for_draw_triggers_closure_;
192 base::Closure advance_commit_state_closure_; 196 base::Closure advance_commit_state_closure_;
193 base::CancelableClosure begin_impl_frame_deadline_task_; 197 base::CancelableClosure begin_impl_frame_deadline_task_;
194 base::CancelableClosure poll_for_draw_triggers_task_; 198 base::CancelableClosure poll_for_draw_triggers_task_;
195 base::CancelableClosure advance_commit_state_task_; 199 base::CancelableClosure advance_commit_state_task_;
196 200
197 SchedulerStateMachine state_machine_; 201 SchedulerStateMachine state_machine_;
198 bool inside_process_scheduled_actions_; 202 bool inside_process_scheduled_actions_;
199 SchedulerStateMachine::Action inside_action_; 203 SchedulerStateMachine::Action inside_action_;
200 204
205 bool on_battery_power_;
206
201 private: 207 private:
202 base::TimeTicks AdjustedBeginImplFrameDeadline( 208 base::TimeTicks AdjustedBeginImplFrameDeadline(
203 const BeginFrameArgs& args, 209 const BeginFrameArgs& args,
204 base::TimeDelta draw_duration_estimate) const; 210 base::TimeDelta draw_duration_estimate) const;
205 void ScheduleBeginImplFrameDeadline(base::TimeTicks deadline); 211 void ScheduleBeginImplFrameDeadline(base::TimeTicks deadline);
206 void SetupNextBeginFrameIfNeeded(); 212 void SetupNextBeginFrameIfNeeded();
207 void PostBeginRetroFrameIfNeeded(); 213 void PostBeginRetroFrameIfNeeded();
208 void SetupNextBeginFrameWhenVSyncThrottlingEnabled(bool needs_begin_frame); 214 void SetupNextBeginFrameWhenVSyncThrottlingEnabled(bool needs_begin_frame);
209 void SetupNextBeginFrameWhenVSyncThrottlingDisabled(bool needs_begin_frame); 215 void SetupNextBeginFrameWhenVSyncThrottlingDisabled(bool needs_begin_frame);
210 void SetupPollingMechanisms(bool needs_begin_frame); 216 void SetupPollingMechanisms(bool needs_begin_frame);
211 void DrawAndSwapIfPossible(); 217 void DrawAndSwapIfPossible();
212 void ProcessScheduledActions(); 218 void ProcessScheduledActions();
213 bool CanCommitAndActivateBeforeDeadline() const; 219 bool CanCommitAndActivateBeforeDeadline() const;
214 void AdvanceCommitStateIfPossible(); 220 void AdvanceCommitStateIfPossible();
215 bool IsBeginMainFrameSentOrStarted() const; 221 bool IsBeginMainFrameSentOrStarted() const;
216 void SetupSyntheticBeginFrames(); 222 void SetupSyntheticBeginFrames();
217 void BeginRetroFrame(); 223 void BeginRetroFrame();
218 void BeginUnthrottledFrame(); 224 void BeginUnthrottledFrame();
225 bool ShouldPostBeginImplFrameDeadline();
219 void BeginImplFrame(const BeginFrameArgs& args); 226 void BeginImplFrame(const BeginFrameArgs& args);
220 void OnBeginImplFrameDeadline(); 227 void OnBeginImplFrameDeadline();
221 void PollForAnticipatedDrawTriggers(); 228 void PollForAnticipatedDrawTriggers();
222 void PollToAdvanceCommitState(); 229 void PollToAdvanceCommitState();
230 void SetupPowerMonitoring();
231 void TeardownPowerMonitoring();
223 232
224 base::TimeDelta VSyncInterval() { return vsync_interval_; } 233 base::TimeDelta VSyncInterval() { return vsync_interval_; }
225 234
226 base::TimeDelta EstimatedParentDrawTime() { 235 base::TimeDelta EstimatedParentDrawTime() {
227 return estimated_parent_draw_time_; 236 return estimated_parent_draw_time_;
228 } 237 }
229 238
230 bool IsInsideAction(SchedulerStateMachine::Action action) { 239 bool IsInsideAction(SchedulerStateMachine::Action action) {
231 return inside_action_ == action; 240 return inside_action_ == action;
232 } 241 }
233 242
234 base::WeakPtrFactory<Scheduler> weak_factory_; 243 base::WeakPtrFactory<Scheduler> weak_factory_;
235 244
236 DISALLOW_COPY_AND_ASSIGN(Scheduler); 245 DISALLOW_COPY_AND_ASSIGN(Scheduler);
237 }; 246 };
238 247
239 } // namespace cc 248 } // namespace cc
240 249
241 #endif // CC_SCHEDULER_SCHEDULER_H_ 250 #endif // CC_SCHEDULER_SCHEDULER_H_
OLDNEW
« no previous file with comments | « no previous file | cc/scheduler/scheduler.cc » ('j') | cc/scheduler/scheduler.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698