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 <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/cancelable_callback.h" |
11 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
12 #include "base/time/time.h" | 13 #include "base/time/time.h" |
13 #include "cc/base/cc_export.h" | 14 #include "cc/base/cc_export.h" |
14 #include "cc/output/begin_frame_args.h" | 15 #include "cc/output/begin_frame_args.h" |
15 #include "cc/scheduler/scheduler_settings.h" | 16 #include "cc/scheduler/scheduler_settings.h" |
16 #include "cc/scheduler/scheduler_state_machine.h" | 17 #include "cc/scheduler/scheduler_state_machine.h" |
17 #include "cc/trees/layer_tree_host.h" | 18 #include "cc/trees/layer_tree_host.h" |
18 | 19 |
19 namespace cc { | 20 namespace cc { |
20 | 21 |
(...skipping 18 matching lines...) Expand all Loading... |
39 virtual DrawSwapReadbackResult ScheduledActionDrawAndReadback() = 0; | 40 virtual DrawSwapReadbackResult ScheduledActionDrawAndReadback() = 0; |
40 virtual void ScheduledActionCommit() = 0; | 41 virtual void ScheduledActionCommit() = 0; |
41 virtual void ScheduledActionUpdateVisibleTiles() = 0; | 42 virtual void ScheduledActionUpdateVisibleTiles() = 0; |
42 virtual void ScheduledActionActivatePendingTree() = 0; | 43 virtual void ScheduledActionActivatePendingTree() = 0; |
43 virtual void ScheduledActionBeginOutputSurfaceCreation() = 0; | 44 virtual void ScheduledActionBeginOutputSurfaceCreation() = 0; |
44 virtual void ScheduledActionAcquireLayerTexturesForMainThread() = 0; | 45 virtual void ScheduledActionAcquireLayerTexturesForMainThread() = 0; |
45 virtual void DidAnticipatedDrawTimeChange(base::TimeTicks time) = 0; | 46 virtual void DidAnticipatedDrawTimeChange(base::TimeTicks time) = 0; |
46 virtual base::TimeDelta DrawDurationEstimate() = 0; | 47 virtual base::TimeDelta DrawDurationEstimate() = 0; |
47 virtual base::TimeDelta BeginFrameToCommitDurationEstimate() = 0; | 48 virtual base::TimeDelta BeginFrameToCommitDurationEstimate() = 0; |
48 virtual base::TimeDelta CommitToActivateDurationEstimate() = 0; | 49 virtual base::TimeDelta CommitToActivateDurationEstimate() = 0; |
| 50 virtual void PostBeginFrameDeadline(const base::Closure& closure, |
| 51 base::TimeTicks deadline) = 0; |
| 52 virtual void DidBeginFrameDeadlineOnImplThread() = 0; |
49 | 53 |
50 protected: | 54 protected: |
51 virtual ~SchedulerClient() {} | 55 virtual ~SchedulerClient() {} |
52 }; | 56 }; |
53 | 57 |
54 class CC_EXPORT Scheduler { | 58 class CC_EXPORT Scheduler { |
55 public: | 59 public: |
56 static scoped_ptr<Scheduler> Create( | 60 static scoped_ptr<Scheduler> Create( |
57 SchedulerClient* client, | 61 SchedulerClient* client, |
58 const SchedulerSettings& scheduler_settings) { | 62 const SchedulerSettings& scheduler_settings) { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 bool CommitPending() const { return state_machine_.CommitPending(); } | 95 bool CommitPending() const { return state_machine_.CommitPending(); } |
92 bool RedrawPending() const { return state_machine_.RedrawPending(); } | 96 bool RedrawPending() const { return state_machine_.RedrawPending(); } |
93 | 97 |
94 bool WillDrawIfNeeded() const; | 98 bool WillDrawIfNeeded() const; |
95 | 99 |
96 base::TimeTicks AnticipatedDrawTime(); | 100 base::TimeTicks AnticipatedDrawTime(); |
97 | 101 |
98 base::TimeTicks LastBeginFrameOnImplThreadTime(); | 102 base::TimeTicks LastBeginFrameOnImplThreadTime(); |
99 | 103 |
100 void BeginFrame(const BeginFrameArgs& args); | 104 void BeginFrame(const BeginFrameArgs& args); |
| 105 void OnBeginFrameDeadline(); |
101 void PollForAnticipatedDrawTriggers(); | 106 void PollForAnticipatedDrawTriggers(); |
102 | 107 |
103 scoped_ptr<base::Value> StateAsValue() { | 108 scoped_ptr<base::Value> StateAsValue() { |
104 return state_machine_.AsValue().Pass(); | 109 return state_machine_.AsValue().Pass(); |
105 } | 110 } |
106 | 111 |
107 private: | 112 private: |
108 Scheduler(SchedulerClient* client, | 113 Scheduler(SchedulerClient* client, |
109 const SchedulerSettings& scheduler_settings); | 114 const SchedulerSettings& scheduler_settings); |
110 | 115 |
| 116 void PostBeginFrameDeadline(base::TimeTicks deadline); |
111 void SetupNextBeginFrameIfNeeded(); | 117 void SetupNextBeginFrameIfNeeded(); |
| 118 void ActivatePendingTree(); |
112 void DrawAndSwapIfPossible(); | 119 void DrawAndSwapIfPossible(); |
113 void DrawAndSwapForced(); | 120 void DrawAndSwapForced(); |
114 void DrawAndReadback(); | 121 void DrawAndReadback(); |
115 void ProcessScheduledActions(); | 122 void ProcessScheduledActions(); |
116 | 123 |
117 const SchedulerSettings settings_; | 124 const SchedulerSettings settings_; |
118 SchedulerClient* client_; | 125 SchedulerClient* client_; |
119 | 126 |
120 base::WeakPtrFactory<Scheduler> weak_factory_; | 127 base::WeakPtrFactory<Scheduler> weak_factory_; |
121 bool last_set_needs_begin_frame_; | 128 bool last_set_needs_begin_frame_; |
122 bool has_pending_begin_frame_; | 129 int begin_frame_did_not_swap_count_; |
123 BeginFrameArgs last_begin_frame_args_; | 130 BeginFrameArgs last_begin_frame_args_; |
| 131 base::CancelableClosure begin_frame_deadline_closure_; |
124 base::CancelableClosure poll_for_draw_triggers_closure_; | 132 base::CancelableClosure poll_for_draw_triggers_closure_; |
125 | 133 |
126 SchedulerStateMachine state_machine_; | 134 SchedulerStateMachine state_machine_; |
127 bool inside_process_scheduled_actions_; | 135 bool inside_process_scheduled_actions_; |
128 | 136 |
129 DISALLOW_COPY_AND_ASSIGN(Scheduler); | 137 DISALLOW_COPY_AND_ASSIGN(Scheduler); |
130 }; | 138 }; |
131 | 139 |
132 } // namespace cc | 140 } // namespace cc |
133 | 141 |
134 #endif // CC_SCHEDULER_SCHEDULER_H_ | 142 #endif // CC_SCHEDULER_SCHEDULER_H_ |
OLD | NEW |