Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1653)

Side by Side Diff: cc/scheduler_state_machine.cc

Issue 11192030: cc: Switch to Chromium DCHECKs LOGs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebaseonenne Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/scheduler.cc ('k') | cc/scheduler_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "config.h" 5 #include "config.h"
6 6
7 #include "CCSchedulerStateMachine.h" 7 #include "CCSchedulerStateMachine.h"
8 #include "base/logging.h"
8 #include "base/stringprintf.h" 9 #include "base/stringprintf.h"
9 10
10
11 namespace cc { 11 namespace cc {
12 12
13 CCSchedulerStateMachine::CCSchedulerStateMachine() 13 CCSchedulerStateMachine::CCSchedulerStateMachine()
14 : m_commitState(COMMIT_STATE_IDLE) 14 : m_commitState(COMMIT_STATE_IDLE)
15 , m_currentFrameNumber(0) 15 , m_currentFrameNumber(0)
16 , m_lastFrameNumberWhereDrawWasCalled(-1) 16 , m_lastFrameNumberWhereDrawWasCalled(-1)
17 , m_consecutiveFailedDraws(0) 17 , m_consecutiveFailedDraws(0)
18 , m_maximumNumberOfFailedDrawsBeforeDrawIsForced(3) 18 , m_maximumNumberOfFailedDrawsBeforeDrawIsForced(3)
19 , m_needsRedraw(false) 19 , m_needsRedraw(false)
20 , m_needsForcedRedraw(false) 20 , m_needsForcedRedraw(false)
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 return false; 96 return false;
97 return true; 97 return true;
98 } 98 }
99 99
100 bool CCSchedulerStateMachine::shouldAcquireLayerTexturesForMainThread() const 100 bool CCSchedulerStateMachine::shouldAcquireLayerTexturesForMainThread() const
101 { 101 {
102 if (!m_mainThreadNeedsLayerTextures) 102 if (!m_mainThreadNeedsLayerTextures)
103 return false; 103 return false;
104 if (m_textureState == LAYER_TEXTURE_STATE_UNLOCKED) 104 if (m_textureState == LAYER_TEXTURE_STATE_UNLOCKED)
105 return true; 105 return true;
106 ASSERT(m_textureState == LAYER_TEXTURE_STATE_ACQUIRED_BY_IMPL_THREAD); 106 DCHECK(m_textureState == LAYER_TEXTURE_STATE_ACQUIRED_BY_IMPL_THREAD);
107 // Transfer the lock from impl thread to main thread immediately if the 107 // Transfer the lock from impl thread to main thread immediately if the
108 // impl thread is not even scheduled to draw. Guards against deadlocking. 108 // impl thread is not even scheduled to draw. Guards against deadlocking.
109 if (!scheduledToDraw()) 109 if (!scheduledToDraw())
110 return true; 110 return true;
111 if (!vsyncCallbackNeeded()) 111 if (!vsyncCallbackNeeded())
112 return true; 112 return true;
113 return false; 113 return false;
114 } 114 }
115 115
116 CCSchedulerStateMachine::Action CCSchedulerStateMachine::nextAction() const 116 CCSchedulerStateMachine::Action CCSchedulerStateMachine::nextAction() const
(...skipping 27 matching lines...) Expand all
144 case COMMIT_STATE_WAITING_FOR_FIRST_DRAW: 144 case COMMIT_STATE_WAITING_FOR_FIRST_DRAW:
145 if (shouldDraw() || m_contextState == CONTEXT_LOST) 145 if (shouldDraw() || m_contextState == CONTEXT_LOST)
146 return m_needsForcedRedraw ? ACTION_DRAW_FORCED : ACTION_DRAW_IF_POS SIBLE; 146 return m_needsForcedRedraw ? ACTION_DRAW_FORCED : ACTION_DRAW_IF_POS SIBLE;
147 // COMMIT_STATE_WAITING_FOR_FIRST_DRAW wants to enforce a draw. If m_can Draw is false 147 // COMMIT_STATE_WAITING_FOR_FIRST_DRAW wants to enforce a draw. If m_can Draw is false
148 // or textures are not available, proceed to the next step (similar as i n COMMIT_STATE_IDLE). 148 // or textures are not available, proceed to the next step (similar as i n COMMIT_STATE_IDLE).
149 bool canCommit = m_visible || m_needsForcedCommit; 149 bool canCommit = m_visible || m_needsForcedCommit;
150 if (m_needsCommit && canCommit && drawSuspendedUntilCommit()) 150 if (m_needsCommit && canCommit && drawSuspendedUntilCommit())
151 return ACTION_BEGIN_FRAME; 151 return ACTION_BEGIN_FRAME;
152 return ACTION_NONE; 152 return ACTION_NONE;
153 } 153 }
154 ASSERT_NOT_REACHED(); 154 NOTREACHED();
155 return ACTION_NONE; 155 return ACTION_NONE;
156 } 156 }
157 157
158 void CCSchedulerStateMachine::updateState(Action action) 158 void CCSchedulerStateMachine::updateState(Action action)
159 { 159 {
160 switch (action) { 160 switch (action) {
161 case ACTION_NONE: 161 case ACTION_NONE:
162 return; 162 return;
163 163
164 case ACTION_BEGIN_FRAME: 164 case ACTION_BEGIN_FRAME:
165 ASSERT(m_visible || m_needsForcedCommit); 165 DCHECK(m_visible || m_needsForcedCommit);
166 m_commitState = COMMIT_STATE_FRAME_IN_PROGRESS; 166 m_commitState = COMMIT_STATE_FRAME_IN_PROGRESS;
167 m_needsCommit = false; 167 m_needsCommit = false;
168 m_needsForcedCommit = false; 168 m_needsForcedCommit = false;
169 return; 169 return;
170 170
171 case ACTION_COMMIT: 171 case ACTION_COMMIT:
172 m_commitState = COMMIT_STATE_WAITING_FOR_FIRST_DRAW; 172 m_commitState = COMMIT_STATE_WAITING_FOR_FIRST_DRAW;
173 m_needsRedraw = true; 173 m_needsRedraw = true;
174 if (m_drawIfPossibleFailed) 174 if (m_drawIfPossibleFailed)
175 m_lastFrameNumberWhereDrawWasCalled = -1; 175 m_lastFrameNumberWhereDrawWasCalled = -1;
(...skipping 13 matching lines...) Expand all
189 m_drawIfPossibleFailed = false; 189 m_drawIfPossibleFailed = false;
190 if (m_insideVSync) 190 if (m_insideVSync)
191 m_lastFrameNumberWhereDrawWasCalled = m_currentFrameNumber; 191 m_lastFrameNumberWhereDrawWasCalled = m_currentFrameNumber;
192 if (m_commitState == COMMIT_STATE_WAITING_FOR_FIRST_DRAW) 192 if (m_commitState == COMMIT_STATE_WAITING_FOR_FIRST_DRAW)
193 m_commitState = COMMIT_STATE_IDLE; 193 m_commitState = COMMIT_STATE_IDLE;
194 if (m_textureState == LAYER_TEXTURE_STATE_ACQUIRED_BY_IMPL_THREAD) 194 if (m_textureState == LAYER_TEXTURE_STATE_ACQUIRED_BY_IMPL_THREAD)
195 m_textureState = LAYER_TEXTURE_STATE_UNLOCKED; 195 m_textureState = LAYER_TEXTURE_STATE_UNLOCKED;
196 return; 196 return;
197 197
198 case ACTION_BEGIN_CONTEXT_RECREATION: 198 case ACTION_BEGIN_CONTEXT_RECREATION:
199 ASSERT(m_commitState == COMMIT_STATE_IDLE); 199 DCHECK(m_commitState == COMMIT_STATE_IDLE);
200 ASSERT(m_contextState == CONTEXT_LOST); 200 DCHECK(m_contextState == CONTEXT_LOST);
201 m_contextState = CONTEXT_RECREATING; 201 m_contextState = CONTEXT_RECREATING;
202 return; 202 return;
203 203
204 case ACTION_ACQUIRE_LAYER_TEXTURES_FOR_MAIN_THREAD: 204 case ACTION_ACQUIRE_LAYER_TEXTURES_FOR_MAIN_THREAD:
205 m_textureState = LAYER_TEXTURE_STATE_ACQUIRED_BY_MAIN_THREAD; 205 m_textureState = LAYER_TEXTURE_STATE_ACQUIRED_BY_MAIN_THREAD;
206 m_mainThreadNeedsLayerTextures = false; 206 m_mainThreadNeedsLayerTextures = false;
207 if (m_commitState != COMMIT_STATE_FRAME_IN_PROGRESS) 207 if (m_commitState != COMMIT_STATE_FRAME_IN_PROGRESS)
208 m_needsCommit = true; 208 m_needsCommit = true;
209 return; 209 return;
210 } 210 }
211 } 211 }
212 212
213 void CCSchedulerStateMachine::setMainThreadNeedsLayerTextures() 213 void CCSchedulerStateMachine::setMainThreadNeedsLayerTextures()
214 { 214 {
215 ASSERT(!m_mainThreadNeedsLayerTextures); 215 DCHECK(!m_mainThreadNeedsLayerTextures);
216 ASSERT(m_textureState != LAYER_TEXTURE_STATE_ACQUIRED_BY_MAIN_THREAD); 216 DCHECK(m_textureState != LAYER_TEXTURE_STATE_ACQUIRED_BY_MAIN_THREAD);
217 m_mainThreadNeedsLayerTextures = true; 217 m_mainThreadNeedsLayerTextures = true;
218 } 218 }
219 219
220 bool CCSchedulerStateMachine::vsyncCallbackNeeded() const 220 bool CCSchedulerStateMachine::vsyncCallbackNeeded() const
221 { 221 {
222 // If we can't draw, don't tick until we are notified that we can draw again . 222 // If we can't draw, don't tick until we are notified that we can draw again .
223 if (!m_canDraw) 223 if (!m_canDraw)
224 return false; 224 return false;
225 225
226 if (m_needsForcedRedraw) 226 if (m_needsForcedRedraw)
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 m_needsCommit = true; 277 m_needsCommit = true;
278 } 278 }
279 279
280 void CCSchedulerStateMachine::setNeedsForcedCommit() 280 void CCSchedulerStateMachine::setNeedsForcedCommit()
281 { 281 {
282 m_needsForcedCommit = true; 282 m_needsForcedCommit = true;
283 } 283 }
284 284
285 void CCSchedulerStateMachine::beginFrameComplete() 285 void CCSchedulerStateMachine::beginFrameComplete()
286 { 286 {
287 ASSERT(m_commitState == COMMIT_STATE_FRAME_IN_PROGRESS); 287 DCHECK(m_commitState == COMMIT_STATE_FRAME_IN_PROGRESS);
288 m_commitState = COMMIT_STATE_READY_TO_COMMIT; 288 m_commitState = COMMIT_STATE_READY_TO_COMMIT;
289 } 289 }
290 290
291 void CCSchedulerStateMachine::beginFrameAborted() 291 void CCSchedulerStateMachine::beginFrameAborted()
292 { 292 {
293 ASSERT(m_commitState == COMMIT_STATE_FRAME_IN_PROGRESS); 293 DCHECK(m_commitState == COMMIT_STATE_FRAME_IN_PROGRESS);
294 m_commitState = COMMIT_STATE_IDLE; 294 m_commitState = COMMIT_STATE_IDLE;
295 setNeedsCommit(); 295 setNeedsCommit();
296 } 296 }
297 297
298 void CCSchedulerStateMachine::didLoseContext() 298 void CCSchedulerStateMachine::didLoseContext()
299 { 299 {
300 if (m_contextState == CONTEXT_LOST || m_contextState == CONTEXT_RECREATING) 300 if (m_contextState == CONTEXT_LOST || m_contextState == CONTEXT_RECREATING)
301 return; 301 return;
302 m_contextState = CONTEXT_LOST; 302 m_contextState = CONTEXT_LOST;
303 } 303 }
304 304
305 void CCSchedulerStateMachine::didRecreateContext() 305 void CCSchedulerStateMachine::didRecreateContext()
306 { 306 {
307 ASSERT(m_contextState == CONTEXT_RECREATING); 307 DCHECK(m_contextState == CONTEXT_RECREATING);
308 m_contextState = CONTEXT_ACTIVE; 308 m_contextState = CONTEXT_ACTIVE;
309 setNeedsCommit(); 309 setNeedsCommit();
310 } 310 }
311 311
312 void CCSchedulerStateMachine::setMaximumNumberOfFailedDrawsBeforeDrawIsForced(in t numDraws) 312 void CCSchedulerStateMachine::setMaximumNumberOfFailedDrawsBeforeDrawIsForced(in t numDraws)
313 { 313 {
314 m_maximumNumberOfFailedDrawsBeforeDrawIsForced = numDraws; 314 m_maximumNumberOfFailedDrawsBeforeDrawIsForced = numDraws;
315 } 315 }
316 316
317 } 317 }
OLDNEW
« no previous file with comments | « cc/scheduler.cc ('k') | cc/scheduler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698