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_state_machine.h" | 5 #include "cc/scheduler_state_machine.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/stringprintf.h" | 8 #include "base/stringprintf.h" |
9 | 9 |
10 namespace cc { | 10 namespace cc { |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 return ACTION_NONE; | 135 return ACTION_NONE; |
136 | 136 |
137 case COMMIT_STATE_FRAME_IN_PROGRESS: | 137 case COMMIT_STATE_FRAME_IN_PROGRESS: |
138 if (shouldDraw()) | 138 if (shouldDraw()) |
139 return m_needsForcedRedraw ? ACTION_DRAW_FORCED : ACTION_DRAW_IF_POS
SIBLE; | 139 return m_needsForcedRedraw ? ACTION_DRAW_FORCED : ACTION_DRAW_IF_POS
SIBLE; |
140 return ACTION_NONE; | 140 return ACTION_NONE; |
141 | 141 |
142 case COMMIT_STATE_READY_TO_COMMIT: | 142 case COMMIT_STATE_READY_TO_COMMIT: |
143 return ACTION_COMMIT; | 143 return ACTION_COMMIT; |
144 | 144 |
145 case COMMIT_STATE_WAITING_FOR_FIRST_DRAW: | 145 case COMMIT_STATE_WAITING_FOR_FIRST_DRAW: { |
146 if (shouldDraw() || m_outputSurfaceState == OUTPUT_SURFACE_LOST) | 146 if (shouldDraw() || m_outputSurfaceState == OUTPUT_SURFACE_LOST) |
147 return m_needsForcedRedraw ? ACTION_DRAW_FORCED : ACTION_DRAW_IF_POS
SIBLE; | 147 return m_needsForcedRedraw ? ACTION_DRAW_FORCED : ACTION_DRAW_IF_POS
SIBLE; |
148 // COMMIT_STATE_WAITING_FOR_FIRST_DRAW wants to enforce a draw. If m_can
Draw is false | 148 // COMMIT_STATE_WAITING_FOR_FIRST_DRAW wants to enforce a draw. If m_can
Draw is false |
149 // or textures are not available, proceed to the next step (similar as i
n COMMIT_STATE_IDLE). | 149 // or textures are not available, proceed to the next step (similar as i
n COMMIT_STATE_IDLE). |
150 bool canCommit = m_visible || m_needsForcedCommit; | 150 bool canCommit = m_visible || m_needsForcedCommit; |
151 if (m_needsCommit && canCommit && drawSuspendedUntilCommit()) | 151 if (m_needsCommit && canCommit && drawSuspendedUntilCommit()) |
152 return ACTION_BEGIN_FRAME; | 152 return ACTION_BEGIN_FRAME; |
153 return ACTION_NONE; | 153 return ACTION_NONE; |
154 } | 154 } |
| 155 |
| 156 case COMMIT_STATE_WAITING_FOR_FIRST_FORCED_DRAW: |
| 157 if (m_needsForcedRedraw) |
| 158 return ACTION_DRAW_FORCED; |
| 159 return ACTION_NONE; |
| 160 } |
155 NOTREACHED(); | 161 NOTREACHED(); |
156 return ACTION_NONE; | 162 return ACTION_NONE; |
157 } | 163 } |
158 | 164 |
159 void SchedulerStateMachine::updateState(Action action) | 165 void SchedulerStateMachine::updateState(Action action) |
160 { | 166 { |
161 switch (action) { | 167 switch (action) { |
162 case ACTION_NONE: | 168 case ACTION_NONE: |
163 return; | 169 return; |
164 | 170 |
165 case ACTION_BEGIN_FRAME: | 171 case ACTION_BEGIN_FRAME: |
166 DCHECK(m_visible || m_needsForcedCommit); | 172 DCHECK(m_visible || m_needsForcedCommit); |
167 m_commitState = COMMIT_STATE_FRAME_IN_PROGRESS; | 173 m_commitState = COMMIT_STATE_FRAME_IN_PROGRESS; |
168 m_needsCommit = false; | 174 m_needsCommit = false; |
169 m_needsForcedCommit = false; | 175 m_needsForcedCommit = false; |
170 return; | 176 return; |
171 | 177 |
172 case ACTION_COMMIT: | 178 case ACTION_COMMIT: |
173 m_commitState = COMMIT_STATE_WAITING_FOR_FIRST_DRAW; | 179 if (m_expectImmediateBeginFrame) |
| 180 m_commitState = COMMIT_STATE_WAITING_FOR_FIRST_FORCED_DRAW; |
| 181 else |
| 182 m_commitState = COMMIT_STATE_WAITING_FOR_FIRST_DRAW; |
174 m_needsRedraw = true; | 183 m_needsRedraw = true; |
175 if (m_drawIfPossibleFailed) | 184 if (m_drawIfPossibleFailed) |
176 m_lastFrameNumberWhereDrawWasCalled = -1; | 185 m_lastFrameNumberWhereDrawWasCalled = -1; |
177 | 186 |
178 if (m_needsForcedRedrawAfterNextCommit) { | 187 if (m_needsForcedRedrawAfterNextCommit) { |
179 m_needsForcedRedrawAfterNextCommit = false; | 188 m_needsForcedRedrawAfterNextCommit = false; |
180 m_needsForcedRedraw = true; | 189 m_needsForcedRedraw = true; |
181 } | 190 } |
182 | 191 |
183 m_textureState = LAYER_TEXTURE_STATE_ACQUIRED_BY_IMPL_THREAD; | 192 m_textureState = LAYER_TEXTURE_STATE_ACQUIRED_BY_IMPL_THREAD; |
184 return; | 193 return; |
185 | 194 |
186 case ACTION_DRAW_FORCED: | 195 case ACTION_DRAW_FORCED: |
187 case ACTION_DRAW_IF_POSSIBLE: | 196 case ACTION_DRAW_IF_POSSIBLE: |
188 m_needsRedraw = false; | 197 m_needsRedraw = false; |
189 m_needsForcedRedraw = false; | 198 m_needsForcedRedraw = false; |
190 m_drawIfPossibleFailed = false; | 199 m_drawIfPossibleFailed = false; |
191 if (m_insideVSync) | 200 if (m_insideVSync) |
192 m_lastFrameNumberWhereDrawWasCalled = m_currentFrameNumber; | 201 m_lastFrameNumberWhereDrawWasCalled = m_currentFrameNumber; |
193 if (m_commitState == COMMIT_STATE_WAITING_FOR_FIRST_DRAW) { | 202 if (m_commitState == COMMIT_STATE_WAITING_FOR_FIRST_FORCED_DRAW) { |
194 if (m_expectImmediateBeginFrame) { | 203 DCHECK(m_expectImmediateBeginFrame); |
195 m_commitState = COMMIT_STATE_FRAME_IN_PROGRESS; | 204 m_commitState = COMMIT_STATE_FRAME_IN_PROGRESS; |
196 m_expectImmediateBeginFrame = false; | 205 m_expectImmediateBeginFrame = false; |
197 } else | 206 } else if (m_commitState == COMMIT_STATE_WAITING_FOR_FIRST_DRAW) |
198 m_commitState = COMMIT_STATE_IDLE; | 207 m_commitState = COMMIT_STATE_IDLE; |
199 } | |
200 if (m_textureState == LAYER_TEXTURE_STATE_ACQUIRED_BY_IMPL_THREAD) | 208 if (m_textureState == LAYER_TEXTURE_STATE_ACQUIRED_BY_IMPL_THREAD) |
201 m_textureState = LAYER_TEXTURE_STATE_UNLOCKED; | 209 m_textureState = LAYER_TEXTURE_STATE_UNLOCKED; |
202 return; | 210 return; |
203 | 211 |
204 case ACTION_BEGIN_OUTPUT_SURFACE_RECREATION: | 212 case ACTION_BEGIN_OUTPUT_SURFACE_RECREATION: |
205 DCHECK(m_commitState == COMMIT_STATE_IDLE); | 213 DCHECK(m_commitState == COMMIT_STATE_IDLE); |
206 DCHECK(m_outputSurfaceState == OUTPUT_SURFACE_LOST); | 214 DCHECK(m_outputSurfaceState == OUTPUT_SURFACE_LOST); |
207 m_outputSurfaceState = OUTPUT_SURFACE_RECREATING; | 215 m_outputSurfaceState = OUTPUT_SURFACE_RECREATING; |
208 return; | 216 return; |
209 | 217 |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 m_outputSurfaceState = OUTPUT_SURFACE_ACTIVE; | 328 m_outputSurfaceState = OUTPUT_SURFACE_ACTIVE; |
321 setNeedsCommit(); | 329 setNeedsCommit(); |
322 } | 330 } |
323 | 331 |
324 void SchedulerStateMachine::setMaximumNumberOfFailedDrawsBeforeDrawIsForced(int
numDraws) | 332 void SchedulerStateMachine::setMaximumNumberOfFailedDrawsBeforeDrawIsForced(int
numDraws) |
325 { | 333 { |
326 m_maximumNumberOfFailedDrawsBeforeDrawIsForced = numDraws; | 334 m_maximumNumberOfFailedDrawsBeforeDrawIsForced = numDraws; |
327 } | 335 } |
328 | 336 |
329 } // namespace cc | 337 } // namespace cc |
OLD | NEW |