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

Side by Side Diff: cc/CCSchedulerStateMachine.cpp

Issue 10907075: Roll cc snapshot up to 127605 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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/CCSchedulerStateMachine.h ('k') | cc/CCSchedulerStateMachineTest.cpp » ('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 "TextStream.h"
9
8 10
9 namespace WebCore { 11 namespace WebCore {
10 12
11 CCSchedulerStateMachine::CCSchedulerStateMachine() 13 CCSchedulerStateMachine::CCSchedulerStateMachine()
12 : m_commitState(COMMIT_STATE_IDLE) 14 : m_commitState(COMMIT_STATE_IDLE)
13 , m_currentFrameNumber(0) 15 , m_currentFrameNumber(0)
14 , m_lastFrameNumberWhereDrawWasCalled(-1) 16 , m_lastFrameNumberWhereDrawWasCalled(-1)
15 , m_consecutiveFailedDraws(0) 17 , m_consecutiveFailedDraws(0)
16 , m_maximumNumberOfFailedDrawsBeforeDrawIsForced(3) 18 , m_maximumNumberOfFailedDrawsBeforeDrawIsForced(3)
17 , m_needsRedraw(false) 19 , m_needsRedraw(false)
18 , m_needsForcedRedraw(false) 20 , m_needsForcedRedraw(false)
19 , m_needsForcedRedrawAfterNextCommit(false) 21 , m_needsForcedRedrawAfterNextCommit(false)
20 , m_needsCommit(false) 22 , m_needsCommit(false)
21 , m_needsForcedCommit(false) 23 , m_needsForcedCommit(false)
22 , m_mainThreadNeedsLayerTextures(false) 24 , m_mainThreadNeedsLayerTextures(false)
23 , m_updateMoreResourcesPending(false) 25 , m_updateMoreResourcesPending(false)
24 , m_insideVSync(false) 26 , m_insideVSync(false)
25 , m_visible(false) 27 , m_visible(false)
26 , m_canBeginFrame(false) 28 , m_canBeginFrame(false)
27 , m_canDraw(true) 29 , m_canDraw(false)
28 , m_drawIfPossibleFailed(false) 30 , m_drawIfPossibleFailed(false)
29 , m_textureState(LAYER_TEXTURE_STATE_UNLOCKED) 31 , m_textureState(LAYER_TEXTURE_STATE_UNLOCKED)
30 , m_contextState(CONTEXT_ACTIVE) 32 , m_contextState(CONTEXT_ACTIVE)
31 { 33 {
32 } 34 }
33 35
36 String CCSchedulerStateMachine::toString()
37 {
38 TextStream ts;
39 ts << "m_commitState = " << m_commitState << "; ";
40 ts << "m_currentFrameNumber = " << m_currentFrameNumber << "; ";
41 ts << "m_lastFrameNumberWhereDrawWasCalled = " << m_lastFrameNumberWhereDraw WasCalled << "; ";
42 ts << "m_consecutiveFailedDraws = " << m_consecutiveFailedDraws << "; ";
43 ts << "m_maximumNumberOfFailedDrawsBeforeDrawIsForced = " << m_maximumNumber OfFailedDrawsBeforeDrawIsForced << "; ";
44 ts << "m_needsRedraw = " << m_needsRedraw << "; ";
45 ts << "m_needsForcedRedraw = " << m_needsForcedRedraw << "; ";
46 ts << "m_needsForcedRedrawAfterNextCommit = " << m_needsForcedRedrawAfterNex tCommit << "; ";
47 ts << "m_needsCommit = " << m_needsCommit << "; ";
48 ts << "m_needsForcedCommit = " << m_needsForcedCommit << "; ";
49 ts << "m_mainThreadNeedsLayerTextures = " << m_mainThreadNeedsLayerTextures << "; ";
50 ts << "m_updateMoreResourcesPending = " << m_updateMoreResourcesPending << " ; ";
51 ts << "m_insideVSync = " << m_insideVSync << "; ";
52 ts << "m_visible = " << m_visible << "; ";
53 ts << "m_canBeginFrame = " << m_canBeginFrame << "; ";
54 ts << "m_canDraw = " << m_canDraw << "; ";
55 ts << "m_drawIfPossibleFailed = " << m_drawIfPossibleFailed << "; ";
56 ts << "m_textureState = " << m_textureState << "; ";
57 ts << "m_contextState = " << m_contextState << "; ";
58 return ts.release();
59 }
60
34 bool CCSchedulerStateMachine::hasDrawnThisFrame() const 61 bool CCSchedulerStateMachine::hasDrawnThisFrame() const
35 { 62 {
36 return m_currentFrameNumber == m_lastFrameNumberWhereDrawWasCalled; 63 return m_currentFrameNumber == m_lastFrameNumberWhereDrawWasCalled;
37 } 64 }
38 65
39 bool CCSchedulerStateMachine::drawSuspendedUntilCommit() const 66 bool CCSchedulerStateMachine::drawSuspendedUntilCommit() const
40 { 67 {
41 if (!m_canDraw) 68 if (!m_canDraw)
42 return true; 69 return true;
43 if (!m_visible) 70 if (!m_visible)
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 230
204 void CCSchedulerStateMachine::setMainThreadNeedsLayerTextures() 231 void CCSchedulerStateMachine::setMainThreadNeedsLayerTextures()
205 { 232 {
206 ASSERT(!m_mainThreadNeedsLayerTextures); 233 ASSERT(!m_mainThreadNeedsLayerTextures);
207 ASSERT(m_textureState != LAYER_TEXTURE_STATE_ACQUIRED_BY_MAIN_THREAD); 234 ASSERT(m_textureState != LAYER_TEXTURE_STATE_ACQUIRED_BY_MAIN_THREAD);
208 m_mainThreadNeedsLayerTextures = true; 235 m_mainThreadNeedsLayerTextures = true;
209 } 236 }
210 237
211 bool CCSchedulerStateMachine::vsyncCallbackNeeded() const 238 bool CCSchedulerStateMachine::vsyncCallbackNeeded() const
212 { 239 {
213 if (!m_visible || m_contextState != CONTEXT_ACTIVE) { 240 // To prevent live-lock, we must always tick when updating resources.
214 if (m_needsForcedRedraw || m_commitState == COMMIT_STATE_UPDATING_RESOUR CES) 241 if (m_updateMoreResourcesPending || m_commitState == COMMIT_STATE_UPDATING_R ESOURCES)
215 return true; 242 return true;
216 243
244 // If we can't draw, don't tick until we are notified that we can draw again .
245 if (!m_canDraw)
217 return false; 246 return false;
218 }
219 247
220 return m_needsRedraw || m_needsForcedRedraw || m_commitState == COMMIT_STATE _UPDATING_RESOURCES; 248 if (m_needsForcedRedraw)
249 return true;
250
251 return m_needsRedraw && m_visible && m_contextState == CONTEXT_ACTIVE;
221 } 252 }
222 253
223 void CCSchedulerStateMachine::didEnterVSync() 254 void CCSchedulerStateMachine::didEnterVSync()
224 { 255 {
225 m_insideVSync = true; 256 m_insideVSync = true;
226 } 257 }
227 258
228 void CCSchedulerStateMachine::didLeaveVSync() 259 void CCSchedulerStateMachine::didLeaveVSync()
229 { 260 {
230 m_currentFrameNumber++; 261 m_currentFrameNumber++;
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 m_contextState = CONTEXT_ACTIVE; 339 m_contextState = CONTEXT_ACTIVE;
309 setNeedsCommit(); 340 setNeedsCommit();
310 } 341 }
311 342
312 void CCSchedulerStateMachine::setMaximumNumberOfFailedDrawsBeforeDrawIsForced(in t numDraws) 343 void CCSchedulerStateMachine::setMaximumNumberOfFailedDrawsBeforeDrawIsForced(in t numDraws)
313 { 344 {
314 m_maximumNumberOfFailedDrawsBeforeDrawIsForced = numDraws; 345 m_maximumNumberOfFailedDrawsBeforeDrawIsForced = numDraws;
315 } 346 }
316 347
317 } 348 }
OLDNEW
« no previous file with comments | « cc/CCSchedulerStateMachine.h ('k') | cc/CCSchedulerStateMachineTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698