Chromium Code Reviews| 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_STATE_MACHINE_H_ | 5 #ifndef CC_SCHEDULER_SCHEDULER_STATE_MACHINE_H_ |
| 6 #define CC_SCHEDULER_SCHEDULER_STATE_MACHINE_H_ | 6 #define CC_SCHEDULER_SCHEDULER_STATE_MACHINE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 35 // requested, while external state includes things like the current time being | 35 // requested, while external state includes things like the current time being |
| 36 // near to the vblank time. | 36 // near to the vblank time. |
| 37 // | 37 // |
| 38 // The scheduler seperates "what to do next" from the updating of its internal | 38 // The scheduler seperates "what to do next" from the updating of its internal |
| 39 // state to make testing cleaner. | 39 // state to make testing cleaner. |
| 40 class CC_EXPORT SchedulerStateMachine { | 40 class CC_EXPORT SchedulerStateMachine { |
| 41 public: | 41 public: |
| 42 // settings must be valid for the lifetime of this class. | 42 // settings must be valid for the lifetime of this class. |
| 43 explicit SchedulerStateMachine(const SchedulerSettings& settings); | 43 explicit SchedulerStateMachine(const SchedulerSettings& settings); |
| 44 | 44 |
| 45 enum OutputSurfaceState { | 45 enum class OutputSurfaceState { |
| 46 OUTPUT_SURFACE_ACTIVE, | 46 ACTIVE, |
| 47 OUTPUT_SURFACE_LOST, | 47 LOST, |
| 48 OUTPUT_SURFACE_CREATING, | 48 CREATING, |
| 49 OUTPUT_SURFACE_WAITING_FOR_FIRST_COMMIT, | 49 WAITING_FOR_FIRST_COMMIT, |
| 50 OUTPUT_SURFACE_WAITING_FOR_FIRST_ACTIVATION, | 50 WAITING_FOR_FIRST_ACTIVATION, |
| 51 }; | 51 }; |
| 52 static const char* OutputSurfaceStateToString(OutputSurfaceState state); | 52 static const char* OutputSurfaceStateToString(OutputSurfaceState state); |
| 53 | 53 |
| 54 friend ::std::ostream& operator<<(::std::ostream& os, | |
|
Sami
2015/01/07 14:13:03
It's unfortunate that we need to add these just fo
jamesr
2015/01/07 22:32:00
enum classes, unlike enums, aren't implicitly conv
Shanmuga Pandi
2015/01/08 05:13:30
I think PrintTo will solve gtest print issue.
But
| |
| 55 const OutputSurfaceState& state) { | |
| 56 return os << OutputSurfaceStateToString(state); | |
| 57 } | |
| 58 | |
| 54 // Note: BeginImplFrameState will always cycle through all the states in | 59 // Note: BeginImplFrameState will always cycle through all the states in |
| 55 // order. Whether or not it actually waits or draws, it will at least try to | 60 // order. Whether or not it actually waits or draws, it will at least try to |
| 56 // wait in BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME and try to draw in | 61 // wait in INSIDE_BEGIN_FRAME and try to draw in |
| 57 // BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE | 62 // INSIDE_DEADLINE |
| 58 enum BeginImplFrameState { | 63 enum class BeginImplFrameState { |
| 59 BEGIN_IMPL_FRAME_STATE_IDLE, | 64 IDLE, |
| 60 BEGIN_IMPL_FRAME_STATE_BEGIN_FRAME_STARTING, | 65 BEGIN_FRAME_STARTING, |
| 61 BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME, | 66 INSIDE_BEGIN_FRAME, |
| 62 BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE, | 67 INSIDE_DEADLINE, |
| 63 }; | 68 }; |
| 64 static const char* BeginImplFrameStateToString(BeginImplFrameState state); | 69 static const char* BeginImplFrameStateToString(BeginImplFrameState state); |
| 65 | 70 |
| 66 enum BeginImplFrameDeadlineMode { | 71 friend ::std::ostream& operator<<(::std::ostream& os, |
| 67 BEGIN_IMPL_FRAME_DEADLINE_MODE_IMMEDIATE, | 72 const BeginImplFrameState& state) { |
| 68 BEGIN_IMPL_FRAME_DEADLINE_MODE_REGULAR, | 73 return os << BeginImplFrameStateToString(state); |
| 69 BEGIN_IMPL_FRAME_DEADLINE_MODE_LATE, | 74 } |
| 75 | |
| 76 enum class BeginImplFrameDeadlineMode { | |
| 77 IMMEDIATE, | |
| 78 REGULAR, | |
| 79 LATE, | |
| 70 }; | 80 }; |
| 71 static const char* BeginImplFrameDeadlineModeToString( | 81 static const char* BeginImplFrameDeadlineModeToString( |
| 72 BeginImplFrameDeadlineMode mode); | 82 BeginImplFrameDeadlineMode mode); |
| 73 | 83 |
| 74 enum CommitState { | 84 enum class CommitState { |
| 75 COMMIT_STATE_IDLE, | 85 IDLE, |
| 76 COMMIT_STATE_BEGIN_MAIN_FRAME_SENT, | 86 BEGIN_MAIN_FRAME_SENT, |
| 77 COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED, | 87 BEGIN_MAIN_FRAME_STARTED, |
| 78 COMMIT_STATE_READY_TO_COMMIT, | 88 READY_TO_COMMIT, |
| 79 COMMIT_STATE_WAITING_FOR_ACTIVATION, | 89 WAITING_FOR_ACTIVATION, |
| 80 COMMIT_STATE_WAITING_FOR_DRAW, | 90 WAITING_FOR_DRAW, |
| 81 }; | 91 }; |
| 82 static const char* CommitStateToString(CommitState state); | 92 static const char* CommitStateToString(CommitState state); |
| 83 | 93 |
| 84 enum ForcedRedrawOnTimeoutState { | 94 friend ::std::ostream& operator<<(::std::ostream& os, |
| 85 FORCED_REDRAW_STATE_IDLE, | 95 const CommitState& state) { |
| 86 FORCED_REDRAW_STATE_WAITING_FOR_COMMIT, | 96 return os << CommitStateToString(state); |
| 87 FORCED_REDRAW_STATE_WAITING_FOR_ACTIVATION, | 97 } |
| 88 FORCED_REDRAW_STATE_WAITING_FOR_DRAW, | 98 |
| 99 enum class ForcedRedrawOnTimeoutState { | |
| 100 IDLE, | |
| 101 WAITING_FOR_COMMIT, | |
| 102 WAITING_FOR_ACTIVATION, | |
| 103 WAITING_FOR_DRAW, | |
| 89 }; | 104 }; |
| 90 static const char* ForcedRedrawOnTimeoutStateToString( | 105 static const char* ForcedRedrawOnTimeoutStateToString( |
| 91 ForcedRedrawOnTimeoutState state); | 106 ForcedRedrawOnTimeoutState state); |
| 92 | 107 |
| 93 bool CommitPending() const { | 108 bool CommitPending() const { |
| 94 return commit_state_ == COMMIT_STATE_BEGIN_MAIN_FRAME_SENT || | 109 return commit_state_ == CommitState::BEGIN_MAIN_FRAME_SENT || |
| 95 commit_state_ == COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED || | 110 commit_state_ == CommitState::BEGIN_MAIN_FRAME_STARTED || |
| 96 commit_state_ == COMMIT_STATE_READY_TO_COMMIT; | 111 commit_state_ == CommitState::READY_TO_COMMIT; |
| 97 } | 112 } |
| 98 CommitState commit_state() const { return commit_state_; } | 113 CommitState commit_state() const { return commit_state_; } |
| 99 | 114 |
| 100 bool RedrawPending() const { return needs_redraw_; } | 115 bool RedrawPending() const { return needs_redraw_; } |
| 101 bool PrepareTilesPending() const { return needs_prepare_tiles_; } | 116 bool PrepareTilesPending() const { return needs_prepare_tiles_; } |
| 102 | 117 |
| 103 enum Action { | 118 enum Action { |
| 104 ACTION_NONE, | 119 NONE, |
| 105 ACTION_ANIMATE, | 120 ANIMATE, |
| 106 ACTION_SEND_BEGIN_MAIN_FRAME, | 121 SEND_BEGIN_MAIN_FRAME, |
| 107 ACTION_COMMIT, | 122 COMMIT, |
| 108 ACTION_ACTIVATE_SYNC_TREE, | 123 ACTIVATE_SYNC_TREE, |
| 109 ACTION_DRAW_AND_SWAP_IF_POSSIBLE, | 124 DRAW_AND_SWAP_IF_POSSIBLE, |
| 110 ACTION_DRAW_AND_SWAP_FORCED, | 125 DRAW_AND_SWAP_FORCED, |
| 111 ACTION_DRAW_AND_SWAP_ABORT, | 126 DRAW_AND_SWAP_ABORT, |
| 112 ACTION_BEGIN_OUTPUT_SURFACE_CREATION, | 127 BEGIN_OUTPUT_SURFACE_CREATION, |
| 113 ACTION_PREPARE_TILES, | 128 PREPARE_TILES, |
| 114 }; | 129 }; |
| 115 static const char* ActionToString(Action action); | 130 static const char* ActionToString(Action action); |
| 116 | 131 |
| 117 scoped_refptr<base::debug::ConvertableToTraceFormat> AsValue() const; | 132 scoped_refptr<base::debug::ConvertableToTraceFormat> AsValue() const; |
| 118 void AsValueInto(base::debug::TracedValue* dict, base::TimeTicks now) const; | 133 void AsValueInto(base::debug::TracedValue* dict, base::TimeTicks now) const; |
| 119 | 134 |
| 120 Action NextAction() const; | 135 Action NextAction() const; |
| 121 void UpdateState(Action action); | 136 void UpdateState(Action action); |
| 122 | 137 |
| 123 // Indicates whether the impl thread needs a BeginImplFrame callback in order | 138 // Indicates whether the impl thread needs a BeginImplFrame callback in order |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 341 bool impl_latency_takes_priority_on_battery_; | 356 bool impl_latency_takes_priority_on_battery_; |
| 342 bool children_need_begin_frames_; | 357 bool children_need_begin_frames_; |
| 343 | 358 |
| 344 private: | 359 private: |
| 345 DISALLOW_COPY_AND_ASSIGN(SchedulerStateMachine); | 360 DISALLOW_COPY_AND_ASSIGN(SchedulerStateMachine); |
| 346 }; | 361 }; |
| 347 | 362 |
| 348 } // namespace cc | 363 } // namespace cc |
| 349 | 364 |
| 350 #endif // CC_SCHEDULER_SCHEDULER_STATE_MACHINE_H_ | 365 #endif // CC_SCHEDULER_SCHEDULER_STATE_MACHINE_H_ |
| OLD | NEW |