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_STATE_MACHINE_H_ | 5 #ifndef CC_SCHEDULER_STATE_MACHINE_H_ |
6 #define CC_SCHEDULER_STATE_MACHINE_H_ | 6 #define CC_SCHEDULER_STATE_MACHINE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "cc/cc_export.h" | 11 #include "cc/cc_export.h" |
| 12 #include "cc/scheduler_settings.h" |
12 | 13 |
13 namespace cc { | 14 namespace cc { |
14 | 15 |
15 // The SchedulerStateMachine decides how to coordinate main thread activites | 16 // The SchedulerStateMachine decides how to coordinate main thread activites |
16 // like painting/running javascript with rendering and input activities on the | 17 // like painting/running javascript with rendering and input activities on the |
17 // impl thread. | 18 // impl thread. |
18 // | 19 // |
19 // The state machine tracks internal state but is also influenced by external st
ate. | 20 // The state machine tracks internal state but is also influenced by external st
ate. |
20 // Internal state includes things like whether a frame has been requested, while | 21 // Internal state includes things like whether a frame has been requested, while |
21 // external state includes things like the current time being near to the vblank
time. | 22 // external state includes things like the current time being near to the vblank
time. |
22 // | 23 // |
23 // The scheduler seperates "what to do next" from the updating of its internal s
tate to | 24 // The scheduler seperates "what to do next" from the updating of its internal s
tate to |
24 // make testing cleaner. | 25 // make testing cleaner. |
25 class CC_EXPORT SchedulerStateMachine { | 26 class CC_EXPORT SchedulerStateMachine { |
26 public: | 27 public: |
27 SchedulerStateMachine(); | 28 // settings must be valid for the lifetime of this class. |
| 29 SchedulerStateMachine(const SchedulerSettings& settings); |
28 | 30 |
29 enum CommitState { | 31 enum CommitState { |
30 COMMIT_STATE_IDLE, | 32 COMMIT_STATE_IDLE, |
31 COMMIT_STATE_FRAME_IN_PROGRESS, | 33 COMMIT_STATE_FRAME_IN_PROGRESS, |
32 COMMIT_STATE_READY_TO_COMMIT, | 34 COMMIT_STATE_READY_TO_COMMIT, |
33 COMMIT_STATE_WAITING_FOR_FIRST_DRAW, | 35 COMMIT_STATE_WAITING_FOR_FIRST_DRAW, |
34 COMMIT_STATE_WAITING_FOR_FIRST_FORCED_DRAW, | 36 COMMIT_STATE_WAITING_FOR_FIRST_FORCED_DRAW, |
35 }; | 37 }; |
36 | 38 |
37 enum TextureState { | 39 enum TextureState { |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 protected: | 144 protected: |
143 bool shouldDrawForced() const; | 145 bool shouldDrawForced() const; |
144 bool drawSuspendedUntilCommit() const; | 146 bool drawSuspendedUntilCommit() const; |
145 bool scheduledToDraw() const; | 147 bool scheduledToDraw() const; |
146 bool shouldDraw() const; | 148 bool shouldDraw() const; |
147 bool shouldAttemptTreeActivation() const; | 149 bool shouldAttemptTreeActivation() const; |
148 bool shouldAcquireLayerTexturesForMainThread() const; | 150 bool shouldAcquireLayerTexturesForMainThread() const; |
149 bool hasDrawnThisFrame() const; | 151 bool hasDrawnThisFrame() const; |
150 bool hasAttemptedTreeActivationThisFrame() const; | 152 bool hasAttemptedTreeActivationThisFrame() const; |
151 | 153 |
| 154 const SchedulerSettings m_settings; |
| 155 |
152 CommitState m_commitState; | 156 CommitState m_commitState; |
153 | 157 |
154 int m_currentFrameNumber; | 158 int m_currentFrameNumber; |
155 int m_lastFrameNumberWhereDrawWasCalled; | 159 int m_lastFrameNumberWhereDrawWasCalled; |
156 int m_lastFrameNumberWhereTreeActivationAttempted; | 160 int m_lastFrameNumberWhereTreeActivationAttempted; |
157 int m_consecutiveFailedDraws; | 161 int m_consecutiveFailedDraws; |
158 int m_maximumNumberOfFailedDrawsBeforeDrawIsForced; | 162 int m_maximumNumberOfFailedDrawsBeforeDrawIsForced; |
159 bool m_needsRedraw; | 163 bool m_needsRedraw; |
160 bool m_needsForcedRedraw; | 164 bool m_needsForcedRedraw; |
161 bool m_needsForcedRedrawAfterNextCommit; | 165 bool m_needsForcedRedrawAfterNextCommit; |
162 bool m_needsCommit; | 166 bool m_needsCommit; |
163 bool m_needsForcedCommit; | 167 bool m_needsForcedCommit; |
164 bool m_expectImmediateBeginFrame; | 168 bool m_expectImmediateBeginFrame; |
165 bool m_mainThreadNeedsLayerTextures; | 169 bool m_mainThreadNeedsLayerTextures; |
166 bool m_insideVSync; | 170 bool m_insideVSync; |
167 bool m_visible; | 171 bool m_visible; |
168 bool m_canBeginFrame; | 172 bool m_canBeginFrame; |
169 bool m_canDraw; | 173 bool m_canDraw; |
170 bool m_hasPendingTree; | 174 bool m_hasPendingTree; |
171 bool m_drawIfPossibleFailed; | 175 bool m_drawIfPossibleFailed; |
172 TextureState m_textureState; | 176 TextureState m_textureState; |
173 OutputSurfaceState m_outputSurfaceState; | 177 OutputSurfaceState m_outputSurfaceState; |
174 | 178 |
175 DISALLOW_COPY_AND_ASSIGN(SchedulerStateMachine); | 179 DISALLOW_COPY_AND_ASSIGN(SchedulerStateMachine); |
176 }; | 180 }; |
177 | 181 |
178 } | 182 } |
179 | 183 |
180 #endif // CC_SCHEDULER_STATE_MACHINE_H_ | 184 #endif // CC_SCHEDULER_STATE_MACHINE_H_ |
OLD | NEW |