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 #include "cc/scheduler/scheduler.h" | 5 #include "cc/scheduler/scheduler.h" |
6 | 6 |
7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "cc/debug/traced_value.h" | 10 #include "cc/debug/traced_value.h" |
11 | 11 |
12 namespace cc { | 12 namespace cc { |
13 | 13 |
14 Scheduler::Scheduler(SchedulerClient* client, | 14 Scheduler::Scheduler(SchedulerClient* client, |
15 const SchedulerSettings& scheduler_settings) | 15 const SchedulerSettings& scheduler_settings) |
16 : settings_(scheduler_settings), | 16 : settings_(scheduler_settings), |
17 client_(client), | 17 client_(client), |
18 weak_factory_(this), | 18 weak_factory_(this), |
19 last_set_needs_begin_frame_(false), | 19 last_set_needs_begin_frame_(false), |
20 has_pending_begin_frame_(false), | 20 has_pending_begin_frame_(false), |
21 state_machine_(scheduler_settings), | 21 state_machine_(scheduler_settings), |
22 inside_process_scheduled_actions_(false) { | 22 inside_process_scheduled_actions_(false), |
| 23 inside_action_(SchedulerStateMachine::ACTION_NONE) { |
23 DCHECK(client_); | 24 DCHECK(client_); |
24 DCHECK(!state_machine_.BeginFrameNeededToDrawByImplThread()); | 25 DCHECK(!state_machine_.BeginFrameNeededToDrawByImplThread()); |
25 } | 26 } |
26 | 27 |
27 Scheduler::~Scheduler() { | 28 Scheduler::~Scheduler() { |
28 client_->SetNeedsBeginFrameOnImplThread(false); | 29 client_->SetNeedsBeginFrameOnImplThread(false); |
29 } | 30 } |
30 | 31 |
31 void Scheduler::SetCanStart() { | 32 void Scheduler::SetCanStart() { |
32 state_machine_.SetCanStart(); | 33 state_machine_.SetCanStart(); |
(...skipping 24 matching lines...) Expand all Loading... |
57 state_machine_.SetNeedsCommit(); | 58 state_machine_.SetNeedsCommit(); |
58 state_machine_.SetNeedsForcedCommitForReadback(); | 59 state_machine_.SetNeedsForcedCommitForReadback(); |
59 ProcessScheduledActions(); | 60 ProcessScheduledActions(); |
60 } | 61 } |
61 | 62 |
62 void Scheduler::SetNeedsRedraw() { | 63 void Scheduler::SetNeedsRedraw() { |
63 state_machine_.SetNeedsRedraw(); | 64 state_machine_.SetNeedsRedraw(); |
64 ProcessScheduledActions(); | 65 ProcessScheduledActions(); |
65 } | 66 } |
66 | 67 |
| 68 void Scheduler::SetNeedsManageTiles() { |
| 69 DCHECK(!IsInsideAction(SchedulerStateMachine::ACTION_MANAGE_TILES)); |
| 70 state_machine_.SetNeedsManageTiles(); |
| 71 ProcessScheduledActions(); |
| 72 } |
| 73 |
67 void Scheduler::SetSwapUsedIncompleteTile(bool used_incomplete_tile) { | 74 void Scheduler::SetSwapUsedIncompleteTile(bool used_incomplete_tile) { |
68 state_machine_.SetSwapUsedIncompleteTile(used_incomplete_tile); | 75 state_machine_.SetSwapUsedIncompleteTile(used_incomplete_tile); |
69 ProcessScheduledActions(); | 76 ProcessScheduledActions(); |
70 } | 77 } |
71 | 78 |
72 void Scheduler::SetMainThreadNeedsLayerTextures() { | 79 void Scheduler::SetMainThreadNeedsLayerTextures() { |
73 state_machine_.SetMainThreadNeedsLayerTextures(); | 80 state_machine_.SetMainThreadNeedsLayerTextures(); |
74 ProcessScheduledActions(); | 81 ProcessScheduledActions(); |
75 } | 82 } |
76 | 83 |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 DCHECK(!has_pending_begin_frame_); | 183 DCHECK(!has_pending_begin_frame_); |
177 has_pending_begin_frame_ = true; | 184 has_pending_begin_frame_ = true; |
178 last_begin_frame_args_ = args; | 185 last_begin_frame_args_ = args; |
179 state_machine_.DidEnterBeginFrame(args); | 186 state_machine_.DidEnterBeginFrame(args); |
180 ProcessScheduledActions(); | 187 ProcessScheduledActions(); |
181 state_machine_.DidLeaveBeginFrame(); | 188 state_machine_.DidLeaveBeginFrame(); |
182 } | 189 } |
183 | 190 |
184 void Scheduler::PollForAnticipatedDrawTriggers() { | 191 void Scheduler::PollForAnticipatedDrawTriggers() { |
185 TRACE_EVENT0("cc", "Scheduler::PollForAnticipatedDrawTriggers"); | 192 TRACE_EVENT0("cc", "Scheduler::PollForAnticipatedDrawTriggers"); |
186 state_machine_.PollForAnticipatedDrawTriggers(); | 193 state_machine_.DidEnterPollForAnticipatedDrawTriggers(); |
187 ProcessScheduledActions(); | 194 ProcessScheduledActions(); |
| 195 state_machine_.DidLeavePollForAnticipatedDrawTriggers(); |
188 } | 196 } |
189 | 197 |
190 void Scheduler::DrawAndSwapIfPossible() { | 198 void Scheduler::DrawAndSwapIfPossible() { |
191 DrawSwapReadbackResult result = | 199 DrawSwapReadbackResult result = |
192 client_->ScheduledActionDrawAndSwapIfPossible(); | 200 client_->ScheduledActionDrawAndSwapIfPossible(); |
193 state_machine_.DidDrawIfPossibleCompleted(result.did_draw); | 201 state_machine_.DidDrawIfPossibleCompleted(result.did_draw); |
194 if (result.did_swap) | 202 if (result.did_swap) |
195 has_pending_begin_frame_ = false; | 203 has_pending_begin_frame_ = false; |
196 } | 204 } |
197 | 205 |
(...skipping 18 matching lines...) Expand all Loading... |
216 | 224 |
217 SchedulerStateMachine::Action action; | 225 SchedulerStateMachine::Action action; |
218 do { | 226 do { |
219 state_machine_.CheckInvariants(); | 227 state_machine_.CheckInvariants(); |
220 action = state_machine_.NextAction(); | 228 action = state_machine_.NextAction(); |
221 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler"), | 229 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler"), |
222 "SchedulerStateMachine", | 230 "SchedulerStateMachine", |
223 "state", | 231 "state", |
224 TracedValue::FromValue(state_machine_.AsValue().release())); | 232 TracedValue::FromValue(state_machine_.AsValue().release())); |
225 state_machine_.UpdateState(action); | 233 state_machine_.UpdateState(action); |
| 234 base::AutoReset<SchedulerStateMachine::Action> |
| 235 mark_inside_action(&inside_action_, action); |
226 switch (action) { | 236 switch (action) { |
227 case SchedulerStateMachine::ACTION_NONE: | 237 case SchedulerStateMachine::ACTION_NONE: |
228 break; | 238 break; |
229 case SchedulerStateMachine::ACTION_SEND_BEGIN_FRAME_TO_MAIN_THREAD: | 239 case SchedulerStateMachine::ACTION_SEND_BEGIN_FRAME_TO_MAIN_THREAD: |
230 client_->ScheduledActionSendBeginFrameToMainThread(); | 240 client_->ScheduledActionSendBeginFrameToMainThread(); |
231 break; | 241 break; |
232 case SchedulerStateMachine::ACTION_COMMIT: | 242 case SchedulerStateMachine::ACTION_COMMIT: |
233 client_->ScheduledActionCommit(); | 243 client_->ScheduledActionCommit(); |
234 break; | 244 break; |
235 case SchedulerStateMachine::ACTION_UPDATE_VISIBLE_TILES: | 245 case SchedulerStateMachine::ACTION_UPDATE_VISIBLE_TILES: |
(...skipping 14 matching lines...) Expand all Loading... |
250 break; | 260 break; |
251 case SchedulerStateMachine::ACTION_DRAW_AND_READBACK: | 261 case SchedulerStateMachine::ACTION_DRAW_AND_READBACK: |
252 DrawAndReadback(); | 262 DrawAndReadback(); |
253 break; | 263 break; |
254 case SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION: | 264 case SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION: |
255 client_->ScheduledActionBeginOutputSurfaceCreation(); | 265 client_->ScheduledActionBeginOutputSurfaceCreation(); |
256 break; | 266 break; |
257 case SchedulerStateMachine::ACTION_ACQUIRE_LAYER_TEXTURES_FOR_MAIN_THREAD: | 267 case SchedulerStateMachine::ACTION_ACQUIRE_LAYER_TEXTURES_FOR_MAIN_THREAD: |
258 client_->ScheduledActionAcquireLayerTexturesForMainThread(); | 268 client_->ScheduledActionAcquireLayerTexturesForMainThread(); |
259 break; | 269 break; |
| 270 case SchedulerStateMachine::ACTION_MANAGE_TILES: |
| 271 client_->ScheduledActionManageTiles(); |
| 272 break; |
260 } | 273 } |
261 } while (action != SchedulerStateMachine::ACTION_NONE); | 274 } while (action != SchedulerStateMachine::ACTION_NONE); |
262 | 275 |
263 SetupNextBeginFrameIfNeeded(); | 276 SetupNextBeginFrameIfNeeded(); |
264 client_->DidAnticipatedDrawTimeChange(AnticipatedDrawTime()); | 277 client_->DidAnticipatedDrawTimeChange(AnticipatedDrawTime()); |
265 } | 278 } |
266 | 279 |
267 bool Scheduler::WillDrawIfNeeded() const { | 280 bool Scheduler::WillDrawIfNeeded() const { |
268 return !state_machine_.PendingDrawsShouldBeAborted(); | 281 return !state_machine_.PendingDrawsShouldBeAborted(); |
269 } | 282 } |
270 | 283 |
271 } // namespace cc | 284 } // namespace cc |
OLD | NEW |