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" |
(...skipping 21 matching lines...) Expand all Loading... |
32 COMMIT_STATE_READY_TO_COMMIT, | 32 COMMIT_STATE_READY_TO_COMMIT, |
33 COMMIT_STATE_WAITING_FOR_FIRST_DRAW, | 33 COMMIT_STATE_WAITING_FOR_FIRST_DRAW, |
34 }; | 34 }; |
35 | 35 |
36 enum TextureState { | 36 enum TextureState { |
37 LAYER_TEXTURE_STATE_UNLOCKED, | 37 LAYER_TEXTURE_STATE_UNLOCKED, |
38 LAYER_TEXTURE_STATE_ACQUIRED_BY_MAIN_THREAD, | 38 LAYER_TEXTURE_STATE_ACQUIRED_BY_MAIN_THREAD, |
39 LAYER_TEXTURE_STATE_ACQUIRED_BY_IMPL_THREAD, | 39 LAYER_TEXTURE_STATE_ACQUIRED_BY_IMPL_THREAD, |
40 }; | 40 }; |
41 | 41 |
42 enum OutputSurfaceState { | 42 enum ContextState { |
43 OUTPUT_SURFACE_ACTIVE, | 43 CONTEXT_ACTIVE, |
44 OUTPUT_SURFACE_LOST, | 44 CONTEXT_LOST, |
45 OUTPUT_SURFACE_RECREATING, | 45 CONTEXT_RECREATING, |
46 }; | 46 }; |
47 | 47 |
48 bool commitPending() const | 48 bool commitPending() const |
49 { | 49 { |
50 return m_commitState != COMMIT_STATE_IDLE; | 50 return m_commitState != COMMIT_STATE_IDLE; |
51 } | 51 } |
52 | 52 |
53 bool redrawPending() const { return m_needsRedraw; } | 53 bool redrawPending() const { return m_needsRedraw; } |
54 | 54 |
55 enum Action { | 55 enum Action { |
56 ACTION_NONE, | 56 ACTION_NONE, |
57 ACTION_BEGIN_FRAME, | 57 ACTION_BEGIN_FRAME, |
58 ACTION_COMMIT, | 58 ACTION_COMMIT, |
59 ACTION_DRAW_IF_POSSIBLE, | 59 ACTION_DRAW_IF_POSSIBLE, |
60 ACTION_DRAW_FORCED, | 60 ACTION_DRAW_FORCED, |
61 ACTION_BEGIN_OUTPUT_SURFACE_RECREATION, | 61 ACTION_BEGIN_CONTEXT_RECREATION, |
62 ACTION_ACQUIRE_LAYER_TEXTURES_FOR_MAIN_THREAD, | 62 ACTION_ACQUIRE_LAYER_TEXTURES_FOR_MAIN_THREAD, |
63 }; | 63 }; |
64 Action nextAction() const; | 64 Action nextAction() const; |
65 void updateState(Action); | 65 void updateState(Action); |
66 | 66 |
67 // Indicates whether the scheduler needs a vsync callback in order to make | 67 // Indicates whether the scheduler needs a vsync callback in order to make |
68 // progress. | 68 // progress. |
69 bool vsyncCallbackNeeded() const; | 69 bool vsyncCallbackNeeded() const; |
70 | 70 |
71 // Indicates that the system has entered and left a vsync callback. | 71 // Indicates that the system has entered and left a vsync callback. |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 void setMainThreadNeedsLayerTextures(); | 113 void setMainThreadNeedsLayerTextures(); |
114 | 114 |
115 // Indicates whether we can successfully begin a frame at this time. | 115 // Indicates whether we can successfully begin a frame at this time. |
116 void setCanBeginFrame(bool can) { m_canBeginFrame = can; } | 116 void setCanBeginFrame(bool can) { m_canBeginFrame = can; } |
117 | 117 |
118 // Indicates whether drawing would, at this time, make sense. | 118 // Indicates whether drawing would, at this time, make sense. |
119 // canDraw can be used to supress flashes or checkerboarding | 119 // canDraw can be used to supress flashes or checkerboarding |
120 // when such behavior would be undesirable. | 120 // when such behavior would be undesirable. |
121 void setCanDraw(bool can) { m_canDraw = can; } | 121 void setCanDraw(bool can) { m_canDraw = can; } |
122 | 122 |
123 void didLoseOutputSurface(); | 123 void didLoseContext(); |
124 void didRecreateOutputSurface(); | 124 void didRecreateContext(); |
125 | 125 |
126 // Exposed for testing purposes. | 126 // Exposed for testing purposes. |
127 void setMaximumNumberOfFailedDrawsBeforeDrawIsForced(int); | 127 void setMaximumNumberOfFailedDrawsBeforeDrawIsForced(int); |
128 | 128 |
129 std::string toString(); | 129 std::string toString(); |
130 | 130 |
131 protected: | 131 protected: |
132 bool shouldDrawForced() const; | 132 bool shouldDrawForced() const; |
133 bool drawSuspendedUntilCommit() const; | 133 bool drawSuspendedUntilCommit() const; |
134 bool scheduledToDraw() const; | 134 bool scheduledToDraw() const; |
(...skipping 13 matching lines...) Expand all Loading... |
148 bool m_needsCommit; | 148 bool m_needsCommit; |
149 bool m_needsForcedCommit; | 149 bool m_needsForcedCommit; |
150 bool m_expectImmediateBeginFrame; | 150 bool m_expectImmediateBeginFrame; |
151 bool m_mainThreadNeedsLayerTextures; | 151 bool m_mainThreadNeedsLayerTextures; |
152 bool m_insideVSync; | 152 bool m_insideVSync; |
153 bool m_visible; | 153 bool m_visible; |
154 bool m_canBeginFrame; | 154 bool m_canBeginFrame; |
155 bool m_canDraw; | 155 bool m_canDraw; |
156 bool m_drawIfPossibleFailed; | 156 bool m_drawIfPossibleFailed; |
157 TextureState m_textureState; | 157 TextureState m_textureState; |
158 OutputSurfaceState m_outputSurfaceState; | 158 ContextState m_contextState; |
159 | 159 |
160 DISALLOW_COPY_AND_ASSIGN(SchedulerStateMachine); | 160 DISALLOW_COPY_AND_ASSIGN(SchedulerStateMachine); |
161 }; | 161 }; |
162 | 162 |
163 } | 163 } |
164 | 164 |
165 #endif // CC_SCHEDULER_STATE_MACHINE_H_ | 165 #endif // CC_SCHEDULER_STATE_MACHINE_H_ |
OLD | NEW |