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_state_machine.h" | 5 #include "cc/scheduler/scheduler_state_machine.h" |
6 | 6 |
7 #include "cc/scheduler/scheduler.h" | 7 #include "cc/scheduler/scheduler.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 | 9 |
10 #define EXPECT_ACTION_UPDATE_STATE(action) \ | 10 #define EXPECT_ACTION_UPDATE_STATE(action) \ |
11 EXPECT_EQ(action, state.NextAction()) << *state.AsValue(); \ | 11 EXPECT_EQ(action, state.NextAction()) << *state.ToValue(); \ |
12 state.UpdateState(action); | 12 if (action == SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE || \ |
Sami
2013/08/30 13:49:06
Nit: maybe separate this part into a normal functi
brianderson
2013/09/03 22:51:47
I wanted to do that, but then we lose information
| |
13 action == SchedulerStateMachine::ACTION_DRAW_AND_SWAP_FORCED) { \ | |
14 if (SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_DRAW == \ | |
15 state.CommitState() && \ | |
16 SchedulerStateMachine::OUTPUT_SURFACE_ACTIVE != \ | |
17 state.output_surface_state()) \ | |
18 return; \ | |
19 EXPECT_EQ(SchedulerStateMachine::BEGIN_FRAME_STATE_INSIDE_DEADLINE, \ | |
20 state.begin_frame_state()) \ | |
21 << *state.ToValue(); \ | |
22 } \ | |
23 state.UpdateState(action); \ | |
24 if (action == SchedulerStateMachine::ACTION_NONE) { \ | |
25 state.AdvanceBeginFrameStateWhenNoActionsRemain(); \ | |
26 } | |
13 | 27 |
14 namespace cc { | 28 namespace cc { |
15 | 29 |
16 namespace { | 30 namespace { |
17 | 31 |
32 const SchedulerStateMachine::BeginFrameState all_begin_frame_states[] = { | |
33 SchedulerStateMachine::BEGIN_FRAME_STATE_IDLE, | |
34 SchedulerStateMachine::BEGIN_FRAME_STATE_INSIDE_BEGIN_FRAME, | |
35 SchedulerStateMachine::BEGIN_FRAME_STATE_DEADLINE_PENDING, | |
36 SchedulerStateMachine::BEGIN_FRAME_STATE_INSIDE_DEADLINE, }; | |
37 | |
18 const SchedulerStateMachine::CommitState all_commit_states[] = { | 38 const SchedulerStateMachine::CommitState all_commit_states[] = { |
19 SchedulerStateMachine::COMMIT_STATE_IDLE, | 39 SchedulerStateMachine::COMMIT_STATE_IDLE, |
20 SchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS, | 40 SchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS, |
21 SchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT, | 41 SchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT, |
22 SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_DRAW | 42 SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_ACTIVATION, |
23 }; | 43 SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_DRAW, }; |
24 | 44 |
25 // Exposes the protected state fields of the SchedulerStateMachine for testing | 45 // Exposes the protected state fields of the SchedulerStateMachine for testing |
26 class StateMachine : public SchedulerStateMachine { | 46 class StateMachine : public SchedulerStateMachine { |
27 public: | 47 public: |
28 explicit StateMachine(const SchedulerSettings& scheduler_settings) | 48 explicit StateMachine(const SchedulerSettings& scheduler_settings) |
29 : SchedulerStateMachine(scheduler_settings) {} | 49 : SchedulerStateMachine(scheduler_settings) {} |
30 | 50 |
31 void CreateAndInitializeOutputSurfaceWithActivatedCommit() { | 51 void CreateAndInitializeOutputSurfaceWithActivatedCommit() { |
32 DidCreateAndInitializeOutputSurface(); | 52 DidCreateAndInitializeOutputSurface(); |
33 output_surface_state_ = OUTPUT_SURFACE_ACTIVE; | 53 output_surface_state_ = OUTPUT_SURFACE_ACTIVE; |
34 } | 54 } |
35 | 55 |
36 void SetCommitState(CommitState cs) { commit_state_ = cs; } | 56 void SetCommitState(CommitState cs) { commit_state_ = cs; } |
37 CommitState CommitState() const { return commit_state_; } | 57 CommitState CommitState() const { return commit_state_; } |
38 | 58 |
59 void SetBeginFrameState(BeginFrameState bfs) { begin_frame_state_ = bfs; } | |
60 BeginFrameState begin_frame_state() const { return begin_frame_state_; } | |
61 | |
39 OutputSurfaceState output_surface_state() { return output_surface_state_; } | 62 OutputSurfaceState output_surface_state() { return output_surface_state_; } |
40 | 63 |
41 bool NeedsCommit() const { return needs_commit_; } | 64 bool NeedsCommit() const { return needs_commit_; } |
42 | 65 |
43 void SetNeedsRedraw(bool b) { needs_redraw_ = b; } | 66 void SetNeedsRedraw(bool b) { needs_redraw_ = b; } |
44 bool NeedsRedraw() const { return needs_redraw_; } | 67 bool NeedsRedraw() const { return needs_redraw_; } |
45 | 68 |
46 void SetNeedsForcedRedrawForTimeout(bool b) { | 69 void SetNeedsForcedRedrawForTimeout(bool b) { |
47 forced_redraw_state_ = FORCED_REDRAW_STATE_WAITING_FOR_COMMIT; | 70 forced_redraw_state_ = FORCED_REDRAW_STATE_WAITING_FOR_COMMIT; |
48 commit_state_ = COMMIT_STATE_WAITING_FOR_FIRST_DRAW; | 71 commit_state_ = COMMIT_STATE_WAITING_FOR_FIRST_DRAW; |
(...skipping 1361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1410 EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.NextAction()); | 1433 EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.NextAction()); |
1411 | 1434 |
1412 state.BeginFrameAbortedByMainThread(true); | 1435 state.BeginFrameAbortedByMainThread(true); |
1413 | 1436 |
1414 EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.NextAction()); | 1437 EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.NextAction()); |
1415 EXPECT_FALSE(state.PendingDrawsShouldBeAborted()); | 1438 EXPECT_FALSE(state.PendingDrawsShouldBeAborted()); |
1416 } | 1439 } |
1417 | 1440 |
1418 } // namespace | 1441 } // namespace |
1419 } // namespace cc | 1442 } // namespace cc |
OLD | NEW |