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/cancelable_callback.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
14 #include "cc/base/cc_export.h" | 14 #include "cc/base/cc_export.h" |
15 #include "cc/output/begin_frame_args.h" | 15 #include "cc/output/begin_frame_args.h" |
16 #include "cc/scheduler/draw_swap_readback_result.h" | 16 #include "cc/scheduler/draw_swap_readback_result.h" |
17 #include "cc/scheduler/scheduler_settings.h" | 17 #include "cc/scheduler/scheduler_settings.h" |
18 #include "cc/scheduler/scheduler_state_machine.h" | 18 #include "cc/scheduler/scheduler_state_machine.h" |
19 #include "cc/trees/layer_tree_host.h" | 19 #include "cc/trees/layer_tree_host.h" |
20 | 20 |
21 namespace cc { | 21 namespace cc { |
22 | 22 |
23 class Thread; | 23 class Thread; |
24 | 24 |
25 class SchedulerClient { | 25 class SchedulerClient { |
26 public: | 26 public: |
27 virtual void SetNeedsBeginImplFrame(bool enable) = 0; | 27 virtual void SetNeedsBeginFrame(bool enable) = 0; |
28 virtual void OnBeginImplFrame(const BeginFrameArgs& args) = 0; | |
28 virtual void ScheduledActionSendBeginMainFrame() = 0; | 29 virtual void ScheduledActionSendBeginMainFrame() = 0; |
29 virtual DrawSwapReadbackResult ScheduledActionDrawAndSwapIfPossible() = 0; | 30 virtual DrawSwapReadbackResult ScheduledActionDrawAndSwapIfPossible() = 0; |
30 virtual DrawSwapReadbackResult ScheduledActionDrawAndSwapForced() = 0; | 31 virtual DrawSwapReadbackResult ScheduledActionDrawAndSwapForced() = 0; |
31 virtual DrawSwapReadbackResult ScheduledActionDrawAndReadback() = 0; | 32 virtual DrawSwapReadbackResult ScheduledActionDrawAndReadback() = 0; |
32 virtual void ScheduledActionCommit() = 0; | 33 virtual void ScheduledActionCommit() = 0; |
33 virtual void ScheduledActionUpdateVisibleTiles() = 0; | 34 virtual void ScheduledActionUpdateVisibleTiles() = 0; |
34 virtual void ScheduledActionActivatePendingTree() = 0; | 35 virtual void ScheduledActionActivatePendingTree() = 0; |
35 virtual void ScheduledActionBeginOutputSurfaceCreation() = 0; | 36 virtual void ScheduledActionBeginOutputSurfaceCreation() = 0; |
36 virtual void ScheduledActionAcquireLayerTexturesForMainThread() = 0; | 37 virtual void ScheduledActionAcquireLayerTexturesForMainThread() = 0; |
37 virtual void ScheduledActionManageTiles() = 0; | 38 virtual void ScheduledActionManageTiles() = 0; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
103 } | 104 } |
104 | 105 |
105 bool WillDrawIfNeeded() const; | 106 bool WillDrawIfNeeded() const; |
106 | 107 |
107 base::TimeTicks AnticipatedDrawTime() const; | 108 base::TimeTicks AnticipatedDrawTime() const; |
108 | 109 |
109 void NotifyBeginMainFrameStarted(); | 110 void NotifyBeginMainFrameStarted(); |
110 | 111 |
111 base::TimeTicks LastBeginImplFrameTime(); | 112 base::TimeTicks LastBeginImplFrameTime(); |
112 | 113 |
113 void BeginImplFrame(const BeginFrameArgs& args); | 114 void BeginFrame(const BeginFrameArgs& args); |
115 void BeginRetroFrame(); | |
116 void BeginImplFrame(); | |
114 void OnBeginImplFrameDeadline(); | 117 void OnBeginImplFrameDeadline(); |
115 void PollForAnticipatedDrawTriggers(); | 118 void PollForAnticipatedDrawTriggers(); |
116 | 119 |
117 scoped_ptr<base::Value> StateAsValue() const; | 120 scoped_ptr<base::Value> StateAsValue() const; |
118 | 121 |
119 bool IsInsideAction(SchedulerStateMachine::Action action) { | 122 bool IsInsideAction(SchedulerStateMachine::Action action) { |
120 return inside_action_ == action; | 123 return inside_action_ == action; |
121 } | 124 } |
122 | 125 |
123 bool IsBeginMainFrameSent() const; | 126 bool IsBeginMainFrameSent() const; |
124 | 127 |
125 private: | 128 private: |
126 Scheduler(SchedulerClient* client, | 129 Scheduler(SchedulerClient* client, |
127 const SchedulerSettings& scheduler_settings, | 130 const SchedulerSettings& scheduler_settings, |
128 int layer_tree_host_id, | 131 int layer_tree_host_id, |
129 const scoped_refptr<base::SequencedTaskRunner>& impl_task_runner); | 132 const scoped_refptr<base::SequencedTaskRunner>& impl_task_runner); |
130 | 133 |
131 base::TimeTicks AdjustedBeginImplFrameDeadline() const; | 134 base::TimeTicks AdjustedBeginImplFrameDeadline() const; |
132 void ScheduleBeginImplFrameDeadline(base::TimeTicks deadline); | 135 void ScheduleBeginImplFrameDeadline(base::TimeTicks deadline); |
133 void SetupNextBeginImplFrameIfNeeded(); | 136 void SetupNextBeginFrameIfNeeded(); |
134 void ActivatePendingTree(); | 137 void ActivatePendingTree(); |
135 void DrawAndSwapIfPossible(); | 138 void DrawAndSwapIfPossible(); |
136 void DrawAndSwapForced(); | 139 void DrawAndSwapForced(); |
137 void DrawAndReadback(); | 140 void DrawAndReadback(); |
138 void ProcessScheduledActions(); | 141 void ProcessScheduledActions(); |
139 | 142 |
140 bool CanCommitAndActivateBeforeDeadline() const; | 143 bool CanCommitAndActivateBeforeDeadline() const; |
141 void AdvanceCommitStateIfPossible(); | 144 void AdvanceCommitStateIfPossible(); |
142 | 145 |
143 bool IsBeginMainFrameSentOrStarted() const; | 146 bool IsBeginMainFrameSentOrStarted() const; |
144 | 147 |
145 const SchedulerSettings settings_; | 148 const SchedulerSettings settings_; |
146 SchedulerClient* client_; | 149 SchedulerClient* client_; |
147 int layer_tree_host_id_; | 150 int layer_tree_host_id_; |
148 scoped_refptr<base::SequencedTaskRunner> impl_task_runner_; | 151 scoped_refptr<base::SequencedTaskRunner> impl_task_runner_; |
149 | 152 |
150 bool last_set_needs_begin_impl_frame_; | 153 bool last_set_needs_begin_frame_; |
151 BeginFrameArgs last_begin_impl_frame_args_; | 154 bool begin_retro_frame_posted_; |
155 | |
156 BeginFrameArgs begin_frame_args_; | |
Sami
2014/04/01 13:09:10
It seems like we could do without this field and i
brianderson
2014/04/01 19:12:53
I liked the idea of having access to the original
brianderson
2014/04/02 04:15:57
I ended up getting rid of begin_frame_args_ like y
| |
157 BeginFrameArgs begin_retro_frame_args_; | |
158 BeginFrameArgs begin_impl_frame_args_; | |
159 | |
152 base::CancelableClosure begin_impl_frame_deadline_closure_; | 160 base::CancelableClosure begin_impl_frame_deadline_closure_; |
153 base::CancelableClosure poll_for_draw_triggers_closure_; | 161 base::CancelableClosure poll_for_draw_triggers_closure_; |
154 base::RepeatingTimer<Scheduler> advance_commit_state_timer_; | 162 base::RepeatingTimer<Scheduler> advance_commit_state_timer_; |
155 | 163 |
156 SchedulerStateMachine state_machine_; | 164 SchedulerStateMachine state_machine_; |
157 bool inside_process_scheduled_actions_; | 165 bool inside_process_scheduled_actions_; |
158 SchedulerStateMachine::Action inside_action_; | 166 SchedulerStateMachine::Action inside_action_; |
159 | 167 |
160 base::WeakPtrFactory<Scheduler> weak_factory_; | 168 base::WeakPtrFactory<Scheduler> weak_factory_; |
161 | 169 |
162 DISALLOW_COPY_AND_ASSIGN(Scheduler); | 170 DISALLOW_COPY_AND_ASSIGN(Scheduler); |
163 }; | 171 }; |
164 | 172 |
165 } // namespace cc | 173 } // namespace cc |
166 | 174 |
167 #endif // CC_SCHEDULER_SCHEDULER_H_ | 175 #endif // CC_SCHEDULER_SCHEDULER_H_ |
OLD | NEW |