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

Side by Side Diff: cc/CCScheduler.cpp

Issue 10911262: cc: Scheduler will never process a commit until it receives a vsync tick. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase 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/CCScheduler.h ('k') | cc/CCSchedulerTest.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 "CCScheduler.h" 7 #include "CCScheduler.h"
8 8
9 #include "TraceEvent.h" 9 #include "TraceEvent.h"
10 10
11 namespace WebCore { 11 namespace WebCore {
12 12
13 CCScheduler::CCScheduler(CCSchedulerClient* client, PassOwnPtr<CCFrameRateContro ller> frameRateController) 13 CCScheduler::CCScheduler(CCSchedulerClient* client, PassOwnPtr<CCFrameRateContro ller> frameRateController)
14 : m_client(client) 14 : m_client(client)
15 , m_frameRateController(frameRateController) 15 , m_frameRateController(frameRateController)
16 , m_hasMoreResourceUpdates(false)
16 , m_updateMoreResourcesPending(false) 17 , m_updateMoreResourcesPending(false)
17 { 18 {
18 ASSERT(m_client); 19 ASSERT(m_client);
19 m_frameRateController->setClient(this); 20 m_frameRateController->setClient(this);
20 m_frameRateController->setActive(m_stateMachine.vsyncCallbackNeeded()); 21 m_frameRateController->setActive(m_stateMachine.vsyncCallbackNeeded());
21 } 22 }
22 23
23 CCScheduler::~CCScheduler() 24 CCScheduler::~CCScheduler()
24 { 25 {
25 m_frameRateController->setActive(false); 26 m_frameRateController->setActive(false);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 m_stateMachine.setNeedsForcedRedraw(); 71 m_stateMachine.setNeedsForcedRedraw();
71 processScheduledActions(); 72 processScheduledActions();
72 } 73 }
73 74
74 void CCScheduler::setMainThreadNeedsLayerTextures() 75 void CCScheduler::setMainThreadNeedsLayerTextures()
75 { 76 {
76 m_stateMachine.setMainThreadNeedsLayerTextures(); 77 m_stateMachine.setMainThreadNeedsLayerTextures();
77 processScheduledActions(); 78 processScheduledActions();
78 } 79 }
79 80
80 void CCScheduler::beginFrameComplete() 81 void CCScheduler::beginFrameComplete(bool hasResourceUpdates)
81 { 82 {
82 TRACE_EVENT0("cc", "CCScheduler::beginFrameComplete"); 83 TRACE_EVENT0("cc", "CCScheduler::beginFrameComplete");
84 m_hasMoreResourceUpdates = hasResourceUpdates;
83 m_stateMachine.beginFrameComplete(); 85 m_stateMachine.beginFrameComplete();
84 processScheduledActions(); 86 processScheduledActions();
85 } 87 }
86 88
87 void CCScheduler::beginFrameAborted() 89 void CCScheduler::beginFrameAborted()
88 { 90 {
89 TRACE_EVENT0("cc", "CCScheduler::beginFrameAborted"); 91 TRACE_EVENT0("cc", "CCScheduler::beginFrameAborted");
90 m_stateMachine.beginFrameAborted(); 92 m_stateMachine.beginFrameAborted();
91 processScheduledActions(); 93 processScheduledActions();
92 } 94 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 126
125 void CCScheduler::setTimebaseAndInterval(double timebase, double intervalSeconds ) 127 void CCScheduler::setTimebaseAndInterval(double timebase, double intervalSeconds )
126 { 128 {
127 m_frameRateController->setTimebaseAndInterval(timebase, intervalSeconds); 129 m_frameRateController->setTimebaseAndInterval(timebase, intervalSeconds);
128 } 130 }
129 131
130 void CCScheduler::vsyncTick() 132 void CCScheduler::vsyncTick()
131 { 133 {
132 if (m_updateMoreResourcesPending) { 134 if (m_updateMoreResourcesPending) {
133 m_updateMoreResourcesPending = false; 135 m_updateMoreResourcesPending = false;
134 m_stateMachine.beginUpdateMoreResourcesComplete(m_client->hasMoreResourc eUpdates()); 136 ASSERT(m_hasMoreResourceUpdates);
137 m_stateMachine.beginUpdateMoreResourcesComplete(true);
135 } 138 }
136 TRACE_EVENT0("cc", "CCScheduler::vsyncTick"); 139 TRACE_EVENT0("cc", "CCScheduler::vsyncTick");
137 140
138 m_stateMachine.didEnterVSync(); 141 m_stateMachine.didEnterVSync();
139 processScheduledActions(); 142 processScheduledActions();
140 m_stateMachine.didLeaveVSync(); 143 m_stateMachine.didLeaveVSync();
141 } 144 }
142 145
146 void CCScheduler::updateResourcesComplete()
147 {
148 TRACE_EVENT0("cc", "CCScheduler::updateResourcesComplete");
149 if (m_updateMoreResourcesPending) {
150 m_updateMoreResourcesPending = false;
151 m_stateMachine.beginUpdateMoreResourcesComplete(false);
152 }
153 m_hasMoreResourceUpdates = false;
154 processScheduledActions();
155 }
156
143 void CCScheduler::processScheduledActions() 157 void CCScheduler::processScheduledActions()
144 { 158 {
145 // Early out so we don't spam TRACE_EVENTS with useless processScheduledActi ons. 159 // Early out so we don't spam TRACE_EVENTS with useless processScheduledActi ons.
146 if (m_stateMachine.nextAction() == CCSchedulerStateMachine::ACTION_NONE) { 160 if (m_stateMachine.nextAction() == CCSchedulerStateMachine::ACTION_NONE) {
147 m_frameRateController->setActive(m_stateMachine.vsyncCallbackNeeded()); 161 m_frameRateController->setActive(m_stateMachine.vsyncCallbackNeeded());
148 return; 162 return;
149 } 163 }
150 164
151 // This function can re-enter itself. For example, draw may call 165 // This function can re-enter itself. For example, draw may call
152 // setNeedsCommit. Proceeed with caution. 166 // setNeedsCommit. Proceeed with caution.
153 CCSchedulerStateMachine::Action action; 167 CCSchedulerStateMachine::Action action;
154 do { 168 do {
155 action = m_stateMachine.nextAction(); 169 action = m_stateMachine.nextAction();
156 m_stateMachine.updateState(action); 170 m_stateMachine.updateState(action);
157 TRACE_EVENT1("cc", "CCScheduler::processScheduledActions()", "action", a ction); 171 TRACE_EVENT1("cc", "CCScheduler::processScheduledActions()", "action", a ction);
158 172
159 switch (action) { 173 switch (action) {
160 case CCSchedulerStateMachine::ACTION_NONE: 174 case CCSchedulerStateMachine::ACTION_NONE:
161 break; 175 break;
162 case CCSchedulerStateMachine::ACTION_BEGIN_FRAME: 176 case CCSchedulerStateMachine::ACTION_BEGIN_FRAME:
163 m_client->scheduledActionBeginFrame(); 177 m_client->scheduledActionBeginFrame();
164 break; 178 break;
165 case CCSchedulerStateMachine::ACTION_BEGIN_UPDATE_MORE_RESOURCES: 179 case CCSchedulerStateMachine::ACTION_BEGIN_UPDATE_MORE_RESOURCES:
166 if (m_client->hasMoreResourceUpdates()) { 180 if (m_hasMoreResourceUpdates) {
167 m_client->scheduledActionUpdateMoreResources(m_frameRateControll er->nextTickTimeIfActivated()); 181 m_client->scheduledActionUpdateMoreResources(m_frameRateControll er->nextTickTimeIfActivated());
168 m_updateMoreResourcesPending = true; 182 m_updateMoreResourcesPending = true;
169 } else 183 } else
170 m_stateMachine.beginUpdateMoreResourcesComplete(false); 184 m_stateMachine.beginUpdateMoreResourcesComplete(false);
171 break; 185 break;
172 case CCSchedulerStateMachine::ACTION_COMMIT: 186 case CCSchedulerStateMachine::ACTION_COMMIT:
173 m_client->scheduledActionCommit(); 187 m_client->scheduledActionCommit();
174 break; 188 break;
175 case CCSchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE: { 189 case CCSchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE: {
176 CCScheduledActionDrawAndSwapResult result = m_client->scheduledActio nDrawAndSwapIfPossible(); 190 CCScheduledActionDrawAndSwapResult result = m_client->scheduledActio nDrawAndSwapIfPossible();
(...skipping 14 matching lines...) Expand all
191 m_client->scheduledActionAcquireLayerTexturesForMainThread(); 205 m_client->scheduledActionAcquireLayerTexturesForMainThread();
192 break; 206 break;
193 } 207 }
194 } while (action != CCSchedulerStateMachine::ACTION_NONE); 208 } while (action != CCSchedulerStateMachine::ACTION_NONE);
195 209
196 // Activate or deactivate the frame rate controller. 210 // Activate or deactivate the frame rate controller.
197 m_frameRateController->setActive(m_stateMachine.vsyncCallbackNeeded()); 211 m_frameRateController->setActive(m_stateMachine.vsyncCallbackNeeded());
198 } 212 }
199 213
200 } 214 }
OLDNEW
« no previous file with comments | « cc/CCScheduler.h ('k') | cc/CCSchedulerTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698